mirror of
https://github.com/beetbox/beets.git
synced 2026-01-01 05:23:05 +01:00
fix The artist behavior with artists with 'the' string in the name
This commit is contained in:
parent
a6bda748ce
commit
c8876dde8e
2 changed files with 12 additions and 7 deletions
|
|
@ -154,10 +154,10 @@ class TitlecasePlugin(BeetsPlugin):
|
|||
init_field[0], str
|
||||
):
|
||||
cased_list: list[str] = [
|
||||
self.titlecase(i) for i in init_field
|
||||
self.titlecase(i, field) for i in init_field
|
||||
]
|
||||
setattr(item, field, cased_list)
|
||||
self._log.debug(
|
||||
self._log.info(
|
||||
(
|
||||
f"{field}: {', '.join(init_field)} -> "
|
||||
f"{', '.join(cased_list)}"
|
||||
|
|
@ -166,7 +166,7 @@ class TitlecasePlugin(BeetsPlugin):
|
|||
elif isinstance(init_field, str):
|
||||
cased: str = self.titlecase(init_field, field)
|
||||
setattr(item, field, cased)
|
||||
self._log.debug(f"{field}: {init_field} -> {cased}")
|
||||
self._log.info(f"{field}: {init_field} -> {cased}")
|
||||
else:
|
||||
self._log.debug(f"{field}: no string present")
|
||||
else:
|
||||
|
|
@ -185,7 +185,9 @@ class TitlecasePlugin(BeetsPlugin):
|
|||
callback=self.__preserved__,
|
||||
)
|
||||
if self.the_artist and "artist" in field:
|
||||
titlecased = titlecased.replace("the", "The")
|
||||
titlecased = titlecased.replace("the ", "The ").replace(
|
||||
" the", " The"
|
||||
)
|
||||
# More complicated phrase replacements.
|
||||
for phrase, regexp in self.preserve_phrases.items():
|
||||
titlecased = regexp.sub(phrase, titlecased)
|
||||
|
|
|
|||
|
|
@ -101,18 +101,21 @@ titlecase_test_cases = [
|
|||
},
|
||||
{
|
||||
"config": {
|
||||
"the_artist": True,
|
||||
"preserve": [""],
|
||||
"fields": ["artists", "discogs_artistid"],
|
||||
"fields": ["artist", "artists", "discogs_artistid"],
|
||||
"force_lowercase": False,
|
||||
"small_first_last": True,
|
||||
},
|
||||
"item": Item(
|
||||
artists=["artist_one", "artist_two"],
|
||||
artist="pinkpantheress",
|
||||
artists=["pinkpantheress", "artist_two"],
|
||||
artists_ids=["aBcDeF32", "aBcDeF12"],
|
||||
discogs_artistid=21,
|
||||
),
|
||||
"expected": Item(
|
||||
artists=["Artist_One", "Artist_Two"],
|
||||
artist="Pinkpantheress",
|
||||
artists=["Pinkpantheress", "Artist_Two"],
|
||||
artists_ids=["aBcDeF32", "aBcDeF12"],
|
||||
discogs_artistid=21,
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in a new issue