#!/bin/bash
+# work is a directory do symlinked original and convert
work="$(pwd)/handy"
+# scriptpath is the path to flactomp3v2.sh script
scriptpath="/media/smbdaten1/scripts"
+# musicpath is collection directory
musicpath="/media/smbdaten1/musik-flac"
+parallelopts=":"
if [ ! -f albumlist ]
then
exit
fi
+while getopts "S:" optname
+do
+ case "$optname" in
+ "S")
+ parallelopts="$OPTARG"
+ ;;
+ *)
+ parallelopts=":"
+ ;;
+ esac
+done
+
echo
-echo "Phase 01 von 04: flac's in das Arbeitsverzeichnis $work kopieren"
-echo
+echo "Phase 01 von 03: flac's in das Arbeitsverzeichnis $work verlinken"
if [ ! -d $work ]
then
mkdir $work
fi
-anzahl=$(cat albumlist | wc -l)
+# make symlinks of original flac's
for i in $(cat albumlist)
do
- z=$(($z+1))
- rsync -av $musicpath/$i $work/
- echo
- echo "Phase 01: $((100*$z/$anzahl))% fertig"
- echo
+ cp -rs $musicpath/$i $work/
done
-echo "Phase 02 von 04: flac -> mp3"
-echo
-find $work -name '*.flac' | sort | parallel $scriptpath/flactomp3v2.sh {}
-echo
-echo "Phase 03 von 04: flac's und cover's loeschen"
echo
-find $work -name '*.flac' | sort | xargs rm -v
-find $work -name 'cover*' | sort | xargs rm -v
+echo "Phase 02 von 03: flac -> mp3"
+find $work -name '*.flac' | sort | parallel --eta --progress --noswap -S $parallelopts $scriptpath/flactomp3v2.sh {}
echo
-echo "Phase 04 von 04: replaygain hinzufuegen"
+echo "Phase 03 von 03: flac's und cover's loeschen"
echo
-$scriptpath/mp3gainalbum.sh $work
+find $work -name '*.flac' | sort | xargs rm
+find $work -name 'cover*' | sort | xargs rm
GENRE=$(metaflac "$a" --show-tag=GENRE | sed s/.*=//g)
TRACKNUMBER=$(metaflac "$a" --show-tag=TRACKNUMBER | sed s/.*=//g)
DATE=$(metaflac "$a" --show-tag=DATE | sed s/.*=//g)
+RRL=$(metaflac "$a" --show-tag=REPLAYGAIN_REFERENCE_LOUDNESS | sed s/.*=//g)
+RTG=$(metaflac "$a" --show-tag=REPLAYGAIN_TRACK_GAIN | sed s/.*=//g)
+RTP=$(metaflac "$a" --show-tag=REPLAYGAIN_TRACK_PEAK | sed s/.*=//g)
+RAG=$(metaflac "$a" --show-tag=REPLAYGAIN_ALBUM_GAIN | sed s/.*=//g)
+RAP=$(metaflac "$a" --show-tag=REPLAYGAIN_ALBUM_PEAK | sed s/.*=//g)
# stream flac into the lame encoder
-# tag-v2
-flac -s -c -d "$a" | lame --silent -b 192 -m j --id3v2-only --pad-id3v2 --ignore-tag-errors \
---ta "$ARTIST" --tt "$TITLE" --tl "$ALBUM" --tg "${GENRE:-12}" \
---tn "${TRACKNUMBER:-0}" --ty "$DATE" - "$OUTF"
+flac -s -c -d "$a" | lame --silent -b 192 -m j --noreplaygain - "$OUTF"
-if [ -f ${a%/*}/cover.jpeg ]
+# ID3v2.3 tagging
+if [ -f ${a%/*}/cover.jpg ]
then
- eyeD3 --to-v2.3 --add-image ${a%/*}/cover.jpeg:FRONT_COVER --no-tagging-time-frame $OUTF > /dev/null 2>&1
+ eyeD3 --to-v2.3 \
+-a "$ARTIST" -t "$TITLE" -A "$ALBUM" -G "${GENRE:-12}" \
+-n "${TRACKNUMBER:-0}" -Y "$DATE" \
+--set-user-text-frame="REPLAYGAIN_REFERENCE_LOUDNESS:$RRL" \
+--set-user-text-frame="REPLAYGAIN_TRACK_GAIN:$RTG" \
+--set-user-text-frame="REPLAYGAIN_TRACK_PEAK:$RTP" \
+--set-user-text-frame="REPLAYGAIN_ALBUM_GAIN:$RAG" \
+--set-user-text-frame="REPLAYGAIN_ALBUM_PEAK:$RAP" \
+--add-image ${a%/*}/cover.jpg:FRONT_COVER \
+--no-tagging-time-frame \
+$OUTF > /dev/null 2>&1
else
- if [ -f ${a%/*}/cover.jpg ]
- then
- eyeD3 --to-v2.3 --add-image ${a%/*}/cover.jpg:FRONT_COVER --no-tagging-time-frame $OUTF > /dev/null 2>&1
- fi
+ eyeD3 --to-v2.3 \
+-a "$ARTIST" -t "$TITLE" -A "$ALBUM" -G "${GENRE:-12}" \
+-n "${TRACKNUMBER:-0}" -Y "$DATE" \
+--set-user-text-frame="REPLAYGAIN_REFERENCE_LOUDNESS:$RRL" \
+--set-user-text-frame="REPLAYGAIN_TRACK_GAIN:$RTG" \
+--set-user-text-frame="REPLAYGAIN_TRACK_PEAK:$RTP" \
+--set-user-text-frame="REPLAYGAIN_ALBUM_GAIN:$RAG" \
+--set-user-text-frame="REPLAYGAIN_ALBUM_PEAK:$RAP" \
+--no-tagging-time-frame \
+$OUTF > /dev/null 2>&1
fi
-echo "$a -> $OUTF"
+exit 0