diff options
| author | Bnyro <bnyro@tutanota.com> | 2026-07-07 10:44:13 +0200 |
|---|---|---|
| committer | Bnyro <bnyro@tutanota.com> | 2026-07-07 10:49:54 +0200 |
| commit | f69b22c45cf156dd935db583550d2134077435d1 (patch) | |
| tree | 53140f4520e79ae21c6e344b944f8377abf218ee | |
| parent | f9304437267b1113086e3cbec47dfb37e15f1112 (diff) | |
[fix] kagi: crashes when there are no results
| -rw-r--r-- | searx/engines/kagi.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/searx/engines/kagi.py b/searx/engines/kagi.py index 63ec64c17..85cc62c98 100644 --- a/searx/engines/kagi.py +++ b/searx/engines/kagi.py @@ -139,9 +139,13 @@ def response(resp: "SXNG_Response") -> EngineResults: if kagi_categ in ("images", "videos"): # the JSON key is "image" for "images" and "video" for "videos" - json_results = json_data["data"][kagi_categ[:-1]] + json_results = json_data["data"].get(kagi_categ[:-1]) else: - json_results = json_data["data"][kagi_categ] + json_results = json_data["data"].get(kagi_categ) + + # if no results were found, the response doesn't contain the results field + if not json_results: + return res for result in json_results: published_date: datetime | None = None |
