mirror of
https://github.com/searxng/searxng
synced 2024-01-01 18:24:07 +00:00
[fix] engine torznab - categories, before join convert int to str
BTW add init() function and replace SearxEngineAPIException by ValueError. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
9fb77065bd
commit
3abbe6d25b
@ -35,10 +35,11 @@ api_key = ''
|
|||||||
# https://newznab.readthedocs.io/en/latest/misc/api/#predefined-categories
|
# https://newznab.readthedocs.io/en/latest/misc/api/#predefined-categories
|
||||||
torznab_categories = []
|
torznab_categories = []
|
||||||
|
|
||||||
|
def init(engine_settings=None): # pylint: disable=unused-argument
|
||||||
|
if len(base_url) < 1:
|
||||||
|
raise ValueError('missing torznab base_url')
|
||||||
|
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
if len(base_url) < 1:
|
|
||||||
raise SearxEngineAPIException('missing torznab base_url')
|
|
||||||
|
|
||||||
search_url = base_url + '?t=search&q={search_query}'
|
search_url = base_url + '?t=search&q={search_query}'
|
||||||
if len(api_key) > 0:
|
if len(api_key) > 0:
|
||||||
@ -47,14 +48,13 @@ def request(query, params):
|
|||||||
search_url += '&cat={torznab_categories}'
|
search_url += '&cat={torznab_categories}'
|
||||||
|
|
||||||
params['url'] = search_url.format(
|
params['url'] = search_url.format(
|
||||||
search_query=quote(query),
|
search_query = quote(query),
|
||||||
api_key=api_key,
|
api_key = api_key,
|
||||||
torznab_categories=",".join(torznab_categories)
|
torznab_categories = ",".join([str(x) for x in torznab_categories])
|
||||||
)
|
)
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
def response(resp):
|
def response(resp):
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user