diff options
author | jcherqui <joachim.cherqui@viacesi.fr> | 2017-01-15 15:29:01 +0100 |
---|---|---|
committer | jcherqui <joachim.cherqui@viacesi.fr> | 2017-01-15 16:13:23 +0100 |
commit | 39a97825d9cbcff4b2a29adbae4a745dbfa6c823 (patch) | |
tree | cd7c7d3eda8eda9f8b3d13682b5d248fa0f595d9 /searx/engines | |
parent | 4776abd1acdc87a218eb6ae894008c6e8df4a2af (diff) | |
download | searxng-39a97825d9cbcff4b2a29adbae4a745dbfa6c823.tar.gz searxng-39a97825d9cbcff4b2a29adbae4a745dbfa6c823.zip |
Add torrent infos
Diffstat (limited to 'searx/engines')
-rw-r--r-- | searx/engines/1337x.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/searx/engines/1337x.py b/searx/engines/1337x.py index e0cf7e520..c6bc3cb6d 100644 --- a/searx/engines/1337x.py +++ b/searx/engines/1337x.py @@ -1,6 +1,7 @@ from urllib import quote from lxml import html from searx.engines.xpath import extract_text +from searx.utils import get_torrent_size from urlparse import urljoin url = 'https://1337x.to/' @@ -23,9 +24,17 @@ def response(resp): for result in dom.xpath('//table[contains(@class, "table-list")]/tbody//tr'): href = urljoin(url, result.xpath('./td[contains(@class, "name")]/a[2]/@href')[0]) title = extract_text(result.xpath('./td[contains(@class, "name")]/a[2]')) + seed = extract_text(result.xpath('.//td[contains(@class, "seeds")]')) + leech = extract_text(result.xpath('.//td[contains(@class, "leeches")]')) + filesize_info = extract_text(result.xpath('.//td[contains(@class, "size")]/text()')) + filesize, filesize_multiplier = filesize_info.split() + filesize = get_torrent_size(filesize, filesize_multiplier) results.append({'url': href, 'title': title, - 'content': ''}) + 'seed': seed, + 'leech': leech, + 'filesize': filesize, + 'template': 'torrent.html'}) return results |