Skip to content

Commit

Permalink
added subs proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyhalight committed Aug 10, 2024
1 parent 21797b5 commit 9d25001
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Исправлена ошибка из-за которой кнопка не исчезала на Pornhub (#700)
- Временно, поддержка `www.reddit.com` заменена на `old.reddit.com` из-за багов с инициализацией
- Добавлена поддержка большего числа инстансов Peertube
- Добавлено проксирование субтитров (#739)
- Добавлена поддержка Poketube (#726)
- Исправлена работа Peertube
- Исправлена работа Google Drive (#737)
Expand Down
2 changes: 1 addition & 1 deletion dist/vot-min.user.js

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions dist/vot.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7869,9 +7869,22 @@ class VideoHandler {
this.votDownloadSubtitlesButton.hidden = true;
this.yandexSubtitles = null;
} else {
this.yandexSubtitles = await fetchSubtitles(
this.subtitlesList.at(parseInt(subs)),
);
const subtitlesObj = this.subtitlesList.at(parseInt(subs));
if (
this.data.audioProxy === 1 &&
subtitlesObj.url.startsWith(
"https://brosubs.s3-private.mds.yandex.net/vtrans/",
)
) {
const audioPath = subtitlesObj.url.replace(
"https://brosubs.s3-private.mds.yandex.net/vtrans/",
"",
);
subtitlesObj.url = `https://${this.data.proxyWorkerHost}/video-subtitles/subtitles-proxy/${audioPath}`;
console.log(`[VOT] Subs proxied via ${subtitlesObj.url}`);
}

this.yandexSubtitles = await fetchSubtitles(subtitlesObj);
this.subtitlesWidget.setContent(this.yandexSubtitles);
this.votDownloadSubtitlesButton.hidden = false;
}
Expand Down
23 changes: 18 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ class VideoHandler {
await this.updateTranslationErrorMsg(
res.remainingTime > 0
? secsToStrTime(res.remainingTime)
: (res.message ??
localizationProvider.get("translationTakeFewMinutes")),
: res.message ??
localizationProvider.get("translationTakeFewMinutes"),
);
} catch (err) {
console.error("[VOT] Failed to translate video", err);
Expand Down Expand Up @@ -1636,9 +1636,22 @@ class VideoHandler {
this.votDownloadSubtitlesButton.hidden = true;
this.yandexSubtitles = null;
} else {
this.yandexSubtitles = await fetchSubtitles(
this.subtitlesList.at(parseInt(subs)),
);
const subtitlesObj = this.subtitlesList.at(parseInt(subs));
if (
this.data.audioProxy === 1 &&
subtitlesObj.url.startsWith(
"https://brosubs.s3-private.mds.yandex.net/vtrans/",
)
) {
const audioPath = subtitlesObj.url.replace(
"https://brosubs.s3-private.mds.yandex.net/vtrans/",
"",
);
subtitlesObj.url = `https://${this.data.proxyWorkerHost}/video-subtitles/subtitles-proxy/${audioPath}`;
console.log(`[VOT] Subs proxied via ${subtitlesObj.url}`);
}

this.yandexSubtitles = await fetchSubtitles(subtitlesObj);
this.subtitlesWidget.setContent(this.yandexSubtitles);
this.votDownloadSubtitlesButton.hidden = false;
}
Expand Down

0 comments on commit 9d25001

Please sign in to comment.