mirror of https://github.com/searxng/searxng.git
[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 <markus.heiser@darmarit.de>
This commit is contained in:
parent
21bfb4996e
commit
9eda4044be
|
@ -9,6 +9,8 @@ import string
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
from searx import utils
|
||||||
|
|
||||||
# Engine metadata
|
# Engine metadata
|
||||||
about = {
|
about = {
|
||||||
"website": "https://www.bilibili.com",
|
"website": "https://www.bilibili.com",
|
||||||
|
@ -56,6 +58,8 @@ def request(query, params):
|
||||||
|
|
||||||
# Format the video duration
|
# Format the video duration
|
||||||
def format_duration(duration):
|
def format_duration(duration):
|
||||||
|
if not ":" in duration:
|
||||||
|
return None
|
||||||
minutes, seconds = map(int, duration.split(":"))
|
minutes, seconds = map(int, duration.split(":"))
|
||||||
total_seconds = minutes * 60 + seconds
|
total_seconds = minutes * 60 + seconds
|
||||||
|
|
||||||
|
@ -70,7 +74,7 @@ def response(resp):
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
for item in search_res.get("data", {}).get("result", []):
|
for item in search_res.get("data", {}).get("result", []):
|
||||||
title = item["title"]
|
title = utils.html_to_text(item["title"])
|
||||||
url = item["arcurl"]
|
url = item["arcurl"]
|
||||||
thumbnail = item["pic"]
|
thumbnail = item["pic"]
|
||||||
description = item["description"]
|
description = item["description"]
|
||||||
|
|
Loading…
Reference in New Issue