From 14aa3dcd5e3349b4df1d16cb197ac17742d07976 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 25 Nov 2026 22:02:00 -0500 Subject: [PATCH] chore: remove code left from acquisition and Discover suggestions, and uncalled queries Nothing reached any of it: - MusicBrainz search (artists, albums, songs), artist lookups and the query escaping they used. The release-group lookups the duplicate resolver uses stay. - Release-group covers, and artist-level tags for artists not in the library. - Nine named queries with no caller (CountTracksByArtist went with the previous commit), two of them describing request-progress reporting. The MusicBrainz client's retry and not-found tests now drive the release-group lookup. Co-Authored-By: Claude Opus 5.5 --- internal/coverart/provider.go | 8 - internal/coverart/provider_mbcaa.go | 9 -- internal/coverart/provider_mbcaa_test.go | 21 --- internal/db/dbq/albums.sql.go | 13 -- internal/db/dbq/artists.sql.go | 40 ----- internal/db/dbq/audit_log.sql.go | 38 ----- internal/db/dbq/covers.sql.go | 33 ---- internal/db/dbq/duplicates.sql.go | 17 --- internal/db/dbq/invites.sql.go | 36 ----- internal/db/dbq/password_resets.sql.go | 11 -- internal/db/dbq/system_playlists.sql.go | 30 ---- internal/db/dbq/users.sql.go | 30 ---- internal/db/queries/albums.sql | 6 - internal/db/queries/artists.sql | 3 - internal/db/queries/audit_log.sql | 5 - internal/db/queries/covers.sql | 11 -- internal/db/queries/duplicates.sql | 9 -- internal/db/queries/invites.sql | 7 - internal/db/queries/password_resets.sql | 5 - internal/db/queries/system_playlists.sql | 17 --- internal/db/queries/users.sql | 4 - internal/musicbrainz/client.go | 35 ----- internal/musicbrainz/client_test.go | 127 +--------------- internal/musicbrainz/entities.go | 185 ----------------------- internal/tags/provider.go | 25 --- internal/tags/provider_lastfm.go | 49 +----- internal/tags/provider_musicbrainz.go | 32 +--- internal/tags/settings.go | 21 --- 28 files changed, 10 insertions(+), 817 deletions(-) diff --git a/internal/coverart/provider.go b/internal/coverart/provider.go index f7b07e44..5eb75871 100644 --- a/internal/coverart/provider.go +++ b/internal/coverart/provider.go @@ -81,14 +81,6 @@ type AlbumCoverProvider interface { FetchAlbumCover(ctx context.Context, ref AlbumRef) ([]byte, error) } -// ReleaseGroupCoverProvider is an opt-in capability for sources that can -// answer by MusicBrainz release group, which is how the release catalogue -// names an album before any edition of it is held. -type ReleaseGroupCoverProvider interface { - AlbumCoverProvider - FetchReleaseGroupCover(ctx context.Context, groupMBID string) ([]byte, error) -} - // ArtistArtProvider is an opt-in capability: providers implementing // it can fetch artist images. Returns thumb + fanart atomically at // the JSON metadata step (one round-trip yields both URLs); the two diff --git a/internal/coverart/provider_mbcaa.go b/internal/coverart/provider_mbcaa.go index c05eed1b..d81079d6 100644 --- a/internal/coverart/provider_mbcaa.go +++ b/internal/coverart/provider_mbcaa.go @@ -96,13 +96,6 @@ func (p *mbcaaProvider) FetchAlbumCover(ctx context.Context, ref AlbumRef) ([]by return p.fetchFront(ctx, "release", ref.MBID) } -// FetchReleaseGroupCover retrieves the 500px front cover the Cover Art -// Archive chose for a release group: what a search result or a wanted album -// shows before any edition of it is held. -func (p *mbcaaProvider) FetchReleaseGroupCover(ctx context.Context, groupMBID string) ([]byte, error) { - return p.fetchFront(ctx, "release-group", groupMBID) -} - // fetchFront fetches /{entity}/{mbid}/front-500, honouring the rate limit. func (p *mbcaaProvider) fetchFront(ctx context.Context, entity, mbid string) ([]byte, error) { if !p.enabled.Load() { @@ -170,5 +163,3 @@ func (p *mbcaaProvider) TestConnection(ctx context.Context) error { } return err } - -var _ ReleaseGroupCoverProvider = (*mbcaaProvider)(nil) diff --git a/internal/coverart/provider_mbcaa_test.go b/internal/coverart/provider_mbcaa_test.go index 18090712..b837617e 100644 --- a/internal/coverart/provider_mbcaa_test.go +++ b/internal/coverart/provider_mbcaa_test.go @@ -166,24 +166,3 @@ func TestNewMBCAAProviderFromConfig_ReplacesRegisteredConfig(t *testing.T) { t.Errorf("cfg.UserAgent = %q, want %q", gotUA, "Minstrel/test-replaced (x)") } } - -func TestMBCAAProvider_FetchReleaseGroupCover_AsksByGroup(t *testing.T) { - var path string - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - path = r.URL.Path - _, _ = w.Write([]byte("jpeg")) - })) - defer srv.Close() - p := newMBCAAProviderForTest(t, srv.URL) - - body, err := p.FetchReleaseGroupCover(context.Background(), "rg-1") - if err != nil || string(body) != "jpeg" { - t.Fatalf("body %q, err %v", body, err) - } - if path != "/release-group/rg-1/front-500" { - t.Errorf("path = %q", path) - } - if _, err := p.FetchReleaseGroupCover(context.Background(), ""); !errors.Is(err, ErrNotFound) { - t.Errorf("no id: err = %v, want ErrNotFound", err) - } -} diff --git a/internal/db/dbq/albums.sql.go b/internal/db/dbq/albums.sql.go index 9562ce36..4dc54cc6 100644 --- a/internal/db/dbq/albums.sql.go +++ b/internal/db/dbq/albums.sql.go @@ -89,19 +89,6 @@ func (q *Queries) CountAlbums(ctx context.Context) (int64, error) { return count, err } -const countAlbumsByArtist = `-- name: CountAlbumsByArtist :one -SELECT COUNT(*) FROM albums WHERE artist_id = $1 -` - -// Used by request-progress reporting to count how many albums have been -// ingested for a matched artist while a request is still in flight. -func (q *Queries) CountAlbumsByArtist(ctx context.Context, artistID pgtype.UUID) (int64, error) { - row := q.db.QueryRow(ctx, countAlbumsByArtist, artistID) - var count int64 - err := row.Scan(&count) - return count, err -} - const countAlbumsMatching = `-- name: CountAlbumsMatching :one SELECT COUNT(*) FROM albums WHERE title ILIKE '%' || $1::text || '%' ` diff --git a/internal/db/dbq/artists.sql.go b/internal/db/dbq/artists.sql.go index 2f4f931a..4f10514e 100644 --- a/internal/db/dbq/artists.sql.go +++ b/internal/db/dbq/artists.sql.go @@ -218,46 +218,6 @@ func (q *Queries) ListArtists(ctx context.Context) ([]Artist, error) { return items, nil } -const listArtistsAlpha = `-- name: ListArtistsAlpha :many -SELECT id, name, sort_name, mbid, created_at, updated_at, artist_thumb_path, artist_fanart_path, artist_art_source, artist_art_sources_version FROM artists ORDER BY sort_name, name, id LIMIT $1 OFFSET $2 -` - -type ListArtistsAlphaParams struct { - Limit int32 - Offset int32 -} - -func (q *Queries) ListArtistsAlpha(ctx context.Context, arg ListArtistsAlphaParams) ([]Artist, error) { - rows, err := q.db.Query(ctx, listArtistsAlpha, arg.Limit, arg.Offset) - if err != nil { - return nil, err - } - defer rows.Close() - var items []Artist - for rows.Next() { - var i Artist - if err := rows.Scan( - &i.ID, - &i.Name, - &i.SortName, - &i.Mbid, - &i.CreatedAt, - &i.UpdatedAt, - &i.ArtistThumbPath, - &i.ArtistFanartPath, - &i.ArtistArtSource, - &i.ArtistArtSourcesVersion, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - const listArtistsAlphaWithCovers = `-- name: ListArtistsAlphaWithCovers :many SELECT artists.id, artists.name, artists.sort_name, artists.mbid, artists.created_at, artists.updated_at, artists.artist_thumb_path, artists.artist_fanart_path, artists.artist_art_source, artists.artist_art_sources_version, cov.id AS cover_album_id, diff --git a/internal/db/dbq/audit_log.sql.go b/internal/db/dbq/audit_log.sql.go index 873c0c4d..8c1c3f86 100644 --- a/internal/db/dbq/audit_log.sql.go +++ b/internal/db/dbq/audit_log.sql.go @@ -30,44 +30,6 @@ func (q *Queries) CountAuditLogByActions(ctx context.Context, arg CountAuditLogB return column_1, err } -const listAuditLog = `-- name: ListAuditLog :many -SELECT id, actor_id, target_id, action, metadata, created_at FROM audit_log - ORDER BY created_at DESC - LIMIT $1 OFFSET $2 -` - -type ListAuditLogParams struct { - Limit int32 - Offset int32 -} - -func (q *Queries) ListAuditLog(ctx context.Context, arg ListAuditLogParams) ([]AuditLog, error) { - rows, err := q.db.Query(ctx, listAuditLog, arg.Limit, arg.Offset) - if err != nil { - return nil, err - } - defer rows.Close() - var items []AuditLog - for rows.Next() { - var i AuditLog - if err := rows.Scan( - &i.ID, - &i.ActorID, - &i.TargetID, - &i.Action, - &i.Metadata, - &i.CreatedAt, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - const listAuditLogByActions = `-- name: ListAuditLogByActions :many SELECT id, actor_id, target_id, action, metadata, created_at FROM audit_log WHERE action = ANY($1::text[]) diff --git a/internal/db/dbq/covers.sql.go b/internal/db/dbq/covers.sql.go index ee99d700..e8af0c0a 100644 --- a/internal/db/dbq/covers.sql.go +++ b/internal/db/dbq/covers.sql.go @@ -39,39 +39,6 @@ func (q *Queries) ClearAlbumCoverNone(ctx context.Context, id pgtype.UUID) error return err } -const countAlbumCoverSources = `-- name: CountAlbumCoverSources :one -SELECT - COUNT(*) FILTER (WHERE cover_art_source IS NULL) ::bigint AS untried, - COUNT(*) FILTER (WHERE cover_art_source = 'sidecar') ::bigint AS sidecar, - COUNT(*) FILTER (WHERE cover_art_source = 'embedded')::bigint AS embedded, - COUNT(*) FILTER (WHERE cover_art_source = 'mbcaa') ::bigint AS mbcaa, - COUNT(*) FILTER (WHERE cover_art_source = 'none') ::bigint AS none - FROM albums -` - -type CountAlbumCoverSourcesRow struct { - Untried int64 - Sidecar int64 - Embedded int64 - Mbcaa int64 - None int64 -} - -// Diagnostic for the admin overview: counts by source, including NULL. -// Returns one row with named tallies. -func (q *Queries) CountAlbumCoverSources(ctx context.Context) (CountAlbumCoverSourcesRow, error) { - row := q.db.QueryRow(ctx, countAlbumCoverSources) - var i CountAlbumCoverSourcesRow - err := row.Scan( - &i.Untried, - &i.Sidecar, - &i.Embedded, - &i.Mbcaa, - &i.None, - ) - return i, err -} - const getAlbumWithFirstTrackPath = `-- name: GetAlbumWithFirstTrackPath :one SELECT a.id, a.mbid, a.title, a.cover_art_path, a.cover_art_source, ar.name AS artist_name, diff --git a/internal/db/dbq/duplicates.sql.go b/internal/db/dbq/duplicates.sql.go index 857762fa..a7f0b603 100644 --- a/internal/db/dbq/duplicates.sql.go +++ b/internal/db/dbq/duplicates.sql.go @@ -27,23 +27,6 @@ func (q *Queries) AddDuplicateGroupMember(ctx context.Context, arg AddDuplicateG return err } -const countPendingDuplicateGroups = `-- name: CountPendingDuplicateGroups :one -SELECT count(*)::bigint - FROM duplicate_groups g - WHERE g.status = 'pending' - AND (SELECT count(*) FROM duplicate_group_members m WHERE m.group_id = g.id) >= 2 -` - -// Proposals awaiting review. A group left with one member — its other tracks -// deleted since the sweep — is no proposal at all and is not counted; the next -// sweep retires it. -func (q *Queries) CountPendingDuplicateGroups(ctx context.Context) (int64, error) { - row := q.db.QueryRow(ctx, countPendingDuplicateGroups) - var column_1 int64 - err := row.Scan(&column_1) - return column_1, err -} - const countPendingDuplicateGroupsInView = `-- name: CountPendingDuplicateGroupsInView :one SELECT count(*)::bigint FROM duplicate_groups g diff --git a/internal/db/dbq/invites.sql.go b/internal/db/dbq/invites.sql.go index 9f9b9a2d..697977cf 100644 --- a/internal/db/dbq/invites.sql.go +++ b/internal/db/dbq/invites.sql.go @@ -109,42 +109,6 @@ func (q *Queries) ListInvitesActive(ctx context.Context) ([]UserInvite, error) { return items, nil } -const listInvitesAll = `-- name: ListInvitesAll :many -SELECT token, invited_by, note, created_at, expires_at, redeemed_at, redeemed_by FROM user_invites - ORDER BY created_at DESC - LIMIT $1 -` - -// Includes redeemed + expired for full audit visibility. Caller -// supplies a LIMIT to bound the response. -func (q *Queries) ListInvitesAll(ctx context.Context, limit int32) ([]UserInvite, error) { - rows, err := q.db.Query(ctx, listInvitesAll, limit) - if err != nil { - return nil, err - } - defer rows.Close() - var items []UserInvite - for rows.Next() { - var i UserInvite - if err := rows.Scan( - &i.Token, - &i.InvitedBy, - &i.Note, - &i.CreatedAt, - &i.ExpiresAt, - &i.RedeemedAt, - &i.RedeemedBy, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - const redeemInvite = `-- name: RedeemInvite :execrows UPDATE user_invites SET redeemed_at = now(), redeemed_by = $2 diff --git a/internal/db/dbq/password_resets.sql.go b/internal/db/dbq/password_resets.sql.go index 64977b7f..97e0990e 100644 --- a/internal/db/dbq/password_resets.sql.go +++ b/internal/db/dbq/password_resets.sql.go @@ -27,17 +27,6 @@ func (q *Queries) CreatePasswordReset(ctx context.Context, arg CreatePasswordRes return err } -const deleteExpiredPasswordResets = `-- name: DeleteExpiredPasswordResets :exec -DELETE FROM password_resets WHERE expires_at < now() - interval '7 days' -` - -// Cleanup: drop tokens that have been expired more than 7 days. -// Not wired in U3; useful to have for a future cron sweep. -func (q *Queries) DeleteExpiredPasswordResets(ctx context.Context) error { - _, err := q.db.Exec(ctx, deleteExpiredPasswordResets) - return err -} - const getPasswordReset = `-- name: GetPasswordReset :one SELECT token, user_id, created_at, expires_at, used_at FROM password_resets WHERE token = $1 ` diff --git a/internal/db/dbq/system_playlists.sql.go b/internal/db/dbq/system_playlists.sql.go index 439177ab..4d1ee7cc 100644 --- a/internal/db/dbq/system_playlists.sql.go +++ b/internal/db/dbq/system_playlists.sql.go @@ -412,36 +412,6 @@ func (q *Queries) PickSeedArtists(ctx context.Context, userID pgtype.UUID) ([]Pi return items, nil } -const pickTopAlbumCoverForArtistByUser = `-- name: PickTopAlbumCoverForArtistByUser :one -SELECT a.cover_art_path - FROM albums a - LEFT JOIN tracks t ON t.album_id = a.id - LEFT JOIN play_events pe - ON pe.track_id = t.id - AND pe.user_id = $1 - AND pe.was_skipped = false - WHERE a.artist_id = $2 - AND a.cover_art_path IS NOT NULL - GROUP BY a.id, a.release_date, a.cover_art_path - ORDER BY COUNT(pe.id) DESC, a.release_date DESC NULLS LAST, a.id - LIMIT 1 -` - -type PickTopAlbumCoverForArtistByUserParams struct { - UserID pgtype.UUID - ArtistID pgtype.UUID -} - -// "Songs like X" cover. Most-played album by user; tie-break by most-recent -// release. NULL if the artist has no albums or all covers are NULL. -// Note: albums uses cover_art_path (not cover_path). -func (q *Queries) PickTopAlbumCoverForArtistByUser(ctx context.Context, arg PickTopAlbumCoverForArtistByUserParams) (*string, error) { - row := q.db.QueryRow(ctx, pickTopAlbumCoverForArtistByUser, arg.UserID, arg.ArtistID) - var cover_art_path *string - err := row.Scan(&cover_art_path) - return cover_art_path, err -} - const pickTopPlayedTrackForArtistByUser = `-- name: PickTopPlayedTrackForArtistByUser :one SELECT COALESCE( (SELECT t.id diff --git a/internal/db/dbq/users.sql.go b/internal/db/dbq/users.sql.go index 5815913f..34fc4c54 100644 --- a/internal/db/dbq/users.sql.go +++ b/internal/db/dbq/users.sql.go @@ -381,36 +381,6 @@ func (q *Queries) ListActiveUsersWithTimezones(ctx context.Context) ([]ListActiv return items, nil } -const listUsernamesByIDs = `-- name: ListUsernamesByIDs :many -SELECT id, username FROM users WHERE id = ANY($1::uuid[]) -` - -type ListUsernamesByIDsRow struct { - ID pgtype.UUID - Username string -} - -// Names a list's people in one round trip. -func (q *Queries) ListUsernamesByIDs(ctx context.Context, dollar_1 []pgtype.UUID) ([]ListUsernamesByIDsRow, error) { - rows, err := q.db.Query(ctx, listUsernamesByIDs, dollar_1) - if err != nil { - return nil, err - } - defer rows.Close() - var items []ListUsernamesByIDsRow - for rows.Next() { - var i ListUsernamesByIDsRow - if err := rows.Scan(&i.ID, &i.Username); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - const listUsers = `-- name: ListUsers :many SELECT id, username, display_name, is_admin, debug_mode_enabled, created_at diff --git a/internal/db/queries/albums.sql b/internal/db/queries/albums.sql index 163138a6..8c78a585 100644 --- a/internal/db/queries/albums.sql +++ b/internal/db/queries/albums.sql @@ -205,11 +205,6 @@ LIMIT $1 OFFSET $2; -- Total album count for the /api/library/albums envelope. SELECT COUNT(*) FROM albums; --- name: CountAlbumsByArtist :one --- Used by request-progress reporting to count how many albums have been --- ingested for a matched artist while a request is still in flight. -SELECT COUNT(*) FROM albums WHERE artist_id = $1; - -- name: DeleteAlbumIfEmpty :one -- Deletes the album row only when it has no remaining tracks. -- Used after a track delete to tidy up orphaned albums. RETURNING gives @@ -304,7 +299,6 @@ UPDATE albums updated_at = now() WHERE id = $1; - -- name: GetAlbumsByIDs :many -- Batched lookup used by /api/library/sync to hydrate upsert payloads --. Mirror of GetArtistsByIDs. diff --git a/internal/db/queries/artists.sql b/internal/db/queries/artists.sql index f6e9d189..8b88adf3 100644 --- a/internal/db/queries/artists.sql +++ b/internal/db/queries/artists.sql @@ -30,9 +30,6 @@ WHERE name ILIKE '%' || $1 || '%' ORDER BY sort_name, id LIMIT $2 OFFSET $3; --- name: ListArtistsAlpha :many -SELECT * FROM artists ORDER BY sort_name, name, id LIMIT $1 OFFSET $2; - -- name: ListArtistsNewest :many -- Secondary id tiebreaker keeps pagination stable when created_at ties. SELECT * FROM artists ORDER BY created_at DESC, id DESC LIMIT $1 OFFSET $2; diff --git a/internal/db/queries/audit_log.sql b/internal/db/queries/audit_log.sql index ea699eb1..a47503bc 100644 --- a/internal/db/queries/audit_log.sql +++ b/internal/db/queries/audit_log.sql @@ -2,11 +2,6 @@ INSERT INTO audit_log (actor_id, target_id, action, metadata) VALUES ($1, $2, $3, $4); --- name: ListAuditLog :many -SELECT * FROM audit_log - ORDER BY created_at DESC - LIMIT $1 OFFSET $2; - -- name: CountAuditLogByActions :one -- System actions carry no actor; system_only narrows to them. SELECT count(*)::bigint FROM audit_log diff --git a/internal/db/queries/covers.sql b/internal/db/queries/covers.sql index ecad7846..e2a8ca86 100644 --- a/internal/db/queries/covers.sql +++ b/internal/db/queries/covers.sql @@ -59,14 +59,3 @@ UPDATE albums UPDATE albums SET cover_art_source = NULL WHERE id = $1 AND cover_art_source = 'none'; - --- name: CountAlbumCoverSources :one --- Diagnostic for the admin overview: counts by source, including NULL. --- Returns one row with named tallies. -SELECT - COUNT(*) FILTER (WHERE cover_art_source IS NULL) ::bigint AS untried, - COUNT(*) FILTER (WHERE cover_art_source = 'sidecar') ::bigint AS sidecar, - COUNT(*) FILTER (WHERE cover_art_source = 'embedded')::bigint AS embedded, - COUNT(*) FILTER (WHERE cover_art_source = 'mbcaa') ::bigint AS mbcaa, - COUNT(*) FILTER (WHERE cover_art_source = 'none') ::bigint AS none - FROM albums; diff --git a/internal/db/queries/duplicates.sql b/internal/db/queries/duplicates.sql index 8ff5dfc2..7aadcba7 100644 --- a/internal/db/queries/duplicates.sql +++ b/internal/db/queries/duplicates.sql @@ -103,15 +103,6 @@ DELETE FROM duplicate_groups g OR (SELECT s.started_at FROM duplicate_sweeps s WHERE s.id = g.last_seen_sweep_id) < (SELECT s.started_at FROM duplicate_sweeps s WHERE s.id = sqlc.arg(sweep_id))); --- name: CountPendingDuplicateGroups :one --- Proposals awaiting review. A group left with one member — its other tracks --- deleted since the sweep — is no proposal at all and is not counted; the next --- sweep retires it. -SELECT count(*)::bigint - FROM duplicate_groups g - WHERE g.status = 'pending' - AND (SELECT count(*) FROM duplicate_group_members m WHERE m.group_id = g.id) >= 2; - -- name: CountPendingDuplicateGroupsInView :one -- CountPendingDuplicateGroups narrowed to one view of the report: -- review what an admin still has to decide: every class but diff --git a/internal/db/queries/invites.sql b/internal/db/queries/invites.sql index 2ede3f45..dea66e5c 100644 --- a/internal/db/queries/invites.sql +++ b/internal/db/queries/invites.sql @@ -13,13 +13,6 @@ SELECT * FROM user_invites WHERE redeemed_at IS NULL AND expires_at > now() ORDER BY created_at DESC; --- name: ListInvitesAll :many --- Includes redeemed + expired for full audit visibility. Caller --- supplies a LIMIT to bound the response. -SELECT * FROM user_invites - ORDER BY created_at DESC - LIMIT $1; - -- name: RedeemInvite :execrows -- Atomic claim: returns rows-affected so the caller can detect -- already-redeemed / expired tokens (rows=0) versus successful claim diff --git a/internal/db/queries/password_resets.sql b/internal/db/queries/password_resets.sql index 8ff57f22..5ffc6f08 100644 --- a/internal/db/queries/password_resets.sql +++ b/internal/db/queries/password_resets.sql @@ -15,8 +15,3 @@ UPDATE password_resets WHERE token = $1 AND used_at IS NULL AND expires_at > now(); - --- name: DeleteExpiredPasswordResets :exec --- Cleanup: drop tokens that have been expired more than 7 days. --- Not wired in U3; useful to have for a future cron sweep. -DELETE FROM password_resets WHERE expires_at < now() - interval '7 days'; diff --git a/internal/db/queries/system_playlists.sql b/internal/db/queries/system_playlists.sql index 3a7ec7db..2938c17a 100644 --- a/internal/db/queries/system_playlists.sql +++ b/internal/db/queries/system_playlists.sql @@ -214,23 +214,6 @@ SELECT COALESCE( LIMIT 1) )::uuid AS id; --- name: PickTopAlbumCoverForArtistByUser :one --- "Songs like X" cover. Most-played album by user; tie-break by most-recent --- release. NULL if the artist has no albums or all covers are NULL. --- Note: albums uses cover_art_path (not cover_path). -SELECT a.cover_art_path - FROM albums a - LEFT JOIN tracks t ON t.album_id = a.id - LEFT JOIN play_events pe - ON pe.track_id = t.id - AND pe.user_id = $1 - AND pe.was_skipped = false - WHERE a.artist_id = $2 - AND a.cover_art_path IS NOT NULL - GROUP BY a.id, a.release_date, a.cover_art_path - ORDER BY COUNT(pe.id) DESC, a.release_date DESC NULLS LAST, a.id - LIMIT 1; - -- name: DeleteSystemPlaylistsForUser :exec -- Atomic-replace step. CASCADE on playlist_tracks.playlist_id handles -- the join rows. diff --git a/internal/db/queries/users.sql b/internal/db/queries/users.sql index 1c1bb2b6..abddfda3 100644 --- a/internal/db/queries/users.sql +++ b/internal/db/queries/users.sql @@ -43,10 +43,6 @@ UPDATE users SET subsonic_password = $2 WHERE id = $1; -- name: GetUserByID :one SELECT * FROM users WHERE id = $1; --- name: ListUsernamesByIDs :many --- Names a list's people in one round trip. -SELECT id, username FROM users WHERE id = ANY($1::uuid[]); - -- name: SetListenBrainzToken :exec UPDATE users SET listenbrainz_token = $2, diff --git a/internal/musicbrainz/client.go b/internal/musicbrainz/client.go index e1e53ad2..b0a25e93 100644 --- a/internal/musicbrainz/client.go +++ b/internal/musicbrainz/client.go @@ -8,7 +8,6 @@ import ( "io" "net/http" "net/url" - "strconv" "strings" "time" ) @@ -173,37 +172,3 @@ func sleep(ctx context.Context, d time.Duration) error { return nil } } - -// luceneSpecial are the characters MusicBrainz's search syntax gives meaning. -const luceneSpecial = `+-&|!(){}[]^"~*?:\/` - -// Escape makes text typed by a person safe to put in a search query, so -// "AM/FM" or "Moon O)))" searches for what was typed rather than failing to -// parse. -func Escape(s string) string { - var b strings.Builder - for _, r := range s { - if strings.ContainsRune(luceneSpecial, r) { - b.WriteByte('\\') - } - b.WriteRune(r) - } - return b.String() -} - -// fieldQuery searches each field for the escaped text. -func fieldQuery(text string, fields ...string) string { - t := Escape(strings.TrimSpace(text)) - parts := make([]string, len(fields)) - for i, f := range fields { - parts[i] = f + ":(" + t + ")" - } - return strings.Join(parts, " OR ") -} - -func searchLimit(limit int) string { - if limit <= 0 || limit > 100 { - limit = 25 - } - return strconv.Itoa(limit) -} diff --git a/internal/musicbrainz/client_test.go b/internal/musicbrainz/client_test.go index 3c0938fe..ec8597e6 100644 --- a/internal/musicbrainz/client_test.go +++ b/internal/musicbrainz/client_test.go @@ -3,10 +3,8 @@ package musicbrainz import ( "context" "errors" - "fmt" "net/http" "net/http/httptest" - "strconv" "sync/atomic" "testing" "time" @@ -17,119 +15,6 @@ func testClient(srv *httptest.Server) *Client { return &Client{BaseURL: srv.URL, Pace: &Pacer{}, Backoff: time.Millisecond} } -func TestEscape_KeepsWhatWasTyped(t *testing.T) { - for in, want := range map[string]string{ - "Signal Tower": "Signal Tower", - "AM/FM": `AM\/FM`, - "Moon O)))": `Moon O\)\)\)`, - `"Odd" Al`: `\"Odd\" Al`, - } { - if got := Escape(in); got != want { - t.Errorf("Escape(%q) = %q, want %q", in, got, want) - } - } -} - -func TestSearchReleaseGroups_AsksTitleAndArtistAndReadsCredits(t *testing.T) { - var query, agent atomic.Value - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - query.Store(r.URL.Query().Get("query")) - agent.Store(r.Header.Get("User-Agent")) - _, _ = w.Write([]byte(`{"release-groups": [{ - "id": "rg1", "title": "OK Calculator", "primary-type": "Album", "secondary-types": [], - "first-release-date": "1997-05-21", - "artist-credit": [{"name": "Signal Tower", "joinphrase": "", "artist": {"id": "a1", "name": "Signal Tower"}}] - }]}`)) - })) - defer srv.Close() - - got, err := testClient(srv).SearchReleaseGroups(context.Background(), "ok calculator", 10) - if err != nil { - t.Fatal(err) - } - if q := query.Load(); q != "releasegroup:(ok calculator) OR artist:(ok calculator)" { - t.Errorf("query = %q", q) - } - if agent.Load() != UserAgent { - t.Errorf("User-Agent = %q", agent.Load()) - } - if len(got) != 1 || got[0].MBID != "rg1" || got[0].Year() != "1997" || got[0].ArtistCredit != "Signal Tower" || got[0].ArtistMBIDs[0] != "a1" { - t.Errorf("got %+v", got) - } -} - -func TestSearchReleaseGroupsBy_AsksForBothTitleAndArtist(t *testing.T) { - var query atomic.Value - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - query.Store(r.URL.Query().Get("query")) - _, _ = w.Write([]byte(`{"release-groups": [{"id": "rg1", "title": "Highway to Nowhere", - "artist-credit": [{"name": "AM/FM", "artist": {"id": "a1"}}]}]}`)) - })) - defer srv.Close() - - got, err := testClient(srv).SearchReleaseGroupsBy(context.Background(), " AM/FM ", "Highway to Nowhere", 10) - if err != nil { - t.Fatal(err) - } - if q := query.Load(); q != `releasegroup:(Highway to Nowhere) AND artist:(AM\/FM)` { - t.Errorf("query = %q", q) - } - if len(got) != 1 || got[0].MBID != "rg1" || got[0].ArtistMBIDs[0] != "a1" { - t.Errorf("got %+v", got) - } -} - -func TestSearchRecordings_FilesASongUnderItsAlbum(t *testing.T) { - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - _, _ = w.Write([]byte(`{"recordings": [{ - "id": "rec1", "title": "Karma Patrol", "length": 264000, - "artist-credit": [{"name": "Signal Tower", "artist": {"id": "a1"}}], - "releases": [ - {"id": "r1", "status": "Official", "release-group": {"id": "rg-live", "title": "Live", "primary-type": "Album", "secondary-types": ["Live"]}}, - {"id": "r2", "status": "Official", "release-group": {"id": "rg1", "title": "OK Calculator", "primary-type": "Album"}} - ] - }]}`)) - })) - defer srv.Close() - - got, err := testClient(srv).SearchRecordings(context.Background(), "karma patrol", 5) - if err != nil { - t.Fatal(err) - } - if len(got) != 1 || got[0].ReleaseGroup.MBID != "rg1" || got[0].LengthMs != 264000 { - t.Errorf("got %+v, want it filed under the studio album", got) - } -} - -func TestArtistReleaseGroups_PagesUntilTheCount(t *testing.T) { - var calls atomic.Int32 - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - calls.Add(1) - offset, _ := strconv.Atoi(r.URL.Query().Get("offset")) - if r.URL.Query().Get("artist") != "a1" { - t.Errorf("artist = %q", r.URL.Query().Get("artist")) - } - // 3 in all, two per page. - var items string - for i := offset; i < offset+2 && i < 3; i++ { - if items != "" { - items += "," - } - items += fmt.Sprintf(`{"id": "rg%d", "title": "T%d", "primary-type": "Album"}`, i, i) - } - _, _ = fmt.Fprintf(w, `{"release-group-count": 3, "release-groups": [%s]}`, items) - })) - defer srv.Close() - - got, err := testClient(srv).ArtistReleaseGroups(context.Background(), "a1") - if err != nil { - t.Fatal(err) - } - if len(got) != 3 || calls.Load() != 2 { - t.Errorf("got %d groups in %d calls, want 3 in 2", len(got), calls.Load()) - } -} - func TestReleaseGroupReleases_ReadsMediaAndTracks(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.Query().Get("inc") != "media recordings" { @@ -171,12 +56,12 @@ func TestGet_ThrottleIsRetriedThenUnreachable(t *testing.T) { w.WriteHeader(http.StatusServiceUnavailable) return } - _, _ = w.Write([]byte(`{"artists": [{"id": "a1", "name": "Signal Tower"}]}`)) + _, _ = w.Write([]byte(`{"id": "rg1", "title": "Paper Boats"}`)) })) defer srv.Close() - got, err := testClient(srv).SearchArtists(context.Background(), "signal tower", 5) - if err != nil || len(got) != 1 || calls.Load() != 2 { + got, err := testClient(srv).ReleaseGroup(context.Background(), "rg1") + if err != nil || got.Title != "Paper Boats" || calls.Load() != 2 { t.Fatalf("a throttled first answer should be retried: %v, %+v, %d calls", err, got, calls.Load()) } @@ -184,7 +69,7 @@ func TestGet_ThrottleIsRetriedThenUnreachable(t *testing.T) { w.WriteHeader(http.StatusBadGateway) })) defer down.Close() - if _, err := testClient(down).SearchArtists(context.Background(), "x", 5); !errors.Is(err, ErrUnreachable) { + if _, err := testClient(down).ReleaseGroup(context.Background(), "rg1"); !errors.Is(err, ErrUnreachable) { t.Errorf("err = %v, want ErrUnreachable", err) } } @@ -193,13 +78,13 @@ func TestGet_NotFoundAndNoServer(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNotFound) })) - if _, err := testClient(srv).Artist(context.Background(), "nope"); !errors.Is(err, ErrNotFound) { + if _, err := testClient(srv).ReleaseGroup(context.Background(), "nope"); !errors.Is(err, ErrNotFound) { t.Errorf("err = %v, want ErrNotFound", err) } srv.Close() c := testClient(srv) c.Retries = -1 - if _, err := c.Artist(context.Background(), "a1"); !errors.Is(err, ErrUnreachable) { + if _, err := c.ReleaseGroup(context.Background(), "rg1"); !errors.Is(err, ErrUnreachable) { t.Errorf("a closed server: err = %v, want ErrUnreachable", err) } } diff --git a/internal/musicbrainz/entities.go b/internal/musicbrainz/entities.go index 7cffd525..6b7d8d9e 100644 --- a/internal/musicbrainz/entities.go +++ b/internal/musicbrainz/entities.go @@ -7,16 +7,6 @@ import ( "strings" ) -// Artist is a MusicBrainz artist. -type Artist struct { - MBID string - Name string - SortName string - Disambiguation string - Type string // Person, Group, Orchestra, …; may be empty - Country string -} - // ReleaseGroup is what a person calls an album: one work, released any // number of times. type ReleaseGroup struct { @@ -31,14 +21,6 @@ type ReleaseGroup struct { ArtistMBIDs []string } -// Year is the first release's year, or "". -func (g ReleaseGroup) Year() string { - if len(g.FirstReleaseDate) >= 4 { - return g.FirstReleaseDate[:4] - } - return "" -} - // Release is one issue of a release group: a pressing, an edition, a // digital release, each with its own track list. type Release struct { @@ -98,18 +80,6 @@ type Track struct { RecordingMBID string } -// Recording is a piece of audio, as a search returns it. -type Recording struct { - MBID string - Title string - LengthMs int - ArtistCredit string - ArtistMBIDs []string - // ReleaseGroup is the group the recording is best known from: the first - // official album it appears on, else the first release listed. - ReleaseGroup ReleaseGroup -} - // --- wire shapes --- type wireCredit struct { @@ -138,19 +108,6 @@ func credit(cs []wireCredit) (string, []string) { return b.String(), ids } -type wireArtist struct { - ID string `json:"id"` - Name string `json:"name"` - SortName string `json:"sort-name"` - Disambiguation string `json:"disambiguation"` - Type string `json:"type"` - Country string `json:"country"` -} - -func (w wireArtist) artist() Artist { - return Artist{MBID: w.ID, Name: w.Name, SortName: w.SortName, Disambiguation: w.Disambiguation, Type: w.Type, Country: w.Country} -} - type wireReleaseGroup struct { ID string `json:"id"` Title string `json:"title"` @@ -192,7 +149,6 @@ type wireRelease struct { Format string `json:"format"` Tracks []wireTrack `json:"tracks"` } `json:"media"` - ReleaseGroup *wireReleaseGroup `json:"release-group"` } func (w wireRelease) release() Release { @@ -217,149 +173,8 @@ func (w wireRelease) release() Release { return r } -// --- searches --- - -// SearchArtists finds artists by name or alias. -func (c *Client) SearchArtists(ctx context.Context, text string, limit int) ([]Artist, error) { - var resp struct { - Artists []wireArtist `json:"artists"` - } - q := url.Values{"query": {fieldQuery(text, "artist", "alias")}, "limit": {searchLimit(limit)}} - if err := c.get(ctx, "/artist", q, &resp); err != nil { - return nil, err - } - out := make([]Artist, 0, len(resp.Artists)) - for _, a := range resp.Artists { - out = append(out, a.artist()) - } - return out, nil -} - -// SearchReleaseGroups finds albums by title or by artist, so "signal tower ok -// computer" and "ok calculator" both find OK Calculator. -func (c *Client) SearchReleaseGroups(ctx context.Context, text string, limit int) ([]ReleaseGroup, error) { - var resp struct { - ReleaseGroups []wireReleaseGroup `json:"release-groups"` - } - q := url.Values{"query": {fieldQuery(text, "releasegroup", "artist")}, "limit": {searchLimit(limit)}} - if err := c.get(ctx, "/release-group", q, &resp); err != nil { - return nil, err - } - out := make([]ReleaseGroup, 0, len(resp.ReleaseGroups)) - for _, g := range resp.ReleaseGroups { - out = append(out, g.group()) - } - return out, nil -} - -// SearchReleaseGroupsBy finds an artist's albums by title: both must -// match, where SearchReleaseGroups takes either. It is for naming an album -// already in hand, not for a person's search box. -func (c *Client) SearchReleaseGroupsBy(ctx context.Context, artist, title string, limit int) ([]ReleaseGroup, error) { - var resp struct { - ReleaseGroups []wireReleaseGroup `json:"release-groups"` - } - query := "releasegroup:(" + Escape(strings.TrimSpace(title)) + ") AND artist:(" + Escape(strings.TrimSpace(artist)) + ")" - q := url.Values{"query": {query}, "limit": {searchLimit(limit)}} - if err := c.get(ctx, "/release-group", q, &resp); err != nil { - return nil, err - } - out := make([]ReleaseGroup, 0, len(resp.ReleaseGroups)) - for _, g := range resp.ReleaseGroups { - out = append(out, g.group()) - } - return out, nil -} - -// SearchRecordings finds songs by title or by artist. -func (c *Client) SearchRecordings(ctx context.Context, text string, limit int) ([]Recording, error) { - var resp struct { - Recordings []struct { - ID string `json:"id"` - Title string `json:"title"` - Length *int `json:"length"` - ArtistCredit []wireCredit `json:"artist-credit"` - Releases []wireRelease `json:"releases"` - } `json:"recordings"` - } - q := url.Values{"query": {fieldQuery(text, "recording", "artist")}, "limit": {searchLimit(limit)}} - if err := c.get(ctx, "/recording", q, &resp); err != nil { - return nil, err - } - out := make([]Recording, 0, len(resp.Recordings)) - for _, r := range resp.Recordings { - name, ids := credit(r.ArtistCredit) - rec := Recording{MBID: r.ID, Title: r.Title, ArtistCredit: name, ArtistMBIDs: ids} - if r.Length != nil { - rec.LengthMs = *r.Length - } - rec.ReleaseGroup = bestKnownFrom(r.Releases) - out = append(out, rec) - } - return out, nil -} - -// bestKnownFrom picks the release group a recording should be filed under -// in a search result: the first official album, else the first release. -func bestKnownFrom(releases []wireRelease) ReleaseGroup { - var first *wireReleaseGroup - for _, r := range releases { - if r.ReleaseGroup == nil || r.ReleaseGroup.ID == "" { - continue - } - if first == nil { - first = r.ReleaseGroup - } - if r.Status == "Official" && r.ReleaseGroup.PrimaryType == "Album" && len(r.ReleaseGroup.SecondaryTypes) == 0 { - return r.ReleaseGroup.group() - } - } - if first == nil { - return ReleaseGroup{} - } - return first.group() -} - // --- lookups and browses --- -// Artist looks one artist up by MBID. -func (c *Client) Artist(ctx context.Context, mbid string) (Artist, error) { - var w wireArtist - if err := c.get(ctx, "/artist/"+url.PathEscape(mbid), nil, &w); err != nil { - return Artist{}, err - } - if w.ID == "" { - return Artist{}, ErrBadResponse - } - return w.artist(), nil -} - -// ArtistReleaseGroups lists every release group the artist is credited on, -// paging through MusicBrainz's browse. -func (c *Client) ArtistReleaseGroups(ctx context.Context, artistMBID string) ([]ReleaseGroup, error) { - var out []ReleaseGroup - for page := 0; page < maxPages; page++ { - var resp struct { - Count int `json:"release-group-count"` - ReleaseGroups []wireReleaseGroup `json:"release-groups"` - } - q := url.Values{ - "artist": {artistMBID}, "inc": {"artist-credits"}, - "limit": {strconv.Itoa(pageSize)}, "offset": {strconv.Itoa(len(out))}, - } - if err := c.get(ctx, "/release-group", q, &resp); err != nil { - return nil, err - } - for _, g := range resp.ReleaseGroups { - out = append(out, g.group()) - } - if len(resp.ReleaseGroups) == 0 || len(out) >= resp.Count { - break - } - } - return out, nil -} - // ReleaseGroupReleases lists every release of a release group with its // media and track lists. func (c *Client) ReleaseGroupReleases(ctx context.Context, groupMBID string) ([]Release, error) { diff --git a/internal/tags/provider.go b/internal/tags/provider.go index 863d86aa..c215f860 100644 --- a/internal/tags/provider.go +++ b/internal/tags/provider.go @@ -87,31 +87,6 @@ type TrackTagProvider interface { FetchTrackTags(ctx context.Context, ref TrackRef) ([]Tag, error) } -// ArtistRef is the lookup key for artist-level tags. MBID is the artist's -// MusicBrainz ID (required by MBID-keyed providers); Name is the fallback for -// name-based providers (Last.fm). At least one must be set or every provider -// returns ErrNotFound. -type ArtistRef struct { - MBID string - Name string -} - -// ArtistTagProvider is the artist-level tag capability, used by tag-space -// Discover. Separate from TrackTagProvider, so a source can implement either -// without the other, and so the enricher can ask for the capability it needs -// rather than checking at the call site. -// -// The subject here is an artist Minstrel does NOT have locally, so there is no -// track to fall back to and no recording-level tag to prefer. -type ArtistTagProvider interface { - Provider - // FetchArtistTags returns the artist's folksonomy tags, or ErrNotFound - // (terminal — nothing upstream) / ErrTransient (retry). A disabled - // provider, or one missing a required key, returns ErrNotFound so the - // chain simply skips it. - FetchArtistTags(ctx context.Context, ref ArtistRef) ([]Tag, error) -} - // TestableProvider is an opt-in capability for the admin Test-Connection // button: answer "is my config working?" without a full enrichment cycle. type TestableProvider interface { diff --git a/internal/tags/provider_lastfm.go b/internal/tags/provider_lastfm.go index acca1e0f..e37a3eb8 100644 --- a/internal/tags/provider_lastfm.go +++ b/internal/tags/provider_lastfm.go @@ -121,50 +121,6 @@ func (p *lastfmProvider) FetchTrackTags(ctx context.Context, ref TrackRef) ([]Ta return out, nil } -// FetchArtistTags looks up an artist's top tags by name, with the MBID as an -// extra hint when present. Name-first is deliberate and the opposite -// emphasis from MusicBrainz: Last.fm's tag data is keyed on its own artist -// pages, and autocorrect resolves most spelling drift from the similarity feed. -// -// `artist.getTopTags` returns the same `toptags` envelope as -// `track.getTopTags`, so the response type and normalizer are reused as-is — -// the 0-100 popularity scale is identical. -func (p *lastfmProvider) FetchArtistTags(ctx context.Context, ref ArtistRef) ([]Tag, error) { - if !p.enabled.Load() || p.currentKey() == "" { - return nil, ErrNotFound - } - if ref.Name == "" { - return nil, ErrNotFound - } - - q := url.Values{ - "method": {"artist.gettoptags"}, - "api_key": {p.currentKey()}, - "format": {"json"}, - "artist": {ref.Name}, - "autocorrect": {"1"}, - } - if ref.MBID != "" { - q.Set("mbid", ref.MBID) - } - - var resp lastfmTopTags - if err := p.client.getJSON(ctx, lastfmBaseURL+"?"+q.Encode(), &resp); err != nil { - return nil, err - } - if resp.Error != 0 { - if lastfmTransientErrors[resp.Error] { - return nil, ErrTransient - } - return nil, ErrNotFound - } - out := normalizeLastfmTags(resp.TopTags.Tag) - if len(out) == 0 { - return nil, ErrNotFound - } - return out, nil -} - // TestConnection verifies the key against a well-known track. func (p *lastfmProvider) TestConnection(ctx context.Context) error { if p.currentKey() == "" { @@ -207,7 +163,6 @@ func normalizeLastfmTags(raw []lastfmTag) []Tag { // Compile-time capability checks. var ( - _ TrackTagProvider = (*lastfmProvider)(nil) - _ ArtistTagProvider = (*lastfmProvider)(nil) - _ TestableProvider = (*lastfmProvider)(nil) + _ TrackTagProvider = (*lastfmProvider)(nil) + _ TestableProvider = (*lastfmProvider)(nil) ) diff --git a/internal/tags/provider_musicbrainz.go b/internal/tags/provider_musicbrainz.go index a3cc6912..e42450b0 100644 --- a/internal/tags/provider_musicbrainz.go +++ b/internal/tags/provider_musicbrainz.go @@ -98,33 +98,6 @@ func (p *musicbrainzProvider) FetchTrackTags(ctx context.Context, ref TrackRef) return nil, ErrNotFound } -// FetchArtistTags looks up an artist's own tags by MBID. MBID-only: -// MusicBrainz has no name-based tag lookup worth trusting for this, and a -// wrong-artist match would poison the tag cache silently. -// -// Note the scale is 1.0, NOT artistTagWeightFactor. That discount exists -// because FetchTrackTags uses artist tags as a *proxy* for a track's tags, and -// the artist's overall character is the coarser signal of the two. Here the -// artist IS the subject, so there is nothing to discount relative to — and -// applying it would make these weights incomparable with track_tags, which is -// the comparison tag-space Discover depends on. -func (p *musicbrainzProvider) FetchArtistTags(ctx context.Context, ref ArtistRef) ([]Tag, error) { - if !p.enabled.Load() || ref.MBID == "" { - return nil, ErrNotFound - } - tags, err := p.fetchEntityTags(ctx, "artist", ref.MBID, 1.0) - if err != nil { - return nil, err - } - // fetchEntityTags reports an existing-but-untagged entity as (empty, nil) - // so FetchTrackTags can fall through to the next level. There is no next - // level here, so empty is the terminal "nothing upstream". - if len(tags) == 0 { - return nil, ErrNotFound - } - return tags, nil -} - // fetchEntityTags loads folksonomy tags for a MusicBrainz entity ("recording" // or "artist") by MBID and scales the normalized weights by `scale`. Returns // an empty slice (not ErrNotFound) when the entity exists but is untagged, so @@ -182,7 +155,6 @@ func normalizeMBTags(raw []mbTag) []Tag { // Compile-time capability checks. var ( - _ TrackTagProvider = (*musicbrainzProvider)(nil) - _ ArtistTagProvider = (*musicbrainzProvider)(nil) - _ TestableProvider = (*musicbrainzProvider)(nil) + _ TrackTagProvider = (*musicbrainzProvider)(nil) + _ TestableProvider = (*musicbrainzProvider)(nil) ) diff --git a/internal/tags/settings.go b/internal/tags/settings.go index c3f68b8b..a63c40d9 100644 --- a/internal/tags/settings.go +++ b/internal/tags/settings.go @@ -136,27 +136,6 @@ func (s *SettingsService) EnabledTrackTagProviders() []TrackTagProvider { return out } -// EnabledArtistTagProviders returns the enabled providers implementing -// ArtistTagProvider, in registration order. Snapshot — do not mutate. -// -// Separate from EnabledTrackTagProviders rather than one call with a capability -// argument: the two chains are consumed by different drains, and a provider may -// implement one capability without the other. -func (s *SettingsService) EnabledArtistTagProviders() []ArtistTagProvider { - s.mu.RLock() - defer s.mu.RUnlock() - var out []ArtistTagProvider - for _, p := range AllProviders() { - if !s.enabledIDs[p.ID()] { - continue - } - if ap, ok := p.(ArtistTagProvider); ok { - out = append(out, ap) - } - } - return out -} - // CurrentVersion returns the version the enricher stamps onto rows. func (s *SettingsService) CurrentVersion() int32 { s.mu.RLock()