🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Clean up, comments and logs
Deluan52a407b84bf8
diff --git a/cmd/wire_gen.go b/cmd/wire_gen.goindex 06b5dd247..cdd62d4fb 100644--- a/cmd/wire_gen.go+++ b/cmd/wire_gen.go@@ -42,9 +42,7 @@ func CreateSubsonicAPIRouter() *subsonic.Router {mediaStreamer := core.NewMediaStreamer(dataStore, transcoderTranscoder, transcodingCache)archiver := core.NewArchiver(dataStore)players := core.NewPlayers(dataStore)- client := core.LastFMNewClient()- spotifyClient := core.SpotifyNewClient()- externalInfo := core.NewExternalInfo2(dataStore, client, spotifyClient)+ externalInfo := core.NewExternalInfo2(dataStore)scanner := GetScanner()router := subsonic.New(dataStore, artwork, mediaStreamer, archiver, players, externalInfo, scanner)return routerdiff --git a/core/external_info2.go b/core/external_info2.goindex fea2b3524..43ddceffd 100644--- a/core/external_info2.go+++ b/core/external_info2.go@@ -10,8 +10,6 @@ import ("github.com/Masterminds/squirrel""github.com/navidrome/navidrome/conf""github.com/navidrome/navidrome/core/agents"- "github.com/navidrome/navidrome/core/lastfm"- "github.com/navidrome/navidrome/core/spotify""github.com/navidrome/navidrome/log""github.com/navidrome/navidrome/model")@@ -20,7 +18,7 @@ type externalInfo2 struct {ds model.DataStore}-func NewExternalInfo2(ds model.DataStore, lfm *lastfm.Client, spf *spotify.Client) ExternalInfo {+func NewExternalInfo2(ds model.DataStore) ExternalInfo {return &externalInfo2{ds: ds}}@@ -66,13 +64,14 @@ func (e *externalInfo2) UpdateArtistInfo(ctx context.Context, id string, similar}// If we have fresh info, just return it- if time.Since(artist.ExternalInfoUpdatedAt) < time.Second { //consts.ArtistInfoTimeToLive {+ if time.Since(artist.ExternalInfoUpdatedAt) < time.Second { // TODO: consts.ArtistInfoTimeToLive {log.Debug("Found cached ArtistInfo", "updatedAt", artist.ExternalInfoUpdatedAt, "name", artist.Name)err := e.loadSimilar(ctx, artist, includeNotPresent)return artist, err}- log.Debug(ctx, "ArtistInfo not cached", "updatedAt", artist.ExternalInfoUpdatedAt, "id", id, "name", artist.Name)+ log.Debug(ctx, "ArtistInfo not cached or expired", "updatedAt", artist.ExternalInfoUpdatedAt, "id", id, "name", artist.Name)+ // Call all registered agents and collect informationwg := &sync.WaitGroup{}e.callGetMBID(ctx, allAgents, artist, wg)e.callGetBiography(ctx, allAgents, artist, wg)@@ -81,10 +80,15 @@ func (e *externalInfo2) UpdateArtistInfo(ctx context.Context, id string, similare.callGetSimilar(ctx, allAgents, artist, similarCount, wg)wg.Wait()+ if isDone(ctx) {+ log.Warn(ctx, "ArtistInfo update canceled", ctx.Err())+ return nil, ctx.Err()+ }+artist.ExternalInfoUpdatedAt = time.Now()err = e.ds.Artist(ctx).Put(artist)if err != nil {- log.Error(ctx, "Error trying to update artistImageUrl", "id", id, err)+ log.Error(ctx, "Error trying to update artist external information", "id", id, "name", artist.Name, err)}if !includeNotPresent {@@ -99,15 +103,16 @@ func (e *externalInfo2) UpdateArtistInfo(ctx context.Context, id string, similar}log.Trace(ctx, "ArtistInfo collected", "artist", artist)-return artist, nil}func (e *externalInfo2) SimilarSongs(ctx context.Context, id string, count int) (model.MediaFiles, error) {+ // TODOreturn nil, nil}func (e *externalInfo2) TopSongs(ctx context.Context, artistName string, count int) (model.MediaFiles, error) {+ // TODOreturn nil, nil}@@ -124,6 +129,7 @@ func (e *externalInfo2) callGetMBID(ctx context.Context, allAgents []agents.Intewg.Add(1)go func() {defer wg.Done()+ start := time.Now()for _, a := range allAgents {if isDone(ctx) {break@@ -135,7 +141,7 @@ func (e *externalInfo2) callGetMBID(ctx context.Context, allAgents []agents.Intembid, err := agent.GetMBID(artist.Name)if mbid != "" && err == nil {artist.MbzArtistID = mbid- log.Debug(ctx, "Got MBID", "agent", a.AgentName(), "artist", artist.Name, "mbid", mbid)+ log.Debug(ctx, "Got MBID", "agent", a.AgentName(), "artist", artist.Name, "mbid", mbid, "elapsed", time.Since(start))break}}@@ -146,6 +152,7 @@ func (e *externalInfo2) callGetURL(ctx context.Context, allAgents []agents.Interwg.Add(1)go func() {defer wg.Done()+ start := time.Now()for _, a := range allAgents {if isDone(ctx) {break@@ -157,7 +164,7 @@ func (e *externalInfo2) callGetURL(ctx context.Context, allAgents []agents.Interurl, err := agent.GetURL(artist.Name, artist.MbzArtistID)if url != "" && err == nil {artist.ExternalUrl = url- log.Debug(ctx, "Got External Url", "agent", a.AgentName(), "artist", artist.Name, "url", url)+ log.Debug(ctx, "Got External Url", "agent", a.AgentName(), "artist", artist.Name, "url", url, "elapsed", time.Since(start))break}}@@ -168,6 +175,7 @@ func (e *externalInfo2) callGetBiography(ctx context.Context, allAgents []agentswg.Add(1)go func() {defer wg.Done()+ start := time.Now()for _, a := range allAgents {if isDone(ctx) {break@@ -179,7 +187,7 @@ func (e *externalInfo2) callGetBiography(ctx context.Context, allAgents []agentsbio, err := agent.GetBiography(artist.Name, artist.MbzArtistID)if bio != "" && err == nil {artist.Biography = bio- log.Debug(ctx, "Got Biography", "agent", a.AgentName(), "artist", artist.Name, "len", len(bio))+ log.Debug(ctx, "Got Biography", "agent", a.AgentName(), "artist", artist.Name, "len", len(bio), "elapsed", time.Since(start))break}}@@ -190,6 +198,7 @@ func (e *externalInfo2) callGetImage(ctx context.Context, allAgents []agents.Intwg.Add(1)go func() {defer wg.Done()+ start := time.Now()for _, a := range allAgents {if isDone(ctx) {break@@ -202,7 +211,7 @@ func (e *externalInfo2) callGetImage(ctx context.Context, allAgents []agents.Intif len(images) == 0 || err != nil {continue}- log.Debug(ctx, "Got Images", "agent", a.AgentName(), "artist", artist.Name, "images", images)+ log.Debug(ctx, "Got Images", "agent", a.AgentName(), "artist", artist.Name, "images", images, "elapsed", time.Since(start))sort.Slice(images, func(i, j int) bool { return images[i].Size > images[j].Size })if len(images) >= 1 {artist.LargeImageUrl = images[0].URL@@ -222,6 +231,7 @@ func (e *externalInfo2) callGetSimilar(ctx context.Context, allAgents []agents.Iwg.Add(1)go func() {defer wg.Done()+ start := time.Now()for _, a := range allAgents {if isDone(ctx) {break@@ -238,7 +248,7 @@ func (e *externalInfo2) callGetSimilar(ctx context.Context, allAgents []agents.Iif err != nil {continue}- log.Debug(ctx, "Got Similar Artists", "agent", a.AgentName(), "artist", artist.Name, "similar", similar)+ log.Debug(ctx, "Got Similar Artists", "agent", a.AgentName(), "artist", artist.Name, "similar", similar, "elapsed", time.Since(start))artist.SimilarArtists = sabreak}diff --git a/core/wire_providers.go b/core/wire_providers.goindex c89b1ef1a..24dad0655 100644--- a/core/wire_providers.go+++ b/core/wire_providers.go@@ -1,12 +1,7 @@package coreimport (- "net/http"-"github.com/google/wire"- "github.com/navidrome/navidrome/conf"- "github.com/navidrome/navidrome/core/lastfm"- "github.com/navidrome/navidrome/core/spotify""github.com/navidrome/navidrome/core/transcoder")@@ -20,23 +15,5 @@ var Set = wire.NewSet(NewExternalInfo2,NewCacheWarmer,NewPlayers,- LastFMNewClient,- SpotifyNewClient,transcoder.New,)--func LastFMNewClient() *lastfm.Client {- if conf.Server.LastFM.ApiKey == "" {- return nil- }-- return lastfm.NewClient(conf.Server.LastFM.ApiKey, conf.Server.LastFM.Language, http.DefaultClient)-}--func SpotifyNewClient() *spotify.Client {- if conf.Server.Spotify.ID == "" || conf.Server.Spotify.Secret == "" {- return nil- }-- return spotify.NewClient(conf.Server.Spotify.ID, conf.Server.Spotify.Secret, http.DefaultClient)-}