From 9ff5088c4fb89c87add2aab3cdc1fa1cc081a1fa Mon Sep 17 00:00:00 2001 From: data Date: Sun, 14 Aug 2005 19:51:29 +0000 Subject: [PATCH 1/1] r103@frost: data | 2005-08-13 04:51:15 +0300 abcde 2.3 branched version changed to 2.3.99 in trunk preparations to add TOC reading from CDROM allowed diffing of CDDB entries once parsed - rewriten the part of the function that asks for user input reordered some options to have them in groups that "make sense" entries in README, man page, config file and debian change log added git-svn-id: http://abcde.googlecode.com/svn/trunk@92 a0fa61bc-5347-0410-a1a9-7f54aa4e1825 --- Makefile | 2 +- README | 7 +++ TODO | 3 -- abcde | 120 +++++++++++++++++++++++++++++++++-------------- abcde.1 | 10 ++++ abcde.conf | 11 +++++ debian/changelog | 8 ++++ 7 files changed, 122 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index f3cc0ce..fa4277f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 2.3.0 +VERSION = 2.3.99 INSTALL = /usr/bin/install -c # Installation directories diff --git a/README b/README index 638ff64..9049a2a 100644 --- a/README +++ b/README @@ -25,6 +25,13 @@ ID3TAGV=1 MAJOR CHANGES ============= +Changes in 2.4: +* Read TOC entries from the CD. The default uses cdrdao. +* Possibility to use CDDBCHOICE1,CDDBCHOICE2 (i.e., 1,3) to get a diff of two + parsed CDDB entries. +* Added SHOWCDDBFIELDS to define wether to show the YEAR and GENRE fields from + the CDDB output. + Changes in 2.3: * Support for mkcue, to create a CUE sheet of the CD structure. It can be used with "-1" to create a backup, so that later on the original CD can be diff --git a/TODO b/TODO index 6152609..cda1d25 100644 --- a/TODO +++ b/TODO @@ -8,9 +8,6 @@ TODO: * move the wav files to a different dir if the user wants to keep the tracks * read the TOC and CDTEXT files and store them -* storing TOC seems a good idea to recreate the index entries if we decide to - burn the cd. - * read_and_encode_and_tag? :) * Customizable post-read/encode/tag hooks (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=114851) diff --git a/abcde b/abcde index 810ab8b..17ebeb1 100755 --- a/abcde +++ b/abcde @@ -11,7 +11,7 @@ # Copyright for this work is to expire January 1, 2010, after which it # shall be public domain. -VERSION="2.3.0" +VERSION="2.3.99" usage () { @@ -48,6 +48,8 @@ echo "-P Use UNIX pipes to read+encode without wav files" echo "-r " echo " Also encode on these remote hosts" echo "-R Add replaygain values to the tag info (only for vorbis,flac)" +echo "-s " +echo " Show dielfs from the CDDB info (year,genre)" echo "-S <#> Set the CD speed" #echo "-t File types to preprocess (wav)" #echo "-T Set postprocessing options" @@ -1328,6 +1330,18 @@ do_cddbparse () vecho "ONETRACK mode selected: displaying only the title of the CD..." fi echo "---- $(grep DTITLE "${CDDBPARSEFILE}" | cut '-d=' -f2- | tr -d \\r\\n ) ----" + if [ X"$SHOWCDDBYEAR" = "Xy" ]; then + PARSEDYEAR=$(grep DYEAR "${CDDBPARSEFILE}" | cut '-d=' -f2-) + if [ X"$PARSEDYEAR" = "X" ]; then + echo "YEAR=$PARSEDYEAR" + fi + fi + if [ X"$SHOWCDDBGENRE" = "Xy" ]; then + PARSEDGENRE=$(grep DGENRE "${CDDBPARSEFILE}" | cut '-d=' -f2-) + if [ X"$PARSEDGENRE" = "X" ]; then + echo "GENRE=$PARSEDGENRE" + fi + fi if [ ! "$ONETRACK" = "y" ]; then for TRACK in $(f_seq_row 1 $TRACKS) do @@ -1604,17 +1618,32 @@ do_cddbedit () cat "$ABCDETEMPDIR/cddbchoices" >&2 fi + CDDBCHOICENUM="" # I'll take CDDB read #3 for $400, Alex - echo -n "Which entry would you like abcde to use (0 for none)? [0-$CDDBCHOICES]: " >&2 - read CDDBCHOICE - [ X"$CDDBCHOICE" = "X" ] && CDDBCHOICE=1 - # Make sure we get a valid choice - CDCHOICENUM=$(echo $CDDBCHOICE | xargs printf %d 2>/dev/null) - while [ $CDCHOICENUM -lt 0 ] || [ $CDCHOICENUM -gt $CDDBCHOICES ]; do - echo "Invalid selection. Please choose a number between 1 and $CDDBCHOICES." >&2 - echo -n "Selection [0-$CDDBCHOICES]: " >&2 + while [ $CDCHOICENUM -lt 0 ] || [ $CDCHOICENUM -gt $CDDBCHOICES ]; do + echo -n "Which entry would you like abcde to use (0 for none)? [0-$CDDBCHOICES]: " >&2 read CDDBCHOICE - CDCHOICENUM=$(echo $CDDBCHOICE | xargs printf %d 2>/dev/null) + [ X"$CDDBCHOICE" = "X" ] && CDDBCHOICE=1 + if echo $CDDBCHOICE | egrep -q "[[:digit:]]+,[[:digit:]]+" ; then + if [ ! X"$DIFF" = "X" ]; then + # We parse the 2 choices to diff, store them in temporary files and diff them. + for PARSECHOICE in $(echo $CDDBCHOICE | tr , \ ); do + do_cddbparse "$ABCDETEMPDIR/cddbread.$PARSECHOICE" > "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE" + done + PARSECHOICE1=$(echo $CDDBCHOICE | cut -d"," -f1) + PARSECHOICE2=$(echo $CDDBCHOICE | cut -d"," -f2) + echo "Showing diff between choices $PARSECHOICE1 and $PARSECHOICE2..." + $DIFF $DIFFOPTS "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE1" "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE2" + else + echo "The diff program was not found in your path. Please choose a number between 0 and $CDDBCHOICES." >&2 + fi + else + if [ $CDCHOICENUM -lt 0 ] || [ $CDCHOICENUM -gt $CDDBCHOICES ]; then + # Make sure we get a valid choice + CDCHOICENUM=$(echo $CDDBCHOICE | xargs printf %d 2>/dev/null) + echo "Invalid selection. Please choose a number between 0 and $CDDBCHOICES." >&2 + fi + fi done if [ "$CDCHOICENUM" = "0" ]; then vecho "Creating empty CDDB template..." @@ -2037,6 +2066,13 @@ CDDBURL="http://freedb.freedb.org/~cddb/cddb.cgi" CDDBSUBMIT=freedb-submit@freedb.org CDDBPROTO=5 HELLOINFO="$(whoami)@$(hostname)" +CDDBCOPYLOCAL="n" +CDDBLOCALDIR="$HOME/.cddb" +CDDBUSELOCAL="n" + +# List of fields we parse and show during the CDDB parsing... +SHOWCDDBFIELDS="year,genre" + INTERACTIVE=y CDROMREADERSYNTAX=cdparanoia ENCODERSYNTAX=default @@ -2068,9 +2104,6 @@ VARIOUSARTISTS=n VARIOUSARTISTSTYLE=forward KEEPWAVS=n PADTRACKS=n -CDDBCOPYLOCAL="n" -CDDBLOCALDIR="$HOME/.cddb" -CDDBUSELOCAL="n" # If using scsi devices, cdda2wav needs a CDROMID, instead of a device node # i.e. CDROMID="1,0,0" @@ -2114,6 +2147,8 @@ NORMALIZE=normalize-audio CDSPEED=eject VORBISGAIN=vorbisgain MKCUE=mkcue +MKTOC=cdrdao +DIFF=diff # Options for programs called from abcde # mp3 @@ -2146,6 +2181,7 @@ NORMALIZEOPTS= CDSPEEDOPTS="-x" CDSPEEDVALUE= MKCUEOPTS= +MKTOCOPTS="" VORBISCOMMENTOPTS="-R" METAFLACOPTS="--no-utf8-convert" @@ -2231,8 +2267,8 @@ if [ "$CDROM" = "" ] ; then fi # Parse command line options -#while getopts 1a:bc:C:d:Dhj:klLnNo:pr:S:t:T:vVx opt ; do -while getopts 1a:A:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do +#while getopts 1a:A:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do +while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:vVxw:W: opt ; do case "$opt" in 1) ONETRACK=y ;; a) ACTIONS="$OPTARG" ;; @@ -2260,7 +2296,7 @@ while getopts 1a:A:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do P) USEPIPES=y ;; r) REMOTEHOSTS="$OPTARG" ;; R) REPLAYGAIN=y ;; - s) STARTTRACKNUMBER="$OPTARG" ;; + s) SHOWCDDBFIELDS="$OPTARG" ;; S) CDSPEEDVALUE="$OPTARG" ;; # t) PREPROCESSFORMATS="$OPTARG" # PREPROCESS=y ;; @@ -2354,25 +2390,15 @@ do esac done -# Sanity checks: +for SHOWCDDBFIELD in $(echo $SHOWCDDBFIELDS | tr , \ ); do + case $SHOWCDDBFIELD in + y*|Y*) SHOWCDDBYEAR="y";; + g*|G*) SHOWCDDBGENRE="y";; + *) ;; + esac +done -# Check the encoding format, if nothing has been configured in the system, from the ones available in the system -if [ X"$OUTPUTTYPE" = "X" ]; then - for DEFAULT_OUTPUT in $( echo "$DEFAULT_OUTPUT_BINARIES" | tr , \ ); do - DEFAULT_OUTPUT_FORMAT="$(echo $DEFAULT_OUTPUT | cut -d ":" -f 1)" - DEFAULT_OUTPUT_BINARY="$(echo $DEFAULT_OUTPUT | cut -d ":" -f 2)" - if which $DEFAULT_OUTPUT_BINARY > /dev/null 2>&1 ; then - OUTPUTTYPE=$DEFAULT_OUTPUT_FORMAT - vecho "No default output type defined. Autoselecting $OUTPUTTYPE..." >&2 - break - fi - done - if [ X"$OUTPUTTYPE" = "X" ]; then - echo "abcde error: no encoder found in the PATH" >&2 - echo "hits: are all dependencies installed? has the \$PATH been modified?" >&2 - exit 1 - fi -fi +# Sanity checks: # At this point a CDROM has to be defined, so we check it exists. if [ X"$CDROM" != "X" ] ; then @@ -2420,6 +2446,24 @@ if [ X"$USEPIPES" = "Xy" ]; then fi fi +# Check the encoding format from the ones available in the system, if nothing has been configured in the system. +if [ X"$OUTPUTTYPE" = "X" ]; then + for DEFAULT_OUTPUT in $( echo "$DEFAULT_OUTPUT_BINARIES" | tr , \ ); do + DEFAULT_OUTPUT_FORMAT="$(echo $DEFAULT_OUTPUT | cut -d ":" -f 1)" + DEFAULT_OUTPUT_BINARY="$(echo $DEFAULT_OUTPUT | cut -d ":" -f 2)" + if [ -x $(which $DEFAULT_OUTPUT_BINARY) ] ; then + OUTPUTTYPE=$DEFAULT_OUTPUT_FORMAT + vecho "No default output type defined. Autoselecting $OUTPUTTYPE..." >&2 + break + fi + done + if [ X"$OUTPUTTYPE" = "X" ]; then + echo "abcde error: no encoder found in the PATH" >&2 + echo "hits: are all dependencies installed? has the \$PATH been modified?" >&2 + exit 1 + fi +fi + # Decide which CDROM reader we're gonna use case "$CDROMREADERSYNTAX" in cdparanoia|debug) @@ -2683,9 +2727,15 @@ CDROMREADER="$CDROMREADER $CDROMREADEROPTS" CDDBTOOL="$CDDBTOOL $CDDBTOOLOPTS" HTTPGET="$HTTPGET $HTTPGETOPTS" +# And last but not least, check if we can diff between files +if [ -x $(which $DIFF) ]; then :; else + vecho "[WAR] Disabling diff since we cannot find it in the \$PATH..." + DIFF="" +fi + # Here it used to say: # One thousand lines in, we can start doing stuff with things -# Well, right now we are at line 2157 ;) +# Well, right now we are at line 2695 ;) # Export needed things so they can be read in this subshell export CDDBTOOL ABCDETEMPDIR TRACKQUEUE LOWDISK EJECTCD EJECT EJECTOPTS diff --git a/abcde.1 b/abcde.1 index c340f51..6d2fae6 100644 --- a/abcde.1 +++ b/abcde.1 @@ -197,6 +197,10 @@ Actually use the stored copies of the CDDB entries. Can be overriden using the "-L" flag (if is CDDBUSELOCAL in "n"). If an entry is found, we always give the choice of retrieving a CDDB entry from the internet. .TP +.B SHOWCDDBFIELDS +Coma-separated list of fields we want to parse during the CDDB parsing. +Defaults to "year,genre". +.TP .B OGGENCODERSYNTAX Specifies the style of encoder to use for the Ogg/Vorbis encoder. Valid options are \'oggenc\' (default for Ogg/Vorbis) and \'vorbize\'. @@ -382,6 +386,12 @@ for the first time, during abcde execution. It can be used to close the CDROM tray, to set its speed (via "setcd" or via "eject", if available) and other preparation actions. The default function is empty. .TP +.B post_read +post_read () is a shell function which is executed after the CDROM is read +(and, if applies, before the CDROM is ejected). It can be used to read a TOC +from the CDROM, or to try to read the DATA areas from the CD (if any exist). +The default function is empty. +.TP .B EJECTCD If set to "y", abcde will call eject(1) to eject the cdrom from the drive after all tracks have been read. diff --git a/abcde.conf b/abcde.conf index df4877c..0022363 100644 --- a/abcde.conf +++ b/abcde.conf @@ -40,6 +40,13 @@ # so they can be reused when ripping CDs. #CDDBUSELOCAL="n" +# List, separated with a coma, the fields we want the parsing function to +# output. Defaults to YEAR and GENRE, for a complete list of fields provided by +# CDDB. +# The fields are not case sensitive. Actually, "y,g" will work as fine as "Y,G" +# or "YEAR, GENRE" +#SHOWPARSEDFIELDS=year,genre + # Specify the style of encoder to use here - # oggenc, vorbize - for OGGENCODERSYNTAX # lame, gogo, bladeenc, l3enc, xingmp3enc, mp3enc - for MP3ENCODERSYNTAX @@ -117,6 +124,8 @@ #CDSPEED=eject #VORBISGAIN=vorbisgain #MKCUE=mkcue +#MKTOC=cdrdao +#DIFF=diff # Options to call programs with: @@ -165,6 +174,8 @@ #CDSPEEDOPTS="-x" #CDSPEEDVALUE="" #MKCUEOPTS="" +#MKTOCOPTS="" +#DIFFOPTS="" #VORBISCOMMENTOPTS="-R" #METAFLACOPTS="--no-utf8-convert" diff --git a/debian/changelog b/debian/changelog index b880764..ae6e75d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +abcde (2.3.99-1) unstable; urgency=low + + * Added diff choice to CDDB entries ("1,4"). + * Added SHOWCDDBFIELDS to allow the user to show YEAR and GENRE in the + parsed CDDB output. + + -- Jesus Climent Sat, 13 Aug 2005 03:26:59 +0300 + abcde (2.3.0-1) unstable; urgency=low * New upstream release! -- 2.20.1