[mod] result_templates/videos.html: replace embedded HTML by data_src

Embedded HTML breaks SearXNG architecture.  To modularize, HTML is generated in
the templates (oscar & simple) and result parameter 'embedded' is replaced by
'data_src', an URL for embedded content (<iframe>).

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2022-02-07 16:16:57 +01:00
parent a4942213a1
commit 46e131fdad
10 changed files with 23 additions and 66 deletions

View file

@ -32,12 +32,6 @@ time_range_url = '&sp=EgII{time_range}%253D%253D'
next_page_url = 'https://www.youtube.com/youtubei/v1/search?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8'
time_range_dict = {'day': 'Ag', 'week': 'Aw', 'month': 'BA', 'year': 'BQ'}
embedded_url = (
'<iframe width="540" height="304" '
+ 'data-src="https://www.youtube-nocookie.com/embed/{videoid}" '
+ 'frameborder="0" allowfullscreen></iframe>'
)
base_youtube_url = 'https://www.youtube.com/watch?v='
@ -91,7 +85,7 @@ def parse_next_page_response(response_text):
'author': section['ownerText']['runs'][0]['text'],
'length': section['lengthText']['simpleText'],
'template': 'videos.html',
'embedded': embedded_url.format(videoid=section['videoId']),
'data_src': 'https://www.youtube-nocookie.com/embed/' + section['videoId'],
'thumbnail': section['thumbnail']['thumbnails'][-1]['url'],
}
)
@ -150,7 +144,6 @@ def parse_first_page_response(response_text):
thumbnail = 'https://i.ytimg.com/vi/' + videoid + '/hqdefault.jpg'
title = get_text_from_json(video.get('title', {}))
content = get_text_from_json(video.get('descriptionSnippet', {}))
embedded = embedded_url.format(videoid=videoid)
author = get_text_from_json(video.get('ownerText', {}))
length = get_text_from_json(video.get('lengthText', {}))
@ -163,7 +156,7 @@ def parse_first_page_response(response_text):
'author': author,
'length': length,
'template': 'videos.html',
'embedded': embedded,
'data_src': 'https://www.youtube-nocookie.com/embed/' + videoid,
'thumbnail': thumbnail,
}
)