Browse Source

Merge pull request #2626 from mikeri/solidtorrents

Add Solid Torrents engine
Alexandre Flament 4 years ago
parent
commit
92dd5e245e
3 changed files with 60 additions and 0 deletions
  1. 1 0
      Makefile
  2. 53 0
      searx/engines/solidtorrents.py
  3. 6 0
      searx/settings.yml

+ 1 - 0
Makefile

@@ -194,6 +194,7 @@ PYLINT_FILES=\
 	searx/engines/google_videos.py \
 	searx/engines/google_videos.py \
 	searx/engines/google_images.py \
 	searx/engines/google_images.py \
 	searx/engines/mediathekviewweb.py \
 	searx/engines/mediathekviewweb.py \
+	searx/engines/solidtorrents.py \
 	searx/engines/google_scholar.py \
 	searx/engines/google_scholar.py \
 	searx/engines/yahoo_news.py \
 	searx/engines/yahoo_news.py \
 	searx/engines/apkmirror.py \
 	searx/engines/apkmirror.py \

+ 53 - 0
searx/engines/solidtorrents.py

@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+"""Solid Torrents
+
+"""
+
+# pylint: disable=missing-function-docstring
+
+from json import loads
+from urllib.parse import urlencode
+from searx import logger
+
+logger = logger.getChild('solidtor engine')
+
+about = {
+    "website": 'https://www.solidtorrents.net/',
+    "wikidata_id": None,
+    "official_api_documentation": None,
+    "use_official_api": True,
+    "require_api_key": False,
+    "results": 'JSON',
+}
+
+categories = ['files']
+paging = True
+
+base_url = 'https://www.solidtorrents.net/'
+search_url = base_url + 'api/v1/search?{query}'
+
+
+def request(query, params):
+    skip = (params['pageno'] - 1) * 20
+    query = urlencode({'q': query, 'skip': skip})
+    params['url'] = search_url.format(query=query)
+    logger.debug("query_url --> %s", params['url'])
+    return params
+
+
+def response(resp):
+    results = []
+    search_results = loads(resp.text)
+
+    for result in search_results["results"]:
+        results.append({
+            'infohash': result["infohash"],
+            'seed': result["swarm"]["seeders"],
+            'leech': result["swarm"]["leechers"],
+            'title': result["title"],
+            'link': "https://solidtorrents.net/view/" + result["_id"],
+            'filesize': result["size"],
+            'magnetlink': result["magnet"],
+            'template': "torrent.html",
+        })
+    return results

+ 6 - 0
searx/settings.yml

@@ -957,6 +957,12 @@ engines:
     timeout : 6.0
     timeout : 6.0
     disabled : True
     disabled : True
 
 
+  - name : solidtorrents
+    engine : solidtorrents
+    shortcut : solid
+    timeout : 3.0
+    disabled : True
+
   - name : torrentz
   - name : torrentz
     engine : torrentz
     engine : torrentz
     shortcut : tor
     shortcut : tor