Skip to content

Commit

Permalink
Merge pull request #217 from safinn/main
Browse files Browse the repository at this point in the history
Catch 503 response exception
  • Loading branch information
g0ldyy authored Nov 23, 2024
2 parents 8b476d7 + a8e98b5 commit 21b37a3
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions comet/api/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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())
Expand Down

0 comments on commit 21b37a3

Please sign in to comment.