diff --git a/docs/changelog.rst b/docs/changelog.rst index b2011fe2..8d255590 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -13,21 +13,23 @@ Feature release. - Core: Mopidy restores its last state when started. Can be enabled by setting the config value :confval:`core/restore_state` to ``true``. -- MPD: Fix MPD protocol for ``replay_gain_status`` command. The actual command - remains unimplemented. (PR: :issue:`1520`) - -- MPD: Add ``nextsong`` and ``nextsongid`` to the response of MPD ``status`` - command. (Fixes: :issue:`1133`, :issue:`1516`, PR: :issue:`1523`) - -- Local: Skip hidden directories directly in ``media_dir``. - (Fixes: :issue:`1559`, PR: :issue:`1555`) - - Audio: Update scanner to handle sources such as RTSP. (Fixes: :issue:`1479`) - Audio: The scanner set the date to :attr:`mopidy.models.Track.date` and :attr:`mopidy.models.Album.date` (Fixes: :issue:`1741`) +- File: Add new config value :confval:`file/excluded_file_extensions`. + +- Local: Skip hidden directories directly in ``media_dir``. + (Fixes: :issue:`1559`, PR: :issue:`1555`) + +- MPD: Fix MPD protocol for ``replay_gain_status`` command. The actual command + remains unimplemented. (PR: :issue:`1520`) + +- MPD: Add ``nextsong`` and ``nextsongid`` to the response of MPD ``status`` + command. (Fixes: :issue:`1133`, :issue:`1516`, PR: :issue:`1523`) + v2.0.1 (2016-08-16) =================== diff --git a/docs/ext/file.rst b/docs/ext/file.rst index 2331626c..661bf869 100644 --- a/docs/ext/file.rst +++ b/docs/ext/file.rst @@ -27,18 +27,24 @@ See :ref:`config` for general help on configuring Mopidy. .. confval:: file/media_dirs A list of directories to be browsable. - Optionally the path can be followed by ``|`` and a name that will be shown for that path. + Optionally the path can be followed by ``|`` and a name that will be shown + for that path. .. confval:: file/show_dotfiles Whether to show hidden files and directories that start with a dot. Default is false. +.. confval:: file/excluded_file_extensions + + File extensions to exclude when scanning the media directory. Values + should be separated by either comma or newline. + .. confval:: file/follow_symlinks Whether to follow symbolic links found in :confval:`file/media_dirs`. - Directories and files that are outside the configured directories will not be shown. - Default is false. + Directories and files that are outside the configured directories will not + be shown. Default is false. .. confval:: file/metadata_timeout diff --git a/mopidy/file/__init__.py b/mopidy/file/__init__.py index ea4dea12..771a65a4 100644 --- a/mopidy/file/__init__.py +++ b/mopidy/file/__init__.py @@ -22,6 +22,7 @@ class Extension(ext.Extension): def get_config_schema(self): schema = super(Extension, self).get_config_schema() schema['media_dirs'] = config.List(optional=True) + schema['excluded_file_extensions'] = config.List(optional=True) schema['show_dotfiles'] = config.Boolean(optional=True) schema['follow_symlinks'] = config.Boolean(optional=True) schema['metadata_timeout'] = config.Integer(optional=True) diff --git a/mopidy/file/ext.conf b/mopidy/file/ext.conf index 486619a1..5470a8ec 100644 --- a/mopidy/file/ext.conf +++ b/mopidy/file/ext.conf @@ -4,5 +4,8 @@ media_dirs = $XDG_MUSIC_DIR|Music ~/|Home show_dotfiles = false +excluded_file_extensions = + .jpg + .jpeg follow_symlinks = false metadata_timeout = 1000 diff --git a/mopidy/file/library.py b/mopidy/file/library.py index 10182a38..6d426b85 100644 --- a/mopidy/file/library.py +++ b/mopidy/file/library.py @@ -34,8 +34,12 @@ class FileLibraryProvider(backend.LibraryProvider): def __init__(self, backend, config): super(FileLibraryProvider, self).__init__(backend) self._media_dirs = list(self._get_media_dirs(config)) - self._follow_symlinks = config['file']['follow_symlinks'] self._show_dotfiles = config['file']['show_dotfiles'] + self._excluded_file_extensions = tuple( + bytes(file_ext.lower()) + for file_ext in config['file']['excluded_file_extensions']) + self._follow_symlinks = config['file']['follow_symlinks'] + self._scanner = scan.Scanner( timeout=config['file']['metadata_timeout']) @@ -60,6 +64,10 @@ class FileLibraryProvider(backend.LibraryProvider): if not self._show_dotfiles and dir_entry.startswith(b'.'): continue + if (self._excluded_file_extensions and + dir_entry.endswith(self._excluded_file_extensions)): + continue + if os.path.islink(child_path) and not self._follow_symlinks: logger.debug('Ignoring symlink: %s', uri) continue