From 661d995e3b9eb25576b27c5f93c67a784424fc8f Mon Sep 17 00:00:00 2001 From: frost768 Date: Sun, 2 Apr 2023 18:14:26 +0300 Subject: [PATCH] filter out non subtitle files --- src/backend/providers/superstream/index.ts | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/backend/providers/superstream/index.ts b/src/backend/providers/superstream/index.ts index 8abed467..9ebe6262 100644 --- a/src/backend/providers/superstream/index.ts +++ b/src/backend/providers/superstream/index.ts @@ -225,15 +225,23 @@ registerProvider({ const subtitleRes = (await get(subtitleApiQuery)).data; - const mappedCaptions = subtitleRes.list.map((subtitle: any): MWCaption => { - return { - needsProxy: true, - langIso: subtitle.language, - url: subtitle.subtitles[0].file_path, - type: MWCaptionType.SRT, - }; - }); - + const mappedCaptions = subtitleRes.list.map( + (subtitle: any): MWCaption | null => { + const sub = subtitle; + sub.subtitles = subtitle.subtitles.filter((subFile: any) => { + const extension = subFile.file_path.substring( + sub.file_path.length - 3 + ); + return [MWCaptionType.SRT, MWCaptionType.VTT].includes(extension); + }); + return { + needsProxy: true, + langIso: subtitle.language, + url: sub.subtitles[0].file_path, + type: MWCaptionType.SRT, + }; + } + ); return { embeds: [], stream: {