Compare commits

..

1 Commits

Author SHA1 Message Date
ScriptFanix
7a359ad2d6 Merge branch 'dev' into 'master'
v1.0.4 last minute fixes

See merge request atom/AtOM!32
2025-10-13 18:21:25 +02:00
27 changed files with 198 additions and 350 deletions

View File

@ -1,25 +1,3 @@
# DEV
### BUGS (Minor)
* `toys/createindex`: handle empty channel count, bitdepth and sampling rate cleanly
### Enhancements
* Allow ignoring microsecond precision in timestamps
* Don't print useless information (stuff that handled 0 files and such)
* Store transcoded file paths relative to their destination's root
* Add missing error codes (used but not declared)
# 1.0.4
## `BREAKING CHANGES`
* ffmpeg parser was fixed. All files previously parsed by it and parsers depending on it will be reprocessed. Running in batches (`-B <batchsize>`) is recommended.
### BUGS
* `ffmpeg` output parsed incorrectly
* `toys/createindex`: incorrect path for ID3v1 tag index file
### Enhancements
* Use bash builtin `printf` instead of command `date`
* Commit to database more frequently when reading tags
# 1.0.3 # 1.0.3
## `BREAKING CHANGES` ## `BREAKING CHANGES`
* Implementing replaygain copy meant bumping versions of every tag parser. All file tags will be read again. Running in batches (`-B <batchsize>`) is recommended. * Implementing replaygain copy meant bumping versions of every tag parser. All file tags will be read again. Running in batches (`-B <batchsize>`) is recommended.

View File

@ -21,12 +21,12 @@ have AtOM do that!
Here's what I have for my tests: Here's what I have for my tests:
| Directory | Format | Sample rate | Bitrate | Channels | FAT32 compat. | ASCII | Size | | Directory | Format | Sample rate | Bitrate | Channels | FAT32 compat. | ASCII | Size |
| --------- | ------ | ----------- | --------- | -------- | ------------- | ----- | ---- | | --------- | ------ | ----------- | ------- | -------- | ------------- | ----- | ---- |
| 0-Full | Mixed | Mixed | Mixed | Mixed | No | No | 568G | | 0-Full | Mixed | Mixed | Mixed | Mixed | No | No | 508G |
| 1-High | Vorbis | Same | Quality 5 | Same | Yes | No | 143G | | 1-High | Opus | Same | 128 | Same | Yes | No | 101G |
| 2-Medium | Opus | Same | 64 | Same | Yes | No | 60G | | 2-Medium | Opus | Same | 64 | Same | Yes | No | 59G |
| 3-Small | Opus | Same | 32 | Same | Yes | No | 31G | | 3-Small | Opus | Same | 32 | Same | Yes | No | 30G |
| 4-MP3 | MP3 | 44100 | 128 | 2 | Yes | Yes | 119G | | 4-MP3 | MP3 | 44100 | 128 | 2 | Yes | Yes | 114G |

160
atom
View File

