Анатолий Шарифулин > Net-LastFM-Submission > Net::LastFM::Submission

Download:
Net-LastFM-Submission.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.1   Source   Latest Release: Net-LastFM-Submission-0.64

NAME ^

Net::LastFM::Submission - simple Perl interface to the Last.fm Submissions Protocol (v1.2.1)

SYNOPSIS ^

        use Net::LastFM::Submission;
        
        my $submit = Net::LastFM::Submission->new(
                'user'      => 'XXX',
                'password'  => 'YYY',
        );
        
        $submit->handshake;
        
        $submit->submit(
                'artist' => 'Artist name',
                'title'  => 'Track title',
                'time'   => time - 10*60, # 10 minutes ago
        );
        
        $submit->now_playing(
                'artist' => 'Artist name',
                'title'  => 'Track title',
        );

DESCRIPTION ^

The module provides a simple Perl interface to the Last.fm Submissions Protocol (current version is 1.2.1).

The Last.fm Submissions Protocol is designed for the submission of now-playing and recent historical track data to Last.fm user profiles (aka 'Scrobbling').

http://www.lastfm.ru/api/submissions

METHODS ^

new(%args)

This is a constructor for Net::LastFM::Submission object. It takes list of parameters or hashref parameter.

        # list
        my $submit = Net::LastFM::Submission->new(
                'user'     => 'XXX',
                'password' => 'YYY',
        );
        
        # hashref
        my $submit = Net::LastFM::Submission->new({
                'user'     => 'XXX',
                'password' => 'YYY',
        });

This is a list of support parameters:

  • user

    The name of the Last.FM user. Required.

  • password

    The password of the Last.FM user. Required for Standard authentication only. It is used for generate authentication token, see section 1.2 http://www.lastfm.ru/api/submissions#1.2.

  • api_key

    The API key from your Web Services account. Required for Web Services authentication only.

  • api_secret

    The API secret from your Web Services account. Required for Web Services authentication only. It is used for generate authentication token, see section 1.3 http://www.lastfm.ru/api/submissions#1.3.

  • secret_key

    The Web Services session key generated via the authentication protocol. Required for Web Services authentication only.

  • clinet_id

    Is an identifier for the client. Optional. Default value is tst, see section 1.1 http://www.lastfm.ru/api/submissions#1.1.

  • client_ver

    Is the version of the client being used. Optional. Default value is 1.0.

  • ua

    Is an user agent. Optional. Default is LWP::UserAgent with timeout 10 seconds.

  • enc

    Is the encoding of data, module try to encode a data (artist/title/album) unless data is UTF-8. See <Encode>. Optional. Default value is cp1251.

handshake()

The initial negotiation with the submissions server to establish authentication and connection details for the session. See http://www.lastfm.ru/api/submissions#handshake.

        $submit->handshake;

If the handshake was successful, the returned hashref has the format:

        {
                'status' => 'OK',
                'sid'    => 'Session ID', # the scrobble session id, to be used in all following now-playing and submission requests
                'url'    => {
                        'np'  => 'Now-Playing URL',
                        'sm'  => 'Submission URL'
                }
        }

If the handshake was break, the returned hashref has the format:

        {
                'error'  => 'BANNED/BADAUTH/BADTIME/FAILED',
                'code'   => '200/500', # code of status line response
                'reason' => '...'      # reason of error
        }
now_playing(%args)

Optional lightweight notification of now-playing data at the start of the track for realtime information purposes. See http://www.lastfm.ru/api/submissions#np.

It takes list of parameters or hashref parameter.

        # list
        $submit->now_playing(
                'artist' => 'Artist name',
                'title'  => 'Track title',
        );
        
        # hashref
        $submit->now_playing({
                'artist' => 'Artist name',
                'title'  => 'Track title',
        });

This is a list of support parameters:

  • artist

    The artist name. Required.

  • title

    The track name. Required.

  • album

    The album title, or an empty string if not known.

  • length

    The length of the track in seconds, or an empty string if not known.

  • id

    The position of the track on the album, or an empty string if not known.

  • mb_id

    The MusicBrainz Track ID, or an empty string if not known.

  • enc

    Is the encoding of data, module try to encode a data (artist/title/album) unless data is UTF-8. Optional. Default value is parameter enc of self object.

If the notification was successful, the returned hashref has the format:

        {
                'status' => 'OK',
        }

If the notification was break, the returned hashref has the format:

        {
                'error'  => 'ERROR/BADSESSION',
                'code'   => '200/500', # code of status line response
                'reason' => '...'      # reason of error
        }
submit(%args)

Submission of full track data at the end of the track for statistical purposes. See http://www.lastfm.ru/api/submissions#subs.

It takes list of parameters (information about one track) or list of hashref parameters (limit of Last.FM is 50).

        # list
        $submit->submit(
                'artist' => 'Artist name',
                'title'  => 'Track title',
        );
        
        # hashref
        $submit->submit(
                grep { $_->{'source'} = 'R';1 }
                {
                        'artist' => 'Artist name 1',
                        'title'  => 'Track title 1',
                        'time'   => time - 10*60,
                }
                {
                        'artist' => 'Artist name 2',
                        'title'  => 'Track title 2',
                }
        );

This is a list of support parameters:

  • artist

    The artist name. Required.

  • title

    The track name. Required.

  • time

    The time the track started playing, in UNIX timestamp format. Optional. Default value is current time.

  • source

    The source of the track. Optional. Default value is R.

  • rating

    A single character denoting the rating of the track. Empty if not applicable.

  • length

    The length of the track in seconds. Required when the source is P, optional otherwise.

  • album

    The album title, or an empty string if not known.

  • id

    The position of the track on the album, or an empty string if not known.

  • mb_id

    The MusicBrainz Track ID, or an empty string if not known.

  • enc

    Is the encoding of data, module try to encode a data (artist/title/album) unless data is UTF-8. Optional. Default value is parameter enc of self object.

If the submit was successful, the returned hashref has the format:

        {
                'status' => 'OK',
        }

If the submit was break, the returned hashref has the format:

        {
                'error'  => 'ERROR/BADSESSION/FAILED',
                'code'   => '200/500', # code of status line response
                'reason' => '...'      # reason of error
        }

DEBUG MODE ^

Module supports debug mode.

        BEGIN { $ENV{SUBMISSION_DEBUG}++ };
        use Net::LastFM::Submission;

SEE ALSO ^

AUTHOR ^

Anatoly Sharifulin, <sharifulin at gmail.com>

BUGS ^

Please report any bugs or feature requests to bug-net-lastfm-submission at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-LastFM-Submission. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

        perldoc Net::LastFM::Submission

You can also look for information at:

COPYRIGHT & LICENSE ^

Copyright 2009 Anatoly Sharifulin, all rights reserved.

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

syntax highlighting: