FreeDB(3pm)
πΈ NAME πΈ
Net::FreeDB β a Perl interface to freedb server(s) π
Okay bestie, welcome to the User Contributed Perl Documentation entry for FreeDB(3pm). Strap in, we're talking to CD databases. π
β¨ 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 π¦
So Net::FreeDB was inspired by Net::CDDB, and honestly? It was literally designed as a replacement β in-part β by Net::CDDB's own author, Jeremy D. Zawodny. Iconic behaviour, no notes. π
What you get with Net::FreeDB is an oop interface to the freedb server(s), plus some basic cdrom functionality like determining disc ids, track offsets, etc. It's giving "does the CD stuff so you don't have to." π₯
π METHODS π
new(remote_host => $h, remote_port => $p, user => $u, hostname => $hn, timeout => $to)
Constructor: creates a new Net::FreeDB object. β¨
Parameters:
- The first one (the
userparam) β set it to the 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 the freedb server. Defaults to120
new() creates and returns a new Net::FreeDB object that is connected to 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:
- a discid
- the number of tracks
- first track offset
- second track offset... etc.
Query expects $num_trks number of extra params after the first two.
query() returns an array of hashes. The hashes look like:
{
Category => 'newage',
DiscID => 'discid',
Artist => 'artist',
Album => 'title'
}
Sets $obj->error on error.
NOTE: 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 or that you believe the disc to be. The second is the disc id. This may be generated for the current cd in your drive by calling get_local_disc_id()
Sets $obj->error on error.
NOTE: Using an incorrect category will result in either no return or an incorrect return. π Please check the CDDB::File documentation for information on this module.
read() requests a freedb record for the given information and returns a CDDB::File object. π
unlink($server_category_string, $disc_id)
Parameters:
- a server category name
- a valid
disc_id
This will delete the given entry on the server (if you have permission). Bestie, 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:
- a server category name
- a valid
disc_id - a properly formatted array of lines from a cddb file
Returns 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:
- The total number of tracks of the current disc
- An array of the track offsets in seconds
- The total number of seconds of the disc.
Returns a valid disc_id if found, otherwise $obj->error will be set. π
get($filename)
Parameters:
- 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:
- The number of lines per section desired
- (Optional) A date after which statistics should be calculated in the format of
hh[mm[ss[MM[DD[[CC]YY]]]]] - (Optional) Must pass a
start_dateif passing this. A date afterstart_dateat which time statistics to not be calculated in the format ofhh[mm[ss[MM[DD[[CC]YY]]]]] - (Optional) The string
'day'to indicate that statistics should be calcuated for today. - (Optional) A number of days to be calculated, default is
1 - (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: None
Returns 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:
- type is either
sitesormotd - based on param 1, an array of lines, either a list of mirror sites or a new message of the day
Assuming you have permission to do so the server content will be updated. π
Sets $obj->error on error.
quit
Parameters: None
Disconnects from the server. Byeeee ππ
sites()
Parameters: None
sites() returns an array reference of urls that can be used as a new remote_host. πβ¨
stat
Parameters: None
Returns undef on error (and sets $obj->error). Otherwise returns a hashref where 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: None
Tells the server to update the database (if you have permission).
Sets $obj->error on error.
validate($validating_string)
Parameters:
- A string to be validated.
If you have permission, given a string the server will validate the string as valid for use in a write call or not. π
Sets $obj->error on error.
ver
Parameters: None
Returns a string of the server's version. π·οΈ
whom
Parameters: None
If 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 machines, but it's an array index in the number of cdrom drives on windows machines 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 would require 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 π
Okay so, the current version of getdiscid() and getdiscdata() on the Windows platform takes ANY string in a single cdrom configuration and works fine. That is, if you only have 1 cdrom drive, you can pass in ANY string and it will still scan that cdrom drive and return the correct data. If you have more then 1 cdrom drive, giving the correct drive number will return in an accurate return. π
π AUTHOR π
David Shultz <dshultz@cpan.org> Peter Pentchev <roam@ringlet.net>
π CREDITS π
Jeremy D. Zawodny <jzawodn@users.sourceforge.net> Pete Jordon <ramtops@users.sourceforge.net>
π COPYRIGHT π
Copyright (c) 2002, 2014 David Shultz. Copyright (c) 2005, 2006 Peter Pentchev. All rights reserved. This program is free software; you can redistribute it and/or modify if under the same terms as Perl itself.
And that's the whole page, bestie β no cap. π«Ά This lil masterpiece is from perl v5.42.3, dated 2026-08-19, filed under FreeDB(3pm). Go forth and query those discs. π
β¨
π¦ where this page comes from
- ubuntu stonking: libnet-freedb-perl 0.10-5build2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms