fi
}
+# diffentries <filename> <max_value> <entry1>,<entry2>
+diffentries ()
+{
+ FILENAME=$1
+ shift
+ local CDDBDIFFCHOICES=$1
+ shift
+ local CDDBDIFFCHOICE="$@"
+ if [ ! X"$DIFF" = "X" ]; then
+ PARSECHOICE1=$(echo $CDDBDIFFCHOICE | cut -d"," -f1 | xargs printf %d 2>/dev/null)
+ PARSECHOICE2=$(echo $CDDBDIFFCHOICE | cut -d"," -f2 | xargs printf %d 2>/dev/null)
+ if [ $PARSECHOICE1 -lt 1 ] || [ $PARSECHOICE1 -gt $CDDBDIFFCHOICES ] || \
+ [ $PARSECHOICE2 -lt 1 ] || [ $PARSECHOICE2 -gt $CDDBDIFFCHOICES ] || \
+ [ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then
+ echo "Invalid diff range. Please select two coma-separated numbers between 1 and $CDDBDIFFCHOICES" >&2
+ else
+ # We parse the 2 choices to diff, store them in temporary files and diff them.
+ for PARSECHOICE in $(echo $CDDBDIFFCHOICE | tr , \ ); do
+ do_cddbparse "$ABCDETEMPDIR/$FILENAME.$PARSECHOICE" > "$ABCDETEMPDIR/$FILENAME.parsechoice.$PARSECHOICE"
+ done
+ echo "Showing diff between choices $PARSECHOICE1 and $PARSECHOICE2..." > "$ABCDETEMPDIR/$FILENAME.diff"
+ $DIFF $DIFFOPTS "$ABCDETEMPDIR/$FILENAME.parsechoice.$PARSECHOICE1" "$ABCDETEMPDIR/$FILENAME.parsechoice.$PARSECHOICE2" >> "$ABCDETEMPDIR/$FILENAME.diff"
+ if [ $(cat "$ABCDETEMPDIR/$FILENAME.diff" | wc -l) -ge 24 ]; then
+ page "$ABCDETEMPDIR/$FILENAME.diff"
+ else
+ cat "$ABCDETEMPDIR/$FILENAME.diff" >&2
+ fi
+ fi
+ else
+ echo "The diff program was not found in your path. Please choose a number between 0 and $CDDBDIFFCHOICES." >&2
+ fi
+}
+
# do_getcddbinfo
# Finds an specific field from cddbinfo
do_getcddbinfo()
disktool -u ${CDROM#/dev/}
fi
if [ "$CDROMREADERSYNTAX" = "flac" ] ; then
- if [ "$TRACKINFO" = "" ]; then
+ if $METAFLAC $METAFLACOPTS --export-cuesheet-to=- $CDROM > /dev/null 2>&1 ; then
TRACKINFO=$($METAFLAC $METAFLACOPTS --export-cuesheet-to=- $CDROM | $CUE2DISCID)
else
- if $METAFLAC $METAFLACOPTS --export-cuesheet-to=- $CDROM > /dev/null 2>&1 ; then :; else
- log error "the input flac file does not contain a cuesheet."
- exit 1
- fi
+ log error "the input flac file does not contain a cuesheet."
+ exit 1
fi
else
case "$CDDBMETHOD" in
if checkstatus cuefile > /dev/null 2>&1 ; then :; else
CUEFILE=cue-$(echo "$TRACKINFO" | cut -f1 -d' ').txt
vecho "Creating cue file..."
- if $CUEREADER $CUEREADEROPTS > "$ABCDETEMPDIR/$CUEFILE"; then
- echo cuefile=$CUEFILE >> "$ABCDETEMPDIR/status"
- else
- log warning "reading the CUE sheet with mkcue is still considered experimental"
- log warning "and there was a problem with the CD reading. abcde will continue,"
- log warning "but consider reporting the problem to the abcde author"
- fi
+ case $CDROMREADERSYNTAX in
+ flac)
+ if $METAFLAC --export-cuesheet-to=- $CDROM > "$ABCDETEMPDIR/$CUEFILE"; then :; else
+ log warning "the input flac file does not contain a cuesheet."
+ fi
+ ;;
+ *)
+ if $CUEREADER $CUEREADEROPTS > "$ABCDETEMPDIR/$CUEFILE"; then
+ echo cuefile=$CUEFILE >> "$ABCDETEMPDIR/status"
+ else
+ log warning "reading the CUE sheet with mkcue is still considered experimental"
+ log warning "and there was a problem with the CD reading. abcde will continue,"
+ log warning "but consider reporting the problem to the abcde author"
+ fi
+ ;;
+ esac
fi
fi
# If we got the CDPARANOIA status and it is not recorded, save it now
echo ""
} >> "$ABCDETEMPDIR/cddblocalchoices"
done
+ if [ $(cat "$ABCDETEMPDIR/cddblocalchoices" | wc -l) -ge 24 ]; then
+ page "$ABCDETEMPDIR/cddblocalchoices"
+ else
+ # It's all going to fit in one page, cat it
+ cat "$ABCDETEMPDIR/cddblocalchoices" >&2
+ fi
CDDBLOCALCHOICES=$( echo "$CDDBLOCALRESULTS" | wc -l )
- cat "$ABCDETEMPDIR/cddblocalchoices"
+ # Setting the choice to an impossible integer to avoid errors in the numeric comparisons
CDDBLOCALCHOICENUM=-1
if [ "$INTERACTIVE" = "y" ]; then
while [ $CDDBLOCALCHOICENUM -lt 0 ] || [ $CDDBLOCALCHOICENUM -gt $CDDBLOCALCHOICES ]; do
echo -n "Locally cached CDDB entries found. Which one would you like to use (0 for none)? [0-$CDDBLOCALCHOICES]: " >&2
- read CDDBLOCALCHOICENUM
- [ x"$CDDBLOCALCHOICENUM" = "x" ] && CDDBLOCALCHOICENUM="1"
+ read CDDBLOCALCHOICE
+ [ x"$CDDBLOCALCHOICE" = "x" ] && CDDBLOCALCHOICE="1"
+ # FIXME # Introduce diff's
+ if echo $CDDBLOCALCHOICE | egrep -q "[[:space:]]*[[:digit:]]+,[[:digit:]]+[[:space:]]*" ; then
+ diffentries cddblocalread "$CDDBLOCALCHOICES" "$CDDBLOCALCHOICE"
+ elif echo $CDDBLOCALCHOICE | egrep -q "[[:space:]]*[[:digit:]]+[[:space:]]*" ; then
+ # Make sure we get a valid choice
+ CDDBLOCALCHOICENUM=$(echo $CDDBLOCALCHOICE | xargs printf %d 2>/dev/null)
+ if [ $CDDBLOCALCHOICENUM -lt 0 ] || [ $CDDBLOCALCHOICENUM -gt $CDDBLOCALCHOICES ]; then
+ echo "Invalid selection. Please choose a number between 0 and $CDDBLOCALCHOICES." >&2
+ fi
+ fi
done
else
### FIXME ###
# the user said
# We need the first and last track for cdda2wav
FIRSTTRACK=$2
- LASTTRACK=$3
+ LASTTRACK=$(expr $3 + 0)
UTRACKNUM=$FIRSTTRACK
case "$CDROMREADERSYNTAX" in
flac) READTRACKNUMS="$FIRSTTRACK.1-$(($LASTTRACK + 1)).0" ;;
cdparanoia) READTRACKNUMS="$FIRSTTRACK-$LASTTRACK" ;;
- cdda2wav) READTRACKNUMS="$FIRSTTRACK+$LASTRACK" ;;
+ cdda2wav) READTRACKNUMS="$FIRSTTRACK+$LASTTRACK" ;;
*) echo "abcde error: $CDROMREADERSYNTAX does not support ONETRACK mode"
exit 1 ;;
esac
esac
if [ "$DOCDDB" = "y" ]; then
+ # start with a sane default:
+ CDDBLOCALSTATUS=notfound
if [ $CDDBUSELOCAL = "y" ]; then
do_localcddb
fi
(
-if [ "$ONETRACK" = "y" ]; then
+if [ ! "$ONETRACK" = "y" ]; then
if [ "$DOPLAYLIST" = "y" ]; then
echo Creating playlist... >&2
do_playlist