@@ -28,14 +28,11 @@ xpath_title = './/td[3]/a[last()]'
2828xpath_torrent_links = './/td[3]/a'
2929xpath_filesize = './/td[4]/text()'
3030
31−# do search-request
3231def request(query, params):
3332 query = urlencode({'keyword': query})
3433 params['url'] = search_url.format(query=query, offset=params['pageno'])
3534 return params
3635
37−
38−# get response from search-request
3936def response(resp):
4037 results = []
4138 dom = html.fromstring(resp.text)
@@ -46,23 +43,17 @@ def response(resp):
4643 magnet_link = "magnet:?xt=urn:btih:{}&tr=http://tracker.acgsou.com:2710/announce"
4744 torrent_link = ""
4845
49− # category in which our torrent belongs
5046 try:
5147 category = extract_text(result.xpath(xpath_category)[0])
5248 except:
5349 pass
5450
55− # torrent title
5651 page_a = result.xpath(xpath_title)[0]
5752 title = extract_text(page_a)
58−
59− # link to the page
6053 href = base_url + page_a.attrib.get('href')
61−
62− #magnet link
54+
6355 magnet_link = magnet_link.format(page_a.attrib.get('href')[5:-5])
6456
65− # let's try to calculate the torrent size
6657 try:
6758 filesize_info = result.xpath(xpath_filesize)[0]
6859 filesize = filesize_info[:-2]
@@ -70,16 +61,14 @@ def response(resp):
7061 filesize = get_torrent_size(filesize, filesize_multiplier)
7162 except :
7263 pass
73−
74− # content string contains all information not included into template
64+ #I didn't add download/seed/leech count since as I figured out they are generated randowmly everytime
7565 content = 'Category: "{category}".'
7666 content = content.format(category=category)
77−
67+
7868 results.append({'url': href,
7969 'title': title,
8070 'content': content,
8171 'filesize': filesize,
8272 'magnetlink': magnet_link,
8373 'template': 'torrent.html'})
84−
8574 return results