mirror of
https://github.com/gabehf/Koito.git
synced 2026-04-22 12:01:52 -07:00
Merge 8938390106 into 0ec7b458cc
This commit is contained in:
commit
effa3d2e80
3 changed files with 16 additions and 13 deletions
|
|
@ -298,7 +298,7 @@ func FetchMissingArtistImages(ctx context.Context, store db.DB) error {
|
||||||
Msg("FetchMissingArtistImages: Attempting to fetch missing artist image")
|
Msg("FetchMissingArtistImages: Attempting to fetch missing artist image")
|
||||||
|
|
||||||
var aliases []string
|
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)
|
aliases = utils.FlattenAliases(aliasrow)
|
||||||
} else {
|
} else {
|
||||||
aliases = []string{artist.Name}
|
aliases = []string{artist.Name}
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,16 @@ func GetArtistImage(ctx context.Context, opts ArtistImageOpts) (string, error) {
|
||||||
} else {
|
} else {
|
||||||
l.Debug().Msg("GetArtistImage: Subsonic image fetching is disabled")
|
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 {
|
if imgsrc.lastfmEnabled {
|
||||||
img, err := imgsrc.lastfmC.GetArtistImage(ctx, opts.MBID, opts.Aliases[0])
|
img, err := imgsrc.lastfmC.GetArtistImage(ctx, opts.MBID, opts.Aliases[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -93,17 +103,6 @@ func GetArtistImage(ctx context.Context, opts ArtistImageOpts) (string, error) {
|
||||||
} else {
|
} else {
|
||||||
l.Debug().Msg("GetArtistImage: LastFM image fetching is disabled")
|
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")
|
l.Warn().Msg("GetArtistImage: No image providers are enabled")
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,10 @@ func (c *LastFMClient) getEntity(ctx context.Context, params url.Values, result
|
||||||
return nil
|
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
|
// selectBestImage picks the largest available image from the LastFM slice
|
||||||
func (c *LastFMClient) selectBestImage(images []lastFMImage) string {
|
func (c *LastFMClient) selectBestImage(images []lastFMImage) string {
|
||||||
// Rank preference: mega > extralarge > large > medium > small
|
// Rank preference: mega > extralarge > large > medium > small
|
||||||
|
|
@ -135,7 +139,7 @@ func (c *LastFMClient) selectBestImage(images []lastFMImage) string {
|
||||||
|
|
||||||
imgMap := make(map[string]string)
|
imgMap := make(map[string]string)
|
||||||
for _, img := range images {
|
for _, img := range images {
|
||||||
if img.URL != "" {
|
if img.URL != "" && !strings.Contains(img.URL, lastFMPlaceholderHash) {
|
||||||
imgMap[img.Size] = img.URL
|
imgMap[img.Size] = img.URL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue