From 8b4f39da422de4b3a90e07fcd00bc76b7dcbd6c2 Mon Sep 17 00:00:00 2001 From: Fabrice Laporte Date: Fri, 23 Sep 2016 22:23:32 +0200 Subject: [PATCH] lyrics: search for song title part preceding colon. fix #2205 --- beetsplug/lyrics.py | 3 +++ test/test_lyrics.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index b2e5b5f0d..dc069e430 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -168,6 +168,9 @@ def search_pairs(item): for title in list(titles): titles.add(strip_part(title, pattern)) + # Remove part of the title string after colon ':' + titles.add(strip_part(title, r"(.+?)\s*:.*")) + # Check for a dual song (e.g. Pink Floyd - Speak to Me / Breathe) # and each of them. multi_titles = [] diff --git a/test/test_lyrics.py b/test/test_lyrics.py index d49c4d980..797a227be 100644 --- a/test/test_lyrics.py +++ b/test/test_lyrics.py @@ -84,6 +84,7 @@ class LyricsPluginTest(unittest.TestCase): self.assertIn(('Alice', ['song']), lyrics.search_pairs(item)) + def test_search_pairs_multi_titles(self): item = Item(title='1 / 2', artist='A') self.assertIn(('A', ['1 / 2']), lyrics.search_pairs(item)) @@ -118,6 +119,10 @@ class LyricsPluginTest(unittest.TestCase): self.assertNotIn(('A', ['Song']), lyrics.search_pairs(item)) self.assertIn(('A', ['Song and B']), lyrics.search_pairs(item)) + item = Item(title='Song: B', artist='A') + self.assertIn(('A', ['Song']), lyrics.search_pairs(item)) + self.assertIn(('A', ['Song: B']), lyrics.search_pairs(item)) + def test_remove_credits(self): self.assertEqual( lyrics.remove_credits("""It's close to midnight