fix: remove retranslate subtitle code
This commit is contained in:
@@ -15,7 +15,6 @@ export class BilingualSubtitleManager {
|
|||||||
#preTranslateSeconds = 100;
|
#preTranslateSeconds = 100;
|
||||||
#setting = {};
|
#setting = {};
|
||||||
#isAdPlaying = false;
|
#isAdPlaying = false;
|
||||||
#FAILED_TEXT = "[Translation failed]";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {object} options
|
* @param {object} options
|
||||||
@@ -285,9 +284,7 @@ export class BilingualSubtitleManager {
|
|||||||
const isCurrent = sub.start <= currentTimeMs && sub.end >= currentTimeMs;
|
const isCurrent = sub.start <= currentTimeMs && sub.end >= currentTimeMs;
|
||||||
const isUpcoming =
|
const isUpcoming =
|
||||||
sub.start > currentTimeMs && sub.start <= currentTimeMs + lookAheadMs;
|
sub.start > currentTimeMs && sub.start <= currentTimeMs + lookAheadMs;
|
||||||
const needsTranslation =
|
const needsTranslation = !sub.translation && !sub.isTranslating;
|
||||||
(!sub.translation || sub.translation === this.this.#FAILED_TEXT) &&
|
|
||||||
!sub.isTranslating;
|
|
||||||
|
|
||||||
if ((isCurrent || isUpcoming) && needsTranslation) {
|
if ((isCurrent || isUpcoming) && needsTranslation) {
|
||||||
this.#translateAndStore(sub);
|
this.#translateAndStore(sub);
|
||||||
@@ -312,7 +309,7 @@ export class BilingualSubtitleManager {
|
|||||||
subtitle.translation = translatedText;
|
subtitle.translation = translatedText;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.info("Translation failed for:", subtitle.text, error);
|
logger.info("Translation failed for:", subtitle.text, error);
|
||||||
subtitle.translation = this.#FAILED_TEXT;
|
subtitle.translation = "[Translation failed]";
|
||||||
} finally {
|
} finally {
|
||||||
subtitle.isTranslating = false;
|
subtitle.isTranslating = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user