@@ -24,6 +24,7 @@ search_url = url + 'search/{search_term}/{pageno}/'
25# specific xpath variables
25# specific xpath variables
26magnet_xpath = './/a[@title="Torrent magnet link"]'
26magnet_xpath = './/a[@title="Torrent magnet link"]'
27+torrent_xpath = './/a[@title="Download torrent file"]'
27content_xpath = './/span[@class="font11px lightgrey block"]'
28content_xpath = './/span[@class="font11px lightgrey block"]'
@@ -60,6 +61,9 @@ def response(resp):
60 method="text"))
61 method="text"))
61 seed = result.xpath('.//td[contains(@class, "green")]/text()')[0]
62 seed = result.xpath('.//td[contains(@class, "green")]/text()')[0]
62 leech = result.xpath('.//td[contains(@class, "red")]/text()')[0]
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]
64 # convert seed to int if possible
68 # convert seed to int if possible
65 if seed.isdigit():
69 if seed.isdigit():
@@ -73,7 +77,31 @@ def response(resp):
80+ # convert filesize to byte if possible
82+ filesize = float(filesize)
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)
96+ # convert files to int if possible
76 magnetlink = result.xpath(magnet_xpath)[0].attrib['href']
102 magnetlink = result.xpath(magnet_xpath)[0].attrib['href']
104+ torrentfile = result.xpath(torrent_xpath)[0].attrib['href']
78 # append result
106 # append result
79 results.append({'url': href,
107 results.append({'url': href,
@@ -81,7 +109,10 @@ def response(resp):
81 'content': content,
109 'content': content,
82 'seed': seed,
110 'seed': seed,
83 'leech': leech,
111 'leech': leech,
112+ 'filesize': filesize,
84 'magnetlink': magnetlink,
114 'magnetlink': magnetlink,
115+ 'torrentfile':torrentfile,
85 'template': 'torrent.html'})
116 'template': 'torrent.html'})
87 # return results sorted by seeder
118 # return results sorted by seeder