From d43cf35ad233739bf397dfdc484cfedb779fe90a Mon Sep 17 00:00:00 2001 From: Xavier Hocquet Date: Thu, 5 Dec 2019 20:06:46 -0700 Subject: [PATCH 1/5] Strip and lowercase Genius lyrics artist comparison --- beetsplug/lyrics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 16699d9d3..1345018f0 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -395,7 +395,7 @@ class Genius(Backend): song_info = None for hit in json["response"]["hits"]: - if hit["result"]["primary_artist"]["name"] == artist: + if hit["result"]["primary_artist"]["name"].strip(u'\u200b').lower() == artist.lower(): song_info = hit break From c8e8e587f8ffd8319e941a3e201dfd6a516d368e Mon Sep 17 00:00:00 2001 From: Xavier Hocquet Date: Thu, 5 Dec 2019 20:06:49 -0700 Subject: [PATCH 2/5] Add debug logger for Genius lyrics no-match --- beetsplug/lyrics.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 1345018f0..b10f8dd02 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -402,6 +402,8 @@ class Genius(Backend): if song_info: song_api_path = song_info["result"]["api_path"] return self.lyrics_from_song_api_path(song_api_path) + else: + self._log.debug(u'Genius did not return a matching artist entry') class LyricsWiki(SymbolsReplaced): From a4a0a4bd28ca72205bfef7062606eb916261ea35 Mon Sep 17 00:00:00 2001 From: ybnd Date: Tue, 28 Jan 2020 09:45:20 +0100 Subject: [PATCH 3/5] Remove --replaygain flag when checking bs1770gain availability bs1770gain exits with error 1 when called without data, interpreted as unavailable --- test/test_replaygain.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test_replaygain.py b/test/test_replaygain.py index fe0515bee..437b1426a 100644 --- a/test/test_replaygain.py +++ b/test/test_replaygain.py @@ -40,7 +40,7 @@ if any(has_program(cmd, ['-v']) for cmd in ['mp3gain', 'aacgain']): else: GAIN_PROG_AVAILABLE = False -if has_program('bs1770gain', ['--replaygain']): +if has_program('bs1770gain'): LOUDNESS_PROG_AVAILABLE = True else: LOUDNESS_PROG_AVAILABLE = False @@ -58,7 +58,6 @@ def reset_replaygain(item): class ReplayGainCliTestBase(TestHelper): - def setUp(self): self.setup_beets() self.config['replaygain']['backend'] = self.backend From 9f43408f1b25910f7ebe98e0a30aab6ff0a33611 Mon Sep 17 00:00:00 2001 From: Xavier Hocquet Date: Sun, 2 Feb 2020 15:57:43 -0700 Subject: [PATCH 4/5] Changelog and cleanup --- beetsplug/lyrics.py | 8 ++++++-- docs/changelog.rst | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index b10f8dd02..20e39548c 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -395,15 +395,19 @@ class Genius(Backend): song_info = None for hit in json["response"]["hits"]: - if hit["result"]["primary_artist"]["name"].strip(u'\u200b').lower() == artist.lower(): + # Genius uses zero-width characters to denote lowercase artist names + hit_artist = hit["result"]["primary_artist"]["name"].strip(u'\u200b').lower() + + if hit_artist == artist.lower(): song_info = hit break if song_info: + self._log.debug(u'fetched: {0}', song_info["result"]["url"]) song_api_path = song_info["result"]["api_path"] return self.lyrics_from_song_api_path(song_api_path) else: - self._log.debug(u'Genius did not return a matching artist entry') + self._log.debug(u'genius: no matching artist') class LyricsWiki(SymbolsReplaced): diff --git a/docs/changelog.rst b/docs/changelog.rst index c6b805b30..545bf7a84 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -134,6 +134,8 @@ Fixes: * :doc:`/plugins/bpd`: Fix the transition to next track when in consume mode. Thanks to :user:`aereaux`. :bug:`3437` +* :doc:`/plugins/lyrics`: Fix a corner-case with Genius lowercase artist names + :bug:`3446` For plugin developers: From 95e0f54d7cea6c338efa47d16bc96c148970219f Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 2 Feb 2020 21:04:55 -0500 Subject: [PATCH 5/5] Fix too-long lines (#3448) --- beetsplug/lyrics.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 20e39548c..0e797d5a3 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -395,8 +395,10 @@ class Genius(Backend): song_info = None for hit in json["response"]["hits"]: - # Genius uses zero-width characters to denote lowercase artist names - hit_artist = hit["result"]["primary_artist"]["name"].strip(u'\u200b').lower() + # Genius uses zero-width characters to denote lowercase + # artist names. + hit_artist = hit["result"]["primary_artist"]["name"]. \ + strip(u'\u200b').lower() if hit_artist == artist.lower(): song_info = hit