Net-DAAP-Client
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Net/DAAP/Client.pm view on Meta::CPAN
$url = $daap->url($song_or_playlist_id);
$binary_audio_data = $obj->get($song_id);
$binary_audio_data = $obj->get(@song_ids);
$song_id = $obj->save($dir, $song_id);
@song_ids = $obj->get($dir, @song_ids);
$daap->disconnect;
if ($daap->error) {
warn $daap->error; # returns error string
}
=head1 DESCRIPTION
Net::DAAP::Client provides objects representing connections to DAAP
servers. You can fetch databases, playlists, and songs. This module
was written based on a reverse engineering of Apple's iTunes 4 sharing
implementation. As a result, features that iTunes 4 doesn't support
(browsing, searching) aren't supported here.
Each connection object has a destructor, so that you can forget to
C<disconnect> without leaving the server expecting you to call back.
=head2 WARNING
If you store your object in a global variable, Perl can't seem to
disconnect gracefully from the server. Until I figure out why, always
store your object in a lexical (C<my>) variable.
=head1 METHODS
=cut
my $DAAP_Port = 3689;
my @User_Columns = qw( SERVER_HOST SERVER_PORT PASSWORD DEBUG SONG_ATTRIBUTES );
my %Defaults = (
# user-specified
SERVER_HOST => "",
SERVER_PORT => $DAAP_Port,
PASSWORD => "",
DEBUG => 0,
SONG_ATTRIBUTES => [ qw(dmap.itemid dmap.itemname dmap.persistentid
daap.songalbum daap.songartist daap.songformat
daap.songsize) ],
# private
ERROR => "",
CONNECTED => 0,
DATABASE_LIST => undef,
DATABASE => undef,
SONGS => undef,
PLAYLISTS => undef,
VALIDATOR => undef,
);
sub new {
my $class = shift;
my $self = bless { %Defaults } => $class;
if (@_ > 1) {
$self->_init(@_);
} elsif (@_) {
$self->{SERVER_HOST} = shift;
} else {
warn "Why are you calling new with no arguments?";
die "Need to implement get/set for hostname and port";
}
return $self;
}
=head2 * new()
$obj = Net::DAAP::Client->new(OPTNAME => $value, ...);
The allowed options are:
=over 4
=item SERVER_NAME
The hostname or IP address of the server.
=item SERVER_PORT
The port number of the server.
=item PASSWORD
The password to use when authenticating.
=item DEBUG
Print some debugging output
=item SONG_ATTRIBUTES
The attributes to retrieve for a song as an array reference. The
default list is:
[qw( dmap.itemid dmap.itemname dmap.persistentid daap.songalbum
daap.songartist daap.songformat daap.songsize )]
=back
=cut
sub _init {
my $self = shift;
my %opts = @_;
foreach my $key (@User_Columns) {
$self->{$key} = $opts{$key} || $Defaults{$key};
}
}
sub _debug {
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.847 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )