Merge branch 'toys'

* toys:
  Update documentation
  createindex: -S: show size
This commit is contained in:
Vincent Riquer 2013-10-20 02:03:07 +02:00
commit ae32fab334
2 changed files with 64 additions and 3 deletions

View File

@ -9,9 +9,12 @@ width (default: 50).
Options: Options:
-f: Path -f: Path
-#: File count
-S: Size
-b: Average bitrate -b: Average bitrate
-C: Channels -C: Channels
-s: Sample rate -s: Sample rate
-B: Bits per sample
-m: Mofification time -m: Mofification time
-M: Format -M: Format
@ -22,12 +25,12 @@ Options:
-d: Disc -d: Disc
-g: Genre -g: Genre
-p: Performer -p: Performer
-N: Track total
-t: Title -t: Title
-y: Year -y: Year
-T <format>: date-time format (see 'man date' for possible values) -T <format>: date-time format (see 'man date' for possible values)
-o -|<file>: output file (path relative to Source) - mandatory - must -o -|<file>: output file - mandatory.
appear last.
-u: update database first -u: update database first
-D: debug -D: debug

View File

@ -63,6 +63,8 @@ do
'-N') show+=(tracktotals) ;; '-N') show+=(tracktotals) ;;
'-p') show+=(performers) ;; '-p') show+=(performers) ;;
'-s') show+=(rates) ;; '-s') show+=(rates) ;;
'-S') show+=(size)
length[count]=5 ;;
'-B') show+=(depths) ;; '-B') show+=(depths) ;;
'-t') show+=(titles) ;; '-t') show+=(titles) ;;
'-y') show+=(years) ;; '-y') show+=(years) ;;
@ -89,6 +91,7 @@ done
No output specified! No output specified!
-f Path -f Path
-# File count -# File count
-S Size
-b Average bitrate -b Average bitrate
-C Channels -C Channels
-s Sample rate -s Sample rate
@ -170,6 +173,55 @@ printline() {
done done
unset pathparts unset pathparts
;; ;;
'size')
if (( size > 1073741823 ))
then
info=$(( (size * 1000) / 1073741824 ))
int=$(( info / 1000 ))
if (( ${#int} > 2 ))
then
info=$(printf %4sG $int)
else
info=$(
printf %2s.%.1sG\
$int \
${info#int}
)
fi
elif (( size > 1048575 ))
then
info=$(( (size * 1000) / 1048576 ))
int=$(( info / 1000 ))
if (( ${#int} > 2 ))
then
info=$(printf %4sM $int)
else
info=$(
printf %2s.%.1sM\
$int \
${info#int}
)
fi
suffix=M
elif (( size > 1023 ))
then
info=$(( (size * 1000) / 1024 ))
int=$(( info / 1000 ))
if (( ${#int} > 2 ))
then
info=$(printf %4sk $int)
else
info=$(
printf %2s.%.1sk\
$int \
${info#int}
)
fi
else
info=$size
info=$(printf %4s $size)
fi
;;
*) *)
info="${!info}" info="${!info}"
;; ;;
@ -247,6 +299,7 @@ do
titles) info='Title' ;; titles) info='Title' ;;
tracktotals) info='Track total' ;; tracktotals) info='Track total' ;;
years) info='Date' ;; years) info='Date' ;;
size) info='Size' ;;
esac esac
printtmp="${info:0:$locallength}" printtmp="${info:0:$locallength}"
until (( ${#printtmp} == locallength )) until (( ${#printtmp} == locallength ))
@ -277,7 +330,8 @@ SELECT
tags.performer, tags.performer,
tags.title, tags.title,
tags.track, tags.track,
tags.year tags.year,
source_files.size
FROM source_files FROM source_files
INNER JOIN mime_types INNER JOIN mime_types
ON source_files.mime_type=mime_types.id ON source_files.mime_type=mime_types.id
@ -338,6 +392,8 @@ do
rest="${rest#*::AtOM:SQL:Sep::}" rest="${rest#*::AtOM:SQL:Sep::}"
year="${rest%%::AtOM:SQL:Sep::*}" year="${rest%%::AtOM:SQL:Sep::*}"
rest="${rest#*::AtOM:SQL:Sep::}" rest="${rest#*::AtOM:SQL:Sep::}"
filesize="${rest%%::AtOM:SQL:Sep::*}"
rest="${rest#*::AtOM:SQL:Sep::}"
case $mimetype in case $mimetype in
application/ogg\ opus) type=Opus ;; application/ogg\ opus) type=Opus ;;
application/ogg\ vorbis) type=Vorbis ;; application/ogg\ vorbis) type=Vorbis ;;
@ -355,6 +411,7 @@ do
esac esac
if [[ $dir == $olddir ]] if [[ $dir == $olddir ]]
then then
(( size += filesize ))
(( count++ )) (( count++ ))
(( $bitrate )) && (( bitrates+=bitrate )) (( $bitrate )) && (( bitrates+=bitrate ))
(( ((
@ -493,6 +550,7 @@ do
titles="$title" titles="$title"
tracktotals="$tracktotal" tracktotals="$tracktotal"
years="$year" years="$year"
size="$filesize"
count=1 count=1
(( bitrate )) && (( bitrates=bitrate )) (( bitrate )) && (( bitrates=bitrate ))
oldmimetype=$mimetype oldmimetype=$mimetype