From f95f661efda1d06e2865bd076e293d13c52d955b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Sun, 19 Jan 2025 15:42:47 +0000 Subject: [PATCH] Do not search for Various Artists, split titles by ' / ' --- beetsplug/lyrics.py | 18 ++++++++++++++---- test/plugins/test_lyrics.py | 3 ++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 0b121eee63..5de57c8cc1 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -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 = [ @@ -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) diff --git a/test/plugins/test_lyrics.py b/test/plugins/test_lyrics.py index 24a870a918..c6d48c3bdb 100644 --- a/test/plugins/test_lyrics.py +++ b/test/plugins/test_lyrics.py @@ -37,6 +37,7 @@ class TestLyricsUtils: @pytest.mark.parametrize( "artist, title", [ + ("Various Artists", "Title"), ("Artist", ""), ("", "Title"), (" ", ""), @@ -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"]),