Merge pull request #550 from adamcik/fix/bug-516-blacklist-extensions-in-scanner

local: Add file ext blacklist (fixes #516).
This commit is contained in:
Stein Magnus Jodal 2013-10-27 13:36:32 -07:00
commit 15554ea062
4 changed files with 16 additions and 0 deletions

View File

@ -52,6 +52,10 @@ Configuration values
Number of milliseconds before giving up scanning a file and moving on to
the next file.
.. confval:: local/excluded_file_extensions
File extensions to exclude when scanning the media directory.
Usage
=====

View File

@ -23,6 +23,7 @@ class Extension(ext.Extension):
schema['tag_cache_file'] = config.Path()
schema['scan_timeout'] = config.Integer(
minimum=1000, maximum=1000*60*60)
schema['excluded_file_extensions'] = config.List(optional=True)
return schema
def validate_environment(self):

View File

@ -4,3 +4,9 @@ media_dir = $XDG_MUSIC_DIR
playlists_dir = $XDG_DATA_DIR/mopidy/local/playlists
tag_cache_file = $XDG_DATA_DIR/mopidy/local/tag_cache
scan_timeout = 1000
excluded_file_extensions =
.jpeg
.jpg
.png
.txt
.log

View File

@ -71,6 +71,7 @@ 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']
uris_library = set()
uris_update = set()
@ -92,6 +93,10 @@ def main():
logging.info('Checking %s for new or modified 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:
logging.debug('Skipped %s: File extension excluded.', uri)
continue
if uri not in uris_library:
uris_update.add(uri)