feat: 'In Library' badges, artist images on local pages, MBID-based Tier 3
Three features wired together: 1. 'In Library' badges on explore search results: CheckLibraryMBIDs Wails binding batch-checks which search result MBIDs exist in the local library. Green badges render on matching artist cards and album cards. 2. Artist images on local artist-details page: Local artist pages now call GetArtistMBID(name) to resolve the MBID from tags, then GetArtistImageURL(mbid) to fetch the cached Wikimedia photo. Falls back to initial-letter avatar. 3. Tier 3 search index uses direct MBIDs from tags: buildTier3Library now reads artists.mbid column (from audio tags) for direct MBID matching, falling back to name matching for untagged artists. Eliminates false matches and catches artists that name matching misses.
This commit is contained in:
@@ -24,6 +24,7 @@ type Service struct {
|
||||
index *SearchIndex
|
||||
artProxy *CoverArtProxy
|
||||
artistImg *ArtistImageProvider
|
||||
libMBID *LibraryMBIDIndex
|
||||
logger *slog.Logger
|
||||
ctx context.Context
|
||||
}
|
||||
@@ -41,6 +42,7 @@ func NewExploreService(logger *slog.Logger, db *database.DB) *Service {
|
||||
db, cache, NewRateLimiter(), logger.WithGroup("artist-image"),
|
||||
)
|
||||
index := NewSearchIndex(db, lb, artistImg, logger.WithGroup("search-index"))
|
||||
libMBID := NewLibraryMBIDIndex(db)
|
||||
|
||||
logger.Info("explore service created")
|
||||
|
||||
@@ -51,6 +53,7 @@ func NewExploreService(logger *slog.Logger, db *database.DB) *Service {
|
||||
index: index,
|
||||
artProxy: artProxy,
|
||||
artistImg: artistImg,
|
||||
libMBID: libMBID,
|
||||
logger: logger,
|
||||
ctx: context.Background(),
|
||||
}
|
||||
@@ -198,6 +201,19 @@ func (e *Service) GetArtistImageURL(artistMBID string) string {
|
||||
return e.artistImg.GetArtistImage(artistMBID)
|
||||
}
|
||||
|
||||
// CheckLibraryMBIDs returns which of the given MBIDs exist in the
|
||||
// local music library. Returns a map of MBID → entity type
|
||||
// ("artist", "release_group", "recording").
|
||||
func (e *Service) CheckLibraryMBIDs(mbids []string) map[string]string {
|
||||
return e.libMBID.CheckMBIDs(mbids)
|
||||
}
|
||||
|
||||
// GetArtistMBID returns the MusicBrainz ID for a local library
|
||||
// artist by name, or "" if not found or no MBID tagged.
|
||||
func (e *Service) GetArtistMBID(artistName string) string {
|
||||
return e.libMBID.GetArtistMBID(artistName)
|
||||
}
|
||||
|
||||
// Search concurrently queries MusicBrainz for artists, release
|
||||
// groups, and recordings matching the query, then boosts results
|
||||
// using ListenBrainz popularity data. The final score blends
|
||||
|
||||
Reference in New Issue
Block a user