Documentation ¶
Overview ¶
Package lastfm provides a way to communicate with last.fm's api in go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Version is the SemVer representation of the module's state. Version = "0.6.1" // BaseURL is the root of all API calls. BaseURL = "https://ws.audioscrobbler.com/2.0/" )
var SortOrder = []string{"0", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4", "5", "6", "7", "8", "9"}
SortOrder is the order array keys should be in to generate a valid signature. The "signature" for authenticated calls requires you to put the parameters in alphabetical order. This includes the arrays in track.scrobble, which have to be sorted according to the ASCII table, not as though the numbers were strings. By this method, 10 < 19 < 1. Much time was spent trying to make `sort.Sort` work with this until I decided this was perfectly fine.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
An API object provides the mechanism to authenticate and communicate with last.fm's system.
func New ¶
New initializes an API object with the provided api key and shared secret. The user's session key is not required as you may need to contact the API in order to obtain one.
func (*API) AlbumSearch ¶
AlbumSearch contacts last.fm and returns a list of albums that match the search query.
func (*API) Authenticate ¶
Authenticate accepts a username and password and uses the mobile authentication scheme to generate a session token. Using the mobile scheme avoids the need to handle oauth callbacks.
func (*API) Authenticated ¶
Authenticated returns whether a session key has been set.
func (*API) SetSessionKey ¶
SetSessionKey adds the user's session key/token to the object, allowing for authenticated API calls.
func (*API) SetVerbose ¶
SetVerbose sets whether more information (such as curl versions of the calls).
type Album ¶
type Album struct { API *API Name string `json:"name"` Artist string `json:"artist"` URL string `json:"url"` Images []Image `json:"image"` Streamable string `json:"streamable"` MusicBrainzID string `json:"mbid"` Listeners string `json:"lisners"` Playcount string `json:"playcount"` TrackList TrackList `json:"tracks"` }
An Album represents an album, and implements the Scrobbler interface.
type Artist ¶
type Artist struct { Name string `json:"name"` URL string `json:"url"` MusicBrainzID string `json:"mbid"` }
An Artist represents the person or group responsible for creating a track or album.
type AttrList ¶
type AttrList struct {
TrackNumber int `json:"rank,string"`
}
An AttrList contains attributes about a track.
type Scrobbler ¶
type Scrobbler interface {
Scrobble() error
}
A Scrobbler is a type that can scrobble itself, or record the track(s) it contains to last.fm.