mp3 tagging: giving some more options
authorAndrew Strong <andrew.david.strong@gmail.com>
Sat, 10 Jan 2015 08:20:46 +0000 (19:20 +1100)
committerAndrew Strong <andrew.david.strong@gmail.com>
Sat, 10 Jan 2015 08:20:46 +0000 (19:20 +1100)
This update allows 3 different ways to tag mp3 files
using ID3TAGV:

  * id3v2.4 using eyeD3 (set in abcde as the default)
  * id3v2.3 using id3v2
  * id3v1 using id3

Thanks to Adriaan for this patch which fixes issue 101.

abcde
abcde.conf

diff --git a/abcde b/abcde
index 9bdad01..9303ca9 100755 (executable)
--- a/abcde
+++ b/abcde
@@ -817,8 +817,27 @@ do_tag ()
                                TPE2="Various"
                        fi
 
+
                        case "$ID3SYNTAX" in
-                               id3);;
+                               id3)
+                                       run_command tagtrack-$OUTPUT-$1 nice $ENCNICE \
+                                               $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
+                                               -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" \
+                                               -y "$CDYEAR" -g "$GENREID" \
+                                               -T "${TRACKNUM:-$1}" \
+                                               "$ABCDETEMPDIR/track$1.$OUTPUT"
+                                       ;;
+                               id3v2)
+                                       # FIXME # track numbers in mp3 come with 1/10, so we cannot
+                                       # happily substitute them with $TRACKNUM
+                                       run_command tagtrack-$OUTPUT-$1 nice $ENCNICE \
+                                               $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
+                                               -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" \
+                                               -y "$CDYEAR" -g "$GENREID" \
+                                               -T "${TRACKNUM:-$1}/$TRACKS" \
+                                               ${TPE2:+--TPE2 "$TPE2"} \
+                                               "$ABCDETEMPDIR/track$1.$OUTPUT"
+                                       ;;
                                eyed3*)
                                        # FIXME # track numbers in mp3 come with 1/10, so we cannot
                                        # happily substitute them with $TRACKNUM
@@ -842,24 +861,9 @@ do_tag ()
                                                "${addopts[@]}" \
                                                "$ABCDETEMPDIR/track$1.$OUTPUT"
                                        ;;
-                               # FIXME # Still not activated...
-                               id3ed)
-                                       run_command tagtrack-$OUTPUT-$1 nice $ENCNICE \
-                                               $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
-                                               -a "$DALBUM" -n "$TRACKARTIST" -s "$TRACKNAME" \
-                                               -y "$CDYEAR" -g "$GENREID" -k "${TRACKNUM:-$1}" \
-                                               "$ABCDETEMPDIR/track$1.$OUTPUT"
-                                       ;;
                                *)
-                                       # FIXME # track numbers in mp3 come with 1/10, so we cannot
-                                       # happily substitute them with $TRACKNUM
-                                       run_command tagtrack-$OUTPUT-$1 nice $ENCNICE \
-                                               $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
-                                               -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" \
-                                               -y "$CDYEAR" -g "$GENREID" \
-                                               -T "${TRACKNUM:-$1}/$TRACKS" \
-                                               ${TPE2:+--TPE2 "$TPE2"} \
-                                               "$ABCDETEMPDIR/track$1.$OUTPUT"
+                                       log error "Internal error: ID3SYNTAX has an illegal value"
+                                       exit 1
                                        ;;
                        esac
                        ;;
@@ -3265,7 +3269,7 @@ VAPLAYLISTFORMAT='${ARTISTFILE}-${ALBUMFILE}.${OUTPUT}.m3u'
 VAPLAYLISTDATAPREFIX=''
 DOSPLAYLIST=n
 COMMENT=''
-ID3TAGV=2
+ID3TAGV=id3v2.4
 ENCNICE=10
 READNICE=10
 DISTMP3NICE=10
@@ -3310,6 +3314,7 @@ WVENC=wavpack
 AACENC=faac
 
 ID3=id3
+ID3V2=id3v2
 EYED3=eyeD3
 VORBISCOMMENT=vorbiscomment
 METAFLAC=metaflac
@@ -4009,22 +4014,42 @@ case "$AACENCODERSYNTAX" in
 esac
 
 # and which tagger
-if [ "$ID3TAGV" = "1" ]; then
-       TAGGER="$ID3"
-       TAGGEROPTS="$ID3OPTS"
-else
-       TAGGER="$EYED3"
-       # 0.7 changed syntax
-       if $EYED3 --help 2>&1 | grep -q -- --set-encoding ; then
-               # only if it offers the --set-encoding, assume <= 0.6.x
-               ID3SYNTAX=eyed3_06
-               TAGGEROPTS="--set-encoding utf16-LE $EYED3OPTS"
-       else
-               # anything wrong, any failure, assume >= 0.7
-               ID3SYNTAX=eyed3
-               TAGGEROPTS="--encoding utf16 $EYED3OPTS"
-       fi
-fi
+case "$ID3TAGV" in
+       id3v1)
+               TAGGER="$ID3"
+               ID3SYNTAX=id3
+               TAGGEROPTS="$ID3OPTS"
+               ;;
+       id3v2.3)
+               TAGGER="$ID3V2"
+               ID3SYNTAX=id3v2
+               TAGGEROPTS="$ID3V2OPTS"
+               ;;
+       id3v2.4)
+               TAGGER="$EYED3"
+               # Note that eyeD3 is set to tag in utf-16 (below). This causes
+               # trouble with CDDBPROTO=5 (which we test here) but also
+               # with cached cddb files in latin1 (which we cannot test).
+               if [ "$CDDBPROTO" -lt 6 ]; then
+                       log warning "You cannot have id3v2.4 tags encoded in latin1. Setting CDDBPROTO to 6 for now."
+                       CDDBPROTO=6
+               fi
+               # eyeD3 version 0.7 changed syntax
+               if $EYED3 --help 2>&1 | grep -q -- --set-encoding ; then
+                       # only if it offers the --set-encoding, assume <= 0.6.x
+                       ID3SYNTAX=eyed3_06
+                       TAGGEROPTS="--set-encoding utf16-LE $EYED3OPTS"
+               else
+                       # anything wrong, any failure, assume >= 0.7
+                       ID3SYNTAX=eyed3
+                       TAGGEROPTS="--encoding utf16 $EYED3OPTS"
+               fi
+               ;;
+       *)
+               log error "Error: ID3TAGV must be either \"id3v1\", \"id3v2.3\" or \"id3v2.4\""
+               exit 1
+               ;;
+esac
 
 # NOGAP is specific to lame. Other encoders fail ...
 if [ "$NOGAP" = "y" ] && [ ! "$MP3ENCODER" = "lame" ]; then
index 1d68ffe..58115d2 100644 (file)
 #OPUSENC=opusenc
 
 #ID3=id3
+#ID3V2=id3v2
 #EYED3=eyeD3
 #CDPARANOIA=cdparanoia
 #CDDA2WAV=icedax
 # For the encoder options look at: opusenc -h.
 #OPUSENCOPTS='--bitrate 128'
 
+# There are three ways to tag MP3 files: id3v1 (with id3), id3v2.3
+# (with id3v2) and id3v2.4 (with eyeD3). Use ID3TAGV to select one of
+# the older formats
+#ID3TAGV=id3v2.4
 #ID3OPTS=
+#ID3V2OPTS=
 #EYED3OPTS="--set-encoding=utf16-LE"
 #CDPARANOIAOPTS=
 #CDDA2WAVOPTS=