Merge pull request #2634 from anarcat/musixmatch-block-detect

lyrics: detect MusixMatch blocking
This commit is contained in:
Adrian Sampson 2017-07-18 17:13:31 -04:00 committed by GitHub
commit c06eca7e58
2 changed files with 14 additions and 1 deletions

View file

@ -319,9 +319,19 @@ class MusiXmatch(SymbolsReplaced):
html = self.fetch_url(url)
if not html:
return
if "We detected that your IP is blocked" in html:
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>')
return lyrics.strip(',"').replace('\\n', '\n')
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
return lyrics
class Genius(Backend):

View file

@ -14,6 +14,9 @@ Fixes:
* :doc:`/plugins/replaygain`: Fix a regression in the previous release related
to the new R128 tags. :bug:`2615` :bug:`2623`
* :doc:`/plugins/lyrics`: The MusixMatch backend now detect and warns
the user when blocked on the server. Thanks to
:user:`anarcat`. :bug:`2634` :bug:`2632`
For developers: