diff --git a/toys/README b/toys/README index f9f57ab..8840acd 100644 --- a/toys/README +++ b/toys/README @@ -9,9 +9,12 @@ width (default: 50). Options: -f: Path + -#: File count + -S: Size -b: Average bitrate -C: Channels -s: Sample rate + -B: Bits per sample -m: Mofification time -M: Format @@ -22,12 +25,12 @@ Options: -d: Disc -g: Genre -p: Performer + -N: Track total -t: Title -y: Year -T : date-time format (see 'man date' for possible values) - -o -|: output file (path relative to Source) - mandatory - must - appear last. + -o -|: output file - mandatory. -u: update database first -D: debug diff --git a/toys/createindex b/toys/createindex index 4b32af2..487ff8c 100755 --- a/toys/createindex +++ b/toys/createindex @@ -63,6 +63,8 @@ do '-N') show+=(tracktotals) ;; '-p') show+=(performers) ;; '-s') show+=(rates) ;; + '-S') show+=(size) + length[count]=5 ;; '-B') show+=(depths) ;; '-t') show+=(titles) ;; '-y') show+=(years) ;; @@ -89,6 +91,7 @@ done No output specified! -f Path -# File count + -S Size -b Average bitrate -C Channels -s Sample rate @@ -170,6 +173,55 @@ printline() { done 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}" ;; @@ -247,6 +299,7 @@ do titles) info='Title' ;; tracktotals) info='Track total' ;; years) info='Date' ;; + size) info='Size' ;; esac printtmp="${info:0:$locallength}" until (( ${#printtmp} == locallength )) @@ -277,7 +330,8 @@ SELECT tags.performer, tags.title, tags.track, - tags.year + tags.year, + source_files.size FROM source_files INNER JOIN mime_types ON source_files.mime_type=mime_types.id @@ -338,6 +392,8 @@ do rest="${rest#*::AtOM:SQL:Sep::}" year="${rest%%::AtOM:SQL:Sep::*}" rest="${rest#*::AtOM:SQL:Sep::}" + filesize="${rest%%::AtOM:SQL:Sep::*}" + rest="${rest#*::AtOM:SQL:Sep::}" case $mimetype in application/ogg\ opus) type=Opus ;; application/ogg\ vorbis) type=Vorbis ;; @@ -355,6 +411,7 @@ do esac if [[ $dir == $olddir ]] then + (( size += filesize )) (( count++ )) (( $bitrate )) && (( bitrates+=bitrate )) (( @@ -493,6 +550,7 @@ do titles="$title" tracktotals="$tracktotal" years="$year" + size="$filesize" count=1 (( bitrate )) && (( bitrates=bitrate )) oldmimetype=$mimetype