Browse Source

Add torrent infos

jcherqui 7 years ago
parent
commit
39a97825d9
1 changed files with 10 additions and 1 deletions
  1. 10
    1
      searx/engines/1337x.py

+ 10
- 1
searx/engines/1337x.py View File

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