Add Last.FM Authentication methods

This commit is contained in:
Deluan
2021-06-10 23:54:20 -04:00
committed by Deluan Quintão
parent 73e1a8fa06
commit a4f91b74d2
5 changed files with 168 additions and 62 deletions
+8 -6
View File
@@ -14,28 +14,30 @@ import (
const (
lastFMAgentName = "lastfm"
lastFMAPIKey = "9b94a5515ea66b2da3ec03c12300327e"
//lastFMAPISecret = "74cb6557cec7171d921af5d7d887c587" // Will be needed when implementing Scrobbling
lastFMAPISecret = "74cb6557cec7171d921af5d7d887c587" // nolint:gosec
)
type lastfmAgent struct {
ctx context.Context
apiKey string
secret string
lang string
client *Client
}
func lastFMConstructor(ctx context.Context) agents.Interface {
l := &lastfmAgent{
ctx: ctx,
lang: conf.Server.LastFM.Language,
ctx: ctx,
lang: conf.Server.LastFM.Language,
apiKey: lastFMAPIKey,
secret: lastFMAPISecret,
}
if conf.Server.LastFM.ApiKey != "" {
l.apiKey = conf.Server.LastFM.ApiKey
} else {
l.apiKey = lastFMAPIKey
l.secret = conf.Server.LastFM.Secret
}
hc := utils.NewCachedHTTPClient(http.DefaultClient, consts.DefaultCachedHttpClientTTL)
l.client = NewClient(l.apiKey, l.lang, hc)
l.client = NewClient(l.apiKey, l.secret, l.lang, hc)
return l
}