improvements from review

This commit is contained in:
MrNuggelz 2019-10-15 15:32:50 +02:00
parent b6588edac5
commit c7e81d8b81
2 changed files with 16 additions and 15 deletions

View file

@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import, division, print_function
import os
from beets import util
from beets.plugins import BeetsPlugin
from beets.ui import Subcommand
@ -14,23 +13,25 @@ class Unimported(BeetsPlugin):
super(Unimported, self).__init__()
self.config.add(
{
'ignore_extensions': '[]'
'ignore_extensions': []
}
)
def commands(self):
def print_unimported(lib, opts, args):
in_library = set(
exts_to_ignore = self.config['ignore_extensions'].as_str_seq()
in_folder = set(
(os.path.join(r, file) for r, d, f in os.walk(lib.directory)
for file in f if not any(
[file.endswith(extension.encode()) for extension in
self.config['ignore_extensions'].get()])))
test = set((x.path for x in lib.items()))
for f in in_library - test:
print(f.decode('utf-8'))
exts_to_ignore])))
in_library = set(x.path for x in lib.items())
for f in in_folder - in_library:
print(util.displayable_path(f))
unimported = Subcommand(
'unimported',
help='list files in library which have not been imported')
help='list all files in the library folder which are not listed'
' in the beets library database')
unimported.func = print_unimported
return [unimported]

View file

@ -1,7 +1,7 @@
Play Plugin
Unimported Plugin
===========
The ``unimported`` plugin allows to list all files in the library folder which are not imported.
The ``unimported`` plugin allows to list all files in the library folder which are not listed in the beets library database.
Command Line Usage
------------------
@ -12,7 +12,7 @@ The command will list all files in the library folder which are not imported. Yo
exclude file extensions using the configuration file::
unimported:
ignore_extensions: [jpg,png] # default []
ignore_extensions: jpg png
The default configuration moves all English articles to the end of the string,
but you can override these defaults to make more complex changes.