soulsync/tests/metadata
Broque Thomas 987409508b fix(metadata): surface MusicBrainz 'Other' release-groups in discography (#650)
S-Bryce reported that for some artists (Vocaloid producers, JP indie
acts, niche Western indie) the artist detail page was missing whole
release-groups visible on musicbrainz.org. Downloaded tracks from
those release-groups appeared in artist track counts but were not
bound to any visible album / single card — orphan "ghost" tracks the
user couldn't browse to.

Two duplicated bugs fed each other:

1. `core/musicbrainz_search.py` browsed MB release-groups with
   `release_types=['album', 'ep', 'single']`. MB's primary-type
   vocabulary is {Album, Single, EP, Broadcast, Other} — music
   videos, one-off web releases, and broadcast singles use Other.
   Pre-fix the filter dropped them at the API layer.

2. Three sites duplicated the same "raw primary-type → internal
   album_type" mapping with slightly different vocabularies and all
   silently defaulted unknown values (including 'Other') to 'album':

       core/musicbrainz_search.py  `_map_release_type`
       core/metadata/types.py      inline `{single:single, ep:ep}.get(...)`
       core/metadata/cache.py      Deezer-specific record_type guard

Letting Other through the filter without a real mapper would have
placed music videos in the Albums view alongside LPs — visually
misleading.

Fix shape:

- New `core/metadata/release_type.py` — single canonical mapper
  consumed by every provider's raw→Album projection. Knows the full
  MB vocabulary including 'other' and 'broadcast'; routes both into
  the singles bucket since they're functionally single-track
  releases. Compilation secondary-type override preserved (MB's
  canonical Greatest-Hits pattern is `primary=Album,
  secondary=[Compilation]`).

- `core/musicbrainz_search.py` `_map_release_type` becomes a thin
  alias for the new helper so the six internal call sites stay
  intact. API filter gains 'other'.

- `core/metadata/types.py` Album projection drops its inline mini-
  mapper and calls the canonical helper. Now also handles the
  compilation secondary-type override it was previously missing.

- The Deezer-specific cache.py guard stays as-is — Deezer's
  record_type vocabulary is closed (album|single|ep), not affected
  by this issue.

Verified end-to-end against MB for S-Bryce's artist (`46196b9c-affa-
4616-b53b-e967c8bd70e0`, inabakumori): pre-fix returned 22 release-
groups; post-fix returns 27, with the 5 extra all landing in the
Singles section with album_type='single' as intended.

23 new unit tests pin the mapper contract (case-insensitive primary
types, compilation secondary override, Other/Broadcast → single,
unknown → album default preserved, defensive empty/None inputs).
2 new tests in test_musicbrainz_search pin the API filter inclusion
of 'other' and the round-trip into the Singles bucket. All 516
existing metadata tests still green — refactor leaves historical
behaviour for {album, ep, single, compilation} unchanged.
2026-05-19 20:20:28 -07:00
..
test_album_mbid_cache.py Fix album MBID inconsistency: detector + persistent release-MBID cache 2026-05-03 17:16:39 -07:00
test_album_type_normalization.py Pin type='track' / type='artist' collision case for album-type normalizer 2026-05-12 21:15:58 -07:00
test_artist_resolution.py Fix Soulseek downloads losing collab artist tags 2026-05-13 22:11:20 -07:00
test_artist_source_detail.py feat: artist-detail deep linking — /artist-detail/:source/:id 2026-05-18 13:07:54 -07:00
test_artist_source_lookup.py Add amazon_id column to artists table for full source parity 2026-05-16 17:06:54 -07:00
test_build_album_info_typed_path.py Migrate album-info builders to typed Album path 2026-05-03 22:53:12 -07:00
test_deezer_cover_url_upgrade.py Deezer cover-art download: fallback to original URL on CDN refusal 2026-05-10 18:29:36 -07:00
test_deezer_search_query.py Deezer search: free-text fallback when advanced query returns 0 2026-05-10 09:16:13 -07:00
test_deezer_track_cache_validity.py Fix Deezer contributors tagging silently dropping for cache-polluted tracks 2026-05-14 11:10:51 -07:00
test_discography_filters.py Skip already-owned tracks during download discography 2026-05-12 15:10:41 -07:00
test_discography_typed_path.py Migrate discography + quality scanner to typed Album path 2026-05-04 08:12:40 -07:00
test_enrichment_events.py Drop old per-service enrichment routes after registry cutover 2026-05-01 20:43:18 -07:00
test_image_url_normalization.py Move image URL normalization into metadata helpers 2026-05-02 22:02:36 +03:00
test_metadata_album_tracks.py Move metadata helpers into package modules 2026-04-29 11:28:42 +03:00
test_metadata_artist_image.py Move metadata helpers into package modules 2026-04-29 11:28:42 +03:00
test_metadata_cache.py Move profile Spotify cache into registry 2026-04-29 12:36:37 +03:00
test_metadata_cache_batch_lookup.py Move metadata API into package 2026-04-29 08:10:18 +03:00
test_metadata_discography.py Tighten artist discography soundtrack matching 2026-05-17 22:51:38 -07:00
test_metadata_enrichment.py Preserve full release dates in audio tags 2026-05-17 23:02:41 -07:00
test_metadata_gap_filler.py Fix: maintenance findings badge inflated when scan dedup-skipped 2026-05-04 08:55:13 -07:00
test_metadata_musicmap.py Move metadata helpers into package modules 2026-04-29 11:28:42 +03:00
test_metadata_registry.py Add MusicBrainz as a metadata source 2026-05-18 18:47:13 -07:00
test_multi_artist_tag_settings.py Fix Soulseek downloads losing collab artist tags 2026-05-13 22:11:20 -07:00
test_musicbrainz_search.py fix(metadata): surface MusicBrainz 'Other' release-groups in discography (#650) 2026-05-19 20:20:28 -07:00
test_release_type.py fix(metadata): surface MusicBrainz 'Other' release-groups in discography (#650) 2026-05-19 20:20:28 -07:00
test_relevance.py Fix Deezer search relevance — issue #534 2026-05-10 08:53:42 -07:00
test_runtime_bundle.py fix post-download tagging, and enable tagging for hifi 2026-05-02 07:50:12 -06:00
test_track_number_format.py Stop writing TRCK as "6/0" when album total_tracks is unknown 2026-05-14 15:25:16 -07:00
test_typed_metadata_types.py Add MusicBrainz as a metadata source 2026-05-18 18:47:13 -07:00