Module Lastfm.Audioscrobbler


module Audioscrobbler: sig .. end


Audioscrobbler is the submission protocol as described at

http://www.audioscrobbler.net/development/protocol/

Types



type source =
| User
| Broadcast
| Recommendation
| Lastfm
| Unknown
source of the track

type rating =
| Love
| Ban
| Skip
possible rating for the track

type song = {
   artist : string;
   track : string;
   time : float option;
   source : source option;
   rating : rating option;
   length : float option;
   album : string option;
   trackauth : string option;
   tracknumber : int option;
   musicbrainzid : string option;
}
song submission type

type error =
| Http of string
| Banned
| Badauth
| Badtime
| Failed of string
| UnknownError of string
| Success
| Internal of string
various errors
exception Error of error
val string_of_error : error -> string
Get meaning of Error e

Basic API

Using this API, all requests are done in one single step

val do_np : Lastfm.client -> Lastfm.login -> song -> unit
do_np client login song Execute a nowplaying request with authentification
val do_submit : Lastfm.client -> Lastfm.login -> song list -> unit
do_submit client login song Execute a nowplaying request with authentification

Advanced API

This API is for advanced usages.

You may use it this way:

  1. handshake : initiate session
  2. np/submit: execute request

The module will cache session informations and avoid redundant requests, so you might always call handshake.

val handshake : Lastfm.client -> Lastfm.login -> string
handshake client login Open session, returns session ID
val np : string -> song -> unit
np sessionID track Execute a nowplaying request
val submit : string -> song list -> unit
submit sessionID tracks Execute a submit request