From: EinvalSledge@gmail.com Date: Fri, 20 Apr 2012 01:07:51 +0000 (+0000) Subject: * If we don't find any CDDB or Musicbrainz information for the CD, try X-Git-Url: https://git.hcoop.net/clinton/abcde.git/commitdiff_plain/a778f99c66182a27baca017fdd1a6f229a996557?ds=sidebyside * If we don't find any CDDB or Musicbrainz information for the CD, try to extract CD-Text information to populate the cddbinfo template. (Closes issue 41). git-svn-id: http://abcde.googlecode.com/svn/trunk@321 a0fa61bc-5347-0410-a1a9-7f54aa4e1825 --- diff --git a/abcde b/abcde index 34e0546..33f7128 100755 --- a/abcde +++ b/abcde @@ -2229,6 +2229,58 @@ do_localcddb () fi } +# do_cdtext +# Try to read CD-Text from the drive using icedax / cdda2wav +do_cdtext () +{ + if new_checkexec icedax; then + CDTEXT_READER=icedax + elif new_checkexec cdda2wav; then + CDTEXT_READER=cdda2wav + else + # Didn't find either, bail + return 0 + fi + + if [ "$CDROMID" = "" ]; then + CDDA2WAVCDROM="$CDROM" + else + CDDA2WAVCDROM="$CDROMID" + fi + + # Do we have CD-Text on the disc (and can the drive read it?) + ${CDTEXT_READER} -J -N -D ${CDDA2WAVCDROM} > $ABCDETEMPDIR/cd-text 2>&1 + grep -q '^CD-Text: detected' $ABCDETEMPDIR/cd-text + ERRORCODE=$? + if [ $ERRORCODE -ne 0 ]; then + # No CD-Text found, bail + return 0 + fi + + rm -f "$ABCDETEMPDIR/cddbchoices" + CDDBCHOICES=1 + # Make an empty template + $CDDBTOOL template $(cat "$ABCDETEMPDIR/discid") > "$ABCDETEMPDIR/cddbread.1" + echo -n "Retrieved 1 CD-Text match..." >> "$ABCDETEMPDIR/cddbchoices" + echo "done." >> "$ABCDETEMPDIR/cddbchoices" + echo cddb-read-1-complete >> "$ABCDETEMPDIR/status" + echo cddb-choice=1 >> "$ABCDETEMPDIR/status" + ATITLE=$(grep -e '^Album title:' ${ABCDETEMPDIR}/cd-text | cut -c14- ) + echo "200 none ${ATITLE}" >> "$ABCDETEMPDIR/cddbquery" + # List out disc title/author and contents + echo ---- ${ATITLE} ---- >> "$ABCDETEMPDIR/cddbchoices" + for TRACK in $(f_seq_row 1 $TRACKS) + do + TRACKM1=$(($TRACK - 1)) + TITLE="$(grep -E ^Track\ +$TRACK: "$ABCDETEMPDIR/cd-text" | cut -c11- | tr -d \\r\\n)" + echo "$TRACK: $TITLE" >> "$ABCDETEMPDIR/cddbchoices" + sed -i "s~^TTITLE${TRACKM1}=.*~TTITLE${TRACKM1}=${TITLE}~" $ABCDETEMPDIR/cddbread.1 + done + sed -i "s~^DTITLE=.*~DTITLE=${ATITLE}~" $ABCDETEMPDIR/cddbread.1 + echo >> "$ABCDETEMPDIR/cddbchoices" + echo "cdtext-readcomplete" >> "$ABCDETEMPDIR/status" +} + # do_musicbrainz # Work with the musicbrainz WS API, then transform the results here so # they look (very) like the results from CDDB. Maybe not the best way @@ -4022,6 +4074,13 @@ if [ "$DOCDDB" = "y" ]; then ;; esac fi + CHOICE=$(checkstatus cddb-choice) + if [ $CHOICE = 0 ] ; then + # We don't have any information at all; try to fall back + # to CD-Text for basic information + vecho "No CDDB information found, trying cdtext from the CD" + do_cdtext + fi fi do_cddbedit diff --git a/changelog b/changelog index db13477..1d73e32 100644 --- a/changelog +++ b/changelog @@ -25,6 +25,9 @@ abcde 2.5.1 UNRELEASED far) and a new vvecho() function for callers to use. * With EXTRAVERBOSE==2 or more, make run_command() print out each command as it's run. (Closes issue 39). + * If we don't find any CDDB or Musicbrainz information for the CD, try + to extract CD-Text information to populate the cddbinfo template. + (Closes issue 41). [ Colin Tuckley ] * replace deprecated egrep with grep -E (Closes issue 24).