diff --git a/musicbrainzngs/mbxml.py b/musicbrainzngs/mbxml.py index e85fe7c..fe4df09 100644 --- a/musicbrainzngs/mbxml.py +++ b/musicbrainzngs/mbxml.py @@ -775,10 +775,17 @@ def make_tag_request(**kwargs): e_xml = ET.SubElement(e_list, "{%s}%s" % (NS, entity_type.replace('_', '-'))) e_xml.set("{%s}id" % NS, e) taglist = ET.SubElement(e_xml, "{%s}user-tag-list" % NS) - for tag in tags: - usertag_xml = ET.SubElement(taglist, "{%s}user-tag" % NS) - name_xml = ET.SubElement(usertag_xml, "{%s}name" % NS) - name_xml.text = tag + if isinstance(tags, dict): + for tag, vote in tags.items(): + usertag_xml = ET.SubElement(taglist, "{%s}user-tag" % NS) + usertag_xml.set('vote', vote) + name_xml = ET.SubElement(usertag_xml, "{%s}name" % NS) + name_xml.text = tag + else: + for tag in tags: + usertag_xml = ET.SubElement(taglist, "{%s}user-tag" % NS) + name_xml = ET.SubElement(usertag_xml, "{%s}name" % NS) + name_xml.text = tag if kwargs.keys(): raise TypeError("make_tag_request() got an unexpected keyword argument '%s'" % kwargs.popitem()[0]) diff --git a/musicbrainzngs/musicbrainz.py b/musicbrainzngs/musicbrainz.py index 9a54fb1..d19c2db 100644 --- a/musicbrainzngs/musicbrainz.py +++ b/musicbrainzngs/musicbrainz.py @@ -1259,8 +1259,10 @@ def submit_tags(**kwargs): """Submit user tags. Takes parameters named e.g. 'artist_tags', 'recording_tags', etc., and of the form: + {entity_id1: {tag1: vote, ...}, ...} + If you don't want to vote, you can use a list of tags instead: {entity_id1: [tag1, ...], ...} - If you only have one tag for an entity you can use a string instead + If you only have one tag for an entity, you can use a string instead of a list. The user's tags for each entity will be set to that list, adding or @@ -1269,7 +1271,7 @@ def submit_tags(**kwargs): """ for k, v in kwargs.items(): for id, tags in v.items(): - kwargs[k][id] = tags if isinstance(tags, list) else [tags] + kwargs[k][id] = tags if isinstance(tags, (list, dict)) else [tags] query = mbxml.make_tag_request(**kwargs) return _do_mb_post("tag", query)