lastfm

package
v0.0.0-...-0dfd57a Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Service lastfm provides access to Last.FM API and stores the user library.

Index

Constants

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

Variables

View Source
var BroadGenres = []string{
	"acoustic",
	"classical",
	"country",
	"electronic",
	"folk",
	"gothic",
	"hip-hop",
	"indie",
	"jazz",
	"metal",
	"podcast",
	"pop",
	"punk",
	"reggae",
	"rock",
	"singer-songwriter",
	"soundtrack",
}
View Source
var IgnoredGenres = map[string]string{
	"composer":         "",
	"composers":        "",
	"female vocalists": "",
	"hip hop":          "hip-hop",
	"instrumental":     "",
	"rap":              "hip-hop",
}
View Source
var Module = &services.Module{
	Name:        "lastfm",
	Version:     "1.0",
	NewInstance: NewService,
}

Functions

func FindGenre

func FindGenre(tags []ApiTag) (string, string)

Types

type Api

type Api struct {
	Url string
	Key string
}

func NewApi

func NewApi(key string) *Api

func (*Api) ArtistGetTopTags

func (a *Api) ArtistGetTopTags(artist string) (*ApiTopTags, error)

func (*Api) UserGetRecentTracks

func (a *Api) UserGetRecentTracks(user string, page int, from int64) (*ApiRecentTracks, error)

type ApiRecentTracks

type ApiRecentTracks struct {
	ApiResponse
	RecentTracks struct {
		Attr struct {
			User       string `json:"user"`
			Page       int    `json:"page,string"`
			PerPage    int    `json:"perPage,string"`
			TotalPages int    `json:"totalPages,string"`
			Total      int    `json:"total,string"`
		} `json:"@attr"`
		Tracks []ApiTrack `json:"track"`
	} `json:"recenttracks"`
}

type ApiResponse

type ApiResponse struct {
	Error   int    `json:"error"`
	Message string `json:"message"`
}

func (ApiResponse) IsError

func (r ApiResponse) IsError() error

type ApiTag

type ApiTag struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
	Url   string `json:"url"`
}

type ApiTopTags

type ApiTopTags struct {
	ApiResponse
	TopTags struct {
		Tags []ApiTag `json:"tag"`
		Attr struct {
			Artist string `json:"artist"`
		} `json:"@attr"`
	} `json:"toptags"`
}

type ApiTrack

type ApiTrack struct {
	Artist struct {
		Text string `json:"#text"`
	} `json:"artist"`
	Album struct {
		Text string `json:"#text"`
	} `json:"album"`
	Name string `json:"name"`
	Url  string `json:"url"`
	Date struct {
		UTS  int    `json:"uts,string"`
		Text string `json:"#text"`
	} `json:"date"`
	Attr struct {
		NowPlaying bool `json:"nowplaying,string"`
	} `json:"@attr"`
}

func (ApiTrack) ParseDate

func (t ApiTrack) ParseDate() (time.Time, error)

type Artist

type Artist struct {
	Id         int64
	Name       string `sql:"index"`
	Genre      string
	BroadGenre string
}

func (Artist) TableName

func (Artist) TableName() string

type ByDate

type ByDate []Track

func (ByDate) Len

func (a ByDate) Len() int

func (ByDate) Less

func (a ByDate) Less(i, j int) bool

func (ByDate) Swap

func (a ByDate) Swap(i, j int)

type Config

type Config struct {
	User   string
	ApiKey string
}

type Dependencies

type Dependencies struct {
	DB     *gorm.DB
	Config services.Config
	Log    sfproto.Logger
	Client sarif.Client
}

type Service

type Service struct {
	DB  *gorm.DB
	Log sfproto.Logger
	sarif.Client
	// contains filtered or unexported fields
}

func NewService

func NewService(deps *Dependencies) *Service

func (*Service) Enable

func (s *Service) Enable() error

func (*Service) ImportAll

func (s *Service) ImportAll() error

func (*Service) RefreshArtistInfo

func (s *Service) RefreshArtistInfo()

type Track

type Track struct {
	Id     int64
	Artist string
	Album  string
	Title  string
	Time   time.Time `sql:"index"`
}

func (Track) TableName

func (Track) TableName() string

Jump to

Keyboard shortcuts

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