Skip to content

Commit

Permalink
added support of inbox and bk paths for mail.ru video
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyhalight committed Aug 17, 2024
1 parent 25056bf commit 790205f
Show file tree
Hide file tree
Showing 11 changed files with 255 additions and 199 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Исправлена ошибка из-за которой кнопка перевода могла не появляться до первичного получения субтитров или завершения автоперевода
- Автоперевод и первичное получение субтитров, теперь, происходит параллельно
- Добавлена настройка горячей клавиши перевода (#485 в #760)
- Добавлена поддержка путей `/inbox/` и `/bk/` для Видео Mail.ru

# 1.6.1

Expand Down
2 changes: 1 addition & 1 deletion dist/vot-min.user.js

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions dist/vot.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ const yandexProtobuf = {
});

;// CONCATENATED MODULE: ./node_modules/vot.js/package.json
const package_namespaceObject = {"rE":"1.0.3"};
const package_namespaceObject = {"rE":"1.0.4"};
;// CONCATENATED MODULE: ./node_modules/vot.js/dist/secure.js

const utf8Encoder = new TextEncoder();
Expand Down Expand Up @@ -2507,9 +2507,20 @@ class VideoHelperError extends Error {
}
}
class MailRuHelper {
API_ORIGIN = "https://my.mail.ru/";
async getExtraVideoId(pathname) {
try {
const content = document.querySelector(".sp-video__page-config")?.innerText;
return /"itemId":\s?"([^"]+)"/.exec(content)?.[1];
}
catch (err) {
console.error("Failed to get mail.ru extra video id", err.message);
return undefined;
}
}
async getVideoData(videoId) {
try {
const res = await fetchWithTimeout(`https://my.mail.ru/+/video/meta/${videoId}?xemail=&ajax_call=1&func_name=&mna=&mnb=&ext=1&_=${new Date().getTime()}`);
const res = await fetchWithTimeout(`${this.API_ORIGIN}+/video/meta/${videoId}?xemail=&ajax_call=1&func_name=&mna=&mnb=&ext=1&_=${new Date().getTime()}`);
return (await res.json());
}
catch (err) {
Expand Down Expand Up @@ -3269,10 +3280,13 @@ async function getVideoID(service, video) {
}
case VideoService.mailru: {
const pathname = url.pathname;
if (pathname.startsWith("/v/") || pathname.startsWith("/mail/")) {
if (/\/(v|mail)\//.exec(pathname)) {
return pathname.slice(1);
}
const videoId = /video\/embed\/([^/]+)/.exec(pathname)?.[1];
const videoId = /video\/embed\/([^/]+)/.exec(pathname)?.[1] ??
/\/(bk|inbox)\/([^/]+)\/video\//.exec(pathname)
? await VideoHelper.mailru.getExtraVideoId(pathname)
: undefined;
if (!videoId) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
"bowser": "^2.11.0",
"lit": "^3.2.0",
"requestidlecallback-polyfill": "^1.0.2",
"vot.js": "^1.0.3"
"vot.js": "^1.0.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff --git a/node_modules/vot.js/dist/types/helpers/udemy.d.ts b/node_modules/vot.js/dist/types/helpers/udemy.d.ts
new file mode 100644
index 0000000..1be4a49
index 0000000..4e20871
--- /dev/null
+++ b/node_modules/vot.js/dist/types/helpers/udemy.d.ts
@@ -0,0 +1,51 @@
Expand Down Expand Up @@ -58,14 +58,14 @@ index 0000000..1be4a49
\ No newline at end of file
diff --git a/node_modules/vot.js/dist/types/helpers/udemy.js b/node_modules/vot.js/dist/types/helpers/udemy.js
new file mode 100644
index 0000000..693da49
index 0000000..0aacd4e
--- /dev/null
+++ b/node_modules/vot.js/dist/types/helpers/udemy.js
@@ -0,0 +1 @@
+export {}
\ No newline at end of file
diff --git a/node_modules/vot.js/dist/utils/helper.d.ts b/node_modules/vot.js/dist/utils/helper.d.ts
index c2f9f80..0b4416c 100644
index 80a6b43..36d1d6c 100644
--- a/node_modules/vot.js/dist/utils/helper.d.ts
+++ b/node_modules/vot.js/dist/utils/helper.d.ts
@@ -4,7 +4,8 @@ import * as Kodik from "../types/helpers/kodik.js";
Expand All @@ -76,9 +76,9 @@ index c2f9f80..0b4416c 100644
+import * as Udemy from "../types/helpers/udemy.js";
+import { VideoService, RequestLang, TranslationHelp } from "../types/yandex.js";
export declare class MailRuHelper {
getVideoData(videoId: string): Promise<MailRu.VideoInfo | undefined>;
}
@@ -80,6 +81,24 @@ export declare class KickHelper {
API_ORIGIN: string;
getExtraVideoId(pathname: string): Promise<string | undefined>;
@@ -82,6 +83,24 @@ export declare class KickHelper {
title: string;
}>;
}
Expand All @@ -103,7 +103,7 @@ index c2f9f80..0b4416c 100644
export declare class AppleDeveloperHelper {
getVideoData(videoId: string): Promise<{
url: string;
@@ -93,6 +112,7 @@ export default class VideoHelper {
@@ -95,6 +114,7 @@ export default class VideoHelper {
static [VideoService.reddit]: RedditHelper;
static [VideoService.bannedvideo]: BannedVideoHelper;
static [VideoService.kick]: KickHelper;
Expand All @@ -113,7 +113,7 @@ index c2f9f80..0b4416c 100644
//# sourceMappingURL=helper.d.ts.map
\ No newline at end of file
diff --git a/node_modules/vot.js/dist/utils/helper.js b/node_modules/vot.js/dist/utils/helper.js
index 96234ed..a6dd08e 100644
index e55f95d..0778561 100644
--- a/node_modules/vot.js/dist/utils/helper.js
+++ b/node_modules/vot.js/dist/utils/helper.js
@@ -1,8 +1,12 @@
Expand All @@ -129,7 +129,7 @@ index 96234ed..a6dd08e 100644
class VideoHelperError extends Error {
constructor(message) {
super(message);
@@ -367,6 +371,120 @@ export class KickHelper {
@@ -379,6 +383,120 @@ export class KickHelper {
};
}
}
Expand Down Expand Up @@ -250,7 +250,7 @@ index 96234ed..a6dd08e 100644
export class AppleDeveloperHelper {
async getVideoData(videoId) {
const res = await fetchWithTimeout(`https://developer.apple.com/${videoId}`);
@@ -388,5 +506,6 @@ export default class VideoHelper {
@@ -400,5 +518,6 @@ export default class VideoHelper {
static [VideoService.reddit] = new RedditHelper();
static [VideoService.bannedvideo] = new BannedVideoHelper();
static [VideoService.kick] = new KickHelper();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff --git a/node_modules/vot.js/dist/types/helpers/coursehunter.d.ts b/node_modules/vot.js/dist/types/helpers/coursehunter.d.ts
new file mode 100644
index 0000000..9f08d77
index 0000000..595fff9
--- /dev/null
+++ b/node_modules/vot.js/dist/types/helpers/coursehunter.d.ts
@@ -0,0 +1,7 @@
Expand All @@ -14,14 +14,14 @@ index 0000000..9f08d77
\ No newline at end of file
diff --git a/node_modules/vot.js/dist/types/helpers/coursehunter.js b/node_modules/vot.js/dist/types/helpers/coursehunter.js
new file mode 100644
index 0000000..693da49
index 0000000..0aacd4e
--- /dev/null
+++ b/node_modules/vot.js/dist/types/helpers/coursehunter.js
@@ -0,0 +1 @@
+export {}
\ No newline at end of file
diff --git a/node_modules/vot.js/dist/utils/helper.d.ts b/node_modules/vot.js/dist/utils/helper.d.ts
index 0b4416c..64f4eab 100644
index 36d1d6c..1f88850 100644
--- a/node_modules/vot.js/dist/utils/helper.d.ts
+++ b/node_modules/vot.js/dist/utils/helper.d.ts
@@ -5,6 +5,7 @@ import * as Patreon from "../types/helpers/patreon.js";
Expand All @@ -31,8 +31,8 @@ index 0b4416c..64f4eab 100644
+import * as Coursehunter from "../types/helpers/coursehunter.js";
import { VideoService, RequestLang, TranslationHelp } from "../types/yandex.js";
export declare class MailRuHelper {
getVideoData(videoId: string): Promise<MailRu.VideoInfo | undefined>;
@@ -99,6 +100,14 @@ export declare class UdemyHelper {
API_ORIGIN: string;
@@ -101,6 +102,14 @@ export declare class UdemyHelper {
detectedLanguage?: RequestLang
}>;
}
Expand All @@ -47,7 +47,7 @@ index 0b4416c..64f4eab 100644
export declare class AppleDeveloperHelper {
getVideoData(videoId: string): Promise<{
url: string;
@@ -113,6 +122,7 @@ export default class VideoHelper {
@@ -115,6 +124,7 @@ export default class VideoHelper {
static [VideoService.bannedvideo]: BannedVideoHelper;
static [VideoService.kick]: KickHelper;
static [VideoService.udemy]: UdemyHelper;
Expand All @@ -57,10 +57,10 @@ index 0b4416c..64f4eab 100644
//# sourceMappingURL=helper.d.ts.map
\ No newline at end of file
diff --git a/node_modules/vot.js/dist/utils/helper.js b/node_modules/vot.js/dist/utils/helper.js
index a6dd08e..0939c0a 100644
index 0778561..750d917 100644
--- a/node_modules/vot.js/dist/utils/helper.js
+++ b/node_modules/vot.js/dist/utils/helper.js
@@ -485,6 +485,33 @@ export class UdemyHelper {
@@ -497,6 +497,33 @@ export class UdemyHelper {
};
}
}
Expand Down Expand Up @@ -94,18 +94,18 @@ index a6dd08e..0939c0a 100644
export class AppleDeveloperHelper {
async getVideoData(videoId) {
const res = await fetchWithTimeout(`https://developer.apple.com/${videoId}`);
@@ -507,5 +534,6 @@ export default class VideoHelper {
@@ -519,5 +546,6 @@ export default class VideoHelper {
static [VideoService.bannedvideo] = new BannedVideoHelper();
static [VideoService.kick] = new KickHelper();
static [VideoService.udemy] = new UdemyHelper();
+ static [VideoService.coursehunter] = new CoursehunterHelper();
static [VideoService.appledeveloper] = new AppleDeveloperHelper();
}
diff --git a/node_modules/vot.js/dist/utils/videoData.js b/node_modules/vot.js/dist/utils/videoData.js
index aec4c51..c676760 100644
index bdff13c..115fa98 100644
--- a/node_modules/vot.js/dist/utils/videoData.js
+++ b/node_modules/vot.js/dist/utils/videoData.js
@@ -184,6 +184,10 @@ export async function getVideoID(service, video) {
@@ -188,6 +188,10 @@ export async function getVideoID(service, video) {
}
case VideoService.yandexdisk:
return /\/i\/([^/]+)/.exec(url.pathname)?.[1];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/node_modules/vot.js/dist/config/sites.js b/node_modules/vot.js/dist/config/sites.js
index c1a178c..29bfeeb 100644
index bfa6edc..d7598b2 100644
--- a/node_modules/vot.js/dist/config/sites.js
+++ b/node_modules/vot.js/dist/config/sites.js
@@ -233,6 +233,7 @@ export default [
@@ -238,6 +238,7 @@ export default [
url: "https://coursehunter.net/course/",
match: /^coursehunter.net$/,
selector: "#oframeplayer > pjsdiv:nth-of-type(1)",
Expand All @@ -12,7 +12,7 @@ index c1a178c..29bfeeb 100644
host: VideoService.okru,
diff --git a/node_modules/vot.js/dist/types/helpers/coursera.d.ts b/node_modules/vot.js/dist/types/helpers/coursera.d.ts
new file mode 100644
index 0000000..2803fc9
index 0000000..15d378e
--- /dev/null
+++ b/node_modules/vot.js/dist/types/helpers/coursera.d.ts
@@ -0,0 +1,52 @@
Expand Down Expand Up @@ -71,14 +71,14 @@ index 0000000..2803fc9
\ No newline at end of file
diff --git a/node_modules/vot.js/dist/types/helpers/coursera.js b/node_modules/vot.js/dist/types/helpers/coursera.js
new file mode 100644
index 0000000..693da49
index 0000000..0aacd4e
--- /dev/null
+++ b/node_modules/vot.js/dist/types/helpers/coursera.js
@@ -0,0 +1 @@
+export {}
\ No newline at end of file
diff --git a/node_modules/vot.js/dist/utils/helper.d.ts b/node_modules/vot.js/dist/utils/helper.d.ts
index 64f4eab..67e5edf 100644
index 1f88850..597091f 100644
--- a/node_modules/vot.js/dist/utils/helper.d.ts
+++ b/node_modules/vot.js/dist/utils/helper.d.ts
@@ -6,6 +6,7 @@ import * as BannedVideo from "../types/helpers/bannedvideo.js";
Expand All @@ -88,8 +88,8 @@ index 64f4eab..67e5edf 100644
+import * as Coursera from "../types/helpers/coursera.js";
import { VideoService, RequestLang, TranslationHelp } from "../types/yandex.js";
export declare class MailRuHelper {
getVideoData(videoId: string): Promise<MailRu.VideoInfo | undefined>;
@@ -97,7 +98,7 @@ export declare class UdemyHelper {
API_ORIGIN: string;
@@ -99,7 +100,7 @@ export declare class UdemyHelper {
title: string;
description: string;
translationHelp: TranslationHelp[] | null;
Expand All @@ -98,7 +98,7 @@ index 64f4eab..67e5edf 100644
}>;
}
export declare class CoursehunterHelper {
@@ -108,6 +109,19 @@ export declare class CoursehunterHelper {
@@ -110,6 +111,19 @@ export declare class CoursehunterHelper {
title: string;
}>;
}
Expand All @@ -118,7 +118,7 @@ index 64f4eab..67e5edf 100644
export declare class AppleDeveloperHelper {
getVideoData(videoId: string): Promise<{
url: string;
@@ -123,6 +137,7 @@ export default class VideoHelper {
@@ -125,6 +139,7 @@ export default class VideoHelper {
static [VideoService.kick]: KickHelper;
static [VideoService.udemy]: UdemyHelper;
static [VideoService.coursehunter]: CoursehunterHelper;
Expand All @@ -128,7 +128,7 @@ index 64f4eab..67e5edf 100644
//# sourceMappingURL=helper.d.ts.map
\ No newline at end of file
diff --git a/node_modules/vot.js/dist/utils/helper.js b/node_modules/vot.js/dist/utils/helper.js
index 0939c0a..cb1fda5 100644
index 750d917..aeba2ba 100644
--- a/node_modules/vot.js/dist/utils/helper.js
+++ b/node_modules/vot.js/dist/utils/helper.js
@@ -1,7 +1,7 @@
Expand All @@ -140,7 +140,7 @@ index 0939c0a..cb1fda5 100644
import config from "../config/config.js";
import { VideoService } from "../types/yandex.js";
import { localizationProvider } from "../../../../src/localization/localizationProvider.js";
@@ -450,13 +450,13 @@ export class UdemyHelper {
@@ -462,13 +462,13 @@ export class UdemyHelper {
}

const courseLangData = await this.getCourseLang(courseId);
Expand All @@ -159,7 +159,7 @@ index 0939c0a..cb1fda5 100644
if (!subtitleUrl) {
console.log("Failed to find subtitle file in captions", captions)
}
@@ -474,7 +474,7 @@ export class UdemyHelper {
@@ -486,7 +486,7 @@ export class UdemyHelper {
targetUrl: videoUrl,
},
],
Expand All @@ -168,7 +168,7 @@ index 0939c0a..cb1fda5 100644
} : {
url: videoUrl,
translationHelp: null,
@@ -525,6 +525,90 @@ export class AppleDeveloperHelper {
@@ -537,6 +537,90 @@ export class AppleDeveloperHelper {
};
}
}
Expand Down Expand Up @@ -259,7 +259,7 @@ index 0939c0a..cb1fda5 100644
export default class VideoHelper {
static [VideoService.mailru] = new MailRuHelper();
static [VideoService.weverse] = new WeverseHelper();
@@ -535,5 +619,6 @@ export default class VideoHelper {
@@ -547,5 +631,6 @@ export default class VideoHelper {
static [VideoService.kick] = new KickHelper();
static [VideoService.udemy] = new UdemyHelper();
static [VideoService.coursehunter] = new CoursehunterHelper();
Expand Down
14 changes: 14 additions & 0 deletions patches/vot.js+1.0.4+018+removed-mailru-extra-fetch.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/node_modules/vot.js/dist/utils/helper.js b/node_modules/vot.js/dist/utils/helper.js
index b61b6bc..f8eded2 100644
--- a/node_modules/vot.js/dist/utils/helper.js
+++ b/node_modules/vot.js/dist/utils/helper.js
@@ -18,8 +18,7 @@ export class MailRuHelper {
API_ORIGIN = "https://my.mail.ru/";
async getExtraVideoId(pathname) {
try {
- const res = await fetchWithTimeout(`${this.API_ORIGIN}${pathname}`);
- const content = await res.text();
+ const content = document.querySelector(".sp-video__page-config")?.innerText;
return /"itemId":\s?"([^"]+)"/.exec(content)?.[1];
}
catch (err) {
Loading

0 comments on commit 790205f

Please sign in to comment.