From 9814fe1ec9428865007d71c3159af52bf62ce05a Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 16 Nov 2013 00:20:26 +0100 Subject: [PATCH 1/9] zeroconf: Fix logger name --- mopidy/utils/zeroconf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mopidy/utils/zeroconf.py b/mopidy/utils/zeroconf.py index c1781867..56fd3c07 100644 --- a/mopidy/utils/zeroconf.py +++ b/mopidy/utils/zeroconf.py @@ -5,7 +5,7 @@ import re import socket import string -logger = logging.getLogger('mopidy.utils.zerconf') +logger = logging.getLogger('mopidy.utils.zeroconf') try: import dbus From f3b09e4ef2cf713cfc00c9f1fd0ab129fa9c6b83 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 16 Nov 2013 00:20:49 +0100 Subject: [PATCH 2/9] zeroconf: Catch DBusException from AddService Fixes #576 --- mopidy/utils/zeroconf.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mopidy/utils/zeroconf.py b/mopidy/utils/zeroconf.py index 56fd3c07..a85fddbe 100644 --- a/mopidy/utils/zeroconf.py +++ b/mopidy/utils/zeroconf.py @@ -66,11 +66,15 @@ class Zeroconf(object): bus.get_object('org.freedesktop.Avahi', server.EntryGroupNew()), 'org.freedesktop.Avahi.EntryGroup') - text = [_convert_text_to_dbus_bytes(t) for t in self.text] - self.group.AddService(_AVAHI_IF_UNSPEC, _AVAHI_PROTO_UNSPEC, - dbus.UInt32(_AVAHI_PUBLISHFLAGS_NONE), - self.name, self.stype, self.domain, self.host, - dbus.UInt16(self.port), text) + try: + text = [_convert_text_to_dbus_bytes(t) for t in self.text] + self.group.AddService( + _AVAHI_IF_UNSPEC, _AVAHI_PROTO_UNSPEC, + dbus.UInt32(_AVAHI_PUBLISHFLAGS_NONE), self.name, self.stype, + self.domain, self.host, dbus.UInt16(self.port), text) + except dbus.exceptions.DBusException as e: + logger.debug('Zeroconf publish failed: %s', e) + return False self.group.Commit() return True From 5c33115eebc9002cc480ec8f47293a2bd181dce0 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 16 Nov 2013 00:55:18 +0100 Subject: [PATCH 3/9] zeroconf: Don't set host when binding to all interfaces --- mopidy/utils/zeroconf.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/mopidy/utils/zeroconf.py b/mopidy/utils/zeroconf.py index a85fddbe..6b43e62e 100644 --- a/mopidy/utils/zeroconf.py +++ b/mopidy/utils/zeroconf.py @@ -1,7 +1,6 @@ from __future__ import unicode_literals import logging -import re import socket import string @@ -17,13 +16,6 @@ _AVAHI_PROTO_UNSPEC = -1 _AVAHI_PUBLISHFLAGS_NONE = 0 -def _filter_loopback_and_meta_addresses(host): - # TODO: see if we can find a cleaner way of handling this. - if re.search(r'(? Date: Sat, 16 Nov 2013 01:28:44 +0100 Subject: [PATCH 4/9] zeroconf: Wrap publish in try-except --- mopidy/utils/zeroconf.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/mopidy/utils/zeroconf.py b/mopidy/utils/zeroconf.py index 6b43e62e..36d38f8b 100644 --- a/mopidy/utils/zeroconf.py +++ b/mopidy/utils/zeroconf.py @@ -46,34 +46,33 @@ class Zeroconf(object): try: bus = dbus.SystemBus() - except dbus.exceptions.DBusException as e: - logger.debug('Zeroconf publish failed: %s', e) - return False - if not bus.name_has_owner('org.freedesktop.Avahi'): - logger.debug('Zeroconf publish failed: Avahi service not running.') - return False + if not bus.name_has_owner('org.freedesktop.Avahi'): + logger.debug( + 'Zeroconf publish failed: Avahi service not running.') + return False - server = dbus.Interface(bus.get_object('org.freedesktop.Avahi', '/'), - 'org.freedesktop.Avahi.Server') + server = dbus.Interface( + bus.get_object('org.freedesktop.Avahi', '/'), + 'org.freedesktop.Avahi.Server') - self.group = dbus.Interface( - bus.get_object('org.freedesktop.Avahi', server.EntryGroupNew()), - 'org.freedesktop.Avahi.EntryGroup') + self.group = dbus.Interface( + bus.get_object( + 'org.freedesktop.Avahi', server.EntryGroupNew()), + 'org.freedesktop.Avahi.EntryGroup') - try: text = [_convert_text_to_dbus_bytes(t) for t in self.text] self.group.AddService( _AVAHI_IF_UNSPEC, _AVAHI_PROTO_UNSPEC, dbus.UInt32(_AVAHI_PUBLISHFLAGS_NONE), self.name, self.stype, self.domain, self.host, dbus.UInt16(self.port), text) + + self.group.Commit() + return True except dbus.exceptions.DBusException as e: logger.debug('Zeroconf publish failed: %s', e) return False - self.group.Commit() - return True - def unpublish(self): if self.group: self.group.Reset() From eee276d8c0a412eff659465fd33ca7ab549d5da4 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 16 Nov 2013 01:28:53 +0100 Subject: [PATCH 5/9] zeroconf: Wrap unpublish in try-except --- mopidy/utils/zeroconf.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mopidy/utils/zeroconf.py b/mopidy/utils/zeroconf.py index 36d38f8b..33fbd13b 100644 --- a/mopidy/utils/zeroconf.py +++ b/mopidy/utils/zeroconf.py @@ -75,5 +75,9 @@ class Zeroconf(object): def unpublish(self): if self.group: - self.group.Reset() - self.group = None + try: + self.group.Reset() + except dbus.exceptions.DBusException as e: + logger.debug('Zeroconf unpublish failed: %s', e) + finally: + self.group = None From 6323a0762940561a467e46cf2716c8aa12fb6a15 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 16 Nov 2013 01:55:23 +0100 Subject: [PATCH 6/9] mpd: Don't save comments to tag cache As they can contain newlines. Fixes #579. --- mopidy/frontends/mpd/translator.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mopidy/frontends/mpd/translator.py b/mopidy/frontends/mpd/translator.py index e103e170..e4fb0d62 100644 --- a/mopidy/frontends/mpd/translator.py +++ b/mopidy/frontends/mpd/translator.py @@ -322,6 +322,12 @@ def _add_to_tag_cache(result, dirs, files, media_dir): for track in files: track_result = dict(track_to_mpd_format(track)) + # XXX Don't save comments to the tag cache as they may span multiple + # lines. We'll start saving track comments when we move from tag_cache + # to a JSON file. See #579 for details. + if 'Comment' in track_result: + del track_result['Comment'] + path = uri_to_path(track_result['file']) try: text_path = path.decode('utf-8') From 0c1ce36bfcfb398c6895cee37985e5ee673d6140 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 16 Nov 2013 02:10:40 +0100 Subject: [PATCH 7/9] mpd: bitrate in status response is always an int Fixes #577 --- mopidy/frontends/mpd/protocol/status.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mopidy/frontends/mpd/protocol/status.py b/mopidy/frontends/mpd/protocol/status.py index 49e08ee8..deb5d503 100644 --- a/mopidy/frontends/mpd/protocol/status.py +++ b/mopidy/frontends/mpd/protocol/status.py @@ -214,8 +214,11 @@ def status(context): def _status_bitrate(futures): current_tl_track = futures['playback.current_tl_track'].get() - if current_tl_track is not None: - return current_tl_track.track.bitrate + if current_tl_track is None: + return 0 + if current_tl_track.track.bitrate is None: + return 0 + return current_tl_track.track.bitrate def _status_consume(futures): From 2e85c222e0dc1de12503f7e2773016f2d6620e7d Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 16 Nov 2013 02:21:18 +0100 Subject: [PATCH 8/9] local: Ignore capitalization of excluded file exts Fixes #575 --- mopidy/scanner.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mopidy/scanner.py b/mopidy/scanner.py index b61517ef..1cd73e4b 100644 --- a/mopidy/scanner.py +++ b/mopidy/scanner.py @@ -65,7 +65,9 @@ def main(): local_updater = updaters.values()[0](config) # TODO: switch to actor? media_dir = config['local']['media_dir'] - excluded_extensions = config['local']['excluded_file_extensions'] + excluded_extensions = set( + file_ext.lower() + for file_ext in config['local']['excluded_file_extensions']) # TODO: cleanup to consistently use local urls, not a random mix of local # and file uris depending on how the data was loaded. @@ -91,7 +93,8 @@ def main(): logging.info('Checking %s for unknown tracks.', media_dir) for uri in path.find_uris(config['local']['media_dir']): - if os.path.splitext(path.uri_to_path(uri))[1] in excluded_extensions: + file_ext = os.path.splitext(path.uri_to_path(uri))[1] + if file_ext.lower() in excluded_extensions: logging.debug('Skipped %s: File extension excluded.', uri) continue From 3b03cdd22205ca7c71a5ecebc36ac401e0c0f86c Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 16 Nov 2013 02:26:57 +0100 Subject: [PATCH 9/9] docs: Update changelog --- docs/changelog.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index f425b94f..cbb44afe 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -46,6 +46,11 @@ v0.17.0 (UNRELEASED) - Fix scanner so that time of last modification is respected when deciding which files can be skipped. +- The scanner now ignores the capitalization of file extensions in + :confval:`local/excluded_file_extensions`, so you no longer need to list both + ``.jpg`` and ``.JPG`` to ignore JPEG files when scanning. (Fixes: + :issue:`525`) + **MPD frontend** - The MPD service is now published as a Zeroconf service if avahi-daemon is @@ -58,6 +63,9 @@ v0.17.0 (UNRELEASED) ``performer``. These tags can be used with ``list ...``, ``search ...``, and ``find ...`` and their variants, and are supported in the ``any`` tag also +- The ``bitrate`` field in the ``status`` response is now always an integer. + This follows the behavior of the original MPD server. (Fixes: :issue:`577`) + **HTTP frontend** - The HTTP service is now published as a Zeroconf service if avahi-daemon is