Procházet zdrojové kódy

Merge pull request #829 from jcherqui/master

[WIP] Add 1337x.to engine
Adam Tauber před 7 roky
rodič
revize
1a9f8240b8

+ 40
- 0
searx/engines/1337x.py Zobrazit soubor

@@ -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

+ 4
- 0
searx/settings.yml Zobrazit soubor

@@ -588,6 +588,10 @@ engines:
588 588
     timeout : 10.0
589 589
     disabled : True
590 590
 
591
+  - name : 1337x
592
+    engine : 1337x
593
+    shortcut : 1337x
594
+    disabled : True
591 595
 
592 596
 #The blekko technology and team have joined IBM Watson! -> https://blekko.com/
593 597
 #  - name : blekko images

binární
searx/static/themes/oscar/img/icons/1337x.png Zobrazit soubor