logo

searx

My custom branche(s) on searx, a meta-search engine git clone https://hacktivis.me/git/searx.git
commit: 6725112e6bde20a78ea12df5ee23a323493e8395
parent 66f87f8117df527e02d88fdbab5430d6ba02997d
Author: rhapsodhy <me@rhapsodhy.hu>
Date:   Wed, 14 May 2014 19:30:32 +0100

[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