From 1bf8ae0a01ba39691c25a13dd56028dc2ea588d5 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 5 Jun 2013 12:17:49 -0700 Subject: [PATCH 1/8] mpdupdate: Allow UNIX domain socket for MPD server If the host configuration begins with a '/', it is assumed to reference a UNIX domain socket. This is similar to libmpdclient's behaviour. --- beetsplug/mpdupdate.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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)) From 11e8c3e784c405c4cad9edd9ce2b2a781469360c Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Wed, 5 Jun 2013 18:43:47 -0700 Subject: [PATCH 2/8] mpdupdate domain sockets (#313): changelog/docs --- docs/changelog.rst | 2 ++ docs/plugins/mpdupdate.rst | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 9aa62d548..3c979c070 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -97,6 +97,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.) From 78187cfcbaa34e835d861a9d3fa220845745c065 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Wed, 5 Jun 2013 20:00:17 -0700 Subject: [PATCH 3/8] preferred_media: null default, expand docs Setting the default preferred_media to null is more like previous versions. This way, as digital becomes more popular, we aren't stuck with a default configuration that prefers an outdated format. --- beets/autotag/match.py | 19 ++++++++++--------- beets/config_default.yaml | 2 +- docs/changelog.rst | 5 ++--- docs/reference/config.rst | 9 ++++++--- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 8935165f3..0e3d2ad13 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -274,15 +274,16 @@ def distance(items, album_info, mapping): dist_max += weights['year'].as_number() # Actual or preferred media. - preferred_media = config['match']['preferred_media'].get() - if likelies['media'] and album_info.media: - dist += string_dist(likelies['media'], album_info.media) * \ - weights['media'].as_number() - dist_max += weights['media'].as_number() - elif album_info.media and preferred_media: - dist += string_dist(album_info.media, preferred_media) * \ - weights['media'].as_number() - dist_max += weights['media'].as_number() + if album_info.media: + preferred_media = config['match']['preferred_media'].get() + if likelies['media']: + dist += string_dist(likelies['media'], album_info.media) * \ + weights['media'].as_number() + dist_max += weights['media'].as_number() + elif preferred_media: + dist += string_dist(album_info.media, preferred_media) * \ + weights['media'].as_number() + dist_max += weights['media'].as_number() # MusicBrainz album ID. if likelies['mb_albumid']: diff --git a/beets/config_default.yaml b/beets/config_default.yaml index 7bbb16a6b..30b7bdac5 100644 --- a/beets/config_default.yaml +++ b/beets/config_default.yaml @@ -72,7 +72,7 @@ match: partial: medium tracklength: strong tracknumber: strong - preferred_media: CD + preferred_media: null weight: source: 2.0 artist: 3.0 diff --git a/docs/changelog.rst b/docs/changelog.rst index 3c979c070..364c7f029 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -66,9 +66,8 @@ same MusicBrainz release group: beets re-identify the same release when re-importing existing files. * Prefer releases that are closest to the tagged ``year``. Tolerate files tagged with release or original year. -* Prefer CD releases by default, when there is no ``media`` tagged in the - files being imported. This can be changed with the :ref:`preferred_media` - setting. +* The new :ref:`preferred_media` config option lets you prefer a certain media + type when the ``media`` field is unset on an album. * Apply minor penalties across a range of fields to differentiate between nearly identical releases: ``disctotal``, ``label``, ``catalognum``, ``country`` and ``albumdisambig``. diff --git a/docs/reference/config.rst b/docs/reference/config.rst index d23db6b02..05ef16b4f 100644 --- a/docs/reference/config.rst +++ b/docs/reference/config.rst @@ -425,9 +425,12 @@ The above example shows the default ``max_rec`` settings. preferred_media ~~~~~~~~~~~~~~~ -When comparing files that have no ``media`` tagged, prefer releases that more -closely resemble this media (using a string distance). When files are already -tagged with media, this setting is ignored. Default: ``CD``. +When an album has its ``media`` field set, it is compared against matches to +prefer releases of the same media type. But this option lets you control what +happens when an album *doesn't* have ``media`` set (which is the case for most +albums that haven't already been run through a MusicBrainz tagger). Set this +option to ``CD``, for example, to prefer CD releases. Defaults to ``null``, +indicating no preference. .. _path-format-config: From e04cb6f5482dcecec4d51b029e52a8f4f39ce9bd Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Wed, 5 Jun 2013 20:06:49 -0700 Subject: [PATCH 4/8] media field distance: binary, not string diff --- beets/autotag/match.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 0e3d2ad13..707fa2f67 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -275,14 +275,10 @@ def distance(items, album_info, mapping): # Actual or preferred media. if album_info.media: - preferred_media = config['match']['preferred_media'].get() - if likelies['media']: - dist += string_dist(likelies['media'], album_info.media) * \ - weights['media'].as_number() - dist_max += weights['media'].as_number() - elif preferred_media: - dist += string_dist(album_info.media, preferred_media) * \ - weights['media'].as_number() + compare_media = likelies['media'] or \ + config['match']['preferred_media'].get() + if compare_media and compare_media != album_info.media: + dist += weights['media'].as_number() dist_max += weights['media'].as_number() # MusicBrainz album ID. From 90873af0bea40f653e8bec7700613f0abd558a3e Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Wed, 5 Jun 2013 20:57:27 -0700 Subject: [PATCH 5/8] media comparison: lower-case both sides --- beets/autotag/match.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 707fa2f67..bb00ee862 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -277,7 +277,7 @@ def distance(items, album_info, mapping): if album_info.media: compare_media = likelies['media'] or \ config['match']['preferred_media'].get() - if compare_media and compare_media != album_info.media: + if compare_media and compare_media.lower() != album_info.media.lower(): dist += weights['media'].as_number() dist_max += weights['media'].as_number() From d21a6aad83c31d2cfe5f413d7303ae244fe09f7d Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Wed, 5 Jun 2013 21:52:26 -0700 Subject: [PATCH 6/8] Added tag v1.2.0 for changeset b3f7b5267a2f --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 7fa4eb224..e73394121 100644 --- a/.hgtags +++ b/.hgtags @@ -19,3 +19,4 @@ f3cd4c138c6f40dc324a23bf01c4c7d97766477e 1.0rc2 f28ea9e2ef8d39913d79dbba73db280ff0740c50 v1.1.0-beta.2 8f070ce28a7b33d8509b29a8dbe937109bbdbd21 v1.1.0-beta.3 97f04ce252332dbda013cbc478d702d54a8fc1bd v1.1.0 +b3f7b5267a2f7b46b826d087421d7f4569211240 v1.2.0 From c5e8e7b52dc231632078d8f85a9a3f03606d39c1 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Wed, 5 Jun 2013 21:58:04 -0700 Subject: [PATCH 7/8] oops! forgot release date --- docs/changelog.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 364c7f029..b6ddf0270 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 From 31d1d90e4ceaac34b8b82fb087573e4daa732db5 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Wed, 5 Jun 2013 21:58:08 -0700 Subject: [PATCH 8/8] Added tag v1.2.0 for changeset ecff182221ec --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index e73394121..2d04bb17f 100644 --- a/.hgtags +++ b/.hgtags @@ -20,3 +20,5 @@ 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