get hls from proxy

This commit is contained in:
Roy Olav Purser 2021-05-26 19:40:31 +02:00
parent 1ffebd4dc4
commit 0588fb301c
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -281,13 +281,12 @@ try:
except Exception as e:
logger.info(e)
async def rewrite(current, proxy):
async def rewrite(upstream, current, proxy):
ndata = None
text = None
try:
async with proxy.session() as session:
logger.info(current)
resp = await session.get(current)
resp = await session.get(upstream)
text = await resp.text()
logger.info(text)
except Exception as e:
@ -386,7 +385,7 @@ class MainHandler(tornado.web.RequestHandler):
ctype = await handler.proxy.content_type(upstream_proxy)
data = None
if "mpegurl" in ctype.lower():
data = await rewrite(upstream, handler.proxy)
data = await rewrite(upstream_proxy, upstream, handler.proxy)
if isinstance(data, str):
self.set_header("Content-Type", "application/vnd.apple.mpegurl")
self.write(data)