mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-21 21:26:19 +01:00
Update faselhd/faselhd.js
This commit is contained in:
parent
d2292ca5bc
commit
e2fdfbcc53
1 changed files with 92 additions and 20 deletions
|
|
@ -132,29 +132,101 @@ async function extractStreamUrl(url) {
|
||||||
|
|
||||||
const regex = /<li\s+class="active"\s+onclick="player_iframe\.location\.href\s*=\s*'([^']+)'"/i;
|
const regex = /<li\s+class="active"\s+onclick="player_iframe\.location\.href\s*=\s*'([^']+)'"/i;
|
||||||
const match = regex.exec(html);
|
const match = regex.exec(html);
|
||||||
|
if (!match || !match[1]) return "";
|
||||||
|
const primaryUrl = match[1].trim();
|
||||||
|
|
||||||
if (!match || !match[1]) {
|
const response2 = await fetchv2(primaryUrl);
|
||||||
console.log("No stream URL found in page");
|
const html2 = await response2.text();
|
||||||
|
|
||||||
|
const scriptRegex = /<script[^>]*>\s*(\(function\([\s\S]*?)\s*<\/script>/i;
|
||||||
|
const scriptMatch = html2.match(scriptRegex);
|
||||||
|
if (scriptMatch && scriptMatch[1]) {
|
||||||
|
const postData = {
|
||||||
|
code: scriptMatch[1].trim(),
|
||||||
|
options: {
|
||||||
|
jsx: true,
|
||||||
|
unpack: true,
|
||||||
|
unminify: true,
|
||||||
|
deobfuscate: true,
|
||||||
|
mangle: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const decryptResp = await fetchv2("https://webcrack-fdpm.vercel.app/api/decrypt", { "Content-Type": "application/json" }, "POST", postData);
|
||||||
|
const result = await decryptResp.json();
|
||||||
|
const deobfuscatedCode = result.code;
|
||||||
|
|
||||||
|
const extracted = (function(code) {
|
||||||
|
let m = code.match(/sources:\s*\[\{\s*file:\s*"([^"]+\.m3u8)"/);
|
||||||
|
if (m) return m[1];
|
||||||
|
m = code.match(/data-url="([^"]+\.m3u8)"/);
|
||||||
|
if (m) return m[1];
|
||||||
|
m = code.match(/file:\s*"([^"]+\.m3u8)"/);
|
||||||
|
if (m) return m[1];
|
||||||
|
return null;
|
||||||
|
})(deobfuscatedCode);
|
||||||
|
|
||||||
|
if (extracted) {
|
||||||
|
const final = await a(extracted);
|
||||||
|
return final || "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const netRes = await networkFetch(primaryUrl, { timeoutSeconds: 2, returnHTML: true });
|
||||||
|
const netHtml = netRes.html || "";
|
||||||
|
|
||||||
|
const fm = netHtml.match(/data-url="([^"]+\.m3u8)"/)
|
||||||
|
|| netHtml.match(/sources:\s*\[\{\s*file:\s*"([^"]+\.m3u8)"/)
|
||||||
|
|| netHtml.match(/file:\s*"([^"]+\.m3u8)"/);
|
||||||
|
|
||||||
|
const found = fm ? fm[1] : "";
|
||||||
|
const final = found ? await a(found) : "";
|
||||||
|
return final || "";
|
||||||
|
} catch {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
const streamUrl = match[1].trim();
|
} catch {
|
||||||
|
|
||||||
console.log(streamUrl);
|
|
||||||
|
|
||||||
const response2 = await networkFetch(streamUrl, {
|
|
||||||
timeoutSeconds: 2,
|
|
||||||
returnHTML: true
|
|
||||||
});
|
|
||||||
const html2 = response2.html;
|
|
||||||
|
|
||||||
const match2 = html2.match(/data-url="([^"]+\.m3u8)"/);
|
|
||||||
if (match2) {
|
|
||||||
return match2[1];
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log("Error fetching stream URL content:"+ err);
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function a(streamUrl) {
|
||||||
|
try {
|
||||||
|
const looksLikeMaster = /master\.m3u8|\/stream\/v2\//i.test(streamUrl);
|
||||||
|
if (!looksLikeMaster) return streamUrl;
|
||||||
|
|
||||||
|
const res = await fetchv2(streamUrl);
|
||||||
|
const txt = await res.text();
|
||||||
|
|
||||||
|
const lines = txt.split(/\r?\n/);
|
||||||
|
const variants = [];
|
||||||
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
const line = lines[i].trim();
|
||||||
|
if (line.startsWith('#EXT-X-STREAM-INF:')) {
|
||||||
|
const info = line;
|
||||||
|
const urlLine = (lines[i+1] || "").trim();
|
||||||
|
if (!urlLine || urlLine.startsWith('#')) continue;
|
||||||
|
|
||||||
|
const resMatch = info.match(/RESOLUTION=(\d+)x(\d+)/i);
|
||||||
|
const bwMatch = info.match(/BANDWIDTH=(\d+)/i);
|
||||||
|
const labelMatch = info.match(/NAME="([^"]+)"/i);
|
||||||
|
|
||||||
|
const width = resMatch ? parseInt(resMatch[1], 10) : 0;
|
||||||
|
const height = resMatch ? parseInt(resMatch[2], 10) : 0;
|
||||||
|
const bw = bwMatch ? parseInt(bwMatch[1], 10) : 0;
|
||||||
|
|
||||||
|
variants.push({ url: urlLine, width, height, bw, label: labelMatch ? labelMatch[1] : "" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (variants.length === 0) return streamUrl;
|
||||||
|
|
||||||
|
const prefer1080 = variants.find(v => v.height >= 1000 || /1080/i.test(v.url) || /1080/i.test(v.label));
|
||||||
|
if (prefer1080) return prefer1080.url;
|
||||||
|
|
||||||
|
variants.sort((a,b) => b.bw - a.bw);
|
||||||
|
return variants[0].url || streamUrl;
|
||||||
|
} catch {
|
||||||
|
return streamUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue