summaryrefslogtreecommitdiff
path: root/searx/results.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-12-10 10:57:07 +0100
committerAlexandre Flament <alex@al-f.net>2020-12-10 10:57:07 +0100
commit0ba74cd812573a70075c5ab12ac35145954fbcc6 (patch)
tree49f4dafb88633d9916db9b369978bd9d4e36d5c9 /searx/results.py
parentd41cafd5f3554f2adf6728b4ffaafd6c8a49a1ce (diff)
downloadsearxng-0ba74cd812573a70075c5ab12ac35145954fbcc6.tar.gz
searxng-0ba74cd812573a70075c5ab12ac35145954fbcc6.zip
[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.
Diffstat (limited to 'searx/results.py')
-rw-r--r--searx/results.py5
1 files 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 '')