mirror of
https://github.com/beetbox/beets.git
synced 2025-12-10 10:32:34 +01:00
Merge pull request #1911 from jackwilsdon/fix-musixmatch-url
Fix MusixMatch issues
This commit is contained in:
commit
c9be5bc7d1
2 changed files with 19 additions and 7 deletions
|
|
@ -200,18 +200,28 @@ class Backend(object):
|
|||
|
||||
|
||||
class SymbolsReplaced(Backend):
|
||||
REPLACEMENTS = {
|
||||
r'\s+': '_',
|
||||
'<': 'Less_Than',
|
||||
'>': 'Greater_Than',
|
||||
'#': 'Number_',
|
||||
r'[\[\{]': '(',
|
||||
r'[\[\{]': ')'
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def _encode(cls, s):
|
||||
s = re.sub(r'\s+', '_', s)
|
||||
s = s.replace("<", "Less_Than")
|
||||
s = s.replace(">", "Greater_Than")
|
||||
s = s.replace("#", "Number_")
|
||||
s = re.sub(r'[\[\{]', '(', s)
|
||||
s = re.sub(r'[\]\}]', ')', s)
|
||||
for old, new in cls.REPLACEMENTS.iteritems():
|
||||
s = re.sub(old, new, s)
|
||||
|
||||
return super(SymbolsReplaced, cls)._encode(s)
|
||||
|
||||
|
||||
class MusiXmatch(SymbolsReplaced):
|
||||
REPLACEMENTS = dict(SymbolsReplaced.REPLACEMENTS, **{
|
||||
r'\s+': '-'
|
||||
})
|
||||
|
||||
URL_PATTERN = 'https://www.musixmatch.com/lyrics/%s/%s'
|
||||
|
||||
def fetch(self, artist, title):
|
||||
|
|
@ -220,7 +230,7 @@ class MusiXmatch(SymbolsReplaced):
|
|||
if not html:
|
||||
return
|
||||
lyrics = extract_text_between(html,
|
||||
'"lyrics_body":', '"lyrics_language":')
|
||||
'"body":', '"language":')
|
||||
return lyrics.strip(',"').replace('\\n', '\n')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ Fixes:
|
|||
could undo the ``id3v23`` setting. :bug:`1903`
|
||||
* :doc:`/plugins/lyrics`: Add compatibility with some changes to the
|
||||
LyricsWiki page markup. :bug:`1912` :bug:`1909`
|
||||
* :doc:`/plugins/lyrics`: Also fix retrieval from Musixmatch and the way we
|
||||
guess the URL for lyrics. :bug:`1880`
|
||||
|
||||
|
||||
1.3.17 (February 7, 2016)
|
||||
|
|
|
|||
Loading…
Reference in a new issue