Merge branch 'toys'

This commit is contained in:
Vincent Riquer 2013-09-28 00:34:03 +02:00
commit cf3652c028

View File

@ -61,14 +61,19 @@ do
'-M') show+=(types) ;; '-M') show+=(types) ;;
'-p') show+=(performers) ;; '-p') show+=(performers) ;;
'-s') show+=(rates) ;; '-s') show+=(rates) ;;
'-B') show+=(depths) ;;
'-t') show+=(titles) ;; '-t') show+=(titles) ;;
'-y') show+=(years) ;; '-y') show+=(years) ;;
'-#') show+=(count) ;;
'-T') timeformat="$OPTARG" ;; '-T') timeformat="$1"
continue ;;
'-o') output="$1" '-o') output="$1"
continue ;; continue ;;
'-u') update=1 ;; '-u') update=1
'-D') (( debug++ )) ;; continue ;;
'-D') (( debug++ ))
continue ;;
[0-9]*) length[count-1]=$opt [0-9]*) length[count-1]=$opt
continue ;; continue ;;
esac esac
@ -79,9 +84,11 @@ done
cat <<-EOHelp cat <<-EOHelp
No output specified! No output specified!
-f Path -f Path
-# File count
-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
@ -110,11 +117,6 @@ openDatabase
columns="${show[@]//*/-}" columns="${show[@]//*/-}"
if ! [[ "$output" == - ]]
then
exec > "$output"
fi
printPath() { printPath() {
for key in ${!pathparts[@]} for key in ${!pathparts[@]}
do do
@ -136,12 +138,18 @@ printline() {
path="$olddir" path="$olddir"
case $info in case $info in
'bitrates') 'bitrates')
info=$((bitrates/count)) info=$(
printf %${locallength}d \
$((bitrates/count))
)
(( info )) || unset info (( info )) || unset info
;; ;;
'oldtimestamp') 'oldtimestamp')
info=$(printDate ${!info}) info=$(printDate ${!info})
;; ;;
'count')
info=$(printf %${locallength}d $count)
;;
'path') 'path')
while [[ $path =~ / ]] while [[ $path =~ / ]]
do do
@ -186,6 +194,11 @@ then
updateTags updateTags
fi fi
if ! [[ "$output" == - ]]
then
exec > "$output"
fi
printDate() { printDate() {
date -d"@$1" +"${timeformat:-%x %X}" date -d"@$1" +"${timeformat:-%x %X}"
} }
@ -195,21 +208,23 @@ do
info="${show[index]}" info="${show[index]}"
locallength="${length[index]:=50}" locallength="${length[index]:=50}"
case $info in case $info in
albumartists) info="Album artist" ;; albumartists) info='Album artist' ;;
albums) info="Album" ;; albums) info='Album' ;;
artists) info="Artist" ;; artists) info='Artist' ;;
bitrates) info="Bitrate" ;; bitrates) info='Bitrate' ;;
composers) info="Composer" ;; depths) info='Bit depth' ;;
channelss) info="Channels" ;; channelss) info='Channels' ;;
discs) info="Disc" ;; composers) info='Composer' ;;
path) info="Directory name" ;; count) info='#' ;;
genres) info="Genre" ;; discs) info='Disc' ;;
oldtimestamp) info="Last modified" ;; path) info='Directory name' ;;
types) info="Format" ;; genres) info='Genre' ;;
performers) info="Performer" ;; oldtimestamp) info='Last modified' ;;
rates) info="Sample rate" ;; types) info='Format' ;;
titles) info="Title" ;; performers) info='Performer' ;;
years) info="Date" ;; rates) info='Sample rate' ;;
titles) info='Title' ;;
years) info='Date' ;;
esac esac
printtmp="${info:0:$locallength}" printtmp="${info:0:$locallength}"
until (( ${#printtmp} == locallength )) until (( ${#printtmp} == locallength ))
@ -228,6 +243,7 @@ SELECT
tags.bitrate, tags.bitrate,
tags.channels, tags.channels,
tags.rate, tags.rate,
tags.depth,
source_files.last_change, source_files.last_change,
mime_types.mime_text, mime_types.mime_text,
tags.albumartist, tags.albumartist,
@ -270,6 +286,8 @@ do
rest="${rest#*::AtOM:SQL:Sep::}" rest="${rest#*::AtOM:SQL:Sep::}"
rate="${rest%%::AtOM:SQL:Sep::*}" rate="${rest%%::AtOM:SQL:Sep::*}"
rest="${rest#*::AtOM:SQL:Sep::}" rest="${rest#*::AtOM:SQL:Sep::}"
depth="${rest%%::AtOM:SQL:Sep::*}"
rest="${rest#*::AtOM:SQL:Sep::}"
timestamp="${rest%%::AtOM:SQL:Sep::*}" timestamp="${rest%%::AtOM:SQL:Sep::*}"
timestamp="${timestamp%%.*}" timestamp="${timestamp%%.*}"
rest="${rest#*::AtOM:SQL:Sep::}" rest="${rest#*::AtOM:SQL:Sep::}"
@ -310,7 +328,8 @@ do
esac esac
if [[ $dir == $olddir ]] if [[ $dir == $olddir ]]
then then
(( $bitrate )) && (( count++ , bitrates+=bitrate )) (( count++ ))
(( $bitrate )) && (( bitrates+=bitrate ))
(( ((
oldtimestamp = ( oldtimestamp = (
timestamp > oldtimestamp timestamp > oldtimestamp
@ -340,6 +359,16 @@ do
rates+="${rates+,}$rate" rates+="${rates+,}$rate"
fi fi
fi fi
if [ -n "$depth" ] && ! [[ $depths =~ $expr1"$depth"$expr2 ]]
then
if [ -n "$depths" ] \
&& (( depth < ${depths%%,*} ))
then
depths="$depth,$depths"
else
depths+="${depths+,}$depth"
fi
fi
if ! [[ $types =~ $expr1"$type"$expr2 ]] if ! [[ $types =~ $expr1"$type"$expr2 ]]
then then
[ -z "$types" ] \ [ -z "$types" ] \
@ -418,6 +447,7 @@ do
unset bitrates unset bitrates
channelss="$channels" channelss="$channels"
rates="$rate" rates="$rate"
depths="$depth"
types="$type" types="$type"
albumartists="$albumartist" albumartists="$albumartist"
albums="$album" albums="$album"
@ -428,7 +458,8 @@ do
performers="$performer" performers="$performer"
titles="$title" titles="$title"
years="$year" years="$year"
(( bitrate )) && (( count=1 , bitrates=bitrate )) count=1
(( bitrate )) && (( bitrates=bitrate ))
oldmimetype=$mimetype oldmimetype=$mimetype
oldrate=$rate oldrate=$rate
oldtimestamp=$timestamp oldtimestamp=$timestamp