From c9ccf018f24c5593f2cb9ac9ae8be6c815025f25 Mon Sep 17 00:00:00 2001 From: frost768 Date: Tue, 14 Mar 2023 23:29:39 +0300 Subject: [PATCH] fix flixhq episodeId --- src/backend/providers/flixhq.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/backend/providers/flixhq.ts b/src/backend/providers/flixhq.ts index 2232ca9d..0de96b21 100644 --- a/src/backend/providers/flixhq.ts +++ b/src/backend/providers/flixhq.ts @@ -55,7 +55,7 @@ registerProvider({ rank: 100, type: [MWMediaType.MOVIE, MWMediaType.SERIES], - async scrape({ media, progress }) { + async scrape({ media, episode, progress }) { if (!this.type.includes(media.meta.type)) { throw new Error("Unsupported type"); } @@ -97,10 +97,23 @@ registerProvider({ if (!mediaInfo.episodes) throw new Error("No watchable item found"); // get stream info from media progress(75); + + // By default we assume it is a movie + let episodeId: string | undefined = mediaInfo.episodes[0].id; + if (media.meta.type === MWMediaType.SERIES) { + const seasonNo = media.meta.seasonData.number; + const episodeNo = media.meta.seasonData.episodes.find( + (e) => e.id === episode + )?.number; + episodeId = mediaInfo.episodes.find( + (e: any) => e.season === seasonNo && e.number === episodeNo + )?.id; + } + if (!episodeId) throw new Error("No watchable item found"); const watchInfo = await proxiedFetch("/watch", { baseURL: flixHqBase, params: { - episodeId: mediaInfo.episodes[0].id, + episodeId, mediaId: flixId, }, });