mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
mpdstats: Fix Python 3 compatibility (fix #2405)
We previously needed a hack to get the client to consume and produce Unicode strings. The library has since added Unicode support, behind a constructor flag. We can remove the hack now, which was causing a crash on Python 3 because the library uses Unicode by default there, and instead use its built-in support.
This commit is contained in:
parent
c21f456f03
commit
ca904a9d0c
3 changed files with 4 additions and 16 deletions
|
|
@ -46,20 +46,6 @@ def is_url(path):
|
||||||
return path.split('://', 1)[0] in ['http', 'https']
|
return path.split('://', 1)[0] in ['http', 'https']
|
||||||
|
|
||||||
|
|
||||||
# Use the MPDClient internals to get unicode.
|
|
||||||
# see http://www.tarmack.eu/code/mpdunicode.py for the general idea
|
|
||||||
class MPDClient(mpd.MPDClient):
|
|
||||||
def _write_command(self, command, args=[]):
|
|
||||||
args = [six.text_type(arg).encode('utf-8') for arg in args]
|
|
||||||
super(MPDClient, self)._write_command(command, args)
|
|
||||||
|
|
||||||
def _read_line(self):
|
|
||||||
line = super(MPDClient, self)._read_line()
|
|
||||||
if line is not None:
|
|
||||||
return line.decode('utf-8')
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class MPDClientWrapper(object):
|
class MPDClientWrapper(object):
|
||||||
def __init__(self, log):
|
def __init__(self, log):
|
||||||
self._log = log
|
self._log = log
|
||||||
|
|
@ -67,7 +53,7 @@ class MPDClientWrapper(object):
|
||||||
self.music_directory = (
|
self.music_directory = (
|
||||||
mpd_config['music_directory'].as_str())
|
mpd_config['music_directory'].as_str())
|
||||||
|
|
||||||
self.client = MPDClient()
|
self.client = mpd.MPDClient(use_unicode=True)
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
"""Connect to the MPD.
|
"""Connect to the MPD.
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ Fixes:
|
||||||
* :doc:`/plugins/replaygain`: Fix Python 3 compatibility in the ``bs1770gain``
|
* :doc:`/plugins/replaygain`: Fix Python 3 compatibility in the ``bs1770gain``
|
||||||
backend. :bug:`2382`
|
backend. :bug:`2382`
|
||||||
* :doc:`/plugins/bpd`: Report playback times as integer. :bug:`2394`
|
* :doc:`/plugins/bpd`: Report playback times as integer. :bug:`2394`
|
||||||
|
* :doc:`/plugins/mpdstats`: Fix Python 3 compatibility. The plugin also now
|
||||||
|
requires version 0.4.2 or later of the ``python-mpd2`` library. :bug:`2405`
|
||||||
|
|
||||||
|
|
||||||
1.4.3 (January 9, 2017)
|
1.4.3 (January 9, 2017)
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -117,7 +117,7 @@ setup(
|
||||||
'discogs': ['discogs-client>=2.1.0'],
|
'discogs': ['discogs-client>=2.1.0'],
|
||||||
'beatport': ['requests-oauthlib>=0.6.1'],
|
'beatport': ['requests-oauthlib>=0.6.1'],
|
||||||
'lastgenre': ['pylast'],
|
'lastgenre': ['pylast'],
|
||||||
'mpdstats': ['python-mpd2'],
|
'mpdstats': ['python-mpd2>=0.4.2'],
|
||||||
'web': ['flask', 'flask-cors'],
|
'web': ['flask', 'flask-cors'],
|
||||||
'import': ['rarfile'],
|
'import': ['rarfile'],
|
||||||
'thumbnails': ['pyxdg'] +
|
'thumbnails': ['pyxdg'] +
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue