From 9eda4044bebc3c23f7d803caca5e6a763ef92712 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 6 Sep 2024 06:54:02 +0200 Subject: [PATCH] [fix] bilibili engine - ValueError in duration & HTML in title - ValueError in duration: issue reported in #3799 - HTML in title: related to #3770 [#3799] https://github.com/searxng/searxng/issues/3799 [#3770] https://github.com/searxng/searxng/pull/3770 Signed-off-by: Markus Heiser --- searx/engines/bilibili.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/searx/engines/bilibili.py b/searx/engines/bilibili.py index f26f2164f..f3436d3a7 100644 --- a/searx/engines/bilibili.py +++ b/searx/engines/bilibili.py @@ -9,6 +9,8 @@ import string from urllib.parse import urlencode from datetime import datetime, timedelta +from searx import utils + # Engine metadata about = { "website": "https://www.bilibili.com", @@ -56,6 +58,8 @@ def request(query, params): # Format the video duration def format_duration(duration): + if not ":" in duration: + return None minutes, seconds = map(int, duration.split(":")) total_seconds = minutes * 60 + seconds @@ -70,7 +74,7 @@ def response(resp): results = [] for item in search_res.get("data", {}).get("result", []): - title = item["title"] + title = utils.html_to_text(item["title"]) url = item["arcurl"] thumbnail = item["pic"] description = item["description"]