From 9de5e2e8571079cdb53e9a8bcbfa39341032406c Mon Sep 17 00:00:00 2001 From: Nadav Tau Date: Sun, 9 Oct 2016 10:40:10 +0300 Subject: [PATCH 1/6] Excluded file ext in Mopidy-File Added support for excluding specific file extensions from Mopidy-File library --- mopidy/file/__init__.py | 1 + mopidy/file/ext.conf | 3 +++ mopidy/file/library.py | 7 +++++++ 3 files changed, 11 insertions(+) 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..64721a26 100644 --- a/mopidy/file/ext.conf +++ b/mopidy/file/ext.conf @@ -6,3 +6,6 @@ media_dirs = show_dotfiles = false follow_symlinks = false metadata_timeout = 1000 +excluded_file_extensions = + .jpg + .jpeg diff --git a/mopidy/file/library.py b/mopidy/file/library.py index 10182a38..dbf7fb4e 100644 --- a/mopidy/file/library.py +++ b/mopidy/file/library.py @@ -36,6 +36,10 @@ class FileLibraryProvider(backend.LibraryProvider): 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 = config['file']['excluded_file_extensions'] + self._excluded_file_extensions = tuple( + bytes(file_ext.lower()) for file_ext in self._excluded_file_extensions) + self._scanner = scan.Scanner( timeout=config['file']['metadata_timeout']) @@ -60,6 +64,9 @@ 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 From 5e9f18f0bfff28c34c72a960de0c8c06a53136f9 Mon Sep 17 00:00:00 2001 From: Nadav Tau Date: Sun, 9 Oct 2016 11:13:30 +0300 Subject: [PATCH 2/6] Fixing CI issues --- mopidy/file/library.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mopidy/file/library.py b/mopidy/file/library.py index dbf7fb4e..6a2db5f9 100644 --- a/mopidy/file/library.py +++ b/mopidy/file/library.py @@ -36,9 +36,11 @@ class FileLibraryProvider(backend.LibraryProvider): 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 = config['file']['excluded_file_extensions'] + self._excluded_file_extensions = \ + config['file']['excluded_file_extensions'] self._excluded_file_extensions = tuple( - bytes(file_ext.lower()) for file_ext in self._excluded_file_extensions) + bytes(file_ext.lower()) for file_ext in + self._excluded_file_extensions) self._scanner = scan.Scanner( timeout=config['file']['metadata_timeout']) @@ -64,7 +66,8 @@ 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): + 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: From 1841ca2177b1cc0f79c051b2a529153068f60602 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 24 Oct 2016 23:38:59 +0200 Subject: [PATCH 3/6] file: Fix minor style issues --- mopidy/file/ext.conf | 4 ++-- mopidy/file/library.py | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/mopidy/file/ext.conf b/mopidy/file/ext.conf index 64721a26..5470a8ec 100644 --- a/mopidy/file/ext.conf +++ b/mopidy/file/ext.conf @@ -4,8 +4,8 @@ media_dirs = $XDG_MUSIC_DIR|Music ~/|Home show_dotfiles = false -follow_symlinks = false -metadata_timeout = 1000 excluded_file_extensions = .jpg .jpeg +follow_symlinks = false +metadata_timeout = 1000 diff --git a/mopidy/file/library.py b/mopidy/file/library.py index 6a2db5f9..6d426b85 100644 --- a/mopidy/file/library.py +++ b/mopidy/file/library.py @@ -34,13 +34,11 @@ 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 = \ - config['file']['excluded_file_extensions'] self._excluded_file_extensions = tuple( - bytes(file_ext.lower()) for file_ext in - self._excluded_file_extensions) + 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']) @@ -66,8 +64,8 @@ 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): + 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: From d62a789092c75ea4991524888234eda8b7d5c099 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 24 Oct 2016 23:42:30 +0200 Subject: [PATCH 4/6] file: Document file/excluded_file_extensions --- docs/ext/file.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 From 3b40c77cfb4c2ec0adf5633b15d348acb31daa86 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 24 Oct 2016 23:43:03 +0200 Subject: [PATCH 5/6] docs: Reorder backlog --- docs/changelog.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index b2011fe2..97527218 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -13,21 +13,21 @@ 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`) +- 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) =================== From 5d6879bff9b598dc9da2923d7e2455660ae3bc6e Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 24 Oct 2016 23:43:47 +0200 Subject: [PATCH 6/6] docs: Add file/excluded_file_extensions to changelog --- docs/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 97527218..8d255590 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -19,6 +19,8 @@ Feature release. :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`)