From bca13c0d4a5069f47d7287c726a156e5a6103199 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Fri, 14 May 2021 18:57:26 +0200 Subject: [PATCH] log to stdout --- stream.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stream.py b/stream.py index 0d1a115..e5323f8 100755 --- a/stream.py +++ b/stream.py @@ -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)