Perl interface to audioscrobbler.com/last.fm
use Audio::Scrobbler;
$scrob = new Audio::Scrobbler(cfg => { ... });
$scrob->handshake(); $scrob->submit(artist => "foo", album => "hello", track => "world", length => 180);
The \*(C`Audio::Scrobbler\*(C' module provides a Perl interface to the track submission \s-1API\s0 of Last.fm's AudioScrobbler - http://www.audioscrobbler.com/. So far, only track submissions are handled; the future plans include access to the various statistics.
The \*(C`Audio::Scrobbler\*(C' class defines the following methods:
Create a new \*(C`Audio::Scrobbler\*(C' object and initialize it with the provided configuration parameters. The parameters themselves are discussed in the description of the handshake and submit methods below.
Retrieves or sets the description of the last error encountered in the operation of this \*(C`Audio::Scrobbler\*(C' object.
Perfors a handshake with the AudioScrobbler \s-1API\s0 via a request to http://post.audioscrobbler.com/. This method requires that the following configuration parameters be set:
The name of the program (or plug-in) performing the AudioScrobbler handshake.
The version of the program (or plug-in).
The username of the user's AudioScrobbler registration.
If the handshake is successful, the method returns a true value, and the submit method may be invoked. Otherwise, an appropriate error message may be retrieved via the err method. If the fake configuration parameter is set, the handshake method does not actually perform the handshake with the AudioScrobbler \s-1API\s0, just simulates a successful handshake and returns a true value. If the verbose configuration parameter is set, the handshake method reports its progress with diagnostic messages to the standard output.
Submits a single track to the AudioScrobbler \s-1API\s0. This method may only be invoked after a successful handshake. The track information is contained in the hash referenced by the info parameter; the following elements are used:
The track's title.
The name of the artist performing the track.
The duration of the track in seconds.
The name of the album (optional).
Also, the submit method requires that the following configuration parameters be set for this \*(C`Audio::Scrobbler\*(C' object:
The username of the user's AudioScrobbler registration.
The password for the AudioScrobbler registration.
If the submission is successful, the method returns a true value. Otherwise, an appropriate error message may be retrieved via the err method. If the fake configuration parameter is set, the submit method does not actually submit the track information to the AudioScrobbler \s-1API\s0, just simulates a successful submission and returns a true value. If the verbose configuration parameter is set, the submit method reports its progress with diagnostic messages to the standard output.
There are also several methods and functions for the module's internal use:
Creates or returns the cached \*(C`LWP::UserAgent\*(C' object used by the \*(C`Audio::Scrobbler\*(C' class for access to the AudioScrobbler \s-1API\s0.
Decode a URL-encoded string. Obtained from http://glennf.com/writing/hexadecimal.url.encoding.html
Return the URL-encoded representation of a string. Obtained from http://glennf.com/writing/hexadecimal.url.encoding.html
Do something with \s-1UPDATE\s0 responses to the handshake.
Honor \s-1INTERVAL\s0 in some way.
Figure out a way to cache unsuccesful submissions for later retrying.
Web services - stats!
scrobbler-helper\|(1)
The home site of the \*(C`Audio::Scrobbler\*(C' module is http://devel.ringlet.net/audio/Audio-Scrobbler/
Peter Pentchev, <[email protected]>
Copyright (C) 2005, 2006 by Peter Pentchev.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.
$Id: Scrobbler.pm 88 2006-01-02 09:16:32Z roam $