Update beets to 1.4.7

Also updates:
- colorama-0.4.1
- jellyfish-0.6.1
- munkres-1.0.12
- musicbrainzngs-0.6
- mutagen-1.41.1
- pyyaml-3.13
- six-1.12.0
- unidecode-1.0.23
This commit is contained in:
Labrys of Knossos 2018-12-15 00:52:11 -05:00
commit e854005ae1
193 changed files with 15896 additions and 6384 deletions

View file

@ -27,6 +27,7 @@ from beets.plugins import BeetsPlugin
import os
import socket
from beets import config
import six
# No need to introduce a dependency on an MPD library for such a
@ -34,14 +35,14 @@ from beets import config
# easier.
class BufferedSocket(object):
"""Socket abstraction that allows reading by line."""
def __init__(self, host, port, sep='\n'):
def __init__(self, host, port, sep=b'\n'):
if host[0] in ['/', '~']:
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.sock.connect(os.path.expanduser(host))
else:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((host, port))
self.buf = ''
self.buf = b''
self.sep = sep
def readline(self):
@ -50,11 +51,11 @@ class BufferedSocket(object):
if not data:
break
self.buf += data
if '\n' in self.buf:
if self.sep in self.buf:
res, self.buf = self.buf.split(self.sep, 1)
return res + self.sep
else:
return ''
return b''
def send(self, data):
self.sock.send(data)
@ -67,7 +68,7 @@ class MPDUpdatePlugin(BeetsPlugin):
def __init__(self):
super(MPDUpdatePlugin, self).__init__()
config['mpd'].add({
'host': u'localhost',
'host': os.environ.get('MPD_HOST', u'localhost'),
'port': 6600,
'password': u'',
})
@ -86,9 +87,9 @@ class MPDUpdatePlugin(BeetsPlugin):
def update(self, lib):
self.update_mpd(
config['mpd']['host'].get(unicode),
config['mpd']['host'].as_str(),
config['mpd']['port'].get(int),
config['mpd']['password'].get(unicode),
config['mpd']['password'].as_str(),
)
def update_mpd(self, host='localhost', port=6600, password=None):
@ -101,28 +102,28 @@ class MPDUpdatePlugin(BeetsPlugin):
s = BufferedSocket(host, port)
except socket.error as e:
self._log.warning(u'MPD connection failed: {0}',
unicode(e.strerror))
six.text_type(e.strerror))
return
resp = s.readline()
if 'OK MPD' not in resp:
if b'OK MPD' not in resp:
self._log.warning(u'MPD connection failed: {0!r}', resp)
return
if password:
s.send('password "%s"\n' % password)
s.send(b'password "%s"\n' % password.encode('utf8'))
resp = s.readline()
if 'OK' not in resp:
if b'OK' not in resp:
self._log.warning(u'Authentication failed: {0!r}', resp)
s.send('close\n')
s.send(b'close\n')
s.close()
return
s.send('update\n')
s.send(b'update\n')
resp = s.readline()
if 'updating_db' not in resp:
if b'updating_db' not in resp:
self._log.warning(u'Update failed: {0!r}', resp)
s.send('close\n')
s.send(b'close\n')
s.close()
self._log.info(u'Database updated.')