@ -1,17 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
## Define exit codes ## Define exit codes
source "$SHAREDIR"/errorcodes # General config errors [10-19]
ELOAD=10
EINTERVAL=11
ENOCFG=19
# Source cofig errors [20-29]
# Destination config errors [30-49]
EFORMAT=30
ECHANNEL=31
EFMTINVPARM=49
# config structures # config structures
declare -A \ declare -A \
@ -38,11 +36,21 @@ declare -A \
exit $EBASHVERS exit $EBASHVERS
} }
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
LC_ALL=C LC_ALL=C
shopt -s extglob shopt -s extglob
source "$SHAREDIR"/id3genres source $SHAREDIR/id3genres
for function in "$LIBDIR"/*/* for function in "$LIBDIR"/*/*
do do
@ -117,12 +125,12 @@ do
:) :)
echo "-$OPTARG requires an argument" echo "-$OPTARG requires an argument"
help help
exit $EINVARG exit 127
;; ;;
*) *)
echo "Unrecognized option: -$OPTARG" echo "Unrecognized option: -$OPTARG"
help help
exit $EINVARG exit 127
;; ;;
esac esac
done done
@ -206,13 +214,9 @@ read -u4 removecount
until (( ${#removefile[@]} == removecount )) until (( ${#removefile[@]} == removecount ))
do do
echo ' echo '
SELECT destination_files.id, SELECT id,
destinations.name, filename
destination_files.filename
FROM destination_files FROM destination_files
INNER JOIN destinations
ON destination_files.destination_id
= destinations.id
WHERE source_file_id is NULL WHERE source_file_id is NULL
LIMIT 500 OFFSET '${#removefile[@]}'; LIMIT 500 OFFSET '${#removefile[@]}';
@ -222,17 +226,13 @@ do
read -u4 line read -u4 line
until [[ $line == AtOM:NoMoreFiles ]] until [[ $line == AtOM:NoMoreFiles ]]
do do
removeFileId=${line%%::AtOM:SQL:Sep::*} removefile[${line%::AtOM:SQL:Sep::*}]="${line#*::AtOM:SQL:Sep::}"
rest=${line#*::AtOM:SQL:Sep::}
removeFileDestName=${line%%::AtOM:SQL:Sep::*}
rest=${line#*::AtOM:SQL:Sep::}
removefile[$removeFileId]="${destinationpath["$removeFileDestName"]}/${rest%%::AtOM:SQL:Sep::*}"
read -u4 line read -u4 line
done done
done done
unset deleted deleted=0
unset removed removed=0
echo 'BEGIN TRANSACTION;' >&3 echo 'BEGIN TRANSACTION;' >&3
for id in ${!removefile[@]} for id in ${!removefile[@]}
do do
@ -256,9 +256,9 @@ do
done done
echo 'COMMIT;' >&3 echo 'COMMIT;' >&3
(( cron )) || echo -n $'\r' (( cron )) || echo -n $'\r'
echo -n "${deleted+$deleted files deleted${removed:+, }}${removed:+$removed removed from database}" echo -n "Suppressed $deleted files, $removed removed from database"
(( cron )) || echo -ne "\033[K" (( cron )) || echo -ne "\033[K"
(( deleted || removed )) && echo echo
unset removecount deleted removed removefile unset removecount deleted removed removefile
updateTags updateTags
@ -272,8 +272,7 @@ do
Update destination_files last_change 0 \ Update destination_files last_change 0 \
<<<"destination_id = $forcedestid" <<<"destination_id = $forcedestid"
else else
echo "Full rebuild of destination $forcedest was requested," \ echo "Destination $forcedest does not exist!" >&2
"but it does not exist!" >&2
fi fi
done done
@ -289,7 +288,6 @@ echo '
ascii INTEGER, ascii INTEGER,
source_file INTEGER, source_file INTEGER,
fileid INTEGER, fileid INTEGER,
destdir TEXT,
filename TEXT, filename TEXT,
cmd_arg0 TEXT, cmd_arg0 TEXT,
cmd_arg1 TEXT, cmd_arg1 TEXT,
@ -442,7 +440,7 @@ do
decodefiles+=("$line::AtOM:SQL:Sep::") decodefiles+=("$line::AtOM:SQL:Sep::")
read -u4 line read -u4 line
done done
(( cron )) || echo -n $'Creating tasks...\033[K' (( cron )) || echo -n 'Creating tasks... '
(( textunidecodeneeded )) && ascii (( textunidecodeneeded )) && ascii
@ -548,11 +546,8 @@ do
tmpfile tmpfile
done done
echo 'COMMIT;' >&3 echo 'COMMIT;' >&3
(( cron )) || echo -n $'\r\033[K' (( cron )) || echo -n $'\r'
(( count )) \ echo "Created ${count:-0} tasks for $filecount files ${togo:+($togo left) }(${copies:-0} immediate copies)"
&& echo "Created $count tasks for $filecount files \
${togo:+($togo left) } \
${copies:+($copies immediate copies)}"
# remove perl unicode to ascii coprocess # remove perl unicode to ascii coprocess
(( textunidecodeneeded )) && eval exec "${toascii[1]}>&-" (( textunidecodeneeded )) && eval exec "${toascii[1]}>&-"
@ -567,7 +562,7 @@ remaining=$taskcount
failed=0 failed=0
echo 'BEGIN TRANSACTION;' >&3 echo 'BEGIN TRANSACTION;' >&3
committime=$EPOCHSECONDS committime=$EPOCHSECONDS
while (( remaining || ${#workers[@]} )) while (( (remaining || ${#workers[@]}) && ! quit ))
do do
timestamp=$EPOCHSECONDS timestamp=$EPOCHSECONDS
if (( $timestamp - committime >= 60 )) if (( $timestamp - committime >= 60 ))
@ -581,15 +576,16 @@ do
then then
concurrency="$fixed_workers" concurrency="$fixed_workers"
else else
if (( timestamp - concurrencychange >= loadinterval )) if [ -z "$quit" ] \
&& (( ! pause )) \
&& (( timestamp - concurrencychange >= loadinterval ))
then then
if (( concurrency > 1 || allow_zero_running )) \ if (( concurrency > 1 )) \
&& (( load > maxload && concurrency )) && (( load > maxload ))
then then
concurrencychange=$timestamp concurrencychange=$timestamp
(( --concurrency )) (( --concurrency ))
elif (( load < maxload )) \ elif (( load < maxload )) && (( active > concurrency - 1 ))
&& (( active > concurrency - 1 ))
then then
concurrencychange=$timestamp concurrencychange=$timestamp
(( ++concurrency )) (( ++concurrency ))
@ -598,11 +594,16 @@ do
fi fi
checkworkers checkworkers
cleaner cleaner
master (( pause )) || master
if (( ran - failed )) if (( ran - failed ))
then then
currenttime=$timestamp currenttime=$timestamp
(( runtime = currenttime - starttime )) if (( pause ))
then
(( runtime = pausestart - starttime - pausedtime ))
else
(( runtime = currenttime - starttime - pausedtime ))
fi
avgduration=$(( avgduration=$((
( runtime * 1000) ( runtime * 1000)
/ /
@ -638,7 +639,11 @@ do
fmtprogress="T:%${#taskcount}i/%i (F:%i) %3i%%" fmtprogress="T:%${#taskcount}i/%i (F:%i) %3i%%"
fmttime='%2id %2ih%02im%02is (A:%4.1fs/task)' fmttime='%2id %2ih%02im%02is (A:%4.1fs/task)'
eta="ETA:$( eta="ETA:$(
printf "%(%c)T" "$(( currenttime + secsremaining ))" date -d "${days:-0} days
${hours:-0} hours
${minutes:-0} minutes
${seconds:-0} seconds" \
+'%d/%m %H:%M:%S'
)" )"
(( cron )) || printf \ (( cron )) || printf \
"\r$fmtload $fmtworkers $fmtprogress $fmttime $eta\033[K"\ "\r$fmtload $fmtworkers $fmtprogress $fmttime $eta\033[K"\
@ -655,7 +660,7 @@ do
${minutes:-0} \ ${minutes:-0} \
${seconds:-0} \ ${seconds:-0} \
${avgdsec:-0}.${avgdmsec:-0} ${avgdsec:-0}.${avgdmsec:-0}
if ! (( concurrency )) && ! (( cron )) if (( pause ))
then then
if (( active )) if (( active ))
then then
@ -670,25 +675,22 @@ unset count
endtime=$EPOCHSECONDS endtime=$EPOCHSECONDS
(( elapsedseconds = endtime - starttime )) (( elapsedseconds = endtime - starttime - pausedtime ))
(( days = (( days =
elapsedseconds elapsedseconds
/ /
( 24*60*60 ) ( 24*60*60 )
)) || true )) || true
(( days )) || unset days
(( hours = (( hours =
( elapsedseconds - ( days*24*60*60 ) ) ( elapsedseconds - ( days*24*60*60 ) )
/ /
( 60*60 ) ( 60*60 )
)) || true )) || true
(( days && hours )) || unset hours
(( minutes = (( minutes =
( elapsedseconds - ( ( days*24 + hours ) *60*60 ) ) ( elapsedseconds - ( ( days*24 + hours ) *60*60 ) )
/ /
60 60
)) || true )) || true
(( days && hours && minutes )) || unset minutes
(( seconds = (( seconds =
elapsedseconds elapsedseconds
- -
@ -696,15 +698,10 @@ endtime=$EPOCHSECONDS
)) || true )) || true
(( cron )) || echo -n $'\r' (( cron )) || echo -n $'\r'
(( ran )) \ echo -n "Ran ${ran:=0} tasks, $failed of which failed, in $days" \
&& echo -n "Ran $ran tasks${failed:+, $failed of which failed,} \ "days, $hours hours, $minutes minutes and $seconds seconds."
in ${days:+$days days,} \
${hours:+$hours hours,} \
${minutes:+$minutes minutes and} \
$seconds seconds."
(( cron )) || echo -en "\033[K" (( cron )) || echo -en "\033[K"
(( ran )) && echo echo
if (( failed )) if (( failed ))
then then
echo $'\nFailed tasks:\n' echo $'\nFailed tasks:\n'
@ -787,10 +784,17 @@ then
echo "${line%%::AtOM:SQL:Sep::*}" echo "${line%%::AtOM:SQL:Sep::*}"
line="${line#*::AtOM:SQL:Sep::}" line="${line#*::AtOM:SQL:Sep::}"
line="${line//::AtOM:SQL:Sep::/ }" line="${line//::AtOM:SQL:Sep::/ }"
echo $'\t'"${line/+( )$/}"$'\n' echo $'\t'"${line/+( )$/}"
echo
done done
fi fi
if [ -n "$quit" ]
then
closeDatabase
exit
fi
for destination in "${!destinationpath[@]}" for destination in "${!destinationpath[@]}"
do do
echo ' echo '
@ -890,9 +894,7 @@ do
progressSpin progressSpin
if [[ "$oldfilename" != "$destfilename" ]] if [[ "$oldfilename" != "$destfilename" ]]
then then
mv \ mv "$oldfilename" "$destfilename"
"${destinationpath[$destination]}/$oldfilename" \
"${destinationpath[$destination]}/$destfilename"
(( changedcount++ )) (( changedcount++ ))
commit=1 commit=1
fi fi
@ -917,10 +919,9 @@ do
(( textunidecodeneeded )) && eval exec "${toascii[1]}>&-" (( textunidecodeneeded )) && eval exec "${toascii[1]}>&-"
echo 'COMMIT;' >&3 echo 'COMMIT;' >&3
(( cron )) || echo -n $'\r' (( cron )) || echo -n $'\r'
(( changedcount )) \ echo -n "$destination: Renamed ${changedcount:-0} files"
&& echo -n "$destination: Renamed $changedcount files"
(( cron )) || echo -en "\033[K" (( cron )) || echo -en "\033[K"
(( changedcount )) && echo echo
fi fi
unset count changedcount renamefiles unset count changedcount renamefiles
done done
@ -928,20 +929,16 @@ done
copyFiles_action copyFiles_action
echo ' echo '
SELECT destination_files.id, SELECT id,
destination_files.filename, filename,
destination_files.old_filename, old_filename
destinations.name
FROM destination_files FROM destination_files
INNER JOIN destinations
ON destination_files.destination_id
= destinations.id
WHERE old_filename IS NOT NULL; WHERE old_filename IS NOT NULL;
SELECT "AtOM:NoMoreFiles"; SELECT "AtOM:NoMoreFiles";
' >&3 ' >&3
(( cron )) || echo -n 'Removing obsolete files...'$'\033[K' (( cron )) || echo -n 'Removing obsolete files... '
lines=() lines=()
read -u4 line read -u4 line
while [[ $line != AtOM:NoMoreFiles ]] while [[ $line != AtOM:NoMoreFiles ]]
@ -955,12 +952,10 @@ do
id=${line%%::AtOM:SQL:Sep::*} id=${line%%::AtOM:SQL:Sep::*}
rest=${line#*::AtOM:SQL:Sep::} rest=${line#*::AtOM:SQL:Sep::}
filename=${rest%%::AtOM:SQL:Sep::*} filename=${rest%%::AtOM:SQL:Sep::*}
rest=${line#*::AtOM:SQL:Sep::} oldfilename=${rest#*::AtOM:SQL:Sep::}
oldfilename=${rest%%::AtOM:SQL:Sep::*}
destination=${rest#*::AtOM:SQL:Sep::}
if [[ $oldfilename != "$filename" ]] && [ -f "$oldfilename" ] if [[ $oldfilename != "$filename" ]] && [ -f "$oldfilename" ]
then then
rm -f "${destinationpath[$destination]}/$oldfilename" rm -f "$oldfilename"
fi fi
Update destination_files old_filename NULL <<<"id = $id" Update destination_files old_filename NULL <<<"id = $id"
(( count++ )) (( count++ ))
@ -968,12 +963,11 @@ do
done done
echo 'COMMIT;' >&3 echo 'COMMIT;' >&3
(( cron )) || echo -n $'\r' (( cron )) || echo -n $'\r'
(( count )) \ echo -n "Removed ${count:-0} obsolete files."
&& echo -n "Removed $count obsolete files."
(( cron )) || echo -en "\033[K" (( cron )) || echo -en "\033[K"
(( count )) && echo echo
(( debug )) && echo "Purging empty directories..." echo "Purging empty directories."
for path in "${destinationpath[@]}" for path in "${destinationpath[@]}"
do do
find "$path" -type d -empty -delete find "$path" -type d -empty -delete

View File

@ -39,11 +39,6 @@ Sections:
* debug <level>: Integer. Currently defined values: * debug <level>: Integer. Currently defined values:
* 1: few additional status informations. * 1: few additional status informations.
* 3: log SQL queries. * 3: log SQL queries.
* skip-timestamp-microsec <bool>: Ignore microsecond precision in timestamps.
Microsec precise timestamps are still stored as-is in the DB, this
setting just impacts comparisons when determining if a file has been
changed.
[source] [source]
This section defines where are the files you want transcoded. This section defines where are the files you want transcoded.

View File

@ -34,9 +34,6 @@ database /home/user/.local/share/AtOM/atom.db
# 3: log SQL queries to <temporary-directory>/debug.log # 3: log SQL queries to <temporary-directory>/debug.log
#debug 1 #debug 1
# * skip-timestamp-microsec: Ignore microsecond precision in timestamps.
skip-timestamp-microsec 0
[source] [source]
# This section defines where are the files you want transcoded. # This section defines where are the files you want transcoded.

View File

@ -5,7 +5,7 @@ getConfigDestination() {
destinationenabled["$destination"]="$value" destinationenabled["$destination"]="$value"
;; ;;
'path') 'path')
destinationpath["$destination"]="${value%/}" destinationpath["$destination"]="$value"
;; ;;
'format') 'format')
case "$value" in case "$value" in

View File

@ -75,9 +75,6 @@ getConfigGeneral() {
'database') 'database')
database="$value" database="$value"
;; ;;
'skip-timestamp-microsec')
skip_us_timestamp="$value"
;;
debug) debug)
(( value > debug )) && debug=$value (( value > debug )) && debug=$value
;; ;;

View File

@ -33,9 +33,6 @@ database $database
# * debug <level>: Integer. # * debug <level>: Integer.
#debug 1 #debug 1
# * skip-timestamp-microsec: Ignore microsecond precision in timestamps.
skip-timestamp-microsec ${skip_us_timestamp:-0}
[source] [source]
# This section defines where are the files you want transcoded. # This section defines where are the files you want transcoded.

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
copyFiles_action() { copyFiles_action() {
(( cron )) || echo -n $'Copying files...\033[K' (( cron )) || echo -n "Copying files... "
echo ' echo '
SELECT SELECT
source_files.filename, source_files.filename,
@ -79,29 +79,15 @@ copyFiles_action() {
fi fi
fi fi
fi fi
if cp -a --reflink=always \ if cp -al "$sourcepath/$sourcefilename" "$destdir" 2>/dev/null\
"$sourcepath/$sourcefilename" \ || cp -a "$sourcepath/$sourcefilename" "$destdir"
"$destdir" \
2>/dev/null \
|| cp -al \
"$sourcepath/$sourcefilename" \
"$destdir" \
2>/dev/null \
|| cp -a \
"$sourcepath/$sourcefilename" \
"$destdir"
then then
Update destination_files \ Update destination_files \
filename \ filename "$destdir/${sourcefilename##*/}"\
"$destdir/${sourcefilename##*/}"\ rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}"\
rename_pattern \ fat32compat ${destinationfat32compat["$destination"]}\
"${destinationrenamepath[$destination]}/${destinationrename[$destination]}"\ ascii ${destinationascii["$destination"]}\
fat32compat \ last_change $lastchange \
${destinationfat32compat["$destination"]}\
ascii \
${destinationascii["$destination"]}\
last_change \
$lastchange \
<<-EOWhere <<-EOWhere
id = $destfileid id = $destfileid
EOWhere EOWhere
@ -117,7 +103,7 @@ copyFiles_action() {
(( cron )) || echo -en "\033[K" (( cron )) || echo -en "\033[K"
echo echo
else else
(( cron )) || echo -n $'\r\033[K' (( cron )) || echo -e "\rNothing to copy.\033[K"
fi fi
unset count done unset count done
} }

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
currentdbversion=7 currentdbversion=6
checkDatabaseVersion() { checkDatabaseVersion() {
local dbversion local dbversion
if dbversion=$(Select atom version <<<"\"1\" = 1") if dbversion=$(Select atom version <<<"\"1\" = 1")
@ -18,7 +18,7 @@ checkDatabaseVersion() {
echo "Database schema version $dbversion is higher than echo "Database schema version $dbversion is higher than
that of this version of AtOM that of this version of AtOM
($currentdbversion). Bailing out." >&2 ($currentdbversion). Bailing out." >&2
exit $EDBVERSION exit 1
fi fi
else else
Insert atom 1 <<<"version $currentdbversion" Insert atom 1 <<<"version $currentdbversion"

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
upgradedatabase_6_7() {
echo "Upgrading database to version 7... (backup is $database.bak_v6)"
cp "$database" "$database.bak_v6"
for destination in "${destinations[@]}"
do
echo "UPDATE destination_files SET filename = REPLACE(filename,'${destinationpath[$destination]}/','') WHERE filename LIKE '${destinationpath[$destination]}/%';" >&3
done
Update atom version 7 <<<"1 = 1"
}

View File

@ -53,7 +53,7 @@ encodeFile::mp3() {
esac esac
fi fi
fi fi
lameopts+=("$tempdir/$tmpfile.wav" "${destinationpath[$destination]}/$destdir/$destfile.mp3") lameopts+=("$tempdir/$tmpfile.wav" "$destdir/$destfile.mp3")
encodetaskid=$( encodetaskid=$(
Insert tasks <<-EOInsert Insert tasks <<-EOInsert
key ${fileid}lame$destination key ${fileid}lame$destination

View File

@ -23,7 +23,7 @@ encodeFile::opus() {
[ -n "$track" ] && opusencopts+=(--comment "TRACKNUMBER=${track%/*}") [ -n "$track" ] && opusencopts+=(--comment "TRACKNUMBER=${track%/*}")
[ -n "${track#*/}" ] && opusencopts+=(--comment "TRACKTOTAL=${track#*/}") [ -n "${track#*/}" ] && opusencopts+=(--comment "TRACKTOTAL=${track#*/}")
[ -n "$year" ] && opusencopts+=(--comment "DATE=$year") [ -n "$year" ] && opusencopts+=(--comment "DATE=$year")
opusencopts+=("$tempdir/$tmpfile".wav "${destinationpath[$destination]}/$destdir/$destfile.opus") opusencopts+=("$tempdir/$tmpfile".wav "$destdir/$destfile.opus")
encodetaskid=$( encodetaskid=$(
Insert tasks <<-EOInsert Insert tasks <<-EOInsert
key ${fileid}opusenc$destination key ${fileid}opusenc$destination

View File

@ -17,7 +17,7 @@ encodeFile::vorbis() {
[ -n "$title" ] && oggencopts+=(-t "$title") [ -n "$title" ] && oggencopts+=(-t "$title")
[ -n "$track" ] && oggencopts+=(-N "$track") [ -n "$track" ] && oggencopts+=(-N "$track")
[ -n "$year" ] && oggencopts+=(-d "$year") [ -n "$year" ] && oggencopts+=(-d "$year")
oggencopts+=(-o "${destinationpath[$destination]}/$destdir/$destfile.ogg" "$tempdir/$tmpfile.wav") oggencopts+=(-o "$destdir/$destfile.ogg" "$tempdir/$tmpfile.wav")
encodetaskid=$( encodetaskid=$(
Insert tasks <<-EOInsert Insert tasks <<-EOInsert
key ${fileid}oggenc$destination key ${fileid}oggenc$destination

View File

@ -41,7 +41,7 @@ getDestDir() {
) )
) )
then then
destdir="" destdir="${destinationpath[$destination]}/"
if (( ${destinationascii["$destination"]} )) if (( ${destinationascii["$destination"]} ))
then then
echo "$album" >&${toascii[1]} echo "$album" >&${toascii[1]}
@ -83,7 +83,8 @@ getDestDir() {
replace=$(sanitizeFile "$disc" dir) replace=$(sanitizeFile "$disc" dir)
destdir="${destdir//?(\[)%\{disc\}?(\])/$replace}" destdir="${destdir//?(\[)%\{disc\}?(\])/$replace}"
else else
destdir=$(sanitizeFile "${filename%%/*}" dir) destdir="${destinationpath[$destination]}/"
destdir+=$(sanitizeFile "${filename%%/*}" dir)
part=${filename#*/} part=${filename#*/}
while [[ $part =~ / ]] while [[ $part =~ / ]]
do do
@ -100,7 +101,7 @@ getDestDir() {
fi fi
if ! [ -d "$destdir" ] if ! [ -d "$destdir" ]
then then
mkdir -p "${destinationpath[$destination]}/$destdir" mkdir -p "$destdir"
fi fi
destdir="${destdir//+(\/)//}" destdir="${destdir//+(\/)//}"
} }

View File

@ -10,17 +10,10 @@ getFiles() {
echo 'BEGIN TRANSACTION;' >&3 echo 'BEGIN TRANSACTION;' >&3
while read time size filename while read time size filename
do do
if (( skip_us_timestamp ))
then
compare_time=${time%.*}.%
else
compare_time=$time
fi
if ! Select source_files id >/dev/null <<-EOWhere if ! Select source_files id >/dev/null <<-EOWhere
filename = $filename filename = $filename
mime_type > 0 mime_type > 0
last_change LIKE $compare_time last_change = $time
size = $size
EOWhere EOWhere
then then
mimetype=$(file -b --mime-type "$sourcepath/$filename") mimetype=$(file -b --mime-type "$sourcepath/$filename")
@ -67,10 +60,6 @@ getFiles() {
) )
echo 'COMMIT;' >&3 echo 'COMMIT;' >&3
(( cron )) || echo -n $'\r' (( cron )) || echo -n $'\r'
if (( count )) echo "${count:-0} files found, ${new:=0} new or changed."$'\033[K'
then
echo "$count files found${new:+, $new new or changed}." \
$'\033[K'
fi
unset count unset count
} }

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
getTags_version='unknown-4' getTags_version='unknown-4'
getTags() { getTags() {
local type unset type
case "$mimetype" in case "$mimetype" in
audio/mpeg) audio/mpeg)
type=ffmpeg type=ffmpeg

View File

@ -206,8 +206,8 @@ echo '
done done
echo 'COMMIT;' >&3 echo 'COMMIT;' >&3
(( cron )) || echo -n $'\r' (( cron )) || echo -n $'\r'
(( count )) && echo -n "Read tags from $count files." echo -n "Read tags from ${count:-0} files."
(( cron )) || echo -n $'\033[K' (( cron )) || echo -ne "\033[K"
(( count )) && echo echo
unset count tagfiles unset count tagfiles
} }

View File

@ -220,7 +220,7 @@ master() {
echo "Waiting for children to come back home..." echo "Waiting for children to come back home..."
wait wait
echo $'\nGood luck!' echo $'\nGood luck!'
exit $ETASKLEFT exit 1
elif (( ready == 0 )) elif (( ready == 0 ))
then then
sleep 0.1 sleep 0.1

View File

@ -1,24 +0,0 @@
#!/usr/bin/env bash
## Define exit codes
# General config errors [10-19]
EDBVERSION=10
ELOAD=11
EINTERVAL=12
ELOAD=13
EIONICE=14
ENOCFG=19
# Source cofig errors [20-29]
# Destination config errors [30-49]
EFORMAT=30
ECHANNEL=31
EQUALITY=32
EMAXBPS=33
EINVDEST=34
EFMTINVPARM=49
# Tasks
ETASKLEFT=50
# Sanity
ESANITY=60
# Invalid arguments
EINVARG=127

View File

@ -1,26 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
cat <<-EOWarn
This script is unmaintained and provided as-is. It may or may not work.
Use at your own risk!
EOWarn
read -p "Press Enter to continue or Ctrl-C to abort"
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
## Define exit codes
source "$SHAREDIR"/errorcodes
# config structures # config structures
declare -A \ declare -A \
destinationchannels \ destinationchannels \
@ -43,6 +22,16 @@ declare -A \
exit $EBASHVERS exit $EBASHVERS
} }
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
LC_ALL=C LC_ALL=C
shopt -s extglob shopt -s extglob

View File

@ -1,18 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
## Define exit codes
source "$SHAREDIR"/errorcodes
# config structures # config structures
declare -A \ declare -A \
destinationchannels \ destinationchannels \
@ -35,6 +22,16 @@ declare -A \
exit $EBASHVERS exit $EBASHVERS
} }
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
LC_ALL=C LC_ALL=C
shopt -s extglob shopt -s extglob

View File

@ -1,18 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
## Define exit codes
source "$SHAREDIR"/errorcodes
# config structures # config structures
declare -A \ declare -A \
destinationchannels \ destinationchannels \
@ -35,6 +22,16 @@ declare -A \
exit $EBASHVERS exit $EBASHVERS
} }
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
LC_ALL=C LC_ALL=C
shopt -s extglob shopt -s extglob
@ -65,42 +62,27 @@ getConfig
sanityCheck sanityCheck
openDatabase openDatabase
echo ' echo 'SELECT id,filename FROM destination_files WHERE filename IS NOT NULL;' >&3
SELECT
destination_files.id,
destinations.name,
destination_files.filename
FROM destinations
INNER JOIN destination_files
ON destinations.id=destination_files.destination_id
WHERE filename IS NOT NULL;' >&3
echo 'SELECT "AtOM:NoMoreFiles";' >&3 echo 'SELECT "AtOM:NoMoreFiles";' >&3
declare -a \ read -u4 filename
destination_names \ until [[ $filename == AtOM:NoMoreFiles ]]
files
read -u4 line
until [[ $line == AtOM:NoMoreFiles ]]
do do
id=${line%%::AtOM:SQL:Sep::*} files+=("$filename")
rest=${line#*::AtOM:SQL:Sep::} read -u4 filename
destination_names[id]=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*::AtOM:SQL:Sep::}
files[id]=${rest}
read -u4 line
done done
echo 'BEGIN TRANSACTION;' >&3 echo 'BEGIN TRANSACTION;' >&3
echo -n "Checking for missing files... " echo -n "Checking for missing files... "
for index in "${!files[@]}" for filename in "${files[@]}"
do do
destination=${destination_names[index]} id=${filename%%::AtOM:SQL:Sep::*}
filename="${destinationpath[$destination]}/${files[index]}" filename=${filename#*::AtOM:SQL:Sep::}
if ! [ -f "$filename" ] if ! [ -f "$filename" ]
then then
echo -e "\r$filename\033[K" echo -e "\r$filename\033[K"
((regen))&&Update destination_files last_change 0 <<<"id = $index" ((regen))&&Update destination_files last_change 0 <<<"id = $id"
echo -n "Checking for missing files... " echo -n "Checking for missing files... "
(( missing++ )) (( missing++ ))
fi fi
@ -109,6 +91,6 @@ done
echo 'COMMIT;' >&3 echo 'COMMIT;' >&3
echo -e "\r${missing:-No} missing files\033[K" echo -e "\r${missing:-0} missing files\033[K"
closeDatabase closeDatabase

View File

@ -1,18 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
## Define exit codes
source "$SHAREDIR"/errorcodes
# config structures # config structures
declare -A \ declare -A \
destinationchannels \ destinationchannels \
@ -35,6 +22,16 @@ declare -A \
exit $EBASHVERS exit $EBASHVERS
} }
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
LC_ALL=C LC_ALL=C
shopt -s extglob shopt -s extglob
@ -76,7 +73,7 @@ do
do do
if ! Select destination_files id \ if ! Select destination_files id \
>/dev/null \ >/dev/null \
<<<"filename = ${filename#${destinationpath["$destination"]}/}" <<<"filename = $filename"
then then
echo -e $'\r'"$filename\033[K" echo -e $'\r'"$filename\033[K"
(( remove )) && rm -f "$filename" (( remove )) && rm -f "$filename"

View File

@ -1,17 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
declare -r \ #!/bin/bash
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
## Define exit codes
source "$SHAREDIR"/errorcodes
# config structures # config structures
declare -A \ declare -A \
@ -35,6 +24,16 @@ declare -A \
exit $EBASHVERS exit $EBASHVERS
} }
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
LC_ALL=C LC_ALL=C
shopt -s extglob shopt -s extglob
@ -453,10 +452,7 @@ do
expr2='(,|$)' expr2='(,|$)'
if ! [[ $channelss =~ $expr1"$channels"$expr2 ]] if ! [[ $channelss =~ $expr1"$channels"$expr2 ]]
then then
if [[ -n "$channels" ]] if [ -n "$channelss" ] \
then
:
elif [ -n "$channelss" ] \
&& (( channels < ${channelss%%,*} )) && (( channels < ${channelss%%,*} ))
then then
channelss="$channels,$channelss" channelss="$channels,$channelss"
@ -466,10 +462,7 @@ do
fi fi
if ! [[ $rates =~ $expr1"$rate"$expr2 ]] if ! [[ $rates =~ $expr1"$rate"$expr2 ]]
then then
if [[ -n "$rate" ]] if [ -n "$rates" ] \
then
:
elif [ -n "$rates" ] \
&& (( rate < ${rates%%,*} )) && (( rate < ${rates%%,*} ))
then then
rates="$rate,$rates" rates="$rate,$rates"
@ -479,10 +472,7 @@ do
fi fi
if [ -n "$depth" ] && ! [[ $depths =~ $expr1"$depth"$expr2 ]] if [ -n "$depth" ] && ! [[ $depths =~ $expr1"$depth"$expr2 ]]
then then
if [[ -n "$depth" ]] if [ -n "$depths" ] \
then
:
elif [ -n "$depths" ] \
&& (( depth < ${depths%%,*} )) && (( depth < ${depths%%,*} ))
then then
depths="$depth,$depths" depths="$depth,$depths"

View File

@ -1,18 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
## Define exit codes
source "$SHAREDIR"/errorcodes
# config structures # config structures
declare -A \ declare -A \
destinationchannels \ destinationchannels \
@ -35,6 +22,16 @@ declare -A \
exit $EBASHVERS exit $EBASHVERS
} }
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
LC_ALL=C LC_ALL=C
shopt -s extglob shopt -s extglob

View File

@ -1,18 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
## Define exit codes
source "$SHAREDIR"/errorcodes
# config structures # config structures
declare -A \ declare -A \
destinationchannels \ destinationchannels \
@ -36,6 +23,16 @@ declare -A \
exit $EBASHVERS exit $EBASHVERS
} }
declare -r \
DOCDIR=%DOCDIR% \
LIBDIR=%LIBDIR% \
SHAREDIR=%SHAREDIR%
declare -r \
exampleconf=$DOCDIR/example.cfg \
schema=$SHAREDIR/schema.sql \
\
oldIFS="$IFS"
LC_ALL=C LC_ALL=C
shopt -s extglob shopt -s extglob