Include a shared Last.FM api key, providing zero conf ArtistInfo (bio/top songs/similar artists)
This commit is contained in:
+13
-6
@@ -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)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user