Don't allow autoplay of embedded video, and explicitly turn autoplay off on invideous sites

main
Bob Mottram 2022-04-06 11:18:43 +01:00
parent 47edfad98d
commit 0ec0e0460b
1 changed files with 10 additions and 5 deletions

View File

@ -44,7 +44,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
"src=\"https://player.vimeo.com/video/" + \
url + "\" width=\"" + str(width) + \
"\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"autoplay; " + \
"\" frameborder=\"0\" allow=\"" + \
"fullscreen\" allowfullscreen></iframe>\n</center>\n"
return content
@ -66,7 +66,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
"decoding=\"async\" src=\"" + \
video_site + url + "\" width=\"" + str(width) + \
"\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"autoplay; fullscreen\" " + \
"\" frameborder=\"0\" allow=\"fullscreen\" " + \
"allowfullscreen></iframe>\n</center>\n"
return content
@ -87,7 +87,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
"decoding=\"async\" src=\"" + \
video_site + url + "\" width=\"" + str(width) + \
"\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"autoplay; fullscreen\" " + \
"\" frameborder=\"0\" allow=\"fullscreen\" " + \
"allowfullscreen></iframe>\n</center>\n"
return content
@ -114,12 +114,17 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
url = url.split('&')[0]
if '?utm_' in url:
url = url.split('?utm_')[0]
# explicitly turn off autoplay
if '&autoplay=' not in url:
url += '&autoplay=0'
else:
url = url.replace('&autoplay=1', '&autoplay=0')
content += \
"<center>\n<iframe loading=\"lazy\" " + \
"decoding=\"async\" src=\"" + \
video_site + url + "\" width=\"" + \
str(width) + "\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"autoplay; fullscreen\" " + \
"\" frameborder=\"0\" allow=\"fullscreen\" " + \
"allowfullscreen></iframe>\n</center>\n"
return content
@ -204,7 +209,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
"allow-scripts\" src=\"https://" + \
site + url + "\" width=\"" + str(width) + \
"\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"autoplay; " + \
"\" frameborder=\"0\" allow=\"" + \
"fullscreen\" allowfullscreen></iframe>\n</center>\n"
return content
return content