@@ -0,0 +1,80 @@
1+# SPDX-License-Identifier: AGPL-3.0-or-later
4+ Prowlarr search (Files)
9+from urllib.parse import urlencode
10+from searx.exceptions import SearxEngineAPIException
17+search_type = 'search'
18+search_categories = ''
22+def request(query, params):
24+ raise SearxEngineAPIException('missing prowlarr base url')
27+ raise SearxEngineAPIException('missing prowlarr API key')
36+ query_args['indexerIds'] = indexer_ids
38+ if search_categories:
39+ query_args['categories'] = search_categories
41+ params['url'] = base_url + urlencode(query_args)
49+ json_data = loads(resp.text)
51+ for result in json_data:
54+ 'title': result['title'],
55+ 'url': result['infoUrl'],
56+ 'template': 'torrent.html'
59+ if 'files' in result:
60+ new_result['files'] = result['files']
63+ new_result['filesize'] = result['size']
65+ if 'seeders' in result:
66+ new_result['seed'] = result['seeders']
68+ if 'leechers' in result:
69+ new_result['leech'] = result['leechers']
71+ if 'downloadUrl' in result:
72+ new_result['torrentfile'] = result['downloadUrl']
74+ # magnet link *may* be in guid, but it may be also idential to infoUrl
75+ if 'guid' in result and isinstance(result['guid'], str) and result['guid'].startswith('magnet'):
76+ new_result['magnetlink'] = result['guid']
78+ results.append(new_result)