-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ node_modules | |
|
||
# testing | ||
/coverage | ||
test-scripts | ||
|
||
# misc | ||
.DS_Store | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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(""", '"') | ||
.replaceAll("&", "&"); | ||
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]; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type Source = { | ||
src: string; | ||
}; | ||
//# sourceMappingURL=linkedin.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.