mirror of
https://github.com/beetbox/beets.git
synced 2026-01-17 13:44:01 +01:00
Merge branch 'master' into generic-cached-classproperty
This commit is contained in:
commit
79aec80b9e
4 changed files with 63 additions and 4 deletions
|
|
@ -108,6 +108,7 @@ class FtInTitlePlugin(plugins.BeetsPlugin):
|
|||
"drop": False,
|
||||
"format": "feat. {}",
|
||||
"keep_in_artist": False,
|
||||
"preserve_album_artist": True,
|
||||
"custom_words": [],
|
||||
}
|
||||
)
|
||||
|
|
@ -133,12 +134,19 @@ class FtInTitlePlugin(plugins.BeetsPlugin):
|
|||
self.config.set_args(opts)
|
||||
drop_feat = self.config["drop"].get(bool)
|
||||
keep_in_artist_field = self.config["keep_in_artist"].get(bool)
|
||||
preserve_album_artist = self.config["preserve_album_artist"].get(
|
||||
bool
|
||||
)
|
||||
custom_words = self.config["custom_words"].get(list)
|
||||
write = ui.should_write()
|
||||
|
||||
for item in lib.items(args):
|
||||
if self.ft_in_title(
|
||||
item, drop_feat, keep_in_artist_field, custom_words
|
||||
item,
|
||||
drop_feat,
|
||||
keep_in_artist_field,
|
||||
preserve_album_artist,
|
||||
custom_words,
|
||||
):
|
||||
item.store()
|
||||
if write:
|
||||
|
|
@ -151,11 +159,16 @@ class FtInTitlePlugin(plugins.BeetsPlugin):
|
|||
"""Import hook for moving featuring artist automatically."""
|
||||
drop_feat = self.config["drop"].get(bool)
|
||||
keep_in_artist_field = self.config["keep_in_artist"].get(bool)
|
||||
preserve_album_artist = self.config["preserve_album_artist"].get(bool)
|
||||
custom_words = self.config["custom_words"].get(list)
|
||||
|
||||
for item in task.imported_items():
|
||||
if self.ft_in_title(
|
||||
item, drop_feat, keep_in_artist_field, custom_words
|
||||
item,
|
||||
drop_feat,
|
||||
keep_in_artist_field,
|
||||
preserve_album_artist,
|
||||
custom_words,
|
||||
):
|
||||
item.store()
|
||||
|
||||
|
|
@ -204,6 +217,7 @@ class FtInTitlePlugin(plugins.BeetsPlugin):
|
|||
item: Item,
|
||||
drop_feat: bool,
|
||||
keep_in_artist_field: bool,
|
||||
preserve_album_artist: bool,
|
||||
custom_words: list[str],
|
||||
) -> bool:
|
||||
"""Look for featured artists in the item's artist fields and move
|
||||
|
|
@ -218,7 +232,7 @@ class FtInTitlePlugin(plugins.BeetsPlugin):
|
|||
# Check whether there is a featured artist on this track and the
|
||||
# artist field does not exactly match the album artist field. In
|
||||
# that case, we attempt to move the featured artist to the title.
|
||||
if albumartist and artist == albumartist:
|
||||
if preserve_album_artist and albumartist and artist == albumartist:
|
||||
return False
|
||||
|
||||
_, featured = split_on_feat(artist, custom_words=custom_words)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ Unreleased
|
|||
New features:
|
||||
|
||||
- :doc:`plugins/ftintitle`: Added argument for custom feat. words in ftintitle.
|
||||
- :doc: `/plugins/play`: Added `$playlist` marker to precisely edit the playlist
|
||||
- :doc:`plugins/ftintitle`: Added argument to skip the processing of artist and
|
||||
album artist are the same in ftintitle.
|
||||
- :doc:`plugins/play`: Added `$playlist` marker to precisely edit the playlist
|
||||
filepath into the command calling the player program.
|
||||
|
||||
Bug fixes:
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ file. The available options are:
|
|||
- **keep_in_artist**: Keep the featuring X part in the artist field. This can be
|
||||
useful if you still want to be able to search for features in the artist
|
||||
field. Default: ``no``.
|
||||
- **preserve_album_artist**: If the artist and the album artist are the same,
|
||||
skip the ftintitle processing. Default: ``yes``.
|
||||
- **custom_words**: List of additional words that will be treated as a marker
|
||||
for artist features. Default: ``[]``.
|
||||
|
||||
|
|
|
|||
|
|
@ -205,6 +205,47 @@ def add_item(
|
|||
("Alice med Bob", "Song 1"),
|
||||
id="custom-feat-words-keep-in-artists-drop-from-title",
|
||||
),
|
||||
# ---- preserve_album_artist variants ----
|
||||
pytest.param(
|
||||
{
|
||||
"format": "feat. {}",
|
||||
"preserve_album_artist": True,
|
||||
},
|
||||
("ftintitle",),
|
||||
("Alice feat. Bob", "Song 1", "Alice"),
|
||||
("Alice", "Song 1 feat. Bob"),
|
||||
id="skip-if-artist-and-album-artists-is-the-same-different-match",
|
||||
),
|
||||
pytest.param(
|
||||
{
|
||||
"format": "feat. {}",
|
||||
"preserve_album_artist": False,
|
||||
},
|
||||
("ftintitle",),
|
||||
("Alice feat. Bob", "Song 1", "Alice"),
|
||||
("Alice", "Song 1 feat. Bob"),
|
||||
id="skip-if-artist-and-album-artists-is-the-same-different-match-b",
|
||||
),
|
||||
pytest.param(
|
||||
{
|
||||
"format": "feat. {}",
|
||||
"preserve_album_artist": True,
|
||||
},
|
||||
("ftintitle",),
|
||||
("Alice feat. Bob", "Song 1", "Alice feat. Bob"),
|
||||
("Alice feat. Bob", "Song 1"),
|
||||
id="skip-if-artist-and-album-artists-is-the-same-matching-match",
|
||||
),
|
||||
pytest.param(
|
||||
{
|
||||
"format": "feat. {}",
|
||||
"preserve_album_artist": False,
|
||||
},
|
||||
("ftintitle",),
|
||||
("Alice feat. Bob", "Song 1", "Alice feat. Bob"),
|
||||
("Alice", "Song 1 feat. Bob"),
|
||||
id="skip-if-artist-and-album-artists-is-the-same-matching-match-b",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_ftintitle_functional(
|
||||
|
|
|
|||
Loading…
Reference in a new issue