Skip to content

Commit

Permalink
fix: debrid download link caching not working in certain case
Browse files Browse the repository at this point in the history
  • Loading branch information
g0ldyy committed Aug 29, 2024
1 parent 178d188 commit 271dbb6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
27 changes: 13 additions & 14 deletions comet/api/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ async def stream(request: Request, b64config: str, type: str, id: str):
episode = None
if type == "series":
info = id.split(":")
full_id = id
id = info[0]
season = int(info[1])
episode = int(info[2])
Expand Down Expand Up @@ -454,6 +453,19 @@ async def playback(request: Request, b64config: str, hash: str, index: str):
config = config_check(b64config)
if not config:
return FileResponse("comet/assets/invalidconfig.mp4")

if (
settings.PROXY_DEBRID_STREAM
and settings.PROXY_DEBRID_STREAM_PASSWORD
== config["debridStreamProxyPassword"]
and config["debridApiKey"] == ""
):
config["debridService"] = (
settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE
)
config["debridApiKey"] = (
settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY
)

async with aiohttp.ClientSession() as session:
# Check for cached download link
Expand All @@ -476,19 +488,6 @@ async def playback(request: Request, b64config: str, hash: str, index: str):
)

if not download_link:
if (
settings.PROXY_DEBRID_STREAM
and settings.PROXY_DEBRID_STREAM_PASSWORD
== config["debridStreamProxyPassword"]
and config["debridApiKey"] == ""
):
config["debridService"] = (
settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE
)
config["debridApiKey"] = (
settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY
)

debrid = getDebrid(session, config)
download_link = await debrid.generate_download_link(hash, index)
if not download_link:
Expand Down
2 changes: 1 addition & 1 deletion comet/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AppSettings(BaseSettings):
PROXY_DEBRID_STREAM: Optional[bool] = False
PROXY_DEBRID_STREAM_PASSWORD: Optional[str] = None
PROXY_DEBRID_STREAM_MAX_CONNECTIONS: Optional[int] = 100
PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE: Optional[str] = None
PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE: Optional[str] = "realdebrid"
PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY: Optional[str] = None
TITLE_MATCH_CHECK: Optional[bool] = True

Expand Down

0 comments on commit 271dbb6

Please sign in to comment.