mirror of
https://github.com/beetbox/beets.git
synced 2026-01-11 02:13:28 +01:00
Merge pull request #3635 from jtpavlock/master
Fix genius lyrics backend artist matching with hyphens
This commit is contained in:
commit
3e32a4fb87
3 changed files with 18 additions and 6 deletions
|
|
@ -419,15 +419,13 @@ class Genius(Backend):
|
|||
return None
|
||||
|
||||
for hit in json["response"]["hits"]:
|
||||
# Genius uses zero-width characters to denote lowercase
|
||||
# artist names.
|
||||
hit_artist = hit["result"]["primary_artist"]["name"]. \
|
||||
strip(u'\u200b').lower()
|
||||
hit_artist = hit["result"]["primary_artist"]["name"]
|
||||
|
||||
if hit_artist == artist.lower():
|
||||
if slug(hit_artist) == slug(artist):
|
||||
return self.lyrics_from_song_page(hit["result"]["url"])
|
||||
|
||||
self._log.debug(u'genius: no matching artist')
|
||||
self._log.debug(u'Genius failed to find a matching artist for \'{0}\'',
|
||||
artist)
|
||||
|
||||
|
||||
class LyricsWiki(SymbolsReplaced):
|
||||
|
|
|
|||
|
|
@ -129,6 +129,9 @@ New features:
|
|||
* :doc:`/plugins/plexupdate`: Add option to use secure connection to Plex
|
||||
server, and to ignore certificate validation errors if necessary.
|
||||
:bug:`2871`
|
||||
* :doc:`/plugins/lyrics`: Improved searching Genius backend when artist
|
||||
contained special characters.
|
||||
:bug:`3634`
|
||||
|
||||
Fixes:
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import itertools
|
||||
import os
|
||||
import re
|
||||
import six
|
||||
|
|
@ -485,18 +486,28 @@ class SlugTests(unittest.TestCase):
|
|||
# plain ascii passthrough
|
||||
text = u"test"
|
||||
self.assertEqual(lyrics.slug(text), 'test')
|
||||
|
||||
# german unicode and capitals
|
||||
text = u"Mørdag"
|
||||
self.assertEqual(lyrics.slug(text), 'mordag')
|
||||
|
||||
# more accents and quotes
|
||||
text = u"l'été c'est fait pour jouer"
|
||||
self.assertEqual(lyrics.slug(text), 'l-ete-c-est-fait-pour-jouer')
|
||||
|
||||
# accents, parens and spaces
|
||||
text = u"\xe7afe au lait (boisson)"
|
||||
self.assertEqual(lyrics.slug(text), 'cafe-au-lait-boisson')
|
||||
text = u"Multiple spaces -- and symbols! -- merged"
|
||||
self.assertEqual(lyrics.slug(text),
|
||||
'multiple-spaces-and-symbols-merged')
|
||||
text = u"\u200Bno-width-space"
|
||||
self.assertEqual(lyrics.slug(text), 'no-width-space')
|
||||
|
||||
# variations of dashes should get standardized
|
||||
dashes = [u'\u200D', u'\u2010']
|
||||
for dash1, dash2 in itertools.combinations(dashes, 2):
|
||||
self.assertEqual(lyrics.slug(dash1), lyrics.slug(dash2))
|
||||
|
||||
|
||||
def suite():
|
||||
|
|
|
|||
Loading…
Reference in a new issue