Skip to content

Commit

Permalink
Add annotation as a valid inc for browse methods
Browse files Browse the repository at this point in the history
Also add to lookup event, and parse them in events
Fixes #251

Signed-off-by: Alastair Porter <[email protected]>
  • Loading branch information
alastair committed Jan 16, 2022
1 parent 1638c62 commit b68be38
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
3 changes: 2 additions & 1 deletion musicbrainzngs/mbxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
21 changes: 11 additions & 10 deletions musicbrainzngs/musicbrainz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><artist id="0383dadf-2a4e-4d10-a46a-e9e041da8eb3" type="Group" type-id="e431f5f6-b5d2-343d-8b36-72607fffb74b"><name>Queen</name><sort-name>Queen</sort-name><annotation><text>'''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.</text></annotation><disambiguation>UK rock group</disambiguation><isni-list><isni>0000000115265309</isni></isni-list><country>GB</country><area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed"><name>United Kingdom</name><sort-name>United Kingdom</sort-name><iso-3166-1-code-list><iso-3166-1-code>GB</iso-3166-1-code></iso-3166-1-code-list></area><begin-area id="f03d09b3-39dc-4083-afd6-159e3f0d462f"><name>London</name><sort-name>London</sort-name><disambiguation>Greater London, which includes the City of London</disambiguation></begin-area><life-span><begin>1970-06-27</begin></life-span></artist></metadata>
4 changes: 4 additions & 0 deletions test/test_mbxml_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])

0 comments on commit b68be38

Please sign in to comment.