maxheight and maxwidth dynamic
This commit is contained in:
parent
63489d75dc
commit
3c83946b4b
29
stream.py
29
stream.py
@ -190,8 +190,33 @@ class MainHandler(tornado.web.RequestHandler):
|
||||
self.set_status(404)
|
||||
self.write("HTML template missing.")
|
||||
def handle_embed(self, provider):
|
||||
max_width = self.get_query_argument("maxwidth", "320")
|
||||
max_height = self.get_query_argument("maxheight", "180")
|
||||
width = self.get_query_argument("maxwidth")
|
||||
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
|
||||
if stream_server is not None:
|
||||
origin = f'{stream_server}{self.request.path}'
|
||||
|
Loading…
Reference in New Issue
Block a user