Reference

FreeDB(3pm)

Perl extension for accessing the free internet database of CD information

NAME

FreeDB.pm - Perl extension for accessing the free internet database of CD information

SYNOPSIS

  use FreeDB;

  my $cddb = new FreeDB;
  my $success = 0;

  $success = $cddb->fetch;

  if (!$success) {
     print "couldn't fetch cd info\n";
     exit 1;
  }

  print $cddb->artist . "\n";
  print $cddb->title  . "\n\n";

  while ($cddb->next_track) {
     print $cddb->current_track_number_padded, ". ";
     print $cddb->current_track_info;
     print " (", $cddb->current_track_time_in_minutes, ")\n";
  }

  print "\n\n", $cddb->disc_info, "\n";

VERSION

Version 1.0.1

ITERATIVE METHODS

next_track

Tells FreeDB to advance to the next track on the cd. You must call this before calling any of the current_* methods to set FreeDB on the first track. This way you can conveniently use this method in a while loop. Returns the track_number or 0 when you run out of tracks.

current_track_info

Returns the track info for the current track.

current_track_number

Returns the number of the current track. You can give a specific track number to set FreeDB on a particular track.

current_track_number_padded

Returns the number of the current track in 2 digit format. That is, 9 will print as 09 if you call this method.

current_track_extended_info

Returns any extended info that the current track may have in its record.

current_track_detailed_info

Returns all relevant info for the current track-- number, info, extended info, and time in seconds.

current_track_time_in_minutes

Returns the track's length in minutes.

current_track_time_in_seconds

Returns the track's length in seconds.

current_track_offset

CONFIGURATION METHODS

cddb_server

This sets and gets the full URL for the cddb server. $cddb->new() sets this for you, but you can customize it by setting it after you call $cddb->new() and before you call $cddb->fetch().

cdrom_device

The device that corresponds to your cdrom drive (eg /dev/cdrom). )$cddb->new() sets this for you, but you can customize it by setting it after you call $cddb->new() and before you call $cddb->fetch().

cache_directory

The directory where FreeDB will cache fetched records for you (eg ~/.cddb). $cddb->new() sets this for you, but you can customize it by setting it after you call $cddb->new() and before you call $cddb->fetch().

ignore_cache

Set this to a non-zero value if you want to force FreeDB to make a trip to the server and not attempt to load your disc's record from the local cache. $cddb->new() sets this to 0, but you can customize it by setting it after you call $cddb->new() and before you call $cddb->fetch().

proxy_value

$cddb->new() sets this to "", but if you need to go through a proxy, you can customize it by setting it after you call $cddb->new() and before you call $cddb->fetch().

OTHER METHODS

fetch

This is the method that actually goes and gets the record (either from the server or your local cache). It returns 1 on success or 0 on failure. Optionally you can give a cddb entry as argument. It will use this information and consequently does not look at the cdrom device, cache, or cddb server.

create_new

Creates a new

artist

Returns the disc's artist. Big surprise there.

discid

Returns the discid that FreeDB uses as a a filename for your locally cached disc record.

disc_info

Returns info from the EXTD field of the record

title

Returns the disc's title. We're just full of surprises today.

disc_length

Returns the disc's length (running time) in seconds.

total_tracks

Returns the total number of tracks on the disc.

ARRAY ACCESSOR METHODS

These methods return arrays containing all the info for the tracks on the disc. They're listed here in case you want to use them, but you'll probably do best with the current_* methods above as they provide the easiest method for plowing through the tracks on the disc.

track_info

Returns an array containing the track names for all tracks on the disc.

offsets

Returns an array containing the byte offsets (Is that right?) for all tracks on the disc.

extended_track_info

Returns an array containing the extended info for all tracks on the disc.

detailed_track_info

Returns an array containing all the info for all tracks on the disc.

track_lengths

Returns an array containing all the track lengths in seconds for all tracks on the disc.

DESCRIPTION

A Perl module to provide convenient OO access to the free CDDB

THANKS

Thanks to J.I. van Hemert for graciously giving me permission to use the cddb storage and retrieval code from his wonderful program disc-cover (http://www.liacs.nl/~jvhemert/disc-cover), as well as some nice patches to FreeDB.pm . I originally wrote FreeDB.pm for use with my own Free Software cd labelling program called cdlabelgen (http://www.red-bean.com/~bwf/software/cdlabelgen/).

AUTHOR

Design, Code cleanup and objectification/modularization by B. W. Fitzpatrick <[email protected]>. J.I. van Hemert <[email protected]> and Richard Martin wrote the original cddb routines.

LAST MODIFIED

$Id: FreeDB.pm,v 1.16 1999/12/08 13:46:32 bwf Exp $

History