log to stdout

This commit is contained in:
Roy Olav Purser 2021-05-14 18:57:26 +02:00
parent fa8eec1769
commit bca13c0d4a
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3
import json
import sys
import urllib.parse
import re
import os
@ -11,7 +12,7 @@ import tornado.routing
import aiohttp
import aiohttp_socks
logging.basicConfig(format='[%(filename)s:%(lineno)d] %(message)s', level=logging.INFO)
logging.basicConfig(format='[%(filename)s:%(lineno)d] %(message)s', stream=sys.stdout, level=logging.INFO)
logger = logging.getLogger(__name__)
providers = {}
@ -247,8 +248,9 @@ async def rewrite(current, proxy):
except Exception as e:
logger.info(e)
if text is not None:
lines = text.splitlines()
links = []
for line in text.splitlines():
for line in lines:
if line.startswith("#EXT-X-KEY:METHOD="):
matches = re.findall(r'(?<=URI=").+(?=")', line)
if len(matches) == 1:
@ -276,7 +278,7 @@ async def rewrite(current, proxy):
else:
if isinstance(link_text, str):
links = json.loads(link_text)
for line in text.splitlines():
for line in lines:
if line.startswith("#EXT-X-KEY:METHOD="):
matches = re.findall(r'(?<=URI=").+(?=")', line)
if len(matches) == 1:
@ -339,8 +341,6 @@ class MainHandler(tornado.web.RequestHandler):
else:
upstream_proxy = await handler.proxy.proxy_url(upstream, None)
ctype = await handler.proxy.content_type(upstream_proxy)
logger.info(ctype)
logger.info(upstream)
data = None
if "mpegurl" in ctype.lower():
data = await rewrite(upstream, handler.proxy)