summaryrefslogtreecommitdiffstats
path: root/drg2flac.sh
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2013-08-15 21:14:20 +0200
committerFlorian Bruhin <git@the-compiler.org>2013-08-15 21:14:20 +0200
commitb7cb5bf9bf03a0b806f7f93b6fdd0cec5c07d9b9 (patch)
tree1b5bf82931c8c2ca35af44b90fc57f5f72376aa4 /drg2flac.sh
parentd9da894c06e13df0a19c0ffd43c86634f3e8434a (diff)
downloaddrg2flac-b7cb5bf9bf03a0b806f7f93b6fdd0cec5c07d9b9.tar.gz
drg2flac-b7cb5bf9bf03a0b806f7f93b6fdd0cec5c07d9b9.zip
Improve flac argument parsing
Diffstat (limited to 'drg2flac.sh')
-rwxr-xr-xdrg2flac.sh37
1 files changed, 23 insertions, 14 deletions
diff --git a/drg2flac.sh b/drg2flac.sh
index 8b625c5..2d144a1 100755
--- a/drg2flac.sh
+++ b/drg2flac.sh
@@ -115,33 +115,48 @@ tmp=$(mktemp -d)
# Convert
for infile in "$@"; do
- skipimage=0
+ flacargs=()
echo "${cbold}===== $infile =====${cres}"
echo
echo "${cblue}Getting metadata${cres}"
+ [[ -z "$artist" ]] && artist="I-Doser"
+ flacargs+=("-T" "ARTIST=$artist")
+
title=$(drg2sbg -r 2 "$infile")
- (( $? != 0 )) && { error "$infile" "getting the title"; continue ;}
+ if (( $? != 0 )); then
+ error "$infile" "getting the title"
+ continue
+ else
+ flacargs+=("-T" "TITLE=$title")
+ fi
desc=$(drg2sbg -r 4 "$infile")
- (( $? != 0 )) && { error "$infile" "getting the description"; continue ;}
+ if (( $? != 0 )); then
+ error "$infile" "getting the description"
+ continue
+ fi
drg2sbg -r 3 -o "$tmp/image" "$infile"
if (( $? != 0 )); then
error "$infile" "getting the image"
- echo "Converted file will have no image!" >&2
- skipimage=1
else
echo
echo "${cblue}Converting image${cres}"
convert "$tmp/image" "$tmp/image.png"
if (( $? != 0 )); then
error "$infile" "converting the image"
- echo "Converted file will have no image!" >&2
- skipimage=1
+ else
+ flacargs+=("--picture=$tmp/image.png")
fi
fi
+ flacargs+=("-T" "ENCODING=converted by drg2flac using flac --no-mid-side")
+ flacargs+=("--no-mid-side")
+ [[ -z "$outfile" ]] && outfile="${infile%.*}.flac"
+ flacargs+=("-o" "$outfile")
+ flacargs+=("$tmp/wav")
+
echo
echo "${cblue}Converting drg to sbg${cres}"
drg2sbg -o "$tmp/sbg" "$infile"
@@ -155,13 +170,7 @@ for infile in "$@"; do
echo
echo
echo "${cblue}Converting wav to flac${cres}"
- [[ -z "$outfile" ]] && outfile="${infile%.*}.flac"
- [[ -z "$artist" ]] && artist="I-Doser"
- (( $skipimage == 0 )) && imageopts="--picture=$tmp/image.png" || imageopts=
- flacopts+=" --no-mid-side"
- flac $flacopts -T "ARTIST=$artist" -T "TITLE=$title" \
- -T ENCODING="converted by drg2flac using flac $flacopts" \
- "$imageopts" -o "$outfile" "$tmp/wav"
+ flac "${flacargs[@]}"
(( $? != 0 )) && { error "$infile" "converting wav to flac"; continue ;}
echo "${cgreen}Done!${cres}"