From b68be38d9d8c471c4c16610e726873cad6be3a4a Mon Sep 17 00:00:00 2001 From: Alastair Porter Date: Sun, 16 Jan 2022 19:11:16 +0100 Subject: [PATCH] Add annotation as a valid inc for browse methods Also add to lookup event, and parse them in events Fixes #251 Signed-off-by: Alastair Porter --- musicbrainzngs/mbxml.py | 3 ++- musicbrainzngs/musicbrainz.py | 21 ++++++++++--------- ...2a4e-4d10-a46a-e9e041da8eb3-annotation.xml | 4 ++++ test/test_mbxml_artist.py | 4 ++++ 4 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 test/data/artist/0383dadf-2a4e-4d10-a46a-e9e041da8eb3-annotation.xml diff --git a/musicbrainzngs/mbxml.py b/musicbrainzngs/mbxml.py index e85fe7cb..e47859a3 100644 --- a/musicbrainzngs/mbxml.py +++ b/musicbrainzngs/mbxml.py @@ -295,7 +295,8 @@ def parse_event(event): "alias-list": parse_alias_list, "tag-list": parse_tag_list, "user-tag-list": parse_tag_list, - "rating": parse_rating} + "rating": parse_rating, + "annotation": parse_annotation} result.update(parse_attributes(attribs, event)) result.update(parse_elements(elements, inner_els, event)) diff --git a/musicbrainzngs/musicbrainz.py b/musicbrainzngs/musicbrainz.py index 7e5c2ad6..8a5230e3 100644 --- a/musicbrainzngs/musicbrainz.py +++ b/musicbrainzngs/musicbrainz.py @@ -50,8 +50,8 @@ "discids", "media", "aliases", "annotation" ] + RELATION_INCLUDES + TAG_INCLUDES + RATING_INCLUDES, - 'place' : ["aliases", "annotation"] + RELATION_INCLUDES + TAG_INCLUDES, - 'event' : ["aliases"] + RELATION_INCLUDES + TAG_INCLUDES + RATING_INCLUDES, + 'place': ["aliases", "annotation"] + RELATION_INCLUDES + TAG_INCLUDES, + 'event': ["aliases", "annotation"] + RELATION_INCLUDES + TAG_INCLUDES + RATING_INCLUDES, 'recording': [ "artists", "releases", # Subqueries "discids", "media", "artist-credits", "isrcs", @@ -83,16 +83,17 @@ 'collection': ['releases'], } VALID_BROWSE_INCLUDES = { - 'artist': ["aliases"] + TAG_INCLUDES + RATING_INCLUDES + RELATION_INCLUDES, - 'event': ["aliases"] + TAG_INCLUDES + RATING_INCLUDES + RELATION_INCLUDES, - 'label': ["aliases"] + TAG_INCLUDES + RATING_INCLUDES + RELATION_INCLUDES, - 'recording': ["artist-credits", "isrcs", "work-level-rels"] + TAG_INCLUDES + RATING_INCLUDES + RELATION_INCLUDES, - 'release': ["artist-credits", "labels", "recordings", "isrcs", + 'artist': ["annotation", "aliases"] + TAG_INCLUDES + RATING_INCLUDES + RELATION_INCLUDES, + 'event': ["annotation", "aliases"] + TAG_INCLUDES + RATING_INCLUDES + RELATION_INCLUDES, + 'label': ["annotation", "aliases"] + TAG_INCLUDES + RATING_INCLUDES + RELATION_INCLUDES, + 'recording': ["annotation", "artist-credits", "isrcs", + "work-level-rels"] + TAG_INCLUDES + RATING_INCLUDES + RELATION_INCLUDES, + 'release': ["annotation", "artist-credits", "labels", "recordings", "isrcs", "release-groups", "media", "discids"] + RELATION_INCLUDES, - 'place': ["aliases"] + TAG_INCLUDES + RELATION_INCLUDES, - 'release-group': ["artist-credits"] + TAG_INCLUDES + RATING_INCLUDES + RELATION_INCLUDES, + 'place': ["annotation", "aliases"] + TAG_INCLUDES + RELATION_INCLUDES, + 'release-group': ["annotation", "artist-credits"] + TAG_INCLUDES + RATING_INCLUDES + RELATION_INCLUDES, 'url': RELATION_INCLUDES, - 'work': ["aliases", "annotation"] + TAG_INCLUDES + RATING_INCLUDES + RELATION_INCLUDES, + 'work': ["annotation", "aliases", "annotation"] + TAG_INCLUDES + RATING_INCLUDES + RELATION_INCLUDES, } #: These can be used to filter whenever releases are includes or browsed diff --git a/test/data/artist/0383dadf-2a4e-4d10-a46a-e9e041da8eb3-annotation.xml b/test/data/artist/0383dadf-2a4e-4d10-a46a-e9e041da8eb3-annotation.xml new file mode 100644 index 00000000..777f1632 --- /dev/null +++ b/test/data/artist/0383dadf-2a4e-4d10-a46a-e9e041da8eb3-annotation.xml @@ -0,0 +1,4 @@ + +QueenQueen'''Note:''' Please add any 2011 Remaster releases to either ''Universal Island Records'' or ''Hollywood Records'' and '''not''' '''''Island Records'''''. Any previously added releases which fall under this category should be edited. +---- +See also [artist:9dcffd99-eca6-4a09-8dbd-c6c4ed2f20fd|Queen + Paul Rodgers] and [artist:7e07a487-5438-4128-b2d0-f0f18ac08384|Queen + Adam Lambert] for released from Brian May and Roger Taylor collaborating with other singers.UK rock group0000000115265309GBUnited KingdomUnited KingdomGBLondonLondonGreater London, which includes the City of London1970-06-27 diff --git a/test/test_mbxml_artist.py b/test/test_mbxml_artist.py index 8cded147..e8f25c30 100644 --- a/test/test_mbxml_artist.py +++ b/test/test_mbxml_artist.py @@ -31,3 +31,7 @@ def testArtistTargets(self): res = _common.open_and_parse_test_data(self.datadir, "b3785a55-2cf6-497d-b8e3-cfa21a36f997-artist-rels.xml") self.assertTrue('target-credit' in res['artist']['artist-relation-list'][0]) self.assertEqual(res['artist']['artist-relation-list'][0]["target-credit"], "TAO") + + def testArtistAnnotation(self): + res = _common.open_and_parse_test_data(self.datadir, "0383dadf-2a4e-4d10-a46a-e9e041da8eb3-annotation.xml") + self.assertTrue('Please add any 2011 Remaster releases' in res['artist']['annotation']['text'])