Increase robustness
This commit is contained in:
parent
2b4015addd
commit
422c173c0b
10
transcode.sh
10
transcode.sh
|
@ -2,9 +2,11 @@
|
|||
|
||||
input_directory=/data/music
|
||||
|
||||
tmp_directory=/data/tmp
|
||||
tmp_directory=/data/tmp/transcode
|
||||
lock_file=/tmp/music-transcode.lock
|
||||
|
||||
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
function die()
|
||||
{
|
||||
printf '%s\n' "$1" >&2
|
||||
|
@ -22,7 +24,7 @@ fi
|
|||
function cleanup()
|
||||
{
|
||||
rm -f "$lock_file"
|
||||
rm -rf $tmp_directory"
|
||||
rm -rf "$tmp_directory"
|
||||
}
|
||||
|
||||
trap cleanup EXIT SIGTERM SIGKILL
|
||||
|
@ -34,8 +36,8 @@ fi
|
|||
SAVEIFS=$IFS
|
||||
IFS=`echo -ne "\n\b"`
|
||||
for file in `find "$input_directory" -name '*.flac' -or -name '*.mp3' | sort`; do
|
||||
./transcode_to_mp3.sh "$file" "$input_directory" "/data/mp3" || break
|
||||
./transcode_to_ogg.sh "$file" "$input_directory" "/data/ogg" || break
|
||||
bash ${__dir}/transcode_to_mp3.sh "$file" "$input_directory" "/data/mp3" || break
|
||||
bash ${__dir}/transcode_to_ogg.sh "$file" "$input_directory" "/data/ogg" || break
|
||||
done
|
||||
|
||||
echo "Done Transcoding."
|
||||
|
|
|
@ -9,7 +9,7 @@ function die()
|
|||
input_file="$1"
|
||||
input_directory="$2"
|
||||
output_directory="$3"
|
||||
tmp_directory=/data/tmp
|
||||
tmp_directory=/data/tmp/transcode
|
||||
output_file="`echo "$input_file" | sed -E "s#^$input_directory(.+)\\.[a-z0-9]+\\$#$output_directory\\1.mp3#g"`"
|
||||
|
||||
directory="`dirname "$output_file"`"
|
||||
|
|
|
@ -39,7 +39,7 @@ function ogg_add_cover()
|
|||
input_file="$1"
|
||||
input_directory="$2"
|
||||
output_directory="$3"
|
||||
tmp_directory=/data/tmp
|
||||
tmp_directory=/data/tmp/transcode
|
||||
output_file="`echo "$input_file" | sed -E "s#^$input_directory(.+)\\.[a-z0-9]+\\$#$output_directory\\1.ogg#g"`"
|
||||
|
||||
directory="`dirname "$output_file"`"
|
||||
|
|
Loading…
Reference in a new issue