diff --git a/.hgtags b/.hgtags index 7fa4eb224..2d04bb17f 100644 --- a/.hgtags +++ b/.hgtags @@ -19,3 +19,6 @@ f3cd4c138c6f40dc324a23bf01c4c7d97766477e 1.0rc2 f28ea9e2ef8d39913d79dbba73db280ff0740c50 v1.1.0-beta.2 8f070ce28a7b33d8509b29a8dbe937109bbdbd21 v1.1.0-beta.3 97f04ce252332dbda013cbc478d702d54a8fc1bd v1.1.0 +b3f7b5267a2f7b46b826d087421d7f4569211240 v1.2.0 +b3f7b5267a2f7b46b826d087421d7f4569211240 v1.2.0 +ecff182221ec32a9f6549ad3ce8d2ab4c3e5568a v1.2.0 diff --git a/beetsplug/mpdupdate.py b/beetsplug/mpdupdate.py index 0360a45df..6138efca2 100644 --- a/beetsplug/mpdupdate.py +++ b/beetsplug/mpdupdate.py @@ -35,14 +35,16 @@ database_changed = False # easier. class BufferedSocket(object): """Socket abstraction that allows reading by line.""" - def __init__(self, sep='\n'): - self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + def __init__(self, host, port, sep='\n'): + if host[0] == '/': + self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + self.sock.connect(host) + else: + self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.sock.connect((host, port)) self.buf = '' self.sep = sep - def connect(self, host, port): - self.sock.connect((host, port)) - def readline(self): while self.sep not in self.buf: data = self.sock.recv(1024) @@ -67,8 +69,7 @@ def update_mpd(host='localhost', port=6600, password=None): """ print('Updating MPD database...') - s = BufferedSocket() - s.connect(host, port) + s = BufferedSocket(host, port) resp = s.readline() if 'OK MPD' not in resp: print('MPD connection failed:', repr(resp)) diff --git a/docs/changelog.rst b/docs/changelog.rst index d396a8c7a..6946745ca 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,8 +1,8 @@ Changelog ========= -1.2.0 (in development) ----------------------- +1.2.0 (June 5, 2013) +-------------------- There's a *lot* of new stuff in this release: new data sources for the autotagger, new plugins to look for problems in your library, tracking the @@ -107,6 +107,8 @@ As usual, there were also lots of other great littler enhancements: Johannes Baiter. * The :ref:`fields-cmd` command shows template fields provided by plugins. Thanks again to Pedro Silva. +* :doc:`/plugins/mpdupdate`: You can now communicate with MPD over a Unix + domain socket. Thanks to John Hawthorn. And a batch of fixes: diff --git a/docs/plugins/mpdupdate.rst b/docs/plugins/mpdupdate.rst index 492660106..dca41fd22 100644 --- a/docs/plugins/mpdupdate.rst +++ b/docs/plugins/mpdupdate.rst @@ -17,3 +17,8 @@ MPD server. You can do that using an ``mpdupdate:`` section in your password: seekrit With that all in place, you'll see beets send the "update" command to your MPD server every time you change your beets library. + +If you want to communicate with MPD over a Unix domain socket instead over +TCP, just give the path to the socket in the filesystem for the ``host`` +setting. (Any ``host`` value starting with a slash is interpreted as a domain +socket.)