feat: artist image disk cache + fix top results artist photos
Two changes:
1. Artist image disk cache: ArtistImageProvider now fetches the
actual image bytes from Wikimedia Commons and caches them on
disk (~/.local/share/yellowjacket/artist-image-cache/{mbid}.jpg).
Returns base64 data URLs, same pattern as CoverArtProxy.
First lookup: resolve URL via MB/Wikidata + fetch image (~2s).
Subsequent: instant from disk cache.
404s cached as empty files to avoid re-fetching.
2. Top results artist photos: the Top Results section now shows
artist images from the artistImageCache, same as the Artists
section. Also shows englishName in the top card display name.
This commit is contained in:
@@ -38,7 +38,9 @@ func NewExploreService(logger *slog.Logger, db *database.DB) *Service {
|
||||
lb := NewListenBrainzClient(limiter, cache, logger.WithGroup("listenbrainz"))
|
||||
index := NewSearchIndex(db, lb, logger.WithGroup("search-index"))
|
||||
artProxy := NewCoverArtProxy(db, limiter)
|
||||
artistImg := NewArtistImageProvider(cache, NewRateLimiter(), logger.WithGroup("artist-image"))
|
||||
artistImg := NewArtistImageProvider(
|
||||
db, cache, NewRateLimiter(), logger.WithGroup("artist-image"),
|
||||
)
|
||||
|
||||
logger.Info("explore service created")
|
||||
|
||||
@@ -188,12 +190,12 @@ func (e *Service) GetThumbnails(requests []ThumbnailRequest) map[string]string {
|
||||
return result
|
||||
}
|
||||
|
||||
// GetArtistImageURL returns a Wikimedia Commons thumbnail URL for
|
||||
// the given artist MBID. Resolved via MB url-rels → Wikidata P18
|
||||
// → Commons thumb URL. Cached for 30 days. Returns "" if no
|
||||
// image is available.
|
||||
// GetArtistImageURL returns a base64 data URL for the artist's
|
||||
// photo. Cached on disk — first call resolves via MB/Wikidata and
|
||||
// fetches from Wikimedia Commons, subsequent calls are instant.
|
||||
// Returns "" if no image is available.
|
||||
func (e *Service) GetArtistImageURL(artistMBID string) string {
|
||||
return e.artistImg.GetArtistImageURL(artistMBID)
|
||||
return e.artistImg.GetArtistImage(artistMBID)
|
||||
}
|
||||
|
||||
// Search concurrently queries MusicBrainz for artists, release
|
||||
|
||||
Reference in New Issue
Block a user