From 0549fb40d2ab0b14354e680880b0de3d9d770452 Mon Sep 17 00:00:00 2001 From: jcherqui Date: Sun, 15 Jan 2017 14:24:19 +0100 Subject: [PATCH 1/5] Add 1337x.to engine --- searx/engines/1337x.py | 29 +++++++++++++++++++++++++++++ searx/settings.yml | 4 ++++ 2 files changed, 33 insertions(+) create mode 100644 searx/engines/1337x.py diff --git a/searx/engines/1337x.py b/searx/engines/1337x.py new file mode 100644 index 000000000..8a5da9cb8 --- /dev/null +++ b/searx/engines/1337x.py @@ -0,0 +1,29 @@ +from urllib import quote +from lxml import html +from searx.engines.xpath import extract_text +from urlparse import urljoin + +url = 'https://1337x.to/' +search_url = url + 'search/{search_term}/{pageno}/' +categories = ['videos', 'music', 'files'] +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]')) + + results.append({'url': href, + 'title': title, + 'content': ''}) + + return results diff --git a/searx/settings.yml b/searx/settings.yml index 053cb4401..0ed8912cf 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 : False #The blekko technology and team have joined IBM Watson! -> https://blekko.com/ # - name : blekko images From a320328dda1ae2362a4eeb98e4e46f8ce38d33d3 Mon Sep 17 00:00:00 2001 From: jcherqui Date: Sun, 15 Jan 2017 14:50:29 +0100 Subject: [PATCH 2/5] Fix test --- searx/engines/1337x.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/searx/engines/1337x.py b/searx/engines/1337x.py index 8a5da9cb8..8c90a1b3e 100644 --- a/searx/engines/1337x.py +++ b/searx/engines/1337x.py @@ -8,11 +8,13 @@ search_url = url + 'search/{search_term}/{pageno}/' categories = ['videos', 'music', 'files'] paging = True + def request(query, params): params['url'] = search_url.format(search_term=quote(query), pageno=params['pageno']) return params + def response(resp): results = [] From 4776abd1acdc87a218eb6ae894008c6e8df4a2af Mon Sep 17 00:00:00 2001 From: jcherqui Date: Sun, 15 Jan 2017 15:08:43 +0100 Subject: [PATCH 3/5] Remove categories --- searx/engines/1337x.py | 2 +- searx/settings.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/searx/engines/1337x.py b/searx/engines/1337x.py index 8c90a1b3e..e0cf7e520 100644 --- a/searx/engines/1337x.py +++ b/searx/engines/1337x.py @@ -5,7 +5,7 @@ from urlparse import urljoin url = 'https://1337x.to/' search_url = url + 'search/{search_term}/{pageno}/' -categories = ['videos', 'music', 'files'] +categories = ['videos'] paging = True diff --git a/searx/settings.yml b/searx/settings.yml index 0ed8912cf..549b2b31d 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -591,7 +591,7 @@ engines: - name : 1337x engine : 1337x shortcut : 1337x - disabled : False + disabled : True #The blekko technology and team have joined IBM Watson! -> https://blekko.com/ # - name : blekko images From 39a97825d9cbcff4b2a29adbae4a745dbfa6c823 Mon Sep 17 00:00:00 2001 From: jcherqui Date: Sun, 15 Jan 2017 15:29:01 +0100 Subject: [PATCH 4/5] Add torrent infos --- searx/engines/1337x.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 From d98705bd061a444547420d74bf078537ca3d057c Mon Sep 17 00:00:00 2001 From: jcherqui Date: Sun, 15 Jan 2017 15:44:47 +0100 Subject: [PATCH 5/5] Add 1337x icon --- searx/static/themes/oscar/img/icons/1337x.png | Bin 0 -> 2128 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 searx/static/themes/oscar/img/icons/1337x.png 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 0000000000000000000000000000000000000000..1fde5f24819baf64885492bf9fa921295299fc4f GIT binary patch literal 2128 zcmV-W2(R~vP)u<8>Qi%s-M5q zN7i9{&vVs~AS!rSf zfM~=8O8{cVHf*yEoi?zkrhMy2tuYQnyPovAgnDJeRr@*?p^&cy$zQoh?A*3o7y2?# z#NtmpPaNCNf|Mpkz%*z*huhi(S5d^8cI>rHq9HC#{Vuqg>HUP(EdazGc}8#*yL;3$ zQw_0Y8h?2PtogxyTCcWcIsz~Uu*5iqIDPyb*K#YbS&KPZpT3a?mRQTd!{qR6@z)<+ z%jb{1P3sU44_d;=2zEm;ti_zG1tIGY+#*W{B#3bgv3B7zM+rxVu92m)2EH?nA=U=Y zI7*Oi%N4GXr2`VgYFD?B!!si_M56QgWFwBAo46r%NjU%jM>aSU2bsN;@&+Sc z-)fkeYUMS3dYslAgps8K6k^EN*A;U|UMK5N99cR*A;vMpg=?2+4FRCGVM=@bVQ>Xxjd`Y!eo-=3R6{jE8N?E%aruh&68QCL3ZTY}07y z=p-~`5d(%HM#7k#h&;5L(2z@vldtfFkxm)uRJ3b9p)HqK(~iAlLo9|>$QiTArk(p} z&AG&2Wel-x8l{PZZJN!b>4HFr1#XCK(D%l($7lKTvX7$+yB zPmNWxDnskQJ9amTn~Q;VD^- zTw-_~T6(cKI$XI0W1!C@3kmEexRqcL!|PC=n=FkEBjx7+?KNW&!|2c|Md2E9FDV5K9x|oI~(|f6b(c zF?D#y3vY0m<42bx#?)b5duM$2A#!uLWr#5~<%ltL7~g#;+`6u=osxQ8LLTQE<%ltL z*toSDc&P>e$lxBX1hGP5h@->snziLqYfh>GZW&_VY7)d2c>D5_)2r{;6kfBI(-kI) zks!u7zJyykEQ6LWU%rz*e>Gx>6%s@GOpd>zWFi)o0fZ`hp}Ux%{cR^W!% zg;*fzFWDJmt{=tgLk&^bG$yzPNq+