David Shultz > Net-CDDBScan-2.01 > Net::CDDBScan

Download:
Net-CDDBScan-2.01.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 2.01   Source  

NAME ^

Net::CDDBScan - String search interface to CDDB datbase

SYNOPSIS ^

use Net::CDDBScan;

        Grab a list of all songs for Madonna
        $cddb = Net::CDDBScan->new(CONT =>1);
        $songs = $cddb->getsongs("madonna");
        print $songs{$_},'\n' foreach %{$songs};
        $cddb->close();

DESCRIPTION ^

Net::CDDBScan is an interface to the www.cddb.com website; or more specifically to their online search engine for the cddb database. Originally created as a small part of a greater application. This module allows you to take any existing string like "tricky" or "for whom the bell tolls" and get the artist name, all albums from said artist and all songs on ANY album said artist has ever worked on. (Or close enough: This is assuming the cddb database has a record of the given artist/album/song.)

USING Net::CDDBScan ^

1. Creating a Net::CDDBScan object

You first must create a Net::CDDBScan object.

my $cddb = Net::CDDBScan->new()

new() has the following optional parameters:

       DEBUG: Debug has 2 levels, the first level shows all urls, albums
and songs as it finds them. The second level also shows all internal function
calls.  You shouldn't ever need to use level 2 but it's there if you feel
the need.

DEBUG

Level 1: $cddb = Net::CDDBScan->new(DEBUG =>1)

Level 2: $cddb = Net::CDDBScan->new(DEBUG =>2)

Pretty simple I would think. These currently print to stdout, but I may change that to stderr in the future as it would seem easier to redirect to error logs all debug output without also getting the std output you may still want in stdout.

CONT

CONT is used to tell Net::CDDBScan if you want it to continue or not. Default is no since it can take longer then you may desire. If you ask for a list of albums for the band Portishead.

$albums = $cddb->getalbums("portishead");

Net::CDDBScan will retrieve a list of albums, but only one page worth, that is it will only grab 1 html page worth of data (usually 7-9 items). But, if you want Net::CDDBScan to get ALL albums for a band, then you can set CONT as:

$cddb = Net::CDDBScan->new(CONT =>1);

This will cause Net::CDDBScan to continue through all pages gathering albums until none are left. NOTE: This also works for songs, but not for artist (since one entry is enough to tell us who the artist is. This may change in the future as you may want to know all possible artists for a song or album).

2. Getting a list of all albums for a given artist.

getalbums()

NOTE: Must use the CONT contructor option to get 'ALL' albums

$albums = $cddb->getalbums("medusa");

print $albums{$_},'\n' foreach (keys %$albums);

Returns a reference to a hash of album urls and names (The key is the url and the value is the album name). This function also takes any cddb.com url or partial url in the following formats:

http://www.cddb.com/xm/search?f=artist&q=medusa

www.cddb.com/xm/search?f=artist&q=medusa

/xm/search?f=artist&q=medusa

/xm/search?q=medusa

medusa etc... you get the idea.

The reason for taking all these types of urls/strings is based on the internal usage of this function. These formats are not planned to change.

3. Getting a list of all songs for all albums of a given artist.

getsongs()

        $songs = $cddb->getsongs("cocteau twins");
        print $songs{$_},'\n' foreach (keys %$songs);

This function accepts all the url/string formats that getalbums() takes and otherwise acts just like getalbums() including returning a hashref of urls and song names.

4. Determining an Artist name based on an album or song name.

getartist()

"Mezzanine" is the name of a Massive Attach album

$artist = $cddb->getartist("mezzanine");

NOTE: Currently you cannot do:

$artist = $cddb->getartist('less then strangers');

i.e. You cannot use ANY string for an artist search. Sorry, it's a limitation of the cddb.com search engine. I'm currently working on a work-around. You can use any of the cddb url formats listed above.

$songs = $cddb->getsongs('less then strangers');

@urls = key %{$songs};

$artist = $cddb->getartist($urls[0]);

NOTICE ^

Be aware this module is in BETA stage. Some major changes have happened as I said they would. The biggest change is that getalbums() and getsongs() return hashrefs instead of arrayrefs now. Sorry for the change, but this makes room for much more functionality down the road. More changes are expected which will allow much cleaner usage, much more functionality and caching of data to a local cddb database (optional). If you have any comments, suggestions and/or patches you'd like to submit. Please email me at dshultz@redchip.com

AUTHOR ^

Copyright 1998-2000, David J. Shultz All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Address bug reports and comments to: dshultz@redchip.com

BUGS ^

This section intentionally left blank.

SEE ALSO ^

perl(1).

syntax highlighting: