Skip to content

Commit

Permalink
builded 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyhalight committed Sep 25, 2024
1 parent d888fe0 commit da6546b
Show file tree
Hide file tree
Showing 44 changed files with 690 additions and 105 deletions.
13 changes: 13 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 1.3.0

> [!CAUTION]
> After the update, if you patch files or use the Video Helper class you need to migrate to the new logic of working with VideoHelper
- Reworked logic of VideoHelper to improve typing. Now, to get a helper, you need to create an instance of VideoHelper and call the getHelper method with the necessary service
- Added additional params to getVideoData and getVideoId
- Added info about title, description and subs for Vimeo
- Now, on Vimeo, the id of the embedded video is equal to the regular one if it's public
- Added fetch error handling for some video helpers
- Removed app_id query param for Vimeo (Maybe no more is needed)
- Fixed match Linkedin domain without `www.`

# 1.2.9

- Added support Watchporn.to embed
Expand Down
2 changes: 1 addition & 1 deletion dist/client.d.ts.map

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

2 changes: 1 addition & 1 deletion dist/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default {
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.3.1081",
componentVersion: "24.7.3.1250",
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.

5 changes: 4 additions & 1 deletion dist/config/sites.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ export default [
host: VideoService.vimeo,
url: "https://vimeo.com/",
match: /^vimeo.com$/,
needExtraData: true,
},
{
host: VideoService.vimeo,
url: "https://player.vimeo.com/",
match: /^player.vimeo.com$/,
additionalData: "embed",
needExtraData: true,
},
{
host: VideoService.xvideos,
Expand Down Expand Up @@ -242,7 +245,7 @@ export default [
{
host: VideoService.linkedin,
url: "https://www.linkedin.com/learning/",
match: /^(www)?.linkedin.com$/,
match: /^(www.)?linkedin.com$/,
needExtraData: true,
},
{
Expand Down
2 changes: 1 addition & 1 deletion dist/helpers/appledeveloper.d.ts.map

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

22 changes: 14 additions & 8 deletions dist/helpers/appledeveloper.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import { BaseHelper } from "./base.js";
import { BaseHelper, VideoHelperError } from "./base.js";
export default class AppleDeveloperHelper extends BaseHelper {
API_ORIGIN = "https://developer.apple.com";
async getVideoData(videoId) {
const res = await this.fetch(`${this.API_ORIGIN}/${videoId}`);
const content = await res.text();
const contentUrl = /https:\/\/devstreaming-cdn\.apple\.com\/videos\/([^.]+)\/(cmaf\.m3u8)/.exec(content)?.[0];
if (!contentUrl) {
try {
const res = await this.fetch(`${this.API_ORIGIN}/${videoId}`);
const content = await res.text();
const contentUrl = /https:\/\/devstreaming-cdn\.apple\.com\/videos\/([^.]+)\/(cmaf\.m3u8)/.exec(content)?.[0];
if (!contentUrl) {
throw new VideoHelperError("Failed to find content url");
}
return {
url: contentUrl,
};
}
catch (err) {
console.error(`Failed to get apple developer video data by video ID: ${videoId}`, err.message);
return undefined;
}
return {
url: contentUrl,
};
}
async getVideoId(url) {
return /videos\/play\/([^/]+)\/([\d]+)/.exec(url.pathname)?.[0];
Expand Down
12 changes: 11 additions & 1 deletion dist/helpers/base.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import { FetchFunction, MinimalVideoData } from "../types/client.js";
import { BaseHelperOpts } from "../types/helpers/base.js";
import { ServiceConf } from "../types/yandex.js";
export declare class VideoHelperError extends Error {
constructor(message: string);
}
export declare class BaseHelper {
API_ORIGIN: string;
fetch: FetchFunction;
constructor({ fetchFn }?: BaseHelperOpts);
extraInfo: boolean;
referer: string;
service: ServiceConf | undefined;
constructor({ fetchFn, extraInfo, referer, service, }?: BaseHelperOpts);
getVideoData(videoId: string): Promise<MinimalVideoData | undefined>;
getVideoId(url: URL): Promise<string | undefined>;
returnBaseData(videoId: string): {
url: string;
videoId: string;
host: import("../types/yandex.js").VideoService;
duration: undefined;
} | undefined;
}
//# sourceMappingURL=base.d.ts.map
2 changes: 1 addition & 1 deletion dist/helpers/base.d.ts.map

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

19 changes: 18 additions & 1 deletion dist/helpers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,30 @@ export class VideoHelperError extends Error {
export class BaseHelper {
API_ORIGIN = "https://example.com";
fetch;
constructor({ fetchFn = fetchWithTimeout } = {}) {
extraInfo;
referer;
service;
constructor({ fetchFn = fetchWithTimeout, extraInfo = true, referer = "", service, } = {}) {
this.fetch = fetchFn;
this.extraInfo = extraInfo;
this.referer = referer;
this.service = service;
}
async getVideoData(videoId) {
return undefined;
}
async getVideoId(url) {
return undefined;
}
returnBaseData(videoId) {
if (!this.service) {
return undefined;
}
return {
url: this.service.url + videoId,
videoId,
host: this.service.host,
duration: undefined,
};
}
}
41 changes: 25 additions & 16 deletions dist/helpers/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VideoService } from "../types/yandex.js";
import { BaseHelperOpts } from "../types/helpers/base.js";
import MailRuHelper from "./mailru.js";
import WeverseHelper from "./weverse.js";
import KodikHelper from "./kodik.js";
Expand All @@ -14,6 +14,7 @@ import CoursehunterHelper from "./coursehunter.js";
import TwitchHelper from "./twitch.js";
import SapHelper from "./sap.js";
import LinkedinHelper from "./linkedin.js";
import VimeoHelper from "./vimeo.js";
export * as MailRuHelper from "./mailru.js";
export * as WeverseHelper from "./weverse.js";
export * as KodikHelper from "./kodik.js";
Expand All @@ -29,21 +30,29 @@ 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 * as VimeoHelper from "./vimeo.js";
export declare const availableHelpers: {
mailru: typeof MailRuHelper;
weverse: typeof WeverseHelper;
kodik: typeof KodikHelper;
patreon: typeof PatreonHelper;
reddit: typeof RedditHelper;
bannedvideo: typeof BannedVideoHelper;
kick: typeof KickHelper;
apple_developer: typeof AppleDeveloperHelper;
epicgames: typeof EpicGamesHelper;
nineanimetv: typeof NineAnimeTVHelper;
odysee: typeof OdyseeHelper;
coursehunter: typeof CoursehunterHelper;
twitch: typeof TwitchHelper;
sap: typeof SapHelper;
linkedin: typeof LinkedinHelper;
vimeo: typeof VimeoHelper;
};
export type AvailableVideoHelpers = typeof availableHelpers;
export default class VideoHelper {
static readonly [VideoService.mailru]: MailRuHelper;
static readonly [VideoService.weverse]: WeverseHelper;
static readonly [VideoService.kodik]: KodikHelper;
static readonly [VideoService.patreon]: PatreonHelper;
static readonly [VideoService.reddit]: RedditHelper;
static readonly [VideoService.bannedvideo]: BannedVideoHelper;
static readonly [VideoService.kick]: KickHelper;
static readonly [VideoService.appledeveloper]: AppleDeveloperHelper;
static readonly [VideoService.epicgames]: EpicGamesHelper;
static readonly [VideoService.nineanimetv]: NineAnimeTVHelper;
static readonly [VideoService.odysee]: OdyseeHelper;
static readonly [VideoService.twitch]: TwitchHelper;
static readonly [VideoService.coursehunter]: CoursehunterHelper;
static readonly [VideoService.sap]: SapHelper;
static readonly [VideoService.linkedin]: LinkedinHelper;
helpersData: BaseHelperOpts;
constructor(helpersData?: BaseHelperOpts);
getHelper<K extends keyof AvailableVideoHelpers>(service: K): AvailableVideoHelpers[K]["prototype"];
}
//# 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.

Loading

0 comments on commit da6546b

Please sign in to comment.