mirror of
https://github.com/beetbox/beets.git
synced 2026-02-09 00:41:57 +01:00
Simplify parsing recordings
This way we only ever handle full Recording objects.
This commit is contained in:
parent
432102ebb6
commit
78d7a94041
2 changed files with 8 additions and 5 deletions
|
|
@ -789,10 +789,9 @@ class MusicBrainzPlugin(MusicBrainzAPIMixin, MetadataSourcePlugin):
|
|||
self, item: Item, artist: str, title: str
|
||||
) -> Iterable[beets.autotag.hooks.TrackInfo]:
|
||||
criteria = {"artist": artist, "recording": title, "alias": title}
|
||||
ids = (r["id"] for r in self._search_api("recording", criteria))
|
||||
|
||||
yield from filter(
|
||||
None, map(self.track_info, self._search_api("recording", criteria))
|
||||
)
|
||||
return filter(None, map(self.track_for_id, ids))
|
||||
|
||||
def album_for_id(
|
||||
self, album_id: str
|
||||
|
|
|
|||
|
|
@ -1022,7 +1022,7 @@ class TestMusicBrainzPlugin(PluginMixin):
|
|||
mbid = "d2a6f856-b553-40a0-ac54-a321e8e2da99"
|
||||
RECORDING: ClassVar[dict[str, int | str]] = {
|
||||
"title": "foo",
|
||||
"id": "bar",
|
||||
"id": "00000000-0000-0000-0000-000000000000",
|
||||
"length": 42,
|
||||
}
|
||||
|
||||
|
|
@ -1065,7 +1065,11 @@ class TestMusicBrainzPlugin(PluginMixin):
|
|||
def test_item_candidates(self, monkeypatch, mb):
|
||||
monkeypatch.setattr(
|
||||
"beetsplug._utils.musicbrainz.MusicBrainzAPI.get_json",
|
||||
lambda *_, **__: {"recordings": [self.RECORDING]},
|
||||
lambda *_, **__: {"recordings": [{"id": self.RECORDING["id"]}]},
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"beetsplug._utils.musicbrainz.MusicBrainzAPI.get_recording",
|
||||
lambda *_, **__: self.RECORDING,
|
||||
)
|
||||
|
||||
candidates = list(mb.item_candidates(Item(), "hello", "there"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue