1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { fetch as proxiedFetch } from "https://esm.town/v/std/fetch";
import { customAlphabet } from "npm:nanoid";
const nanoid = customAlphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 10);
const baseUrl = "https://d000d.com";
import { blob } from "https://esm.town/v/std/blob";
export async function doodstream(ctx: Context) {
let url = ctx.url;
const id = url.split("/e/")[1];
const doodDataReq = await fetch(
`https://cool-proxy.koyeb.app/hdiuhmalkmc9d0ck7UCFVGBJHN?destination=`
+ encodeURIComponent(`${url}`),
{
method: "GET",
},
);
const doodData = await doodDataReq.text();
const dataForLater = doodData.match(/\?token=([^&]+)&expiry=/)?.[1];
const path = doodData.match(/\$\.get\('\/pass_md5([^']+)/)?.[1];
const thumbnailTrack = doodData.match(/thumbnails:\s\{\s*vtt:\s'([^']*)'/);
const doodPageReq = await fetch(
`https://cool-proxy.koyeb.app/hdiuhmalkmc9d0ck7UCFVGBJHN?destination=`
+ encodeURIComponent(`${baseUrl}/pass_md5${path}`),
{
headers: {
Referer: `${baseUrl}/e/${id}`,
},
method: "GET",
},
);
const doodPage = await doodPageReq.text();
const downloadURL = `${doodPage}${nanoid()}?token=${dataForLater}&expiry=${Date.now()}`;
if (!downloadURL.startsWith("http")) throw new Error("Invalid URL");
return {
stream: [
{
id: "primary",
type: "file",
flags: [],
captions: [],
qualities: {
unknown: {
type: "mp4",
url: downloadURL,
},
},
headers: {
Referer: baseUrl,
},
...(thumbnailTrack
? {
thumbnailTrack: {
type: "vtt",
url: `https:${thumbnailTrack[1]}`,
},
}
: {}),
},
],
};
}
function unpack(p, a, c, k) {
while (c--) if (k[c]) p = p.replace(new RegExp("\\b" + c.toString(a) + "\\b", "g"), k[c]);
return p;
}
function mat(r, l) {
return r.exec(l);
}
export async function streamwish(ctx) {
const _embed = await fetch(ctx.url);
const embed = await _embed.text();
console.log(embed);
const pr = /p}\('(.*?)',(\d+),(\d+),'(.*?)'\.split/gm;
const ps = /sources:\[{file:\"(.*?)\"/gm;
const p = pr.exec(embed);
if (!p) {
throw new Error("Pattern not matched in embed");
}
const unpackedCode = unpack(String(p[1]), Number(p[2]), Number(p[3]), String(p[4]).split("|"));
console.log(unpackedCode);
const match = mat(ps, unpackedCode);
if (!match) {
throw new Error("No match found");
}
const url = match[1];
return {
stream: [
{
id: "primary",
type: "file",
flags: [],
captions: [],
qualities: {
unknown: {
type: "m3u8",
url,
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
August 3, 2024