mirror of
https://github.com/beetbox/beets.git
synced 2025-12-14 20:43:41 +01:00
Merge pull request #1011 from Kraymer/ftintitle_auto
ftintitle: add 'auto' option
This commit is contained in:
commit
0bf7cb8657
2 changed files with 18 additions and 1 deletions
|
|
@ -18,8 +18,11 @@ from beets.plugins import BeetsPlugin
|
|||
from beets import ui
|
||||
from beets.util import displayable_path
|
||||
from beets import config
|
||||
import logging
|
||||
import re
|
||||
|
||||
log = logging.getLogger('beets')
|
||||
|
||||
|
||||
def split_on_feat(artist):
|
||||
"""Given an artist string, split the "main" artist from any artist
|
||||
|
|
@ -69,7 +72,7 @@ def update_metadata(item, feat_part, drop_feat):
|
|||
item.title = new_title
|
||||
|
||||
|
||||
def ft_in_title(item, drop_feat):
|
||||
def ft_in_title(item, drop_feat, write):
|
||||
"""Look for featured artists in the item's artist fields and move
|
||||
them to the title.
|
||||
"""
|
||||
|
|
@ -118,6 +121,7 @@ class FtInTitlePlugin(BeetsPlugin):
|
|||
super(FtInTitlePlugin, self).__init__()
|
||||
|
||||
self.config.add({
|
||||
'auto': True,
|
||||
'drop': False
|
||||
})
|
||||
|
||||
|
|
@ -130,6 +134,9 @@ class FtInTitlePlugin(BeetsPlugin):
|
|||
action='store_true', default=False,
|
||||
help='drop featuring from artists and ignore title update')
|
||||
|
||||
if self.config['auto']:
|
||||
self.import_stages = [self.imported]
|
||||
|
||||
def commands(self):
|
||||
|
||||
def func(lib, opts, args):
|
||||
|
|
@ -145,3 +152,11 @@ class FtInTitlePlugin(BeetsPlugin):
|
|||
|
||||
self._command.func = func
|
||||
return [self._command]
|
||||
|
||||
def imported(self, session, task):
|
||||
"""Import hook for moving featuring artist automatically.
|
||||
"""
|
||||
drop_feat = self.config['drop'].get(bool)
|
||||
|
||||
for item in task.imported_items():
|
||||
ft_in_title(item, drop_feat)
|
||||
|
|
|
|||
|
|
@ -21,4 +21,6 @@ If you prefer to remove featured artists entirely instead of adding them to
|
|||
the title field, either use the ``-d`` flag to the command or set the
|
||||
``ftintitle.drop`` config option.
|
||||
|
||||
To disable this plugin on import, set the ``auto`` config option to false.
|
||||
|
||||
.. _MusicBrainz style: http://musicbrainz.org/doc/Style
|
||||
|
|
|
|||
Loading…
Reference in a new issue