module type Audioscrobbler_t =sig..end
This is the type of the Audioscrobbler API.
Audioscrobbler is the submission protocol as described at
http://www.audioscrobbler.net/development/protocol/
type source =
| |
User |
| |
Broadcast |
| |
Recommendation |
| |
Lastfm |
| |
Unknown |
source of the track
type rating =
| |
Love |
| |
Ban |
| |
Skip |
possible rating for the track
type action =
| |
NowPlaying |
| |
Submit |
type of action
type song = {
|
artist : |
|
track : |
|
time : |
|
source : |
|
rating : |
|
length : |
|
album : |
|
trackauth : |
|
tracknumber : |
|
musicbrainzid : |
song submission type
type error =
| |
Http of |
| |
Banned |
| |
Badauth |
| |
Badtime |
| |
Failed of |
| |
UnknownError of |
| |
Success |
| |
Internal of |
| |
BadData of |
various errors
exception Error of error
val string_of_error : error -> stringGet meaning of Error e
val base_port : int Stdlib.refBase port. Default: 80
val base_host : string Stdlib.refBase host. Default: "post.audioscrobbler.com"
Functions common to both basic and advanced APIs
val get_song : ?time:float ->
?source:source ->
?rating:rating ->
?length:float ->
?album:string ->
?tracknumber:int ->
?musicbrainzid:string ->
?trackauth:string ->
artist:string -> track:string -> unit -> songget_song
create a song record based on given values.
Optional records can be ommited there.
val check_song : song ->
action -> unitCheck wether required song informations are supplied for given action.
Raises Error (BadData reason) if invalid data is given.
See protocol details there:
Using this API, all requests are done in one single step
val do_np : ?timeout:float ->
?host:string * int ->
Lastfm_generic.client ->
Lastfm_generic.login -> song -> unitdo_np client login song
execute a nowplaying request
with authentification
Optional host parameter is a pair "host",port to override the global values.
val do_submit : ?timeout:float ->
?host:string * int ->
Lastfm_generic.client ->
Lastfm_generic.login ->
song list ->
(error * song)
listdo_submit client login songs
execute a nowplaying request
with authentification.
This functions returns a list
songs for which supplied informations
were incomplete, with corresponding exception
(see check_song source)
This API is for advanced usages.
You may use it this way:
The module will cache session informations and avoid redundant requests, so you might always call handshake.
However, if a np or submit fails, it can be because the session has expired on server side, but the module cache still refered to it. So you might clear this session id, and try another handshake+submit/np.
Check do_no and do_submit for examples.
val handshake : ?timeout:float ->
?host:string * int -> Lastfm_generic.client -> Lastfm_generic.login -> stringhandshake client login
open session, returns session ID
Optional host parameter is a pair "host",port to override the global values.
val np : ?timeout:float -> string -> song -> unitnp sessionID track
execute a nowplaying request
val submit : ?timeout:float ->
string ->
song list ->
(error * song)
listsubmit sessionID tracks
execute a submit request
This functions returns a list songs for which supplied informations were incomplete, with corresponding exception (see check_song)