From 5908a63882e706cfda0dc32dcda75e215bc0833c Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@freedombone.net> Date: Fri, 18 Oct 2019 20:26:23 +0100 Subject: [PATCH] Lazy loading of videos --- webinterface.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/webinterface.py b/webinterface.py index cb7ecff6..3ce77bd4 100644 --- a/webinterface.py +++ b/webinterface.py @@ -1557,7 +1557,7 @@ def addEmbeddedVideoFromSites(translate: {},content: str,width=400,height=300) - url=content.split('>vimeo.com/')[1] if '<' in url: url=url.split('<')[0] - content=content+"<center><iframe src=\"https://player.vimeo.com/video/"+url+"\" width=\""+str(width)+"\" height=\""+str(height)+"\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen></iframe></center>" + content=content+"<center><iframe loading=\"lazy\" src=\"https://player.vimeo.com/video/"+url+"\" width=\""+str(width)+"\" height=\""+str(height)+"\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen></iframe></center>" return content videoSite='https://www.youtube.com' @@ -1565,7 +1565,7 @@ def addEmbeddedVideoFromSites(translate: {},content: str,width=400,height=300) - url=content.split('"'+videoSite)[1] if '"' in url: url=url.split('"')[0].replace('/watch?v=','/embed/') - content=content+"<center><iframe src=\""+videoSite+url+"\" width=\""+str(width)+"\" height=\""+str(height)+"\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen></iframe></center>" + content=content+"<center><iframe loading=\"lazy\" src=\""+videoSite+url+"\" width=\""+str(width)+"\" height=\""+str(height)+"\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen></iframe></center>" return content invidiousSites=('https://invidio.us','axqzx4s6s54s32yentfqojs3x5i7faxza6xo3ehd4bzzsg2ii4fv2iid.onion') @@ -1574,7 +1574,7 @@ def addEmbeddedVideoFromSites(translate: {},content: str,width=400,height=300) - url=content.split('"'+videoSite)[1] if '"' in url: url=url.split('"')[0].replace('/watch?v=','/embed/') - content=content+"<center><iframe src=\""+videoSite+url+"\" width=\""+str(width)+"\" height=\""+str(height)+"\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen></iframe></center>" + content=content+"<center><iframe loading=\"lazy\" src=\""+videoSite+url+"\" width=\""+str(width)+"\" height=\""+str(height)+"\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen></iframe></center>" return content videoSite='https://media.ccc.de' @@ -1584,7 +1584,7 @@ def addEmbeddedVideoFromSites(translate: {},content: str,width=400,height=300) - url=url.split('"')[0] if not url.endswith('/oembed'): url=url+'/oembed' - content=content+"<center><iframe src=\""+videoSite+url+"\" width=\""+str(width)+"\" height=\""+str(height)+"\" frameborder=\"0\" allow=\"fullscreen\" allowfullscreen></iframe></center>" + content=content+"<center><iframe loading=\"lazy\" src=\""+videoSite+url+"\" width=\""+str(width)+"\" height=\""+str(height)+"\" frameborder=\"0\" allow=\"fullscreen\" allowfullscreen></iframe></center>" return content if '"https://' in content: @@ -1596,7 +1596,7 @@ def addEmbeddedVideoFromSites(translate: {},content: str,width=400,height=300) - url=content.split('"https://'+site)[1] if '"' in url: url=url.split('"')[0].replace('/watch/','/embed/') - content=content+"<center><iframe sandbox=\"allow-same-origin allow-scripts\" src=\"https://"+site+url+"\" width=\""+str(width)+"\" height=\""+str(height)+"\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen></iframe></center>" + content=content+"<center><iframe loading=\"lazy\" sandbox=\"allow-same-origin allow-scripts\" src=\"https://"+site+url+"\" width=\""+str(width)+"\" height=\""+str(height)+"\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen></iframe></center>" return content return content