diff --git a/src/subtitle/YouTubeCaptionProvider.js b/src/subtitle/YouTubeCaptionProvider.js index aea0f4d..add6af6 100644 --- a/src/subtitle/YouTubeCaptionProvider.js +++ b/src/subtitle/YouTubeCaptionProvider.js @@ -274,8 +274,6 @@ class YouTubeCaptionProvider { return; } - this.#showNotification(this.#i18n("starting_to_process_subtitle")); - const captionTracks = await this.#getCaptionTracks(videoId); const captionTrack = this.#findCaptionTrack(captionTracks); if (!captionTrack) { @@ -294,9 +292,6 @@ class YouTubeCaptionProvider { return; } - const flatEvents = this.#flatEvents(events); - if (!flatEvents.length) return; - const { segApiSetting, toLang } = this.#setting; const lang = potUrl.searchParams.get("lang"); const fromLang = @@ -304,6 +299,16 @@ class YouTubeCaptionProvider { OPT_LANGS_TO_CODE[OPT_TRANS_MICROSOFT].get(lang.slice(0, 2)) || "auto"; + if (this.#isSameLang(fromLang, toLang)) { + logger.info("Youtube Provider: skip same lang", fromLang, toLang); + return; + } + + this.#showNotification(this.#i18n("starting_to_process_subtitle")); + + const flatEvents = this.#flatEvents(events); + if (!flatEvents.length) return; + if (potUrl.searchParams.get("kind") === "asr" && segApiSetting) { logger.info("Youtube Provider: Starting AI ...");