* Clean up movement to eyeD3, remove id3v2 remnants. Thanks to vskytta
[clinton/abcde.git] / abcde
diff --git a/abcde b/abcde
index 7a6caed..b2d31d0 100755 (executable)
--- a/abcde
+++ b/abcde
@@ -1,6 +1,8 @@
 #!/bin/bash
 # Copyright (c) 1998-2001 Robert Woodcock <rcw@debian.org>
 # Copyright (c) 2003-2006 Jesus Climent <jesus.climent@hispalinux.es>
+# Copyright (c) 2009-2012 Colin Tuckley <colint@debian.org>
+# Copyright (c) 2012      Steve McIntyre <93sam@@debian.org>
 # This code is hereby licensed for public consumption under either the
 # GNU GPL v2 or greater, or Larry Wall's Artistic license - your choice.
 #
@@ -13,7 +15,7 @@
 #
 # $Id$
 
-VERSION='2.5.3-UNRELEASED'
+VERSION='2.5.5-UNRELEASED'
 
 usage ()
 {
@@ -95,7 +97,7 @@ log ()
        esac
 }
 
-# Funtions to replace the need of seq, which is too distribution dependant.
+# Functions to replace the need of seq, which is too distribution dependent.
 f_seq_row ()
 {
        i=$1
@@ -826,9 +828,9 @@ do_tag ()
                                                --comment=::"$COMMENTOUTPUT" -A "$DALBUM" \
                                                -a "$TRACKARTIST" -t "$TRACKNAME" -Y "$CDYEAR" \
                                                -G "$GENREID" -n "${TRACKNUM:-$1}" \
-                                               "${TRACKNUM:+-N $TRACKS}" \
-                                               "${ENCODING:+--set-encoding=$ENCODING}" \
-                                               "${TPE2:+--set-user-text-frame=TPE2:$TPE2}" \
+                                               ${TRACKNUM:+-N "$TRACKS"} \
+                                               ${ENCODING:+--set-encoding="$ENCODING"} \
+                                               ${TPE2:+--set-text-frame=TPE2:"$TPE2"} \
                                                "$ABCDETEMPDIR/track$1.$OUTPUT"
                                        ;;
                                # FIXME # Still not activated...
@@ -2241,10 +2243,19 @@ do_cdtext ()
                return 0
        fi
 
-       if [ "$CDROMID" = "" ]; then
-               CDDA2WAVCDROM="$CDROM"
-       else
+       if [ "$OSFLAVOUR" = "OSX" ] ; then
+               # Hei, we have to unmount the device before running anything like cdda2wav/icedax in OSX
+               diskutil unmount ${CDROM#/dev/}
+               # Also, in OSX the cdrom device for cdda2wav/icedax changes...
+               CDDA2WAVCDROM="IODVDServices"
+       elif [ "$OSFLAVOUR" = "FBSD" ] ; then
                CDDA2WAVCDROM="$CDROMID"
+       else
+               if [ "$CDROMID" = "" ]; then
+                       CDDA2WAVCDROM="$CDROM"
+               else
+                       CDDA2WAVCDROM="$CDROMID"
+               fi
        fi
 
        # Do we have CD-Text on the disc (and can the drive read it?)
@@ -2273,9 +2284,11 @@ do_cdtext ()
                TRACKM1=$(($TRACK - 1))
                TITLE="$(grep -E ^Track\ +$TRACK: "$ABCDETEMPDIR/cd-text" | tr -d \\r\\n | sed 's~^Track ..: .~~g;'"s~'$~~g")"
                echo "$TRACK: $TITLE" >> "$ABCDETEMPDIR/cddbchoices"
-               sed -i "s~^TTITLE${TRACKM1}=.*~TTITLE${TRACKM1}=${TITLE}~" "$ABCDETEMPDIR/cddbread.1"
+               sed "s~^TTITLE${TRACKM1}=.*~TTITLE${TRACKM1}=${TITLE}~" "$ABCDETEMPDIR/cddbread.1" > "$ABCDETEMPDIR/cddbread.new"
+        mv -f "$ABCDETEMPDIR/cddbread.new" "$ABCDETEMPDIR/cddbread.1"
        done
-       sed -i "s~^DTITLE=.*~DTITLE=${ATITLE}~" "$ABCDETEMPDIR/cddbread.1"
+       sed "s~^DTITLE=.*~DTITLE=${ATITLE}~" "$ABCDETEMPDIR/cddbread.1" > "$ABCDETEMPDIR/cddbread.new"
+    mv -f "$ABCDETEMPDIR/cddbread.new" "$ABCDETEMPDIR/cddbread.1"
        echo >> "$ABCDETEMPDIR/cddbchoices"
        echo "cdtext-readcomplete" >> "$ABCDETEMPDIR/status"
 }
@@ -2942,7 +2955,7 @@ do_cdread ()
                cdda2wav | icedax)
                        if [ "$OSFLAVOUR" = "OSX" ] ; then
                                # Hei, we have to unmount the device before running anything like cdda2wav/icedax in OSX
