22 self.
url =
'http://api.genius.com/search?q=%s%%20%s&access_token=Rq_cyNZ6fUOQr4vhyES6vu1iw3e94RX85ju7S8-0jhM-gftzEvQPG7LJrrnTji11'
25 log(
'%s: searching lyrics for %s - %s' % (__title__, song.artist, song.title), debug=self.
DEBUG)
26 lyrics = Lyrics(settings=self.
settings)
28 lyrics.source = __title__
31 headers = {
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; rv:77.0) Gecko/20100101 Firefox/77.0'}
32 url = self.
url % (urllib.parse.quote(song.artist), urllib.parse.quote(song.title))
33 req = requests.get(url, headers=headers, timeout=10)
37 data = json.loads(response)
39 name = data[
'response'][
'hits'][0][
'result'][
'primary_artist'][
'name']
40 track = data[
'response'][
'hits'][0][
'result'][
'title']
41 if (difflib.SequenceMatcher(
None, song.artist.lower(), name.lower()).ratio() > 0.8)
and (difflib.SequenceMatcher(
None, song.title.lower(), track.lower()).ratio() > 0.8):
42 self.
page = data[
'response'][
'hits'][0][
'result'][
'url']
47 log(
'%s: search url: %s' % (__title__, self.
page), debug=self.
DEBUG)
49 headers = {
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; rv:77.0) Gecko/20100101 Firefox/77.0'}
50 req = requests.get(self.
page, headers=headers, timeout=10)
54 response = html.unescape(response)
55 matchcode = re.findall(
'class="Lyrics__Container.*?">(.*?)</div><div', response, flags=re.DOTALL)
58 for matchCodeItem
in matchcode:
59 lyricscode = lyricscode + matchCodeItem
60 lyr1 = re.sub(
'<br/>',
'\n', lyricscode)
61 lyr2 = re.sub(
'<[^<]+?>',
'', lyr1)
62 lyr3 = lyr2.replace(
'\\n',
'\n').strip()
63 if not lyr3
or lyr3 ==
'[Instrumental]' or lyr3.startswith(
'Lyrics for this song have yet to be released'):