lastfm

package
v0.0.0-...-8d52960 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseURL = "https://ws.audioscrobbler.com/2.0/"
)

Variables

View Source
var (
	ErrLastFM        = errors.New("last.fm error")
	ErrNoUserSession = errors.New("no lastfm user session present")
)

Functions

func GetParamSignature

func GetParamSignature(params url.Values, secret string) string

Types

type Album

type Album struct {
	XMLName xml.Name `xml:"album"`
	Name    string   `xml:"name"`
	Artist  string   `xml:"artist"`
	MBID    string   `xml:"mbid"`
	URL     string   `xml:"url"`
	Image   []struct {
		Text string `xml:",chardata"`
		Size string `xml:"size,attr"`
	} `xml:"image"`
	Listeners string `xml:"listeners"`
	Playcount string `xml:"playcount"`
	Tracks    struct {
		Text  string `xml:",chardata"`
		Track []struct {
			Text       string `xml:",chardata"`
			Rank       string `xml:"rank,attr"`
			Name       string `xml:"name"`
			URL        string `xml:"url"`
			Duration   string `xml:"duration"`
			Streamable struct {
				Text      string `xml:",chardata"`
				Fulltrack string `xml:"fulltrack,attr"`
			} `xml:"streamable"`
			Artist struct {
				Text string `xml:",chardata"`
				Name string `xml:"name"`
				Mbid string `xml:"mbid"`
				URL  string `xml:"url"`
			} `xml:"artist"`
		} `xml:"track"`
	} `xml:"tracks"`
	Tags struct {
		Text string `xml:",chardata"`
		Tag  []struct {
			Text string `xml:",chardata"`
			Name string `xml:"name"`
			URL  string `xml:"url"`
		} `xml:"tag"`
	} `xml:"tags"`
	Wiki struct {
		Text      string `xml:",chardata"`
		Published string `xml:"published"`
		Summary   string `xml:"summary"`
		Content   string `xml:"content"`
	} `xml:"wiki"`
}

type Artist

type Artist struct {
	XMLName    xml.Name `xml:"artist"`
	Name       string   `xml:"name"`
	MBID       string   `xml:"mbid"`
	URL        string   `xml:"url"`
	Image      []Image  `xml:"image"`
	Streamable string   `xml:"streamable"`
	Stats      struct {
		Listeners string `xml:"listeners"`
		Playcount string `xml:"playcount"`
	} `xml:"stats"`
	Similar struct {
		Artists []Artist `xml:"artist"`
	} `xml:"similar"`
	Tags struct {
		Tag []ArtistTag `xml:"tag"`
	} `xml:"tags"`
	Bio ArtistBio `xml:"bio"`
}

type ArtistBio

type ArtistBio struct {
	Published string `xml:"published"`
	Summary   string `xml:"summary"`
	Content   string `xml:"content"`
}

type ArtistTag

