diff --git a/comet/api/stream.py b/comet/api/stream.py index fe38073..54e7f55 100644 --- a/comet/api/stream.py +++ b/comet/api/stream.py @@ -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, diff --git a/comet/debrid/stremthru.py b/comet/debrid/stremthru.py index 7762a5d..e97ef15 100644 --- a/comet/debrid/stremthru.py +++ b/comet/debrid/stremthru.py @@ -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, )