172 lines
3.7 KiB
Bash
172 lines
3.7 KiB
Bash
#!/bin/bash
|
|
getConfigDestination() {
|
|
case "$key" in
|
|
'path')
|
|
destinationpath["$destination"]="$value"
|
|
;;
|
|
'format')
|
|
case "$value" in
|
|
'mp3')
|
|
destinationformat["$destination"]=mp3
|
|
;;
|
|
'opus')
|
|
destinationformat["$destination"]=opus
|
|
;;
|
|
'vorbis')
|
|
destinationformat["$destination"]=vorbis
|
|
;;
|
|
*)
|
|
echo "Unsupported destination format: $value" >2&
|
|
exit $EFORMAT
|
|
;;
|
|
esac
|
|
;;
|
|
'quality')
|
|
expr='^[0-9]*$'
|
|
if ! [[ $value =~ $expr ]]
|
|
then
|
|
echo "Invalid quality value: $value" >&2
|
|
exit $EQUALITY
|
|
fi
|
|
unset expr
|
|
case "${destinationformat["$destination"]}" in
|
|
'vorbis')
|
|
destinationquality["$destination"]="$value"
|
|
;;
|
|
*)
|
|
echo "Invalid parameter \"$key\" for format \"${destinationformat["$destination"]}\"" >&2
|
|
exit $EFMTINVPARM
|
|
;;
|
|
esac
|
|
;;
|
|
'normalize')
|
|
case $value in
|
|
'true'|'on'|'yes')
|
|
destinationnormalize["$destination"]=1
|
|
;;
|
|
'false'|'off'|'no')
|
|
destinationnormalize["$destination"]=0
|
|
;;
|
|
*)
|
|
echo "normalize takes values:" \
|
|
"'yes' ,'true' ,'on', 'no', 'false',"\
|
|
"'off'"
|
|
;;
|
|
esac
|
|
;;
|
|
'bitrate')
|
|
expr='^[0-9]*$'
|
|
if ! [[ $value =~ $expr ]]
|
|
then
|
|
echo "Invalid bitrate value: $value" >&2
|
|
exit $EQUALITY
|
|
fi
|
|
unset expr
|
|
case "${destinationformat["$destination"]}" in
|
|
'opus')
|
|
destinationquality["$destination"]="$value"
|
|
;;
|
|
'mp3')
|
|
destinationquality["$destination"]="$value"
|
|
;;
|
|
*)
|
|
echo "$Invalid parameter \"$key\" for format \"${destinationformat["$destination"]}\"" >&2
|
|
exit $EFMTINVPARM
|
|
;;
|
|
esac
|
|
;;
|
|
'loss')
|
|
expr='^[0-9]*$'
|
|
if ! [[ $value =~ $expr ]]
|
|
then
|
|
echo "Invalid loss value: $value" >&2
|
|
exit $EQUALITY
|
|
fi
|
|
unset expr
|
|
case "${destinationformat["$destination"]}" in
|
|
'opus')
|
|
destinationloss["$destination"]="$value"
|
|
;;
|
|
*)
|
|
echo "$Invalid parameter \"$key\" for format \"${destinationformat["$destination"]}\"" >&2
|
|
exit $EFMTINVPARM
|
|
;;
|
|
esac
|
|
;;
|
|
'channels')
|
|
expr='^[0-9]*$'
|
|
if ! [[ $value =~ $expr ]]
|
|
then
|
|
echo "Invalid channel count: $value" >&2
|
|
exit $ECHANNEL
|
|
fi
|
|
unset expr
|
|
destinationchannels["$destination"]=$value
|
|
;;
|
|
'frequency')
|
|
expr='^[0-9]*$'
|
|
if ! [[ $value =~ $expr ]]
|
|
then
|
|
echo "Invalid frequency value: $value" >&2
|
|
exit $ECHANNEL
|
|
fi
|
|
unset expr
|
|
destinationfrequency["$destination"]=$value
|
|
;;
|
|
'noresample')
|
|
case $value in
|
|
'true'|'on'|'yes')
|
|
destinationnoresample["$destination"]=1
|
|
;;
|
|
'false'|'off'|'no')
|
|
destinationnoresample["$destination"]=0
|
|
;;
|
|
*)
|
|
echo "noresample takes values:" \
|
|
"'yes' ,'true' ,'on', 'no', 'false',"\
|
|
"'off'"
|
|
;;
|
|
esac
|
|
;;
|
|
'rename')
|
|
case "$value" in
|
|
*/*)
|
|
destinationrenamepath["$destination"]="${value%/*}"
|
|
;;
|
|
esac
|
|
destinationrename["$destination"]="${value##*/}"
|
|
;;
|
|
'fat32compat')
|
|
case $value in
|
|
'true'|'on'|'yes')
|
|
destinationfat32compat["$destination"]=1
|
|
;;
|
|
'false'|'off'|'no')
|
|
destinationfat32compat["$destination"]=0
|
|
;;
|
|
*)
|
|
echo "fat32compat takes values:" \
|
|
"'yes' ,'true' ,'on', 'no', 'false',"\
|
|
"'off'"
|
|
;;
|
|
esac
|
|
;;
|
|
'skip_mime-type')
|
|
destinationskipmime[$destination]="${destinationskipmime[$destination]:+${destinationskipmime[$destination]}|}$value"
|
|
;;
|
|
'copy_mime-type')
|
|
destinationcopymime[$destination]="${destinationcopymime[$destination]:+${destinationcopymime[$destination]}|}$value"
|
|
;;
|
|
'higher-than')
|
|
expr='^[0-9]*$'
|
|
if ! [[ $value =~ $expr ]]
|
|
then
|
|
echo "Invalid higher-than bitrate value: $value" >&2
|
|
exit $EMAXBPS
|
|
fi
|
|
unset expr
|
|
destinationmaxbps[$destination]="$value"
|
|
;;
|
|
esac
|
|
}
|