
Net::FreeDB2 - FreeDB generic connection class

# quick and dirty CD ripper
use strict;
# Make device name
use Getopt::Std;
$::opt_d = '';
getopts ('d:');
my $dev = $::opt_d || '/dev/cdrom';
# Make a Net::FreeDB2::connection
use Net::FreeDB2;
my $conn = Net::FreeDB2->connection ({
client_name => 'quickrip',
client_version => '1.0',
});
# Create a Net::FreeDB2::Entry object with the information in it from the CD
# in $dev
use Net::FreeDB2::Entry;
my $entry = Net::FreeDB2::Entry->new ({dev => $dev});
# Query the FreeDB/CDDB database
my $res = $conn->query ($entry);
$res->hasError () && die ('Oops, error quering FreeDB');
# Check for matches
if (! scalar ($res->getMatches ())) {
warn ('No matches found');
exit (0);
}
# Get the first match
my $match = ($res->getMatches ())[0];
# Read the match into an entry
my $res = $conn->read ($match);
$res->hasError () && die ('Oops, error reading FreeDB');
my $entry = $res->getEntry ();
# Make cdparanoia commands to rip the tracks
my $tracks = scalar ($entry->getFrameOffset ());
my @cmd = qw (cdparanoia);
push (@cmd, '-d', $dev);
push (@cmd, '-B');
for (my $i = 1; $i <= $tracks; $i++) {
my $title = $entry->getTtitlen ($i);
$title =~ s/\s+/-/g;
my @cmd = (@cmd, $i);
# Execute command
print STDERR "@cmd\n";
system (@cmd);
die ('Oops, command failed') if ($?>>8);
# Rename output file
my $src = sprintf ("track%02d.cdda.wav", $i);
my $dest = sprintf ("%02d-%s.wav", $i, $title);
print STDERR "mv $src $dest\n";
rename ($src, $dest);
}

Net::FreeDB2 is another FreeDB/CDDB access class hierarchy. The basics are similar to the other FreeDB/CDDB Perl modules.
However, in the writers opinion, the details differ enough for it to have a certain right of existance. It's organization is inspired by Net::LDAP.
FreeDB/CDDB connection factory.
Abstract connection
Concrete connection for the HTTP protocol
Concrete connection for the CDDBP protocol
A FreeDB/CDDB entry. Can be read/written from/to a FreeDB/CDDB connection or a file.
Match obtained from a FreeDB/CDDB query comand
Site obtained from a FreeDB/CDDB sites command
Responses from FreeDB/CDDB commands

none

Returns an instanciated Net::FreeDB2::Connection object. Error::Simple exceptions generated by instanciated classes are passed through.
Allowed/mandatory options for OPT_HASH_REF are:
Protocol to use. Allowed vaulues: HTTP and CDDBP. Defaults to HTTP. HTTP causes a Net::FreeDB2::Connection::HTTP object to be instanciated. CDDBP causes a Net::FreeDB2::Connection::CDDBP object to be instanciated.
Mandatory option to name the connecting client software.
Mandatory option with the client software version string.
The hostname of the client. Defaults to &Sys::Hostname::hostname ().
The user of the client. Defaults to scalar (getpwuid ($>));
The FreeDB/CDDB host to use (e.g. www.freedb.org). If defined together with freedb_cgi the connection is actually made during costruction.
The port on the FreeDB/CDDB host to use.
The FreeDB/CDDB host to use (e.g. ~cddb/cddb.cgi). If defined together with freedb_host the connection is actually made during costruction. Only for HTTP protocol. Will not cause error if set for protocol <CDDBP>.
Proxy host to use. Only supported for HTTP protocol. Will not cause error if set for protocol <CDDBP>.
Proxy port to use. Defaults to 8080. Only supported for HTTP protocol. Will not cause error if set for protocol <CDDBP>.
Proxy user name to use. Only supported for HTTP protocol. Will not cause error if set for protocol <CDDBP>.
Proxy password to use. Only supported for HTTP protocol. Will not cause error if set for protocol <CDDBP>.
Options are allowed to be passed as strings. In this case, OPT_STRING must be in the format: <attribute1>=<value1>;<attribute2>=<value2>;... Example: client_name=my-client;client_version=0.0.1

Net::FreeDB2::Entry, Net::FreeDB2::Match, Net::FreeDB2::Response, Net::FreeDB2::Response::Query and Net::FreeDB2::Response::Read

None known (yet).

First development: September 2002

Vincenzo Zocca <Vincenzo@Zocca.com>

Copyright 2002, Vincenzo Zocca.

This file is part of the Net::FreeDB2 module hierarchy for Perl by Vincenzo Zocca.
The Net::FreeDB2 module hierarchy is free software; you can redistribute it and/or modify it under the terms of 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.
The Net::FreeDB2 module hierarchy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the Net::FreeDB2 module hierarchy; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA