X-Git-Url: https://git.hcoop.net/clinton/abcde.git/blobdiff_plain/9ff5088c4fb89c87add2aab3cdc1fa1cc081a1fa..4c2499e18e98cd9623007a950efce27928f6f3b0:/abcde diff --git a/abcde b/abcde index 17ebeb1..99e1cf5 100755 --- a/abcde +++ b/abcde @@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) 1998-2001 Robert Woodcock -# Copyright (c) 2003-2004 Jesus Climent +# Copyright (c) 2003-2005 Jesus Climent # This code is hereby licensed for public consumption under either the # GNU GPL v2 or greater, or Larry Wall's Artistic license - your choice. # @@ -31,6 +31,7 @@ echo "-d " echo " Specify CDROM device to grab" echo "-D Debugging mode (equivalent to sh -x abcde)" echo "-e Erase encoded track information from status file" +#echo "-E Set the encoding information for the tags" echo "-h This help information" #echo "-i Tag files while encoding, when possible (local only) -NWY-" echo "-j <#> Number of encoder processes to run at once (localhost)" @@ -161,6 +162,31 @@ checkerrors () fi } +# page [file] +# Finds the right pager in the system to display a file +page () +{ + PAGEFILE="$1" + # Use the debian sensible-pager wrapper to pick the pager + # user has requested via their $PAGER environment variable + if [ -x "/usr/bin/sensible-pager" ]; then + /usr/bin/sensible-pager "$PAGEFILE" + elif [ -x "$PAGER" ]; then + # That failed, try to load the preferred editor, starting + # with their PAGER variable + $PAGER "$PAGEFILE" + # If that fails, check for less + elif [ -x /usr/bin/less ]; then + /usr/bin/less -f "$PAGEFILE" + # more should be on all UNIX systems + elif [ -x /bin/more ]; then + /bin/more "$PAGEFILE" + else + # No bananas, just cat the thing + cat "$PAGEFILE" >&2 + fi +} + # run_command [blurb] [command...] # Runs a command, silently if necessary, and updates the status file run_command () @@ -302,7 +328,7 @@ splitvarious () TRACKNAME=$(echo "$DTITLEARTIST" | cut -f1 -d~) ;; esac - elif [ "$ONETRACK" = "y" ]; then + elif [ "$VARIOUSARTISTS" = "y" ] && [ "$ONETRACK" = "y" ]; then TRACKARTIST="Various" else TRACKARTIST="$DARTIST" @@ -375,7 +401,7 @@ local id="" "gangsta") id=59 ;; "top 40") id=60 ;; "christian rap") id=61 ;; - "pop/funk") id=62 ;; + "pop/funk"|"pop / funk") id=62 ;; "jungle") id=63 ;; "native american") id=64 ;; "cabaret") id=65 ;; @@ -461,6 +487,7 @@ local id="" "anime") id=145 ;; "jpop") id=146 ;; "synthpop") id=147 ;; + "rock/pop"|"rock / pop") id=148 ;; *) return 1 ;; esac echo ${id} @@ -490,11 +517,24 @@ do_tag () # id3v2 v0.1.9 claims to have solved the -c bug, so we merge both id3 and id3v2 GENREID=$(do_getgenreid "${CDGENRE}") - # FIXME # track numbers in mp3 come with 1/10, so we cannot happily substitute them with $TRACKNUM - run_command tagtrack-$1 $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \ - -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -y "$CDYEAR" \ - -g "$GENREID" -T "${TRACKNUM:-$1/$TRACKS}" \ - "$ABCDETEMPDIR/track$1.$OUTPUT" + case "$ID3SYNTAX" in + id3);; + eyed3) + # FIXME # track numbers in mp3 come with 1/10, so we cannot happily substitute them with $TRACKNUM + run_command tagtrack-$1 $TAGGER $TAGGEROPTS --commen=::"$COMMENTOUTPUT" \ + -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -Y "$CDYEAR" \ + -G "$GENREID" -n "${TRACKNUM:-$1}" "${TRACKNUM:+-N $TRACKS}" \ + "${ENCODING:+--set-encoding=$ENCODING}" + "$ABCDETEMPDIR/track$1.$OUTPUT" + ;; + *) + # FIXME # track numbers in mp3 come with 1/10, so we cannot happily substitute them with $TRACKNUM + run_command tagtrack-$1 $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \ + -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -y "$CDYEAR" \ + -g "$GENREID" -T "${TRACKNUM:-$1/$TRACKS}" \ + "$ABCDETEMPDIR/track$1.$OUTPUT" + ;; + esac ;; vorbis|ogg) case "$OGGENCODERSYNTAX" in @@ -626,7 +666,7 @@ do_encode () TEMPARG="PIPE_$MPPENCODER" ;; esac - IN=${!TEMPARG} + IN="$( eval echo "\$$TEMPARG" )" else IN="$ABCDETEMPDIR/track$1.wav" case "$OUTPUT" in @@ -1271,8 +1311,13 @@ do_discid () if checkstatus cuefile > /dev/null 2>&1 ; then :; else CUEFILE=cue-$(echo "$TRACKINFO" | cut -f1 -d' ').txt vecho "Creating cue file..." - $MKCUE $MKCUEOPTS > "$ABCDETEMPDIR/$CUEFILE" - echo cuefile=$CUEFILE >> "$ABCDETEMPDIR/status" + if $CUEREADER $CUEREADEROPTS > "$ABCDETEMPDIR/$CUEFILE"; then + echo cuefile=$CUEFILE >> "$ABCDETEMPDIR/status" + else + echo "abcde: reading the CUE sheet with mkcue is still considered experimental" + echo "abcde: and there was a problem with the CD reading. abcde will continue," + echo "abcde: but consider reporting the problem to the abcde author" + fi fi fi # If we got the CDPARANOIA status and it is not recorded, save it now @@ -1332,14 +1377,14 @@ do_cddbparse () echo "---- $(grep DTITLE "${CDDBPARSEFILE}" | cut '-d=' -f2- | tr -d \\r\\n ) ----" if [ X"$SHOWCDDBYEAR" = "Xy" ]; then PARSEDYEAR=$(grep DYEAR "${CDDBPARSEFILE}" | cut '-d=' -f2-) - if [ X"$PARSEDYEAR" = "X" ]; then - echo "YEAR=$PARSEDYEAR" + if [ ! X"$PARSEDYEAR" = "X" ]; then + echo "Year: $PARSEDYEAR" fi fi if [ X"$SHOWCDDBGENRE" = "Xy" ]; then PARSEDGENRE=$(grep DGENRE "${CDDBPARSEFILE}" | cut '-d=' -f2-) - if [ X"$PARSEDGENRE" = "X" ]; then - echo "GENRE=$PARSEDGENRE" + if [ ! X"$PARSEDGENRE" = "X" ]; then + echo "Genre: $PARSEDGENRE" fi fi if [ ! "$ONETRACK" = "y" ]; then @@ -1595,30 +1640,15 @@ do_cddbedit () else # The user has a choice to make, display the info in a pager if necessary if [ $(cat "$ABCDETEMPDIR/cddbchoices" | wc -l) -ge 24 ]; then - # Use the debian sensible-pager wrapper to pick the pager - # user has requested via their $PAGER environment variable - if [ -x "/usr/bin/sensible-pager" ]; then - /usr/bin/sensible-pager "$ABCDETEMPDIR/cddbchoices" - elif [ -x "$PAGER" ]; then - # That failed, try to load the preferred editor, starting - # with their PAGER variable - $PAGER "$ABCDETEMPDIR/cddbchoices" - # If that fails, check for less - elif [ -x /usr/bin/less ]; then - /usr/bin/less -f "$ABCDETEMPDIR/cddbchoices" - # more should be on all UNIX systems - elif [ -x /bin/more ]; then - /bin/more "$ABCDETEMPDIR/cddbchoices" - else - # No bananas, just cat the thing - cat "$ABCDETEMPDIR/cddbchoices" >&2 - fi + page "$ABCDETEMPDIR/cddbchoices" else # It's all going to fit in one page, cat it cat "$ABCDETEMPDIR/cddbchoices" >&2 fi CDDBCHOICENUM="" + # Setting the choice to an impossible integer to avoid errors in the numeric comparisons + CDCHOICENUM=-1 # I'll take CDDB read #3 for $400, Alex while [ $CDCHOICENUM -lt 0 ] || [ $CDCHOICENUM -gt $CDDBCHOICES ]; do echo -n "Which entry would you like abcde to use (0 for none)? [0-$CDDBCHOICES]: " >&2 @@ -1626,14 +1656,26 @@ do_cddbedit () [ X"$CDDBCHOICE" = "X" ] && CDDBCHOICE=1 if echo $CDDBCHOICE | egrep -q "[[:digit:]]+,[[:digit:]]+" ; then if [ ! X"$DIFF" = "X" ]; then - # We parse the 2 choices to diff, store them in temporary files and diff them. - for PARSECHOICE in $(echo $CDDBCHOICE | tr , \ ); do - do_cddbparse "$ABCDETEMPDIR/cddbread.$PARSECHOICE" > "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE" - done PARSECHOICE1=$(echo $CDDBCHOICE | cut -d"," -f1) PARSECHOICE2=$(echo $CDDBCHOICE | cut -d"," -f2) - echo "Showing diff between choices $PARSECHOICE1 and $PARSECHOICE2..." - $DIFF $DIFFOPTS "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE1" "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE2" + if [ $PARSECHOICE1 -lt 1 ] || [ $PARSECHOICE1 -gt $CDDBCHOICES ] || \ + [ $PARSECHOICE2 -lt 1 ] || [ $PARSECHOICE2 -gt $CDDBCHOICES ] || \ + [ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then + echo "Invalid diff range. Please select two coma-separated numbers between 1 and $CDDBCHOICES" >&2 + else + + # We parse the 2 choices to diff, store them in temporary files and diff them. + for PARSECHOICE in $(echo $CDDBCHOICE | tr , \ ); do + do_cddbparse "$ABCDETEMPDIR/cddbread.$PARSECHOICE" > "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE" + done + echo "Showing diff between choices $PARSECHOICE1 and $PARSECHOICE2..." > "$ABCDETEMPDIR/cddbread.diff" + $DIFF $DIFFOPTS "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE1" "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE2" >> "$ABCDETEMPDIR/cddbread.diff" + if [ $(cat "$ABCDETEMPDIR/cddbread.diff" | wc -l) -ge 24 ]; then + page "$ABCDETEMPDIR/cddbread.diff" + else + cat "$ABCDETEMPDIR/cddbread.diff" >&2 + fi + fi else echo "The diff program was not found in your path. Please choose a number between 0 and $CDDBCHOICES." >&2 fi @@ -1850,7 +1892,7 @@ do_cddbedit () echo "variousartiststyle=$VARIOUSARTISTSTYLE" >> "$ABCDETEMPDIR/status" if [ "$EDITCDDB" = "y" ] && [ "$UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE" = "y" ]; then - if [ $CDDBDATAMD5SUM != "" ] && [ $CDDBDATAMD5SUM != $($MD5SUM "$CDDBDATA" | cut -d " " -f 1) ]; then + if [ "$CDDBDATAMD5SUM" != "" ] && [ "$CDDBDATAMD5SUM" != "$($MD5SUM "$CDDBDATA" | cut -d " " -f 1)" ]; then # This works but does not have the necessary error checking # yet. If you are familiar with the CDDB spec # (see http://www.freedb.org/src/latest/DBFORMAT) @@ -1915,7 +1957,7 @@ do_cdread () CDDBTRACKNUM=$(expr $UTRACKNUM - 1) if [ "$USEPIPES" = "y" ]; then TEMPARG="PIPE_$CDROMREADERSYNTAX" - FILEARG="${!TEMPARG}" + FILEARG="$( eval echo "\$$TEMPARG" )" REDIR="" PIPE_MESSAGE="and encoding " else @@ -2083,6 +2125,7 @@ FLACENCODERSYNTAX=default SPEEXENCODERSYNTAX=default MPPENCODERSYNTAX=default NORMALIZERSYNTAX=default +CUEREADERSYNTAX=default OUTPUTFORMAT='${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}' # Use the following VAOUTPUTFORMAT to revert to 2.0.x VA format: @@ -2132,6 +2175,7 @@ MPPENC=mppenc ID3=id3 ID3V2=id3v2 +EYED3=eyeD3 CDPARANOIA=cdparanoia CDDA2WAV=cdda2wav DAGRAB=dagrab @@ -2199,6 +2243,7 @@ DEFAULT_OUTPUT_BINARIES=vorbis:oggenc,flac:flac,mp3:lame,mp3:bladeenc,spx:speex # Let's use these checkings to determine the OS flavour, which will be used later if [ X$(uname) = "XFreeBSD" ] ; then HTTPGET=fetch + MD5SUM=md5 NEEDCDROMID=y OSFLAVOUR=FBSD elif [ X$(uname) = "XDarwin" ] ; then @@ -2210,6 +2255,9 @@ elif [ X$(uname) = "XDarwin" ] ; then elif [ X$(uname) = "XOpenBSD" ] ; then HTTPGET=wget MD5SUM=md5 +elif [ X$(uname) = "XNetBSD" ] ; then + HTTPGET=ftp + MD5SUM=md5 else HTTPGET=wget fi @@ -2245,6 +2293,7 @@ if [ "$HTTPGETOPTS" = "" ] ; then wget) HTTPGETOPTS="-q -O -";; curl) HTTPGETOPTS="-f -s";; fetch)HTTPGETOPTS="-q -o -";; + ftp) HTTPGETOPTS="-q -o -";; *) echo "abcde warning: HTTPGET in non-standard and HTTPGETOPTS are not defined." >&2 ;; esac fi @@ -2268,11 +2317,11 @@ fi # Parse command line options #while getopts 1a:A:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do -while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:vVxw:W: opt ; do +while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do case "$opt" in 1) ONETRACK=y ;; a) ACTIONS="$OPTARG" ;; - A) EXPACTIONS="$OPTARG";; + A) EXPACTIONS="$OPTARG" ;; b) BATCH=y ;; c) if [ -e "$OPTARG" ] ; then . "$OPTARG" ; else echo "abcde error: config file \"$OPTARG\" cannot be found." >&2 ; exit 1 ; fi ;; C) DISCID="${OPTARG#abcde.}" ;; @@ -2281,6 +2330,7 @@ while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:vVxw:W: opt ; do e) ERASEENCODEDSTATUS=y ;; h) usage; exit ;; e) ERASEENCODEDSTATUS=y ;; + E) ENCODING="$OPTARG" ;; # f) FORCECDDBUSELOCAL=y ;; i) INLINETAG=y ;; j) MAXPROCS="$OPTARG" ;; @@ -2617,6 +2667,14 @@ else TAGGEROPTS="$ID3V2OPTS" fi +# Options for mkcue +case "$CUEREADERSYNTAX" in + default|mkcue) + CUEREADEROPTS="${CDROM}" + CUEREADER="$MKCUE" + ;; +esac + # Check if both OGGEOUTPUTCONTAINER and FLACOUTPUTCONTAINER are the same, and differentiante them if [ X"$OGGOUTPUTCONTAINER" = "Xogg" ] && [ X"$FLACOUTPUTCONTAINER" = "Xogg" ]; then echo "abcde error: FLAC on an Ogg container is not yet supported" >&2 @@ -2652,8 +2710,8 @@ fi if [ ! "$CDDBAVAIL" = "n" ] && [ "$DOCDDB" = "y" ]; then NEEDHTTPGET=y fi -if [ "$CUEFILE" = "y" ]; then - NEEDMKCUE=y +if [ "$MAKECUEFILE" = "y" ]; then + NEEDCUEREADER=y fi if [ X"$CDSPEEDVALUE" != "X" ]; then @@ -2689,13 +2747,13 @@ if [ "$USEPIPES" = "y" ]; then mpc) PIPEENCODERSVARCHECK="PIPE_$MPPENCODER" ;; esac - if [ ! -n "${!PIPERIPPERSVARCHECK}" ] ; then + if [ ! -n "$( eval echo "\$$PIPERIPPERSVARCHECK" )" ] ; then echo "abcde error: no support for pipes with given ripper" >&2 echo "read the USEPIPES file from the source tarball to help" >&2 echo "on a Debian system, read /usr/share/doc/abcde/USEPIPES.gz" >&2 exit 1; fi - if [ ! -n "${!PIPEENCODERSVARCHECK}" ] ; then + if [ ! -n "$( eval echo "\$$PIPEENCODERSVARCHECK" )" ] ; then echo "abcde error: no support for pipes with given encoder" >&2 echo "read the USEPIPES file from the source tarball to help" >&2 echo "on a Debian system, read /usr/share/doc/abcde/USEPIPES.gz" >&2 @@ -2710,7 +2768,7 @@ for X in $CDROMREADER $CDDISCID ${NEEDTAGGER+$TAGGER} $MP3ENCODER \ ${NEEDCOMMENTER+$VORBISCOMMENT} ${NEEDMETAFLAC+$METAFLAC} \ ${NEEDNORMALIZER+$NORMALIZER} ${NEEDEJECT+$EJECT} \ ${NEEDDISKTOOL+disktool} ${NEEDCDSPEED+$CDSPEED} \ - ${NEEDVORBISGAIN+$VORBISGAIN} ${NEEDMKCUE+$MKCUE} + ${NEEDVORBISGAIN+$VORBISGAIN} ${NEEDCUEREADER+$CUEREADER} do # Cut off the command-line options we just added in X=$(echo $X | cut -d' ' -f2) @@ -2735,7 +2793,7 @@ fi # Here it used to say: # One thousand lines in, we can start doing stuff with things -# Well, right now we are at line 2695 ;) +# Well, right now we are at line 2736 ;) # Export needed things so they can be read in this subshell export CDDBTOOL ABCDETEMPDIR TRACKQUEUE LOWDISK EJECTCD EJECT EJECTOPTS