X-Git-Url: https://git.hcoop.net/clinton/abcde.git/blobdiff_plain/9ad72a6236f5515fe1c67b468e38554851cda495..abd11d6a29816703eeb0f1be9524c0d60c07ccb4:/abcde diff --git a/abcde b/abcde index 31f9c48..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 @@ -2974,10 +3027,23 @@ do_cdspeed () # vecho [message] # -# vecho outputs a message if EXTRAVERBOSE is selected +# vecho outputs a message if EXTRAVERBOSE is 1 or more vecho () { -if [ x"$EXTRAVERBOSE" != "x" ]; then +if [ x"$EXTRAVERBOSE" != "x" ] && [ $EXTRAVERBOSE -gt 0 ] ; then + case $1 in + warning) shift ; log warning "$@" ;; + *) echo "$@" ;; + esac +fi +} + +# vvecho [message] +# +# vvecho outputs a message if EXTRAVERBOSE is 2 or more +vvecho () +{ +if [ x"$EXTRAVERBOSE" != "x" ] && [ $EXTRAVERBOSE -gt 1 ] ; then case $1 in warning) shift ; log warning "$@" ;; *) echo "$@" ;; @@ -3302,9 +3368,21 @@ if [ "$CDROM" = "" ] ; then CDROM=/dev/acd0c elif [ -e /dev/disk1 ]; then CDROM=/dev/disk1 + elif [ "$OSFLAVOUR" = "OSX" ] && [[ $(diskutil list) =~ CD_part.*(disk.)$'\n' ]]; then + CDROM=/dev/${BASH_REMATCH[1]} fi fi +# We used to use EXTRAVERBOSE=y to turn on more debug output. Now +# that's changed to a number to allow for more control. If +# EXTRAVERBOSE=y, set it to 1 for backwards compatibility. +if [ "$EXTRAVERBOSE" = "y" ]; then + EXTRAVERBOSE=1 +fi +if [ "$EXTRAVERBOSE" = "n" ]; then + EXTRAVERBOSE=0 +fi + # Parse command line options #while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPq:r:Rs:S:t:T:vVxw:W: opt ; do while getopts 1a:bBc:C:d:Defghj:klLmMnNo:pPq:r:s:S:t:T:UvVxX:w:W:z opt ; do @@ -3349,7 +3427,7 @@ while getopts 1a:bBc:C:d:Defghj:klLmMnNo:pPq:r:s:S:t:T:UvVxX:w:W:z opt ; do echo "abcde -h for extra help" exit ;; - V) EXTRAVERBOSE="y" ;; + V) EXTRAVERBOSE=$(($EXTRAVERBOSE + 1)) ;; x) EJECTCD="y" ;; X) CUE2DISCID="$OPTARG" ;; w) COMMENT="$OPTARG" ;; @@ -3442,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##*-} @@ -3910,7 +3989,7 @@ fi # Make sure a buncha things exist for X in $CDROMREADER $CDDISCID ${NEEDTAGGER+$TAGGER} $MP3ENCODER \ $OGGENCODER $FLACENCODER $SPEEXENCODER $MPPENCODER \ - $AACENCODER \ + $AACENCODER $CDDBTOOL \ ${NEEDATOMICPARSLEY+$ATOMICPARSLEY} \ ${NEEDHTTPGET+$HTTPGET} ${NEEDDISTMP3+$DISTMP3} \ ${NEEDCOMMENTER+$VORBISCOMMENT} ${NEEDMETAFLAC+$METAFLAC} \ @@ -3996,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