mirror of
https://github.com/beetbox/beets.git
synced 2025-12-07 00:53:08 +01:00
Updated ftintitle plugin to follow a format
This commit is contained in:
parent
a70f8bb91f
commit
d2a95158f2
2 changed files with 11 additions and 5 deletions
|
|
@ -82,6 +82,7 @@ class FtInTitlePlugin(plugins.BeetsPlugin):
|
||||||
self.config.add({
|
self.config.add({
|
||||||
'auto': True,
|
'auto': True,
|
||||||
'drop': False,
|
'drop': False,
|
||||||
|
'format': u'feat. {}'
|
||||||
})
|
})
|
||||||
|
|
||||||
self._command = ui.Subcommand(
|
self._command = ui.Subcommand(
|
||||||
|
|
@ -116,12 +117,13 @@ class FtInTitlePlugin(plugins.BeetsPlugin):
|
||||||
"""Import hook for moving featuring artist automatically.
|
"""Import hook for moving featuring artist automatically.
|
||||||
"""
|
"""
|
||||||
drop_feat = self.config['drop'].get(bool)
|
drop_feat = self.config['drop'].get(bool)
|
||||||
|
feat_format = self.config['format'].get(unicode)
|
||||||
|
|
||||||
for item in task.imported_items():
|
for item in task.imported_items():
|
||||||
self.ft_in_title(item, drop_feat)
|
self.ft_in_title(item, drop_feat, feat_format)
|
||||||
item.store()
|
item.store()
|
||||||
|
|
||||||
def update_metadata(self, item, feat_part, drop_feat):
|
def update_metadata(self, item, feat_part, drop_feat, feat_format):
|
||||||
"""Choose how to add new artists to the title and set the new
|
"""Choose how to add new artists to the title and set the new
|
||||||
metadata. Also, print out messages about any changes that are made.
|
metadata. Also, print out messages about any changes that are made.
|
||||||
If `drop_feat` is set, then do not add the artist to the title; just
|
If `drop_feat` is set, then do not add the artist to the title; just
|
||||||
|
|
@ -137,11 +139,12 @@ class FtInTitlePlugin(plugins.BeetsPlugin):
|
||||||
# Only update the title if it does not already contain a featured
|
# Only update the title if it does not already contain a featured
|
||||||
# artist and if we do not drop featuring information.
|
# artist and if we do not drop featuring information.
|
||||||
if not drop_feat and not contains_feat(item.title):
|
if not drop_feat and not contains_feat(item.title):
|
||||||
new_title = u"{0} feat. {1}".format(item.title, feat_part)
|
new_format = feat_format.format(feat_part)
|
||||||
|
new_title = u"{0} {1}".format(item.title, new_format)
|
||||||
self._log.info(u'title: {0} -> {1}', item.title, new_title)
|
self._log.info(u'title: {0} -> {1}', item.title, new_title)
|
||||||
item.title = new_title
|
item.title = new_title
|
||||||
|
|
||||||
def ft_in_title(self, item, drop_feat):
|
def ft_in_title(self, item, drop_feat, feat_format):
|
||||||
"""Look for featured artists in the item's artist fields and move
|
"""Look for featured artists in the item's artist fields and move
|
||||||
them to the title.
|
them to the title.
|
||||||
"""
|
"""
|
||||||
|
|
@ -162,6 +165,6 @@ class FtInTitlePlugin(plugins.BeetsPlugin):
|
||||||
|
|
||||||
# If we have a featuring artist, move it to the title.
|
# If we have a featuring artist, move it to the title.
|
||||||
if feat_part:
|
if feat_part:
|
||||||
self.update_metadata(item, feat_part, drop_feat)
|
self.update_metadata(item, feat_part, drop_feat, feat_format)
|
||||||
else:
|
else:
|
||||||
self._log.info(u'no featuring artists found')
|
self._log.info(u'no featuring artists found')
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ file. The available options are:
|
||||||
- **drop**: Remove featured artists entirely instead of adding them to the
|
- **drop**: Remove featured artists entirely instead of adding them to the
|
||||||
title field.
|
title field.
|
||||||
Default: ``no``.
|
Default: ``no``.
|
||||||
|
- **format**: Defines the format for the feat part of the new title field.
|
||||||
|
In this format the ``{}`` is used to define where the featured artists are placed
|
||||||
|
Default: ``feat. {}``
|
||||||
|
|
||||||
Running Manually
|
Running Manually
|
||||||
----------------
|
----------------
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue