add "copy" destination type

This commit is contained in:
Vincent Riquer 2017-06-18 18:21:18 +02:00
parent 6c438c4c90
commit d16b31f479
10 changed files with 308 additions and 265 deletions

View File

@ -9,6 +9,9 @@ getConfigDestination() {
'mp3')
destinationformat["$destination"]=mp3
lameneeded=1
# MP3 can't handfle more than 2 channels
[[ -z ${destinationchannels["$destination"]} ]] \
&& destinationchannels["$destination"]=2
;;
'opus')
destinationformat["$destination"]=opus
@ -18,6 +21,9 @@ getConfigDestination() {
destinationformat["$destination"]=vorbis
oggencneeded=1
;;
'copy')
destinationformat["$destination"]=copy
;;
*)
echo "Unsupported destination format: $value" >&2
exit $EFORMAT

View File

@ -48,10 +48,10 @@ printConfig() {
EOF
[ -n "${destinationskipmime["$destination"]}" ] \
&& echo " |Skipped mime-types|${destinationskipmime["$destination"]//\|/
||}"
[ -n "${destinationmskipime["$destination"]}" ] \
| | |}"
[ -n "${destinationcopymime["$destination"]}" ] \
&& echo " |Copied mime-types|${destinationcopymime["$destination"]//\|/
||}"
| | |}"
done
}|column -t -s'|'
}

View File

@ -63,8 +63,8 @@ path $sourcepath
# * path: Where files will be written
path ${destinationpath["$destination"]}
# * format: ogg, opus or mp3. Other formats may appear in the future - feel
# free to implement your preferred format.
# * format: copy, ogg, opus or mp3. Other formats may appear in the future -
# feel free to implement your preferred format.
format ${destinationformat["$destination"]}
EOCfg

View File

@ -1,6 +1,10 @@
#!/bin/bash
declare soxtaskid
decodeFile() {
if [[ ${destinationformat["$destination"]} == copy ]]
then
copied=1
else
case "$mimetype" in
'video/'*)
(( disablevideo )) && continue
@ -148,4 +152,5 @@ decodeFile() {
fi
fi
fi
fi
}

View File

@ -38,6 +38,25 @@ getDestDir() {
)
)
then
if (( ${destinationascii["$destination"]} ))
then
echo "$album" >&${toascii[1]}
read -r -u${toascii[0]} album
echo "$albumartist" >&${toascii[1]}
read -r -u${toascii[0]} albumartist
echo "$artist" >&${toascii[1]}
read -r -u${toascii[0]} artist
echo "$genre" >&${toascii[1]}
read -r -u${toascii[0]} genre
echo "$title" >&${toascii[1]}
read -r -u${toascii[0]} title
echo "$tracknumber" >&${toascii[1]}
read -r -u${toascii[0]} tracknumber
echo "$year" >&${toascii[1]}
read -r -u${toascii[0]} year
echo "$disc" >&${toascii[1]}
read -r -u${toascii[0]} disc
fi
replace=$(sanitizeFile "$album" dir)
destdir+="${destinationrenamepath[$destination]//?(\[)%\{album\}?(\])/$replace}"
replace=$(sanitizeFile "$albumartist" dir)
@ -60,14 +79,15 @@ getDestDir() {
part=${filename#*/}
while [[ $part =~ / ]]
do
destdir+="/$(sanitizeFile "${part%%/*}" dir)"
part=${part#*/}
done
fi
thispart="${part%%/*}"
if (( ${destinationascii["$destination"]} ))
then
echo "$destdir" >&${toascii[1]}
read -r -u${toascii[0]} destdir
echo "$thispart" >&${toascii[1]}
read -r -u${toascii[0]} thispart
fi
destdir+="/$(sanitizeFile "$thispart" dir)"
part=${part#*/}
done
fi
if ! [ -d "$destdir" ]
then

View File

@ -13,7 +13,7 @@ sanitizeFile() {
string=${string//>/ }
string=${string//:/ }
string=${string//\*/ }
string=${string//|/ }
string=${string//\|/ }
string=${string//\"/ }
# Filenames can't begin or end with ' '

View File

@ -4,7 +4,7 @@ setupDestination() {
cat <<-EODesc
Format:
vorbis, opus or mp3. Other formats may appear in the future.
copy, vorbis, opus or mp3. Other formats may appear in the future.
EODesc
comeagain() {
read \
@ -25,6 +25,9 @@ setupDestination() {
destinationformat["$destination"]=vorbis
oggencneeded=1
;;
'copy')
destinationformat["$destination"]=copy
;;
*)
echo "Unsupported destination format: $value" >&2
comeagain
@ -44,6 +47,9 @@ setupDestination() {
${destinationpath["$destination"]+-i"${destinationpath["$destination"]}"}\
destinationpath["$destination"]
case ${destinationformat["$destination"]} in
copy)
:
;;
vorbis)
cat <<-EODesc
@ -199,6 +205,8 @@ setupDestination() {
Now you will have the opportunity to configure "advanced" parameters
for $destination. You may leave any of these fields blank.
EODesc
if [[ ${destinationformat["$destination"]} != copy ]]
then
cat <<-EODesc
Normalize (boolean):
@ -232,6 +240,7 @@ setupDestination() {
esac
}
comeagain
fi
cat <<-EODesc
Rename (string):
@ -362,6 +371,8 @@ setupDestination() {
fi
done
unset skippedmimes
if [[ ${destinationformat["$destination"]} != copy ]]
then
cat <<-EODesc
Copy mime-type (mime-type, string):
@ -492,4 +503,5 @@ setupDestination() {
destinationmaxbps[$destination]="$value"
unset regen
unset expr
fi
}

View File

@ -65,7 +65,7 @@ setupDestinations() {
expr='^[A-z0-9]*$'
comeagain() {
read -p'Name: ' value
[ -z "$value" ] && break
[ -z "$value" ] && return 1
if ! [[ $value =~ $expr ]]
then
echo "Invalid name $value. Please use" \
@ -73,7 +73,7 @@ setupDestinations() {
comeagain
fi
}
comeagain
comeagain || break
destination="$value"
setupDestination
done

View File

@ -2,5 +2,5 @@
extractAudio() {
tmpfile="${fileid}ffmpeg.wav"
commandline=(${ionice}ffmpeg -v 0 -vn -y)
commandline+=(-i "$sourcepath/$filename" "$tempdir/$tmpfile")
commandline+=(-i "$sourcepath/$filename" -map a:0 "$tempdir/$tmpfile")
}

View File

@ -92,7 +92,7 @@ master() {
if (( remaining == 0 ))
then
sleep 0.1
continue
return 0
elif (( active == 0 && ready == 0 ))
then
dumpfile=tasks-$(date +%Y%m%d%H%M%S).csv