refactor(server/coverart): provider interface takes ArtistRef/AlbumRef
Changes the AlbumCoverProvider and ArtistArtProvider interfaces from MBID-only string parameters to ref-struct signatures so name-based providers (Deezer, Last.fm in upcoming tasks) can act on rows without MBIDs. Today, 53 of 213 artists in the dev DB have NULL MBIDs — featured artists, remixers, and compilation contributors created from track-tag splits where the primary-artist MBID is in the file but collaborator IDs aren't. These rows are unreachable by the current MBID-only chain. Refactoring the interface unblocks future name-based providers from acting on them. TheAudioDB and MBCAA keep MBID-only behavior internally: they return ErrNotFound when ref.MBID is empty rather than attempting a name-based fallback. The MBID guard inside EnrichAlbum/EnrichArtist is removed; providers receive the ref unconditionally and decide whether they can act on it. GetAlbumWithFirstTrackPath now JOINs artists to return artist_name alongside the existing fields, supporting AlbumRef construction. No behavioral change today (only TheAudioDB + MBCAA registered, both keep MBID-only behavior). The change unblocks T3 (Deezer) and T4 (Last.fm) which can now register and act on every artist/album regardless of MBID presence. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -89,13 +89,14 @@ func (p *mbcaaProvider) Configure(s ProviderSettings) error {
|
||||
}
|
||||
|
||||
// FetchAlbumCover retrieves the 500px front cover for the given
|
||||
// release MBID. Returns ErrNotFound on 404 or ErrTransient otherwise.
|
||||
func (p *mbcaaProvider) FetchAlbumCover(ctx context.Context, mbid string) ([]byte, error) {
|
||||
// release MBID. MBCAA is MBID-only; returns ErrNotFound when
|
||||
// ref.MBID is empty. Returns ErrNotFound on 404 or ErrTransient otherwise.
|
||||
func (p *mbcaaProvider) FetchAlbumCover(ctx context.Context, ref AlbumRef) ([]byte, error) {
|
||||
if !p.enabled.Load() {
|
||||
return nil, ErrNotFound // defensive; enricher already filters on enabled
|
||||
}
|
||||
if mbid == "" {
|
||||
return nil, fmt.Errorf("coverart: empty mbid")
|
||||
if ref.MBID == "" {
|
||||
return nil, ErrNotFound // MBCAA is MBID-only
|
||||
}
|
||||
|
||||
// Rate limit guard.
|
||||
@@ -118,7 +119,7 @@ func (p *mbcaaProvider) FetchAlbumCover(ctx context.Context, mbid string) ([]byt
|
||||
p.lastCall = time.Now()
|
||||
p.mu.Unlock()
|
||||
|
||||
url := fmt.Sprintf("%s/release/%s/front-500", cfg.BaseURL, mbid)
|
||||
url := fmt.Sprintf("%s/release/%s/front-500", cfg.BaseURL, ref.MBID)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("coverart: build request: %w", err)
|
||||
@@ -147,7 +148,7 @@ func (p *mbcaaProvider) FetchAlbumCover(ctx context.Context, mbid string) ([]byt
|
||||
}
|
||||
|
||||
func (p *mbcaaProvider) TestConnection(ctx context.Context) error {
|
||||
_, err := p.FetchAlbumCover(ctx, mbcaaTestSampleMBID)
|
||||
_, err := p.FetchAlbumCover(ctx, AlbumRef{MBID: mbcaaTestSampleMBID})
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user