From 495222eb105d8f768a1d044f85c499a9aa7bc825 Mon Sep 17 00:00:00 2001 From: frost768 Date: Sat, 1 Apr 2023 12:19:05 +0300 Subject: [PATCH] export subtitle types as a list --- src/backend/helpers/captions.ts | 12 +++++------- .../components/popouts/CaptionSelectionPopout.tsx | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/backend/helpers/captions.ts b/src/backend/helpers/captions.ts index 477f2a68..83edaa84 100644 --- a/src/backend/helpers/captions.ts +++ b/src/backend/helpers/captions.ts @@ -1,12 +1,10 @@ import { mwFetch, proxiedFetch } from "@/backend/helpers/fetch"; import { MWCaption } from "@/backend/helpers/streams"; import DOMPurify from "dompurify"; -import { list, parse, detect } from "subsrt-ts"; +import { parse, detect, list } from "subsrt-ts"; import { ContentCaption } from "subsrt-ts/dist/types/handler"; -export const subtitleTypeList = list() - .map((v) => `.${v}`) - .join(","); +export const subtitleTypeList = list().map((type) => `.${type}`); export const sanitize = DOMPurify.sanitize; export async function getCaptionUrl(caption: MWCaption): Promise { if (caption.url.startsWith("blob:")) return caption.url; @@ -33,7 +31,7 @@ export function parseSubtitles(text: string): ContentCaption[] { if (detect(text) === "") { throw new Error("Invalid subtitle format"); } - return parse(text) - .filter((cue) => cue.type === "caption") - .map((cue) => cue as ContentCaption); + return parse(text).filter( + (cue) => cue.type === "caption" + ) as ContentCaption[]; } diff --git a/src/video/components/popouts/CaptionSelectionPopout.tsx b/src/video/components/popouts/CaptionSelectionPopout.tsx index 6f056415..b9201024 100644 --- a/src/video/components/popouts/CaptionSelectionPopout.tsx +++ b/src/video/components/popouts/CaptionSelectionPopout.tsx @@ -100,7 +100,7 @@ export function CaptionSelectionPopout(props: { { if (!e.target.files) return;