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",
});
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;
}
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]);
const decoded = await decodeHunter(encoded, mask, charCodeOffset, delimiterOffset);
const hlsUrl = decoded.match(linkRegex)[1];
console.log(hlsUrl);
}