NAME
CDDB::Fake - Fake CDDB entries if you have none
SYNOPSIS
use CDDB::Fake;
my $cddb = CDDB::Fake->new("music/Egg/Egg/.nocddb");
print "Artist: ", $cddb->artist, "\n";
foreach my $track ( $cddb->tracks ) {
print "Track ", $track->number, ": ", $track->title, "\n";
}
DESCRIPTION
Sometimes there's no CDDB file available for a piece of music. For example, when you created a collection of tracks from other albums. In this case, a text file containing the name of the artist / album, followed by a mere list of the track titles can be used as a fall-back.
CDDB::Fake implements a part of the CDDB::File API based on manually crafted fall-back files.
I've adopted the convention to name files with CDDB data .cddb
, and the fake data .nocddb
.
For example, you can cut the results of a search at Gracenote (cddb.com) and paste it into the file .nocddb. For example:
Birelli Lagrene / Standards
1. C'est Si Bon
2. Softly, As in a Morning Sunrise
3. Days of Wine and Roses
...
12. Nuages
The titles may be optionally followed by trailing TABs and a MM:SS time indicator.
A tool is included to generate a fake file from the names of the files in the directory.
WARNING: CDDB::Fake implements only a part of the CDDB::File API.
METHODS
- new file
-
The new() package method takes the name of a file, and parses it. A CDDB::Fake object is then created from the file data.
- artist
-
Returns the name of the artist.
- title
-
Returns the name of the album.
- track_count
-
Returns the number of tracks.
- tracks
-
In list context: returns a list of track objects. In scalar context: returns a reference to this list.
- id
-
Returns the (fake) id for this disc.
- year
- genre
- length
-
These methods return undef since the information is not available in CDDB::Fake files.
- extd
-
Returns the extended disc information, that is everything that follows the list of tracks n the fake file.
Track objects provide the following methods:
- number
-
The track number.
- title
-
The track title.
- length
-
The track length (in seconds).
EXAMPLES
It is often handy to generalize the handling of real and fake files:
use CDDB::File; # the real one
use CDDB::Fake; # the fake one
use Carp;
# Return a CDDB::File object if a .cddb file is present, otherwise
# return a CDDB::Fake onkect from a .nocddb file, if present.
sub cddb_info($) {
my $df = shift;
Carp::croak("cddb_info(dir)\n") unless -d $df;
return CDDB::File->new("$df/.cddb") if -s "$df/.cddb";
return CDDB::Fake->new("$df/.nocddb") if -s "$df/.nocddb";
undef;
}
SEE ALSO
AUTHOR
Johan Vromans <jvromans@squirrel.nl>
COPYRIGHT
This programs is Copyright 2003, Squirrel Consultancy.
This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License or the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 238:
You forgot a '=back' before '=head1'