It is a dynamic file, so out
[clinton/abcde.git] / abcde
diff --git a/abcde b/abcde
index 852164d..e233a6e 100755 (executable)
--- a/abcde
+++ b/abcde
@@ -11,7 +11,7 @@
 # Copyright for this work is to expire January 1, 2010, after which it
 # shall be public domain.
 
 # Copyright for this work is to expire January 1, 2010, after which it
 # shall be public domain.
 
-VERSION=2.1.20-2.2pre2
+VERSION=2.2pre2
 
 usage ()
 {
 
 usage ()
 {
@@ -35,7 +35,7 @@ echo "-L    Use local CDDB storage directory"
 echo "-n    No lookup. Don't query CDDB, just create and use template"
 echo "-N    Noninteractive. Never prompt for anything"
 echo "-m    Modify playlist to include CRLF endings, to comply with some players"
 echo "-n    No lookup. Don't query CDDB, just create and use template"
 echo "-N    Noninteractive. Never prompt for anything"
 echo "-m    Modify playlist to include CRLF endings, to comply with some players"
-echo "-o    Output file type(s) (ogg,mp3,flac,spx). Defaults to ogg"
+echo "-o    Output file type(s) (ogg,mp3,flac,spx,mpc). Defaults to ogg"
 echo "-p    Pad track numbers with 0's (if less than 10 tracks)"
 echo "-r    [host1,host2...] Also encode on these remote hosts"
 echo "-s    Start the track numbering at a given number"
 echo "-p    Pad track numbers with 0's (if less than 10 tracks)"
 echo "-r    [host1,host2...] Also encode on these remote hosts"
 echo "-s    Start the track numbering at a given number"
@@ -465,7 +465,7 @@ do_encode ()
                                # errors, so I have not tried it myself.
                                ## FIXME ## Needs some cleanup to determine if an empty tag sent
                                ## FIXME ## to the encoder ends up empty.
                                # errors, so I have not tried it myself.
                                ## FIXME ## Needs some cleanup to determine if an empty tag sent
                                ## FIXME ## to the encoder ends up empty.
-                               run_command encodetrack-$OUTPUT-$1 nice $ENCNICE $MPPENCODER $MPPENCOPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" "$IN" "$OUT"
+                               run_command encodetrack-$OUTPUT-$1 nice $ENCNICE $MPPENCODER $MPPENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" "$IN" "$OUT"
                                ;;
                        esac
                done
                                ;;
                        esac
                done
@@ -661,7 +661,7 @@ do_move ()
                ALBUMFILE=$(mungefilename "$DALBUM")
                ARTISTFILE=$(mungefilename "$TRACKARTIST")
                TRACKFILE=$(mungefilename "$TRACKNAME")
                ALBUMFILE=$(mungefilename "$DALBUM")
                ARTISTFILE=$(mungefilename "$TRACKARTIST")
                TRACKFILE=$(mungefilename "$TRACKNAME")
-               GENRE=$(echo $CDGENRE | tr "[:upper:]" "[:lower:]")
+               GENRE=$(mungegenre "$GENRE")
                YEAR=$(echo $CDYEAR)
                # If we want to start the tracks with a given number, we need to modify the
                # TRACKNUM value before evaluation
                YEAR=$(echo $CDYEAR)
                # If we want to start the tracks with a given number, we need to modify the
                # TRACKNUM value before evaluation
@@ -701,7 +701,7 @@ do_playlist ()
                for LASTTRACK in $TRACKQUEUE; do :; done
                ALBUMFILE=$(mungefilename "$DALBUM")
                ARTISTFILE=$(mungefilename "$DARTIST")
                for LASTTRACK in $TRACKQUEUE; do :; done
                ALBUMFILE=$(mungefilename "$DALBUM")
                ARTISTFILE=$(mungefilename "$DARTIST")
-               GENRE=$(echo $CDGENRE | tr "[:upper:]" "[:lower:]")
+               GENRE=$(mungegenre "$GENRE")
                if [ "$VARIOUSARTISTS" = "y" ] ; then
                        PLAYLISTFILE=$(eval echo $VAPLAYLISTFORMAT)
                else
                if [ "$VARIOUSARTISTS" = "y" ] ; then
                        PLAYLISTFILE=$(eval echo $VAPLAYLISTFORMAT)
                else
@@ -725,7 +725,11 @@ do_playlist ()
                                echo e >&2
                                ERASEPLAYLIST=e
                        fi
                                echo e >&2
                                ERASEPLAYLIST=e
                        fi
-                       [ "$ERASEPLAYLIST" = "e" -o "$ERASEPLAYLIST" = "E" ] && rm -f "$OUTPUTDIR/$PLAYLISTFILE"
+                       # Once we erase the playlist, we use append to create the new one.
+                       [ "$ERASEPLAYLIST" = "e" -o "$ERASEPLAYLIST" = "E" ] && rm -f "$OUTPUTDIR/$PLAYLISTFILE" && ERASEPLAYLIST=a
+               else
+                       # The playlist does not exist, so we can safelly use append to create the new list
+                       ERASEPLAYLIST=a
                fi
                if [ "$ERASEPLAYLIST" = "a" -o "$ERASEPLAYLIST" = "A" ]; then
                        touch "$OUTPUTDIR/$PLAYLISTFILE"
                fi
                if [ "$ERASEPLAYLIST" = "a" -o "$ERASEPLAYLIST" = "A" ]; then
                        touch "$OUTPUTDIR/$PLAYLISTFILE"
@@ -783,7 +787,7 @@ do_discid ()
 {
        # Query the CD to get the track info, unless the user specified -C
        if [ -z "$DISCID" ]; then
 {
        # Query the CD to get the track info, unless the user specified -C
        if [ -z "$DISCID" ]; then
-               echo -n "Getting CD track info... "
+               vecho -n "Getting CD track info... "
                TRACKINFO=$($CDDISCID $CDROM)
                # Make sure there's a CD in there by checking cd-discid's return code
                if [ "$?" = "1" ]; then
                TRACKINFO=$($CDDISCID $CDROM)
                # Make sure there's a CD in there by checking cd-discid's return code
                if [ "$?" = "1" ]; then
@@ -1017,7 +1021,7 @@ do_localcddb ()
                                        done
                                        [ x"$USELOCALRESP" = "x" ] && USELOCALRESP="y"
                                else
                                        done
                                        [ x"$USELOCALRESP" = "x" ] && USELOCALRESP="y"
                                else
-                                       echo "y">&2
+                                       echo "y" >&2
                                fi
                                if [ "$USELOCALRESP" = "y" ]; then
                                #echo "Using local copy of CDDB data"
                                fi
                                if [ "$USELOCALRESP" = "y" ]; then
                                #echo "Using local copy of CDDB data"
@@ -1286,7 +1290,7 @@ do_cddbedit ()
                        fi
                else
                        # We need some code to show the selected option when local repository is selected and we have found a match
                        fi
                else
                        # We need some code to show the selected option when local repository is selected and we have found a match
-                       vecho "Using cached CDDB match..."
+                       vecho "Using cached CDDB match..." >&2
                        # Display the $ABCDETEMPDIR/cddbchoices file created above
                        # Pick a pager so that if the tracks overflow the screen the user can still view everything
                        if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
                        # Display the $ABCDETEMPDIR/cddbchoices file created above
                        # Pick a pager so that if the tracks overflow the screen the user can still view everything
                        if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
@@ -1333,7 +1337,7 @@ do_cddbedit ()
                exit 1
        fi
        CDDBDATA="$ABCDETEMPDIR/cddbread.$(checkstatus cddb-choice)"
                exit 1
        fi
        CDDBDATA="$ABCDETEMPDIR/cddbread.$(checkstatus cddb-choice)"
-       echo -n "Edit selected CDDB data? [y/n] ("
+       echo -n "Edit selected CDDB data? [y/n] (" >&2
        if [ "$INTERACTIVE" = "y" ]; then
                if [ "$UNKNOWNDISK" = "y" ]; then
                        echo -n "y): " >&2
        if [ "$INTERACTIVE" = "y" ]; then
                if [ "$UNKNOWNDISK" = "y" ]; then
                        echo -n "y): " >&2
@@ -1734,6 +1738,8 @@ OGGENCOPTS=
 FLACOPTS=
 # speex
 SPEEXENCOPTS=
 FLACOPTS=
 # speex
 SPEEXENCOPTS=
+# mpc
+MPPENCOPTS=
 
 ID3OPTS=
 ID3V2OPTS=
 
 ID3OPTS=
 ID3V2OPTS=
@@ -1758,7 +1764,13 @@ ACTIONS=cddb,read,encode,tag,move,clean
 # Custom filename munging:
 mungefilename ()
 {
 # Custom filename munging:
 mungefilename ()
 {
-       echo "$@" | sed s,:,\ -,g | tr \ / __ | tr -d \'\"\?\[:cntrl:\]
+       echo "$@" | sed s,:,\ -,g | tr \ /\* __+ | tr -d \'\"\?\[:cntrl:\]
+}
+
+# Custom genre munging:
+mungegenre ()
+{
+       echo $CDGENRE | tr "[:upper:]" "[:lower:]"
 }
 
 # pre_read
 }
 
 # pre_read