Created
December 20, 2016 09:15
-
-
Save oldengremlin/c93b101ee57907bedbfa3e7c0e664feb to your computer and use it in GitHub Desktop.
Split flac from cue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################# | |
# зависимости: | |
# media-sound/shntool | |
# app-cdr/cuetools | |
# media-libs/flac | |
# media-sound/mac | |
# media-sound/ttaenc | |
# media-sound/wavpack | |
############################# | |
while read cuefile | |
do | |
cue="${cuefile##*/}" | |
obj=${cue%.cue} | |
objdir="${cuefile%/*}" | |
pushd "$objdir" | |
if [ -f "$obj".flac ]; then | |
shntool split -i "flac" -o "flac" -f "$cue" -t %n "$obj".flac || echo "Не удалось разделить $obj.flac" \ | |
exit 1 | |
elif [ -f "$obj".ape ]; then | |
shntool split -i "ape" -o "flac" -f "$cue" -t %n "$obj".ape || echo "Не удалось разделить $obj.ape" \ | |
exit 1 | |
elif [ -f "$obj".tta ]; then | |
shntool split -i "tta" -o "flac" -f "$cue" -t %n "$obj".tta || echo "Не удалось разделить $obj.tta" \ | |
exit 1 | |
elif [ -f "$obj".wv ]; then | |
shntool split -i "wv" -o "flac" -f "$cue" -t %n "$obj".wv || echo "Не удалось разделить $obj.wv" \ | |
exit 1 | |
else | |
echo "Файл $obj не найден, выходим." | |
exit 1 | |
fi | |
ln -s "$cue" tmp.cue | |
for (( i=1 ; i <= $(cueprint -d '%N' tmp.cue) ; ++i )); do | |
NN=$(printf '%02d' $i) | |
[ -s "$NN.flac" ] && { | |
cueprint -n $i -t \ | |
'ARRANGER=%A\nCOMPOSER=%C\nGENRE=%G\nMESSAGE=%M\nTRACKNUMBER=%n\nARTIST=%p\nTITLE=%t\nALBUM=%T\n' \ | |
tmp.cue | iconv -f cp1251 | egrep -v '=$' | metaflac --import-tags-from=- $NN.flac | |
mv $NN.flac "$NN - $(cueprint -n $i -t %t tmp.cue | iconv -f cp1251 | sed -e "s,/,,g").flac" | |
} | |
done | |
rm -f tmp.cue "$cue" "$obj".{flac,ape,tta} tags.tmp | |
popd | |
done < <(find . -type f -iname "*.cue") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment