From 38ca7637bbf1474593d79bb1740d78ee0966f1a7 Mon Sep 17 00:00:00 2001 From: Vincent Riquer Date: Sun, 20 Oct 2013 02:00:25 +0200 Subject: [PATCH 1/2] createindex: -S: show size --- toys/createindex | 59 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) 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 From 4c166bbc59ed93e4a9188b5a7e5102f7aebf905e Mon Sep 17 00:00:00 2001 From: Vincent Riquer Date: Sun, 20 Oct 2013 02:02:18 +0200 Subject: [PATCH 2/2] Update documentation --- toys/README | 7 +++++-- toys/createindex | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) 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 25bb520..487ff8c 100755 --- a/toys/createindex +++ b/toys/createindex @@ -91,6 +91,7 @@ done No output specified! -f Path -# File count + -S Size -b Average bitrate -C Channels -s Sample rate