Fix Stremthru token header & refactor passing stremio id for cache status

This commit is contained in:
mhdzumair
2025-01-02 12:45:54 +05:30
parent d67a67af8d
commit 37fb6c6ede
3 changed files with 11 additions and 12 deletions
+3 -5
View File
@@ -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",
+1 -4
View File
@@ -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."""
+7 -3
View File
@@ -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