maxheight and maxwidth dynamic

This commit is contained in:
Roy Olav Purser 2021-05-13 16:14:57 +02:00
parent 63489d75dc
commit 3c83946b4b
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -190,8 +190,33 @@ class MainHandler(tornado.web.RequestHandler):
self.set_status(404) self.set_status(404)
self.write("HTML template missing.") self.write("HTML template missing.")
def handle_embed(self, provider): def handle_embed(self, provider):
max_width = self.get_query_argument("maxwidth", "320") width = self.get_query_argument("maxwidth")
max_height = self.get_query_argument("maxheight", "180") height = self.get_query_argument("maxheight")
if isinstance(width, str) and isinstance(height, str):
pass
if isinstance(width, str):
try:
width_num = (int(width) // 16) * 16
except Exception:
width = "320"
height = "180"
else:
height_num = (width_num * 9) / 16
height = str(height_num)
width = str(width_num)
elif isinstance(height, str):
try:
height_num = (int(height) // 9) * 9
except Exception:
width = "320"
height = "180"
else:
width_num = (height_num * 16) / 9
width = str(width_num)
height = str(height_num)
else:
width = "320"
height = "180"
origin = self.request.path origin = self.request.path
if stream_server is not None: if stream_server is not None:
origin = f'{stream_server}{self.request.path}' origin = f'{stream_server}{self.request.path}'