Audio-Scrobbler2
view release on metacpan or search on metacpan
# Audio::Scrobbler2
[](https://github.com/Perdolique/Audio-Scrobbler2/actions/workflows/test.yml)
`Audio::Scrobbler2` is a small synchronous client for the Last.fm desktop
authentication flow and track scrobbling API.
## Requirements
- Perl 5.26 or newer
- A Last.fm API key and shared secret
## Installation
```console
cpanm Audio::Scrobbler2
```
## Usage
```perl
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:
```perl
$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:
- `track_scrobble` requires a positive integer Unix timestamp for when
playback started.
- All failures throw exceptions instead of returning `0` or inconsistent
error structures.
The constructor and existing method names are unchanged.
## Development
The test suite uses an in-process fake HTTP client and never calls Last.fm:
```console
( run in 1.467 second using v1.01-cache-2.11-cpan-b16cb0d3907 )