Skip to content

Commit

Permalink
fix(debrid/stremthru): handle missing file index
Browse files Browse the repository at this point in the history
  • Loading branch information
MunifTanjim committed Dec 1, 2024
1 parent d1dfdf2 commit 596588f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion comet/api/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,13 +484,17 @@ async def stream(
for resolution in balanced_hashes:
for hash in balanced_hashes[resolution]:
data = sorted_ranked_files[hash]["data"]
index = data['index']
if index == -1:
index = data['title']
url = f"{request.url.scheme}://{request.url.netloc}/{b64config}/playback/{hash}/{data['index']}"
results.append(
{
"name": f"[{debrid_extension}⚡] Comet {data['resolution']}",
"description": format_title(data, config),
"torrentTitle": data["torrent_title"],
"torrentSize": data["torrent_size"],
"url": f"{request.url.scheme}://{request.url.netloc}/{b64config}/playback/{hash}/{data['index']}",
"url": url,
"behaviorHints": {
"filename": data["raw_title"],
"bingeGroup": "comet|" + hash,
Expand Down
5 changes: 4 additions & 1 deletion comet/debrid/stremthru.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,14 @@ async def generate_download_link(self, hash: str, index: str):
)
magnet = await magnet.json()

if magnet["data"]["status"] != "downloaded":
return

file = next(
(
file
for file in magnet["data"]["files"]
if file["index"] == int(index)
if str(file["index"]) == index or file["title"] == index
),
None,
)
Expand Down

0 comments on commit 596588f

Please sign in to comment.