NAME

Net::FreeDB2 - FreeDB generic connection class

SYNOPSIS

# 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);
}

DESCRIPTION

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.

Net::FreeDB

FreeDB/CDDB connection factory.

Net::FreeDB2::Connection

Abstract connection

Net::FreeDB2::Connection::HTTP

Concrete connection for the HTTP protocol

Net::FreeDB2::Connection::CDDBP

Concrete connection for the CDDBP protocol

Net::FreeDB2::Entry

A FreeDB/CDDB entry. Can be read/written from/to a FreeDB/CDDB connection or a file.

Net::FreeDB2::Match

Match obtained from a FreeDB/CDDB query comand

Net::FreeDB2::Site

Site obtained from a FreeDB/CDDB sites command

Net::FreeDB2::Response*

Responses from FreeDB/CDDB commands

CONSTRUCTOR

none

METHODS

connection (OPT_HASH_REF || OPT_STRING)

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

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.

client_name

Mandatory option to name the connecting client software.

client_version

Mandatory option with the client software version string.

client_host

The hostname of the client. Defaults to &Sys::Hostname::hostname ().

client_user

The user of the client. Defaults to scalar (getpwuid ($>));

freedb_host

The FreeDB/CDDB host to use (e.g. www.freedb.org). If defined together with freedb_cgi the connection is actually made during costruction.

freedb_port

The port on the FreeDB/CDDB host to use.

freedb_cgi

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

Proxy host to use. Only supported for HTTP protocol. Will not cause error if set for protocol <CDDBP>.

proxy_port

Proxy port to use. Defaults to 8080. Only supported for HTTP protocol. Will not cause error if set for protocol <CDDBP>.

proxy_user

Proxy user name to use. Only supported for HTTP protocol. Will not cause error if set for protocol <CDDBP>.

proxy_passwd

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

SEE ALSO

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

BUGS

None known (yet).

HISTORY

First development: September 2002

AUTHOR

Vincenzo Zocca <Vincenzo@Zocca.com>

COPYRIGHT

Copyright 2002, Vincenzo Zocca.

LICENSE

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

1 POD Error

The following errors were encountered while parsing the POD:

Around line 141:

=over should be: '=over' or '=over positive_number'