fix genius lyrics artist matching when artist contains a hyphen

This commit is contained in:
Jacob Pavlock 2020-06-26 16:10:33 -07:00
parent 31855a9394
commit ae175e156b

View file

@ -419,16 +419,23 @@ 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 = self._clean(hit["result"]["primary_artist"]["name"])
if hit_artist == artist.lower():
if hit_artist.lower() == artist.lower():
return self.lyrics_from_song_page(hit["result"]["url"])
self._log.debug(u'genius: no matching artist')
def _clean(self, artist):
"""Cleans genius-isms to help artist matching"""
# Genius uses zero-width characters to denote lowercase artist names
artist = artist.strip(u'\u200b')
# Genius uses minus-hypen compared to beets hyphen
artist = artist.replace(u'\u002D', u'\u2010')
return artist
class LyricsWiki(SymbolsReplaced):
"""Fetch lyrics from LyricsWiki."""