Audio::Scrobbler2

Tests

Audio::Scrobbler2 is a small synchronous client for the Last.fm desktop authentication flow and track scrobbling API.

Requirements

Installation

cpanm Audio::Scrobbler2

Usage

use Audio::Scrobbler2;

my $scrobbler = Audio::Scrobbler2->new($api_key, $api_secret);
my $token = $scrobbler->auth_getToken;

# Ask the user to authorize the token:
# https://www.last.fm/api/auth/?api_key=$api_key&token=$token

my $session_key = $scrobbler->auth_getSession;

$scrobbler->track_updateNowPlaying('Artist Name', 'Track Name');
$scrobbler->track_scrobble(
    'Artist Name',
    'Track Name',
    $playback_started_at,
);

An existing session key can be restored without repeating authentication:

$scrobbler->set_session_key($session_key);

All validation, transport, HTTP, JSON, and Last.fm API failures throw exceptions. Submission requests are never retried automatically because a retry could create a duplicate scrobble.

Migrating from 0.05

Version 1.00 contains two breaking changes:

The constructor and existing method names are unchanged.

Development

The test suite uses an in-process fake HTTP client and never calls Last.fm:

perl Makefile.PL
make test
make disttest

Author

Pier Dolique (Perdolique), baget@cpan.org

CPAN ID: BAGET

License

Copyright 2012-2026 Pier Dolique.

This software is available under the same terms as Perl itself.