Merge branch 'master' into toys

This commit is contained in:
Vincent Riquer 2013-05-04 02:11:02 +02:00
commit c5d35386b5
15 changed files with 419 additions and 310 deletions

23
README
View File

@ -52,3 +52,26 @@ AtOM requires a database to function. Now that we have a database containing
various information about our media files, why not use it? various information about our media files, why not use it?
AtOM comes with a small set of tools in the toys/ directory. These are AtOM comes with a small set of tools in the toys/ directory. These are
documented in toys/README. documented in toys/README.
========================
Shameless Self Promotion
------------------------
I am the author of free (Creative Commons CC-By-SA) music which you can stream
for free, or buy to get high quality and bonuses from Bandcamp
(http://djblackred.bandcamp.com). If you like electronic music taking its
inspiration from Trance, Drum & Bass, Ambient and (rarely) Free Jazz, please
check it out!
Downloads are available in FLAC, Ogg, MP3, and more, and includes the "source
code" (sequencer files and the likes) for most tracks.
I am receiving 85% of the money you'll spend, so you won't be feeding some
greedy BigCorp producer or distributor.
And if you don't like it, you can still spread the word to friends who may like.
You can see this as a way to thank me for this piece of code.
=====
Legal
-----
Some of the format and/or tool names cited above are trademarks belonging to
their rightful owners. AtOM and its authors are not linked in any way to
those companies or individuals. Said companies do not endorse nor support
AtOM in any way.

246
atom
View File

@ -144,8 +144,8 @@ removed=0
read -u4 line read -u4 line
until [[ $line == AtOM:NoMoreFiles ]] until [[ $line == AtOM:NoMoreFiles ]]
do do
id=${line%|*} id=${line%::AtOM:SQL:Sep::*}
filename=${line#*|} filename=${line#*::AtOM:SQL:Sep::}
if [ -n "$filename" ] if [ -n "$filename" ]
then then
if rm -f "$filename" if rm -f "$filename"
@ -161,115 +161,7 @@ do
done done
echo "Suppressed $deleted files, $removed removed from database" echo "Suppressed $deleted files, $removed removed from database"
# get files updateTags
for reader in "${tagreaders[@]}"
do
tagreaderclause+="${tagreaderclause:+ AND }NOT tags.tagreader = \"$reader\""
done
echo '
SELECT COUNT(DISTINCT source_files.filename)
FROM source_files
INNER JOIN destination_files
ON destination_files.source_file_id=source_files.id
INNER JOIN destinations
ON destination_files.destination_id=destinations.id
INNER JOIN mime_type_actions
ON destinations.id=mime_type_actions.destination_id
INNER JOIN tags
ON source_files.id=tags.source_file
WHERE mime_type_actions.id = source_files.mime_type
AND (
CAST(tags.last_change AS TEXT)
<>
CAST(source_files.last_change AS TEXT)
OR ('"$tagreaderclause"')
)
AND mime_type_actions.action = 1;' >&3
read -u4 filecount
echo '
SELECT DISTINCT
source_files.id,
source_files.last_change,
mime_type_actions.mime_text,
source_files.filename
FROM source_files
INNER JOIN destination_files
ON destination_files.source_file_id=source_files.id
INNER JOIN destinations
ON destination_files.destination_id=destinations.id
INNER JOIN mime_type_actions
ON destinations.id=mime_type_actions.destination_id
INNER JOIN tags
ON source_files.id=tags.source_file
WHERE mime_type_actions.id = source_files.mime_type
AND (
CAST(tags.last_change AS TEXT)
<>
CAST(source_files.last_change AS TEXT)
OR ('"$tagreaderclause"')
)
AND mime_type_actions.action = 1;
SELECT "AtOM:NoMoreFiles";' >&3
read -u4 line
while ! [[ $line = AtOM:NoMoreFiles ]]
do
tagfiles+=("$line")
read -u4 line
done
echo 'BEGIN TRANSACTION;' >&3
for line in "${tagfiles[@]}"
do
sourcefileid=${line%%|*}
rest=${line#*|}
lastchange=${rest%%|*}
rest=${rest#*|}
mimetype=${rest%%|*}
filename=${rest#*|}
echo -en "\rTags: $((++count*100/filecount))%"
if (( count % 1000 == 0 ))
then
echo 'COMMIT;BEGIN TRANSACTION;' >&3
(( debug )) \
&& echo -n " $count files read, committing..."
fi
if getTags
then
Update tags \
album "${album:-NULL}" \
albumartist "${albumartist:-NULL}" \
artist "${artist:-NULL}" \
composer "${composer:-NULL}" \
disc "${disc:-NULL}" \
genre "${genre:-NULL}" \
performer "${performer:-NULL}" \
title "${title:-NULL}" \
track "${tracknum:-NULL}" \
year "${year:-NULL}" \
last_change "$lastchange" \
rate "${rate:-NULL}" \
channels "${channels:-NULL}" \
bitrate "${bitrate:-NULL}" \
tagreader "$tagreader" \
>/dev/null <<<"source_file = $sourcefileid"
unset genre \
albumartist \
year \
album \
disc \
artist \
tracknum \
title \
composer \
performer \
rate \
bitrate \
channels
fi
done
echo 'COMMIT;' >&3
echo -e "\rRead tags from ${count:-0} files.\033[K"
unset count tagfiles
echo ' echo '
CREATE TEMPORARY TABLE tasks( CREATE TEMPORARY TABLE tasks(
@ -376,7 +268,7 @@ echo '
read -u4 line read -u4 line
while ! [[ $line = AtOM:NoMoreFiles ]] while ! [[ $line = AtOM:NoMoreFiles ]]
do do
decodefiles+=("$line|") decodefiles+=("$line::AtOM:SQL:Sep::")
read -u4 line read -u4 line
done done
echo -n 'Creating tasks... ' echo -n 'Creating tasks... '
@ -384,41 +276,41 @@ echo -n 'Creating tasks... '
echo 'BEGIN TRANSACTION;' >&3 echo 'BEGIN TRANSACTION;' >&3
for line in "${decodefiles[@]}" for line in "${decodefiles[@]}"
do do
fileid=${line%%|*} fileid=${line%%::AtOM:SQL:Sep::*}
rest=${line#*|} rest=${line#*::AtOM:SQL:Sep::}
filename=${rest%%|*} filename=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
mimetype=${rest%%|*} mimetype=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
destination=${rest%%|*} destination=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
destfileid=${rest%%|*} destfileid=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
rate=${rest%%|*} rate=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
channels=${rest%%|*} channels=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
bitrate=${rest%%|*} bitrate=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
genre=${rest%%|*} genre=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
albumartist=${rest%%|*} albumartist=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
year=${rest%%|*} year=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
album=${rest%%|*} album=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
disc=${rest%%|*} disc=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
artist=${rest%%|*} artist=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
track=${rest%%|*} track=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
title=${rest%%|*} title=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
composer=${rest%%|*} composer=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
performer=${rest%%|*} performer=${rest%%::AtOM:SQL:Sep::*}
unset rest unset rest
decodeFile decodeFile
getDestDir getDestDir
@ -647,32 +539,32 @@ do
echo -n "$destination: rename pattern changed, renaming files... " echo -n "$destination: rename pattern changed, renaming files... "
while [[ $line != AtOM:NoMoreFiles ]] while [[ $line != AtOM:NoMoreFiles ]]
do do
oldfilename=${line%%|*} oldfilename=${line%%::AtOM:SQL:Sep::*}
rest=${line#*|}'|' rest=${line#*::AtOM:SQL:Sep::}'::AtOM:SQL:Sep::'
destfileid=${rest%%|*} destfileid=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
filename=${rest%%|*} filename=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
album=${rest%%|*} album=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
albumartist=${rest%%|*} albumartist=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
artist=${rest%%|*} artist=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
composer=${rest%%|*} composer=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
disc=${rest%%|*} disc=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
genre=${rest%%|*} genre=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
performer=${rest%%|*} performer=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
title=${rest%%|*} title=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
track=${rest%%|*} track=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
year=${rest%%|*} year=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
if [ -n "$oldfilename" -a -f "$oldfilename" ] if [ -n "$oldfilename" -a -f "$oldfilename" ]
then then
getDestDir getDestDir
@ -720,10 +612,10 @@ done
echo 'BEGIN TRANSACTION;' >&3 echo 'BEGIN TRANSACTION;' >&3
for line in "${lines[@]}" for line in "${lines[@]}"
do do
id=${line%%|*} id=${line%%::AtOM:SQL:Sep::*}
rest=${line#*|} rest=${line#*::AtOM:SQL:Sep::}
filename=${rest%%|*} filename=${rest%%::AtOM:SQL:Sep::*}
oldfilename=${rest#*|} oldfilename=${rest#*::AtOM:SQL:Sep::}
if [[ $oldfilename != $filename ]] && [ -f "$oldfilename" ] if [[ $oldfilename != $filename ]] && [ -f "$oldfilename" ]
then then
rm -f "$oldfilename" rm -f "$oldfilename"

View File

@ -6,6 +6,7 @@ copyFiles_action() {
source_files.filename, source_files.filename,
source_files.last_change, source_files.last_change,
destinations.id, destinations.id,
destinations.name,
destination_files.id destination_files.id
FROM source_files FROM source_files
INNER JOIN destination_files INNER JOIN destination_files
@ -31,15 +32,17 @@ copyFiles_action() {
echo 'BEGIN TRANSACTION;' >&3 echo 'BEGIN TRANSACTION;' >&3
for copyfile in "${copyfiles[@]}" for copyfile in "${copyfiles[@]}"
do do
sourcefilename=${copyfile%%|*} sourcefilename=${copyfile%%::AtOM:SQL:Sep::*}
sourcedir=${sourcefilename%/*} sourcedir=${sourcefilename%/*}
rest="${copyfile#*|}|" rest="${copyfile#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
lastchange=${rest%%|*} lastchange=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
destinationid=${rest%%|*} destinationid=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
destfileid=${rest%%|*} destination=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
destfileid=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*::AtOM:SQL:Sep::}
echo 'SELECT IFNULL( ( echo 'SELECT IFNULL( (
SELECT destination_files.filename SELECT destination_files.filename
FROM destination_files FROM destination_files

View File

@ -24,5 +24,6 @@ openDatabase() {
exec 3> >(tee -a $tempdir/debug.log >&5) exec 3> >(tee -a $tempdir/debug.log >&5)
fi fi
cat $schema >&3 cat $schema >&3
echo '.separator ::AtOM:SQL:Sep::' >&3
echo 'PRAGMA foreign_keys = ON;' >&3 echo 'PRAGMA foreign_keys = ON;' >&3
} }

View File

@ -3,7 +3,17 @@ decodeFile() {
case "$mimetype" in case "$mimetype" in
'video/'*) 'video/'*)
extractAudio extractAudio
if (( ${destinationnormalize["$destination"]}))\
|| (
[ -n "${destinationfrequency["$destination"]}" ]\
&& (( ${rate:-0} != ${destinationfrequency["$destination"]}))\
) || (
[ -n "${destinationchannels["$destination"]}" ]\
&& (( ${channels:-0} != ${destinationchannels["$destination"]} ))
)
then
sox_needed=1 sox_needed=1
fi
;; ;;
'audio/mpeg') 'audio/mpeg')
if [[ ${destinationformat[$destination]} = mp3 ]] \ if [[ ${destinationformat[$destination]} = mp3 ]] \

View File

@ -1,7 +1,34 @@
#!/bin/bash #!/bin/bash
getDestDir() { getDestDir() {
destdir="${destinationpath[$destination]}/" destdir="${destinationpath[$destination]}/"
if [ -n "${destinationrenamepath[$destination]}" ] if [ -n "${destinationrenamepath[$destination]}" ] \
&& (
(
! [[ ${destinationrenamepath[$destination]} =~ %\{album\} ]] \
|| [ -n "$album" ]
) && (
! [[ ${destinationrenamepath[$destination]} =~ %\{albumartist\} ]] \
|| [ -n "$albumartist" ]
) && (
! [[ ${destinationrenamepath[$destination]} =~ %\{artist\} ]] \
|| [ -n "$artist" ]
) && (
! [[ ${destinationrenamepath[$destination]} =~ %\{genre\} ]] \
|| [ -n "$genre" ]
) && (
! [[ ${destinationrenamepath[$destination]} =~ %\{title\} ]] \
|| [ -n "$title" ]
) && (
! [[ ${destinationrenamepath[$destination]} =~ %\{track\} ]] \
|| [ -n "$track" ]
) && (
! [[ ${destinationrenamepath[$destination]} =~ %\{year\} ]] \
|| [ -n "$year" ]
) && (
! [[ ${destinationrenamepath[$destination]} =~ %\{disc\} ]] \
|| [ -n "$disc" ]
)
)
then then
replace=$(sanitizeFile "$album" dir) replace=$(sanitizeFile "$album" dir)
destdir+="${destinationrenamepath[$destination]//%\{album\}/$replace}" destdir+="${destinationrenamepath[$destination]//%\{album\}/$replace}"

View File

@ -1,6 +1,33 @@
#!/bin/bash #!/bin/bash
getDestFile() { getDestFile() {
if [ -n "${destinationrename[$destination]}" ] if [ -n "${destinationrename[$destination]}" ] \
&& (
(
! [[ ${destinationrename[$destination]} =~ %\{album\} ]] \
|| [ -n "$album" ]
) && (
! [[ ${destinationrename[$destination]} =~ %\{albumartist\} ]] \
|| [ -n "$albumartist" ]
) && (
! [[ ${destinationrename[$destination]} =~ %\{artist\} ]] \
|| [ -n "$artist" ]
) && (
! [[ ${destinationrename[$destination]} =~ %\{genre\} ]] \
|| [ -n "$genre" ]
) && (
! [[ ${destinationrename[$destination]} =~ %\{title\} ]] \
|| [ -n "$title" ]
) && (
! [[ ${destinationrename[$destination]} =~ %\{track\} ]] \
|| [ -n "$track" ]
) && (
! [[ ${destinationrename[$destination]} =~ %\{year\} ]] \
|| [ -n "$year" ]
) && (
! [[ ${destinationrename[$destination]} =~ %\{disc\} ]] \
|| [ -n "$disc" ]
)
)
then then
destfile="${destinationrename[$destination]//%\{album\}/$album}" destfile="${destinationrename[$destination]//%\{album\}/$album}"
destfile="${destfile//%\{albumartist\}/$albumartist}" destfile="${destfile//%\{albumartist\}/$albumartist}"

View File

@ -27,5 +27,12 @@ sanitizeFile() {
string=${string/%+(.)/} string=${string/%+(.)/}
fi fi
fi fi
# Not exactly filename sanitity, but these will make the script fail in
# a decorative way..
string="${string//&/\\&}"
strint="${string//;/\\;}"
# And these would exhibit strange behaviors
string="${string//\[/\\\[}"
string="${string//\]/\\\]}"
echo "$string" echo "$string"
} }

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
getInfosffmpeg_version='ffmpeg-1' getInfosffmpeg_version='ffmpeg-2'
tagreaders+=( "$getInfosffmpeg_version" ) tagreaders+=( "$getInfosffmpeg_version" )
getInfos::ffmpeg() { getInfos::ffmpeg() {
tagreader="$getInfosffmpeg_version" tagreader="$getInfosffmpeg_version"
@ -31,8 +31,8 @@ getInfos::ffmpeg() {
genre=$(gettag genre) genre=$(gettag genre)
performer=$(gettag TOPE) performer=$(gettag TOPE)
title=$(gettag title) title=$(gettag title)
tracknum=$(gettag tracknumber) tracknum=$(gettag track)
year=$(gettag year) year=$(gettag date)
expr='^[0-9]*$' expr='^[0-9]*$'
if [ -n "$genre" ] && [[ $genre =~ $expr ]] if [ -n "$genre" ] && [[ $genre =~ $expr ]]
then then

111
lib/tags/updateTags Normal file
View File

@ -0,0 +1,111 @@
#!/bin/bash
updateTags() {
for reader in "${tagreaders[@]}"
do
tagreaderclause+="${tagreaderclause:+ AND }NOT tags.tagreader = \"$reader\""
done
echo '
SELECT COUNT(DISTINCT source_files.filename)
FROM source_files
INNER JOIN destination_files
ON destination_files.source_file_id=source_files.id
INNER JOIN destinations
ON destination_files.destination_id=destinations.id
INNER JOIN mime_type_actions
ON destinations.id=mime_type_actions.destination_id
INNER JOIN tags
ON source_files.id=tags.source_file
WHERE mime_type_actions.id = source_files.mime_type
AND (
CAST(tags.last_change AS TEXT)
<>
CAST(source_files.last_change AS TEXT)
OR ('"$tagreaderclause"')
)
AND mime_type_actions.action = 1;' >&3
read -u4 filecount
echo '
SELECT DISTINCT
source_files.id,
source_files.last_change,
mime_type_actions.mime_text,
source_files.filename
FROM source_files
INNER JOIN destination_files
ON destination_files.source_file_id=source_files.id
INNER JOIN destinations
ON destination_files.destination_id=destinations.id
INNER JOIN mime_type_actions
ON destinations.id=mime_type_actions.destination_id
INNER JOIN tags
ON source_files.id=tags.source_file
WHERE mime_type_actions.id = source_files.mime_type
AND (
CAST(tags.last_change AS TEXT)
<>
CAST(source_files.last_change AS TEXT)
OR ('"$tagreaderclause"')
)
AND mime_type_actions.action = 1;
SELECT "AtOM:NoMoreFiles";' >&3
read -u4 line
while ! [[ $line = AtOM:NoMoreFiles ]]
do
tagfiles+=("$line")
read -u4 line
done
echo 'BEGIN TRANSACTION;' >&3
for line in "${tagfiles[@]}"
do
sourcefileid=${line%%::AtOM:SQL:Sep::*}
rest=${line#*::AtOM:SQL:Sep::}
lastchange=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*::AtOM:SQL:Sep::}
mimetype=${rest%%::AtOM:SQL:Sep::*}
filename=${rest#*::AtOM:SQL:Sep::}
echo -en "\rTags: $((++count*100/filecount))%"
if (( count % 1000 == 0 ))
then
echo 'COMMIT;BEGIN TRANSACTION;' >&3
(( debug )) \
&& echo -n " $count files read, committing..."
fi
if getTags
then
Update tags \
album "${album:-NULL}" \
albumartist "${albumartist:-NULL}" \
artist "${artist:-NULL}" \
composer "${composer:-NULL}" \
disc "${disc:-NULL}" \
genre "${genre:-NULL}" \
performer "${performer:-NULL}" \
title "${title:-NULL}" \
track "${tracknum:-NULL}" \
year "${year:-NULL}" \
last_change "$lastchange" \
rate "${rate:-NULL}" \
channels "${channels:-NULL}" \
bitrate "${bitrate:-NULL}" \
tagreader "$tagreader" \
>/dev/null <<<"source_file = $sourcefileid"
unset genre \
albumartist \
year \
album \
disc \
artist \
tracknum \
title \
composer \
performer \
rate \
bitrate \
channels
fi
done
echo 'COMMIT;' >&3
echo -e "\rRead tags from ${count:-0} files.\033[K"
unset count tagfiles
}

View File

@ -12,16 +12,16 @@ gettaskinfos() {
WHERE id='$1'; WHERE id='$1';
' >&3 ' >&3
read -u4 line read -u4 line
taskid=${line%%|*} taskid=${line%%::AtOM:SQL:Sep::*}
rest="${line#*|}|" rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
sourcefileid=${rest%%|*} sourcefileid=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
required=${rest%%|*} required=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cleanup=${rest%%|*} cleanup=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
destfileid=${rest%%|*} destfileid=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
destfilename=${rest%%|*} destfilename=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
} }

View File

@ -69,78 +69,78 @@ master() {
else else
(( ++active )) (( ++active ))
read -u4 line read -u4 line
taskid=${line%%|*} taskid=${line%%::AtOM:SQL:Sep::*}
rest="${line#*|}|" rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
sourcefileid=${rest%%|*} sourcefileid=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
required=${rest%%|*} required=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg=("${rest%%|*}") cmd_arg=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cmd_arg+=("${rest%%|*}") cmd_arg+=("${rest%%::AtOM:SQL:Sep::*}")
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
cleanup=${rest%%|*} cleanup=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
destfileid=${rest%%|*} destfileid=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
destfilename=${rest%%|*} destfilename=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
for key in ${!cmd_arg[@]} for key in ${!cmd_arg[@]}
do do
[ -z "${cmd_arg[key]}" ] && unset cmd_arg[key] [ -z "${cmd_arg[key]}" ] && unset cmd_arg[key]

View File

@ -112,8 +112,8 @@ getdstfiles() {
done done
for line in "${lines[@]}" for line in "${lines[@]}"
do do
fileid=${line%|*} fileid=${line%::AtOM:SQL:Sep::*}
filename=${line#*|} filename=${line#*::AtOM:SQL:Sep::}
echo $'\t'"$filename" echo $'\t'"$filename"
(( rename )) && echo -n $'\t' (( rename )) && echo -n $'\t'
(( rename )) && renameFile (( rename )) && renameFile
@ -149,12 +149,12 @@ do
done done
for line in "${lines[@]}" for line in "${lines[@]}"
do do
fileid=${line%%|*} fileid=${line%%::AtOM:SQL:Sep::*}
rest="${line#*|}|" rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
filename=${rest%%|*} filename=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
mimetype=${rest%%|*} mimetype=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
dest=$sourcepath dest=$sourcepath
case "$mimetype" in case "$mimetype" in
'audio/mpeg') 'audio/mpeg')

View File

@ -61,7 +61,7 @@ checkwanted() {
for destination in "${!destinationpath[@]}" for destination in "${!destinationpath[@]}"
do do
echo -ne "\rScanning destination $destination... \033[K" echo -ne "\rScanning destination $destination... \033[K"
while read filename while read -r filename
do do
if ! Select destination_files id \ if ! Select destination_files id \
>/dev/null \ >/dev/null \

View File

@ -93,16 +93,17 @@ if (( update ))
then then
getFiles getFiles
updateMimes updateMimes
updateTags
fi fi
for check in ${!checks[@]} for check in ${!checks[@]}
do do
case $check in case $check in
tracktotal) tracktotal)
whereclause+="${whereclause+ OR }NOT tags.track LIKE \"%/%\"" whereclause+="${whereclause+OR }NOT tags.track LIKE \"%/%\""
;; ;;
*) *)
whereclause+="${whereclause+ OR }tags.$check IS NULL" whereclause+="${whereclause+OR }tags.$check IS NULL"
;; ;;
esac esac
whereclause+=' whereclause+='
@ -124,8 +125,15 @@ cat >&3 <<-EOSelect
FROM tags FROM tags
INNER JOIN source_files INNER JOIN source_files
ON tags.source_file=source_files.id ON tags.source_file=source_files.id
WHERE $whereclause INNER JOIN mime_types
AND NOT tags.tagreader LIKE "unknown-%"; ON source_files.mime_type=mime_types.id
WHERE (
$whereclause
)
AND NOT tags.tagreader LIKE "unknown-%"
AND NOT mime_types.mime_text LIKE "text/%"
AND NOT mime_types.mime_text LIKE "image/%"
;
SELECT "AtOM:NoMoreFiles"; SELECT "AtOM:NoMoreFiles";
EOSelect EOSelect
@ -140,33 +148,33 @@ done
for line in "${lines[@]}" for line in "${lines[@]}"
do do
missing=() missing=()
filename=${line%%|*} filename=${line%%::AtOM:SQL:Sep::*}
rest="${line#*|}|" rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
(( ${checks[genre]} )) && [ -z "${rest%%|*}" ] && missing+=( "Genre" ) (( ${checks[genre]} )) && [ -z "${rest%%::AtOM:SQL:Sep::*}" ] && missing+=( "Genre" )
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
(( ${checks[albumartist]} )) && [ -z "${rest%%|*}" ] && missing+=( "AlbumArtist" ) (( ${checks[albumartist]} )) && [ -z "${rest%%::AtOM:SQL:Sep::*}" ] && missing+=( "AlbumArtist" )
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
(( ${checks[year]} )) && [ -z "${rest%%|*}" ] && missing+=( "Year" ) (( ${checks[year]} )) && [ -z "${rest%%::AtOM:SQL:Sep::*}" ] && missing+=( "Year" )
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
(( ${checks[album]} )) && [ -z "${rest%%|*}" ] && missing+=( "Album" ) (( ${checks[album]} )) && [ -z "${rest%%::AtOM:SQL:Sep::*}" ] && missing+=( "Album" )
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
(( ${checks[disc]} )) && [ -z "${rest%%|*}" ] && missing+=( "Disc" ) (( ${checks[disc]} )) && [ -z "${rest%%::AtOM:SQL:Sep::*}" ] && missing+=( "Disc" )
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
(( ${checks[artist]} )) && [ -z "${rest%%|*}" ] && missing+=( "Artist" ) (( ${checks[artist]} )) && [ -z "${rest%%::AtOM:SQL:Sep::*}" ] && missing+=( "Artist" )
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
track=${rest%%|*} track=${rest%%::AtOM:SQL:Sep::*}
(( ${checks[track]} )) && [ -z "$track" ] && missing+=( "Track" ) (( ${checks[track]} )) && [ -z "$track" ] && missing+=( "Track" )
if (( ${checks[tracktotal]} )) && ! [[ $track =~ / ]] if (( ${checks[tracktotal]} )) && ! [[ $track =~ / ]]
then then
missing+=( TrackTotal ) missing+=( TrackTotal )
fi fi
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
(( ${checks[title]} )) && [ -z "${rest%%|*}" ] && missing+=( "Title" ) (( ${checks[title]} )) && [ -z "${rest%%::AtOM:SQL:Sep::*}" ] && missing+=( "Title" )
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
(( ${checks[composer]} )) && [ -z "${rest%%|*}" ] && missing+=( "Composer" ) (( ${checks[composer]} )) && [ -z "${rest%%::AtOM:SQL:Sep::*}" ] && missing+=( "Composer" )
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
(( ${checks[performer]} )) && [ -z "${rest%%|*}" ] && missing+=( "Performer" ) (( ${checks[performer]} )) && [ -z "${rest%%::AtOM:SQL:Sep::*}" ] && missing+=( "Performer" )
rest=${rest#*|} rest=${rest#*::AtOM:SQL:Sep::}
echo "$filename: ${missing[@]}" echo "$filename: ${missing[@]}"
done done