mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Add album template value in ftintitle plugin
This commit is contained in:
parent
f79c125d15
commit
9c37f94171
5 changed files with 32 additions and 3 deletions
|
|
@ -19,11 +19,11 @@ from __future__ import annotations
|
||||||
import re
|
import re
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from beets import plugins, ui
|
from beets import config, plugins, ui
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from beets.importer import ImportSession, ImportTask
|
from beets.importer import ImportSession, ImportTask
|
||||||
from beets.library import Item
|
from beets.library import Album, Item
|
||||||
|
|
||||||
|
|
||||||
def split_on_feat(
|
def split_on_feat(
|
||||||
|
|
@ -98,6 +98,11 @@ def find_feat_part(
|
||||||
return feat_part
|
return feat_part
|
||||||
|
|
||||||
|
|
||||||
|
def _album_artist_no_feat(album: Album) -> str:
|
||||||
|
custom_words = config["ftintitle"]["custom_words"].as_str_seq()
|
||||||
|
return split_on_feat(album["albumartist"], False, list(custom_words))[0]
|
||||||
|
|
||||||
|
|
||||||
class FtInTitlePlugin(plugins.BeetsPlugin):
|
class FtInTitlePlugin(plugins.BeetsPlugin):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
@ -129,6 +134,10 @@ class FtInTitlePlugin(plugins.BeetsPlugin):
|
||||||
if self.config["auto"]:
|
if self.config["auto"]:
|
||||||
self.import_stages = [self.imported]
|
self.import_stages = [self.imported]
|
||||||
|
|
||||||
|
self.album_template_fields["album_artist_no_feat"] = (
|
||||||
|
_album_artist_no_feat
|
||||||
|
)
|
||||||
|
|
||||||
def commands(self) -> list[ui.Subcommand]:
|
def commands(self) -> list[ui.Subcommand]:
|
||||||
def func(lib, opts, args):
|
def func(lib, opts, args):
|
||||||
self.config.set_args(opts)
|
self.config.set_args(opts)
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ been dropped.
|
||||||
New features:
|
New features:
|
||||||
|
|
||||||
- :doc:`plugins/ftintitle`: Added argument for custom feat. words in ftintitle.
|
- :doc:`plugins/ftintitle`: Added argument for custom feat. words in ftintitle.
|
||||||
|
- :doc:`plugins/ftintitle`: Added album template value ``album_artist_no_feat``.
|
||||||
- :doc:`plugins/musicbrainz`: Allow selecting tags or genres to populate the
|
- :doc:`plugins/musicbrainz`: Allow selecting tags or genres to populate the
|
||||||
genres tag.
|
genres tag.
|
||||||
- :doc:`plugins/ftintitle`: Added argument to skip the processing of artist and
|
- :doc:`plugins/ftintitle`: Added argument to skip the processing of artist and
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,14 @@ file. The available options are:
|
||||||
- **custom_words**: List of additional words that will be treated as a marker
|
- **custom_words**: List of additional words that will be treated as a marker
|
||||||
for artist features. Default: ``[]``.
|
for artist features. Default: ``[]``.
|
||||||
|
|
||||||
|
Path Template Values
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
This plugin provides the ``album_artist_no_feat`` :ref:`template value
|
||||||
|
<templ_plugins>` that you can use in your :ref:`path-format-config` in
|
||||||
|
``paths.default``. Any ``custom_words`` in the configuration are taken into
|
||||||
|
account.
|
||||||
|
|
||||||
Running Manually
|
Running Manually
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -281,6 +281,8 @@ constructs include:
|
||||||
|
|
||||||
- ``$missing`` by :doc:`/plugins/missing`: The number of missing tracks per
|
- ``$missing`` by :doc:`/plugins/missing`: The number of missing tracks per
|
||||||
album.
|
album.
|
||||||
|
- ``$album_artist_no_feat`` by :doc:`/plugins/ftintitle`: The album artist
|
||||||
|
without any featured artists
|
||||||
- ``%bucket{text}`` by :doc:`/plugins/bucket`: Substitute a string by the range
|
- ``%bucket{text}`` by :doc:`/plugins/bucket`: Substitute a string by the range
|
||||||
it belongs to.
|
it belongs to.
|
||||||
- ``%the{text}`` by :doc:`/plugins/the`: Moves English articles to ends of
|
- ``%the{text}`` by :doc:`/plugins/the`: Moves English articles to ends of
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ from collections.abc import Generator
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from beets.library.models import Item
|
from beets.library.models import Album, Item
|
||||||
from beets.test.helper import PluginTestCase
|
from beets.test.helper import PluginTestCase
|
||||||
from beetsplug import ftintitle
|
from beetsplug import ftintitle
|
||||||
|
|
||||||
|
|
@ -364,3 +364,12 @@ def test_custom_words(
|
||||||
if custom_words is None:
|
if custom_words is None:
|
||||||
custom_words = []
|
custom_words = []
|
||||||
assert ftintitle.contains_feat(given, custom_words) is expected
|
assert ftintitle.contains_feat(given, custom_words) is expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_album_template_value():
|
||||||
|
album = Album()
|
||||||
|
album["albumartist"] = "Foo ft. Bar"
|
||||||
|
assert ftintitle._album_artist_no_feat(album) == "Foo"
|
||||||
|
|
||||||
|
album["albumartist"] = "Foobar"
|
||||||
|
assert ftintitle._album_artist_no_feat(album) == "Foobar"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue