Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing release-relation-list field during pseudo-release lookup #4834

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion beets/autotag/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,10 @@ def _is_translation(r):

def _find_actual_release_from_pseudo_release(pseudo_rel: Dict) \
-> Optional[Dict]:
relations = pseudo_rel['release']["release-relation-list"]
try:
relations = pseudo_rel['release']["release-relation-list"]
except KeyError:
return None

# currently we only support trans(liter)ation's
translations = [r for r in relations if _is_translation(r)]
Expand Down
39 changes: 38 additions & 1 deletion test/test_mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def test_follow_pseudo_releases(self):
album = mb.album_for_id('d2a6f856-b553-40a0-ac54-a321e8e2da02')
self.assertEqual(album.country, 'COUNTRY')

def test_pseudo_releases_without_links(self):
def test_pseudo_releases_with_empty_links(self):
side_effect = [{
'release': {
'title': 'pseudo',
Expand Down Expand Up @@ -762,6 +762,43 @@ def test_pseudo_releases_without_links(self):
album = mb.album_for_id('d2a6f856-b553-40a0-ac54-a321e8e2da02')
self.assertEqual(album.country, None)

def test_pseudo_releases_without_links(self):
side_effect = [{
'release': {
'title': 'pseudo',
'id': 'd2a6f856-b553-40a0-ac54-a321e8e2da02',
'status': 'Pseudo-Release',
'medium-list': [{
'track-list': [{
'id': 'baz',
'recording': {
'title': 'translated title',
'id': 'bar',
'length': 42,
},
'position': 9,
'number': 'A1',
}],
'position': 5,
}],
'artist-credit': [{
'artist': {
'name': 'some-artist',
'id': 'some-id',
},
}],
'release-group': {
'id': 'another-id',
},
}
},
]

with mock.patch('musicbrainzngs.get_release_by_id') as gp:
gp.side_effect = side_effect
album = mb.album_for_id('d2a6f856-b553-40a0-ac54-a321e8e2da02')
self.assertEqual(album.country, None)

def test_pseudo_releases_with_unsupported_links(self):
side_effect = [
{
Expand Down