diff --git a/infocache/artistinfocache/artistinfocache.go b/infocache/artistinfocache/artistinfocache.go index 6951205..1b9edf9 100644 --- a/infocache/artistinfocache/artistinfocache.go +++ b/infocache/artistinfocache/artistinfocache.go @@ -80,8 +80,9 @@ func (a *ArtistInfoCache) Lookup(ctx context.Context, artist *db.Artist) (*db.Ar } artistInfo.SetSimilarArtists(similar) - url, _ := a.lastfmClient.StealArtistImage(info.URL) - artistInfo.ImageURL = url + if url, _ := a.lastfmClient.StealArtistImage(info.URL); url != "" { + artistInfo.ImageURL = url + } topTracksResponse, err := a.lastfmClient.ArtistGetTopTracks(artist.Name) if err != nil { diff --git a/lastfm/client.go b/lastfm/client.go index dbe07a7..1e18b18 100644 --- a/lastfm/client.go +++ b/lastfm/client.go @@ -203,6 +203,9 @@ func (c *Client) StealArtistImage(artistURL string) (string, error) { return "", fmt.Errorf("get artist url: %w", err) } defer resp.Body.Close() + if resp.StatusCode/100 != 2 { + return "", fmt.Errorf("get artist url: %s", resp.Status) + } node, err := html.Parse(resp.Body) if err != nil {