-                               diskutil unmount ${CDROM#/dev/} 0
+                               diskutil unmount ${CDROM#/dev/}
                                # Also, in OSX the cdrom device for cdda2wav/icedax changes...
                                CDDA2WAVCDROM="IODVDServices"
                        elif [ "$OSFLAVOUR" = "FBSD" ] ; then
@@ -3193,7 +3206,6 @@ MPPENC=mppenc
 AACENC=faac
 
 ID3=id3
-ID3V2=id3v2
 EYED3=eyeD3
 VORBISCOMMENT=vorbiscomment
 METAFLAC=metaflac
@@ -3245,7 +3257,7 @@ MPPENCOPTS=
 AACENCOPTS=
 
 ID3OPTS=
-ID3V2OPTS=
+EYED3OPTS="--set-encoding=utf16-LE"
 CDPARANOIAOPTS=
 CDDA2WAVOPTS=
 DAGRABOPTS=
@@ -3268,11 +3280,11 @@ MAXPROCS=1
 # List of actions to perform - by default, run to completion
 ACTIONS=cddb,read,encode,tag,move,clean
 
-# This option is basicaly for Debian package dependencies:
-# List of prefered outputs - by default, run with whatever we have in the path
+# This option is basically for Debian package dependencies:
+# List of preferred outputs - by default, run with whatever we have in the path
 DEFAULT_OUTPUT_BINARIES=vorbis:oggenc,flac:flac,mp3:toolame,mp3:lame,mp3:bladeenc,spx:speex,m4a:faac
 
-# List of prefered cdromreaders - by default, run whichever we have in the path
+# List of preferred cdromreaders - by default, run whichever we have in the path
 DEFAULT_CDROMREADERS="cdparanoia icedax cdda2wav"
 
 # List of quality levels associated with the encoders:
@@ -3281,7 +3293,7 @@ DEFAULT_QUALITY_LO="oggenc:-q 1,lame:-q 7,speex:--quality 5,m4a:"
 DEFAULT_QUALITY_HI="oggenc:-q 7,lame:--preset standard,speex:--quality 9,m4a:"
 DEFAULT_QUALITY_XHI="oggenc:-q 10,lame:--preset extreme,speex:--quality 10,m4a:"
 
-# Asume fetch if under FreeBSD. curl is used for Mac OS X. wget is used for
+# Assume fetch if under FreeBSD. curl is used for Mac OS X. wget is used for
 # Linux/OpenBSD. ftp is user for NetBSD.
 # Let's use these checkings to determine the OS flavour, which will be used
 # later
@@ -3313,10 +3325,7 @@ else
 fi
 
 # If CDDBAVAIL is set to n, no CDDB read is done
-# If USEID3 is set to n, no ID3 tagging is done
 CDDBAVAIL=y
-USEID3=y
-USEID3V2=y
 
 # There we go..
 # But before we get into business, let us chop off any GREP environmental
@@ -3360,6 +3369,8 @@ fi
 if [ "$CDROM" = "" ] ; then
        if [ -e /dev/cdroms/cdrom0 ]; then
                CDROM=/dev/cdroms/cdrom0
+       elif [ "$OSFLAVOUR" = "OSX" ] && [[ $(diskutil list) =~ CD_part.*(disk.)$'\n' ]]; then
+               CDROM=/dev/${BASH_REMATCH[1]}
        elif [ -e /dev/cdrom ]; then
                CDROM=/dev/cdrom
        elif [ -e /dev/sr0 ]; then
@@ -3370,8 +3381,6 @@ if [ "$CDROM" = "" ] ; then
                CDROM=/dev/acd0c
        elif [ -e /dev/disk1 ]; then
                CDROM=/dev/disk1
-       elif [ "$OSFLAVOUR" = "OSX" ] && [[ $(diskutil list) =~ CD_part.*(disk.)$'\n' ]]; then
-               CDROM=/dev/${BASH_REMATCH[1]}
        fi
 fi
 
@@ -3593,7 +3602,7 @@ if [ X"$CDROM" != "X" ] ; then
                if [ "$OSFLAVOUR" = "FBSD" ]; then
                        if echo "$CDROMID" | grep "^[0-9],[0-9],[0-9]$" >/dev/null 2>&1 ; then :; else
                                log error "CDROMID not in the right format for $CDROMREADERSYNTAX"
-                               log error "Use \"cdrecord -scanbus\" to obtain a adecuate ID an set CDROMID accordingly"
+                               log error "Use \"cdrecord -scanbus\" to obtain an adequate ID and set CDROMID accordingly"
                                exit 1
                        fi
                fi
@@ -3863,8 +3872,9 @@ if [ "$ID3TAGV" = "1" ]; then
        TAGGER="$ID3"
        TAGGEROPTS="$ID3OPTS"
 else
-       TAGGER="$ID3V2"
-       TAGGEROPTS="$ID3V2OPTS"
+       TAGGER="$EYED3"
+       TAGGEROPTS="$EYED3OPTS"
+       ID3SYNTAX=eyed3
 fi
 
 # NOGAP is specific to lame. Other encoders fail ...
@@ -4048,7 +4058,7 @@ if [ "$DOREAD" = "y" ]; then
        #  - set the CD speed value with eject -x
        vecho -n "Executing customizable pre-read function... "
 
-       pre_read # Execute the user-defined pre-read funtion. Close the CD with it.
+       pre_read # Execute the user-defined pre-read function. Close the CD with it.
 
        vecho "done."
 fi
@@ -4078,7 +4088,7 @@ if [ "$DOCDDB" = "y" ]; then
                        esac
                fi
                CHOICE=$(checkstatus cddb-choice)
-               if [ $CHOICE = 0 ] ; then
+               if [ "$CHOICE" = 0 ] ; then
                        # We don't have any information at all; try to fall back
                        # to CD-Text for basic information
                        vecho "No CDDB information found, trying cdtext from the CD"
@@ -4203,7 +4213,7 @@ if [ "$NOGAP" = "y" ] || [ "$BATCHNORM" = "y" ] || [ "$ONETRACK" = "y" ]; then
        echo NEXTTRACK
 fi
 
-# Execute the user-defined post_read funtion before ejecting CD
+# Execute the user-defined post_read function before ejecting CD
 post_read
 
 # We are now finished with the cdrom - it can be safely ejected. Note that