From 1746eecf2bd4d566bf3d440d9efbff75b68d7d42 Mon Sep 17 00:00:00 2001 From: singletail Date: Wed, 10 Apr 2024 13:56:07 -0400 Subject: [PATCH] [fix] engine: youtube_api - ignore channels / prevent exceptions `youtube_api.py` throws an exception if the search results contain a channel, as channels have no videoId. This PR adds a keycheck for parsing the json response. --- searx/engines/youtube_api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/searx/engines/youtube_api.py b/searx/engines/youtube_api.py index 25ad2cb04..4192530b9 100644 --- a/searx/engines/youtube_api.py +++ b/searx/engines/youtube_api.py @@ -56,6 +56,10 @@ def response(resp): # parse results for result in search_results['items']: + if "videoId" not in result["id"]: + # ignore channels + continue + videoid = result['id']['videoId'] title = result['snippet']['title']