]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add: feature flac with embedded cover
authorBastian Dehn <hhaalo@arcor.de>
Sun, 6 Dec 2020 07:53:09 +0000 (08:53 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 6 Dec 2020 07:54:58 +0000 (08:54 +0100)
albentohandy

index 7f84221157b0a64d52ba4db5d245c9e71792d9e5..0967ad7a47d67916b9c6a71a651f0bfd65b787c4 100755 (executable)
@@ -12,11 +12,13 @@ NAME
     albumtohandy - konvertiert flac to mp3 von einer Sammlung
 
 SYNOPSIS
-    albentohandy [-3] [-i <inputfile] [-m <destfolder] [-n} [-r] [-h]
+    albentohandy [-3] [-f] [-h] [-i <inputfile>] [-m <destfolder>] [-n] [-r]
+                 [-w <workdir>]
 
 OPTIONS
-    -h                      show this help
     -3                      convert to mp3
+    -f                      convert to flac
+    -h                      show this help
     -i <file>               input Datei default=albumlist
     -m <dest>               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"
 }