soulsync/tests/metadata
Broque Thomas c121582557 MusicBrainz genres: fall back to release then artist when recording is empty
User report: SoulSync was only pulling MusicBrainz genres from the
recording (track-level) endpoint. Most MB recordings don't carry genres
at the track level — they live on the release (album) or artist. So
the MB tier was contributing nothing to the genre merge for the
overwhelming majority of tracks.

Fix:
- Added `'genres'` to the release-detail `includes` (was missing).
- After release-detail processing, if pp['mb_genres'] is still empty,
  populate from release_detail['genres'] (sorted by count desc).
- If still empty AND artist_mbid is set, fetch artist with
  `includes=['genres']` and use those.

No extra API call when the recording (or release) already had genres —
the artist fetch only fires when both upstream tiers came back empty.

The downstream genre merge in _embed_metadata_genres is unchanged; this
just makes the MB feed into it richer.

Tests: 4 new (recording present, recording empty → release, recording
+ release empty → artist, all empty → []). Full suite 873 passing.
Ruff clean.

Reported by @kcaoyef421 in Discord.
2026-04-27 19:31:27 -07:00
..
test_artist_source_detail.py Group metadata tests under tests/metadata 2026-04-27 19:54:44 +03:00
test_artist_source_lookup.py Group metadata tests under tests/metadata 2026-04-27 19:54:44 +03:00
test_enrichment_events.py Group metadata tests under tests/metadata 2026-04-27 19:54:44 +03:00
test_metadata_cache_batch_lookup.py Group metadata tests under tests/metadata 2026-04-27 19:54:44 +03:00
test_metadata_enrichment.py MusicBrainz genres: fall back to release then artist when recording is empty 2026-04-27 19:31:27 -07:00
test_metadata_gap_filler.py Group metadata tests under tests/metadata 2026-04-27 19:54:44 +03:00
test_metadata_service_album_tracks.py Group metadata tests under tests/metadata 2026-04-27 19:54:44 +03:00
test_metadata_service_artist_image.py Group metadata tests under tests/metadata 2026-04-27 19:54:44 +03:00
test_metadata_service_cache.py Group metadata tests under tests/metadata 2026-04-27 19:54:44 +03:00
test_metadata_service_discography.py Group metadata tests under tests/metadata 2026-04-27 19:54:44 +03:00
test_metadata_service_musicmap.py Group metadata tests under tests/metadata 2026-04-27 19:54:44 +03:00
test_musicbrainz_search.py Group metadata tests under tests/metadata 2026-04-27 19:54:44 +03:00
test_runtime_bundle.py Split runtime builders into owning modules 2026-04-27 19:54:45 +03:00