From: Bastian Dehn Date: Sun, 6 Dec 2020 07:53:09 +0000 (+0100) Subject: add: feature flac with embedded cover X-Git-Tag: v1.0.0^2~65 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=5166db2b5d09936698e484567c5fb89d12b0666e;p=albentohandy.git add: feature flac with embedded cover --- diff --git a/albentohandy b/albentohandy index 7f84221..0967ad7 100755 --- a/albentohandy +++ b/albentohandy @@ -12,11 +12,13 @@ NAME albumtohandy - konvertiert flac to mp3 von einer Sammlung SYNOPSIS - albentohandy [-3] [-i ] [-m ] [-n] [-r] + [-w ] OPTIONS - -h show this help -3 convert to mp3 + -f convert to flac + -h show this help -i input Datei default=albumlist -m kopiert das Arbeitsverzeichnis in das angegeben Zielverzeichnis @@ -120,6 +122,16 @@ ConvertFlacToMp3() --sshlogin $parallelopts FlacToMp3 {} } +PictureToFlac() +{ + local readonly workdir="$1" + + for i in $(find $workdir -name '*.flac' | sort); do + metaflac \ + --import-picture-from="3|image/jpeg|||${i%/*}/cover.jpg" $i + done +} + MakeSymlinksToWork() { local readonly workdir="$1" @@ -270,7 +282,7 @@ ExistsBasicProgramms() { local exists=true local programms=("vorbiscomment" "flac" "oggenc" "parallel" "lame" \ - "eyeD3") + "eyeD3" "metaflac") for programm in $programms; do if [ ! -f /usr/bin/$programm ]; then @@ -290,6 +302,7 @@ SetDefaultVariables() parallelopts=":" curphase=1 phase=3 + flac=false mp3=false nocover=false removework=false @@ -298,10 +311,15 @@ SetDefaultVariables() ReadArguments() { - while getopts "3hi:m:nrw:" optname; do + while getopts "3fhi:m:nrw:" optname; do case "$optname" in "3") mp3=true; + flac=false; + ;; + "f") + mp3=false; + flac=true; ;; "h") Usage @@ -353,20 +371,25 @@ ConvertProcess() printf "create symlinks of flac's in %s\n" "$WORK" MakeSymlinksToWork "$WORK" "$MUSICPATH" "$albumlist" - if [ ! $mp3 == true ]; then + if [ $mp3 == false ] && [ $flac == false ]; then printf "\nPhase %02d of %02d: flac -> ogg\n" \ $((curphase++)) $phase ConvertCoverToMeta "$WORK" "$parallelopts" ConvertFlacToOgg "$WORK" "$parallelopts" - else + elif [ $mp3 == true ] && [ $flac == false ]; then printf "\nPhase %02d of %02d: flac -> mp3\n" \ $((curphase++)) $phase ConvertFlacToMp3 "$WORK" "$parallelopts" + elif [ $mp3 == false ] && [ $flac == true ]; then + printf "\nPhase %02d of %02d: flac -> mp3\n" \ + $((curphase++)) $phase + PictureToFlac "$WORK" fi - printf "\nPhase %02d of %02d: " $((curphase++)) $phase - printf "remove flac's\n\n" - CleanupFlac "$WORK" + printf "\nPhase %02d of %02d: cleanup\n\n" $((curphase++)) $phase + if [ $flac == false ]; then + CleanupFlac "$WORK" + fi CleanupCover "$WORK" }