The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CDDB.pm - a high-level interface to cddb protocol servers (freedb and CDDB)

VERSION

version 1.222

SYNOPSIS

use CDDB;

### Connect to the cddbp server.
my $cddbp = new CDDB(
  Host  => 'freedb.freedb.org', # default
  Port  => 8880,                # default
  Login => $login_id,           # defaults to %ENV's
) or die $!;

### Retrieve known genres.
my @genres = $cddbp->get_genres();

### Calculate cddbp ID based on MSF info.
my @toc = (
  '1    0  2 37',           # track, CD-i MSF (space-delimited)
  '999  1 38 17',           # lead-out track MSF
  '1000 0  0 Error!',       # error track (don't include if ok)
);
my (
  $cddbp_id,      # used for further cddbp queries
  $track_numbers, # padded with 0's (for convenience)
  $track_lengths, # length of each track, in MM:SS format
  $track_offsets, # absolute offsets (used for further cddbp queries)
  $total_seconds  # total play time, in seconds (for cddbp queries)
 ) = $cddbp->calculate_id(@toc);

### Query discs based on cddbp ID and other information.
my @discs = $cddbp->get_discs($cddbp_id, $track_offsets, $total_seconds);
foreach my $disc (@discs) {
  my ($genre, $cddbp_id, $title) = @$disc;
}

### Query disc details (usually done with get_discs() information).
my $disc_info     = $cddbp->get_disc_details($genre, $cddbp_id);
my $disc_time     = $disc_info->{'disc length'};
my $disc_id       = $disc_info->{discid};
my $disc_title    = $disc_info->{dtitle};
my @track_offsets = @{$disc_info->{offsets}};
my @track_seconds = @{$disc_info->{seconds}};
my @track_titles  = @{$disc_info->{ttitles}};
# other information may be returned... explore!

### Submit a disc via e-mail. (Requires MailTools)

die "can't submit a disc (no mail modules; see README)"
  unless $cddbp->can_submit_disc();

# These are useful for prompting the user to fix defaults:
print "I will send mail through: ", $cddbp->get_mail_host(), "\n";
print "I assume your e-mail address is: ", $cddbp->get_mail_address(), "\n";

# Actually submit a disc record.
$cddbp->submit_disc(
  Genre       => 'classical',
  Id          => 'b811a20c',
  Artist      => 'Various',
  DiscTitle   => 'Cartoon Classics',
  Offsets     => $disc_info->{offsets},   # array reference
  TrackTitles => $disc_info->{ttitles},   # array reference
  From        => 'login@host.domain.etc', # will try to determine
);

DESCRIPTION

CDDB protocol (cddbp) servers provide compact disc information for programs that need it. This allows such programs to display disc and track titles automatically, and it provides extended information like liner notes and lyrics.

This module provides a high-level Perl interface to cddbp servers. With it, a Perl program can identify and possibly gather details about a CD based on its "table of contents" (the disc's track times and offsets).

Disc details have been useful for generating CD catalogs, naming mp3 files, printing CD liners, or even just playing discs in an automated jukebox.

Despite the module's name, it connects to FreeDB servers by default. This began at version 1.04, when cddb.com changed its licensing model to support end-user applications, not third-party libraries. Connections to cddb.com may still work, and patches are welcome to maintain that functionality, but it's no longer officially supported.

PUBLIC METHODS

PRIVATE METHODS

Documented as being not documented.

EXAMPLES

Please see the cddb.t program in the t (tests) directory. It exercises every aspect of CDDB.pm, including submissions.

COMPATIBILITY

CDDB.pm uses standard Perl modules. It has been tested at one point or another on OS/2, MacOS and FreeBSD systems, as well as the systems listed at:

http://testers.cpan.org/search?request=dist&dist=CDDB

If you want to submit disc information to the CDDB, you will need to install two other modules:

Mail::Internet will allow CDDB.pm to send email submissions, and it
automagically includes Mail::Header.

MIME::QuotedPrint will allow CDDB.pm to send non-ASCII text
unscathed.  Currently only ISO-8859-1 and ASCII are supported.

All other features will work without these modules.

KNOWN TEST FAILURES

The last test in the "make test" suite will try to send a sample submission to the CDDB if MailTools is present. It expects to find an SMTP host in the SMTPHOST environment variable. It will fall back to "mail" if SMTPHOST doesn't exist. If neither works, the test will be skipped. To see why it's skipped:

make test TEST_VERBOSE=1

Some of the tests (most notably numbers 25, 27 and 29) compare data returned by a cddbp server against a stored copy of a previous query. These tests fail occasionally since the database is constantly in flux. Starting with version 1.00, the test program uses fuzzy comparisons that should fail less. Version 1.04 saw even fuzzier comparisons. Please report any problems so they can be fixed.

LINKS

BUG TRACKER

https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=CDDB

REPOSITORY

http://github.com/rcaputo/cddb-perl http://gitorious.org/cddb-freedb-perl

OTHER RESOURCES

http://search.cpan.org/dist/CDDB/

CONTACT AND COPYRIGHT

Copyright 1998-2013 Rocco Caputo. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.