1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
|
diff -Naur CDDB-1.3/CDDB.py CDDB-1.4/CDDB.py
--- CDDB-1.3/CDDB.py 2001-03-10 23:34:03.000000000 +0100
+++ CDDB-1.4/CDDB.py 2003-09-01 01:18:43.000000000 +0200
@@ -5,13 +5,13 @@
# Written 17 Nov 1999 by Ben Gertzfield <che@debian.org>
# This work is released under the GNU GPL, version 2 or later.
-# Release version 1.3
-# CVS ID: $Id: CDDB.py,v 1.7 2001/03/10 22:34:03 che_fox Exp $
+# Release version 1.4
+# CVS ID: $Id: CDDB.py,v 1.8 2003/08/31 23:18:43 che_fox Exp $
import urllib, string, socket, os, struct, re
name = 'CDDB.py'
-version = 1.3
+version = 1.4
if os.environ.has_key('EMAIL'):
(default_user, hostname) = string.split(os.environ['EMAIL'], '@')
@@ -19,7 +19,8 @@
default_user = os.geteuid() or os.environ['USER'] or 'user'
hostname = socket.gethostname() or 'host'
-proto = 4
+# Use protocol version 5 to get DYEAR and DGENRE fields.
+proto = 5
default_server = 'http://freedb.freedb.org/~cddb/cddb.cgi'
def query(track_info, server_url=default_server,
diff -Naur CDDB-1.3/CHANGES CDDB-1.4/CHANGES
--- CDDB-1.3/CHANGES 2001-03-10 23:34:03.000000000 +0100
+++ CDDB-1.4/CHANGES 2003-09-01 01:19:45.000000000 +0200
@@ -1,3 +1,14 @@
+v1.4
+----
+
+Updated FreeDB version field to 5; this allows us to get access to the
+DYEAR and DGENRE fields in disc info from CDDB.read().
+
+Added Mac OS X support to cdrommodule.c; thanks to Andre Beckedorf
+and Jeffrey C. Jacobs.
+
+Changed default Solaris CD-ROM device to /dev/vol/aliases/cdrom0.
+
v1.3
----
diff -Naur CDDB-1.3/DiscID.py CDDB-1.4/DiscID.py
--- CDDB-1.3/DiscID.py 2001-03-10 23:34:03.000000000 +0100
+++ CDDB-1.4/DiscID.py 2003-09-01 01:19:45.000000000 +0200
@@ -9,8 +9,8 @@
# Written 17 Nov 1999 by Ben Gertzfield <che@debian.org>
# This work is released under the GNU GPL, version 2 or later.
-# Release version 1.3
-# CVS ID: $Id: DiscID.py,v 1.9 2001/03/10 22:34:03 che_fox Exp $
+# Release version 1.4
+# CVS ID: $Id: DiscID.py,v 1.10 2003/08/31 23:19:45 che_fox Exp $
import cdrom, sys
diff -Naur CDDB-1.3/README CDDB-1.4/README
--- CDDB-1.3/README 2001-03-10 23:34:03.000000000 +0100
+++ CDDB-1.4/README 2003-09-01 01:19:45.000000000 +0200
@@ -1,7 +1,7 @@
-README for CDDB.py and DiscID.py, version 1.3
+README for CDDB.py and DiscID.py, version 1.4
-Copyright (C) 1999, 2000 Ben Gertzfield <che@debian.org>
---------------------------------------------------------
+Copyright (C) 1999-2003 Ben Gertzfield <che@debian.org>
+-------------------------------------------------------
The dynamic duo of CDDB.py and DiscID.py, along with their side-kick C
module cdrommodule.so, provide an easy way for Python programs to
@@ -27,8 +27,8 @@
-----
-If you are using Python 1.6 or 2.0 on Linux, FreeBSD, OpenBSD, or
-Solaris, installing is simple. As root, run:
+If you are using Python 1.6 or 2.0 or later on Linux, FreeBSD,
+OpenBSD, Mac OS X, or Solaris, installing is simple. As root, run:
# python setup.py install
@@ -39,7 +39,7 @@
-----
If you have an older version of Python installed on Linux, FreeBSD,
-OpenBSD, or Solaris:
+OpenBSD, Mac OS X, or Solaris:
% make -f Makefile.pre.in boot
% make
@@ -97,9 +97,9 @@
This is the default, cross-platform way to open the audio
CD-ROM device. The device defaults to /dev/cdrom on Linux and BSD,
- /dev/vol/alias/cdrom0 on Solaris, and cdaudio under Windows. You
- do not have to use this function to open the audio CD-ROM device,
- but it's a sane default.
+ /dev/disk1 on Mac OS X, /dev/vol/aliases/cdrom0 on Solaris, and
+ cdaudio under Windows. You do not have to use this function to open
+ the audio CD-ROM device, but it's a sane default.
If you want to specify a different device name or flags for opening,
use the following:
@@ -218,8 +218,8 @@
the keys of which follow the keywords returned by the CDDB read
command.
- Dictionary entries that will be of inter
-est:
+ Dictionary entries that will be of interest (note: not all of
+ these keys will always be available for all discs):
info['TTITLE#'] (where # ranges from 1 to the last track on the disc):
The title of track number #. Note that this is not padded on the
@@ -240,6 +240,12 @@
info['revision']
Optional; revision of this CDDB entry
+ info['DYEAR']
+ Optional; year this disc was released
+
+ info['DGENRE']
+ Optional; Genre string describing this disc
+
Note that aside from TTITLE#, most of these fields will be empty
strings for most discs. Also, submitted_via and revision are
technically in the comments returned from the server, so may or
@@ -253,8 +259,8 @@
This is the platform-specific part of the trio. I have included
unix/cdrommodule.c, which implements the necessary functions under
- Linux, FreeBSD, OpenBSD, and Solaris, but the interface is intended to be
- easy enough to implement on any platform.
+ Linux, FreeBSD, OpenBSD, Mac OS X, and Solaris, but the interface is
+ intended to be easy enough to implement on any platform.
If you want to write your own cdrommodule.so for your platform,
here are the functions you'll need to export:
@@ -320,3 +326,6 @@
And thanks to Alexander S . Guy <a7r@andern.org> for the OpenBSD
patch.
+
+ Finally, thanks to Andre Beckedorf and Jeffrey C. Jacobs for the
+ Mac OS X cdrommodule.c port.
diff -Naur CDDB-1.3/cddb-info.py CDDB-1.4/cddb-info.py
--- CDDB-1.3/cddb-info.py 2001-03-10 23:34:03.000000000 +0100
+++ CDDB-1.4/cddb-info.py 2003-09-01 01:19:45.000000000 +0200
@@ -5,7 +5,7 @@
# Written 17 Nov 1999 by Ben Gertzfield <che@debian.org
# This work is released under the GNU GPL, version 2 or later.
-# Release version 1.3
+# Release version 1.4
import DiscID, CDDB, sys, os
diff -Naur CDDB-1.3/setup-win32.py CDDB-1.4/setup-win32.py
--- CDDB-1.3/setup-win32.py 2001-03-10 23:34:03.000000000 +0100
+++ CDDB-1.4/setup-win32.py 2003-09-01 01:19:11.000000000 +0200
@@ -2,17 +2,17 @@
"""Setup script for the CDDB module distribution under Win32."""
-__revision__ = "$Id: setup-win32.py,v 1.1 2001/03/10 22:34:03 che_fox Exp $"
+__revision__ = "$Id: setup-win32.py,v 1.2 2003/08/31 23:19:11 che_fox Exp $"
from distutils.core import setup, Extension
setup (# Distribution meta-data
name = "CDDB",
- version = "1.3",
+ version = "1.4",
description = "Module for retrieving track information about audio CDs from CDDB",
author = "Ben Gertzfield",
author_email = "che@debian.org",
- url = "http://csl.cse.ucsc.edu/~ben/python/",
+ url = "http://cddb-py.sourceforge.net",
# Description of the modules and packages in the distribution
py_modules = ['CDDB', 'DiscID', 'win32/cdrom'],
diff -Naur CDDB-1.3/setup.py CDDB-1.4/setup.py
--- CDDB-1.3/setup.py 2001-03-10 23:34:03.000000000 +0100
+++ CDDB-1.4/setup.py 2003-09-01 01:19:11.000000000 +0200
@@ -2,17 +2,17 @@
"""Setup script for the CDDB module distribution."""
-__revision__ = "$Id: setup.py,v 1.4 2001/03/10 22:34:03 che_fox Exp $"
+__revision__ = "$Id: setup.py,v 1.5 2003/08/31 23:19:11 che_fox Exp $"
from distutils.core import setup, Extension
setup (# Distribution meta-data
name = "CDDB",
- version = "1.3",
+ version = "1.4",
description = "Module for retrieving track information about audio CDs from CDDB",
author = "Ben Gertzfield",
author_email = "che@debian.org",
- url = "http://csl.cse.ucsc.edu/~ben/python/",
+ url = "http://cddb-py.sourceforge.net/",
# Description of the modules and packages in the distribution
py_modules = ['CDDB', 'DiscID'],
diff -Naur CDDB-1.3/unix/cdrommodule.c CDDB-1.4/unix/cdrommodule.c
--- CDDB-1.3/unix/cdrommodule.c 2001-03-10 23:34:03.000000000 +0100
+++ CDDB-1.4/unix/cdrommodule.c 2003-09-01 01:24:30.000000000 +0200
@@ -1,4 +1,4 @@
-/*
+/*
* cdrommodule.c
* Python extension module for reading in audio CD-ROM data
*
@@ -12,12 +12,13 @@
*
* FreeBSD support by Michael Yoon <michael@yoon.org>
* OpenBSD support added by Alexander Guy <alex@andern.org>
+ * Darwin/MacOS X support added by Andre Beckedorf <andre@beckedorf.net>
*
* Thanks to Viktor Fougstedt <viktor@dtek.chalmers.se> for info
* on the <sys/cdio.h> include file to make this work on Solaris!
*
- * Release version 1.2
- * CVS ID: $Id: cdrommodule.c,v 1.5 2001/03/10 22:34:03 che_fox Exp $
+ * Release version 1.4
+ * CVS ID: $Id: cdrommodule.c,v 1.8 2003/08/31 23:24:30 che_fox Exp $
*/
#include "Python.h"
@@ -32,6 +33,12 @@
#include <sys/cdio.h>
#endif
+#if defined(__APPLE__)
+#include <sys/types.h>
+#include <IOKit/storage/IOCDTypes.h>
+#include <IOKit/storage/IOCDMediaBSDClient.h>
+#endif
+
/*
* Since FreeBSD has identical support but different names for lots
* of these structs and constants, we'll just #define CDDB_WHATEVER
@@ -56,20 +63,29 @@
#elif defined(__OpenBSD__)
-#define CDDB_TOC_HEADER_STRUCT ioc_toc_header
-#define CDDB_STARTING_TRACK_FIELD starting_track
+#define CDDB_TOC_HEADER_STRUCT ioc_toc_header
+#define CDDB_STARTING_TRACK_FIELD starting_track
#define CDDB_ENDING_TRACK_FIELD ending_track
-#define CDDB_READ_TOC_HEADER_FLAG CDIOREADTOCHEADER
-#define CDDB_TOC_ENTRY_STRUCT ioc_read_toc_entry
-#define CDDB_TRACK_FIELD starting_track
-#define CDDB_FORMAT_FIELD address_format
-#define CDDB_MSF_FORMAT CD_MSF_FORMAT
-#define CDDB_ADDR_FIELD data->addr
+#define CDDB_READ_TOC_HEADER_FLAG CDIOREADTOCHEADER
+#define CDDB_TOC_ENTRY_STRUCT ioc_read_toc_entry
+#define CDDB_TRACK_FIELD starting_track
+#define CDDB_FORMAT_FIELD address_format
+#define CDDB_MSF_FORMAT CD_MSF_FORMAT
+#define CDDB_ADDR_FIELD data->addr
#define CDDB_READ_TOC_ENTRY_FLAG CDIOREADTOCENTRIES
-#define CDDB_CDROM_LEADOUT 0xaa
+#define CDDB_CDROM_LEADOUT 0xaa
#define CDDB_DEFAULT_CDROM_DEVICE "/dev/cdrom"
#define CDDB_DEFAULT_CDROM_FLAGS 0
+#elif defined (__APPLE__) /* Darwin and MacOS X */
+
+#define CDDB_TOC_HEADER_STRUCT CDDiscInfo
+#define CDDB_STARTING_TRACK_FIELD numberOfFirstTrack
+#define CDDB_ENDING_TRACK_FIELD lastTrackNumberInLastSessionLSB
+#define CDDB_TOC_ENTRY_STRUCT CDTrackInfo
+#define CDDB_DEFAULT_CDROM_DEVICE "/dev/disk1"
+#define CDDB_DEFAULT_CDROM_FLAGS O_RDONLY | O_NONBLOCK
+
#else /* Linux and Solaris */
#define CDDB_TOC_HEADER_STRUCT cdrom_tochdr
@@ -85,7 +101,7 @@
#define CDDB_CDROM_LEADOUT CDROM_LEADOUT
#ifdef sun
-#define CDDB_DEFAULT_CDROM_DEVICE "/dev/vol/alias/cdrom0"
+#define CDDB_DEFAULT_CDROM_DEVICE "/dev/vol/aliases/cdrom0"
#else
#define CDDB_DEFAULT_CDROM_DEVICE "/dev/cdrom"
#endif /* sun */
@@ -99,6 +115,10 @@
static PyObject *cdrom_toc_header(PyObject *self, PyObject *args)
{
struct CDDB_TOC_HEADER_STRUCT hdr;
+#if defined(__APPLE__)
+ dk_cd_read_disc_info_t discInfoParams;
+#endif
+
PyObject *cdrom_fileobj;
int cdrom_fd;
@@ -107,7 +127,15 @@
cdrom_fd = fileno(PyFile_AsFile(cdrom_fileobj));
+#if defined(__APPLE__)
+ memset(&discInfoParams, 0, sizeof(discInfoParams));
+ discInfoParams.buffer = &hdr;
+ discInfoParams.bufferLength = sizeof(hdr);
+
+ if (ioctl(cdrom_fd, DKIOCCDREADDISCINFO, &discInfoParams) < 0) {
+#else /* not defined(__APPLE__) */
if (ioctl(cdrom_fd, CDDB_READ_TOC_HEADER_FLAG, &hdr) < 0) {
+#endif
PyErr_SetFromErrno(cdrom_error);
return NULL;
}
@@ -125,6 +153,9 @@
#if defined(__OpenBSD__)
struct cd_toc_entry data;
+#elif defined(__APPLE__)
+ dk_cd_read_track_info_t trackInfoParams;
+ CDMSF trackMSF;
#endif
if (!PyArg_ParseTuple(args, "O!b", &PyFile_Type, &cdrom_fileobj, &track))
@@ -132,14 +163,32 @@
cdrom_fd = fileno(PyFile_AsFile(cdrom_fileobj));
+#if defined(__APPLE__)
+ memset( &trackInfoParams, 0, sizeof(trackInfoParams));
+ trackInfoParams.addressType = kCDTrackInfoAddressTypeTrackNumber;
+ trackInfoParams.address = track;
+ trackInfoParams.bufferLength = sizeof(entry);
+ trackInfoParams.buffer = &entry;
+
+ if (ioctl(cdrom_fd, DKIOCCDREADTRACKINFO, &trackInfoParams) < 0) {
+ PyErr_SetFromErrno(cdrom_error);
+ return NULL;
+ }
+
+ trackMSF = CDConvertLBAToMSF(entry.trackStartAddress);
+
+ return Py_BuildValue("bbb", trackMSF.minute,
+ trackMSF.second,
+ trackMSF.frame);
+#else /* not defined(__APPLE__) */
entry.CDDB_TRACK_FIELD = track;
entry.CDDB_FORMAT_FIELD = CDDB_MSF_FORMAT;
-
+
#if defined(__OpenBSD__)
entry.data = &data;
entry.data_len = sizeof(data);
#endif
-
+
if (ioctl(cdrom_fd, CDDB_READ_TOC_ENTRY_FLAG, &entry) < 0) {
PyErr_SetFromErrno(cdrom_error);
return NULL;
@@ -148,6 +197,7 @@
return Py_BuildValue("bbb", entry.CDDB_ADDR_FIELD.msf.minute,
entry.CDDB_ADDR_FIELD.msf.second,
entry.CDDB_ADDR_FIELD.msf.frame);
+#endif
}
static PyObject *cdrom_leadout(PyObject *self, PyObject *args)
@@ -158,6 +208,11 @@
#if defined(__OpenBSD__)
struct cd_toc_entry data;
+#elif defined(__APPLE__)
+ struct CDDB_TOC_HEADER_STRUCT hdr;
+ dk_cd_read_disc_info_t discInfoParams;
+ dk_cd_read_track_info_t trackInfoParams;
+ CDMSF trackMSF;
#endif
if (!PyArg_ParseTuple(args, "O!", &PyFile_Type, &cdrom_fileobj))
@@ -165,6 +220,33 @@
cdrom_fd = fileno(PyFile_AsFile(cdrom_fileobj));
+#if defined(__APPLE__)
+ memset(&discInfoParams, 0, sizeof(discInfoParams));
+ discInfoParams.buffer = &hdr;
+ discInfoParams.bufferLength = sizeof(hdr);
+
+ if (ioctl(cdrom_fd, DKIOCCDREADDISCINFO, &discInfoParams) < 0) {
+ PyErr_SetFromErrno(cdrom_error);
+ return NULL;
+ }
+
+ memset(&trackInfoParams, 0, sizeof(trackInfoParams));
+ trackInfoParams.addressType = kCDTrackInfoAddressTypeTrackNumber;
+ trackInfoParams.address = hdr.CDDB_ENDING_TRACK_FIELD;
+ trackInfoParams.bufferLength = sizeof(entry);
+ trackInfoParams.buffer = &entry;
+
+ if (ioctl(cdrom_fd, DKIOCCDREADTRACKINFO, &trackInfoParams) < 0) {
+ PyErr_SetFromErrno(cdrom_error);
+ return NULL;
+ }
+
+ trackMSF = CDConvertLBAToMSF(entry.trackStartAddress + entry.trackSize + 1);
+
+ return Py_BuildValue("bbb", trackMSF.minute,
+ trackMSF.second,
+ trackMSF.frame);
+#else /* not defined(__APPLE__) */
entry.CDDB_TRACK_FIELD = CDDB_CDROM_LEADOUT;
entry.CDDB_FORMAT_FIELD = CDDB_MSF_FORMAT;
@@ -181,6 +263,7 @@
return Py_BuildValue("bbb", entry.CDDB_ADDR_FIELD.msf.minute,
entry.CDDB_ADDR_FIELD.msf.second,
entry.CDDB_ADDR_FIELD.msf.frame);
+#endif
}
int cdrom_close(FILE *cdrom_file)
@@ -206,7 +289,7 @@
PyErr_SetFromErrno(cdrom_error);
return NULL;
}
-
+
cdrom_file = fdopen(cdrom_fd, "r");
if (cdrom_file == NULL) {
|