From cf5b345c5f66f093e12920e24d48482163e1baba Mon Sep 17 00:00:00 2001 From: back-to Date: Wed, 15 Jun 2022 16:57:18 +0200 Subject: [PATCH] only read stdout, dont read stderr --- liveproxy/server.py | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/liveproxy/server.py b/liveproxy/server.py index f260a31..edcdedf 100644 --- a/liveproxy/server.py +++ b/liveproxy/server.py @@ -8,7 +8,6 @@ import subprocess import sys from http.server import BaseHTTPRequestHandler, HTTPServer -from select import select from shutil import which from socketserver import ThreadingMixIn from time import time @@ -21,8 +20,8 @@ errno.EPIPE, ) -_re_streamlink = re.compile(r'streamlink$', re.IGNORECASE) -_re_youtube_dl = re.compile(r'(?:youtube|yt)[_-]dl(?:p)?$', re.IGNORECASE) +_re_streamlink = re.compile(r'streamlink', re.IGNORECASE) +_re_youtube_dl = re.compile(r'(?:youtube|yt)[_-]dl(?:p)?', re.IGNORECASE) log = logging.getLogger(__name__.replace('liveproxy.', '')) @@ -110,20 +109,11 @@ def do_GET(self): log.info(f'Stream started {random_id}') try: - while True: - reads, _, _ = select([process.stdout.fileno(), process.stderr.fileno()], [], []) - for descriptor in reads: - # stdout - if descriptor == process.stdout.fileno(): - read = process.stdout.readline() - if read: - self.wfile.write(read) - # stderr - if descriptor == process.stderr.fileno(): - read = process.stderr.readline() - if read: - log.debug(f'{read[0:-1].decode("utf-8")}') - sys.stdout.flush() + while True: + read = process.stdout.readline() + if read: + self.wfile.write(read) + sys.stdout.flush() if process.poll() is not None: self.wfile.close() break