Merge branch 'develop' into feature/subcommands
Conflicts: mopidy/scanner.py
This commit is contained in:
commit
ea28e91f63
@ -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
|
||||
|
||||
@ -29,7 +29,8 @@ class ScanCommand(commands.Command):
|
||||
def run(self, args, config, extensions):
|
||||
media_dir = config['local']['media_dir']
|
||||
scan_timeout = config['local']['scan_timeout']
|
||||
excluded_file_extensions = config['local']['excluded_file_extensions']
|
||||
excluded_file_extensions = set(
|
||||
ext.lower() for ext in config['local']['excluded_file_extensions'])
|
||||
|
||||
updaters = {}
|
||||
for e in extensions:
|
||||
@ -73,7 +74,7 @@ class ScanCommand(commands.Command):
|
||||
logger.info('Checking %s for unknown tracks.', media_dir)
|
||||
for uri in path.find_uris(media_dir):
|
||||
file_extension = os.path.splitext(path.uri_to_path(uri))[1]
|
||||
if file_extension in excluded_file_extensions:
|
||||
if file_extension.lower() in excluded_file_extensions:
|
||||
logger.debug('Skipped %s: File extension excluded.', uri)
|
||||
continue
|
||||
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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')
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import re
|
||||
import socket
|
||||
import string
|
||||
|
||||
logger = logging.getLogger('mopidy.utils.zerconf')
|
||||
logger = logging.getLogger('mopidy.utils.zeroconf')
|
||||
|
||||
try:
|
||||
import dbus
|
||||
@ -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'(?<![.\d])(127|0)[.]', host):
|
||||
return ''
|
||||
return host
|
||||
|
||||
|
||||
def _convert_text_to_dbus_bytes(text):
|
||||
return [dbus.Byte(ord(c)) for c in text]
|
||||
|
||||
@ -38,7 +30,10 @@ class Zeroconf(object):
|
||||
self.domain = domain or ''
|
||||
self.port = port
|
||||
self.text = text or []
|
||||
self.host = _filter_loopback_and_meta_addresses(host or '')
|
||||
if host in ('::', '0.0.0.0'):
|
||||
self.host = ''
|
||||
else:
|
||||
self.host = host
|
||||
|
||||
template = string.Template(name)
|
||||
self.name = template.safe_substitute(
|
||||
@ -51,31 +46,38 @@ class Zeroconf(object):
|
||||
|
||||
try:
|
||||
bus = dbus.SystemBus()
|
||||
|
||||
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')
|
||||
|
||||
self.group = dbus.Interface(
|
||||
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)
|
||||
|
||||
self.group.Commit()
|
||||
return True
|
||||
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
|
||||
|
||||
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')
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user