Skip to content

Commit

Permalink
added some info
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyhalight committed Dec 8, 2023
1 parent b9752d1 commit 11b60a9
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 148 deletions.
18 changes: 12 additions & 6 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ You can see all the restrictions related to site support in [wiki](https://githu
- **[TikTok](https://tiktok.com/)**
- **[Rumble](https://rumble.com/)**
- **[EPorner](https://www.eporner.com/)**
- **[Peertube](https://tube.shanti.cafe/)**
- **[Dailymotion](https://www.dailymotion.com/)**
- **[Trovo](https://trovo.live/)**
- **[Yandex Disk](https://disk.yandex.ru/)**
- **[ProxiTok](https://proxitok.pabloferreiro.es/)**
- **[[⚠️] Invidious](https://yewtu.be)**
- **[[⚠️] Piped](https://piped.video)**
Expand Down Expand Up @@ -154,12 +158,14 @@ Example of changing styles:
| Status | Browser | Extension
|---|---|---
| ⠀✅ | Any | Tampermonkey
| ⠀[Download](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Safari | Userscripts
| ⠀[Download](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Any | Violetmonkey
| ⠀[Download](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Any | [AdGuard Usercripts](https://kb.adguard.com/en/general/userscripts#supported-apps)
| ⠀[Download](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Firefox | Firemonkey
| ⠀[Download](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Any | Greasemonkey
| ⠀[Download](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Any | OrangeMonkey
| ⠀[⚠️ Download](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Safari | Userscripts
| ⠀[⚠️ Download](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Any | Violetmonkey
| ⠀[⚠️ Download](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Any | [AdGuard Usercripts](https://kb.adguard.com/en/general/userscripts#supported-apps)
| ⠀[⚠️ Download](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Firefox | Firemonkey
| ⠀[⚠️ Download](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Any | Greasemonkey
| ⠀[⚠️ Download](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Any | OrangeMonkey

⚠️ - They are not priority extensions. These extensions, due to the "cloudflare" version of the user script, do not have cross-site synchronization of settings, and are also (practically) not tested before the release of a new version of the user script.

![example btn](https://github.com/ilyhalight/voice-over-translation/blob/master/img/example_en.jpg "btn")

Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
- **[TikTok](https://tiktok.com/)**
- **[Rumble](https://rumble.com/)**
- **[EPorner](https://www.eporner.com/)**
- **[Peertube](https://tube.shanti.cafe/)**
- **[Dailymotion](https://www.dailymotion.com/)**
- **[Trovo](https://trovo.live/)**
- **[Yandex Disk](https://disk.yandex.ru/)**
- **[ProxiTok](https://proxitok.pabloferreiro.es/)**
- **[[⚠️] Invidious](https://yewtu.be)**
- **[[⚠️] Piped](https://piped.video)**
Expand Down Expand Up @@ -152,19 +156,21 @@ npm i
| ⠀✅ | Opera GX | LVL4 (core: 91.0.4516.36) | Windows | Tampermonkey
| ⠀✅ | Opera | v92.0.4561.43 | Windows | Tampermonkey
| ⠀✅ | Vivaldi | 5.7.2921.63 | Windows, Linux | Tampermonkey
| | Safari | v15.6.1 | MacOS, iOS | Userscripts
| | Safari | v15.6.1 | MacOS, iOS | Userscripts
| ⠀✅ | Kiwi Browser | v116.0.5845.61 | Android | Tampermonkey

## Протестировано в следующих расширениях для юзерскриптов:
| Статус | Браузер | Расширение
|---|---|---
| ⠀✅ | Любой | Tampermonkey
| ⠀[Загрузить](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Safari | Userscripts
| ⠀[Загрузить](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Любой | Violetmonkey
| ⠀[Загрузить](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Любой | [AdGuard Usercripts](https://kb.adguard.com/en/general/userscripts#supported-apps)
| ⠀[Загрузить](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Firefox | Firemonkey
| ⠀[Загрузить](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Любой | Greasemonkey
| ⠀[Загрузить](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Любой | OrangeMonkey
| ⠀[⚠️ Загрузить](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Safari | Userscripts
| ⠀[⚠️ Загрузить](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Любой | Violetmonkey
| ⠀[⚠️ Загрузить](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Любой | [AdGuard Usercripts](https://kb.adguard.com/en/general/userscripts#supported-apps)
| ⠀[⚠️ Загрузить](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Firefox | Firemonkey
| ⠀[⚠️ Загрузить](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Любой | Greasemonkey
| ⠀[⚠️ Загрузить](https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/dist/vot-cloudflare.user.js) | Любой | OrangeMonkey

⚠️ - Не являются приоритетными расширениями. Эти расширения из-за "cloudflare" версии юзерскрипта не имеют межсайтовой синхронизации настроек, а так же (практически) не тестируются перед выходом новой версии юзерскрипта.

![example btn](https://github.com/ilyhalight/voice-over-translation/blob/master/img/example.jpg "btn")

Expand Down
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- tube.la-dina.net
- peertube.tmp.rcp.tf
- Для VK, Piped, Invidious, Bitchute, Rumble, Peertube, DailyMotion, Trovo, и Yandex Disk стандартный язык перевода изменен на "Auto"
- Добавлен слайдер регулировки авто устанавливаемой громкости видео при включение перевода (#418)
- Добавлен слайдер регулировки автоматически устанавливаемой громкости видео при включение перевода (#418)
- Внесены правки в стили для правильного отображения svg иконок на некоторых сайтах
- Добавлена опция включающая перевод ошибок возвращаемых с сервера. Работает на базе [Яндекс переводчика](https://github.com/FOSWLY/translate-backend) (#429, #309)
- Добавлен выбора сервиса для определения языка видео:
Expand All @@ -32,6 +32,7 @@
- Добавлены доп. проверки на существование методов для YouTube player
- Фикс ошибки Hls в Safari (#423)
- Убраны некоторые дебаг логи и закомментированный код для тестирования Hls и переводов стримов
- Исправлена ошибка из-за которой в Greasymonkey не работала установка громкости

# 1.5.0-beta9
- Добавлена поддержка EPorner (#409)
Expand Down
2 changes: 1 addition & 1 deletion dist/vot-cloudflare-min.user.js

Large diffs are not rendered by default.

74 changes: 8 additions & 66 deletions dist/vot-cloudflare.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1309,10 +1309,8 @@ const getVideoId = (service, video) => {
return url.pathname.match(/(?:videos)\/([^/]+)/)?.[0];
}
case "proxytok":
// return url.pathname.match(/video\/([^/]+)/)?.[1];
return url.pathname.match(/([^/]+)\/video\/([^/]+)/)?.[0];
case "tiktok": {
// let id = url.pathname.match(/video\/([^/]+)/)?.[1];
let id = url.pathname.match(/([^/]+)\/video\/([^/]+)/)?.[0];
if (!id) {
const playerEl = video.closest(".xgplayer-playing, .tiktok-web-player");
Expand Down Expand Up @@ -1707,64 +1705,20 @@ function getVideoVolume() {
}

function setVideoVolume(volume) {
return getPlayer()?.setVolume(Math.round(volume * 100));
}

function checkStreamTime(streamTime) {
// TODO: remove
const absTime = streamTime.absoluteTime;
return (
!(absTime || !Number.isFinite(absTime) || absTime <= 0) &&
Math.abs(Date.now() - 1000 * absTime) < 86400000 &&
streamTime.currentTime !== 0
);
// return !(void 0 === (t = e.absoluteTime) || !Number.isFinite(t) || t <= 0) && Math.abs(Date.now() - 1e3 * t) < 864e5 && 0 !== e.currentTime;
}

function getStreamTime(video) {
// TODO: remove
const player = getPlayer();
const progressState = player?.getProgressState?.call();
let absoluteTime = player?.getMediaReferenceTime
? player?.getMediaReferenceTime?.call()
: progressState?.ingestionTime;
const currentTime = progressState?.seekableEnd || video.currentTime;

// getStreamTimes -> ue()
// СЕЙЧАС ВРЕМЯ ТРАНСЛЯЦИИ УСТАНАВЛИВАЕТСЯ НЕПРАВИЛЬНО И ПЕРЕВОД ЗАЛАГИВАЕТ

const streamTime = {
absoluteTime,
currentTime,
};

return checkStreamTime(streamTime), streamTime;
if (player?.setVolume) {
player.setVolume(Math.round(volume * 100));
return true;
}
}

function videoSeek(video, time) {
// * TIME IN MS
debug/* default */.Z.log("videoSeek", time);
// const player = getPlayer();
// if (!player) {
// console.error("player not found")
// return false;
// }

// const streamTime = getStreamTime(video);
// console.log("videoSeek", video.currentTime - time )
// const finalTime = streamTime.currentTime - time
// const finalTime = video.currentTime - time;
const preTime =
getPlayer()?.getProgressState()?.seekableEnd || video.currentTime;
const finalTime = preTime - time; // we always throw it to the end of the stream - time
video.currentTime = finalTime;

// return player.seekTo.call(time, true);
}

function streamToLive() {
// TODO: remove
return getPlayer()?.seekToStreamTime();
}

function getSubtitles() {
Expand Down Expand Up @@ -1839,9 +1793,7 @@ const youtubeUtils = {
getSubtitles,
getVideoData,
setVideoVolume,
getStreamTime,
videoSeek,
streamToLive,
};

;// CONCATENATED MODULE: ./src/yandexProtobuf.js
Expand Down Expand Up @@ -5199,7 +5151,10 @@ class VideoHandler {
// Set video volume in 0.00-1.00 format
setVideoVolume(volume) {
if (this.site.host === "youtube") {
return youtubeUtils.setVideoVolume(volume);
const videoVolume = youtubeUtils.setVideoVolume(volume);
if (videoVolume) {
return;
}
}
this.video.volume = volume;
}
Expand Down Expand Up @@ -5538,17 +5493,14 @@ class VideoHandler {
reqInterval * 1000,
);

// const streamURL = "https://stream.ram.radio/audio/ram.stream_aac/playlist.m3u8";
debug/* default */.Z.log(resOrError.translatedInfo.url);
const streamURL = `https://${config/* m3u8ProxyHost */.e6}/?all=yes&origin=${encodeURIComponent(
"https://strm.yandex.ru",
)}&referer=${encodeURIComponent(
"https://strm.yandex.ru",
)}&url=${encodeURIComponent(resOrError.translatedInfo.url)}`;
debug/* default */.Z.log(streamURL);
// const timestamp = Date.now(); // get timestamp

debug/* default */.Z.log("Test hls support");
if (this.hls) {
this.hls.on(Hls.Events.MEDIA_ATTACHED, function () {
debug/* default */.Z.log("audio and hls.js are now bound together !");
Expand Down Expand Up @@ -5594,17 +5546,8 @@ class VideoHandler {
throw new VOTLocalizedError("audioFormatNotSupported");
}

// const streamTime = youtubeUtils.getStreamTime(this.video)

// youtubeUtils.videoSeekTo(this.video, streamTime.absoluteTime - (resOrError.translatedInfo.timestamp / 1000));

// console.log("video times", this.video.duration, this.video.currentTime);
// console.log("stream times", streamTime.currentTime, streamTime.absoluteTime);
// console.log("trans info times", resOrError.translatedInfo.timestamp);

youtubeUtils.videoSeek(this.video, 10); // 10 is the most successful number for streaming. With it, the audio is not so far behind the original

// TODO: Remove code repetition
this.volumeOnStart = this.getVideoVolume();
if (typeof this.data.defaultVolume === "number") {
this.audio.volume = this.data.defaultVolume / 100;
Expand All @@ -5627,7 +5570,6 @@ class VideoHandler {
}

if (this.video && !this.video.paused) this.lipSync("play");
// this.audio.play();
videoLipSyncEvents.forEach((e) =>
this.video.addEventListener(e, this.handleVideoEventBound),
);
Expand Down
2 changes: 1 addition & 1 deletion dist/vot-min.user.js

Large diffs are not rendered by default.

74 changes: 8 additions & 66 deletions dist/vot.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1288,10 +1288,8 @@ const getVideoId = (service, video) => {
return url.pathname.match(/(?:videos)\/([^/]+)/)?.[0];
}
case "proxytok":
// return url.pathname.match(/video\/([^/]+)/)?.[1];
return url.pathname.match(/([^/]+)\/video\/([^/]+)/)?.[0];
case "tiktok": {
// let id = url.pathname.match(/video\/([^/]+)/)?.[1];
let id = url.pathname.match(/([^/]+)\/video\/([^/]+)/)?.[0];
if (!id) {
const playerEl = video.closest(".xgplayer-playing, .tiktok-web-player");
Expand Down Expand Up @@ -1686,64 +1684,20 @@ function getVideoVolume() {
}

function setVideoVolume(volume) {
return getPlayer()?.setVolume(Math.round(volume * 100));
}

function checkStreamTime(streamTime) {
// TODO: remove
const absTime = streamTime.absoluteTime;
return (
!(absTime || !Number.isFinite(absTime) || absTime <= 0) &&
Math.abs(Date.now() - 1000 * absTime) < 86400000 &&
streamTime.currentTime !== 0
);
// return !(void 0 === (t = e.absoluteTime) || !Number.isFinite(t) || t <= 0) && Math.abs(Date.now() - 1e3 * t) < 864e5 && 0 !== e.currentTime;
}

function getStreamTime(video) {
// TODO: remove
const player = getPlayer();
const progressState = player?.getProgressState?.call();
let absoluteTime = player?.getMediaReferenceTime
? player?.getMediaReferenceTime?.call()
: progressState?.ingestionTime;
const currentTime = progressState?.seekableEnd || video.currentTime;

// getStreamTimes -> ue()
// СЕЙЧАС ВРЕМЯ ТРАНСЛЯЦИИ УСТАНАВЛИВАЕТСЯ НЕПРАВИЛЬНО И ПЕРЕВОД ЗАЛАГИВАЕТ

const streamTime = {
absoluteTime,
currentTime,
};

return checkStreamTime(streamTime), streamTime;
if (player?.setVolume) {
player.setVolume(Math.round(volume * 100));
return true;
}
}

function videoSeek(video, time) {
// * TIME IN MS
debug/* default */.Z.log("videoSeek", time);
// const player = getPlayer();
// if (!player) {
// console.error("player not found")
// return false;
// }

// const streamTime = getStreamTime(video);
// console.log("videoSeek", video.currentTime - time )
// const finalTime = streamTime.currentTime - time
// const finalTime = video.currentTime - time;
const preTime =
getPlayer()?.getProgressState()?.seekableEnd || video.currentTime;
const finalTime = preTime - time; // we always throw it to the end of the stream - time
video.currentTime = finalTime;

// return player.seekTo.call(time, true);
}

function streamToLive() {
// TODO: remove
return getPlayer()?.seekToStreamTime();
}

function getSubtitles() {
Expand Down Expand Up @@ -1818,9 +1772,7 @@ const youtubeUtils = {
getSubtitles,
getVideoData,
setVideoVolume,
getStreamTime,
videoSeek,
streamToLive,
};

;// CONCATENATED MODULE: ./src/yandexProtobuf.js
Expand Down Expand Up @@ -5171,7 +5123,10 @@ class VideoHandler {
// Set video volume in 0.00-1.00 format
setVideoVolume(volume) {
if (this.site.host === "youtube") {
return youtubeUtils.setVideoVolume(volume);
const videoVolume = youtubeUtils.setVideoVolume(volume);
if (videoVolume) {
return;
}
}
this.video.volume = volume;
}
Expand Down Expand Up @@ -5510,17 +5465,14 @@ class VideoHandler {
reqInterval * 1000,
);

// const streamURL = "https://stream.ram.radio/audio/ram.stream_aac/playlist.m3u8";
debug/* default */.Z.log(resOrError.translatedInfo.url);
const streamURL = `https://${config/* m3u8ProxyHost */.e6}/?all=yes&origin=${encodeURIComponent(
"https://strm.yandex.ru",
)}&referer=${encodeURIComponent(
"https://strm.yandex.ru",
)}&url=${encodeURIComponent(resOrError.translatedInfo.url)}`;
debug/* default */.Z.log(streamURL);
// const timestamp = Date.now(); // get timestamp

debug/* default */.Z.log("Test hls support");
if (this.hls) {
this.hls.on(Hls.Events.MEDIA_ATTACHED, function () {
debug/* default */.Z.log("audio and hls.js are now bound together !");
Expand Down Expand Up @@ -5566,17 +5518,8 @@ class VideoHandler {
throw new VOTLocalizedError("audioFormatNotSupported");
}

// const streamTime = youtubeUtils.getStreamTime(this.video)

// youtubeUtils.videoSeekTo(this.video, streamTime.absoluteTime - (resOrError.translatedInfo.timestamp / 1000));

// console.log("video times", this.video.duration, this.video.currentTime);
// console.log("stream times", streamTime.currentTime, streamTime.absoluteTime);
// console.log("trans info times", resOrError.translatedInfo.timestamp);

youtubeUtils.videoSeek(this.video, 10); // 10 is the most successful number for streaming. With it, the audio is not so far behind the original

// TODO: Remove code repetition
this.volumeOnStart = this.getVideoVolume();
if (typeof this.data.defaultVolume === "number") {
this.audio.volume = this.data.defaultVolume / 100;
Expand All @@ -5599,7 +5542,6 @@ class VideoHandler {
}

if (this.video && !this.video.paused) this.lipSync("play");
// this.audio.play();
videoLipSyncEvents.forEach((e) =>
this.video.addEventListener(e, this.handleVideoEventBound),
);
Expand Down

0 comments on commit 11b60a9

Please sign in to comment.