|
@@ -0,0 +1,40 @@
|
|
1
|
+from urllib import quote
|
|
2
|
+from lxml import html
|
|
3
|
+from searx.engines.xpath import extract_text
|
|
4
|
+from searx.utils import get_torrent_size
|
|
5
|
+from urlparse import urljoin
|
|
6
|
+
|
|
7
|
+url = 'https://1337x.to/'
|
|
8
|
+search_url = url + 'search/{search_term}/{pageno}/'
|
|
9
|
+categories = ['videos']
|
|
10
|
+paging = True
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+def request(query, params):
|
|
14
|
+ params['url'] = search_url.format(search_term=quote(query), pageno=params['pageno'])
|
|
15
|
+
|
|
16
|
+ return params
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+def response(resp):
|
|
20
|
+ results = []
|
|
21
|
+
|
|
22
|
+ dom = html.fromstring(resp.text)
|
|
23
|
+
|
|
24
|
+ for result in dom.xpath('//table[contains(@class, "table-list")]/tbody//tr'):
|
|
25
|
+ href = urljoin(url, result.xpath('./td[contains(@class, "name")]/a[2]/@href')[0])
|
|
26
|
+ title = extract_text(result.xpath('./td[contains(@class, "name")]/a[2]'))
|
|
27
|
+ seed = extract_text(result.xpath('.//td[contains(@class, "seeds")]'))
|
|
28
|
+ leech = extract_text(result.xpath('.//td[contains(@class, "leeches")]'))
|
|
29
|
+ filesize_info = extract_text(result.xpath('.//td[contains(@class, "size")]/text()'))
|
|
30
|
+ filesize, filesize_multiplier = filesize_info.split()
|
|
31
|
+ filesize = get_torrent_size(filesize, filesize_multiplier)
|
|
32
|
+
|
|
33
|
+ results.append({'url': href,
|
|
34
|
+ 'title': title,
|
|
35
|
+ 'seed': seed,
|
|
36
|
+ 'leech': leech,
|
|
37
|
+ 'filesize': filesize,
|
|
38
|
+ 'template': 'torrent.html'})
|
|
39
|
+
|
|
40
|
+ return results
|