61 search_results = resp.json()
62 base_invidious_url = resp.search_params[
'base_url'] +
"/watch?v="
64 for result
in search_results:
65 rtype = result.get(
"type",
None)
67 videoid = result.get(
"videoId",
None)
71 url = base_invidious_url + videoid
72 thumbs = result.get(
"videoThumbnails", [])
73 thumb = next((th
for th
in thumbs
if th[
"quality"] ==
"sddefault"),
None)
75 thumbnail = thumb.get(
"url",
"")
81 if thumbnail
and not urlparse(thumbnail).netloc:
82 thumbnail = resp.search_params[
'base_url'] + thumbnail
84 publishedDate = parser.parse(time.ctime(result.get(
"published", 0)))
85 length = time.gmtime(result.get(
"lengthSeconds"))
87 length = time.strftime(
"%H:%M:%S", length)
89 length = time.strftime(
"%M:%S", length)
94 "title": result.get(
"title",
""),
95 "content": result.get(
"description",
""),
97 "views": humanize_number(result[
'viewCount']),
98 "template":
"videos.html",
99 "author": result.get(
"author"),
100 "publishedDate": publishedDate,
101 "iframe_src": resp.search_params[
'base_url'] +
'/embed/' + videoid,
102 "thumbnail": thumbnail,