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