|
@@ -28,14 +28,11 @@ xpath_title = './/td[3]/a[last()]'
|
28
|
28
|
xpath_torrent_links = './/td[3]/a'
|
29
|
29
|
xpath_filesize = './/td[4]/text()'
|
30
|
30
|
|
31
|
|
-# do search-request
|
32
|
31
|
def request(query, params):
|
33
|
32
|
query = urlencode({'keyword': query})
|
34
|
33
|
params['url'] = search_url.format(query=query, offset=params['pageno'])
|
35
|
34
|
return params
|
36
|
35
|
|
37
|
|
-
|
38
|
|
-# get response from search-request
|
39
|
36
|
def response(resp):
|
40
|
37
|
results = []
|
41
|
38
|
dom = html.fromstring(resp.text)
|
|
@@ -46,23 +43,17 @@ def response(resp):
|
46
|
43
|
magnet_link = "magnet:?xt=urn:btih:{}&tr=http://tracker.acgsou.com:2710/announce"
|
47
|
44
|
torrent_link = ""
|
48
|
45
|
|
49
|
|
- # category in which our torrent belongs
|
50
|
46
|
try:
|
51
|
47
|
category = extract_text(result.xpath(xpath_category)[0])
|
52
|
48
|
except:
|
53
|
49
|
pass
|
54
|
50
|
|
55
|
|
- # torrent title
|
56
|
51
|
page_a = result.xpath(xpath_title)[0]
|
57
|
52
|
title = extract_text(page_a)
|
58
|
|
-
|
59
|
|
- # link to the page
|
60
|
53
|
href = base_url + page_a.attrib.get('href')
|
61
|
|
-
|
62
|
|
- #magnet link
|
|
54
|
+
|
63
|
55
|
magnet_link = magnet_link.format(page_a.attrib.get('href')[5:-5])
|
64
|
56
|
|
65
|
|
- # let's try to calculate the torrent size
|
66
|
57
|
try:
|
67
|
58
|
filesize_info = result.xpath(xpath_filesize)[0]
|
68
|
59
|
filesize = filesize_info[:-2]
|
|
@@ -70,16 +61,14 @@ def response(resp):
|
70
|
61
|
filesize = get_torrent_size(filesize, filesize_multiplier)
|
71
|
62
|
except :
|
72
|
63
|
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
|
75
|
65
|
content = 'Category: "{category}".'
|
76
|
66
|
content = content.format(category=category)
|
77
|
|
-
|
|
67
|
+
|
78
|
68
|
results.append({'url': href,
|
79
|
69
|
'title': title,
|
80
|
70
|
'content': content,
|
81
|
71
|
'filesize': filesize,
|
82
|
72
|
'magnetlink': magnet_link,
|
83
|
73
|
'template': 'torrent.html'})
|
84
|
|
-
|
85
|
74
|
return results
|