maxheight and maxwidth oembed

This commit is contained in:
Roy Olav Purser 2021-05-13 15:44:43 +02:00
parent b247030174
commit 63489d75dc
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -190,14 +190,16 @@ 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")
max_height = self.get_query_argument("maxheight", "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}'
embed_json = {} embed_json = {}
embed_json["version"] = "1.0" embed_json["version"] = "1.0"
embed_json["type"] = "video" embed_json["type"] = "video"
embed_json["width"] = "640" embed_json["width"] = max_width
embed_json["height"] = "360" embed_json["height"] = max_height
embed_json["html"] = str(template_embed.generate(origin=origin, provider=provider), "utf-8") embed_json["html"] = str(template_embed.generate(origin=origin, provider=provider), "utf-8")
self.set_header("Content-Type", "application/json; charset=utf-8") self.set_header("Content-Type", "application/json; charset=utf-8")
self.write(json.dumps(embed_json)) self.write(json.dumps(embed_json))