Skip to content

Commit

Permalink
build: rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyhalight committed Jan 10, 2025
1 parent 709f781 commit 804def0
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 118 deletions.
40 changes: 20 additions & 20 deletions dist/vot-min.user.js

Large diffs are not rendered by default.

197 changes: 99 additions & 98 deletions dist/vot.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ class Chaimu {
defaultDuration: 343,
minChunkSize: 5295308,
loggerLevel: 1,
version: "2.1.7",
version: "2.1.8",
});

;// ./node_modules/@vot.js/shared/dist/types/logger.js
Expand Down Expand Up @@ -5455,8 +5455,7 @@ class PatreonHelper extends BaseHelper {
class RedditHelper extends BaseHelper {
API_ORIGIN = "https://www.reddit.com";
async getContentUrl(videoId) {
if (!this.service.additionalData ||
this.service.additionalData !== "old") {
if (this.service?.additionalData !== "old") {
return document.querySelector("shreddit-player-2")?.src;
}
const playerEl = document.querySelector("[data-hls-url]");
Expand Down Expand Up @@ -5858,8 +5857,8 @@ class CoursehunterLikeHelper extends BaseHelper {
if (courseId !== undefined) {
return String(courseId);
}
const inputEl = document.querySelector('input[name="course_id"]');
return inputEl ? inputEl.value : undefined;
return document.querySelector('input[name="course_id"]')
?.value;
}
async getLessonsData(courseId) {
const lessons = window.lessons;
Expand Down Expand Up @@ -6077,46 +6076,69 @@ class SapHelper extends BaseHelper {
}
}

;// ./node_modules/@vot.js/ext/dist/helpers/linkedin.js
;// ./node_modules/@vot.js/ext/dist/helpers/videojs.js



class LinkedinHelper extends BaseHelper {
class VideoJSHelper extends BaseHelper {
SUBTITLE_SOURCE = "videojs";
SUBTITLE_FORMAT = "vtt";
static getPlayer() {
const videoEl = document.querySelector(".video-js");
if (!videoEl) {
return undefined;
}
return videoEl.player;
return document.querySelector(".video-js")
?.player;
}
async getVideoData(videoId) {
getVideoDataByPlayer(videoId) {
try {
const player = LinkedinHelper.getPlayer();
const player = VideoJSHelper.getPlayer();
if (!player) {
throw new Error(`Video player doesn't have player option, videoId ${videoId}`);
}
const { cache_: { sources, duration }, textTracks_: { tracks_ }, } = player;
const videoUrl = sources.find((source) => source.type === "video/mp4");
const duration = player.duration();
const sources = Array.isArray(player.currentSources)
? player.currentSources
: player.getCache()?.sources;
const { tracks_: tracks } = player.textTracks();
const videoUrl = sources.find((source) => source.type === "video/mp4" || source.type === "video/webm");
if (!videoUrl) {
throw new Error(`Failed to find video url for videoID ${videoId}`);
}
const url = new URL(videoUrl.src);
const subtitles = tracks_.map((track) => ({
const subtitles = tracks
.filter((track) => track.src)
.map((track) => ({
language: normalizeLang(track.language),
source: "linkedin",
format: "vtt",
source: this.SUBTITLE_SOURCE,
format: this.SUBTITLE_FORMAT,
url: track.src,
}));
return {
url: proxyMedia(url),
url: videoUrl.src,
duration,
subtitles,
};
}
catch (err) {
Logger.error("Failed to get linkedin video data", err.message);
Logger.error("Failed to get videojs video data", err.message);
return undefined;
}
}
}

;// ./node_modules/@vot.js/ext/dist/helpers/linkedin.js


class LinkedinHelper extends VideoJSHelper {
SUBTITLE_SOURCE = "linkedin";
async getVideoData(videoId) {
const data = this.getVideoDataByPlayer(videoId);
if (!data) {
return undefined;
}
const { url, duration, subtitles } = data;
return {
url: proxyMedia(new URL(url)),
duration,
subtitles,
};
}
async getVideoId(url) {
return /\/learning\/(([^/]+)\/([^/]+))/.exec(url.pathname)?.[1];
Expand Down Expand Up @@ -6534,23 +6556,12 @@ class VKHelper extends BaseHelper {
return undefined;
}
const videoView = Videoview;
return videoView.getPlayerObject
? videoView.getPlayerObject.call(undefined)
: undefined;
}
getDefault(videoId) {
if (!this.service) {
return undefined;
}
return {
url: this.service.url + videoId,
duration: undefined,
};
return videoView?.getPlayerObject?.call(undefined);
}
async getVideoData(videoId) {
const player = VKHelper.getPlayer();
if (!player) {
return this.getDefault(videoId);
return this.returnBaseData(videoId);
}
try {
const { description: descriptionHTML, duration, md_title: title, } = player.vars;
Expand Down Expand Up @@ -6580,7 +6591,7 @@ class VKHelper extends BaseHelper {
}
catch (err) {
Logger.error(`Failed to get VK video data, because: ${err.message}`);
return this.getDefault(videoId);
return this.returnBaseData(videoId);
}
}
async getVideoId(url) {
Expand Down Expand Up @@ -7171,8 +7182,9 @@ class UdemyHelper extends BaseHelper {



class CourseraHelper extends BaseHelper {
class CourseraHelper extends VideoJSHelper {
API_ORIGIN = "https://www.coursera.org/api";
SUBTITLE_SOURCE = "coursera";
async getCourseData(courseId) {
try {
const response = await this.fetch(`${this.API_ORIGIN}/onDemandCourses.v1/${courseId}`);
Expand All @@ -7184,74 +7196,75 @@ class CourseraHelper extends BaseHelper {
return undefined;
}
}
getPlayer() {
return document.querySelector(".vjs-v8");
}
getPlayerData() {
return this.getPlayer()?.player;
}
findVideoUrl(sources) {
return sources?.find((src) => src.type === "video/mp4")?.src;
}
findSubtitleUrl(captions, detectedLanguage) {
let subtitle = captions?.find((caption) => normalizeLang(caption.srclang) === detectedLanguage);
if (!subtitle) {
subtitle =
captions?.find((caption) => normalizeLang(caption.srclang) === "en") ||
captions?.[0];
}
return subtitle?.src;
static getPlayer() {
return super.getPlayer();
}
async getVideoData(videoId) {
const playerData = this.getPlayerData();
if (!playerData) {
Logger.error("Failed to find player data");
const data = this.getVideoDataByPlayer(videoId);
if (!data) {
return undefined;
}
const { cache_: { duration }, options_: { courseId, tracks, sources }, } = playerData;
const videoUrl = this.findVideoUrl(sources);
if (!videoUrl) {
Logger.error("Failed to find .mp4 video file in sources", sources);
return undefined;
const { options_: options } = CourseraHelper.getPlayer() ?? {};
if (!data.subtitles?.length && options) {
data.subtitles = options.tracks.map((track) => ({
url: track.src,
language: normalizeLang(track.srclang),
source: this.SUBTITLE_SOURCE,
format: this.SUBTITLE_FORMAT,
}));
}
const courseId = options?.courseId;
if (!courseId) {
return data;
}
let courseLang = "en";
const courseData = await this.getCourseData(courseId);
if (courseData) {
const { primaryLanguageCodes: [primaryLangauge], } = courseData;
courseLang = primaryLangauge ? normalizeLang(primaryLangauge) : "en";
courseLang = primaryLangauge
? normalizeLang(primaryLangauge)
: "en";
}
if (!availableLangs.includes(courseLang)) {
courseLang = "en";
}
const subtitleUrl = this.findSubtitleUrl(tracks, courseLang);
const subtitleItem = data.subtitles.find((subtitle) => subtitle.language === courseLang) ??
data.subtitles?.[0];
const subtitleUrl = subtitleItem?.url;
if (!subtitleUrl) {
Logger.warn("Failed to find subtitle file in tracks", tracks);
}
Logger.warn("Failed to find any subtitle file");
}
const { url, duration } = data;
const translationHelp = subtitleUrl
? [
{
target: "subtitles_file_url",
targetUrl: subtitleUrl,
},
{
target: "video_file_url",
targetUrl: url,
},
]
: null;
return {
...(subtitleUrl
? {
url: this.service?.url + videoId,
translationHelp: [
{
target: "subtitles_file_url",
targetUrl: subtitleUrl,
},
{
target: "video_file_url",
targetUrl: videoUrl,
},
],
translationHelp,
}
: {
url: videoUrl,
translationHelp: null,
url,
translationHelp,
}),
detectedLanguage: courseLang,
duration,
};
}
async getVideoId(url) {
return /learn\/([^/]+)\/lecture\/([^/]+)/.exec(url.pathname)?.[0];
const matched = /learn\/([^/]+)\/lecture\/([^/]+)/.exec(url.pathname) ??
/lecture\/([^/]+)\/([^/]+)/.exec(url.pathname);
return matched?.[0];
}
}

Expand All @@ -7268,18 +7281,18 @@ class CloudflareStreamHelper extends BaseHelper {


class DouyinHelper extends BaseHelper {
getPlayer() {
static getPlayer() {
if (typeof player === "undefined") {
return undefined;
}
return player;
}
async getVideoData(videoId) {
const xgPlayer = this.getPlayer();
const xgPlayer = DouyinHelper.getPlayer();
if (!xgPlayer) {
return undefined;
}
const { url: sources, duration, lang, isLive: isStream } = xgPlayer.config;
const { config: { url: sources, duration, lang, isLive: isStream }, } = xgPlayer;
if (!sources) {
return undefined;
}
Expand All @@ -7301,11 +7314,7 @@ class DouyinHelper extends BaseHelper {
if (pathId) {
return pathId;
}
const xgPlayer = this.getPlayer();
if (!xgPlayer) {
return undefined;
}
return xgPlayer.config.vid;
return DouyinHelper.getPlayer()?.config.vid;
}
}

Expand Down Expand Up @@ -7359,16 +7368,7 @@ class LoomHelper extends BaseHelper {
return undefined;
}
const release = SENTRY_RELEASE;
return release?.id;
}
getDefault(videoId) {
if (!this.service) {
return undefined;
}
return {
url: this.service.url + videoId,
duration: undefined,
};
return release.id;
}
async getVideoData(videoId) {
try {
Expand Down Expand Up @@ -7410,7 +7410,7 @@ class LoomHelper extends BaseHelper {
}
catch (err) {
Logger.error(`Failed to get Loom video data, because: ${err.message}`);
return this.getDefault(videoId);
return this.returnBaseData(videoId);
}
}
async getVideoId(url) {
Expand Down Expand Up @@ -7777,6 +7777,7 @@ async function getVideoData(service, opts = {}) {




;// ./node_modules/@vot.js/ext/dist/index.js


Expand Down

0 comments on commit 804def0

Please sign in to comment.