Browse Source

[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>
Markus Heiser 3 years ago
parent
commit
3abbe6d25b
1 changed files with 6 additions and 6 deletions
  1. 6 6
      searx/engines/torznab.py

+ 6 - 6
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 = []