update
This commit is contained in:
+215
-43
@@ -63,10 +63,19 @@ Content-Disposition: form-data; name="page"
|
||||
|
||||
async function extractDetails(url) {
|
||||
try {
|
||||
const response = await fetchv2(url);
|
||||
const headers = {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
|
||||
"Referer": "https://anihq.to/"
|
||||
};
|
||||
const response = await fetchv2(url, headers);
|
||||
const html = await response.text();
|
||||
|
||||
const descMatch = html.match(/<div\s+data-synopsis[^>]*>([\s\S]*?)<\/div>/);
|
||||
let descMatch = html.match(/<div\s+class=["']anime-synopsis["']>[\s\S]*?<div[^>]+class=["']prose[^"']*["'][^>]*>([\s\S]*?)<\/div>/i);
|
||||
|
||||
if (!descMatch) {
|
||||
descMatch = html.match(/<section[^>]+aria-label=["']Anime Overview["'][^>]*>([\s\S]*?)<\/section>/i);
|
||||
}
|
||||
|
||||
let description = "N/A";
|
||||
|
||||
if (descMatch) {
|
||||
@@ -84,7 +93,7 @@ async function extractDetails(url) {
|
||||
}]);
|
||||
} catch (err) {
|
||||
return JSON.stringify([{
|
||||
description: "Error",
|
||||
description: "Error: " + err.message,
|
||||
aliases: "Error",
|
||||
airdate: "Error"
|
||||
}]);
|
||||
@@ -139,46 +148,209 @@ async function extractEpisodes(url) {
|
||||
|
||||
async function extractStreamUrl(url) {
|
||||
try {
|
||||
const response = await fetchv2(url);
|
||||
const html = await response.text();
|
||||
|
||||
const iframeMatch = html.match(/<iframe[^>]+src=['"]https:\/\/([^'"]+\.playerp2p\.com)\/#([^'"]+)['"]/);
|
||||
|
||||
if (!iframeMatch) {
|
||||
console.log("No iframe ID found");
|
||||
return "https://error.org/";
|
||||
}
|
||||
|
||||
const domain = iframeMatch[1];
|
||||
const videoId = iframeMatch[2];
|
||||
|
||||
const apiUrl = `https://${domain}/api/v1/video?id=${videoId}&w=1792&h=1120&r=anihq.to`;
|
||||
const apiResponse = await fetchv2(apiUrl);
|
||||
const encodedString = await apiResponse.text();
|
||||
|
||||
const hasUppercase = /[A-Z]/.test(encodedString);
|
||||
|
||||
let stringToSend;
|
||||
if (hasUppercase) {
|
||||
stringToSend = atob(encodedString);
|
||||
console.log("Decoded string: " + stringToSend);
|
||||
} else {
|
||||
stringToSend = encodedString;
|
||||
console.log("Using encoded string directly (no uppercase found)");
|
||||
}
|
||||
|
||||
const postData = {
|
||||
text: stringToSend
|
||||
const headers = {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
|
||||
"Referer": "https://anihq.to/"
|
||||
};
|
||||
const headers = { "Content-Type": "application/json" };
|
||||
const response2 = await fetchv2("https://enc-dec.app/api/dec-vidstack", headers, "POST", postData);
|
||||
const data = await response2.json();
|
||||
console.log(JSON.stringify(data));
|
||||
console.log("Final URL: " + data.result.source);
|
||||
return data.result.cf;
|
||||
const response = await fetchv2(url, headers);
|
||||
const html = await response.text();
|
||||
|
||||
const iframeMatch = html.match(/<iframe[^>]+src=['"]([^'"]+)['"]/i);
|
||||
if (!iframeMatch) {
|
||||
console.log("No iframe found on page");
|
||||
return null;
|
||||
}
|
||||
|
||||
const iframeUrl = iframeMatch[1];
|
||||
console.log("Found iframe URL:", iframeUrl);
|
||||
|
||||
const iframeResponse = await fetchv2(iframeUrl, headers);
|
||||
const iframeHtml = await iframeResponse.text();
|
||||
|
||||
let streamData = null;
|
||||
try {
|
||||
streamData = voeExtractor(iframeHtml);
|
||||
} catch (error) {
|
||||
console.log("VOE extraction error:", error.message || error);
|
||||
return null;
|
||||
}
|
||||
|
||||
const streamUrlResult = typeof streamData === "string" ? streamData : getStreamUrl(streamData);
|
||||
|
||||
} catch (err) {
|
||||
console.log("Error: " + err.message);
|
||||
return "https://error.org/";
|
||||
if (streamUrlResult) {
|
||||
const origin = "https://bryantenunder.com";
|
||||
console.log("Stream URL secured:", streamUrlResult);
|
||||
|
||||
return JSON.stringify({
|
||||
streams: [
|
||||
{
|
||||
title: "Server 1",
|
||||
streamUrl: streamUrlResult,
|
||||
headers: {
|
||||
"Origin": origin,
|
||||
"Referer": origin + "/"
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
console.log("No stream URL found");
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.log("Fetch error:", error.message || error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* SCHEME START */
|
||||
|
||||
/**
|
||||
* @name voeExtractor
|
||||
* @author Cufiy
|
||||
*/
|
||||
|
||||
function voeExtractor(html, url = null) {
|
||||
const regex = /<script[^>]+type=["']application\/json["'][^>]*>([\s\S]*?)<\/script>/gi;
|
||||
let match;
|
||||
let obfuscatedString = null;
|
||||
while ((match = regex.exec(html)) !== null) {
|
||||
try {
|
||||
const data = JSON.parse(match[1].trim());
|
||||
if (Array.isArray(data) && typeof data[0] === "string") {
|
||||
obfuscatedString = data[0];
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore syntax/parse errors for other script tags
|
||||
}
|
||||
}
|
||||
|
||||
if (!obfuscatedString) {
|
||||
console.log("No valid VOE application/json script tag found");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Step 1: ROT13
|
||||
let step1 = voeRot13(obfuscatedString);
|
||||
|
||||
// Step 2: Remove patterns
|
||||
let step2 = voeRemovePatterns(step1);
|
||||
|
||||
// Step 3: Base64 decode
|
||||
let step3 = voeBase64Decode(step2);
|
||||
|
||||
// Step 4: Subtract 3 from each char code
|
||||
let step4 = voeShiftChars(step3, 3);
|
||||
|
||||
// Step 5: Reverse string
|
||||
let step5 = step4.split("").reverse().join("");
|
||||
|
||||
// Step 6: Base64 decode again
|
||||
let step6 = voeBase64Decode(step5);
|
||||
|
||||
// Step 7: Parse as JSON
|
||||
let result;
|
||||
try {
|
||||
result = JSON.parse(step6);
|
||||
} catch (e) {
|
||||
throw new Error("Final JSON parse error: " + e.message);
|
||||
}
|
||||
|
||||
// check if direct_access_url is set, not null and starts with http
|
||||
const streamUrl = getStreamUrl(result);
|
||||
if (streamUrl) {
|
||||
console.log("Voe Stream URL: " + streamUrl);
|
||||
return streamUrl;
|
||||
} else {
|
||||
console.log("No stream URL found in the decoded JSON");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function voeRot13(str) {
|
||||
return str.replace(/[a-zA-Z]/g, function (c) {
|
||||
return String.fromCharCode(
|
||||
(c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13)
|
||||
? c
|
||||
: c - 26
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function voeRemovePatterns(str) {
|
||||
const patterns = ["@$", "^^", "~@", "%?", "*~", "!!", "#&"];
|
||||
let result = str;
|
||||
for (const pat of patterns) {
|
||||
result = result.split(pat).join("");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function voeBase64Decode(str) {
|
||||
if (typeof atob === "function") {
|
||||
try {
|
||||
return atob(str);
|
||||
} catch (e) {
|
||||
// fallback if atob fails
|
||||
}
|
||||
}
|
||||
|
||||
// Pure Javascript Base64 decoding fallback to avoid reliance on Buffer or atob
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
let cleaned = str.replace(/=+$/, '').replace(/[^A-Za-z0-9+/]/g, '');
|
||||
let output = '';
|
||||
let buffer = 0;
|
||||
let bits = 0;
|
||||
|
||||
for (let i = 0; i < cleaned.length; i++) {
|
||||
const char = cleaned[i];
|
||||
const idx = chars.indexOf(char);
|
||||
if (idx === -1) continue;
|
||||
|
||||
buffer = (buffer << 6) | idx;
|
||||
bits += 6;
|
||||
|
||||
if (bits >= 8) {
|
||||
bits -= 8;
|
||||
const byte = (buffer >> bits) & 0xFF;
|
||||
output += String.fromCharCode(byte);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return decodeURIComponent(escape(output));
|
||||
} catch (e) {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
function voeShiftChars(str, shift) {
|
||||
return str
|
||||
.split("")
|
||||
.map((c) => String.fromCharCode(c.charCodeAt(0) - shift))
|
||||
.join("");
|
||||
}
|
||||
|
||||
function getStreamUrl(result) {
|
||||
if (!result) return null;
|
||||
if (typeof result === "string" && result.startsWith("http")) {
|
||||
return result;
|
||||
}
|
||||
if (typeof result === "object") {
|
||||
if (typeof result.source === "string" && result.source.startsWith("http")) {
|
||||
return result.source;
|
||||
}
|
||||
if (typeof result.direct_access_url === "string" && result.direct_access_url.startsWith("http")) {
|
||||
return result.direct_access_url;
|
||||
}
|
||||
if (Array.isArray(result.source)) {
|
||||
const url = result.source
|
||||
.map((source) => typeof source === "string" ? source : (source.direct_access_url || source.file || source.url))
|
||||
.find((url) => url && url.startsWith("http"));
|
||||
if (url) return url;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/* SCHEME END */
|
||||
Reference in New Issue
Block a user