Skip to content

Commit

Permalink
Merge pull request #2634 from anarcat/musixmatch-block-detect
Browse files Browse the repository at this point in the history
lyrics: detect MusixMatch blocking
  • Loading branch information
sampsyo committed Jul 18, 2017
2 parents 6e1d0a8 + a17974a commit c06eca7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion beetsplug/lyrics.py
Expand Up @@ -319,9 +319,19 @@ def fetch(self, artist, title):
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):
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Expand Up @@ -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:

Expand Down

0 comments on commit c06eca7

Please sign in to comment.