feat: multi-source artist images with thumbnails + grid integration
Complete rewrite of the artist image pipeline:
STORAGE:
- Migration 16: artist_images table tracking source, URL, path,
primary flag, dimensions per image (up to 10 per artist)
- Directory structure: artist-images/{mbid[:2]}/{mbid}/ with
primary.jpg + primary_sm.jpg/_md.jpg/_lg.jpg thumbnails
- Miss marker (.miss file) prevents re-fetching artists with no image
SOURCES (priority order):
1. MusicBrainz direct image relations (Wikimedia Commons)
2. Wikidata P18 property (Wikimedia Commons)
3. Wikipedia lead image (NEW — via Wikidata sitelinks → Wikipedia API)
Each source is checked, deduplicated, and the first available
image becomes the primary with sm/md/lg thumbnail generation
(100px/200px/400px, matching cover art tier sizes).
ASSET SERVING:
- /artist-images/ path registered with Wails asset handler
- Serves files via http.FileServer from the artist-images directory
- Same pattern as /covers/ for cover art
ARTIST MODEL:
- Artist struct gains ImageSmall/ImageMedium/ImageLarge fields
- resolveArtistImages does bulk MBID lookup → disk stat for each
- Populated in GetAllArtists and GetAllArtistsByLibrary
GRID VIEW:
- artists-view uses model URLs directly (no more base64 data URLs)
- Size selection based on imageSize * devicePixelRatio (like cover-grid)
- Removed batch GetArtistImages call and in-memory cache — no longer needed
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
||||
wailsruntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
|
||||
@@ -23,6 +25,7 @@ import (
|
||||
"yellowjacket/backend/playlist"
|
||||
"yellowjacket/backend/profiling"
|
||||
"yellowjacket/backend/queue"
|
||||
"yellowjacket/backend/system"
|
||||
"yellowjacket/backend/tagwriter"
|
||||
)
|
||||
|
||||
@@ -104,6 +107,17 @@ func NewYellowJacketApp(
|
||||
|
||||
yjApp.assetHandler.RegisterHandler(coverart.PathPrefix, coverHandler)
|
||||
|
||||
// Register artist image handler for serving cached artist photos.
|
||||
artistImgDir, err := system.GetUserDataDirPath()
|
||||
if err == nil {
|
||||
artistImgHandler := http.StripPrefix(
|
||||
"/artist-images/",
|
||||
http.FileServer(http.Dir(filepath.Join(artistImgDir, "artist-images"))),
|
||||
)
|
||||
|
||||
yjApp.assetHandler.RegisterHandler("/artist-images/", artistImgHandler)
|
||||
}
|
||||
|
||||
// create playlist service
|
||||
yjApp.playlist = playlist.NewService(
|
||||
yjApp.logger, yjApp.database, yjApp.appConfig,
|
||||
|
||||
Reference in New Issue
Block a user