Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyhalight committed Sep 15, 2024
1 parent 72fcd3d commit 75b8529
Show file tree
Hide file tree
Showing 274 changed files with 478 additions and 331 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ node_modules

# testing
/coverage
test-scripts

# misc
.DS_Store
Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.2.7

- Added support Linkedin learning
- Added support raw `.webm` links
- Added support Watchporn.to
- Added support Sap `/learning-journeys` path

# 1.2.6

- Fix VTT/SRT converter for work with invalid lines type
Expand Down
1 change: 1 addition & 0 deletions dist/config/config.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
declare const _default: {
host: string;
hostVOT: string;
mediaProxy: string;
userAgent: string;
componentVersion: string;
hmac: string;
Expand Down
2 changes: 1 addition & 1 deletion dist/config/config.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion dist/config/config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export default {
host: "api.browser.yandex.ru",
hostVOT: "vot-api.toil.cc/v1",
mediaProxy: "media-proxy.toil.cc",
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 YaBrowser/24.7.0.0 Safari/537.36",
componentVersion: "24.7.2.1098",
componentVersion: "24.7.3.1081",
hmac: "bt8xH3VOlb4mqf0nqAibnDOoiPlXsisf",
defaultDuration: 343,
};
2 changes: 1 addition & 1 deletion dist/config/sites.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion dist/config/sites.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,21 @@ export default [
match: /^learning.sap.com$/,
needExtraData: true,
},
{
host: VideoService.watchpornto,
url: "https://watchporn.to/video/",
match: /^watchporn.to$/,
},
{
host: VideoService.linkedin,
url: "https://www.linkedin.com/learning/",
match: /^(www)?.linkedin.com$/,
needExtraData: true,
},
{
host: VideoService.custom,
url: "stub",
match: (url) => /([^.]+).mp4/.test(url.pathname),
match: (url) => /([^.]+).(mp4|webm)/.test(url.pathname),
rawResult: true,
},
];
3 changes: 3 additions & 0 deletions dist/helpers/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import OdyseeHelper from "./odysee.js";
import CoursehunterHelper from "./coursehunter.js";
import TwitchHelper from "./twitch.js";
import SapHelper from "./sap.js";
import LinkedinHelper from "./linkedin.js";
export * as MailRuHelper from "./mailru.js";
export * as WeverseHelper from "./weverse.js";
export * as KodikHelper from "./kodik.js";
Expand All @@ -27,6 +28,7 @@ export * as OdyseeHelper from "./odysee.js";
export * as CoursehunterHelper from "./coursehunter.js";
export * as TwitchHelper from "./twitch.js";
export * as SapHelper from "./sap.js";
export * as LinkedinHelper from "./linkedin.js";
export default class VideoHelper {
static readonly [VideoService.mailru]: MailRuHelper;
static readonly [VideoService.weverse]: WeverseHelper;
Expand All @@ -42,5 +44,6 @@ export default class VideoHelper {
static readonly [VideoService.twitch]: TwitchHelper;
static readonly [VideoService.coursehunter]: CoursehunterHelper;
static readonly [VideoService.sap]: SapHelper;
static readonly [VideoService.linkedin]: LinkedinHelper;
}
//# sourceMappingURL=index.d.ts.map
2 changes: 1 addition & 1 deletion dist/helpers/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import OdyseeHelper from "./odysee.js";
import CoursehunterHelper from "./coursehunter.js";
import TwitchHelper from "./twitch.js";
import SapHelper from "./sap.js";
import LinkedinHelper from "./linkedin.js";
export * as MailRuHelper from "./mailru.js";
export * as WeverseHelper from "./weverse.js";
export * as KodikHelper from "./kodik.js";
Expand All @@ -27,6 +28,7 @@ export * as OdyseeHelper from "./odysee.js";
export * as CoursehunterHelper from "./coursehunter.js";
export * as TwitchHelper from "./twitch.js";
export * as SapHelper from "./sap.js";
export * as LinkedinHelper from "./linkedin.js";
export default class VideoHelper {
static [VideoService.mailru] = new MailRuHelper();
static [VideoService.weverse] = new WeverseHelper();
Expand All @@ -42,4 +44,5 @@ export default class VideoHelper {
static [VideoService.twitch] = new TwitchHelper();
static [VideoService.coursehunter] = new CoursehunterHelper();
static [VideoService.sap] = new SapHelper();
static [VideoService.linkedin] = new LinkedinHelper();
}
8 changes: 8 additions & 0 deletions dist/helpers/linkedin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { MinimalVideoData } from "../types/client.js";
import { BaseHelper } from "./base.js";
export default class LinkedinHelper extends BaseHelper {
API_ORIGIN: string;
getVideoData(videoId: string): Promise<MinimalVideoData | undefined>;
getVideoId(url: URL): Promise<string | undefined>;
}
//# sourceMappingURL=linkedin.d.ts.map
1 change: 1 addition & 0 deletions dist/helpers/linkedin.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions dist/helpers/linkedin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { parseFromString } from "dom-parser";
import { BaseHelper, VideoHelperError } from "./base.js";
import { proxyMedia } from "../utils/utils.js";
export default class LinkedinHelper extends BaseHelper {
API_ORIGIN = "https://www.linkedin.com/learning";
async getVideoData(videoId) {
try {
const res = await this.fetch(`${this.API_ORIGIN}/${videoId}`);
const content = await res.text();
const doc = parseFromString(content.replace("<!DOCTYPE html>", ""));
const videoEl = doc.getElementsByClassName("video-js")?.[0];
if (!videoEl) {
throw new VideoHelperError(`Failed to find video element for videoID ${videoId}`);
}
const dataSource = (videoEl.getAttribute("data-sources") ?? "[]")
.replaceAll("&quot;", '"')
.replaceAll("&amp;", "&");
const sources = JSON.parse(dataSource);
const videoUrl = sources.find((source) => source.src.includes(".mp4"));
if (!videoUrl) {
throw new Error(`Failed to find video url for videoID ${videoId}`);
}
const url = new URL(videoUrl.src);
const captionUrl = videoEl.getAttribute("data-captions-url");
const subtitles = captionUrl
? [
{
language: "en",
format: "vtt",
url: captionUrl,
},
]
: undefined;
return {
url: proxyMedia(url),
subtitles,
};
}
catch (err) {
console.error("Failed to get linkedin video data", err.message);
return undefined;
}
}
async getVideoId(url) {
return /\/learning\/(([^/]+)\/([^/]+))/.exec(url.pathname)?.[1];
}
}
2 changes: 1 addition & 1 deletion dist/helpers/sap.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions dist/helpers/sap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { parseFromString } from "dom-parser";
import { BaseHelper, VideoHelperError } from "./base.js";
import { normalizeLang } from "../utils/utils.js";
export default class SapHelper extends BaseHelper {
API_ORIGIN = "https://learning.sap.com/courses";
API_ORIGIN = "https://learning.sap.com/";
async requestKaltura(kalturaDomain, partnerId, entryId) {
const clientTag = "html5:v3.17.22";
const apiVersion = "3.3.0";
Expand Down Expand Up @@ -68,6 +68,7 @@ export default class SapHelper extends BaseHelper {
?.firstChild?.getAttribute("id");
if (!entryId) {
entryId = /"sourceId":\s?"([^"]+)"/.exec(content)?.[1];
console.log(entryId);
}
if (!kalturaDomain || Number.isNaN(+partnerId) || !entryId) {
throw new VideoHelperError(`One of the necessary parameters for getting a link to a sap video in wasn't found for ${videoId}. Params: kalturaDomain = ${kalturaDomain}, partnerId = ${partnerId}, entryId = ${entryId}`);
Expand Down Expand Up @@ -107,6 +108,6 @@ export default class SapHelper extends BaseHelper {
};
}
async getVideoId(url) {
return /courses\/(([^/]+)(\/[^/]+)?)/.exec(url.pathname)?.[1];
return /((courses|learning-journeys)\/([^/]+)(\/[^/]+)?)/.exec(url.pathname)?.[1];
}
}
2 changes: 1 addition & 1 deletion dist/typebox/yandex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const RequestLang = Type.Index((typeof availableLangs), Type.Number())
export type ResponseLang = Static<typeof ResponseLang>
export const ResponseLang = Type.Index((typeof availableTTS), Type.Number())

export enum EnumVideoService { custom = "custom", directlink = custom, youtube = "youtube", piped = "piped", invidious = "invidious", vk = "vk", nine_gag = "nine_gag", gag = nine_gag, twitch = "twitch", proxitok = "proxitok", tiktok = "tiktok", vimeo = "vimeo", xvideos = "xvideos", pornhub = "pornhub", twitter = "twitter", rumble = "rumble", facebook = "facebook", rutube = "rutube", coub = "coub", bilibili = "bilibili", mail_ru = "mailru", mailru = mail_ru, bitchute = "bitchute", eporner = "eporner", peertube = "peertube", dailymotion = "dailymotion", trovo = "trovo", yandexdisk = "yandexdisk", ok_ru = "okru", okru = ok_ru, googledrive = "googledrive", bannedvideo = "bannedvideo", weverse = "weverse", newgrounds = "newgrounds", egghead = "egghead", youku = "youku", archive = "archive", kodik = "kodik", patreon = "patreon", reddit = "reddit", kick = "kick", apple_developer = "apple_developer", appledeveloper = apple_developer, poketube = "poketube", epicgames = "epicgames", nineanimetv = "nineanimetv", odysee = "odysee", coursehunter = "coursehunter", sap = "sap" }
export enum EnumVideoService { custom = "custom", directlink = custom, youtube = "youtube", piped = "piped", invidious = "invidious", vk = "vk", nine_gag = "nine_gag", gag = nine_gag, twitch = "twitch", proxitok = "proxitok", tiktok = "tiktok", vimeo = "vimeo", xvideos = "xvideos", pornhub = "pornhub", twitter = "twitter", rumble = "rumble", facebook = "facebook", rutube = "rutube", coub = "coub", bilibili = "bilibili", mail_ru = "mailru", mailru = mail_ru, bitchute = "bitchute", eporner = "eporner", peertube = "peertube", dailymotion = "dailymotion", trovo = "trovo", yandexdisk = "yandexdisk", ok_ru = "okru", okru = ok_ru, googledrive = "googledrive", bannedvideo = "bannedvideo", weverse = "weverse", newgrounds = "newgrounds", egghead = "egghead", youku = "youku", archive = "archive", kodik = "kodik", patreon = "patreon", reddit = "reddit", kick = "kick", apple_developer = "apple_developer", appledeveloper = apple_developer, poketube = "poketube", epicgames = "epicgames", nineanimetv = "nineanimetv", odysee = "odysee", coursehunter = "coursehunter", sap = "sap", watchpornto = "watchpornto", linkedin = "linkedin" }

export type VideoService = Static<typeof VideoService>
export const VideoService = Type.Enum(EnumVideoService)
Expand Down
4 changes: 4 additions & 0 deletions dist/types/helpers/linkedin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type Source = {
src: string;
};
//# sourceMappingURL=linkedin.d.ts.map
1 change: 1 addition & 0 deletions dist/types/helpers/linkedin.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/types/helpers/linkedin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
2 changes: 2 additions & 0 deletions dist/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ export * as BannedVideoType from "./helpers/bannedvideo.js";
export * as CoursehunterType from "./helpers/coursehunter.js";
export * as EpicGamesType from "./helpers/epicgames.js";
export * as NineAnimeTVType from "./helpers/nineanimetv.js";
export * as SapType from "./helpers/sap.js";
export * as LinkedinType from "./helpers/linkedin.js";
export * as BaseHelperType from "./helpers/base.js";
//# sourceMappingURL=index.d.ts.map
2 changes: 1 addition & 1 deletion dist/types/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ export * as BannedVideoType from "./helpers/bannedvideo.js";
export * as CoursehunterType from "./helpers/coursehunter.js";
export * as EpicGamesType from "./helpers/epicgames.js";
export * as NineAnimeTVType from "./helpers/nineanimetv.js";
export * as SapType from "./helpers/sap.js";
export * as LinkedinType from "./helpers/linkedin.js";
export * as BaseHelperType from "./helpers/base.js";
4 changes: 3 additions & 1 deletion dist/types/yandex.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export declare enum VideoService {
nineanimetv = "nineanimetv",
odysee = "odysee",
coursehunter = "coursehunter",
sap = "sap"
sap = "sap",
watchpornto = "watchpornto",
linkedin = "linkedin"
}
export type ServiceConf = {
host: VideoService;
Expand Down
Loading

0 comments on commit 75b8529

Please sign in to comment.