types

Source   Edit  

Types

Listen = object
  trackName*, artistName*: cstring
  releaseName*, recordingMbid*, releaseMbid*: Option[cstring]
  artistMbids*: Option[seq[cstring]]
  trackNumber*, listenedAt*: Option[int]
  mirrored*, preMirror*: Option[bool]
A normalised listen object.
  • mirrored: stores the state of whether a listen to be mirrored has been submitted.
  • preMirror: stores the state of whether a listen was submitted within a mirroring session.
Source   Edit  
Service = enum
  listenBrainzService = "listenbrainz", lastFmService = "lastfm"
Stores the service that the user belongs to:
  • listenBrainzService: user of the ListenBrainz service
  • lastFmService: user of the Last.FM service
Source   Edit  
Session = ref object
  id*: cstring
  users*: seq[cstring]
  mirror*: Option[cstring]
Stores session state, including a seq of user IDs, and optionally a mirror user ID. Source   Edit  
User = ref object
  id*, username*: cstring
  lastUpdateTs*: int
  playingNow*: Option[Listen]
  listenHistory*: seq[Listen]
Stores the user information including the api keys for the service it belongs to.
  • lastUpdateTs: stores the last listen timestamp.
Source   Edit  

Procs

func `==`(a, b: Listen): bool {....raises: [], tags: [], forbids: [].}
does not include mirrored or preMirror Source   Edit  
func `==`(a, b: User): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
func genId(username: cstring; service: Service): cstring {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
func newListen(trackName, artistName: cstring;
               releaseName, recordingMbid, releaseMbid = none(cstring);
               artistMbids = none(seq[cstring]); trackNumber = none(int);
               listenedAt = none(int); mirrored, preMirror = none(bool)): Listen {.
    ...raises: [], tags: [], forbids: [].}
Create new Listen object Source   Edit  
func newSession(id: cstring = "session"; users: seq[cstring] = @[];
                mirror = none(cstring)): Session {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
func newUser(username: cstring; service: Service;
             token, sessionKey: cstring = ""; lastUpdateTs = 0;
             playingNow = none(Listen); listenHistory: seq[Listen] = @[]): User {.
    ...raises: [], tags: [], forbids: [].}
Create new User object Source   Edit