Merge pull request #4086 from jaydesl/master

feat(unimported): support excluding subdirectories
This commit is contained in:
Adrian Sampson 2021-10-12 19:25:27 -07:00 committed by GitHub
commit 44efecbe38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 9 deletions

View file

@ -38,13 +38,23 @@ class Unimported(BeetsPlugin):
def commands(self):
def print_unimported(lib, opts, args):
ignore_exts = [('.' + x).encode() for x
in self.config['ignore_extensions'].as_str_seq()]
ignore_exts = [
('.' + x).encode()
for x in self.config["ignore_extensions"].as_str_seq()
]
ignore_dirs = [
os.path.join(lib.directory, x.encode())
for x in self.config["ignore_subdirectories"].as_str_seq()
]
in_folder = {
os.path.join(r, file) for r, d, f in os.walk(lib.directory)
for file in f if not any(
[file.endswith(extension) for extension in
ignore_exts])}
os.path.join(r, file)
for r, d, f in os.walk(lib.directory)
for file in f
if not any(
[file.endswith(ext) for ext in ignore_exts]
+ [r in ignore_dirs]
)
}
in_library = {x.path for x in lib.items()}
art_files = {x.artpath for x in lib.albums()}
for f in in_folder - in_library - art_files:

View file

@ -33,6 +33,8 @@ Major new features:
Other new things:
* Permissions plugin now sets cover art permissions to the file permissions.
* :doc:`/plugins/unimported`: Support excluding specific
subdirectories in library.
Bug fixes:

View file

@ -1,7 +1,7 @@
Unimported Plugin
=================
The ``unimported`` plugin allows to list all files in the library folder which are not listed in the beets library database, including art files.
The ``unimported`` plugin allows one to list all files in the library folder which are not listed in the beets library database, including art files.
Command Line Usage
------------------
@ -9,9 +9,10 @@ Command Line Usage
To use the ``unimported`` plugin, enable it in your configuration (see
:ref:`using-plugins`). Then use it by invoking the ``beet unimported`` command.
The command will list all files in the library folder which are not imported. You can
exclude file extensions using the configuration file::
exclude file extensions or entire subdirectories using the configuration file::
unimported:
ignore_extensions: jpg png
ignore_subdirectories: NonMusic data temp
The default configuration list all unimported files, ignoring no extensions.
The default configuration lists all unimported files, ignoring no extensions.