NAME

WebService::LastFM - Simple interfece to Last.FM Webservices API

SYNOPSIS

use WebService::LastFM;

my $lastfm = WebService::LastFM->new(
    username => $username,
    password => $password,
);

# get a sessoin key and stream URL to identify your stream
my $stream_info = $lastfm->get_session($mode);

my $session_key = $stream_info->session;
my $stream_url  = $stream_info->stream_url;

# get the song information you are now listening
my $nowplaying = $lastfm->get_nowplaying;

my $streaming         = $nowplaying->streaming;
my $station           = $nowplaying->station;
my $station_url       = $nowplaying->station_url;
my $stationfeed       = $nowplaying->stationfeed;
my $stationfeed_url   = $nowplaying->stationfeed_url;
my $artist            = $nowplaying->artist;
my $artist_url        = $nowplaying->artist_url;
my $track             = $nowplaying->track;
my $track_url         = $nowplaying->track_url;
my $album             = $nowplaying->album;
my $album_url         = $nowplaying->album_url;
my $albumcover_small  = $nowplaying->albumcover_small;
my $albumcover_medium = $nowplaying->albumcover_medium;
my $albumcover_large  = $nowplaying->albumcover_large;
my $trackduration     = $nowplaying->trackduration;
my $trackprogress     = $nowplaying->trackprogress;
my $radiomode         = $nowplaying->radiomode;
my $recordtoprofile   = $nowplaying->recordtoprofile;

# send a command 
$lastfm->send_command($command);

# change the station
$lastfm->change_station($new_mode);

DESCRIPTION

WebService::LastFM provides you a simple interface to Last.FM Webservices API. It currently supports Last.FM Stream API. See http://www.audioscrobbler.com/development/lastfm-ws.php for details.

METHODS

new(%args)
$lastfm = WebService::LastFM->new(
    username => $username,
    password => $password,
);

Creates and returns a new WebService::LastFM object.

get_session([$mode])
$stream_info = $lastfm->get_session($mode);

Retruns a session key and stream URL as a WebService::LastFM::Session object. Setting optional $mode parameter allows you to start the stream on a particular station. (The default is your own profile radio station)

get_nowplaying
$current_song = $lastfm->get_nowplaying;

Returns a WebService::LastFM::NowPlaying object to retrieve the currently playing song's information.

send_command($command)
$response = $lastfm->send_command($command);

Sends a command to Last.FM Stream API to control currently playing song. The command can be one of 'skip', 'love' or 'ban'.

$response you get after issuing a command will be whether 'OK' or 'FAILED'.

change_station($new_mode)
$response = $lastfm->change_station($new_mode);

Changes the station of your stream. $new_mode can be one of 'personal', 'profile' or 'random'. Making a donation to Last.FM is required to change the mode to 'personal'. See http://www.last.fm/tutorial.php for more details.

$response you get after changing station will be whether 'OK' or 'FAILED'.

ua
$lastfm->ua->timeout(10);

Returns a LWP::UserAgent object. You can set some values to change its propaties. See the documentation of LWP::UserAgent for more details.

CAVEAT

WebService::LastFM is in beta version. Besides, Last.FM Webservices API's spec haven't fixed yet, so the interface it provides may be changed later.

SEE ALSO

AUTHOR

Kentaro Kuribayashi, <kentarok@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Kentaro Kuribayashi

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.