Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

CDDB::Fake
Fake CDDB entries if you have none

CDDB::Fake - Fake CDDB entries if you have none


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 track titles may be optionally followed by trailing TABs (not spaces) and a MM:SS time indicator (which may have a leading space if it's M:SS).

Extra track information can be passed on lines that follow the track title. These lines must start with whitespace, and may not begin with a number. Anything that follows the list of tracks is considered extra disc information. For example:


    Birelli Lagrene / Standards

       1. C'est Si Bon

          Original version

       2. Softly, As in a Morning Sunrise

          Live recording.

          Probably incomplete.

       3. Days of Wine and Roses

      ...

      12. Nuages

    This album was recorded in the Olympia Studios in Paris.

Multiple lines of additional info are concatenated with newlines inbetween. However, if one of the lines contains \n (that's backslash-n), all lines are conctenated using a single whitespace, and the \n's are turned into real newlines.

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
Returns a list of track objects.

id
all_ids
Returns the (fake) id for this disc.

year
genre
submitted_by
processed_by
These methods return empty strings since the information is not available in CDDB::Fake files.

length
This method will return the accumulated length of all the tracks, provided this information is present in the fake file.

extd
Returns the extended disc information, that is everything that follows the list of tracks in the fake file.

as_cddb
Returns the data in the format of a CDDB entry.

Track objects provide the following methods:

artist
The artist, usually the same as the artist of the disc.

number
The track number, starting with 1.

title
The track title.

length
The track length (in seconds).

This will be zero unless a track length was specified in the fake info.

offset
The track offset.

This will be bogus unless track offsets could be estimated using the length information.

extd
This extended track info, if present.


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;

        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

the CDDB::File manpage.


AUTHOR

Johan Vromans <jvromans@squirrel.nl>


COPYRIGHT

This programs is Copyright 2003,2004, 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.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy