From 786a2985ca3ef2463b65c684bc8cef6a86ce772f Mon Sep 17 00:00:00 2001 From: Munif Tanjim Date: Tue, 31 Dec 2024 16:44:23 +0600 Subject: [PATCH] feat(debrid/stremthru): pass stremio video id for magnet cache check --- comet/api/stream.py | 1 + comet/debrid/alldebrid.py | 2 +- comet/debrid/debridlink.py | 2 +- comet/debrid/premiumize.py | 2 +- comet/debrid/realdebrid.py | 2 +- comet/debrid/stremthru.py | 20 ++++++++++++++------ comet/debrid/torbox.py | 2 +- 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/comet/api/stream.py b/comet/api/stream.py index efdc8e2..7dc5149 100644 --- a/comet/api/stream.py +++ b/comet/api/stream.py @@ -411,6 +411,7 @@ async def stream( season, episode, kitsu, + video_id=full_id, ) ranked_files = set() diff --git a/comet/debrid/alldebrid.py b/comet/debrid/alldebrid.py index 75a06e0..cb433a8 100644 --- a/comet/debrid/alldebrid.py +++ b/comet/debrid/alldebrid.py @@ -44,7 +44,7 @@ class AllDebrid: ) async def get_files( - self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool + self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool, **kwargs ): chunk_size = 500 chunks = [ diff --git a/comet/debrid/debridlink.py b/comet/debrid/debridlink.py index b3f7261..1d65bd2 100644 --- a/comet/debrid/debridlink.py +++ b/comet/debrid/debridlink.py @@ -48,7 +48,7 @@ class DebridLink: return responses async def get_files( - self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool + self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool, **kwargs ): chunk_size = 10 chunks = [ diff --git a/comet/debrid/premiumize.py b/comet/debrid/premiumize.py index 6631e14..27fdc93 100644 --- a/comet/debrid/premiumize.py +++ b/comet/debrid/premiumize.py @@ -49,7 +49,7 @@ class Premiumize: ) async def get_files( - self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool + self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool, **kwargs ): chunk_size = 100 chunks = [ diff --git a/comet/debrid/realdebrid.py b/comet/debrid/realdebrid.py index d37c864..33b993e 100644 --- a/comet/debrid/realdebrid.py +++ b/comet/debrid/realdebrid.py @@ -42,7 +42,7 @@ class RealDebrid: ) async def get_files( - self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool + self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool, **kwargs ): chunk_size = 100 chunks = [ diff --git a/comet/debrid/stremthru.py b/comet/debrid/stremthru.py index aebf4ff..ed41c6b 100644 --- a/comet/debrid/stremthru.py +++ b/comet/debrid/stremthru.py @@ -58,11 +58,12 @@ class StremThru: return False - async def get_instant(self, magnets: list): + async def get_instant(self, magnets: list, sid: Optional[str] = None): try: - magnet = await self.session.get( - f"{self.base_url}/magnets/check?magnet={','.join(magnets)}&client_ip={self.client_ip}" - ) + url = f"{self.base_url}/magnets/check?magnet={','.join(magnets)}&client_ip={self.client_ip}" + if sid: + url = f"{url}&sid={sid}" + magnet = await self.session.get(url) return await magnet.json() except Exception as e: logger.warning( @@ -70,7 +71,14 @@ class StremThru: ) async def get_files( - self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool + self, + torrent_hashes: list, + type: str, + season: str, + episode: str, + kitsu: bool, + video_id: Optional[str] = None, + **kwargs, ): chunk_size = 25 chunks = [ @@ -80,7 +88,7 @@ class StremThru: tasks = [] for chunk in chunks: - tasks.append(self.get_instant(chunk)) + tasks.append(self.get_instant(chunk, sid=video_id)) responses = await asyncio.gather(*tasks) diff --git a/comet/debrid/torbox.py b/comet/debrid/torbox.py index 2e9cd6d..7e17054 100644 --- a/comet/debrid/torbox.py +++ b/comet/debrid/torbox.py @@ -41,7 +41,7 @@ class TorBox: ) async def get_files( - self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool + self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool, **kwargs ): chunk_size = 50 chunks = [