on master help sign in
Merge pull request #144 from Cqoicebordel/KickassTorrent-Search-Engine

Kickass torrent search engine

commite047d22046e9f4b5cff80c9ec9ee321b209641cb authorAdam Tauber <asciimoo@gmail.com> dateMon 15 Dec 2014, 00:02 (12 years ago) parentba51d78e623ee5
6 files changed+89−1
searx/engines/kickass.py+84 searx/settings.yml+4 searx/static/courgette/img/icon_kickass.ico searx/static/default/img/icon_kickass.ico searx/static/oscar/img/icons/kickass.png searx/webapp.py+1−1
searx/engines/kickass.pynew file+84
@@ -0,0 +1,84 @@
1+## Kickass Torrent (Videos, Music, Files)
2+#
3+# @website https://kickass.so
4+# @provide-api no (nothing found)
5+#
6+# @using-api no
7+# @results HTML (using search portal)
8+# @stable yes (HTML can change)
9+# @parse url, title, content, seed, leech, magnetlink
10+
11+from urlparse import urljoin
12+from cgi import escape
13+from urllib import quote
14+from lxml import html
15+from operator import itemgetter
16+from dateutil import parser
17+
18+# engine dependent config
19+categories = ['videos', 'music', 'files']
20+paging = True
21+
22+# search-url
23+url = 'https://kickass.so/'
24+search_url = url + 'search/{search_term}/{pageno}/'
25+
26+# specific xpath variables
27+magnet_xpath = './/a[@title="Torrent magnet link"]'
28+#content_xpath = './/font[@class="detDesc"]//text()'
29+
30+
31+# do search-request
32+def request(query, params):
33+ params['url'] = search_url.format(search_term=quote(query),
34+ pageno=params['pageno'])
35+
36+ return params
37+
38+
39+# get response from search-request
40+def response(resp):
41+ results = []
42+
43+ dom = html.fromstring(resp.text)
44+
45+ search_res = dom.xpath('//table[@class="data"]//tr')
46+
47+ # return empty array if nothing is found
48+ if not search_res:
49+ return []
50+
51+ # parse results
52+ for result in search_res[1:]:
53+ link = result.xpath('.//a[@class="cellMainLink"]')[0]
54+ href = urljoin(url, link.attrib['href'])
55+ title = ' '.join(link.xpath('.//text()'))
56+ content = escape(html.tostring(result.xpath('.//span[@class="font11px lightgrey block"]')[0], method="text"))
57+ seed = result.xpath('.//td[contains(@class, "green")]/text()')[0]
58+ leech = result.xpath('.//td[contains(@class, "red")]/text()')[0]
59+
60+ # convert seed to int if possible
61+ if seed.isdigit():
62+ seed = int(seed)
63+ else:
64+ seed = 0
65+
66+ # convert leech to int if possible
67+ if leech.isdigit():
68+ leech = int(leech)
69+ else:
70+ leech = 0
71+
72+ magnetlink = result.xpath(magnet_xpath)[0].attrib['href']
73+
74+ # append result
75+ results.append({'url': href,
76+ 'title': title,
77+ 'content': content,
78+ 'seed': seed,
79+ 'leech': leech,
80+ 'magnetlink': magnetlink,
81+ 'template': 'torrent.html'})
82+
83+ # return results sorted by seeder
84+ return sorted(results, key=itemgetter('seed'), reverse=True)
searx/settings.yml+4
@@ -99,6 +99,10 @@ engines:
9999# engine : piratebay
100100# shortcut : tpb
101101
102+ - name : kickass
103+ engine : kickass
104+ shortcut : ka
105+
102106 - name : soundcloud
103107 engine : soundcloud
104108 shortcut : sc
searx/static/courgette/img/icon_kickass.iconew file

Binary file not shown.

searx/static/default/img/icon_kickass.iconew file

Binary file not shown.

searx/static/oscar/img/icons/kickass.pngnew file

Binary file not shown.

searx/webapp.py+1−1
@@ -70,7 +70,7 @@ babel = Babel(app)
7070
7171#TODO configurable via settings.yml
7272favicons = ['wikipedia', 'youtube', 'vimeo', 'dailymotion', 'soundcloud',
73− 'twitter', 'stackoverflow', 'github', 'deviantart']
73+ 'twitter', 'stackoverflow', 'github', 'deviantart', 'kickass']
7474
7575cookie_max_age = 60 * 60 * 24 * 365 * 23 # 23 years
7676