File tree 2 files changed +15
-6
lines changed
2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -775,10 +775,17 @@ def make_tag_request(**kwargs):
775
775
e_xml = ET .SubElement (e_list , "{%s}%s" % (NS , entity_type .replace ('_' , '-' )))
776
776
e_xml .set ("{%s}id" % NS , e )
777
777
taglist = ET .SubElement (e_xml , "{%s}user-tag-list" % NS )
778
- for tag in tags :
779
- usertag_xml = ET .SubElement (taglist , "{%s}user-tag" % NS )
780
- name_xml = ET .SubElement (usertag_xml , "{%s}name" % NS )
781
- name_xml .text = tag
778
+ if isinstance (tags , dict ):
779
+ for tag , vote in tags .items ():
780
+ usertag_xml = ET .SubElement (taglist , "{%s}user-tag" % NS )
781
+ usertag_xml .set ('vote' , vote )
782
+ name_xml = ET .SubElement (usertag_xml , "{%s}name" % NS )
783
+ name_xml .text = tag
784
+ else :
785
+ for tag in tags :
786
+ usertag_xml = ET .SubElement (taglist , "{%s}user-tag" % NS )
787
+ name_xml = ET .SubElement (usertag_xml , "{%s}name" % NS )
788
+ name_xml .text = tag
782
789
if kwargs .keys ():
783
790
raise TypeError ("make_tag_request() got an unexpected keyword argument '%s'" % kwargs .popitem ()[0 ])
784
791
Original file line number Diff line number Diff line change @@ -1259,8 +1259,10 @@ def submit_tags(**kwargs):
1259
1259
"""Submit user tags.
1260
1260
Takes parameters named e.g. 'artist_tags', 'recording_tags', etc.,
1261
1261
and of the form:
1262
+ {entity_id1: {tag1: vote, ...}, ...}
1263
+ If you don't want to vote, you can use a list of tags instead:
1262
1264
{entity_id1: [tag1, ...], ...}
1263
- If you only have one tag for an entity you can use a string instead
1265
+ If you only have one tag for an entity, you can use a string instead
1264
1266
of a list.
1265
1267
1266
1268
The user's tags for each entity will be set to that list, adding or
@@ -1269,7 +1271,7 @@ def submit_tags(**kwargs):
1269
1271
"""
1270
1272
for k , v in kwargs .items ():
1271
1273
for id , tags in v .items ():
1272
- kwargs [k ][id ] = tags if isinstance (tags , list ) else [tags ]
1274
+ kwargs [k ][id ] = tags if isinstance (tags , ( list , dict ) ) else [tags ]
1273
1275
1274
1276
query = mbxml .make_tag_request (** kwargs )
1275
1277
return _do_mb_post ("tag" , query )
You can’t perform that action at this time.
0 commit comments