summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2017-01-15 16:57:04 +0100
committerGitHub <noreply@github.com>2017-01-15 16:57:04 +0100
commit1a9f8240b851c64a10be7b8990b6f3926ca506b3 (patch)
tree98593d720fcf96447f6fcd696a6360421ad208de /searx
parent9d9a592266ffc4f257be5c0f7519a19436672cf5 (diff)
parentd98705bd061a444547420d74bf078537ca3d057c (diff)
downloadsearxng-1a9f8240b851c64a10be7b8990b6f3926ca506b3.tar.gz
searxng-1a9f8240b851c64a10be7b8990b6f3926ca506b3.zip
Merge pull request #829 from jcherqui/master
[WIP] Add 1337x.to engine
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/1337x.py40
-rw-r--r--searx/settings.yml4
-rw-r--r--searx/static/themes/oscar/img/icons/1337x.pngbin0 -> 2128 bytes
3 files changed, 44 insertions, 0 deletions
diff --git a/searx/engines/1337x.py b/searx/engines/1337x.py
new file mode 100644
index 000000000..c6bc3cb6d
--- /dev/null
+++ b/searx/engines/1337x.py
@@ -0,0 +1,40 @@
+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/'
+search_url = url + 'search/{search_term}/{pageno}/'
+categories = ['videos']
+paging = True
+
+
+def request(query, params):
+ params['url'] = search_url.format(search_term=quote(query), pageno=params['pageno'])
+
+ return params
+
+
+def response(resp):
+ results = []
+
+ dom = html.fromstring(resp.text)
+
+ 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,
+ 'seed': seed,
+ 'leech': leech,
+ 'filesize': filesize,
+ 'template': 'torrent.html'})
+
+ return results
diff --git a/searx/settings.yml b/searx/settings.yml
index 053cb4401..549b2b31d 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -588,6 +588,10 @@ engines:
timeout : 10.0
disabled : True
+ - name : 1337x
+ engine : 1337x
+ shortcut : 1337x
+ disabled : True
#The blekko technology and team have joined IBM Watson! -> https://blekko.com/
# - name : blekko images
diff --git a/searx/static/themes/oscar/img/icons/1337x.png b/searx/static/themes/oscar/img/icons/1337x.png
new file mode 100644
index 000000000..1fde5f248
--- /dev/null
+++ b/searx/static/themes/oscar/img/icons/1337x.png
Binary files differ