1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-22 12:10:11 +01:00

[fix] engine piped: 'invalid content'

SearXNG does not allow a None value in the content field of a result item.

If the key (shortDescription, uploaderName) in the JSON response from piped
exists but is set to None, SearXNG ignores this result item::

  DEBUG   searx    : result: invalid content: { ..,  'content': None,  ..}

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2023-08-03 12:03:11 +02:00 committed by Markus Heiser
parent 207fcc0c8c
commit 203f1f0928

View File

@ -142,13 +142,14 @@ def response(resp):
if piped_filter == 'videos': if piped_filter == 'videos':
item["template"] = "videos.html" item["template"] = "videos.html"
item["content"] = result.get("shortDescription", "") # if the value of shortDescription set, but is None, return empty string
item["content"] = result.get("shortDescription", "") or ""
item["thumbnail"] = result.get("thumbnail", "") item["thumbnail"] = result.get("thumbnail", "")
elif piped_filter == 'music_songs': elif piped_filter == 'music_songs':
item["template"] = "default.html" item["template"] = "default.html"
item["img_src"] = result.get("thumbnail", "") item["img_src"] = result.get("thumbnail", "")
item["content"] = result.get("uploaderName", "") item["content"] = result.get("uploaderName", "") or ""
length = result.get("duration") length = result.get("duration")
if length: if length:
item["length"] = datetime.timedelta(seconds=length) item["length"] = datetime.timedelta(seconds=length)