on master help sign in
New files engine: Prowlarr (#3118)
1a18adcDario Nuevo
searx/engines/prowlarr.pynew file+80
@@ -0,0 +1,80 @@
1+# SPDX-License-Identifier: AGPL-3.0-or-later
2+"""
3+
4+ Prowlarr search (Files)
5+
6+"""
7+
8+from json import loads
9+from urllib.parse import urlencode
10+from searx.exceptions import SearxEngineAPIException
11+
12+categories = ''
13+
14+paging = False
15+api_key = ''
16+indexer_ids = ''
17+search_type = 'search'
18+search_categories = ''
19+base_url = ''
20+
21+
22+def request(query, params):
23+ if not base_url:
24+ raise SearxEngineAPIException('missing prowlarr base url')
25+
26+ if not api_key:
27+ raise SearxEngineAPIException('missing prowlarr API key')
28+
29+ query_args = {
30+ 'query': query,
31+ 'apikey': api_key,
32+ 'type': search_type
33+ }
34+
35+ if indexer_ids:
36+ query_args['indexerIds'] = indexer_ids
37+
38+ if search_categories:
39+ query_args['categories'] = search_categories
40+
41+ params['url'] = base_url + urlencode(query_args)
42+
43+ return params
44+
45+
46+def response(resp):
47+ results = []
48+
49+ json_data = loads(resp.text)
50+
51+ for result in json_data:
52+
53+ new_result = {
54+ 'title': result['title'],
55+ 'url': result['infoUrl'],
56+ 'template': 'torrent.html'
57+ }
58+
59+ if 'files' in result:
60+ new_result['files'] = result['files']
61+
62+ if 'size' in result:
63+ new_result['filesize'] = result['size']
64+
65+ if 'seeders' in result:
66+ new_result['seed'] = result['seeders']
67+
68+ if 'leechers' in result:
69+ new_result['leech'] = result['leechers']
70+
71+ if 'downloadUrl' in result:
72+ new_result['torrentfile'] = result['downloadUrl']
73+
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']
77+
78+ results.append(new_result)
79+
80+ return results
searx/settings.yml+20
@@ -908,6 +908,26 @@ engines:
908 engine : openstreetmap
908 engine : openstreetmap
909 shortcut : osm
909 shortcut : osm
910
910
911+# - name : prowlarr
912+# engine : prowlarr
913+# shortcut : prow
914+# categories : files
915+# enable_http : True
916+# api_key : ''
917+# indexer_ids : 5 # comma separated list of indexer ids
918+# search_categories : '' # comma separated list of categories
919+# search_type : search
920+# base_url: http://localhost:9696/api/v1/search?
921+# timeout : 50.0
922+# disabled : True,
923+# about :
924+# website : https://wiki.servarr.com/prowlarr
925+# wikidata_id : None
926+# official_api_documentation : https://wiki.servarr.com/prowlarr/search
927+# use_official_api : true
928+# require_api_key : true
929+# results : JSON
930+
911 - name : openrepos
931 - name : openrepos
912 engine : xpath
932 engine : xpath
913 paging : True
933 paging : True