diff --git a/toys/createindex b/toys/createindex index 4b32af2..25bb520 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) ;; @@ -170,6 +172,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 +298,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 +329,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 +391,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 +410,7 @@ do esac if [[ $dir == $olddir ]] then + (( size += filesize )) (( count++ )) (( $bitrate )) && (( bitrates+=bitrate )) (( @@ -493,6 +549,7 @@ do titles="$title" tracktotals="$tracktotal" years="$year" + size="$filesize" count=1 (( bitrate )) && (( bitrates=bitrate )) oldmimetype=$mimetype