logo

searx

My custom branche(s) on searx, a meta-search engine
commit: 637d58f2ed22c96bb1281900540585f039d60818
parent: 66f87f8117df527e02d88fdbab5430d6ba02997d
Author: Adam Tauber <asciimoo@gmail.com>
Date:   Fri, 16 May 2014 16:43:40 +0200

Merge pull request #65 from rsdy/master

[enh] sort piratebay results by seeders

Diffstat:

Msearx/engines/piratebay.py9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/searx/engines/piratebay.py b/searx/engines/piratebay.py @@ -24,7 +24,6 @@ def request(query, params): pageno=params['pageno'] - 1) return params - def response(resp): results = [] dom = html.fromstring(resp.text) @@ -45,4 +44,10 @@ def response(resp): 'leech': leech, 'magnetlink': magnetlink.attrib['href'], 'template': 'torrent.html'}) - return results + return sorted(results, key=lambda x: get_int('seed'), reversed=True) + +def get_int(field): + try: + return int(field) + except TypeError: + return 0