scrobble-0.2.1.0: Scrobbling server.

Safe Haskell | None

Scrobble.Types

Description

Scrobbling data types.

Synopsis

- data Config = Config {
  - cfgPort :: PortNumber
  - cfgHost :: String
  - cfgExpire :: NominalDiffTime
  }
- data Handlers = Handlers {
  - handleHandshake :: Session -> IO ()
  - handleExpire :: Session -> IO ()
  - handleNowPlaying :: Session -> NowPlaying -> IO ()
  - handleSubmissions :: Session -> [Submission] -> IO Bool
  }
- data Session = Session {
  - sesHandshake :: Bool
  - sesVersion :: String
  - sesClientId :: String
  - sesClientVer :: String
  - sesUser :: String
  - sesTimestamp :: UTCTime
  - sesToken :: String
  }
- data NowPlaying = NowPlaying {
  - npArtist :: String
  - npTrack :: String
  - npAlbum :: Maybe String
  - npLength :: Maybe Integer
  - npPosition :: Maybe Integer
  - npMusicBrainz :: Maybe String
  }
- data Submission = Submission {
  - subArtist :: String
  - subTrack :: String
  - subTimestamp :: UTCTime
  - subSource :: Source
  - subRating :: Maybe Rating
  - subLength :: Maybe Integer
  - subAlbum :: Maybe String
  - subPosition :: Maybe Integer
  - subMusicBrainz :: Maybe String
  }
- data Rating
  - = Love
  - | Ban
  - | Skip
- data Source
  - = UserChosen
  - | NonPersonlizedBroadcast
  - | Personalized
  - | LastFm
  - | Unknown
- data Response
  - = OK
  - | BANNED
  - | BADAUTH
  - | FAILED String
  - | BADSESSION
- data Client = Client {
  - cliToken :: String
  - cliNowPlaying :: URI
  - cliSubmit :: URI
  }
- data Details = Details {
  - detPassword :: String
  - detUsername :: String
  - detClient :: String
  - detVersion :: String
  - detServer :: URI
  }
- data ScrobblerError
  - = ScrobblerBanned
  - | ScrobblerBadAuth
  - | ScrobblerBadTime
  - | ScrobblerFailed String
  - | ScrobblerHardFail
  - | ScrobblerSubmitFail String
  - | ScrobblerNowPlayingFail String

# Documentation

data Config Source

Server configuration.

Constructors

Config |

Fields

cfgPort :: PortNumber

  Port to listen on.

cfgHost :: String

  Host name used for server (probably just localhost).

cfgExpire :: NominalDiffTime

  Number of seconds of inactivity before a session expires.

Instances

Show Config |

data Handlers Source

Event handlers.

Constructors

Handlers |

Fields

handleHandshake :: Session -> IO ()

  Initial connection hand-shake.

handleExpire :: Session -> IO ()

  Session expiry.

handleNowPlaying :: Session -> NowPlaying -> IO ()

  Now-playing notification.

handleSubmissions :: Session -> [Submission] -> IO Bool

  Played tracks submission.

data Session Source

A scrobbling session.

Constructors

Session |

Fields

sesHandshake :: Bool

  Does the session require handshake?

sesVersion :: String

  Version of the protocol.

sesClientId :: String

  Client (music player's) id.

sesClientVer :: String

  Client version.

sesUser :: String

  Username.

sesTimestamp :: UTCTime

  Timestamp of connection.

sesToken :: String

  Session token.

Instances

Show Session |

data NowPlaying Source

A now playing track.

Constructors

NowPlaying |

Fields

npArtist :: String

  Artist name.

npTrack :: String

  Track title.

npAlbum :: Maybe String

  Album name (if any).

npLength :: Maybe Integer

  Track length in seconds (if known).

npPosition :: Maybe Integer

  Track position (if known).

npMusicBrainz :: Maybe String

  MusicBrainz track id (if known).

Instances

Show NowPlaying |

data Submission Source

A track submission.

Constructors

Submission |

Fields

subArtist :: String

  Artist name.

subTrack :: String

  Track title.

subTimestamp :: UTCTime

  Track timestamp.

subSource :: Source

  Source of track.

subRating :: Maybe Rating

  Rating (if any).

subLength :: Maybe Integer

  Track length (if any).

subAlbum :: Maybe String

  Album (if any).

subPosition :: Maybe Integer

  Track position in album (if any).

subMusicBrainz :: Maybe String

  MusicBrainz track id (if any).

Instances

Show Submission |

data Rating Source

A rating of a track.

Note: Currently, a web-service must also be called to set love/ban status. We anticipate that this will be phased out soon, and the submission service will handle the whole process.

Constructors

Love | Love (on any mode if the user has manually loved the track). This implies a listen.
Ban | Ban (only if source=L). This implies a skip, and the client should skip to the next track when a ban happens.
Skip | Skip (only if source=L).

Instances

Enum Rating |
Eq Rating |
Read Rating |
Show Rating |

data Source Source

The source of the track. Required, must be one of the following codes:

Please note, for the time being, sources other than P and L are not supported.

Constructors

UserChosen | Chosen by the user
NonPersonlizedBroadcast | Non-personalised broadcast (e.g. Shoutcast, BBC Radio 1)
Personalized | Personalised recommendation except Last.fm (e.g. Pandora, Launchcast)
LastFm | Last.fm (any mode). In this case, the 5-digit Last.fm recommendation key must be appended to this source ID to prove the validity of the submission (for example, o[0]=L1b48a).
Unknown | Source unknown.

Instances

Enum Source |
Eq Source |
Read Source |
Show Source |

data Response Source

Server response.

Constructors

OK |
BANNED |
BADAUTH |
FAILED String |
BADSESSION |

Instances

Show Response |

data Client Source

A scrobbling client.

Constructors

Client |

Fields

cliToken :: String

  Session token.

cliNowPlaying :: URI

  Now playing URL to submit to.

cliSubmit :: URI

  URL to submit listened tracks to.

Instances

Show Client |

data Details Source

Details for creating a scrobbling client.

Constructors

Details |

Fields

detPassword :: String
detUsername :: String
detClient :: String

  E.g. “qlb”.

detVersion :: String

  E.g. “0.9.2”.

detServer :: URI

  See defaultServer in Scrobble.Client.

Instances

Show Details |

data ScrobblerError Source

Scrobble exception.

Constructors

ScrobblerBanned |
ScrobblerBadAuth |
ScrobblerBadTime |
ScrobblerFailed String |
ScrobblerHardFail |
ScrobblerSubmitFail String |
ScrobblerNowPlayingFail String |

Instances

Data ScrobblerError |
Show ScrobblerError |
Typeable ScrobblerError |
Exception ScrobblerError |