59def response(resp):
60 search_res = resp.json()
61
62 results = []
63
64 for item in search_res.get("data", {}).get("result", []):
65 title = utils.html_to_text(item["title"])
66 url = item["arcurl"]
67 thumbnail = item["pic"]
68 description = item["description"]
69 author = item["author"]
70 video_id = item["aid"]
71 unix_date = item["pubdate"]
72
73 formatted_date = datetime.fromtimestamp(unix_date)
74
75
76 duration = utils.parse_duration_string(item["duration"])
77 if duration and duration > timedelta(minutes=60):
78 duration = None
79
80 iframe_url = f"https://player.bilibili.com/player.html?aid={video_id}&high_quality=1&autoplay=false&danmaku=0"
81
82 results.append(
83 {
84 "title": title,
85 "url": url,
86 "content": description,
87 "author": author,
88 "publishedDate": formatted_date,
89 "length": duration,
90 "thumbnail": thumbnail,
91 "iframe_src": iframe_url,
92 "template": "videos.html",
93 }
94 )
95
96 return results