Merge branch 'master' into toys
* master: fat32compat: no . at beginning or end of dirname copy files: fix DB update remove obsolete (renamed) files: read all data from sqlite first - prevents deadlock fix bitrate copy check fix filepath for copied files wait for last tasks copyFiles_action: protect '"' from SQL ionice implement -c add shebang on lib files print config move files copy copy_mime-type fat32compat: nodes ending with "."
This commit is contained in:
commit
c46f9d86cb
69
atom
69
atom
@ -43,6 +43,8 @@ declare -r \
|
|||||||
\
|
\
|
||||||
oldIFS="$IFS"
|
oldIFS="$IFS"
|
||||||
|
|
||||||
|
cffile="$HOME/.atom/atom.cfg"
|
||||||
|
|
||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
|
|
||||||
shopt -s extglob
|
shopt -s extglob
|
||||||
@ -56,12 +58,15 @@ done
|
|||||||
|
|
||||||
#parse arguments
|
#parse arguments
|
||||||
OPTERR=0
|
OPTERR=0
|
||||||
while getopts ':c:l:T:F:hD' opt
|
while getopts ':c:Cl:T:F:hD' opt
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
c)
|
c)
|
||||||
cffile="$OPTARG"
|
cffile="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
C)
|
||||||
|
cfgdump=1
|
||||||
|
;;
|
||||||
l)
|
l)
|
||||||
cliload="$OPTARG"
|
cliload="$OPTARG"
|
||||||
;;
|
;;
|
||||||
@ -93,16 +98,16 @@ done
|
|||||||
|
|
||||||
#FIXME: check sanity
|
#FIXME: check sanity
|
||||||
|
|
||||||
if [ ! -f ~/.atom/atom.cfg ]
|
if [ ! -f "$cffile" ]
|
||||||
then
|
then
|
||||||
if [ ! -d ~/.atom ]
|
if [ ! -d ~/.atom ]
|
||||||
then
|
then
|
||||||
mkdir -p ~/.atom
|
mkdir -p ~/.atom
|
||||||
fi
|
fi
|
||||||
sed "s:%HOME%:$HOME:" "$exampleconf" > ~/.atom/atom.cfg
|
sed "s:%HOME%:$HOME:" "$exampleconf" > "$cffile"
|
||||||
cat >&2 <<-EOCfgNotice
|
cat >&2 <<-EOCfgNotice
|
||||||
No configuration file found!
|
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.
|
You should change it to your likings using you favorite editor.
|
||||||
|
|
||||||
Bailing out.
|
Bailing out.
|
||||||
@ -112,38 +117,8 @@ fi
|
|||||||
getConfig
|
getConfig
|
||||||
|
|
||||||
set +H
|
set +H
|
||||||
if (( debug ))
|
(( debug || cfgdump )) && printConfig
|
||||||
then
|
(( cfgdump )) && exit
|
||||||
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
|
|
||||||
|
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
@ -518,7 +493,7 @@ do
|
|||||||
getDestFile
|
getDestFile
|
||||||
if (( copied ))
|
if (( copied ))
|
||||||
then
|
then
|
||||||
copyFile
|
copyFiles_matching
|
||||||
else
|
else
|
||||||
encodeFile::${destinationformat[$destination]}
|
encodeFile::${destinationformat[$destination]}
|
||||||
fi
|
fi
|
||||||
@ -561,7 +536,7 @@ starttime=$concurrencychange
|
|||||||
taskcount=$count
|
taskcount=$count
|
||||||
remaining=$taskcount
|
remaining=$taskcount
|
||||||
failed=0
|
failed=0
|
||||||
while (( remaining && ! quit ))
|
while (( (remaining || ${#workers[@]}) && ! quit ))
|
||||||
do
|
do
|
||||||
if read -n 1 -t 0.1 userinput
|
if read -n 1 -t 0.1 userinput
|
||||||
then
|
then
|
||||||
@ -790,6 +765,8 @@ do
|
|||||||
unset count
|
unset count
|
||||||
done
|
done
|
||||||
|
|
||||||
|
copyFiles_action
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
SELECT id,
|
SELECT id,
|
||||||
old_filename
|
old_filename
|
||||||
@ -799,9 +776,16 @@ echo '
|
|||||||
SELECT "AtOM:NoMoreFiles";
|
SELECT "AtOM:NoMoreFiles";
|
||||||
' >&3
|
' >&3
|
||||||
|
|
||||||
echo "Removing obsolete files... "
|
echo -n 'Removing obsolete files... '
|
||||||
|
lines=()
|
||||||
read -u4 line
|
read -u4 line
|
||||||
while [[ $line != AtOM:NoMoreFiles ]]
|
while [[ $line != AtOM:NoMoreFiles ]]
|
||||||
|
do
|
||||||
|
lines+=("$line")
|
||||||
|
read -u4 line
|
||||||
|
done
|
||||||
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
|
for line in "${lines[@]}"
|
||||||
do
|
do
|
||||||
id=${line%%|*}
|
id=${line%%|*}
|
||||||
filename=${line#*|}
|
filename=${line#*|}
|
||||||
@ -810,10 +794,11 @@ do
|
|||||||
rm -f "$filename"
|
rm -f "$filename"
|
||||||
fi
|
fi
|
||||||
Update destination_files old_filename NULL <<<"id = $id"
|
Update destination_files old_filename NULL <<<"id = $id"
|
||||||
progressSpin
|
(( count++ ))
|
||||||
read -u4 line
|
printf '\b\b\b\b%3i%%' $(( (100 * count) / ${#lines[@]} ))
|
||||||
done
|
done
|
||||||
echo $'\r'"Removed ${count:-0} obsolete files."
|
echo 'COMMIT;' >&3
|
||||||
|
echo -e "\rRemoved ${count:-0} obsolete files.\033[K"
|
||||||
|
|
||||||
echo "Purging empty directories."
|
echo "Purging empty directories."
|
||||||
for path in "${destinationpath[@]}"
|
for path in "${destinationpath[@]}"
|
||||||
|
|||||||
@ -26,6 +26,8 @@ Sections:
|
|||||||
too quickly. Set this too high, and AtOM will not adapt quickly enough to
|
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
|
load increase. In both cases, your hard drive will suffer. In my
|
||||||
experience, 30 seconds is a good value.
|
experience, 30 seconds is a good value.
|
||||||
|
* ionice <class> [niceness]: IO-hungry processes will be run with ionice class
|
||||||
|
<class> and niceness [niceness] (if applicable). See man ionice for details.
|
||||||
* temporary-directory <directory>: String. Name speaks for itself: this is
|
* temporary-directory <directory>: String. Name speaks for itself: this is
|
||||||
where FIFOs (for communicating with sqlite) and temporary WAVE files will
|
where FIFOs (for communicating with sqlite) and temporary WAVE files will
|
||||||
be created. Note that debug logs (if enabled) will go there too.
|
be created. Note that debug logs (if enabled) will go there too.
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
[general]
|
[general]
|
||||||
|
ionice 3
|
||||||
max-load 6
|
max-load 6
|
||||||
load-interval 30
|
load-interval 30
|
||||||
temporary-directory %HOME%/.atom/tmp
|
temporary-directory %HOME%/.atom/tmp
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getConfig() {
|
getConfig() {
|
||||||
while read key value
|
while read key value
|
||||||
do
|
do
|
||||||
@ -23,5 +24,5 @@ getConfig() {
|
|||||||
getConfig$context
|
getConfig$context
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done < ~/.atom/atom.cfg
|
done < "$cffile"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getConfigDestination() {
|
getConfigDestination() {
|
||||||
case "$key" in
|
case "$key" in
|
||||||
'path')
|
'path')
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getConfigGeneral() {
|
getConfigGeneral() {
|
||||||
case $key in
|
case $key in
|
||||||
'max-load')
|
'max-load')
|
||||||
@ -22,6 +23,49 @@ getConfigGeneral() {
|
|||||||
fi
|
fi
|
||||||
unset expr
|
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')
|
'temporary-directory')
|
||||||
tempdir="$value"
|
tempdir="$value"
|
||||||
;;
|
;;
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getConfigSource() {
|
getConfigSource() {
|
||||||
case "$key" in
|
case "$key" in
|
||||||
'path')
|
'path')
|
||||||
|
|||||||
54
lib/config/print
Normal file
54
lib/config/print
Normal file
@ -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
|
||||||
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
checkCopy() {
|
checkCopy() {
|
||||||
(
|
(
|
||||||
[ -z "${destinationfrequency[$destination]}" ] \
|
[ -z "${destinationfrequency[$destination]}" ] \
|
||||||
@ -9,7 +10,7 @@ checkCopy() {
|
|||||||
(( ${bitrate:-1000} == ${destinationquality[$destination]} )) \
|
(( ${bitrate:-1000} == ${destinationquality[$destination]} )) \
|
||||||
|| (
|
|| (
|
||||||
[ -n "${destinationmaxbps[$destination]}" ] \
|
[ -n "${destinationmaxbps[$destination]}" ] \
|
||||||
|| ((
|
&& ((
|
||||||
${bitrate:-1000}
|
${bitrate:-1000}
|
||||||
<= ${destinationmaxbps[$destination]:-0}
|
<= ${destinationmaxbps[$destination]:-0}
|
||||||
))
|
))
|
||||||
|
|||||||
83
lib/copy/copyFiles_action
Normal file
83
lib/copy/copyFiles_action
Normal file
@ -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
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
copyFile() {
|
#!/bin/bash
|
||||||
|
copyFiles_matching() {
|
||||||
extension="${filename##*.}"
|
extension="${filename##*.}"
|
||||||
cp -al \
|
cp -al \
|
||||||
"$sourcepath/$filename" \
|
"$sourcepath/$filename" \
|
||||||
@ -7,9 +8,10 @@ copyFile() {
|
|||||||
|| cp -a \
|
|| cp -a \
|
||||||
"$sourcepath/$filename" \
|
"$sourcepath/$filename" \
|
||||||
"$destdir/$destfile.$extension"
|
"$destdir/$destfile.$extension"
|
||||||
echo \
|
echo \
|
||||||
"UPDATE destination_files" \
|
"UPDATE destination_files" \
|
||||||
"SET filename=\"${filename//\"/\"\"}\"," \
|
"SET filename=" \
|
||||||
|
"\"${destdir//\"/\"\"}/${destfile//\"/\"\"}.$extension\"," \
|
||||||
" last_change=(" \
|
" last_change=(" \
|
||||||
" SELECT last_change" \
|
" SELECT last_change" \
|
||||||
" FROM source_files" \
|
" FROM source_files" \
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
Delete() {
|
Delete() {
|
||||||
#Delete table < where_key where_operator where_value
|
#Delete table < where_key where_operator where_value
|
||||||
# [where_key where_operator where_value
|
# [where_key where_operator where_value
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
Insert() {
|
Insert() {
|
||||||
#Insert table [no_id] < key value
|
#Insert table [no_id] < key value
|
||||||
# [key value
|
# [key value
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
InsertIfUnset() {
|
InsertIfUnset() {
|
||||||
#InsertIfUnset table [no_id] < key value \n key value
|
#InsertIfUnset table [no_id] < key value \n key value
|
||||||
local \
|
local \
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
InsertOrUpdate() {
|
InsertOrUpdate() {
|
||||||
#InsertOrUpdate table set_key set_value [set_key set_value […]] < where_key where_value
|
#InsertOrUpdate table set_key set_value [set_key set_value […]] < where_key where_value
|
||||||
# [where_key where_value
|
# [where_key where_value
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
Select() {
|
Select() {
|
||||||
#Select table [col1 [col2 [..]]] < WHERE_key WHERE_operator WHERE_value
|
#Select table [col1 [col2 [..]]] < WHERE_key WHERE_operator WHERE_value
|
||||||
# [WHERE_key WHERE_operator WHERE_value
|
# [WHERE_key WHERE_operator WHERE_value
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
Update() {
|
Update() {
|
||||||
#Update table set_key set_value [set_key set_value […]] < where_key where_operator where_value
|
#Update table set_key set_value [set_key set_value […]] < where_key where_operator where_value
|
||||||
# [where_key where_operator where_value
|
# [where_key where_operator where_value
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
closeDatabase() {
|
closeDatabase() {
|
||||||
echo .quit >&3
|
echo .quit >&3
|
||||||
(( debug )) && echo -n "Waiting for SQLite to terminate... "
|
(( debug )) && echo -n "Waiting for SQLite to terminate... "
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
openDatabase() {
|
openDatabase() {
|
||||||
if [ ! -d "$tempdir" ]
|
if [ ! -d "$tempdir" ]
|
||||||
then
|
then
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
decodeFile() {
|
decodeFile() {
|
||||||
if ! decodetaskid=$(
|
if ! decodetaskid=$(
|
||||||
Select tasks id <<<"key = $tmpfile"
|
Select tasks id <<<"key = $tmpfile"
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
decodeMpcdec() {
|
decodeMpcdec() {
|
||||||
tmpfile="${fileid}mpcdec"
|
tmpfile="${fileid}mpcdec"
|
||||||
commandline=(mpcdec "$sourcepath/$filename" "$tempdir/$tmpfile.wav")
|
commandline=(${ionice}mpcdec)
|
||||||
|
commandline+=("$sourcepath/$filename" "$tempdir/$tmpfile.wav")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
decodeOpusdec() {
|
decodeOpusdec() {
|
||||||
tmpfile="${fileid}opusdec"
|
tmpfile="${fileid}opusdec"
|
||||||
commandline=(opusdec "$sourcepath/$filename" "$tempdir/$tmpfile.wav")
|
commandline=(${ionice}opusdec)
|
||||||
|
commandline+=("$sourcepath/$filename" "$tempdir/$tmpfile.wav")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
decodeSox() {
|
decodeSox() {
|
||||||
commandline=(sox --single-threaded --temp "$tempdir")
|
commandline=(${ionice}sox --single-threaded --temp "$tempdir")
|
||||||
soxoptions_in=''
|
soxoptions_in=''
|
||||||
soxoptions_out=''
|
soxoptions_out=''
|
||||||
if (( ${destinationnormalize["$destination"]} ))
|
if (( ${destinationnormalize["$destination"]} ))
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
createDestinations() {
|
createDestinations() {
|
||||||
for destination in ${!destinationpath[@]}
|
for destination in ${!destinationpath[@]}
|
||||||
do
|
do
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
updateMimes() {
|
updateMimes() {
|
||||||
Update mime_actions action 1 <<<"action != 1"
|
Update mime_actions action 1 <<<"action != 1"
|
||||||
for destination in ${!destinationskipmime[@]}
|
for destination in ${!destinationskipmime[@]}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
encodeFile::mp3() {
|
encodeFile::mp3() {
|
||||||
lameopts=(lame --quiet -v --abr ${destinationquality[$destination]})
|
lameopts=(${ionice}lame --quiet)
|
||||||
|
lameopts+=(-v --abr ${destinationquality[$destination]})
|
||||||
[ -n "$album" ] && lameopts+=(--tl "$album" )
|
[ -n "$album" ] && lameopts+=(--tl "$album" )
|
||||||
[ -n "$artist" ] && lameopts+=(--ta "$artist")
|
[ -n "$artist" ] && lameopts+=(--ta "$artist")
|
||||||
[ -n "$genre" ] && lameopts+=(--tg "$genre")
|
[ -n "$genre" ] && lameopts+=(--tg "$genre")
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
encodeFile::opus() {
|
encodeFile::opus() {
|
||||||
opusencopts=(opusenc --music --quiet)
|
opusencopts=(${ionice}opusenc --music --quiet)
|
||||||
opusencopts+=(--bitrate ${destinationquality[$destination]})
|
opusencopts+=(--bitrate ${destinationquality[$destination]})
|
||||||
[ -n "${destinationloss["$destination"]}" ] \
|
[ -n "${destinationloss["$destination"]}" ] \
|
||||||
&& opusencopts+=(--expect-loss "${destinationloss["$destination"]}")
|
&& opusencopts+=(--expect-loss "${destinationloss["$destination"]}")
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
encodeFile::vorbis() {
|
encodeFile::vorbis() {
|
||||||
oggencopts=(oggenc -Q -q ${destinationquality[$destination]})
|
oggencopts=(${ionice}oggenc -Q -q ${destinationquality[$destination]})
|
||||||
[ -n "$albumartist" ] && oggencopts+=(-c "ALBUMARTIST=$albumartist")
|
[ -n "$albumartist" ] && oggencopts+=(-c "ALBUMARTIST=$albumartist")
|
||||||
[ -n "$album" ] && oggencopts+=(-l "$album")
|
[ -n "$album" ] && oggencopts+=(-l "$album")
|
||||||
[ -n "$artist" ] && oggencopts+=(-a "$artist")
|
[ -n "$artist" ] && oggencopts+=(-a "$artist")
|
||||||
|
|||||||
@ -1,29 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
getDestDir() {
|
getDestDir() {
|
||||||
destdir="${destinationpath[$destination]}/"
|
destdir="${destinationpath[$destination]}/"
|
||||||
if [ -n "${destinationrenamepath[$destination]}" ]
|
if [ -n "${destinationrenamepath[$destination]}" ]
|
||||||
then
|
then
|
||||||
destdir+="${destinationrenamepath[$destination]//%\{album\}/$album}"
|
replace=$(sanitizeFile "$album" dir)
|
||||||
replace=$(sanitizeFile "$albumartist")
|
destdir+="${destinationrenamepath[$destination]//%\{album\}/$replace}"
|
||||||
|
replace=$(sanitizeFile "$albumartist" dir)
|
||||||
destdir="${destdir//%\{albumartist\}/$replace}"
|
destdir="${destdir//%\{albumartist\}/$replace}"
|
||||||
replace=$(sanitizeFile "$artist")
|
replace=$(sanitizeFile "$artist" dir)
|
||||||
destdir="${destdir//%\{artist\}/$replace}"
|
destdir="${destdir//%\{artist\}/$replace}"
|
||||||
replace=$(sanitizeFile "$genre")
|
replace=$(sanitizeFile "$genre" dir)
|
||||||
destdir="${destdir//%\{genre\}/$replace}"
|
destdir="${destdir//%\{genre\}/$replace}"
|
||||||
replace=$(sanitizeFile "$title")
|
replace=$(sanitizeFile "$title" dir)
|
||||||
destdir="${destdir//%\{title\}/$replace}"
|
destdir="${destdir//%\{title\}/$replace}"
|
||||||
tracknumber="${track%/*}"
|
tracknumber="${track%/*}"
|
||||||
replace=$(sanitizeFile "$tracknumber")
|
replace=$(sanitizeFile "$tracknumber" dir)
|
||||||
destdir="${destdir//%\{track\}/$replace}"
|
destdir="${destdir//%\{track\}/$replace}"
|
||||||
replace=$(sanitizeFile "$year")
|
replace=$(sanitizeFile "$year" dir)
|
||||||
destdir="${destdir//%\{year\}/$replace}"
|
destdir="${destdir//%\{year\}/$replace}"
|
||||||
replace=$(sanitizeFile "$disc")
|
replace=$(sanitizeFile "$disc" dir)
|
||||||
destdir="${destdir//%\{disc\}/$replace}"
|
destdir="${destdir//%\{disc\}/$replace}"
|
||||||
else
|
else
|
||||||
destdir+=$(sanitizeFile "${filename%%/*}")
|
destdir+=$(sanitizeFile "${filename%%/*}" dir)
|
||||||
part=${filename#*/}
|
part=${filename#*/}
|
||||||
while [[ $part =~ / ]]
|
while [[ $part =~ / ]]
|
||||||
do
|
do
|
||||||
destdir+="/$(sanitizeFile "${part%%/*}")"
|
destdir+="/$(sanitizeFile "${part%%/*}" dir)"
|
||||||
part=${part#*/}
|
part=${part#*/}
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getDestFile() {
|
getDestFile() {
|
||||||
if [ -n "${destinationrename[$destination]}" ]
|
if [ -n "${destinationrename[$destination]}" ]
|
||||||
then
|
then
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getFiles() {
|
getFiles() {
|
||||||
scantime=$(date +%s)
|
scantime=$(date +%s)
|
||||||
for prune_expression in "${skippeddirectories[@]}"
|
for prune_expression in "${skippeddirectories[@]}"
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
removeObsoleteFiles() {
|
removeObsoleteFiles() {
|
||||||
Delete source_files <<-EOWhere
|
Delete source_files <<-EOWhere
|
||||||
last_seen < $scantime
|
last_seen < $scantime
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
sanitizeFile() {
|
sanitizeFile() {
|
||||||
shopt -s extglob
|
shopt -s extglob
|
||||||
string="$1"
|
string="$1"
|
||||||
@ -18,6 +19,13 @@ sanitizeFile() {
|
|||||||
# Filenames can't begin or end with ' '
|
# Filenames can't begin or end with ' '
|
||||||
string=${string/#+( )/}
|
string=${string/#+( )/}
|
||||||
string=${string/%+( )/}
|
string=${string/%+( )/}
|
||||||
|
|
||||||
|
# Directory names can't begin or end with '.'
|
||||||
|
if [[ $2 == dir ]]
|
||||||
|
then
|
||||||
|
string=${string/#+(.)/}
|
||||||
|
string=${string/%+(.)/}
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo "$string"
|
echo "$string"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getInfosAPE_version='APE-1'
|
getInfosAPE_version='APE-1'
|
||||||
tagreaders+=( "$getInfosAPE_version" )
|
tagreaders+=( "$getInfosAPE_version" )
|
||||||
getInfos::APE() {
|
getInfos::APE() {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getInfosFLAC_version='FLAC-1'
|
getInfosFLAC_version='FLAC-1'
|
||||||
tagreaders+=( "$getInfosFLAC_version" )
|
tagreaders+=( "$getInfosFLAC_version" )
|
||||||
getInfos::FLAC() {
|
getInfos::FLAC() {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getInfosMP3_version='ID3-2'
|
getInfosMP3_version='ID3-2'
|
||||||
tagreaders+=( "$getInfosMP3_version" )
|
tagreaders+=( "$getInfosMP3_version" )
|
||||||
getInfos::MP3() {
|
getInfos::MP3() {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getInfosOgg_version='Ogg-1'
|
getInfosOgg_version='Ogg-1'
|
||||||
tagreaders+=( "$getInfosOgg_version" )
|
tagreaders+=( "$getInfosOgg_version" )
|
||||||
getInfos::Ogg() {
|
getInfos::Ogg() {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getInfosOpus_version='Opus-1'
|
getInfosOpus_version='Opus-1'
|
||||||
tagreaders+=( "$getInfosOpus_version" )
|
tagreaders+=( "$getInfosOpus_version" )
|
||||||
getInfos::Opus() {
|
getInfos::Opus() {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getRateChannelMPC() {
|
getRateChannelMPC() {
|
||||||
while read key value garbage
|
while read key value garbage
|
||||||
do
|
do
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getRateChannelSoxi() {
|
getRateChannelSoxi() {
|
||||||
rate=$(soxi -r "$sourcepath/$filename" 2>/dev/null)
|
rate=$(soxi -r "$sourcepath/$filename" 2>/dev/null)
|
||||||
channels=$(soxi -c "$sourcepath/$filename" 2>/dev/null)
|
channels=$(soxi -c "$sourcepath/$filename" 2>/dev/null)
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getTags_version='unknown-2'
|
getTags_version='unknown-2'
|
||||||
tagreaders+=( "$getTags_version" )
|
tagreaders+=( "$getTags_version" )
|
||||||
getTags() {
|
getTags() {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
gettag() {
|
gettag() {
|
||||||
echo -e "$infos" \
|
echo -e "$infos" \
|
||||||
| sed -n "/^${1}=/I{s/^${1}=//I;p;q}"
|
| sed -n "/^${1}=/I{s/^${1}=//I;p;q}"
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
tryAPE() {
|
tryAPE() {
|
||||||
grep -q 'APETAGEX' \
|
grep -q 'APETAGEX' \
|
||||||
"$sourcepath/$filename" \
|
"$sourcepath/$filename" \
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
gettaskinfos() {
|
gettaskinfos() {
|
||||||
echo '
|
echo '
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
progressSpin() {
|
progressSpin() {
|
||||||
case $(( ++count % 40 )) in
|
case $(( ++count % 40 )) in
|
||||||
0) echo -ne '\b|' ;;
|
0) echo -ne '\b|' ;;
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
checkworkers() {
|
checkworkers() {
|
||||||
for key in ${!workers[@]}
|
for key in ${!workers[@]}
|
||||||
do
|
do
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
cleaner() {
|
cleaner() {
|
||||||
for key in ${!failedtasks[@]}
|
for key in ${!failedtasks[@]}
|
||||||
do
|
do
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
createworker() {
|
createworker() {
|
||||||
worker $1 &
|
worker $1 &
|
||||||
workers[$1]=$!
|
workers[$1]=$!
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
destroyworker() {
|
destroyworker() {
|
||||||
dyingworker=${workers[$1]}
|
dyingworker=${workers[$1]}
|
||||||
unset workers[$1]
|
unset workers[$1]
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
getworkerid() {
|
getworkerid() {
|
||||||
local i
|
local i
|
||||||
for (( i=0 ; i >= 0 ; i++ ))
|
for (( i=0 ; i >= 0 ; i++ ))
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
master() {
|
master() {
|
||||||
if (( active >= concurrency)) || [ -n "$quit" ]
|
if (( active >= concurrency)) || [ -n "$quit" ]
|
||||||
then
|
then
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
worker() {
|
worker() {
|
||||||
exec 2>>"$tempdir/worker$1.log"
|
exec 2>>"$tempdir/worker$1.log"
|
||||||
(( debug >= 2 )) && echo "${cmd_arg[@]}" >&2
|
(( debug >= 2 )) && echo "${cmd_arg[@]}" >&2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user