From 893839010644c9c44f305c81fd5abbe11737a646 Mon Sep 17 00:00:00 2001 From: safierinx-a Date: Fri, 27 Mar 2026 03:11:05 +0530 Subject: [PATCH] Fix artist images: filter Last.fm placeholder, reorder providers, fix alias bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three bugs causing all artist images to be the same Last.fm placeholder: 1. Last.fm stopped serving real artist images years ago and returns a generic placeholder (hash 2a96cbd8b46e442fc41c2b86b821562f) for every artist. Added filter in selectBestImage to reject URLs containing this known placeholder hash. 2. Provider order had Last.fm before Deezer for artist images. Since Last.fm "succeeded" with the placeholder, Deezer was never reached. Swapped order: Deezer now checked before Last.fm. 3. FetchMissingArtistImages had inverted if/else — aliases were used on error, bare name on success. Fixed condition to err == nil. --- internal/catalog/images.go | 2 +- internal/images/imagesrc.go | 21 ++++++++++----------- internal/images/lastfm.go | 6 +++++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/internal/catalog/images.go b/internal/catalog/images.go index 72b6efd..212e084 100644 --- a/internal/catalog/images.go +++ b/internal/catalog/images.go @@ -298,7 +298,7 @@ func FetchMissingArtistImages(ctx context.Context, store db.DB) error { Msg("FetchMissingArtistImages: Attempting to fetch missing artist image") var aliases []string - if aliasrow, err := store.GetAllArtistAliases(ctx, artist.ID); err != nil { + if aliasrow, err := store.GetAllArtistAliases(ctx, artist.ID); err == nil { aliases = utils.FlattenAliases(aliasrow) } else { aliases = []string{artist.Name} diff --git a/internal/images/imagesrc.go b/internal/images/imagesrc.go index 46fe87a..54395e9 100644 --- a/internal/images/imagesrc.go +++ b/internal/images/imagesrc.go @@ -83,6 +83,16 @@ func GetArtistImage(ctx context.Context, opts ArtistImageOpts) (string, error) { } else { l.Debug().Msg("GetArtistImage: Subsonic image fetching is disabled") } + if imgsrc.deezerEnabled { + img, err := imgsrc.deezerC.GetArtistImages(ctx, opts.Aliases) + if err != nil { + l.Debug().Err(err).Msg("GetArtistImage: Could not find artist image from Deezer") + } else if img != "" { + return img, nil + } + } else { + l.Debug().Msg("GetArtistImage: Deezer image fetching is disabled") + } if imgsrc.lastfmEnabled { img, err := imgsrc.lastfmC.GetArtistImage(ctx, opts.MBID, opts.Aliases[0]) if err != nil { @@ -93,17 +103,6 @@ func GetArtistImage(ctx context.Context, opts ArtistImageOpts) (string, error) { } else { l.Debug().Msg("GetArtistImage: LastFM image fetching is disabled") } - if imgsrc.deezerEnabled { - img, err := imgsrc.deezerC.GetArtistImages(ctx, opts.Aliases) - if err != nil { - l.Debug().Err(err).Msg("GetArtistImage: Could not find artist image from Deezer") - return "", err - } else if img != "" { - return img, nil - } - } else { - l.Debug().Msg("GetArtistImage: Deezer image fetching is disabled") - } l.Warn().Msg("GetArtistImage: No image providers are enabled") return "", nil } diff --git a/internal/images/lastfm.go b/internal/images/lastfm.go index f35f6a3..7dafdcc 100644 --- a/internal/images/lastfm.go +++ b/internal/images/lastfm.go @@ -127,6 +127,10 @@ func (c *LastFMClient) getEntity(ctx context.Context, params url.Values, result return nil } +// lastFMPlaceholderHash is the hash of Last.fm's generic "no artist image" placeholder. +// Last.fm stopped serving real artist images years ago and returns this for nearly every artist. +const lastFMPlaceholderHash = "2a96cbd8b46e442fc41c2b86b821562f" + // selectBestImage picks the largest available image from the LastFM slice func (c *LastFMClient) selectBestImage(images []lastFMImage) string { // Rank preference: mega > extralarge > large > medium > small @@ -135,7 +139,7 @@ func (c *LastFMClient) selectBestImage(images []lastFMImage) string { imgMap := make(map[string]string) for _, img := range images { - if img.URL != "" { + if img.URL != "" && !strings.Contains(img.URL, lastFMPlaceholderHash) { imgMap[img.Size] = img.URL } }