mirror of
https://github.com/beetbox/beets.git
synced 2025-12-08 01:23:09 +01:00
sync with latest python-musicbrainz-ngs, fixing Unicode queries (#257)
This commit is contained in:
parent
314ce88f39
commit
256cbf9fd5
3 changed files with 16 additions and 12 deletions
|
|
@ -1,8 +1,3 @@
|
|||
# This is a copy of changeset e60b5af77 from the python-musicbrainz-ngs
|
||||
# project:
|
||||
# https://github.com/alastair/python-musicbrainz-ngs/
|
||||
# MIT license; by Alastair Porter and Adrian Sampson
|
||||
|
||||
import urlparse
|
||||
import urllib2
|
||||
import urllib
|
||||
|
|
@ -12,6 +7,7 @@ import time
|
|||
import logging
|
||||
import httplib
|
||||
import xml.etree.ElementTree as etree
|
||||
from xml.parsers import expat
|
||||
|
||||
from . import mbxml
|
||||
|
||||
|
|
@ -378,6 +374,13 @@ def _safe_open(opener, req, body=None, max_retries=8, retry_delay_delta=2.0):
|
|||
# Out of retries!
|
||||
raise NetworkError("retried %i times" % max_retries, last_exc)
|
||||
|
||||
# Get the XML parsing exceptions to catch. The behavior chnaged with Python 2.7
|
||||
# and ElementTree 1.3.
|
||||
if hasattr(etree, 'ParseError'):
|
||||
ETREE_EXCEPTIONS = (etree.ParseError, expat.ExpatError)
|
||||
else:
|
||||
ETREE_EXCEPTIONS = (expat.ExpatError)
|
||||
|
||||
@_rate_limit
|
||||
def _mb_request(path, method='GET', auth_required=False, client_required=False,
|
||||
args=None, data=None, body=None):
|
||||
|
|
@ -396,6 +399,11 @@ def _mb_request(path, method='GET', auth_required=False, client_required=False,
|
|||
elif client_required:
|
||||
args["client"] = _client
|
||||
|
||||
# Encode Unicode arguments using UTF-8.
|
||||
for key, value in args.items():
|
||||
if isinstance(value, unicode):
|
||||
args[key] = value.encode('utf8')
|
||||
|
||||
# Construct the full URL for the request, including hostname and
|
||||
# query string.
|
||||
url = urlparse.urlunparse((
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@ import xml.etree.ElementTree as ET
|
|||
import string
|
||||
import StringIO
|
||||
import logging
|
||||
|
||||
_log = logging.getLogger('python-musicbrainz-ngs')
|
||||
|
||||
try:
|
||||
from ET import fixtag
|
||||
except:
|
||||
|
|
@ -28,6 +25,7 @@ except:
|
|||
return "%s:%s" % (prefix, tag), xmlns
|
||||
|
||||
NS_MAP = {"http://musicbrainz.org/ns/mmd-2.0#": "ws2"}
|
||||
_log = logging.getLogger("python-musicbrainz-ngs")
|
||||
|
||||
def make_artist_credit(artists):
|
||||
names = []
|
||||
|
|
@ -158,10 +156,8 @@ def parse_collection_release_list(rl):
|
|||
|
||||
def parse_artist_lifespan(lifespan):
|
||||
parts = parse_elements(["begin", "end"], lifespan)
|
||||
beginval = parts.get("begin", "")
|
||||
endval = parts.get("end", "")
|
||||
|
||||
return (beginval, endval)
|
||||
|
||||
return parts
|
||||
|
||||
def parse_artist_list(al):
|
||||
return [parse_artist(a) for a in al]
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in a new issue