mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 12:02:41 +01:00
scrub: Run on import in auto mode (#1657)
This commit is contained in:
parent
5a285cc11f
commit
f5448d1531
2 changed files with 10 additions and 14 deletions
|
|
@ -45,9 +45,6 @@ _MUTAGEN_FORMATS = {
|
|||
}
|
||||
|
||||
|
||||
scrubbing = False
|
||||
|
||||
|
||||
class ScrubPlugin(BeetsPlugin):
|
||||
"""Removes extraneous metadata from files' tags."""
|
||||
def __init__(self):
|
||||
|
|
@ -55,15 +52,12 @@ class ScrubPlugin(BeetsPlugin):
|
|||
self.config.add({
|
||||
'auto': True,
|
||||
})
|
||||
self.register_listener("write", self.write_item)
|
||||
|
||||
if self.config['auto']:
|
||||
self.register_listener("import_task_files", self.import_task_files)
|
||||
|
||||
def commands(self):
|
||||
def scrub_func(lib, opts, args):
|
||||
# This is a little bit hacky, but we set a global flag to
|
||||
# avoid autoscrubbing when we're also explicitly scrubbing.
|
||||
global scrubbing
|
||||
scrubbing = True
|
||||
|
||||
# Walk through matching files and remove tags.
|
||||
for item in lib.items(ui.decargs(args)):
|
||||
self._log.info(u'scrubbing: {0}',
|
||||
|
|
@ -92,8 +86,6 @@ class ScrubPlugin(BeetsPlugin):
|
|||
mf.art = art
|
||||
mf.save()
|
||||
|
||||
scrubbing = False
|
||||
|
||||
scrub_cmd = ui.Subcommand('scrub', help='clean audio tags')
|
||||
scrub_cmd.parser.add_option('-W', '--nowrite', dest='write',
|
||||
action='store_false', default=True,
|
||||
|
|
@ -140,8 +132,9 @@ class ScrubPlugin(BeetsPlugin):
|
|||
self._log.error(u'could not scrub {0}: {1}',
|
||||
util.displayable_path(path), exc)
|
||||
|
||||
def write_item(self, item, path, tags):
|
||||
"""Automatically embed art into imported albums."""
|
||||
if not scrubbing and self.config['auto']:
|
||||
def import_task_files(self, session, task):
|
||||
"""Automatically scrub imported files."""
|
||||
for item in task.imported_items():
|
||||
path = item.path
|
||||
self._log.debug(u'auto-scrubbing {0}', util.displayable_path(path))
|
||||
self._scrub(path)
|
||||
|
|
|
|||
|
|
@ -87,6 +87,9 @@ Fixes:
|
|||
* :doc:`/plugins/lyrics`: Fix a crash in the Google backend when searching for
|
||||
bands with regular-expression characters in their names, like Sunn O))).
|
||||
:bug:`1673`
|
||||
* :doc:`/plugins/scrub`: In ``auto`` mode, the plugin now *actually* only
|
||||
scrubs files on import---not every time files were written, as it previously
|
||||
did. :bug:`1657`
|
||||
|
||||
.. _Emby Server: http://emby.media
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue