mirror of
https://github.com/beetbox/beets.git
synced 2026-02-08 08:25:23 +01:00
Merge c8bfa8a8cc into cdfb813910
This commit is contained in:
commit
341551a463
3 changed files with 36 additions and 9 deletions
|
|
@ -29,7 +29,34 @@ __author__ = "https://github.com/MrNuggelz"
|
|||
class Unimported(BeetsPlugin):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.config.add({"ignore_extensions": [], "ignore_subdirectories": []})
|
||||
self.config.add(
|
||||
{
|
||||
"ignore_extensions": [],
|
||||
"ignore_subdirectories": [],
|
||||
"ignore_as_globs": False,
|
||||
}
|
||||
)
|
||||
|
||||
def walk(self, lib):
|
||||
ignore_subdirs = self.config["ignore_subdirectories"].as_str_seq()
|
||||
if self.config["ignore_as_globs"].get(bool):
|
||||
# The way beets ignore elements in the library, using globbing,
|
||||
# whatever the depth
|
||||
for root, _, files in util.sorted_walk(
|
||||
lib.directory, ignore=ignore_subdirs
|
||||
):
|
||||
yield (root, files)
|
||||
else:
|
||||
# the reverse-compatible search, with ignore_subdirectories as
|
||||
# a direct child of the library root
|
||||
ignore_dirs = [
|
||||
os.path.join(lib.directory, x.encode()) for x in ignore_subdirs
|
||||
]
|
||||
for root, _, files in os.walk(lib.directory):
|
||||
# do not traverse if root is a child of an ignored directory
|
||||
if any(root.startswith(ignored) for ignored in ignore_dirs):
|
||||
continue
|
||||
yield (root, files)
|
||||
|
||||
def commands(self):
|
||||
def print_unimported(lib, opts, args):
|
||||
|
|
@ -37,15 +64,8 @@ class Unimported(BeetsPlugin):
|
|||
f".{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 = set()
|
||||
for root, _, files in os.walk(lib.directory):
|
||||
# do not traverse if root is a child of an ignored directory
|
||||
if any(root.startswith(ignored) for ignored in ignore_dirs):
|
||||
continue
|
||||
for root, files in self.walk(lib):
|
||||
for file in files:
|
||||
# ignore files with ignored extensions
|
||||
if any(file.endswith(ext) for ext in ignore_exts):
|
||||
|
|
|
|||
|
|
@ -324,6 +324,8 @@ New features:
|
|||
``played_ratio_threshold``, to allow configuring the percentage the song must
|
||||
be played for it to be counted as played instead of skipped.
|
||||
- :doc:`plugins/web`: Display artist and album as part of the search results.
|
||||
- :doc:`/plugins/unimported`: Add ``ignore_as_globs`` option to use globbing for
|
||||
the ``ignore_subdirectories`` option.
|
||||
- :doc:`plugins/spotify` :doc:`plugins/deezer`: Add new configuration option
|
||||
:conf:`plugins.index:search_limit` to limit the number of results returned by
|
||||
search queries.
|
||||
|
|
|
|||
|
|
@ -18,5 +18,10 @@ file:
|
|||
unimported:
|
||||
ignore_extensions: jpg png
|
||||
ignore_subdirectories: NonMusic data temp
|
||||
ignore_as_globs: false
|
||||
|
||||
The default configuration lists all unimported files, ignoring no extensions.
|
||||
|
||||
When true, the ``ignore_as_globs`` parameter uses the same way of parsing files
|
||||
as beets, using the ``ignore_subdirectories`` as globs whatever the depth,
|
||||
instead of excluding them if they are the direct child of the library root.
|
||||
|
|
|
|||
Loading…
Reference in a new issue