Audio-Scrobbler2

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

# Audio::Scrobbler2

[![Tests](https://github.com/Perdolique/Audio-Scrobbler2/actions/workflows/test.yml/badge.svg)](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

lib/Audio/Scrobbler2.pm  view on Meta::CPAN


    # Ask the user to authorize the token:
    # https://www.last.fm/api/auth/?api_key=$api_key&token=$api_token
    my $api_session = $scrobbler->auth_getSession;

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

=head1 DESCRIPTION

Audio::Scrobbler2 implements the desktop authentication flow and the two
Last.fm track submission methods needed by a basic scrobbler. Requests use
HTTPS, UTF-8 form encoding, and verified TLS certificates.

All validation, transport, HTTP, JSON, and Last.fm API failures throw an
exception. The module does not retry requests because retrying a submission
could create a duplicate scrobble.

=head1 METHODS

=head2 new

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

Creates a client. Both credentials are required.

=head2 auth_getToken

    my $token = $scrobbler->auth_getToken;

Requests and stores an unauthorized desktop application token.

=head2 auth_getSession

    my $session_key = $scrobbler->auth_getSession;

Exchanges the authorized token for a session key and stores it.

=head2 set_session_key

    $scrobbler->set_session_key($session_key);



( run in 0.978 second using v1.01-cache-2.11-cpan-b16cb0d3907 )