X-Git-Url: https://git.hcoop.net/clinton/abcde.git/blobdiff_plain/7172fbaf157358a6a5788460a2fdbd0bf454bae3..abd11d6a29816703eeb0f1be9524c0d60c07ccb4:/abcde?ds=sidebyside diff --git a/abcde b/abcde index 3d69a30..df4c247 100755 --- a/abcde +++ b/abcde @@ -118,7 +118,7 @@ f_seq_line () done echo else - log error "syntax error while processing track numbers" + log error "syntax error while processing track numbers ($i)" exit 1 fi } @@ -246,6 +246,7 @@ page () # Runs a command, silently if necessary, and updates the status file run_command () { + vvecho "$@" BLURB="$1" shift # See if this is supposed to be silent @@ -2228,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" | tr -d \\r\\n | sed 's~^Track ..: .~~g;'"s~'$~~g")" + 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 @@ -3467,7 +3520,8 @@ else # Range parsing code courtesy of Vincent Ho # Cleaned up to use shell built-ins by Charles Steinkuehler if [ "${1#*[^0-9-]}" != "$1" ]; then - log error "syntax error while processing track numbers" + log error "syntax error while processing track numbers ($1)" + exit 1 else RSTART=${1%%-*} REND=${1##*-} @@ -4021,6 +4075,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