NAME
Net::FreeDB - Perl interface to freedb server(s)
SYNOPSIS
use Net::FreeDB;$freedb = Net::FreeDB->new();$discdata = $freedb->getdiscdata('/dev/cdrom');my $cddb_file_object = $freedb->read('rock', $discdata->{ID});print $cddb_file_object->id;
DESCRIPTION
Net::FreeDB was inspired by Net::CDDB. And in-factwas designed as a replacement in-part by Net::CDDB'sauthor Jeremy D. Zawodny. Net::FreeDB allows anoop interface to the freedb server(s) as well assome basic cdrom functionality like determiningdisc ids, track offsets, etc.
METHODS
- new(remote_host => $h, remote_port => $p, user => $u, hostname => $hn, timeout => $to)
-
Constructor:Creates a new Net::FreeDB object.Parameters:Set to username or user-string you'd like to be logged as. Defaults to $ENV{USER}HOSTNAME: (optional)Set to the hostname you'd like to be known as. Defaults to $ENV{HOSTNAME}TIMEOUT: (optional)Set to the number of seconds to timeout on freedb server. Defaults to 120new() creates and returns a new Net::FreeDB object that is connectedto either the given host or gnudb.gnudb.org as default.
- lscat
-
Returns a list of all available categories on the server.Sets $obj->error on error
- query($id, $num_trks, $trk_offset1, $trk_offset2, $trk_offset3...)
-
Parameters:query($$$...) takes:1: a discid2: the number of tracks3: first track offset4: second track offset... etc.Query expects $num_trks number of extra params after the first two.query() returns an array of hashes. The hashes looks like:{Category => 'newage',DiscID => 'discid',Artist => 'artist',Album => 'title'}Sets $obj->error on errorNOTE: query() can return 'inexact' matches and/or 'multiple exact'matches. The returned array is the given returned match(es).
- read($server_category_string, $disc_id)
-
Parameters:read($$) takes 2 parameters, the first being a server category name.This can be any string either that you make up yourself orthat you believe the disc to be. The second is the disc id. Thismay be generated for the current cd in your drive by calling get_local_disc_id()Sets $obj->error on errorNOTE:Using an incorrect category will result in either no return or anincorrect return. Please check the CDDB::File documentation forinformation on this module.read() requests a freedb record for the given information and returns aCDDB::File object.
- unlink($server_category_string, $disc_id)
-
Parameters:1: a server category name2: a valid disc_idThis will delete the given entry on the server (if you have permission).Check the docs for the read() method to get more information on the parameters.Sets $obj->error on error.
- write($server_category_string, $disc_id, $cddb_formatted_data)
-
Parameters:1: a server category name2: a valid disc_id3: a properly formatted array of lines from a cddb fileReturns true on success, otherwise $obj->error will be set.
- discid($number_of_tracks, $track_1_offset, $track_2_offset, ..., $total_number_of_seconds_of_disc)
-
Parameters:1: The total number of tracks of the current disc2: An array of the track offsets in seconds3: The total number of seconds of the disc.Returns a valid disc_id if found, otherwise $obj->error will be set.
- get($filename)
-
Parameters:1: The filename to retrieve from the server.Returns a scalar containing raw file contents. Returns $obj->error on error.
- log($number_of_lines_per_section, start_date, end_date, 'day', $number_of_days, 'get')
-
Parameters:1: The number of lines per section desired2: (Optional) A date after which statistics should be calculated in the format of hh[mm[ss[MM[DD[[CC]YY]]]]]3: (Optional) Must pass a start_date if passing this. A date after start date at which time statisticsto not be calculated in the format of hh[mm[ss[MM[DD[[CC]YY]]]]]4: (Optional) The string 'day' to indicate that statistics should be calcuated for today.5: (Optional) A number of days to be calculated, default is 16: (Optional) The string 'get' which will cause the log data to be recorded on the server's machine.NOTE: You must provide at least one of the optional options (2,3,4).Sets $obj->error on error.
- motd
-
Parameters:NoneReturns the message of the day as a string.Sets $obj->error on error.
- proto($desired_protocol_level)
-
Parameters: (Optional) The desired protocol level as a number.When called with NO parameters, will set the current and maximum allowed procotol levels,when called with a desired protocol level it will be set, $obj->errror will be set if an error occurs.Returns the currently selected protocol level.
- put($type, $file)
-
Parameters:1: type is either sites or motd2: based on param 1, an array of lines, either a list of mirror sitesor a new message of the dayAssuming you have permission to do so the server content will be updated.Sets $obj->error on error.
- quit
-
Parameters:NoneDisconnects from the server.
- sites()
-
Parameters:Nonesites() returns an array reference of urls that can be used asa new remote_host.
- stat
-
Parameters:NoneReturns undef on error (and sets $obj->error). Otherwise returns a hashrefwhere the keys/values are:max proto => <current_level>An integer representing the server's current operating protocol level.gets => <yes | no>The maximum protocol level.updates => <yes | no>Whether or not the client is allowed to initiate a database update.posting => <yes | no>Whether or not the client is allowed to post new entries.quotes => <yes | no>Whether or not quoted arguments are enabled.current users => <num_users>The number of users currently connected to the server.max users => <num_max_users>The number of users that can concurrently connect to the server.strip ext => <yes | no>Whether or not extended data is stripped by the server before presented to the user.Database entries => <num_db_entries>The total number of entries in the database.<category_name => <num_db_entries>The total number of entries in the database by category.
- update
-
Parameters:NoneTells the server to update the database (if you have permission).Sets $obj->error on error.
- validate($validating_string)
-
Parameters:1: A string to be validated.If you have permission, given a string the server will validate the stringas valid for use in a write call or not.Sets $obj->error on error.
- ver
-
Parameters:NoneReturns a string of the server's version.
- whom
-
Parameters:NoneIf you have permission, returns a list of usernames of all connected users.Sets $obj->error on error.
- get_local_disc_id
-
Parameters:getdiscid($) takes the device you want to use.Basically this means '/dev/cdrom' or whatever on linux machinesbut it's an array index in the number of cdrom drives on windowsmachines starting at 0. (Sorry, I may change this at a later time).So, if you have only 1 cdrom drive then getdiscid(0) would work fine.getdiscid() returns the discid of the current disc in the given drive.NOTE: See BUGS
- get_local_disc_data
-
Parameters:getdiscdata($) takes the device you want to use. See getdiscid()for full description.getdiscdata() returns a hash of the given disc data as you wouldrequire for a call to query. The returns hash look like:{ID => 'd00b3d10',NUM_TRKS => '3',TRACKS => ['150','18082','29172'],SECONDS => '2879'}NOTE: A different return type/design may be developed.
BUGS
The current version of getdiscid() and getdiscdata()on the Windows platform takes ANY string in a singlecdrom configuration and works fine. That is if youonly have 1 cdrom drive; you can pass in ANY stringand it will still scan that cdrom drive and returnthe correct data. If you have more then 1 cdrom drivegiving the correct drive number will return in anaccurate return.