From a8fe8ce9a78ec320cd52a70b0ee2e7502ca8fc91 Mon Sep 17 00:00:00 2001 From: Evgeniy Gurevich Date: Thu, 1 Apr 2021 14:21:49 +0800 Subject: [PATCH 1/3] Fix for Musixmatch multi-part lyrics Sometimes Musixmatch lyrics come in 2 parts. Also, sometime non-existent lyrics return some content --- beetsplug/lyrics.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 08efd38ff..84fe6c6bb 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -291,14 +291,25 @@ class MusiXmatch(Backend): self._log.warning(u'we are blocked at MusixMatch: url %s failed' % url) return - html_part = html.split('

1: + html_part1 = html_parts[-2] + lyrics_part1 = extract_text_between(html_part1, '>', '

') + else: + lyrics_part1 = '' + html_part2 = html_parts[-1] + lyrics_part2 = extract_text_between(html_part2, '>', '

') + lyrics = lyrics_part1 + '\n' + lyrics_part2 lyrics = lyrics.strip(',"').replace('\\n', '\n') # another odd case: sometimes only that string remains, for # missing songs. this seems to happen after being blocked # above, when filling in the CAPTCHA. if "Instant lyrics for all your music." in lyrics: return + # sometimes there are non-existent lyrics with some content + if 'Think is wrong? You can always add the lyrics' in lyrics: + return return lyrics From afc072801c4a254e6b4114d89133d6bebc3e34b9 Mon Sep 17 00:00:00 2001 From: Evgeniy Gurevich Date: Fri, 2 Apr 2021 10:35:53 +0800 Subject: [PATCH 2/3] Simplify Musixmatch multi-part lyrics parser --- beetsplug/lyrics.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 84fe6c6bb..125d1330d 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -292,15 +292,11 @@ class MusiXmatch(Backend): % url) return html_parts = html.split('

Date: Wed, 7 Apr 2021 20:12:52 +0800 Subject: [PATCH 3/3] Update changelog.rst --- docs/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index d9e30e1fd..6aca3ac8e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -215,6 +215,8 @@ Other new things: Fixes: +* :bug:`/plugins/lyrics`: Fixed Musixmatch fetch lyrics divided into multiple elements on the web-page +* :bug:`/plugins/lyrics`: Fixed Musixmatch fetch for non-existing lyrics * :bug:`/plugins/web`: Allow use of backslash in regex web queries. :bug:`3867` * :bug:`/plugins/web`: Fixed a small bug which caused album artpath to be