diff --git a/beetsplug/ftintitle.py b/beetsplug/ftintitle.py index 831236b3c..8a92d20df 100644 --- a/beetsplug/ftintitle.py +++ b/beetsplug/ftintitle.py @@ -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) diff --git a/docs/plugins/ftintitle.rst b/docs/plugins/ftintitle.rst index ed13cb840..c8bf48f46 100644 --- a/docs/plugins/ftintitle.rst +++ b/docs/plugins/ftintitle.rst @@ -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