Module lastfm

Search:
Group by:

import lastfm  
import lastfm/[track, artist, album, tag, chart]

lastfm is a Nim library for the Last.FM web API. It leverages async/await, and provides multiple methods for setting up client-authenticated sessions.

lastfm consists of multiple submodules:

Procs

proc LastFM(apiKey, apiSecret: string): LastFM {.
raises: [], tags: []
.}
Produces an un-authenticated Last.FM session that can be used to...
  • query any track, artist, or album metadata
  • query any public metadata about a Last.FM user account
  • generate one or more authenticated Last.FM sessions, which can then be used for scrobbling, "favoriting," etc.
proc loadAuth(fm: LastFM; sessionKey: string): LastFMSession {.
raises: [], tags: []
.}

Generate a client-authenticated session from a pre-existing session key.

Last.FM session keys do not expire, unless revoked by the user. As such, an application may get authorization using desktopAuth or mobileAuth, then save that session key in a file. The next time the user opens the application, this session key can be reused.

proc mobileAuth(fm: LastFM; username, password: string): Future[LastFMSession] {.
raises: [FutureError], tags: [ReadIOEffect, WriteIOEffect, TimeEffect, RootEffect]
.}
Generate a client-authenticated session following Last.FM's mobile authentication flow. Using this API is not recommended under normal circumstances, as it requires access to the user's password in plaintext.
proc desktopAuth(fm: LastFM; keepGoing: proc (_: string): Future[bool]): Future[  
LastFMSession] {.
raises: [FutureError], tags: [ReadIOEffect, WriteIOEffect, TimeEffect, RootEffect]
.}

Generate a client-authenticated session following Last.FM's "desktop" authentication flow.

keepGoing is passed a URL that should be opened in the client's browser so that they can grant permission to your application.

  • If the user successfully grants permission to your application, keepGoing should return true.
  • If the user does NOT authorize your application, keepGoing must return false. If keepGoing returns false, an IOError is thrown.