瀏覽代碼

Add torrent infos

jcherqui 7 年之前
父節點
當前提交
39a97825d9
共有 1 個文件被更改,包括 10 次插入1 次删除
  1. 10
    1
      searx/engines/1337x.py

+ 10
- 1
searx/engines/1337x.py 查看文件

@@ -1,6 +1,7 @@
1 1
 from urllib import quote
2 2
 from lxml import html
3 3
 from searx.engines.xpath import extract_text
4
+from searx.utils import get_torrent_size
4 5
 from urlparse import urljoin
5 6
 
6 7
 url = 'https://1337x.to/'
@@ -23,9 +24,17 @@ def response(resp):
23 24
     for result in dom.xpath('//table[contains(@class, "table-list")]/tbody//tr'):
24 25
         href = urljoin(url, result.xpath('./td[contains(@class, "name")]/a[2]/@href')[0])
25 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)
26 32
 
27 33
         results.append({'url': href,
28 34
                         'title': title,
29
-                        'content': ''})
35
+                        'seed': seed,
36
+                        'leech': leech,
37
+                        'filesize': filesize,
38
+                        'template': 'torrent.html'})
30 39
 
31 40
     return results