diff --git a/atom b/atom index fe2b3e2..2ca72fe 100755 --- a/atom +++ b/atom @@ -43,6 +43,8 @@ declare -r \ \ oldIFS="$IFS" +cffile="$HOME/.atom/atom.cfg" + LC_ALL=C shopt -s extglob @@ -56,12 +58,15 @@ done #parse arguments OPTERR=0 -while getopts ':c:l:T:F:hD' opt +while getopts ':c:Cl:T:F:hD' opt do case $opt in c) cffile="$OPTARG" ;; + C) + cfgdump=1 + ;; l) cliload="$OPTARG" ;; @@ -93,16 +98,16 @@ done #FIXME: check sanity -if [ ! -f ~/.atom/atom.cfg ] +if [ ! -f "$cffile" ] then if [ ! -d ~/.atom ] then mkdir -p ~/.atom fi - sed "s:%HOME%:$HOME:" "$exampleconf" > ~/.atom/atom.cfg + sed "s:%HOME%:$HOME:" "$exampleconf" > "$cffile" cat >&2 <<-EOCfgNotice No configuration file found! - An example file has been created as ~/.atom/atom.cfg. + An example file has been created as "${cffile/$HOME/~}". You should change it to your likings using you favorite editor. Bailing out. @@ -112,38 +117,8 @@ fi getConfig set +H -if (( debug )) -then - cat <<-EOF - General|Load|$maxload - |Load Interval|$loadinterval - |Temp Dir|$tempdir - |Database|$database - |Debug|$debug - Source|Path|$sourcepath - EOF - for prune_expression in "${skippeddirectories[@]}" - do - echo "|Skipped directory|$prune_expression" - done - for destination in ${!destinationpath[@]} - do - cat <<-EOF - $destination|Path|${destinationpath[$destination]} - |Format|${destinationformat[$destination]} - |Quality|${destinationquality[$destination]} - |Normalize|${destinationnormalize[$destination]} - |Channels|${destinationchannels[$destination]} - |Frequency|${destinationfrequency[$destination]} - |Path Change|${destinationrenamepath[$destination]} - |File Rename|${destinationrename[$destination]} - EOF - echo "|Skipped mime-type|${destinationskipmime[$destination]//\|/ -|Skipped mime-type|}" - echo "|Copied mime-type|${destinationcopymime[$destination]//\|/ -|Copied mime-type|}" - done -fi |column -t -s'|' -n +(( debug || cfgdump )) && printConfig +(( cfgdump )) && exit openDatabase @@ -518,7 +493,7 @@ do getDestFile if (( copied )) then - copyFile + copyFiles_matching else encodeFile::${destinationformat[$destination]} fi @@ -561,7 +536,7 @@ starttime=$concurrencychange taskcount=$count remaining=$taskcount failed=0 -while (( remaining && ! quit )) +while (( (remaining || ${#workers[@]}) && ! quit )) do if read -n 1 -t 0.1 userinput then @@ -790,6 +765,8 @@ do unset count done +copyFiles_action + echo ' SELECT id, old_filename @@ -799,9 +776,16 @@ echo ' SELECT "AtOM:NoMoreFiles"; ' >&3 -echo "Removing obsolete files... " +echo -n 'Removing obsolete files... ' +lines=() read -u4 line while [[ $line != AtOM:NoMoreFiles ]] +do + lines+=("$line") + read -u4 line +done +echo 'BEGIN TRANSACTION;' >&3 +for line in "${lines[@]}" do id=${line%%|*} filename=${line#*|} @@ -810,10 +794,11 @@ do rm -f "$filename" fi Update destination_files old_filename NULL <<<"id = $id" - progressSpin - read -u4 line + (( count++ )) + printf '\b\b\b\b%3i%%' $(( (100 * count) / ${#lines[@]} )) done -echo $'\r'"Removed ${count:-0} obsolete files." +echo 'COMMIT;' >&3 +echo -e "\rRemoved ${count:-0} obsolete files.\033[K" echo "Purging empty directories." for path in "${destinationpath[@]}" diff --git a/doc/config b/doc/config index a32eead..4aa2f32 100644 --- a/doc/config +++ b/doc/config @@ -26,6 +26,8 @@ Sections: too quickly. Set this too high, and AtOM will not adapt quickly enough to load increase. In both cases, your hard drive will suffer. In my experience, 30 seconds is a good value. + * ionice [niceness]: IO-hungry processes will be run with ionice class + and niceness [niceness] (if applicable). See man ionice for details. * temporary-directory : String. Name speaks for itself: this is where FIFOs (for communicating with sqlite) and temporary WAVE files will be created. Note that debug logs (if enabled) will go there too. diff --git a/doc/example.cfg b/doc/example.cfg index 1ffdb39..19b2b14 100644 --- a/doc/example.cfg +++ b/doc/example.cfg @@ -1,4 +1,5 @@ [general] +ionice 3 max-load 6 load-interval 30 temporary-directory %HOME%/.atom/tmp diff --git a/lib/config/getConfig b/lib/config/getConfig index 6c14e36..cbc9b5f 100644 --- a/lib/config/getConfig +++ b/lib/config/getConfig @@ -1,3 +1,4 @@ +#!/bin/bash getConfig() { while read key value do @@ -23,5 +24,5 @@ getConfig() { getConfig$context ;; esac - done < ~/.atom/atom.cfg + done < "$cffile" } diff --git a/lib/config/getConfigDestination b/lib/config/getConfigDestination index 6195ed5..a6fa6a8 100644 --- a/lib/config/getConfigDestination +++ b/lib/config/getConfigDestination @@ -1,3 +1,4 @@ +#!/bin/bash getConfigDestination() { case "$key" in 'path') diff --git a/lib/config/getConfigGeneral b/lib/config/getConfigGeneral index 125b7b6..ec183ab 100644 --- a/lib/config/getConfigGeneral +++ b/lib/config/getConfigGeneral @@ -1,3 +1,4 @@ +#!/bin/bash getConfigGeneral() { case $key in 'max-load') @@ -22,6 +23,49 @@ getConfigGeneral() { fi unset expr ;; + 'ionice') + read class niceness <<<"$value" + case $class in + 1) + # real-time class, only root can do that + if (( UID )) + then + echo "IO class 'realtime' is"\ + "not available to unprivileged"\ + "users" >&2 + exit $EIONICE + fi + if [ -n "$niceness" ] \ + && (( niceness >= 0 && niceness <= 7 )) + then + ionice="ionice -c1 -n$niceness " + else + echo "Invalid IO priority"\ + "'$niceness'" >&2 + exit $EIONICE + fi + ;; + 2) + if [ -n "$niceness" ] \ + && (( niceness >= 0 && niceness <= 7 )) + then + ionice="ionice -c2 -n$niceness " + else + echo "Invalid IO priority"\ + "'$niceness'" >&2 + exit $EIONICE + fi + ;; + 3) + ionice="ionice -c3 " + ;; + *) + echo "Invalid ionice parameters $value"\ + >&2 + exit $EIONICE + ;; + esac + ;; 'temporary-directory') tempdir="$value" ;; diff --git a/lib/config/getConfigSource b/lib/config/getConfigSource index 9df19c3..1042969 100644 --- a/lib/config/getConfigSource +++ b/lib/config/getConfigSource @@ -1,3 +1,4 @@ +#!/bin/bash getConfigSource() { case "$key" in 'path') diff --git a/lib/config/print b/lib/config/print new file mode 100644 index 0000000..0a4fea4 --- /dev/null +++ b/lib/config/print @@ -0,0 +1,54 @@ +#!/bin/bash +printConfig() { + { + echo "General|Config file|$cffile" + [ -n "$ionice" ] && echo "|IO Nice|$ionice" + cat <<-EOF + |Load|$maxload + |Load Interval|$loadinterval + |Temp Dir|$tempdir + |Database|$database + |Debug|$debug + Source|Path|$sourcepath + EOF + for prune_expression in "${skippeddirectories[@]}" + do + (( printed )) \ + && echo -n '||' \ + || echo -n '|Skipped directories|' + echo "$prune_expression" + printed=1 + done + unset printed + for destination in ${!destinationpath[@]} + do + cat <<-EOF + $destination|Path|${destinationpath["$destination"]} + |Format|${destinationformat["$destination"]} + |Quality|${destinationquality["$destination"]} + EOF + if [[ ${destinationformat["$destination"]} == opus ]] + then + echo "|Expected loss|${destinationloss["$destination"]}" + elif [[ ${destinationformat["$destination"]} == mp3 ]] + then + echo "|Prevent resampling|${destinationnoresample["$destination"]}" + fi + cat <<-EOF + |Normalize|${destinationnormalize["$destination"]} + |Channels|${destinationchannels["$destination"]} + |Frequency|${destinationfrequency["$destination"]} + |Higher than|${destinationmaxbps["$destination"]} + |Fat32 Compat.|${destinationfat32compat["$destination"]} + |Path Change|${destinationrenamepath["$destination"]} + |File Rename|${destinationrename["$destination"]} + EOF + [ -n "${destinationskipmime["$destination"]}" ] \ + && echo "|Skipped mime-types|${destinationskipmime["$destination"]//\|/ +||}" + [ -n "${destinationmskipime["$destination"]}" ] \ + && echo "|Copied mime-types|${destinationcopymime["$destination"]//\|/ +||}" + done + }|column -t -s'|' -n +} diff --git a/lib/copy/checkCopy b/lib/copy/checkCopy index 7aa76d6..44738dd 100644 --- a/lib/copy/checkCopy +++ b/lib/copy/checkCopy @@ -1,3 +1,4 @@ +#!/bin/bash checkCopy() { ( [ -z "${destinationfrequency[$destination]}" ] \ @@ -9,7 +10,7 @@ checkCopy() { (( ${bitrate:-1000} == ${destinationquality[$destination]} )) \ || ( [ -n "${destinationmaxbps[$destination]}" ] \ - || (( + && (( ${bitrate:-1000} <= ${destinationmaxbps[$destination]:-0} )) diff --git a/lib/copy/copyFiles_action b/lib/copy/copyFiles_action new file mode 100644 index 0000000..86820cc --- /dev/null +++ b/lib/copy/copyFiles_action @@ -0,0 +1,83 @@ +#!/bin/bash +copyFiles_action() { + echo -n "Copying files... " + echo ' + SELECT + source_files.filename, + source_files.last_change, + destinations.id, + destination_files.id + FROM source_files + INNER JOIN destination_files + ON source_files.id + = destination_files.source_file_id + INNER JOIN destinations + ON destination_files.destination_id=destinations.id + INNER JOIN mime_type_actions + ON mime_type_actions.id = source_files.mime_type + WHERE CAST(destination_files.last_change AS TEXT) + <> CAST(source_files.last_change AS TEXT) + AND mime_type_actions.destination_id = destinations.id + AND mime_type_actions.action = 2; + + SELECT "AtOM:NoMoreFiles";' >&3 + read -u4 line + while ! [[ $line = AtOM:NoMoreFiles ]] + do + copyfiles+=("$line") + read -u4 line + done + + echo 'BEGIN TRANSACTION;' >&3 + for copyfile in "${copyfiles[@]}" + do + sourcefilename=${copyfile%%|*} + sourcedir=${sourcefilename%/*} + rest="${copyfile#*|}|" + lastchange=${rest%%|*} + rest=${rest#*|} + destinationid=${rest%%|*} + rest=${rest#*|} + destfileid=${rest%%|*} + rest=${rest#*|} + echo 'SELECT IFNULL( ( + SELECT destination_files.filename + FROM destination_files + INNER JOIN source_files + ON destination_files.source_file_id=source_files.id + INNER JOIN mime_type_actions + ON + mime_type_actions.id=source_files.mime_type + INNER JOIN destinations + ON destinations.id=destination_files.destination_id + WHERE destinations.id = '$destinationid' + AND source_files.filename LIKE + "'"${sourcedir//\"/\"\"}"'/%" + AND mime_type_actions.action = 1 + LIMIT 1 + ),"AtOM:NotFound"); + '>&3 + read -u4 filename + if [[ $filename != AtOM:NotFound ]] + then + destdir=${filename%/*} + if cp -al "$sourcepath/$sourcefilename" "$destdir" 2>/dev/null\ + || cp -a "$sourcepath/$sourcefilename" "$destdir" + then + Update destination_files \ + filename "$destdir/${sourcefilename##*/}"\ + rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]}"\ + last_change $lastchange \ + <<-EOWhere + id = $destfileid + EOWhere + (( done++ )) + fi + fi + (( count++ )) + printf '\b\b\b\b%3i%%' $(( (count * 100) / ${#copyfiles[@]} )) + done + echo 'COMMIT;' >&3 + echo -e "\rCopied ${done:-0} of $count files.\033[K" + unset count done +} diff --git a/lib/copy/copyFile b/lib/copy/copyFiles_matching similarity index 83% rename from lib/copy/copyFile rename to lib/copy/copyFiles_matching index 9e7b784..64a3744 100644 --- a/lib/copy/copyFile +++ b/lib/copy/copyFiles_matching @@ -1,4 +1,5 @@ -copyFile() { +#!/bin/bash +copyFiles_matching() { extension="${filename##*.}" cp -al \ "$sourcepath/$filename" \ @@ -7,9 +8,10 @@ copyFile() { || cp -a \ "$sourcepath/$filename" \ "$destdir/$destfile.$extension" - echo \ + echo \ "UPDATE destination_files" \ - "SET filename=\"${filename//\"/\"\"}\"," \ + "SET filename=" \ + "\"${destdir//\"/\"\"}/${destfile//\"/\"\"}.$extension\"," \ " last_change=(" \ " SELECT last_change" \ " FROM source_files" \ diff --git a/lib/database/Delete b/lib/database/Delete index 2cd5718..01933ce 100644 --- a/lib/database/Delete +++ b/lib/database/Delete @@ -1,3 +1,4 @@ +#!/bin/bash Delete() { #Delete table < where_key where_operator where_value # [where_key where_operator where_value diff --git a/lib/database/Insert b/lib/database/Insert index 1e0338b..77f7ec2 100644 --- a/lib/database/Insert +++ b/lib/database/Insert @@ -1,3 +1,4 @@ +#!/bin/bash Insert() { #Insert table [no_id] < key value # [key value diff --git a/lib/database/InsertIfUnset b/lib/database/InsertIfUnset index c81ce33..4277a62 100644 --- a/lib/database/InsertIfUnset +++ b/lib/database/InsertIfUnset @@ -1,3 +1,4 @@ +#!/bin/bash InsertIfUnset() { #InsertIfUnset table [no_id] < key value \n key value local \ diff --git a/lib/database/InsertOrUpdate b/lib/database/InsertOrUpdate index 2fdf7c2..4f25110 100644 --- a/lib/database/InsertOrUpdate +++ b/lib/database/InsertOrUpdate @@ -1,3 +1,4 @@ +#!/bin/bash InsertOrUpdate() { #InsertOrUpdate table set_key set_value [set_key set_value […]] < where_key where_value # [where_key where_value diff --git a/lib/database/Select b/lib/database/Select index 4a0ca7e..b096953 100644 --- a/lib/database/Select +++ b/lib/database/Select @@ -1,3 +1,4 @@ +#!/bin/bash Select() { #Select table [col1 [col2 [..]]] < WHERE_key WHERE_operator WHERE_value # [WHERE_key WHERE_operator WHERE_value diff --git a/lib/database/Update b/lib/database/Update index 2e5f1c5..0fe5db5 100644 --- a/lib/database/Update +++ b/lib/database/Update @@ -1,3 +1,4 @@ +#!/bin/bash Update() { #Update table set_key set_value [set_key set_value […]] < where_key where_operator where_value # [where_key where_operator where_value diff --git a/lib/database/closeDatabase b/lib/database/closeDatabase index 91dccad..2d6e1a2 100644 --- a/lib/database/closeDatabase +++ b/lib/database/closeDatabase @@ -1,3 +1,4 @@ +#!/bin/bash closeDatabase() { echo .quit >&3 (( debug )) && echo -n "Waiting for SQLite to terminate... " diff --git a/lib/database/openDatabase b/lib/database/openDatabase index 1b4f970..74f4745 100644 --- a/lib/database/openDatabase +++ b/lib/database/openDatabase @@ -1,3 +1,4 @@ +#!/bin/bash openDatabase() { if [ ! -d "$tempdir" ] then diff --git a/lib/decode/decodeFile b/lib/decode/decodeFile index fb6591b..b66c6ef 100644 --- a/lib/decode/decodeFile +++ b/lib/decode/decodeFile @@ -1,3 +1,4 @@ +#!/bin/bash decodeFile() { if ! decodetaskid=$( Select tasks id <<<"key = $tmpfile" diff --git a/lib/decode/decodeMpcdec b/lib/decode/decodeMpcdec index e1ee72c..3bbd71c 100644 --- a/lib/decode/decodeMpcdec +++ b/lib/decode/decodeMpcdec @@ -1,4 +1,6 @@ +#!/bin/bash decodeMpcdec() { tmpfile="${fileid}mpcdec" - commandline=(mpcdec "$sourcepath/$filename" "$tempdir/$tmpfile.wav") + commandline=(${ionice}mpcdec) + commandline+=("$sourcepath/$filename" "$tempdir/$tmpfile.wav") } diff --git a/lib/decode/decodeOpusdec b/lib/decode/decodeOpusdec index 4721b89..46f08bd 100644 --- a/lib/decode/decodeOpusdec +++ b/lib/decode/decodeOpusdec @@ -1,4 +1,6 @@ +#!/bin/bash decodeOpusdec() { tmpfile="${fileid}opusdec" - commandline=(opusdec "$sourcepath/$filename" "$tempdir/$tmpfile.wav") + commandline=(${ionice}opusdec) + commandline+=("$sourcepath/$filename" "$tempdir/$tmpfile.wav") } diff --git a/lib/decode/decodeSox b/lib/decode/decodeSox index 84c29c6..5d7e6df 100644 --- a/lib/decode/decodeSox +++ b/lib/decode/decodeSox @@ -1,5 +1,6 @@ +#!/bin/bash decodeSox() { - commandline=(sox --single-threaded --temp "$tempdir") + commandline=(${ionice}sox --single-threaded --temp "$tempdir") soxoptions_in='' soxoptions_out='' if (( ${destinationnormalize["$destination"]} )) diff --git a/lib/destinations/createDestinations b/lib/destinations/createDestinations index f2c2d51..fc6e3bc 100644 --- a/lib/destinations/createDestinations +++ b/lib/destinations/createDestinations @@ -1,3 +1,4 @@ +#!/bin/bash createDestinations() { for destination in ${!destinationpath[@]} do diff --git a/lib/destinations/updateMimes b/lib/destinations/updateMimes index 8fc433d..189572b 100644 --- a/lib/destinations/updateMimes +++ b/lib/destinations/updateMimes @@ -1,3 +1,4 @@ +#!/bin/bash updateMimes() { Update mime_actions action 1 <<<"action != 1" for destination in ${!destinationskipmime[@]} diff --git a/lib/encode/encodeFile::mp3 b/lib/encode/encodeFile::mp3 index b49bd05..c958f2a 100644 --- a/lib/encode/encodeFile::mp3 +++ b/lib/encode/encodeFile::mp3 @@ -1,5 +1,7 @@ +#!/bin/bash encodeFile::mp3() { - lameopts=(lame --quiet -v --abr ${destinationquality[$destination]}) + lameopts=(${ionice}lame --quiet) + lameopts+=(-v --abr ${destinationquality[$destination]}) [ -n "$album" ] && lameopts+=(--tl "$album" ) [ -n "$artist" ] && lameopts+=(--ta "$artist") [ -n "$genre" ] && lameopts+=(--tg "$genre") diff --git a/lib/encode/encodeFile::opus b/lib/encode/encodeFile::opus index 50d8a1c..2794a05 100644 --- a/lib/encode/encodeFile::opus +++ b/lib/encode/encodeFile::opus @@ -1,5 +1,6 @@ +#!/bin/bash encodeFile::opus() { - opusencopts=(opusenc --music --quiet) + opusencopts=(${ionice}opusenc --music --quiet) opusencopts+=(--bitrate ${destinationquality[$destination]}) [ -n "${destinationloss["$destination"]}" ] \ && opusencopts+=(--expect-loss "${destinationloss["$destination"]}") diff --git a/lib/encode/encodeFile::vorbis b/lib/encode/encodeFile::vorbis index 7ff4acd..c3a72e3 100644 --- a/lib/encode/encodeFile::vorbis +++ b/lib/encode/encodeFile::vorbis @@ -1,5 +1,6 @@ +#!/bin/bash encodeFile::vorbis() { - oggencopts=(oggenc -Q -q ${destinationquality[$destination]}) + oggencopts=(${ionice}oggenc -Q -q ${destinationquality[$destination]}) [ -n "$albumartist" ] && oggencopts+=(-c "ALBUMARTIST=$albumartist") [ -n "$album" ] && oggencopts+=(-l "$album") [ -n "$artist" ] && oggencopts+=(-a "$artist") diff --git a/lib/files/getDestDir b/lib/files/getDestDir index 4f0baae..81b6839 100644 --- a/lib/files/getDestDir +++ b/lib/files/getDestDir @@ -1,29 +1,31 @@ +#!/bin/bash getDestDir() { destdir="${destinationpath[$destination]}/" if [ -n "${destinationrenamepath[$destination]}" ] then - destdir+="${destinationrenamepath[$destination]//%\{album\}/$album}" - replace=$(sanitizeFile "$albumartist") + replace=$(sanitizeFile "$album" dir) + destdir+="${destinationrenamepath[$destination]//%\{album\}/$replace}" + replace=$(sanitizeFile "$albumartist" dir) destdir="${destdir//%\{albumartist\}/$replace}" - replace=$(sanitizeFile "$artist") + replace=$(sanitizeFile "$artist" dir) destdir="${destdir//%\{artist\}/$replace}" - replace=$(sanitizeFile "$genre") + replace=$(sanitizeFile "$genre" dir) destdir="${destdir//%\{genre\}/$replace}" - replace=$(sanitizeFile "$title") + replace=$(sanitizeFile "$title" dir) destdir="${destdir//%\{title\}/$replace}" tracknumber="${track%/*}" - replace=$(sanitizeFile "$tracknumber") + replace=$(sanitizeFile "$tracknumber" dir) destdir="${destdir//%\{track\}/$replace}" - replace=$(sanitizeFile "$year") + replace=$(sanitizeFile "$year" dir) destdir="${destdir//%\{year\}/$replace}" - replace=$(sanitizeFile "$disc") + replace=$(sanitizeFile "$disc" dir) destdir="${destdir//%\{disc\}/$replace}" else - destdir+=$(sanitizeFile "${filename%%/*}") + destdir+=$(sanitizeFile "${filename%%/*}" dir) part=${filename#*/} while [[ $part =~ / ]] do - destdir+="/$(sanitizeFile "${part%%/*}")" + destdir+="/$(sanitizeFile "${part%%/*}" dir)" part=${part#*/} done fi diff --git a/lib/files/getDestFile b/lib/files/getDestFile index 14f4874..7730b48 100644 --- a/lib/files/getDestFile +++ b/lib/files/getDestFile @@ -1,3 +1,4 @@ +#!/bin/bash getDestFile() { if [ -n "${destinationrename[$destination]}" ] then diff --git a/lib/files/getFiles b/lib/files/getFiles index 977bc4a..1b53e6f 100644 --- a/lib/files/getFiles +++ b/lib/files/getFiles @@ -1,3 +1,4 @@ +#!/bin/bash getFiles() { scantime=$(date +%s) for prune_expression in "${skippeddirectories[@]}" diff --git a/lib/files/removeObsoleteFiles b/lib/files/removeObsoleteFiles index 6cf0f54..69bd04b 100644 --- a/lib/files/removeObsoleteFiles +++ b/lib/files/removeObsoleteFiles @@ -1,3 +1,4 @@ +#!/bin/bash removeObsoleteFiles() { Delete source_files <<-EOWhere last_seen < $scantime diff --git a/lib/files/sanitizeFile b/lib/files/sanitizeFile index 90a3ebc..07e8e50 100644 --- a/lib/files/sanitizeFile +++ b/lib/files/sanitizeFile @@ -1,3 +1,4 @@ +#!/bin/bash sanitizeFile() { shopt -s extglob string="$1" @@ -18,6 +19,13 @@ sanitizeFile() { # Filenames can't begin or end with ' ' string=${string/#+( )/} string=${string/%+( )/} + + # Directory names can't begin or end with '.' + if [[ $2 == dir ]] + then + string=${string/#+(.)/} + string=${string/%+(.)/} + fi fi echo "$string" } diff --git a/lib/tags/getInfos::APE b/lib/tags/getInfos::APE index 181c668..66f2a29 100644 --- a/lib/tags/getInfos::APE +++ b/lib/tags/getInfos::APE @@ -1,3 +1,4 @@ +#!/bin/bash getInfosAPE_version='APE-1' tagreaders+=( "$getInfosAPE_version" ) getInfos::APE() { diff --git a/lib/tags/getInfos::FLAC b/lib/tags/getInfos::FLAC index 04533fa..288eac7 100644 --- a/lib/tags/getInfos::FLAC +++ b/lib/tags/getInfos::FLAC @@ -1,3 +1,4 @@ +#!/bin/bash getInfosFLAC_version='FLAC-1' tagreaders+=( "$getInfosFLAC_version" ) getInfos::FLAC() { diff --git a/lib/tags/getInfos::MP3 b/lib/tags/getInfos::MP3 index 62290dc..c98de74 100644 --- a/lib/tags/getInfos::MP3 +++ b/lib/tags/getInfos::MP3 @@ -1,3 +1,4 @@ +#!/bin/bash getInfosMP3_version='ID3-2' tagreaders+=( "$getInfosMP3_version" ) getInfos::MP3() { diff --git a/lib/tags/getInfos::Ogg b/lib/tags/getInfos::Ogg index 175fe00..c376496 100644 --- a/lib/tags/getInfos::Ogg +++ b/lib/tags/getInfos::Ogg @@ -1,3 +1,4 @@ +#!/bin/bash getInfosOgg_version='Ogg-1' tagreaders+=( "$getInfosOgg_version" ) getInfos::Ogg() { diff --git a/lib/tags/getInfos::Opus b/lib/tags/getInfos::Opus index 61198ba..2f99289 100644 --- a/lib/tags/getInfos::Opus +++ b/lib/tags/getInfos::Opus @@ -1,3 +1,4 @@ +#!/bin/bash getInfosOpus_version='Opus-1' tagreaders+=( "$getInfosOpus_version" ) getInfos::Opus() { diff --git a/lib/tags/getRateChannelMPC b/lib/tags/getRateChannelMPC index 05fdbc9..14b28ba 100644 --- a/lib/tags/getRateChannelMPC +++ b/lib/tags/getRateChannelMPC @@ -1,3 +1,4 @@ +#!/bin/bash getRateChannelMPC() { while read key value garbage do diff --git a/lib/tags/getRateChannelSoxi b/lib/tags/getRateChannelSoxi index a8613cb..91db5fe 100644 --- a/lib/tags/getRateChannelSoxi +++ b/lib/tags/getRateChannelSoxi @@ -1,3 +1,4 @@ +#!/bin/bash getRateChannelSoxi() { rate=$(soxi -r "$sourcepath/$filename" 2>/dev/null) channels=$(soxi -c "$sourcepath/$filename" 2>/dev/null) diff --git a/lib/tags/getTags b/lib/tags/getTags index dbc08e3..6a735df 100644 --- a/lib/tags/getTags +++ b/lib/tags/getTags @@ -1,3 +1,4 @@ +#!/bin/bash getTags_version='unknown-2' tagreaders+=( "$getTags_version" ) getTags() { diff --git a/lib/tags/gettag b/lib/tags/gettag index d6f6a2d..b6f5409 100644 --- a/lib/tags/gettag +++ b/lib/tags/gettag @@ -1,3 +1,4 @@ +#!/bin/bash gettag() { echo -e "$infos" \ | sed -n "/^${1}=/I{s/^${1}=//I;p;q}" diff --git a/lib/tags/tryAPE b/lib/tags/tryAPE index 3cf2db2..53f963e 100644 --- a/lib/tags/tryAPE +++ b/lib/tags/tryAPE @@ -1,3 +1,4 @@ +#!/bin/bash tryAPE() { grep -q 'APETAGEX' \ "$sourcepath/$filename" \ diff --git a/lib/tasks/gettaskinfos b/lib/tasks/gettaskinfos index a92fe91..f0023bd 100644 --- a/lib/tasks/gettaskinfos +++ b/lib/tasks/gettaskinfos @@ -1,3 +1,4 @@ +#!/bin/bash gettaskinfos() { echo ' SELECT diff --git a/lib/tools/progressSpin b/lib/tools/progressSpin index ba41f8e..cecff55 100644 --- a/lib/tools/progressSpin +++ b/lib/tools/progressSpin @@ -1,3 +1,4 @@ +#!/bin/bash progressSpin() { case $(( ++count % 40 )) in 0) echo -ne '\b|' ;; diff --git a/lib/workers/checkworkers b/lib/workers/checkworkers index f8b711e..fa52afb 100644 --- a/lib/workers/checkworkers +++ b/lib/workers/checkworkers @@ -1,3 +1,4 @@ +#!/bin/bash checkworkers() { for key in ${!workers[@]} do diff --git a/lib/workers/cleaner b/lib/workers/cleaner index c1bc581..3db4e0a 100644 --- a/lib/workers/cleaner +++ b/lib/workers/cleaner @@ -1,3 +1,4 @@ +#!/bin/bash cleaner() { for key in ${!failedtasks[@]} do diff --git a/lib/workers/createworker b/lib/workers/createworker index a2b955a..16d8e24 100644 --- a/lib/workers/createworker +++ b/lib/workers/createworker @@ -1,3 +1,4 @@ +#!/bin/bash createworker() { worker $1 & workers[$1]=$! diff --git a/lib/workers/destroyworker b/lib/workers/destroyworker index 707c574..3e34426 100644 --- a/lib/workers/destroyworker +++ b/lib/workers/destroyworker @@ -1,3 +1,4 @@ +#!/bin/bash destroyworker() { dyingworker=${workers[$1]} unset workers[$1] diff --git a/lib/workers/getworkerid b/lib/workers/getworkerid index 0d7ddc3..4e6affc 100644 --- a/lib/workers/getworkerid +++ b/lib/workers/getworkerid @@ -1,3 +1,4 @@ +#!/bin/bash getworkerid() { local i for (( i=0 ; i >= 0 ; i++ )) diff --git a/lib/workers/master b/lib/workers/master index 518dc72..4c22abe 100644 --- a/lib/workers/master +++ b/lib/workers/master @@ -1,3 +1,4 @@ +#!/bin/bash master() { if (( active >= concurrency)) || [ -n "$quit" ] then diff --git a/lib/workers/worker b/lib/workers/worker index 4dd40b5..c4b5954 100644 --- a/lib/workers/worker +++ b/lib/workers/worker @@ -1,3 +1,4 @@ +#!/bin/bash worker() { exec 2>>"$tempdir/worker$1.log" (( debug >= 2 )) && echo "${cmd_arg[@]}" >&2