From 37fb6c6edeefccd36db9ee0c169b014b920d496a Mon Sep 17 00:00:00 2001 From: mhdzumair Date: Thu, 2 Jan 2025 12:45:54 +0530 Subject: [PATCH] Fix Stremthru token header & refactor passing stremio id for cache status --- streaming_providers/stremthru/client.py | 8 +++----- streaming_providers/stremthru/utils.py | 5 +---- utils/parser.py | 10 +++++++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/streaming_providers/stremthru/client.py b/streaming_providers/stremthru/client.py index fef66ee..7427c92 100644 --- a/streaming_providers/stremthru/client.py +++ b/streaming_providers/stremthru/client.py @@ -36,7 +36,7 @@ class StremThru(DebridClient): elif isinstance(self.auth, dict): self.headers["X-StremThru-Store-Name"] = self.auth["store"] self.headers["X-StremThru-Store-Authorization"] = ( - f"Bearer {self.auth["token"]}" + f"Bearer {self.auth['token']}" ) def __del__(self): @@ -119,12 +119,10 @@ class StremThru(DebridClient): async def get_torrent_instant_availability( self, magnet_links: list[str], - stremio_video_id: Optional[str] = None, + stremio_video_id: str, is_http_response: bool = False, ): - params = {"magnet": ",".join(magnet_links)} - if stremio_video_id: - params["sid"] = stremio_video_id + params = {"magnet": ",".join(magnet_links), "sid": stremio_video_id} return await self._make_request( "GET", "/v0/store/magnets/check", diff --git a/streaming_providers/stremthru/utils.py b/streaming_providers/stremthru/utils.py index ad8e098..55c0384 100644 --- a/streaming_providers/stremthru/utils.py +++ b/streaming_providers/stremthru/utils.py @@ -69,10 +69,7 @@ async def get_video_url_from_stremthru( async def update_st_cache_status( - streams: list[TorrentStreams], - user_data: UserData, - stremio_video_id: str | None, - **kwargs, + streams: list[TorrentStreams], user_data: UserData, stremio_video_id: str, **kwargs ) -> str | None: """Updates the cache status of streams based on StremThru's instant availability.""" diff --git a/utils/parser.py b/utils/parser.py index a92ada2..e177119 100644 --- a/utils/parser.py +++ b/utils/parser.py @@ -31,8 +31,8 @@ from utils.validation_helper import validate_m3u8_or_mpd_url_with_cache async def filter_and_sort_streams( streams: list[TorrentStreams], user_data: UserData, + stremio_video_id: str, user_ip: str | None = None, - stremio_video_id: str | None = None, ) -> list[TorrentStreams]: # Convert to sets for faster lookups selected_resolutions_set = set(user_data.selected_resolutions) @@ -227,8 +227,12 @@ async def parse_stream_data( if not streams: return [] - stremio_video_id = f"{streams[0].meta_id}:{season}:{episode}" if is_series else streams[0].meta_id - streams = await filter_and_sort_streams(streams, user_data, user_ip, stremio_video_id) + stremio_video_id = ( + f"{streams[0].meta_id}:{season}:{episode}" if is_series else streams[0].meta_id + ) + streams = await filter_and_sort_streams( + streams, user_data, stremio_video_id, user_ip + ) # Precompute constant values show_full_torrent_name = user_data.show_full_torrent_name