Public
Script
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
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
import { fetch as proxiedFetch } from "https://esm.town/v/std/fetch";
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
import { convertHTMLToJSON } from "https://esm.town/v/tempguy/liteutils";
const baseURLReq = await fetch(
"https://multiembed.mov?video_id=114472&tmdb=1&s=1&e=2",
{
method: "GET",
redirect: "manual",
},
);
const baseURL = await baseURLReq.headers.get("location");
const headers = {
"accept":
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"content-type": "application/x-www-form-urlencoded",
"Referer": baseURL,
};
const baseReq = await proxiedFetch(baseURL, {
"headers": headers,
"body":
"button-click=ZEhKMVpTLVF0LVBTLVF0LVBqLVAtUUxTLVF6TmpBdEwtMC1WMy1Qakl3LVBqQTROai1WLVFOai1QLTU=&button-referer=",
"method": "POST",
});
// "button-click=ZEhKMVpTLVF0LVBTLVF0LVBqLVY0TFMtUXpOLTBjdEwtMC1WMy1Qai1WLVFOLTAtUHktUHotUDMtUERnLTU=&button-referer=",
const match = (await baseReq.text()).match(/load_sources\("([^"]+)"\)/);
if (!match) throw new Error("No match found");
const source = match[1];
const serverList = await proxiedFetch("https://streambucket.net/response.php", {
method: "POST",
body: `token=${source}`,
headers: {
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"pragma": "no-cache",
"x-requested-with": "XMLHttpRequest",
"Referer": baseURL,
"Referrer-Policy": "strict-origin-when-cross-origin",
},
});
console.log(await convertHTMLToJSON(await serverList.text()));
const embedPage = await proxiedFetch(
"https://tempguy-copperscorpion.web.val.run?destination="
+ encodeURIComponent(
`https://streambucket.net/playvideo.php?video_id=S0dpVVFEbWV3ZDBBNGI3QldBPT0=&server_id=42&token=${source}`,
),
{
"headers": headers,
"method": "GET",
},
);
export async function decodeHunter(encoded: string, mask: string, charCodeOffset: number, delimiterOffset: number) {
const delimiter = mask[delimiterOffset];
const chunks = encoded.split(delimiter).filter((chunk) => chunk);
const decoded = chunks
.map((chunk) => {
const charCode = chunk.split("").reduceRight((c, value, index) => {
return c + mask.indexOf(value) * delimiterOffset ** (chunk.length - 1 - index);
}, 0);
return String.fromCharCode(charCode - charCodeOffset);
})
.join("");
return decoded;
}
// <iframe[^>]*class="source-frame show"[^>]*src="([^"]+)"
const url = (await embedPage.text()).match(/<iframe[^>]*class="source-frame show"[^>]*src="([^"]+)"/);
if (!match) throw new Error("No match found");
console.log(url);
const player = await fetch(url[1]);
const regex = /eval\(function\(h,u,n,t,e,r\).*?\("(.*?)",\d*?,"(.*?)",(\d*?),(\d*?),\d*?\)\)/;
const linkRegex = /file:"(.*?)"/;
const hunter_match = (await player.text()).match(regex);
if (hunter_match) {
const encoded = hunter_match[1];
const mask = hunter_match[2];
const charCodeOffset = Number(hunter_match[3]);
const delimiterOffset = Number(hunter_match[4]);
// console.log(hunter_match);
const decoded = await decodeHunter(encoded, mask, charCodeOffset, delimiterOffset);
const hlsUrl = decoded.match(linkRegex)[1];
console.log(hlsUrl);
}
August 8, 2024