diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2014-05-16 16:43:40 +0200 |
|---|---|---|
| committer | Adam Tauber <asciimoo@gmail.com> | 2014-05-16 16:43:40 +0200 |
| commit | 637d58f2ed22c96bb1281900540585f039d60818 (patch) | |
| tree | 31f33aa4ed8431a4c011258d23643dfad518e1fd | |
| parent | 66f87f8117df527e02d88fdbab5430d6ba02997d (diff) | |
| parent | 6725112e6bde20a78ea12df5ee23a323493e8395 (diff) | |
Merge pull request #65 from rsdy/master
[enh] sort piratebay results by seeders
| -rw-r--r-- | searx/engines/piratebay.py | 9 |
1 files changed, 7 insertions, 2 deletions
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 |