local: Add file ext blacklist (fixes #516).
Adds a new local/scan_blacklist_extensions config value for controlling file extensions to ignore.
This commit is contained in:
parent
add79d90dd
commit
3a1d4db227
@ -52,6 +52,10 @@ Configuration values
|
||||
Number of milliseconds before giving up scanning a file and moving on to
|
||||
the next file.
|
||||
|
||||
.. confval:: local/scan_blacklist_extensions
|
||||
|
||||
File extensions to ignore when scanning the media directory.
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
@ -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['scan_blacklist_extensions'] = config.List(optional=True)
|
||||
return schema
|
||||
|
||||
def validate_environment(self):
|
||||
|
||||
@ -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
|
||||
scan_blacklist_extensions =
|
||||
.jpeg
|
||||
.jpg
|
||||
.png
|
||||
.txt
|
||||
.log
|
||||
|
||||
@ -71,6 +71,7 @@ def main():
|
||||
local_updater = updaters.values()[0](config) # TODO: switch to actor?
|
||||
|
||||
media_dir = config['local']['media_dir']
|
||||
blacklist_extensions = config['local']['scan_blacklist_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 blacklist_extensions:
|
||||
logging.debug('Skipped %s: File extension blacklisted.', uri)
|
||||
continue
|
||||
|
||||
if uri not in uris_library:
|
||||
uris_update.add(uri)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user