|
@@ -24,6 +24,7 @@ search_url = url + 'search/{search_term}/{pageno}/'
|
24
|
24
|
|
25
|
25
|
# specific xpath variables
|
26
|
26
|
magnet_xpath = './/a[@title="Torrent magnet link"]'
|
|
27
|
+torrent_xpath = './/a[@title="Download torrent file"]'
|
27
|
28
|
content_xpath = './/span[@class="font11px lightgrey block"]'
|
28
|
29
|
|
29
|
30
|
|
|
@@ -60,6 +61,9 @@ def response(resp):
|
60
|
61
|
method="text"))
|
61
|
62
|
seed = result.xpath('.//td[contains(@class, "green")]/text()')[0]
|
62
|
63
|
leech = result.xpath('.//td[contains(@class, "red")]/text()')[0]
|
|
64
|
+ filesize = result.xpath('.//td[contains(@class, "nobr")]/text()')[0]
|
|
65
|
+ filesize_multiplier = result.xpath('.//td[contains(@class, "nobr")]//span/text()')[0]
|
|
66
|
+ files = result.xpath('.//td[contains(@class, "center")][2]/text()')[0]
|
63
|
67
|
|
64
|
68
|
# convert seed to int if possible
|
65
|
69
|
if seed.isdigit():
|
|
@@ -73,7 +77,31 @@ def response(resp):
|
73
|
77
|
else:
|
74
|
78
|
leech = 0
|
75
|
79
|
|
|
80
|
+ # convert filesize to byte if possible
|
|
81
|
+ try:
|
|
82
|
+ filesize = float(filesize)
|
|
83
|
+
|
|
84
|
+ # convert filesize to byte
|
|
85
|
+ if filesize_multiplier == 'TB':
|
|
86
|
+ filesize = int(filesize * 1024*1024*1024*1024)
|
|
87
|
+ elif filesize_multiplier == 'GB':
|
|
88
|
+ filesize = int(filesize * 1024*1024*1024)
|
|
89
|
+ elif filesize_multiplier == 'MB':
|
|
90
|
+ filesize = int(filesize * 1024*1024)
|
|
91
|
+ elif filesize_multiplier == 'kb':
|
|
92
|
+ filesize = int(filesize * 1024)
|
|
93
|
+ except:
|
|
94
|
+ filesize = None
|
|
95
|
+
|
|
96
|
+ # convert files to int if possible
|
|
97
|
+ if files.isdigit():
|
|
98
|
+ files = int(files)
|
|
99
|
+ else:
|
|
100
|
+ files = None
|
|
101
|
+
|
76
|
102
|
magnetlink = result.xpath(magnet_xpath)[0].attrib['href']
|
|
103
|
+
|
|
104
|
+ torrentfile = result.xpath(torrent_xpath)[0].attrib['href']
|
77
|
105
|
|
78
|
106
|
# append result
|
79
|
107
|
results.append({'url': href,
|
|
@@ -81,7 +109,10 @@ def response(resp):
|
81
|
109
|
'content': content,
|
82
|
110
|
'seed': seed,
|
83
|
111
|
'leech': leech,
|
|
112
|
+ 'filesize': filesize,
|
|
113
|
+ 'files': files,
|
84
|
114
|
'magnetlink': magnetlink,
|
|
115
|
+ 'torrentfile':torrentfile,
|
85
|
116
|
'template': 'torrent.html'})
|
86
|
117
|
|
87
|
118
|
# return results sorted by seeder
|