Merge branch 'toys'

* toys:
  Fix time format and Output file option parsing
  Add track totals
  Hide obsolete files
  Show off
This commit is contained in:
Vincent Riquer 2013-10-06 03:15:19 +02:00
commit 5dabbd69c6

View File

@ -43,6 +43,7 @@ do
source "$function" source "$function"
done done
args="$@"
while [ -n "$1" ] while [ -n "$1" ]
do do
opt="$1" opt="$1"
@ -59,6 +60,7 @@ do
'-g') show+=(genres) ;; '-g') show+=(genres) ;;
'-m') show+=(oldtimestamp) ;; '-m') show+=(oldtimestamp) ;;
'-M') show+=(types) ;; '-M') show+=(types) ;;
'-N') show+=(tracktotals) ;;
'-p') show+=(performers) ;; '-p') show+=(performers) ;;
'-s') show+=(rates) ;; '-s') show+=(rates) ;;
'-B') show+=(depths) ;; '-B') show+=(depths) ;;
@ -67,8 +69,10 @@ do
'-#') show+=(count) ;; '-#') show+=(count) ;;
'-T') timeformat="$1" '-T') timeformat="$1"
shift
continue ;; continue ;;
'-o') output="$1" '-o') output="$1"
shift
continue ;; continue ;;
'-u') update=1 '-u') update=1
continue ;; continue ;;
@ -99,6 +103,7 @@ done
-d Disc -d Disc
-g Genre -g Genre
-p Performer -p Performer
-N Track total
-t Title -t Title
-y Year -y Year
@ -194,11 +199,27 @@ then
updateTags updateTags
fi fi
echo 'SELECT IFNULL(
(SELECT last_seen FROM source_files ORDER BY last_seen DESC LIMIT 1),
0);' >&3
read -u4 lastupdate
if ! [[ "$output" == - ]] if ! [[ "$output" == - ]]
then then
exec > "$output" exec > "$output"
fi fi
cat <<-EOBrag
# Generated by AtOM's createindex toy.
# https://gitorious.org/atom
# (C) 2012-2013 Vincent Riquer (GPL-3)
#
# $0 $args
#
# Last database update: $(date -d @$lastupdate +'%x %X')
EOBrag
printDate() { printDate() {
date -d"@$1" +"${timeformat:-%x %X}" date -d"@$1" +"${timeformat:-%x %X}"
} }
@ -224,6 +245,7 @@ do
performers) info='Performer' ;; performers) info='Performer' ;;
rates) info='Sample rate' ;; rates) info='Sample rate' ;;
titles) info='Title' ;; titles) info='Title' ;;
tracktotals) info='Track total' ;;
years) info='Date' ;; years) info='Date' ;;
esac esac
printtmp="${info:0:$locallength}" printtmp="${info:0:$locallength}"
@ -254,6 +276,7 @@ SELECT
tags.genre, tags.genre,
tags.performer, tags.performer,
tags.title, tags.title,
tags.track,
tags.year tags.year
FROM source_files FROM source_files
INNER JOIN mime_types INNER JOIN mime_types
@ -263,6 +286,7 @@ FROM source_files
WHERE WHERE
NOT mime_types.mime_text LIKE "text/%" NOT mime_types.mime_text LIKE "text/%"
AND NOT mime_types.mime_text LIKE "image/%" AND NOT mime_types.mime_text LIKE "image/%"
AND last_seen = '$lastupdate'
ORDER BY source_files.filename ORDER BY source_files.filename
COLLATE NOCASE; COLLATE NOCASE;
@ -309,6 +333,9 @@ do
rest="${rest#*::AtOM:SQL:Sep::}" rest="${rest#*::AtOM:SQL:Sep::}"
title="${rest%%::AtOM:SQL:Sep::*}" title="${rest%%::AtOM:SQL:Sep::*}"
rest="${rest#*::AtOM:SQL:Sep::}" rest="${rest#*::AtOM:SQL:Sep::}"
track="${rest%%::AtOM:SQL:Sep::*}"
tracktotal=${track#*/}
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::}"
case $mimetype in case $mimetype in
@ -432,6 +459,13 @@ do
[ -n "$title" ] \ [ -n "$title" ] \
&& titles+="${titles+,}$title" && titles+="${titles+,}$title"
fi fi
if ! [[ $tracktotals =~ $expr1"$tracktotal"$expr2 ]]
then
[ -z "$tracktotals" ] \
&& unset tracktotals
[ -n "$tracktotal" ] \
&& tracktotals+="${tracktotals+,}$tracktotal"
fi
if ! [[ $years =~ $expr1"$year"$expr2 ]] if ! [[ $years =~ $expr1"$year"$expr2 ]]
then then
[ -z "$years" ] \ [ -z "$years" ] \
@ -457,6 +491,7 @@ do
genres="$genre" genres="$genre"
performers="$performer" performers="$performer"
titles="$title" titles="$title"
tracktotals="$tracktotal"
years="$year" years="$year"
count=1 count=1
(( bitrate )) && (( bitrates=bitrate )) (( bitrate )) && (( bitrates=bitrate ))