3Scraper for http://www.darklyrics.com/ - the largest metal lyrics archive on the Web.
16 from ctypes
import c_int32
20__title__ =
'darklyrics'
30 self.
searchUrl =
'http://www.darklyrics.com/search?q=%s'
35 lastvisitts =
'Nergal' + str(math.ceil(time.time() * 1000 / (60 * 60 * 6 * 1000)))
38 while i < len(lastvisitts):
40 lastvisittscookie = c_int32((c_int32(lastvisittscookie<<5).value - c_int32(lastvisittscookie).value) + ord(lastvisitts[i])).value
44 lastvisittscookie = lastvisittscookie & lastvisittscookie
45 return str(lastvisittscookie)
48 term = urllib.parse.quote((artist
if artist
else '') +
'+' + (title
if title
else ''))
50 headers = {
'user-agent':
'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0'}
51 req = requests.get(self.
searchUrl % term, headers=headers, cookies={
'lastvisitts': self.
cookie}, timeout=10)
52 searchResponse = req.text
55 searchResult = re.findall(
'<h2><a\shref="(.*?#([0-9]+))".*?>(.*?)</a></h2>', searchResponse)
56 if len(searchResult) == 0:
60 for result
in searchResult:
73 headers = {
'user-agent':
'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0'}
74 req = requests.get(url, headers=headers, cookies={
'lastvisitts': self.
cookie}, timeout=10)
78 pattern =
'<a\sname="%index%">(.*?)(?:<h3>|<div)'
79 pattern = pattern.replace(
'%index%', index)
80 match = re.search(pattern, res, re.MULTILINE | re.DOTALL)
83 s = s.replace(
'<br />',
'')
84 s = s.replace(
'<i>',
'')
85 s = s.replace(
'</i>',
'')
86 s = s.replace(
'</a>',
'')
87 s = s.replace(
'</h3>',
'')
94 headers = {
'user-agent':
'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0'}
95 req = requests.get(url, headers=headers, cookies={
'lastvisitts': self.
cookie}, timeout=10)
99 match = re.search(
'<h2>(?:album|single|ep|live):?\s?(.*?)</h2>', res, re.IGNORECASE)
101 return (
'(' + match.group(1) +
')').replace(
'\'',
'')
106 log(
'%s: searching lyrics for %s - %s' % (__title__, song.artist, song.title), debug=self.
DEBUG)
107 lyrics = Lyrics(settings=self.
settings)
109 lyrics.source = __title__
111 links = self.
search(song.artist , song.title)
112 if(links ==
None or len(links) == 0):
123 title, url, artist, song, index = link
def search(self, artist, title)
def getAlbumName(self, url)
def get_lyrics_from_list(self, link)
def findLyrics(self, url, index)
def __init__(self, *args, **kwargs)
def get_lyrics(self, song)
None log(str msg, int level=LOGDEBUG)