Skip to content

Commit

Permalink
Do not search for Various Artists, split titles by ' / '
Browse files Browse the repository at this point in the history
  • Loading branch information
snejus committed Jan 19, 2025
1 parent bcf7465 commit 730cb8f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
18 changes: 14 additions & 4 deletions beetsplug/lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,20 @@ def generate_alternatives(string, patterns):
# Remove any featuring artists from the artists name
rf"(.*?) {plugins.feat_tokens()}"
]
artists = generate_alternatives(artist, patterns)

# Skip various artists
artists = []
lower_artist = artist.lower()
if "various" not in lower_artist:
artists.extend(generate_alternatives(artist, patterns))
# Use the artist_sort as fallback only if it differs from artist to avoid
# repeated remote requests with the same search terms
if artist_sort and artist.lower() != artist_sort.lower():
artist_sort_lower = artist_sort.lower()
if (
artist_sort
and lower_artist != artist_sort_lower
and "various" not in artist_sort_lower
):
artists.append(artist_sort)

patterns = [
Expand All @@ -180,8 +190,8 @@ def generate_alternatives(string, patterns):
multi_titles = []
for title in titles:
multi_titles.append([title])
if "/" in title:
multi_titles.append([x.strip() for x in title.split("/")])
if " / " in title:
multi_titles.append([x.strip() for x in title.split(" / ")])

return itertools.product(artists, multi_titles)

Expand Down
3 changes: 2 additions & 1 deletion test/plugins/test_lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class TestLyricsUtils:
@pytest.mark.parametrize(
"artist, title",
[
("Various Artists", "Title"),
("Artist", ""),
("", "Title"),
(" ", ""),
Expand Down Expand Up @@ -81,7 +82,7 @@ def test_search_pairs_artists(
@pytest.mark.parametrize(
"title, expected_extra_titles",
[
("1/2", ["1", "2"]),
("1/2", []),
("1 / 2", ["1", "2"]),
("Song (live)", ["Song"]),
("Song (live) (new)", ["Song"]),
Expand Down

0 comments on commit 730cb8f

Please sign in to comment.