]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
change mp3 to lib
authorBastian Dehn <hhaalo@arcor.de>
Tue, 15 Jul 2025 16:09:17 +0000 (18:09 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 15 Jul 2025 16:09:17 +0000 (18:09 +0200)
albentohandy
libs/mp3.sh [new file with mode: 0644]

index 77f40c0e68519e693ed621173ea8442283c89975..eb7ebb17a64a9921e732d4e36877ca10c52f2a53 100755 (executable)
@@ -38,101 +38,14 @@ load_libraries()
        [ -f "$BASHLIBS/voribs.sh" ] \
                || errlog "library vorbis.sh not found" \
                || return $?
+       [ -f "$BASHLIBS/mp3.sh" ] \
+               || errlog "library mp3.sh not found" \
+               || return $?
 
        source "$BASHLIBS/voribs.sh"
+       source "$BASHLIBS/mp3.sh"
 }
 
-#### BEGIN MP3 ####
-
-read_flac_to_mp3_tags()
-{
-       local inputfile="$1"
-       local outputfile="$2"
-       local inputfiledir=${inputfile%/*}
-
-       # get the tags from flac file
-       local readonly ARTIST=$(metaflac "$inputfile" \
-               --show-tag=ARTIST | sed s/.*=//g)
-       local readonly TITLE=$(metaflac "$inputfile" \
-               --show-tag=TITLE | sed s/.*=//g)
-       local readonly ALBUM=$(metaflac "$inputfile" \
-               --show-tag=ALBUM | sed s/.*=//g)
-       local readonly GENRE=$(metaflac "$inputfile" \
-               --show-tag=GENRE | sed s/.*=//g)
-       local readonly TRACKNUMBER=$(metaflac "$inputfile" \
-               --show-tag=TRACKNUMBER | sed s/.*=//g)
-       local readonly DATE=$(metaflac "$inputfile" \
-               --show-tag=DATE | sed s/.*=//g)
-       local readonly RRL=$(metaflac "$inputfile" \
-               --show-tag=REPLAYGAIN_REFERENCE_LOUDNESS | tr '=' ':')
-       local readonly RTG=$(metaflac "$inputfile" \
-               --show-tag=REPLAYGAIN_TRACK_GAIN | tr '=' ':')
-       local readonly RTP=$(metaflac "$inputfile" \
-               --show-tag=REPLAYGAIN_TRACK_PEAK | tr '=' ':')
-       local readonly RAG=$(metaflac "$inputfile" \
-               --show-tag=REPLAYGAIN_ALBUM_GAIN | tr '=' ':')
-       local readonly RAP=$(metaflac "$inputfile" \
-               --show-tag=REPLAYGAIN_ALBUM_PEAK | tr '=' ':')
-
-       # --------------------------------------------------
-
-       # ID3v2.3 tagging with cover and without cover
-       eyeD3 --v2 \
-               --to-v2.3 \
-               --artist="$ARTIST" \
-               --title="$TITLE" \
-               --album="$ALBUM" \
-               --genre="${GENRE:-12}" \
-               --track="${TRACKNUMBER:-0}" \
-               --recording-date="$DATE" \
-               --user-text-frame="$RRL" \
-               --user-text-frame="$RTG" \
-               --user-text-frame="$RTP" \
-               --user-text-frame="$RAG" \
-               --user-text-frame="$RAP" \
-               --add-image="$inputfiledir/cover.jpg":FRONT_COVER \
-               "$outputfile" > /dev/null 2>&1
-}
-
-encoding_flac_to_mp3()
-{
-       local readonly inputfile="$1"
-       local readonly outputfile="$2"
-
-       nice --adjustment=10 flac --totally-silent --stdout --decode \
-               "$inputfile" \
-               | nice --adjustment=15 lame --silent \
-               -b 192 \
-               --noreplaygain \
-               - "$outputfile"
-}
-
-flac_to_mp3()
-{
-       local inputfile="$1"
-       local outputfile="${inputfile/.flac/.mp3}"
-
-       encoding_flac_to_mp3 "$inputfile" "$outputfile"
-       read_flac_to_mp3_tags "$inputfile" "$outputfile"
-}
-
-convert_flac_to_mp3()
-{
-       local workdir="$1"
-
-       export -f flac_to_mp3
-       export -f encoding_flac_to_mp3
-       export -f read_flac_to_mp3_tags
-       find $workdir -name '*.flac' \
-               | sort \
-               | parallel --will-cite \
-               --ungroup \
-               --eta \
-               --progress \
-               flac_to_mp3 {}
-}
-
-#### END MP3 ####
 #### BEGIN OPUS ####
 
 flac_to_opus()
diff --git a/libs/mp3.sh b/libs/mp3.sh
new file mode 100644 (file)
index 0000000..c8e7be0
--- /dev/null
@@ -0,0 +1,87 @@
+read_flac_to_mp3_tags()
+{
+       local inputfile="$1"
+       local outputfile="$2"
+       local inputfiledir=${inputfile%/*}
+
+       # get the tags from flac file
+       local readonly ARTIST=$(metaflac "$inputfile" \
+               --show-tag=ARTIST | sed s/.*=//g)
+       local readonly TITLE=$(metaflac "$inputfile" \
+               --show-tag=TITLE | sed s/.*=//g)
+       local readonly ALBUM=$(metaflac "$inputfile" \
+               --show-tag=ALBUM | sed s/.*=//g)
+       local readonly GENRE=$(metaflac "$inputfile" \
+               --show-tag=GENRE | sed s/.*=//g)
+       local readonly TRACKNUMBER=$(metaflac "$inputfile" \
+               --show-tag=TRACKNUMBER | sed s/.*=//g)
+       local readonly DATE=$(metaflac "$inputfile" \
+               --show-tag=DATE | sed s/.*=//g)
+       local readonly RRL=$(metaflac "$inputfile" \
+               --show-tag=REPLAYGAIN_REFERENCE_LOUDNESS | tr '=' ':')
+       local readonly RTG=$(metaflac "$inputfile" \
+               --show-tag=REPLAYGAIN_TRACK_GAIN | tr '=' ':')
+       local readonly RTP=$(metaflac "$inputfile" \
+               --show-tag=REPLAYGAIN_TRACK_PEAK | tr '=' ':')
+       local readonly RAG=$(metaflac "$inputfile" \
+               --show-tag=REPLAYGAIN_ALBUM_GAIN | tr '=' ':')
+       local readonly RAP=$(metaflac "$inputfile" \
+               --show-tag=REPLAYGAIN_ALBUM_PEAK | tr '=' ':')
+
+       # --------------------------------------------------
+
+       # ID3v2.3 tagging with cover and without cover
+       eyeD3 --v2 \
+               --to-v2.3 \
+               --artist="$ARTIST" \
+               --title="$TITLE" \
+               --album="$ALBUM" \
+               --genre="${GENRE:-12}" \
+               --track="${TRACKNUMBER:-0}" \
+               --recording-date="$DATE" \
+               --user-text-frame="$RRL" \
+               --user-text-frame="$RTG" \
+               --user-text-frame="$RTP" \
+               --user-text-frame="$RAG" \
+               --user-text-frame="$RAP" \
+               --add-image="$inputfiledir/cover.jpg":FRONT_COVER \
+               "$outputfile" > /dev/null 2>&1
+}
+
+encoding_flac_to_mp3()
+{
+       local readonly inputfile="$1"
+       local readonly outputfile="$2"
+
+       nice --adjustment=10 flac --totally-silent --stdout --decode \
+               "$inputfile" \
+               | nice --adjustment=15 lame --silent \
+               -b 192 \
+               --noreplaygain \
+               - "$outputfile"
+}
+
+flac_to_mp3()
+{
+       local inputfile="$1"
+       local outputfile="${inputfile/.flac/.mp3}"
+
+       encoding_flac_to_mp3 "$inputfile" "$outputfile"
+       read_flac_to_mp3_tags "$inputfile" "$outputfile"
+}
+
+convert_flac_to_mp3()
+{
+       local workdir="$1"
+
+       export -f flac_to_mp3
+       export -f encoding_flac_to_mp3
+       export -f read_flac_to_mp3_tags
+       find $workdir -name '*.flac' \
+               | sort \
+               | parallel --will-cite \
+               --ungroup \
+               --eta \
+               --progress \
+               flac_to_mp3 {}
+}