fi
}
-# do_getcddbinfo
+# 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
+}
+
+# getcddbinfo
# Finds an specific field from cddbinfo
-do_getcddbinfo()
+getcddbinfo()
{
case $1 in
TRACKNAME1)
esac
}
-# do_gettracknum
+# gettracknum
# Get the track number we are going to use for different actions
-do_gettracknum()
+gettracknum()
{
if [ -n "$STARTTRACKNUMBER" ] ; then
# Get the trackpadding from the current track
{
if checkstatus replaygain; then :; else
run_command "" echo "Adding replygain information..."
- for OUTPUT in $( echo $OUTPUTTYPE | tr , \ )
+ for TMPOUTPUT in $( echo $OUTPUTTYPE | tr , \ )
do
- case $OUTPUT in
+ case $TMPOUTPUT in
vorbis|ogg)
OUTPUT=$OGGOUTPUTCONTAINER
;;
flac)
OUTPUT=$FLACOUTPUTCONTAINER
;;
+ *)
+ OUTPUT=$TMPOUTPUT
+ ;;
esac
OUTPUTFILES=""
REPLAYINDEX=0
for UTRACKNUM in $TRACKQUEUE
do
CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
- do_getcddbinfo TRACKNAME
+ getcddbinfo TRACKNAME
splitvarious
TRACKFILE="$(mungefilename "$TRACKNAME")"
ARTISTFILE="$(mungefilename "$TRACKARTIST")"
ALBUMFILE="$(mungefilename "$DALBUM")"
- do_gettracknum
+ gettracknum
if [ "$VARIOUSARTISTS" = "y" ]; then
- OUTPUTFILE="$(eval echo $VAOUTPUTFORMAT)"
+ OUTPUTFILE="$(eval echo "$VAOUTPUTFORMAT")"
else
- OUTPUTFILE="$(eval echo $OUTPUTFORMAT)"
+ OUTPUTFILE="$(eval echo "$OUTPUTFORMAT")"
fi
OUTPUTFILES[$REPLAYINDEX]="$OUTPUTDIR/$OUTPUTFILE.$OUTPUT"
(( REPLAYINDEX = $REPLAYINDEX + 1 ))
# If we want to start the tracks with a given number, we need to modify the
# TRACKNUM value before evaluation
if [ -n "$STARTTRACKNUMBERTAG" ] ; then
- do_gettracknum
+ gettracknum
fi
for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
do
fi
# We need IN to proceed, if we are not using pipes.
if [ -s "$IN" -o X"$USEPIPES" = "Xy" ] ; then
- for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
+ for TMPOUTPUT in $(echo $OUTPUTTYPE | tr , \ )
do
- case "$OUTPUT" in
+ case "$TMPOUTPUT" in
vorbis|ogg)
OUT="$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER"
OUTPUT=$OGGOUTPUTCONTAINER
;;
*)
OUT="$ABCDETEMPDIR/track$1.$OUTPUT"
+ OUTPUT=$TMPOUTPUT
;;
esac
if [ "$NOGAP" = "y" ] && checkstatus encodetrack-$OUTPUT-$1 ; then
# TRACKNUM, TRACKNAME, TRACKARTIST, DALBUM, OUTPUTFORMAT, CDGENRE, CDYEAR
do_move ()
{
- for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
+ for TMPOUTPUT in $(echo $OUTPUTTYPE | tr , \ )
do
+ # For now, set OUTPUT as TMPOUTPUT, and then change it once we have
+ # defined the OUTPUTFILE:
+ OUTPUT="$TMPOUTPUT"
+
# Create ALBUMFILE, ARTISTFILE, TRACKFILE
# Munge filenames as follows:
# ' ' -> '_'
ARTISTFILE="$(mungefilename "$TRACKARTIST")"
TRACKFILE="$(mungefilename "$TRACKNAME")"
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
- do_gettracknum
- # Supported variables for OUTPUTFORMAT are GENRE, ALBUMFILE, ARTISTFILE,
- # TRACKFILE, and TRACKNUM.
+ YEAR=${CDYEAR:-$CDYEAR}
+ # If we want to start the tracks with a given number, we need to modify
+ # the TRACKNUM value before evaluation
+ gettracknum
+ # Supported variables for OUTPUTFORMAT are GENRE, YEAR, ALBUMFILE,
+ # ARTISTFILE, TRACKFILE, and TRACKNUM.
if [ "$VARIOUSARTISTS" = "y" ]; then
OUTPUTFILE="$(eval echo "$VAOUTPUTFORMAT")"
else
OUTPUTFILE="$(eval echo "$OUTPUTFORMAT")"
fi
if checkerrors "tagtrack-$OUTPUT-$1"; then :; else
- # Once we know the specific output was successful, we can change the OUTPUT to the value containing the container
- case $OUTPUT in
+ # Once we know the specific output was successful, we can change
+ # the OUTPUT to the value containing the container
+ case $TMPOUTPUT in
vorbis|ogg)
OUTPUT=$OGGOUTPUTCONTAINER
;;
flac)
OUTPUT=$FLACOUTPUTCONTAINER
;;
+ *)
+ OUTPUT=$TMPOUTPUT
+ ;;
esac
# Check that the directory for OUTPUTFILE exists, if it doesn't, create it
OUTPUTFILEDIR="$(dirname "$OUTPUTDIR/$OUTPUTFILE")"
# VARIOUSARTISTS, OUTPUTDIR
do_playlist ()
{
- for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
+ for TMPOUTPUT in $(echo $OUTPUTTYPE | tr , \ )
do
- case $OUTPUT in
+ case $TMPOUTPUT in
vorbis|ogg)
OUTPUT=$OGGOUTPUTCONTAINER
;;
flac)
OUTPUT=$FLACOUTPUTCONTAINER
;;
+ *)
+ OUTPUT=$TMPOUTPUT
+ ;;
esac
# Create a playlist file for the playlist data to go into.
# We used to wipe it out if it existed. Now we request permision if interactive.
for LASTTRACK in $TRACKQUEUE; do :; done
ALBUMFILE="$(mungefilename "$DALBUM")"
ARTISTFILE="$(mungefilename "$DARTIST")"
- GENRE=$(mungegenre "$GENRE")
+ GENRE="$(mungegenre "$GENRE")"
YEAR=${CDYEAR:-$CDYEAR}
if [ "$VARIOUSARTISTS" = "y" ] ; then
- PLAYLISTFILE=$(eval echo $VAPLAYLISTFORMAT)
+ PLAYLISTFILE="$(eval echo "$VAPLAYLISTFORMAT")"
else
- PLAYLISTFILE=$(eval echo $PLAYLISTFORMAT)
+ PLAYLISTFILE="$(eval echo "$PLAYLISTFORMAT")"
fi
- FINALPLAYLISTDIR=$(dirname "$OUTPUTDIR/$PLAYLISTFILE")
+ FINALPLAYLISTDIR="$(dirname "$OUTPUTDIR/$PLAYLISTFILE")"
mkdir -p "$FINALPLAYLISTDIR"
if [ -s "$OUTPUTDIR/$PLAYLISTFILE" ]; then
echo -n "Erase, Append to, or Keep the existing playlist file? [e/a/k] (e): " >&2
do
# Shares some code with do_move since the filenames have to match
CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
- do_getcddbinfo TRACKNAME
+ getcddbinfo TRACKNAME
splitvarious
TRACKFILE="$(mungefilename "$TRACKNAME")"
ARTISTFILE="$(mungefilename "$TRACKARTIST")"
ALBUMFILE="$(mungefilename "$DALBUM")"
# If we want to start the tracks with a given number, we need to modify the
# TRACKNUM value before evaluation
- do_gettracknum
+ gettracknum
if [ "$VARIOUSARTISTS" = "y" ]; then
- OUTPUTFILE=$(eval echo $VAOUTPUTFORMAT)
+ OUTPUTFILE="$(eval echo "$VAOUTPUTFORMAT")"
else
- OUTPUTFILE=$(eval echo $OUTPUTFORMAT)
+ OUTPUTFILE="$(eval echo "$OUTPUTFORMAT")"
fi
if [ "$VARIOUSARTISTS" = "y" ]; then
if [ "$VAPLAYLISTDATAPREFIX" ] ; then
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 ###
echo "Grabbing ${PIPE_MESSAGE}tracks $UTRACKNUM - $LASTTRACK as one track ..." >&2
else
if [ -r "$CDDBDATA" ]; then
- do_getcddbinfo TRACKNAME
+ getcddbinfo TRACKNAME
echo "Grabbing ${PIPE_MESSAGE}track $UTRACKNUM: $TRACKNAME..." >&2
else
echo "Grabbing ${PIPE_MESSAGE}track $UTRACKNUM..." >&2
do_discid # Get ABCDETEMPDIR created and status file initialized
;;
musicbrainz)
- do_musicbrainz
+ do_musicbrainz id
;;
esac
(
-if [ "$ONETRACK" = "y" ]; then
+if [ ! "$ONETRACK" = "y" ]; then
if [ "$DOPLAYLIST" = "y" ]; then
echo Creating playlist... >&2
do_playlist
else
TRACKNUM=$UTRACKNUM
CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
- do_getcddbinfo TRACKNAME
+ getcddbinfo TRACKNAME
splitvarious
fi
fi