From 528aedbdfea947c8c991ec1c7b36752071e6773c Mon Sep 17 00:00:00 2001 From: ragnarlotus Date: Thu, 25 Jun 2026 22:54:43 +0200 Subject: [PATCH] fix(reorganize): include MusicBrainz release IDs --- core/library_reorganize.py | 1 + tests/test_reorganize_canonical_source.py | 24 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/core/library_reorganize.py b/core/library_reorganize.py index 574d5ee7..a7e4fa37 100644 --- a/core/library_reorganize.py +++ b/core/library_reorganize.py @@ -100,6 +100,7 @@ _ALBUM_ID_COLUMNS = { 'deezer': 'deezer_id', 'discogs': 'discogs_id', 'hydrabase': 'soul_id', + 'musicbrainz': 'musicbrainz_release_id', } # Human-facing label for each source. diff --git a/tests/test_reorganize_canonical_source.py b/tests/test_reorganize_canonical_source.py index 711638ed..bb39c436 100644 --- a/tests/test_reorganize_canonical_source.py +++ b/tests/test_reorganize_canonical_source.py @@ -73,3 +73,27 @@ def test_no_canonical_unchanged(monkeypatch): album_data = {"spotify_album_id": "sp1"} source, _, _ = lr._resolve_source(album_data, "spotify") assert source == "spotify" + + +def test_musicbrainz_release_id_is_used_by_priority_walk(monkeypatch): + _patch_fetch(monkeypatch, { + ('musicbrainz', 'mb-release-1'): [{'name': 'x'}], + }) + monkeypatch.setattr( + lr, + 'get_source_priority', + lambda primary: ['musicbrainz', 'spotify'], + ) + + album_data = { + 'musicbrainz_release_id': 'mb-release-1', + } + + source, api_album, items = lr._resolve_source( + album_data, + 'musicbrainz', + ) + + assert source == 'musicbrainz' + assert api_album == {'name': 'musicbrainz:mb-release-1'} + assert items == [{'name': 'x'}]