@@ -0,0 +1,53 @@
1+# SPDX-License-Identifier: AGPL-3.0-or-later
2+"""Solid Torrents
3+
4+"""
5+
6+# pylint: disable=missing-function-docstring
7+
8+from json import loads
9+from urllib.parse import urlencode
10+from searx import logger
11+
12+logger = logger.getChild('solidtor engine')
13+
14+about = {
15+ "website": 'https://www.solidtorrents.net/',
16+ "wikidata_id": None,
17+ "official_api_documentation": None,
18+ "use_official_api": True,
19+ "require_api_key": False,
20+ "results": 'JSON',
21+}
22+
23+categories = ['files']
24+paging = True
25+
26+base_url = 'https://www.solidtorrents.net/'
27+search_url = base_url + 'api/v1/search?{query}'
28+
29+
30+def request(query, params):
31+ skip = (params['pageno'] - 1) * 20
32+ query = urlencode({'q': query, 'skip': skip})
33+ params['url'] = search_url.format(query=query)
34+ logger.debug("query_url --> %s", params['url'])
35+ return params
36+
37+
38+def response(resp):
39+ results = []
40+ search_results = loads(resp.text)
41+
42+ for result in search_results["results"]:
43+ results.append({
44+ 'infohash': result["infohash"],
45+ 'seed': result["swarm"]["seeders"],
46+ 'leech': result["swarm"]["leechers"],
47+ 'title': result["title"],
48+ 'link': "https://solidtorrents.net/view/" + result["_id"],
49+ 'filesize': result["size"],
50+ 'magnetlink': result["magnet"],
51+ 'template': "torrent.html",
52+ })
53+ return results