From 25e32a14b749263f22d728912daf6900be9a8f3d Mon Sep 17 00:00:00 2001 From: cloud <62519659+lem6ns@users.noreply.github.com> Date: Thu, 9 Mar 2023 15:35:39 -0700 Subject: [PATCH] feat(netfilm): add captions --- src/backend/providers/netfilm.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/backend/providers/netfilm.ts b/src/backend/providers/netfilm.ts index e979f7b6..ff25fbf8 100644 --- a/src/backend/providers/netfilm.ts +++ b/src/backend/providers/netfilm.ts @@ -44,20 +44,27 @@ registerProvider({ baseURL: netfilmBase, }); - const { qualities } = watchInfo.data; + const data = watchInfo.data; // get best quality source - const source = qualities.reduce((p: any, c: any) => + const source = data.qualities.reduce((p: any, c: any) => c.quality > p.quality ? c : p ); + const mappedCaptions = data.subtitles.map((sub: Record) => ({ + needsProxy: false, + url: sub.url.replace("https://convert-srt-to-vtt.vercel.app/?url=", ""), + type: MWCaptionType.SRT, + langIso: sub.language, + })) + return { embeds: [], stream: { streamUrl: source.url.replace("akm-cdn", "aws-cdn").replace("gg-cdn", "aws-cdn"), quality: qualityMap[source.quality as QualityInMap], type: MWStreamType.HLS, - captions: [], + captions: mappedCaptions, }, }; } @@ -112,13 +119,20 @@ registerProvider({ c.quality > p.quality ? c : p ); + const mappedCaptions = data.subtitles.map((sub: Record) => ({ + needsProxy: false, + url: sub.url.replace("https://convert-srt-to-vtt.vercel.app/?url=", ""), + type: MWCaptionType.SRT, + langIso: sub.language, + })) + return { embeds: [], stream: { streamUrl: source.url.replace("akm-cdn", "aws-cdn").replace("gg-cdn", "aws-cdn"), quality: qualityMap[source.quality as QualityInMap], type: MWStreamType.HLS, - captions: [], + captions: mappedCaptions, }, }; },