From aeec5e361cecf6e827521c5bda34c5a5a051f630 Mon Sep 17 00:00:00 2001 From: Gabe Date: Thu, 9 Oct 2025 09:49:12 +0800 Subject: [PATCH] fix: subtitle --- src/subtitle/YouTubeCaptionProvider.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/subtitle/YouTubeCaptionProvider.js b/src/subtitle/YouTubeCaptionProvider.js index 0d8d62c..fb2b9fa 100644 --- a/src/subtitle/YouTubeCaptionProvider.js +++ b/src/subtitle/YouTubeCaptionProvider.js @@ -134,17 +134,18 @@ class YouTubeCaptionProvider { try { const baseUrl = new URL(captionTrack.baseUrl); - baseUrl.searchParams.set("potc", potUrl.searchParams.get("potc")); - baseUrl.searchParams.set("pot", potUrl.searchParams.get("pot")); - baseUrl.searchParams.set("fmt", "json3"); - baseUrl.searchParams.set("c", potUrl.searchParams.get("c")); - if (potUrl.searchParams.get("kind")) { - baseUrl.searchParams.set("kind", potUrl.searchParams.get("kind")); + potUrl.searchParams.set("lang", baseUrl.searchParams.get("lang")); + potUrl.searchParams.set("fmt", "json3"); + if (baseUrl.searchParams.get("kind")) { + potUrl.searchParams.set("kind", baseUrl.searchParams.get("kind")); + } else { + potUrl.searchParams.delete("kind"); } - const res = await fetch(baseUrl); + const res = await fetch(potUrl); if (res.ok) { - return res.json(); + const json = await res.json(); + return json; } logger.error( `Youtube Provider: Failed to fetch subtitles: ${res.status}`