azot 5.0.0-alpha.2 → 5.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -4
- package/dist/api.mjs +1 -0
- package/dist/azot.mjs +20 -0
- package/dist/azt.mjs +2 -0
- package/dist/builtins/instagram/instagram.cjs +121 -0
- package/dist/builtins/ntv/ntv.cjs +104 -0
- package/dist/builtins/rbc/rbc.cjs +37 -0
- package/dist/builtins/rutube/rutube.cjs +92 -0
- package/dist/builtins/soundcloud/soundcloud.cjs +94 -0
- package/dist/builtins/tiktok/tiktok.cjs +76 -0
- package/dist/builtins/virtualroom/virtualroom.cjs +46 -0
- package/dist/builtins/vk/vk.cjs +122 -0
- package/dist/builtins/weibo/weibo.cjs +64 -0
- package/dist/context--_LoC7SX.mjs +3 -0
- package/dist/context.mjs +1 -0
- package/dist/vitest.mjs +1 -0
- package/package.json +62 -139
- package/types/{main.d.ts → api.d.ts} +31 -15
- package/types/extension-v2.d.ts +81 -0
- package/types/extension.d.ts +8 -8
- package/types/feedback.d.ts +86 -0
- package/types/manifest.d.ts +9 -0
- package/out/azt.js +0 -2
- package/out/chunk-nOFOJqeH.js +0 -1
- package/out/main.js +0 -1
- package/out/test.js +0 -3
- package/types/input.d.ts +0 -15
- /package/types/{test.d.ts → context.d.ts} +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//#region src/extensions-api/main.ts
|
|
2
|
+
const runtimeContext = Azot ?? Streamyx ?? {};
|
|
3
|
+
if (runtimeContext) {
|
|
4
|
+
if (!runtimeContext.defineExtension) runtimeContext.defineExtension = (extension) => extension;
|
|
5
|
+
}
|
|
6
|
+
const defineExtension = runtimeContext.defineExtension;
|
|
7
|
+
runtimeContext.version;
|
|
8
|
+
runtimeContext.sleep;
|
|
9
|
+
runtimeContext.input;
|
|
10
|
+
runtimeContext.prompt;
|
|
11
|
+
runtimeContext.notify;
|
|
12
|
+
runtimeContext.confirm;
|
|
13
|
+
runtimeContext.ask;
|
|
14
|
+
runtimeContext.utils;
|
|
15
|
+
const Input = runtimeContext.Input;
|
|
16
|
+
const UrlSource = runtimeContext.UrlSource;
|
|
17
|
+
runtimeContext.ALL_FORMATS;
|
|
18
|
+
runtimeContext.DASH;
|
|
19
|
+
runtimeContext.DASH_FORMATS;
|
|
20
|
+
runtimeContext.HLS;
|
|
21
|
+
runtimeContext.HLS_FORMATS;
|
|
22
|
+
runtimeContext.MP4;
|
|
23
|
+
runtimeContext.MP3;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/builtins/ntv/ntv.ts
|
|
26
|
+
const between = (text, from, to) => text.split(from)[1]?.split(to)[0];
|
|
27
|
+
const extractXmlTag = (xmlBody, tagName) => {
|
|
28
|
+
const rawContent = between(xmlBody, `<${tagName}>`, `</${tagName}>`)?.trim();
|
|
29
|
+
if (!rawContent) return void 0;
|
|
30
|
+
const cdataMatch = rawContent.match(/<!\[CDATA\[(.*?)\]\]>/s);
|
|
31
|
+
if (cdataMatch?.[1]) return cdataMatch[1].trim();
|
|
32
|
+
return rawContent.split("DATA[")[1]?.split("]")[0]?.trim() || rawContent;
|
|
33
|
+
};
|
|
34
|
+
const fetchText = async (url, kind) => {
|
|
35
|
+
const response = await fetch(url);
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
console.error(`Failed to fetch ${kind}. Status: ${response.status} ${response.statusText}`);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return await response.text();
|
|
41
|
+
};
|
|
42
|
+
const resolveEpisodeEntries = async (url, pageBody, visited) => {
|
|
43
|
+
const pathname = new URL(url).pathname;
|
|
44
|
+
const episodeUrls = /* @__PURE__ */ new Set();
|
|
45
|
+
for (const part of pageBody.split("href=\"/serial")) {
|
|
46
|
+
if (!part.startsWith("/")) continue;
|
|
47
|
+
const route = part.split("\"")[0];
|
|
48
|
+
if (!route || route.length <= 1 || route.includes("/issues/") || route.includes("/about/") || route.split("/").length <= 2) continue;
|
|
49
|
+
episodeUrls.add(url.replace(pathname, `/serial${route}`));
|
|
50
|
+
}
|
|
51
|
+
const results = [];
|
|
52
|
+
for (const episodeUrl of episodeUrls) results.push(...await resolveEntriesInternal(episodeUrl, visited));
|
|
53
|
+
return results;
|
|
54
|
+
};
|
|
55
|
+
const resolveEntriesInternal = async (url, visited = /* @__PURE__ */ new Set()) => {
|
|
56
|
+
if (visited.has(url)) return [];
|
|
57
|
+
visited.add(url);
|
|
58
|
+
const pageBody = await fetchText(url, "NTV page");
|
|
59
|
+
if (!pageBody) return [];
|
|
60
|
+
const videoMetadataFeedLink = between(pageBody, "<meta property=\"ya:ovs:feed_url\" content=\"", "\">") ?? between(pageBody, "<meta property=\"ya:ovs:feed_url\" content=\"", "\" />");
|
|
61
|
+
if (!videoMetadataFeedLink) {
|
|
62
|
+
if (new URL(url).pathname.includes("/serial")) return resolveEpisodeEntries(url, pageBody, visited);
|
|
63
|
+
console.error("Could not find video link in the page.");
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
const videoId = videoMetadataFeedLink.split("video/")[1]?.split("/")[0];
|
|
67
|
+
if (!videoId) {
|
|
68
|
+
console.error("Could not parse NTV video id.");
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
const xmlBody = await fetchText(`https://www.ntv.ru/vi${videoId}/`, "NTV XML metadata");
|
|
72
|
+
if (!xmlBody) return [];
|
|
73
|
+
const playbackLink = extractXmlTag(xmlBody, "dash") || extractXmlTag(xmlBody, "hls");
|
|
74
|
+
const fileLink = extractXmlTag(xmlBody, "file") || extractXmlTag(xmlBody, "video");
|
|
75
|
+
const finalLink = extractXmlTag(xmlBody, "hifile") || extractXmlTag(xmlBody, "hd_video") || playbackLink || fileLink;
|
|
76
|
+
if (!finalLink) {
|
|
77
|
+
console.error("Could not resolve NTV media URL.");
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
const title = between(xmlBody, "<embed_tag>", "</embed_tag>") || "NTV";
|
|
81
|
+
const name = between(pageBody, "\"name\":\"", "\"");
|
|
82
|
+
const episodeNumberString = name?.includes("серия") ? name.split("-")[0] : void 0;
|
|
83
|
+
const episodeNumber = episodeNumberString ? parseInt(episodeNumberString, 10) : void 0;
|
|
84
|
+
const subtitlesRoute = between(xmlBody, "<subtitles>", "</subtitles>");
|
|
85
|
+
const subtitlesUrl = subtitlesRoute ? `https://www.ntv.ru${subtitlesRoute}` : void 0;
|
|
86
|
+
if (subtitlesUrl) console.debug(`Subtitles: ${subtitlesUrl}`);
|
|
87
|
+
const input = new Input({ source: new UrlSource(finalLink) });
|
|
88
|
+
if (subtitlesUrl) input.addSubtitleTrack(new UrlSource(subtitlesUrl), {
|
|
89
|
+
languageCode: "ru",
|
|
90
|
+
name: "Russian"
|
|
91
|
+
});
|
|
92
|
+
return [{
|
|
93
|
+
type: episodeNumber ? "episode" : "video",
|
|
94
|
+
title,
|
|
95
|
+
season: episodeNumber ? 1 : void 0,
|
|
96
|
+
episode: episodeNumber,
|
|
97
|
+
input
|
|
98
|
+
}];
|
|
99
|
+
};
|
|
100
|
+
var ntv_default = defineExtension({ resolveEntries(url) {
|
|
101
|
+
return resolveEntriesInternal(url, /* @__PURE__ */ new Set());
|
|
102
|
+
} });
|
|
103
|
+
//#endregion
|
|
104
|
+
module.exports = ntv_default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/extensions-api/main.ts
|
|
2
|
+
const runtimeContext = Azot ?? Streamyx ?? {};
|
|
3
|
+
if (runtimeContext) {
|
|
4
|
+
if (!runtimeContext.defineExtension) runtimeContext.defineExtension = (extension) => extension;
|
|
5
|
+
}
|
|
6
|
+
const defineExtension = runtimeContext.defineExtension;
|
|
7
|
+
runtimeContext.version;
|
|
8
|
+
runtimeContext.sleep;
|
|
9
|
+
runtimeContext.input;
|
|
10
|
+
runtimeContext.prompt;
|
|
11
|
+
runtimeContext.notify;
|
|
12
|
+
runtimeContext.confirm;
|
|
13
|
+
runtimeContext.ask;
|
|
14
|
+
runtimeContext.utils;
|
|
15
|
+
const Input = runtimeContext.Input;
|
|
16
|
+
const UrlSource = runtimeContext.UrlSource;
|
|
17
|
+
runtimeContext.ALL_FORMATS;
|
|
18
|
+
runtimeContext.DASH;
|
|
19
|
+
runtimeContext.DASH_FORMATS;
|
|
20
|
+
runtimeContext.HLS;
|
|
21
|
+
runtimeContext.HLS_FORMATS;
|
|
22
|
+
runtimeContext.MP4;
|
|
23
|
+
runtimeContext.MP3;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/builtins/rbc/rbc.ts
|
|
26
|
+
var rbc_default = defineExtension({ async resolveEntries(url) {
|
|
27
|
+
const response = await fetch(url);
|
|
28
|
+
if (!response.ok) throw new Error(`Failed to fetch RBC page: ${response.status} ${response.statusText}`);
|
|
29
|
+
const uri = (await response.text()).match(/(?:https?:)?\/\/[^\s"'<>]+\.m3u8(?:\?[^\s"'<>]*)?/i)?.[0];
|
|
30
|
+
if (!uri) throw new Error("Could not find RBC playlist URL.");
|
|
31
|
+
return [{
|
|
32
|
+
type: "video",
|
|
33
|
+
input: new Input({ source: new UrlSource(uri.startsWith("//") ? `https:${uri}` : uri) })
|
|
34
|
+
}];
|
|
35
|
+
} });
|
|
36
|
+
//#endregion
|
|
37
|
+
module.exports = rbc_default;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region src/extensions-api/main.ts
|
|
2
|
+
const runtimeContext = Azot ?? Streamyx ?? {};
|
|
3
|
+
if (runtimeContext) {
|
|
4
|
+
if (!runtimeContext.defineExtension) runtimeContext.defineExtension = (extension) => extension;
|
|
5
|
+
}
|
|
6
|
+
const defineExtension = runtimeContext.defineExtension;
|
|
7
|
+
runtimeContext.version;
|
|
8
|
+
runtimeContext.sleep;
|
|
9
|
+
runtimeContext.input;
|
|
10
|
+
runtimeContext.prompt;
|
|
11
|
+
runtimeContext.notify;
|
|
12
|
+
runtimeContext.confirm;
|
|
13
|
+
runtimeContext.ask;
|
|
14
|
+
runtimeContext.utils;
|
|
15
|
+
const Input = runtimeContext.Input;
|
|
16
|
+
const UrlSource = runtimeContext.UrlSource;
|
|
17
|
+
runtimeContext.ALL_FORMATS;
|
|
18
|
+
runtimeContext.DASH;
|
|
19
|
+
runtimeContext.DASH_FORMATS;
|
|
20
|
+
runtimeContext.HLS;
|
|
21
|
+
runtimeContext.HLS_FORMATS;
|
|
22
|
+
runtimeContext.MP4;
|
|
23
|
+
runtimeContext.MP3;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/builtins/rutube/rutube.ts
|
|
26
|
+
const patterns = [
|
|
27
|
+
"/video/:id{/}?",
|
|
28
|
+
"/play/embed/:id{/}?",
|
|
29
|
+
"/shorts/:id{/}?",
|
|
30
|
+
"/yappy/:yappyId{/}?",
|
|
31
|
+
"/video/private/:id{/}?"
|
|
32
|
+
];
|
|
33
|
+
const getRutubeParams = (url) => {
|
|
34
|
+
const params = {
|
|
35
|
+
yappyId: "",
|
|
36
|
+
id: "",
|
|
37
|
+
key: ""
|
|
38
|
+
};
|
|
39
|
+
params.key = new URL(url).searchParams.get("p") ?? "";
|
|
40
|
+
for (const path of patterns) {
|
|
41
|
+
const match = new URLPattern(path, "https://rutube.ru").exec(url);
|
|
42
|
+
if (!match) continue;
|
|
43
|
+
Object.assign(params, match.pathname.groups);
|
|
44
|
+
Object.assign(params, match.search.groups);
|
|
45
|
+
}
|
|
46
|
+
return params;
|
|
47
|
+
};
|
|
48
|
+
const resolveYappyEntries = async (yappyId) => {
|
|
49
|
+
const yappyUrl = (await fetch(`https://rutube.ru/pangolin/api/web/yappy/yappypage/?client=wdp&videoId=${yappyId}&page=1&page_size=15`).then((result) => result.json()).catch(() => null))?.results?.find((item) => String(item.id) === yappyId)?.link;
|
|
50
|
+
if (!yappyUrl) {
|
|
51
|
+
console.error("ErrorEmptyDownload");
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
return [{
|
|
55
|
+
type: "video",
|
|
56
|
+
title: `rutube_yappy_${yappyId}`,
|
|
57
|
+
input: new Input({ source: new UrlSource(yappyUrl) })
|
|
58
|
+
}];
|
|
59
|
+
};
|
|
60
|
+
var rutube_default = defineExtension({ async resolveEntries(url) {
|
|
61
|
+
const params = getRutubeParams(url);
|
|
62
|
+
if (params.yappyId) return resolveYappyEntries(params.yappyId);
|
|
63
|
+
if (!params.id) {
|
|
64
|
+
console.error("Could not extract Rutube video id");
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
const requestUrl = new URL(`https://rutube.ru/api/play/options/${params.id}/?no_404=true&referer&pver=v2`);
|
|
68
|
+
if (params.key) requestUrl.searchParams.set("p", params.key);
|
|
69
|
+
const play = await fetch(requestUrl).then((response) => response.json()).catch((error) => {
|
|
70
|
+
if (error instanceof Error) console.debug(error.message);
|
|
71
|
+
return null;
|
|
72
|
+
});
|
|
73
|
+
if (!play) {
|
|
74
|
+
console.error("Cannot fetch play info");
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
if (play.detail || !play.video_balancer?.m3u8) {
|
|
78
|
+
console.error("Play info is empty");
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
if (play.live_streams?.hls) {
|
|
82
|
+
console.error("Live videos are not supported");
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
return [{
|
|
86
|
+
type: "video",
|
|
87
|
+
title: play.title?.trim() || `rutube_${params.id}`,
|
|
88
|
+
input: new Input({ source: new UrlSource(play.video_balancer.m3u8) })
|
|
89
|
+
}];
|
|
90
|
+
} });
|
|
91
|
+
//#endregion
|
|
92
|
+
module.exports = rutube_default;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//#region src/extensions-api/main.ts
|
|
2
|
+
const runtimeContext = Azot ?? Streamyx ?? {};
|
|
3
|
+
if (runtimeContext) {
|
|
4
|
+
if (!runtimeContext.defineExtension) runtimeContext.defineExtension = (extension) => extension;
|
|
5
|
+
}
|
|
6
|
+
const defineExtension = runtimeContext.defineExtension;
|
|
7
|
+
runtimeContext.version;
|
|
8
|
+
runtimeContext.sleep;
|
|
9
|
+
runtimeContext.input;
|
|
10
|
+
runtimeContext.prompt;
|
|
11
|
+
runtimeContext.notify;
|
|
12
|
+
runtimeContext.confirm;
|
|
13
|
+
runtimeContext.ask;
|
|
14
|
+
const utils = runtimeContext.utils;
|
|
15
|
+
const Input = runtimeContext.Input;
|
|
16
|
+
const UrlSource = runtimeContext.UrlSource;
|
|
17
|
+
runtimeContext.ALL_FORMATS;
|
|
18
|
+
runtimeContext.DASH;
|
|
19
|
+
runtimeContext.DASH_FORMATS;
|
|
20
|
+
runtimeContext.HLS;
|
|
21
|
+
runtimeContext.HLS_FORMATS;
|
|
22
|
+
runtimeContext.MP4;
|
|
23
|
+
runtimeContext.MP3;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/builtins/soundcloud/soundcloud.ts
|
|
26
|
+
const cachedId = {
|
|
27
|
+
version: "",
|
|
28
|
+
id: ""
|
|
29
|
+
};
|
|
30
|
+
const findClientId = async () => {
|
|
31
|
+
try {
|
|
32
|
+
const homePage = await fetch("https://soundcloud.com/").then((response) => response.text()).catch((error) => {
|
|
33
|
+
const cause = error instanceof Error && error.cause != null ? String(error.cause) : "";
|
|
34
|
+
if (error instanceof Error && cause.includes("ECONNRESET")) console.warn("Soundcloud may be blocked in your region. Use proxy or VPN to bypass restrictions.");
|
|
35
|
+
return "";
|
|
36
|
+
});
|
|
37
|
+
const version = homePage.match(/window\.__sc_version="([0-9]{10})"/)?.[1];
|
|
38
|
+
if (version && cachedId.version === version) return cachedId.id;
|
|
39
|
+
let clientId = "";
|
|
40
|
+
for (const script of homePage.matchAll(/<script.+src="(.+)">/g)) {
|
|
41
|
+
const assetUrl = script[1];
|
|
42
|
+
if (!assetUrl?.startsWith("https://a-v2.sndcdn.com/")) continue;
|
|
43
|
+
const resolvedId = (await fetch(assetUrl).then((response) => response.text()).catch(() => "")).match(/\("client_id=[A-Za-z0-9]{32}"\)/)?.[0].match(/[A-Za-z0-9]{32}/)?.[0];
|
|
44
|
+
if (resolvedId) {
|
|
45
|
+
clientId = resolvedId;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (version) {
|
|
50
|
+
cachedId.version = version;
|
|
51
|
+
cachedId.id = clientId;
|
|
52
|
+
}
|
|
53
|
+
return clientId;
|
|
54
|
+
} catch {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const prefersMp3 = (options) => options.audioCodecs?.some((codec) => codec === "aac" || codec === "mp3") ?? false;
|
|
59
|
+
var soundcloud_default = defineExtension({ async resolveEntries(url, options) {
|
|
60
|
+
const { author, song, accessKey, shortLink } = utils.execUrlPatterns(url, [
|
|
61
|
+
":author/:song/s-:accessKey",
|
|
62
|
+
":author/:song",
|
|
63
|
+
":shortLink"
|
|
64
|
+
], ["https://soundcloud.com", "https://on.soundcloud.com"]).pathname;
|
|
65
|
+
const clientId = await findClientId();
|
|
66
|
+
if (!clientId) throw new Error("No client ID");
|
|
67
|
+
let link;
|
|
68
|
+
if (new URL(url).hostname === "on.soundcloud.com" && shortLink) link = await fetch(`https://on.soundcloud.com/${shortLink}/`, { redirect: "manual" }).then((response) => {
|
|
69
|
+
const location = response.headers.get("location");
|
|
70
|
+
if (response.status === 302 && location?.startsWith("https://soundcloud.com/")) return location.split("?", 1)[0];
|
|
71
|
+
}).catch(() => void 0);
|
|
72
|
+
if (!link && author && song) link = `https://soundcloud.com/${author}/${song}${accessKey ? `/s-${accessKey}` : ""}`;
|
|
73
|
+
if (!link) throw new Error("Could not fetch");
|
|
74
|
+
const json = await fetch(`https://api-v2.soundcloud.com/resolve?url=${link}&client_id=${clientId}`).then((response) => response.status === 200 ? response.json() : null).catch(() => null);
|
|
75
|
+
if (!json) throw new Error("Could not fetch");
|
|
76
|
+
const transcodings = json.media?.transcodings;
|
|
77
|
+
if (!transcodings?.length) throw new Error("Empty download");
|
|
78
|
+
let selectedStream = transcodings.find((value) => value.preset === "opus_0_0");
|
|
79
|
+
const mp3Stream = transcodings.find((value) => value.preset === "mp3_0_0");
|
|
80
|
+
if (mp3Stream && (prefersMp3(options) || !selectedStream)) selectedStream = mp3Stream;
|
|
81
|
+
if (!selectedStream) throw new Error("Empty download");
|
|
82
|
+
const streamUrl = `${selectedStream.url}${selectedStream.url.includes("?") ? "&" : "?"}client_id=${clientId}&track_authorization=${json.track_authorization}`;
|
|
83
|
+
if (!streamUrl.startsWith("https://api-v2.soundcloud.com/media/soundcloud:tracks:")) throw new Error("Empty download");
|
|
84
|
+
const fileUrl = await fetch(streamUrl).then(async (response) => (await response.json()).url ?? "").catch(() => "");
|
|
85
|
+
if (!fileUrl) throw new Error("Could not fetch");
|
|
86
|
+
return [{
|
|
87
|
+
type: "audio",
|
|
88
|
+
title: json.title.trim(),
|
|
89
|
+
author: json.user.username.trim(),
|
|
90
|
+
input: new Input({ source: new UrlSource(fileUrl) })
|
|
91
|
+
}];
|
|
92
|
+
} });
|
|
93
|
+
//#endregion
|
|
94
|
+
module.exports = soundcloud_default;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//#region src/extensions-api/main.ts
|
|
2
|
+
const runtimeContext = Azot ?? Streamyx ?? {};
|
|
3
|
+
if (runtimeContext) {
|
|
4
|
+
if (!runtimeContext.defineExtension) runtimeContext.defineExtension = (extension) => extension;
|
|
5
|
+
}
|
|
6
|
+
const defineExtension = runtimeContext.defineExtension;
|
|
7
|
+
runtimeContext.version;
|
|
8
|
+
runtimeContext.sleep;
|
|
9
|
+
runtimeContext.input;
|
|
10
|
+
runtimeContext.prompt;
|
|
11
|
+
runtimeContext.notify;
|
|
12
|
+
runtimeContext.confirm;
|
|
13
|
+
runtimeContext.ask;
|
|
14
|
+
runtimeContext.utils;
|
|
15
|
+
const Input = runtimeContext.Input;
|
|
16
|
+
const UrlSource = runtimeContext.UrlSource;
|
|
17
|
+
runtimeContext.ALL_FORMATS;
|
|
18
|
+
runtimeContext.DASH;
|
|
19
|
+
runtimeContext.DASH_FORMATS;
|
|
20
|
+
runtimeContext.HLS;
|
|
21
|
+
runtimeContext.HLS_FORMATS;
|
|
22
|
+
runtimeContext.MP4;
|
|
23
|
+
runtimeContext.MP3;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/builtins/tiktok/tiktok.ts
|
|
26
|
+
var tiktok_default = defineExtension({
|
|
27
|
+
canHandle: (url) => {
|
|
28
|
+
try {
|
|
29
|
+
const hostname = new URL(url).hostname.toLowerCase();
|
|
30
|
+
return hostname === "tiktok.com" || hostname.endsWith(".tiktok.com");
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
async resolveEntries(url) {
|
|
36
|
+
const response = await fetch(url);
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
console.error(`Failed to fetch TikTok page. Status: ${response.status}`);
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const jsonString = (await response.text()).split("<script id=\"__UNIVERSAL_DATA_FOR_REHYDRATION__\" type=\"application/json\">")[1]?.split("<\/script>")[0];
|
|
42
|
+
if (!jsonString) {
|
|
43
|
+
console.error("Could not find target script tag. TikTok might have updated their page structure.");
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
let data;
|
|
47
|
+
try {
|
|
48
|
+
data = JSON.parse(jsonString);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error("Failed to parse TikTok page JSON", error, { url });
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
const videoDetail = data.__DEFAULT_SCOPE__?.["webapp.video-detail"];
|
|
54
|
+
const videoData = videoDetail?.itemInfo?.itemStruct;
|
|
55
|
+
if (!videoData) {
|
|
56
|
+
console.error("Could not find video data in the JSON payload. The content might be unavailable or the structure has changed.");
|
|
57
|
+
if (videoDetail?.statusMsg) console.error(`Error ${videoDetail.statusCode}: ${videoDetail.statusMsg}`);
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
const videoUrl = videoData.video?.playAddr;
|
|
61
|
+
if (!videoUrl) {
|
|
62
|
+
console.error("Could not find a video URL (playAddr) in the JSON payload.");
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
return [{
|
|
66
|
+
type: "video",
|
|
67
|
+
title: videoData.desc || "TikTok Video",
|
|
68
|
+
input: new Input({ source: new UrlSource(videoUrl, { requestInit: { headers: {
|
|
69
|
+
Referer: "https://www.tiktok.com/",
|
|
70
|
+
Cookie: document.cookie
|
|
71
|
+
} } }) })
|
|
72
|
+
}];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
//#endregion
|
|
76
|
+
module.exports = tiktok_default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/extensions-api/main.ts
|
|
2
|
+
const runtimeContext = Azot ?? Streamyx ?? {};
|
|
3
|
+
if (runtimeContext) {
|
|
4
|
+
if (!runtimeContext.defineExtension) runtimeContext.defineExtension = (extension) => extension;
|
|
5
|
+
}
|
|
6
|
+
const defineExtension = runtimeContext.defineExtension;
|
|
7
|
+
runtimeContext.version;
|
|
8
|
+
runtimeContext.sleep;
|
|
9
|
+
runtimeContext.input;
|
|
10
|
+
runtimeContext.prompt;
|
|
11
|
+
runtimeContext.notify;
|
|
12
|
+
runtimeContext.confirm;
|
|
13
|
+
runtimeContext.ask;
|
|
14
|
+
runtimeContext.utils;
|
|
15
|
+
const Input = runtimeContext.Input;
|
|
16
|
+
const UrlSource = runtimeContext.UrlSource;
|
|
17
|
+
runtimeContext.ALL_FORMATS;
|
|
18
|
+
runtimeContext.DASH;
|
|
19
|
+
runtimeContext.DASH_FORMATS;
|
|
20
|
+
runtimeContext.HLS;
|
|
21
|
+
runtimeContext.HLS_FORMATS;
|
|
22
|
+
runtimeContext.MP4;
|
|
23
|
+
runtimeContext.MP3;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/builtins/virtualroom/virtualroom.ts
|
|
26
|
+
var virtualroom_default = defineExtension({ async resolveEntries(url) {
|
|
27
|
+
const recordId = new URL(url).searchParams.get("recordId");
|
|
28
|
+
if (!recordId) {
|
|
29
|
+
console.error("Could not extract VirtualRoom recordId.");
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const info = await fetch(`https://mv1.virtualroom.ru/vr/player/records/${recordId}/info`).then((response) => response.ok ? response.json() : null).catch(() => null);
|
|
33
|
+
const events = await fetch(`https://mv1.virtualroom.ru/vr/player/records/${recordId}/events`).then((response) => response.ok ? response.json() : null).catch(() => null);
|
|
34
|
+
const roomName = info?.data?.roomParameters?.name ?? "VirtualRoom";
|
|
35
|
+
return (events?.data?.translations ?? []).filter((translation) => !!translation.url).map((translation) => ({
|
|
36
|
+
title: [
|
|
37
|
+
roomName,
|
|
38
|
+
translation.type,
|
|
39
|
+
translation.source,
|
|
40
|
+
translation.start
|
|
41
|
+
].filter(Boolean).join(" "),
|
|
42
|
+
input: new Input({ source: new UrlSource(translation.url) })
|
|
43
|
+
}));
|
|
44
|
+
} });
|
|
45
|
+
//#endregion
|
|
46
|
+
module.exports = virtualroom_default;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
//#region src/extensions-api/main.ts
|
|
2
|
+
const runtimeContext = Azot ?? Streamyx ?? {};
|
|
3
|
+
if (runtimeContext) {
|
|
4
|
+
if (!runtimeContext.defineExtension) runtimeContext.defineExtension = (extension) => extension;
|
|
5
|
+
}
|
|
6
|
+
const defineExtension = runtimeContext.defineExtension;
|
|
7
|
+
runtimeContext.version;
|
|
8
|
+
runtimeContext.sleep;
|
|
9
|
+
runtimeContext.input;
|
|
10
|
+
runtimeContext.prompt;
|
|
11
|
+
runtimeContext.notify;
|
|
12
|
+
runtimeContext.confirm;
|
|
13
|
+
runtimeContext.ask;
|
|
14
|
+
runtimeContext.utils;
|
|
15
|
+
const Input = runtimeContext.Input;
|
|
16
|
+
const UrlSource = runtimeContext.UrlSource;
|
|
17
|
+
runtimeContext.ALL_FORMATS;
|
|
18
|
+
runtimeContext.DASH;
|
|
19
|
+
runtimeContext.DASH_FORMATS;
|
|
20
|
+
runtimeContext.HLS;
|
|
21
|
+
runtimeContext.HLS_FORMATS;
|
|
22
|
+
runtimeContext.MP4;
|
|
23
|
+
runtimeContext.MP3;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/builtins/vk/vk.ts
|
|
26
|
+
const resolutions = [
|
|
27
|
+
"2160",
|
|
28
|
+
"1440",
|
|
29
|
+
"1080",
|
|
30
|
+
"720",
|
|
31
|
+
"480",
|
|
32
|
+
"360",
|
|
33
|
+
"240",
|
|
34
|
+
"144"
|
|
35
|
+
];
|
|
36
|
+
const parseVideoIds = (url) => {
|
|
37
|
+
const match = url.match(/video-(\d+)_(\d+)/);
|
|
38
|
+
if (!match) return null;
|
|
39
|
+
return {
|
|
40
|
+
ownerId: match[1],
|
|
41
|
+
videoId: match[2]
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const findPlayerPayload = (payload) => {
|
|
45
|
+
if (!payload) return null;
|
|
46
|
+
for (const item of payload) {
|
|
47
|
+
if (!Array.isArray(item)) continue;
|
|
48
|
+
for (const nested of item) if (nested && typeof nested === "object" && "player" in nested) return nested;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
52
|
+
const selectQuality = (params, options) => {
|
|
53
|
+
const selectedQuality = options.videoQuality?.replace("p", "").trim();
|
|
54
|
+
const available = resolutions.filter((resolution) => !!params[`url${resolution}`]);
|
|
55
|
+
if (!available.length) return null;
|
|
56
|
+
if (selectedQuality && available.includes(selectedQuality)) return selectedQuality;
|
|
57
|
+
return available[0];
|
|
58
|
+
};
|
|
59
|
+
var vk_default = defineExtension({ async resolveEntries(url, options) {
|
|
60
|
+
const videoIds = parseVideoIds(url);
|
|
61
|
+
if (!videoIds) {
|
|
62
|
+
console.error("Could not extract VK video identifiers");
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
const response = await fetch("https://vkvideo.ru/al_video.php?act=show", {
|
|
66
|
+
method: "POST",
|
|
67
|
+
headers: {
|
|
68
|
+
"content-type": "application/x-www-form-urlencoded; charset=utf-8",
|
|
69
|
+
accept: "*/*",
|
|
70
|
+
"accept-language": "ru-RU,ru;q=0.9",
|
|
71
|
+
"sec-ch-ua": "\"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\", \"Not?A_Brand\";v=\"99\"",
|
|
72
|
+
"sec-ch-ua-mobile": "?0",
|
|
73
|
+
"sec-ch-ua-platform": "\"macOS\"",
|
|
74
|
+
"sec-fetch-dest": "empty",
|
|
75
|
+
"sec-fetch-mode": "cors",
|
|
76
|
+
"sec-fetch-site": "same-origin",
|
|
77
|
+
"x-requested-with": "XMLHttpRequest",
|
|
78
|
+
Referer: url,
|
|
79
|
+
"Referrer-Policy": "strict-origin-when-cross-origin"
|
|
80
|
+
},
|
|
81
|
+
body: new URLSearchParams({
|
|
82
|
+
al: "1",
|
|
83
|
+
autoplay: "1",
|
|
84
|
+
claim: "",
|
|
85
|
+
force_no_repeat: "true",
|
|
86
|
+
is_video_page: "true",
|
|
87
|
+
list: "",
|
|
88
|
+
module: "direct",
|
|
89
|
+
t: "",
|
|
90
|
+
video: `-${videoIds.ownerId}_${videoIds.videoId}`
|
|
91
|
+
}).toString()
|
|
92
|
+
});
|
|
93
|
+
if (!response.ok) throw new Error(`VK request failed: ${response.status} ${response.statusText}`);
|
|
94
|
+
const playerState = findPlayerPayload((await response.json()).payload);
|
|
95
|
+
const params = playerState?.player?.params;
|
|
96
|
+
const player = params && params.length > 0 ? params[0] : void 0;
|
|
97
|
+
if (!playerState || !player) {
|
|
98
|
+
console.error("Could not find VK player payload");
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
if (playerState.mvData?.is_active_live === 1 || playerState.mvData?.is_active_live === "1") {
|
|
102
|
+
console.error("Live videos are not supported");
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
const quality = selectQuality(player, options);
|
|
106
|
+
const mediaUrl = quality ? player[`url${quality}`] : void 0;
|
|
107
|
+
const sourceUrl = player.dash_sep || mediaUrl;
|
|
108
|
+
if (!sourceUrl) {
|
|
109
|
+
console.error("Could not find video URL");
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
return [{
|
|
113
|
+
type: "video",
|
|
114
|
+
title: [player.md_title?.trim(), player.md_author?.trim()].filter(Boolean).join(" "),
|
|
115
|
+
input: new Input({ source: new UrlSource(sourceUrl, { requestInit: { headers: {
|
|
116
|
+
Referer: url,
|
|
117
|
+
Cookie: document.cookie
|
|
118
|
+
} } }) })
|
|
119
|
+
}];
|
|
120
|
+
} });
|
|
121
|
+
//#endregion
|
|
122
|
+
module.exports = vk_default;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//#region src/extensions-api/main.ts
|
|
2
|
+
const runtimeContext = Azot ?? Streamyx ?? {};
|
|
3
|
+
if (runtimeContext) {
|
|
4
|
+
if (!runtimeContext.defineExtension) runtimeContext.defineExtension = (extension) => extension;
|
|
5
|
+
}
|
|
6
|
+
const defineExtension = runtimeContext.defineExtension;
|
|
7
|
+
runtimeContext.version;
|
|
8
|
+
runtimeContext.sleep;
|
|
9
|
+
runtimeContext.input;
|
|
10
|
+
runtimeContext.prompt;
|
|
11
|
+
runtimeContext.notify;
|
|
12
|
+
runtimeContext.confirm;
|
|
13
|
+
runtimeContext.ask;
|
|
14
|
+
const utils = runtimeContext.utils;
|
|
15
|
+
const Input = runtimeContext.Input;
|
|
16
|
+
const UrlSource = runtimeContext.UrlSource;
|
|
17
|
+
runtimeContext.ALL_FORMATS;
|
|
18
|
+
runtimeContext.DASH;
|
|
19
|
+
runtimeContext.DASH_FORMATS;
|
|
20
|
+
runtimeContext.HLS;
|
|
21
|
+
runtimeContext.HLS_FORMATS;
|
|
22
|
+
runtimeContext.MP4;
|
|
23
|
+
runtimeContext.MP3;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/builtins/weibo/weibo.ts
|
|
26
|
+
var weibo_default = defineExtension({ async resolveEntries(url) {
|
|
27
|
+
const result = utils.execUrlPatterns(url, ["/:userId(\\d+)/:bid", "/detail/:mid"], ["https://weibo.com/", "https://m.weibo.cn"]);
|
|
28
|
+
const id = result.pathname.bid || result.pathname.mid;
|
|
29
|
+
if (!id) return [];
|
|
30
|
+
const json = await fetch(`https://m.weibo.cn/statuses/show?id=${id}`, {
|
|
31
|
+
credentials: "include",
|
|
32
|
+
referrer: `https://m.weibo.cn/status/${result.pathname.bid ?? id}?jumpfrom=weibocom`,
|
|
33
|
+
method: "GET",
|
|
34
|
+
mode: "cors"
|
|
35
|
+
}).then((response) => response.json()).catch(() => null);
|
|
36
|
+
if (!json?.data) {
|
|
37
|
+
console.error("Could not resolve Weibo post metadata");
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
const results = [];
|
|
41
|
+
const pictures = json.data.pics;
|
|
42
|
+
const pageInfo = json.data.page_info;
|
|
43
|
+
if (pictures?.length) for (const video of pictures.filter((picture) => picture.type === "video" || picture.type === "livephoto")) {
|
|
44
|
+
if (!video.videoSrc) continue;
|
|
45
|
+
results.push({
|
|
46
|
+
type: "video",
|
|
47
|
+
title: video.pid,
|
|
48
|
+
input: new Input({ source: new UrlSource(video.videoSrc) })
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else if (pageInfo?.type === "video") {
|
|
52
|
+
const pageInfoUrl = Object.values(pageInfo.urls ?? {})[0];
|
|
53
|
+
const mediaInfoUrl = pageInfo.media_info?.stream_url_hd || pageInfo.media_info?.stream_url;
|
|
54
|
+
const sourceUrl = pageInfoUrl || mediaInfoUrl;
|
|
55
|
+
if (sourceUrl) results.push({
|
|
56
|
+
type: "video",
|
|
57
|
+
title: pageInfo.title || pageInfo.page_title,
|
|
58
|
+
input: new Input({ source: new UrlSource(sourceUrl) })
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return results;
|
|
62
|
+
} });
|
|
63
|
+
//#endregion
|
|
64
|
+
module.exports = weibo_default;
|