summaryrefslogtreecommitdiff
path: root/searx/engines
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2015-01-11 01:20:46 +0100
committerAdam Tauber <asciimoo@gmail.com>2015-01-11 01:20:46 +0100
commit8ef709ea1f86413d04051eea0876c20a48c8ae90 (patch)
treebb08e23f6760320c180282c6b90010ec60199c64 /searx/engines
parentaff33ea8969a477e9e02ef4be00872685ba1ca72 (diff)
parent9109686c4e7208e0c228afcc8dfe5e20e24d598d (diff)
Merge pull request #170 from pointhi/little_fixes
Little fixes, add searx-autocompletion, more informations about torrents
Diffstat (limited to 'searx/engines')
-rw-r--r--searx/engines/kickass.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/searx/engines/kickass.py b/searx/engines/kickass.py
index 16e9d6de6..a4d270673 100644
--- a/searx/engines/kickass.py
+++ b/searx/engines/kickass.py
@@ -24,6 +24,7 @@ search_url = url + 'search/{search_term}/{pageno}/'
# specific xpath variables
magnet_xpath = './/a[@title="Torrent magnet link"]'
+torrent_xpath = './/a[@title="Download torrent file"]'
content_xpath = './/span[@class="font11px lightgrey block"]'
@@ -60,6 +61,9 @@ def response(resp):
method="text"))
seed = result.xpath('.//td[contains(@class, "green")]/text()')[0]
leech = result.xpath('.//td[contains(@class, "red")]/text()')[0]
+ filesize = result.xpath('.//td[contains(@class, "nobr")]/text()')[0]
+ filesize_multiplier = result.xpath('.//td[contains(@class, "nobr")]//span/text()')[0]
+ files = result.xpath('.//td[contains(@class, "center")][2]/text()')[0]
# convert seed to int if possible
if seed.isdigit():
@@ -73,15 +77,42 @@ def response(resp):
else:
leech = 0
+ # convert filesize to byte if possible
+ try:
+ filesize = float(filesize)
+
+ # convert filesize to byte
+ if filesize_multiplier == 'TB':
+ filesize = int(filesize * 1024 * 1024 * 1024 * 1024)
+ elif filesize_multiplier == 'GB':
+ filesize = int(filesize * 1024 * 1024 * 1024)
+ elif filesize_multiplier == 'MB':
+ filesize = int(filesize * 1024 * 1024)
+ elif filesize_multiplier == 'kb':
+ filesize = int(filesize * 1024)
+ except:
+ filesize = None
+
+ # convert files to int if possible
+ if files.isdigit():
+ files = int(files)
+ else:
+ files = None
+
magnetlink = result.xpath(magnet_xpath)[0].attrib['href']
+ torrentfile = result.xpath(torrent_xpath)[0].attrib['href']
+
# append result
results.append({'url': href,
'title': title,
'content': content,
'seed': seed,
'leech': leech,
+ 'filesize': filesize,
+ 'files': files,
'magnetlink': magnetlink,
+ 'torrentfile': torrentfile,
'template': 'torrent.html'})
# return results sorted by seeder