From 8ffb59378708c83121299433a248e077d1cf6e48 Mon Sep 17 00:00:00 2001 From: Dimitris Date: Sat, 23 Nov 2024 21:07:09 +0000 Subject: [PATCH 1/2] disable httpx stream timeout --- comet/api/stream.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/comet/api/stream.py b/comet/api/stream.py index 02b21a4..f8c69f1 100644 --- a/comet/api/stream.py +++ b/comet/api/stream.py @@ -634,7 +634,7 @@ class Streamer: def __init__(self, id: str): self.id = id - self.client = httpx.AsyncClient(proxy=proxy) + self.client = httpx.AsyncClient(proxy=proxy, timeout=None) self.response = None async def stream_content(self, headers: dict): From a8e98b590e4e392dfb0c37096ce11d81fae90763 Mon Sep 17 00:00:00 2001 From: Dimitris Date: Sat, 23 Nov 2024 21:08:04 +0000 Subject: [PATCH 2/2] catch 503 error and set proxy on retry request - continue to raise exceptions for everything else --- comet/api/stream.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/comet/api/stream.py b/comet/api/stream.py index f8c69f1..8bbcb2d 100644 --- a/comet/api/stream.py +++ b/comet/api/stream.py @@ -656,17 +656,21 @@ async def close(self): range_header = request.headers.get("range", "bytes=0-") - response = await session.head( - download_link, headers={"Range": range_header} - ) - if response.status == 503 and config["debridService"] == "alldebrid": - proxy = ( - settings.DEBRID_PROXY_URL - ) # proxy is not needed to proxy realdebrid stream - + try: response = await session.head( - download_link, headers={"Range": range_header}, proxy=proxy + download_link, headers={"Range": range_header} ) + except aiohttp.ClientResponseError as e: + if e.status == 503 and config["debridService"] == "alldebrid": + proxy = ( + settings.DEBRID_PROXY_URL + ) # proxy is not needed to proxy realdebrid stream + + response = await session.head( + download_link, headers={"Range": range_header}, proxy=proxy + ) + else: + raise if response.status == 206: id = str(uuid.uuid4())