mirror of
https://github.com/beetbox/beets.git
synced 2025-12-07 09:04:33 +01:00
Fix #1656, maybe: encode Discogs token strings
This commit is contained in:
parent
f4a617e641
commit
f784cd1a22
2 changed files with 9 additions and 6 deletions
|
|
@ -39,7 +39,8 @@ import os
|
||||||
urllib3_logger = logging.getLogger('requests.packages.urllib3')
|
urllib3_logger = logging.getLogger('requests.packages.urllib3')
|
||||||
urllib3_logger.setLevel(logging.CRITICAL)
|
urllib3_logger.setLevel(logging.CRITICAL)
|
||||||
|
|
||||||
USER_AGENT = u'beets/{0} +http://beets.radbox.org/'.format(beets.__version__)
|
USER_AGENT = 'beets/{0} +http://beets.radbox.org/'.format(beets.__version__) \
|
||||||
|
.encode('utf8')
|
||||||
|
|
||||||
# Exceptions that discogs_client should really handle but does not.
|
# Exceptions that discogs_client should really handle but does not.
|
||||||
CONNECTION_ERRORS = (ConnectionError, socket.error, httplib.HTTPException,
|
CONNECTION_ERRORS = (ConnectionError, socket.error, httplib.HTTPException,
|
||||||
|
|
@ -65,8 +66,8 @@ class DiscogsPlugin(BeetsPlugin):
|
||||||
def setup(self, session=None):
|
def setup(self, session=None):
|
||||||
"""Create the `discogs_client` field. Authenticate if necessary.
|
"""Create the `discogs_client` field. Authenticate if necessary.
|
||||||
"""
|
"""
|
||||||
c_key = self.config['apikey'].get(unicode)
|
c_key = self.config['apikey'].get(unicode).encode('utf8')
|
||||||
c_secret = self.config['apisecret'].get(unicode)
|
c_secret = self.config['apisecret'].get(unicode).encode('utf8')
|
||||||
|
|
||||||
# Get the OAuth token from a file or log in.
|
# Get the OAuth token from a file or log in.
|
||||||
try:
|
try:
|
||||||
|
|
@ -76,8 +77,8 @@ class DiscogsPlugin(BeetsPlugin):
|
||||||
# No token yet. Generate one.
|
# No token yet. Generate one.
|
||||||
token, secret = self.authenticate(c_key, c_secret)
|
token, secret = self.authenticate(c_key, c_secret)
|
||||||
else:
|
else:
|
||||||
token = tokendata['token']
|
token = tokendata['token'].encode('utf8')
|
||||||
secret = tokendata['secret']
|
secret = tokendata['secret'].encode('utf8')
|
||||||
|
|
||||||
self.discogs_client = Client(USER_AGENT, c_key, c_secret,
|
self.discogs_client = Client(USER_AGENT, c_key, c_secret,
|
||||||
token, secret)
|
token, secret)
|
||||||
|
|
@ -120,7 +121,7 @@ class DiscogsPlugin(BeetsPlugin):
|
||||||
with open(self._tokenfile(), 'w') as f:
|
with open(self._tokenfile(), 'w') as f:
|
||||||
json.dump({'token': token, 'secret': secret}, f)
|
json.dump({'token': token, 'secret': secret}, f)
|
||||||
|
|
||||||
return token, secret
|
return token.encode('utf8'), secret.encode('utf8')
|
||||||
|
|
||||||
def album_distance(self, items, album_info, mapping):
|
def album_distance(self, items, album_info, mapping):
|
||||||
"""Returns the album distance.
|
"""Returns the album distance.
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ Fixes:
|
||||||
|
|
||||||
* :doc:`/plugins/plexupdate`: Fix a crash when Plex libraries use non-ASCII
|
* :doc:`/plugins/plexupdate`: Fix a crash when Plex libraries use non-ASCII
|
||||||
collection names. :bug:`1649`
|
collection names. :bug:`1649`
|
||||||
|
* :doc:`/plugins/discogs`: Maybe fix a crash when using some versions of the
|
||||||
|
``requests`` library. :bug:`1656`
|
||||||
|
|
||||||
|
|
||||||
1.3.15 (October 17, 2015)
|
1.3.15 (October 17, 2015)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue