From 3abbe6d25bb001b6ef25144426b2539e1ed4c827 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 7 Oct 2021 11:38:27 +0200 Subject: [PATCH] [fix] engine torznab - categories, before join convert int to str BTW add init() function and replace SearxEngineAPIException by ValueError. Signed-off-by: Markus Heiser --- searx/engines/torznab.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/searx/engines/torznab.py b/searx/engines/torznab.py index fed6b1fd1..960d1ee90 100644 --- a/searx/engines/torznab.py +++ b/searx/engines/torznab.py @@ -35,10 +35,11 @@ api_key = '' # https://newznab.readthedocs.io/en/latest/misc/api/#predefined-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): - if len(base_url) < 1: - raise SearxEngineAPIException('missing torznab base_url') search_url = base_url + '?t=search&q={search_query}' if len(api_key) > 0: @@ -47,14 +48,13 @@ def request(query, params): search_url += '&cat={torznab_categories}' params['url'] = search_url.format( - search_query=quote(query), - api_key=api_key, - torznab_categories=",".join(torznab_categories) + search_query = quote(query), + api_key = api_key, + torznab_categories = ",".join([str(x) for x in torznab_categories]) ) return params - def response(resp): results = []