Skip to content

SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.

[enh] sort piratebay results by seeders

rhapsodhy6725112e6bde
diff --git a/searx/engines/piratebay.py b/searx/engines/piratebay.py
index ca1085141..85268dcab 100644
--- 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