[paranoia] patch for CDDB info

Steve Shah sshah at planetoid.org
Sat Jan 15 02:32:32 PST 2000



Hi Folks,

I wanted cdparanoia to generate the QUERY format for a CDDB query so
that I could use it with cddbcmd and script the process of getting
a complete request from the CDDB. So I added a command line parameter
(-G) to the latest release to do so. The patch is below. It ain't
rocket science, but I hope you find it useful... With the modified 
version of cdparanoia, I can use the following shell script to dump
info on a CD:

#!/bin/sh

SITE=us.cddb.com
CGI="/~cddb/cddb.cgi"

TRKNFO=`cdparanoia -qG`
DISCID=`cddbcmd -m http -h $SITE -c $CGI DISCID $TRKNFO | awk '{print $4}'`
TMP=`cddbcmd -m http -h $SITE -c $CGI CDDB QUERY $DISCID $TRKNFO`
CATEGORY=`echo $TMP | awk '{print $1}'`
DISCCODE=`echo $TMP | awk '{print $2}'`

cddbcmd -m http -h $SITE -c $CGI CDDB READ $CATEGORY $DISCCODE

-Steve

diff -u cdparanoia-III-alpha9.7/main.c cdparanoia-III-alpha9.7-sjs/main.c
--- cdparanoia-III-alpha9.7/main.c      Tue Dec 14 00:18:44 1999
+++ cdparanoia-III-alpha9.7-sjs/main.c  Sat Jan 15 01:58:31 2000
@@ -223,6 +223,24 @@
   report("");
 }
 
+static void gen_cddb_request(cdrom_drive *d) {
+  long audiolen=0;
+  int i;
+
+  printf ("%d ",d->tracks);
+  for (i=1;i<=d->tracks;i++) {
+    if (cdda_track_audiop(d,i)) {
+
+      long sec =  cdda_track_firstsector(d,i);
+      audiolen += cdda_track_lastsector(d,i)-sec+1;
+     
+      printf ("%d ",sec);
+    }
+  }
+  printf ("%d\n",audiolen/75);
+}
+
+
 static void usage(FILE *f){
   fprintf( f,
 VERSION"\n"
@@ -237,6 +255,7 @@
 "                                    stderr (for wrapper scripts)\n"
 "  -V --version                    : print version info and quit\n"
 "  -Q --query                      : autosense drive, query disc and quit\n"
+"  -G --gen-cddb-request           : generate CDDB request and quit\n"
 "  -B --batch                      : 'batch' mode (saves each track to a\n"
 "                                    seperate file.\n"
 "  -s --search-for-drive           : do an exhaustive search for drive\n"
@@ -583,9 +602,10 @@
     memset(dispcache,' ',graph);
 }
 
-const char *optstring = "escCn:o:d:g:S:prRwafvqVQhZzYXWBi:Tt:";
+const char *optstring = "escCn:o:d:g:S:prRwafvqVQhZzYXWBi:Tt:G";
 
 struct option options [] = {
+       {"gen-cddb-request",no_argument,NULL,'G'},
        {"stderr-progress",no_argument,NULL,'e'},
        {"search-for-drive",no_argument,NULL,'s'},
        {"force-cdrom-little-endian",no_argument,NULL,'c'},
@@ -656,6 +676,7 @@
   int output_endian=0; /* -1=host, 0=little, 1=big */
   int query_only=0;
   int batch=0,i;
+  int gen_cddb_req=0;
 
   /* full paranoia, but allow skipping */
   int paranoia_mode=PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP; 
@@ -670,6 +691,9 @@
 
   while((c=getopt_long(argc,argv,optstring,options,&long_option_index))!=EOF){
     switch(c){
+    case 'G':
+      gen_cddb_req=1;
+      break;
     case 'B':
       batch=1;
       break;
@@ -783,7 +807,7 @@
     }
   }
 
-  if(optind>=argc && !query_only){
+  if(optind>=argc && !query_only && !gen_cddb_req){
     if(batch)
       span=NULL;
     else{
@@ -907,6 +931,11 @@
 
   if(force_cdrom_speed!=-1){
     cdda_speed_set(d,force_cdrom_speed);
+  }
+
+  if (gen_cddb_req) { 
+    gen_cddb_request(d);
+    exit(0);
   }
 
   /* Dump the TOC */


-- 
______________________________________________________________________________
Steve Shah (sshah at planetoid.org) | SysAdmin/Coder/Gabbernaut/DJ/Writer/Minister
    http://www.planetoid.org     | We're not dropping out, we're infiltrating.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                   Nothing says christmas like xsnow...

--- >8 ----
List archives:  http://www.xiph.org/archives/
Paranoia homepage: http://www.xiph.org/paranoia/
To unsubscribe from this list, send a message to 'paranoia-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.




More information about the Paranoia mailing list