From c8876dde8e4647fd15db9160392c5ea21cee1398 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 15 Nov 2025 16:08:48 -0800 Subject: [PATCH] fix The artist behavior with artists with 'the' string in the name --- beetsplug/titlecase.py | 10 ++++++---- test/plugins/test_titlecase.py | 9 ++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/beetsplug/titlecase.py b/beetsplug/titlecase.py index 51cc8a12a..5309885f1 100644 --- a/beetsplug/titlecase.py +++ b/beetsplug/titlecase.py @@ -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) diff --git a/test/plugins/test_titlecase.py b/test/plugins/test_titlecase.py index d641c5b5d..2babe20ed 100644 --- a/test/plugins/test_titlecase.py +++ b/test/plugins/test_titlecase.py @@ -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, ),