From 631393d4c2580672f323543b1e5147ca6a6bcca4 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Mon, 31 May 2021 13:35:45 +0200 Subject: [PATCH] add ctype to result --- backend/stream_providers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/stream_providers.py b/backend/stream_providers.py index 4950e29..a0f7158 100755 --- a/backend/stream_providers.py +++ b/backend/stream_providers.py @@ -119,7 +119,7 @@ class StreamProvider(): self.proxy = proxy def process(self): data = self.stream() - if not isinstance(data.upstream(), str): + if not isinstance(data.upstream(), str) or isinstance(data.ctype(), str): return data proxies = None if isinstance(self.proxy, str): @@ -128,11 +128,13 @@ class StreamProvider(): proxies["https"] = "socks5://" + self.proxy ctype = "binary/octet-stream" try: - resp = requests.head(data.upstream(), proxies=proxies) + resp = requests.head(data.upstream(), proxies=proxies, timeout=5) except Exception as e: self.logger.info(e) else: ctype = resp.headers.get("Content-Type", "binary/octet-stream") + if "mpegurl" in ctype.lower(): + ctype = "application/vnd.apple.mpegurl" return StreamData(data.upstream(), ctype, data.thumbnail(), data.title(), data.description(), data.override) async def run(self): data = None @@ -273,6 +275,7 @@ async def get_any(upstream, proxy, logger): temp_result = await task if isinstance(temp_result, StreamData): result.update("upstream", temp_result.upstream(), temp_result.override) + result.update("ctype", temp_result.ctype(), temp_result.override) result.update("thumbnail", temp_result.thumbnail(), temp_result.override) result.update("title", temp_result.title(), temp_result.override) result.update("description", temp_result.description(), temp_result.override)