From 4f2501ed98fe6e50214de337a338422ce3813ec6 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Sat, 29 May 2021 16:02:12 +0200 Subject: [PATCH] request media directely --- backend/stream.py | 4 +++- frontend/script.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/stream.py b/backend/stream.py index bc40e54..e0bc062 100755 --- a/backend/stream.py +++ b/backend/stream.py @@ -269,9 +269,11 @@ class MainHandler(tornado.web.RequestHandler): upstream_proxy = await handler.proxy.proxy_url(upstream, None) ctype = await handler.proxy.content_type(upstream_proxy) self.set_header("Content-Type", ctype) - self.set_header("Content-Location", upstream_proxy) if redir: self.redirect(upstream_proxy, status=303) + else: + self.set_header("Content-Location", upstream_proxy) + async def get(self): await self.handle_any(True) async def head(self): diff --git a/frontend/script.js b/frontend/script.js index c957381..6f899dd 100644 --- a/frontend/script.js +++ b/frontend/script.js @@ -26,6 +26,7 @@ video.className = "video-js vjs-big-play-centered"; body.appendChild(video); const ctype = xhr.getResponseHeader("Content-Type"); + const media = xhr.getResponseHeader("Content-Location"); const image = xhr.getResponseHeader("Custom-Poster"); console.log(ctype); const options = {}; @@ -43,7 +44,7 @@ } const source = {}; source.type = ctype; - source.src = upstream; + source.src = media; player.src(source); const canPlayTypeRaw = player.canPlayType(ctype); const canPlayType = (canPlayTypeRaw === "maybe") || (canPlayTypeRaw === "probably");