From d41cafd5f3554f2adf6728b4ffaafd6c8a49a1ce Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Thu, 10 Dec 2020 10:40:45 +0100 Subject: [PATCH 1/2] [fix] xpath, mojeek: fix commit 58d72f26925d56e22330c54be03c3dcbee0c4135 before commit 58d72f2, category was not set in xpath.py, so searx/engines/__init__py was setting the category to ['general'] the commit 58d72f2 set the category to [] which is not replaced by searx/engines/__init__.py consequence: the mojeek engine is hidden in the preferences. this commit revert the xpath.py change. close #2368 --- searx/engines/xpath.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/searx/engines/xpath.py b/searx/engines/xpath.py index d420e250a..1507176ec 100644 --- a/searx/engines/xpath.py +++ b/searx/engines/xpath.py @@ -7,7 +7,6 @@ url_xpath = None content_xpath = None title_xpath = None thumbnail_xpath = False -categories = [] paging = False suggestion_xpath = '' results_xpath = '' @@ -39,7 +38,7 @@ def request(query, params): def response(resp): results = [] dom = html.fromstring(resp.text) - is_onion = True if 'onions' in categories else False + is_onion = True if 'onions' in categories else False # pylint: disable=undefined-variable if results_xpath: for result in eval_xpath_list(dom, results_xpath): From 0ba74cd812573a70075c5ab12ac35145954fbcc6 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Thu, 10 Dec 2020 10:57:07 +0100 Subject: [PATCH 2/2] [mod] results: don't crash when an engine don't have a category According to https://github.com/searx/searx/blob/820b468bfe96f693d60ce06f1e78af51f00deefc/searx/engines/__init__.py#L87-L88 an engine can have no category at all. Without this commit, searx raise an exception in searx/results.py Note: in this case, the engine is not shown in the preferences. --- searx/results.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/searx/results.py b/searx/results.py index 5bf4e6b9e..fb7e816eb 100644 --- a/searx/results.py +++ b/searx/results.py @@ -309,10 +309,11 @@ class ResultContainer: for res in results: # FIXME : handle more than one category per engine - res['category'] = engines[res['engine']].categories[0] + engine = engines[res['engine']] + res['category'] = engine.categories[0] if len(engine.categories) > 0 else '' # FIXME : handle more than one category per engine - category = engines[res['engine']].categories[0]\ + category = res['category']\ + ':' + res.get('template', '')\ + ':' + ('img_src' if 'img_src' in res or 'thumbnail' in res else '')