Merge pull request #3901 from Ubiquitine/patch-1

Fix for Musixmatch multi-part lyrics
This commit is contained in:
Adrian Sampson 2021-04-07 08:33:40 -04:00 committed by GitHub
commit 2fa2d1b4ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -291,14 +291,21 @@ class MusiXmatch(Backend):
self._log.warning(u'we are blocked at MusixMatch: url %s failed'
% url)
return
html_part = html.split('<p class="mxm-lyrics__content')[-1]
lyrics = extract_text_between(html_part, '>', '</p>')
html_parts = html.split('<p class="mxm-lyrics__content')
# Sometimes lyrics come in 2 or more parts
lyrics_parts = []
for html_part in html_parts:
lyrics_parts.append(extract_text_between(html_part, '>', '</p>'))
lyrics = '\n'.join(lyrics_parts)
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 'Lyrics | Musixmatch' in lyrics:
return
return lyrics

View file

@ -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