Include a shared Last.FM api key, providing zero conf ArtistInfo (bio/top songs/similar artists)

This commit is contained in:
Deluan
2021-05-27 16:14:24 -04:00
parent db11b6b8f8
commit b398053223
5 changed files with 50 additions and 10 deletions
+13 -6
View File
@@ -10,7 +10,11 @@ import (
"github.com/navidrome/navidrome/utils/lastfm"
)
const lastFMAgentName = "lastfm"
const (
lastFMAgentName = "lastfm"
lastFMAPIKey = "c2918986bf01b6ba353c0bc1bdd27bea"
//lastFMAPISecret = "3ff2aa214a6d8f2242515083bbb70e79" // Will be needed when implementing Scrobbling
)
type lastfmAgent struct {
ctx context.Context
@@ -21,9 +25,13 @@ type lastfmAgent struct {
func lastFMConstructor(ctx context.Context) Interface {
l := &lastfmAgent{
ctx: ctx,
apiKey: conf.Server.LastFM.ApiKey,
lang: conf.Server.LastFM.Language,
ctx: ctx,
lang: conf.Server.LastFM.Language,
}
if conf.Server.LastFM.ApiKey != "" {
l.apiKey = conf.Server.LastFM.ApiKey
} else {
l.apiKey = lastFMAPIKey
}
hc := NewCachedHTTPClient(http.DefaultClient, consts.DefaultCachedHttpClientTTL)
l.client = lastfm.NewClient(l.apiKey, l.lang, hc)
@@ -132,8 +140,7 @@ func (l *lastfmAgent) callArtistGetTopTracks(artistName, mbid string, count int)
func init() {
conf.AddHook(func() {
if conf.Server.LastFM.ApiKey != "" {
log.Info("Last.FM integration is ENABLED")
if conf.Server.LastFM.Enabled {
Register(lastFMAgentName, lastFMConstructor)
}
})