type ArtistTag struct {
	Name string `xml:"name"`
	URL  string `xml:"url"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(keySecret KeySecretFunc) *Client

func NewClientCustom

func NewClientCustom(httpClient *http.Client, keySecret KeySecretFunc) *Client

func (*Client) AlbumGetInfo

func (c *Client) AlbumGetInfo(artistName, albumName string) (Album, error)

func (*Client) ArtistGetInfo

func (c *Client) ArtistGetInfo(artistName string) (Artist, error)

func (*Client) ArtistGetSimilar

func (c *Client) ArtistGetSimilar(artistName string) (SimilarArtists, error)

func (*Client) ArtistGetTopTracks

func (c *Client) ArtistGetTopTracks(artistName string) (TopTracks, error)

func (*Client) GetCurrentUser

func (c *Client) GetCurrentUser(user *db.User) (User, error)

func (*Client) GetSession

func (c *Client) GetSession(token string) (string, error)

func (*Client) IsUserAuthenticated

func (c *Client) IsUserAuthenticated(user db.User) bool

func (*Client) LoveTrack

func (c *Client) LoveTrack(user *db.User, track *db.Track) error

func (*Client) Scrobble

func (c *Client) Scrobble(user db.User, track scrobble.Track, stamp time.Time, submission bool) error

func (*Client) StealArtistImage

func (c *Client) StealArtistImage(artistURL string) (string, error)

func (*Client) TrackGetSimilarTracks

func (c *Client) TrackGetSimilarTracks(artistName, trackName string) (SimilarTracks, error)

func (*Client) UserGetLovedTracks

func (c *Client) UserGetLovedTracks(userName string) (LovedTracks, error)

type Error

type Error struct {
	Code  uint   `xml:"code,attr"`
	Value string `xml:",chardata"`
}

type Image

type Image struct {
	Text string `xml:",chardata"`
	Size string `xml:"size,attr"`
}

type KeySecretFunc

type KeySecretFunc func() (apiKey, secret string, err error)

type LastFM

type LastFM struct {
	XMLName        xml.Name       `xml:"lfm"`
	Status         string         `xml:"status,attr"`
	Session        Session        `xml:"session"`
	Error          Error          `xml:"error"`
	Artist         Artist         `xml:"artist"`
	Album          Album          `xml:"album"`
	TopTracks      TopTracks      `xml:"toptracks"`
	SimilarTracks  SimilarTracks  `xml:"similartracks"`
	SimilarArtists SimilarArtists `xml:"similarartists"`
	LovedTracks    LovedTracks    `xml:"lovedtracks"`
	User           User           `xml:"user"`
}

type LovedTracks

type LovedTracks struct {
	XMLName xml.Name `xml:"lovedtracks"`
	Tracks  []struct {
		Track
		Date struct {
			Text string `xml:",chardata"`
			UTS  string `xml:"uts,attr"`
		} `xml:"date"`
		Artist Artist `xml:"artist"`
	} `xml:"track"`
}

type Session

type Session struct {
	Name       string `xml:"name"`
	Key        string `xml:"key"`
	Subscriber uint   `xml:"subscriber"`
}

type SimilarArtist

type SimilarArtist struct {
	XMLName    xml.Name `xml:"artist"`
	Name       string   `xml:"name"`
	MBID       string   `xml:"mbid"`
	URL        string   `xml:"url"`
	Image      []Image  `xml:"image"`
	Streamable string   `xml:"streamable"`
}

type SimilarArtists

type SimilarArtists struct {
	XMLName xml.Name `xml:"similarartists"`
	Artist  string   `xml:"artist,attr"`
	Artists []Artist `xml:"artist"`
}

type SimilarTracks

type SimilarTracks struct {
	XMLName xml.Name `xml:"similartracks"`
	Artist  string   `xml:"artist,attr"`
	Track   string   `xml:"track,attr"`
	Tracks  []Track  `xml:"track"`
}

type TopTracks

type TopTracks struct {
	XMLName xml.Name `xml:"toptracks"`
	Artist  string   `xml:"artist,attr"`
	Tracks  []Track  `xml:"track"`
}

type Track

type Track struct {
	Rank      int     `xml:"rank,attr"`
	Tracks    []Track `xml:"track"`
	Name      string  `xml:"name"`
	MBID      string  `xml:"mbid"`
	PlayCount int     `xml:"playcount"`
	Listeners int     `xml:"listeners"`
	URL       string  `xml:"url"`
	Image     []Image `xml:"image"`
}

type User

type User struct {
	Text     string `xml:",chardata"`
	Name     string `xml:"name"`
	Realname string `xml:"realname"`
	Image    []struct {
		Text string `xml:",chardata"`
		Size string `xml:"size,attr"`
	} `xml:"image"`
	URL        string `xml:"url"`
	Country    string `xml:"country"`
	Age        string `xml:"age"`
	Gender     string `xml:"gender"`
	Subscriber string `xml:"subscriber"`
	Playcount  string `xml:"playcount"`
	Playlists  string `xml:"playlists"`
	Bootstrap  string `xml:"bootstrap"`
	Registered struct {
		Text     string `xml:",chardata"`
		Unixtime string `xml:"unixtime,attr"`
	} `xml:"registered"`
	Type        string `xml:"type"`
	ArtistCount string `xml:"artist_count"`
	AlbumCount  string `xml:"album_count"`
	TrackCount  string `xml:"track_count"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL