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)"
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 ()
echo $TO
}
+# do_getcddbinfo
+# Finds an specific field from cddbinfo
+#
+# TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2 -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')
+# TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2 -d= | tr -d \[:cntrl:\])
+# TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
+
+do_getcddbinfo ()
+{
+ :
+}
+
# This code splits the a Various Artist track name from one of the following
# forms:
#
TRACKNAME=$(echo "$DTITLEARTIST" | cut -f1 -d~)
;;
esac
- elif [ "$ONETRACK" = "y" ]; then
+ elif [ "$VARIOUSARTISTS" = "y" ] && [ "$ONETRACK" = "y" ]; then
TRACKARTIST="Various"
else
TRACKARTIST="$DARTIST"
"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 ;;
"anime") id=145 ;;
"jpop") id=146 ;;
"synthpop") id=147 ;;
+ "rock/pop"|"rock / pop") id=148 ;;
*) return 1 ;;
esac
echo ${id}
# 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
TEMPARG="PIPE_$MPPENCODER"
;;
esac
- IN=${!TEMPARG}
+ IN="$( eval echo "\$$TEMPARG" )"
else
IN="$ABCDETEMPDIR/track$1.wav"
case "$OUTPUT" in
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
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
+ 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
+ if [ ! X"$PARSEDGENRE" = "X" ]; then
echo "Genre: $PARSEDGENRE"
fi
fi
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
[ 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
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)
CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
if [ "$USEPIPES" = "y" ]; then
TEMPARG="PIPE_$CDROMREADERSYNTAX"
- FILEARG="${!TEMPARG}"
+ FILEARG="$( eval echo "\$$TEMPARG" )"
REDIR=""
PIPE_MESSAGE="and encoding "
else
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:
ID3=id3
ID3V2=id3v2
+EYED3=eyeD3
CDPARANOIA=cdparanoia
CDDA2WAV=cdda2wav
DAGRAB=dagrab
# 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
elif [ X$(uname) = "XOpenBSD" ] ; then
HTTPGET=wget
MD5SUM=md5
+elif [ X$(uname) = "XNetBSD" ] ; then
+ HTTPGET=ftp
+ MD5SUM=md5
else
HTTPGET=wget
fi
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
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.}" ;;
e) ERASEENCODEDSTATUS=y ;;
h) usage; exit ;;
e) ERASEENCODEDSTATUS=y ;;
+ E) ENCODING="$OPTARG" ;;
# f) FORCECDDBUSELOCAL=y ;;
i) INLINETAG=y ;;
j) MAXPROCS="$OPTARG" ;;
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
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
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
${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)