Skip to content

Commit

Permalink
Don't try to connect to external services if artist is Unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Feb 2, 2023
1 parent f4b50c4 commit cf04db7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions core/agents/agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"strings"
"time"

"github.com/navidrome/navidrome/model"

"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/consts"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/utils"
)

Expand Down Expand Up @@ -42,6 +42,9 @@ func (a *Agents) AgentName() string {
}

func (a *Agents) GetArtistMBID(ctx context.Context, id string, name string) (string, error) {
if id == consts.UnknownArtistID {
return "", ErrNotFound
}
start := time.Now()
for _, ag := range a.agents {
if utils.IsCtxDone(ctx) {
Expand All @@ -61,6 +64,9 @@ func (a *Agents) GetArtistMBID(ctx context.Context, id string, name string) (str
}

func (a *Agents) GetArtistURL(ctx context.Context, id, name, mbid string) (string, error) {
if id == consts.UnknownArtistID {
return "", ErrNotFound
}
start := time.Now()
for _, ag := range a.agents {
if utils.IsCtxDone(ctx) {
Expand All @@ -80,6 +86,9 @@ func (a *Agents) GetArtistURL(ctx context.Context, id, name, mbid string) (strin
}

func (a *Agents) GetArtistBiography(ctx context.Context, id, name, mbid string) (string, error) {
if id == consts.UnknownArtistID {
return "", ErrNotFound
}
start := time.Now()
for _, ag := range a.agents {
if utils.IsCtxDone(ctx) {
Expand All @@ -99,6 +108,9 @@ func (a *Agents) GetArtistBiography(ctx context.Context, id, name, mbid string)
}

func (a *Agents) GetSimilarArtists(ctx context.Context, id, name, mbid string, limit int) ([]Artist, error) {
if id == consts.UnknownArtistID {
return nil, ErrNotFound
}
start := time.Now()
for _, ag := range a.agents {
if utils.IsCtxDone(ctx) {
Expand All @@ -122,6 +134,9 @@ func (a *Agents) GetSimilarArtists(ctx context.Context, id, name, mbid string, l
}

func (a *Agents) GetArtistImages(ctx context.Context, id, name, mbid string) ([]ExternalImage, error) {
if id == consts.UnknownArtistID {
return nil, ErrNotFound
}
start := time.Now()
for _, ag := range a.agents {
if utils.IsCtxDone(ctx) {
Expand All @@ -141,6 +156,9 @@ func (a *Agents) GetArtistImages(ctx context.Context, id, name, mbid string) ([]
}

func (a *Agents) GetArtistTopSongs(ctx context.Context, id, artistName, mbid string, count int) ([]Song, error) {
if id == consts.UnknownArtistID {
return nil, ErrNotFound
}
start := time.Now()
for _, ag := range a.agents {
if utils.IsCtxDone(ctx) {
Expand Down

0 comments on commit cf04db7

Please sign in to comment.