Net_CDDB (Constructor) [line 316]
Net_CDDB Net_CDDB(
[string
$protocol = 'cddbp://freedb.org:8880'], [string
$cdreader = 'cddiscid:///dev/acd0'], [array
$option_params = array()])
|
|
Construct a new CDDB object using the given backend/connection parameters
Create a new CDDB object which gives access to CDDB/FreeDB.org servers to allow a user to query the database for information about music CDs. You can use this class to submit discs to the FreeDB.org project or retrieve music CD information such as disc title, artist, track names, etc.
The class uses a driver architecture both for accessing remote CDDB servers and for reading the table of contents off a local CD-ROM drive so that new CDDB and CD-ROM access methods can be easily added in the future.
The class currently offers two different driver protocols to access this the CDDB/FreeDB.org database: CDDBP or HTTP.
- cddbp:// - CDDBP/Telnet style protocol to query database (default)
The class also offers a few different drivers to read the table of contents from the audio-CD in your CD/DVD drive:
- cddiscid:// - Use the Linux/UNIX 'cd-discid' binary
- cdparanoia:// - Use the Linux/UNIX 'cdparanoia' binary
- test:// - Testing class to make sure things work like they should
You may optionally provide an array of options parameters and CD TOC reader parameters to the class which specify options. Here are the valid array keys for each protocol:
For CDDBP:
- persist (defaults to false, set to true to reuse connection for multiple CDDB queries)
- sudo (defaults to false, set to true if you want to execute the callback binary using sudo)
- submit_uri (defaults to /~cddb/submit.cgi)
For HTTP:
- sudo (defaults to false, set to true if you want to execute the callback binary using sudo)
- submit_uri (defaults to /~cddb/submit.cgi)
$params_cddbp = array(
'persist' => true,
);
$cddb = new
Net_CDDB('cddbp://my_username@freedb.org:8880', 'cddiscid:///dev/acd0', $params_cddbp);
//$cddb = new Net_CDDB('http://my_username@freedb.org:80/~cddb/cddb.cgi', 'cddiscid:///dev/acd0');
print("\n\nSearching for the CD in the CD-ROM drive:\n");
Parameters:
calculateDiscId [line 949]
string calculateDiscId(
array
$track_offsets, int
$length, [bool
$query = false])
|
|
Calculate a disc ID based on the track offsets and the disc length
Parameters:
calculateDiscIdForCD [line 733]
string calculateDiscIdForCD(
[string
$device = null])
|
|
Calculate the 8-byte disc id from the CD-ROM drive
Parameters:
calculateLengthForCD [line 782]
integer calculateLengthForCD(
[string
$device = null])
|
|
Calculate the length in seconds of the disc in the CD-ROM drive
Parameters:
calculateTrackOffsetsForCD [line 753]
array calculateTrackOffsetsForCD(
[string
$device = null])
|
|
Calculate the track offsets from the TOC of the disc in the CD-ROM drive
Parameters:
connect [line 398]
Establish connection to CDDB server
You *do not* need to manually call this, the other public methods of this class will ensure a connection is established before querying the database on their own. This is provided as a convience method just in case someone needs it.
debug [line 365]
void debug(
bool
$true_or_false)
|
|
Enables or disables debugging ( prints out all responses/requests )
Parameters:
disconnect [line 414]
Disconnect from CDDB server
getDetails [line 710]
object getDetails(
object
$disc)
|
|
Fill a CDDBDisc object with detailed information about the disc
After searching the CDDB database for discs matching yours by discid and track offsets, you can use this function to get detailed information about one of the CDDBDisc objects. This function will fill and return the CDDBDisc object with information about track offsets, song titles, etc.
Parameters:
getDetailsByDiscId [line 659]
object getDetailsByDiscId(
string
$genre, string
$discid, [
$obj = true])
|
|
Get CD information by genre and disc id value
Searches the CDDB database for a CD matching the given genre and discid and returns a CDDBDisc object containing information for that CD. Returns false if the disc was not found in the database or an error occurs.
Parameters:
getGenres [line 430]
Retrieve list of genre's from CDDB server
help [line 1150]
string help(
[string
$cmd = ''], [string
$subcmd = ''])
|
|
Get protocol help from the CDDB server
Parameters:
motd [line 1164]
Get the message of the day from the CDDB server
searchDatabase [line 849]
object searchDatabase(
array
$track_offsets, integer
$length, [
$obj = true])
|
|
Search and return CDDBDisc objects for CDs matching given length/offsets
Parameters:
searchDatabaseForCD [line 809]
array searchDatabaseForCD(
[string
$device = null])
|
|
Search and return CDDBDisc objects matching the disc in the CD-ROM drive
Parameters:
searchDatabaseWithRawQuery [line 886]
array searchDatabaseWithRawQuery(
string
$query, [
$obj = true])
|
|
Utility method to search for CDDB discs using a raw 'cddb query ...' command
This is provided as a utility method for anyone who might want to search the CDDB database with a raw CDDB query command. It returns an array of CDDBDisc objects which match the query.
// CDDB queries look like this:
// cddb query [discid] [num_tracks] [offset_1] [offset_2] ... [offset_n] [length]
// Replace [discid] with the 8-char discid, [num_tracks] with the number of tracks, [offset_*] with the track offsets, and [length] with the total length of the CD in seconds
$query = "cddb query 50dd30f 15 150 21052 43715 58057 71430 92865 117600 131987 150625 163292 181490 195685 210197 233230 249257 3541";
print_r($cddbsearchDatabaseWithRawQuery($query));
Parameters:
sites [line 1259]
Get a list of CDDB mirrors
statistics [line 1178]
Get CDDB database server statistics
submitDisc [line 993]
bool submitDisc(
object
$obj, [string
$email = null], [bool
$test = false])
|
|
Submit a revised/new Net_CDDB_Disc object to the FreeDB.org database
Note that at this time only submission via HTTP is supported. The only other option is SMTP, which may be supported in the future. This method uses the HTTP_Request class to make the request. I chose to include the HTTP_Request class here instead of globally because most users will use the Net_CDDB package for read-only access to CDDB servers, and thus won't be using this method.
Parameters:
version [line 1289]
Get the CDDB server version string
_createProtocol [line 1093]
object _createProtocol(
$dsn,
$options, string
$type, array
$params)
|
|
Create a protocol instance of the given type with the given parameters
Creates a protocol object instance of a given type by protocol type. The array of connection parameters will be passed directly to the protocol instance.
Parameters:
_createReader [line 1124]
object _createReader(
string
$type, array
$params)
|
|
Create a cd reader instance of a given type with the parameters
Parameters:
_debug [line 379]
void _debug(
string
$msg)
|
|
Prints/logs debugging messages
Parameters:
_parseRecord [line 518]
array _parseRecord(
string
$str)
|
|
Parse a CDDB style database record
Parameters:
_parseResult [line 614]
array _parseResult(
string
$str)
|
|
Parse a result string returned by a CDDB query into an array
Parameters:
_readLine [line 488]
Read a line from the response buffer
_readResponseStatus [line 476]
int _readResponseStatus(
)
|
|
Reads the return status for the last command ( 200, 210, 500, etc. )
_send [line 457]
void _send(
string
$query)
|
|
Send a query to the backend and retrieve the result from the query
Parameters: