feat: update Movies4U version to 1.4 and modify catalog titles

fix: handle anti-DDoS checks in meta and posts fetching
fix: improve episode extraction logic in episodes
fix: enhance stream link extraction in stream

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Himanshu
2026-05-03 21:24:04 +05:30
parent 80e687da6b
commit 2ce3c737d1
11 changed files with 309 additions and 83 deletions
+69 -27
View File
@@ -43,10 +43,53 @@ export const getMeta = async function ({
};
try {
const response = await axios.get(url, {
let response = await axios.get(url, {
headers: { ...headers, Referer: baseUrl },
});
if (
response.data &&
response.data.includes("Please turn JavaScript on and reload the page.")
) {
const b1Match = response.data.match(/var b1=atob\(['"]([^'"]+)['"]\)/);
const a2Match = response.data.match(/_0x2aa8=\[['"]([^'"]+)['"]\]/);
const c3Match = response.data.match(/c3=toNumbers\(['"]([^'"]+)['"]\)/);
if (b1Match && a2Match && c3Match) {
const unescapeHexStr = (str: string) =>
str.replace(/\\x([0-9A-Fa-f]{2})/g, (_, hex) =>
String.fromCharCode(parseInt(hex, 16)),
);
const minJsRes = await axios.get(`${baseUrl}/min.js`, {
headers: { ...headers, Referer: baseUrl },
});
const b1Hex = atob(unescapeHexStr(b1Match[1]));
const a2Hex = atob(unescapeHexStr(a2Match[1]));
const c3Hex = unescapeHexStr(c3Match[1]);
const solver = new Function(
"c3Hex",
"a1Hex",
"b2Hex",
`
${minJsRes.data}
function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}
function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e='',f=0;f<d.length;f++)e+=(16>d[f]?'0':'')+d[f].toString(16);return e.toLowerCase()}
return toHex(slowAES.decrypt(toNumbers(c3Hex), 2, toNumbers(a1Hex), toNumbers(b2Hex)));
`,
);
const decrypted = solver(c3Hex, a2Hex, b1Hex);
const newCookie = `Antiddos-systems-DH=${decrypted}`;
response = await axios.get(url, {
headers: { ...headers, Referer: baseUrl, Cookie: newCookie },
});
}
}
const $ = cheerio.load(response.data);
const infoContainer = $(".entry-content, .post-inner").length
? $(".entry-content, .post-inner")
@@ -100,29 +143,23 @@ export const getMeta = async function ({
image = "";
result.image = image;
// --- Synopsis ---
result.synopsis =
$("h3.movie-title")
.filter((i, el) => $(el).text().includes("Storyline"))
.next("p")
.text()
.trim() ||
infoContainer.find("p").first().text().trim() ||
"";
// --- LinkList extraction ---
const links: Link[] = [];
const h4Elements = $(".download-links-div").find("> h4");
h4Elements.each((index, element) => {
// The site changed its layout. Links are now inside <p> tags following <h3> or <h4> tags with quality info.
// We can also just look for the <a> tags directly and find their preceding quality headers.
const hElements = infoContainer.find("h3, h4, p");
hElements.each((index, element) => {
const el = $(element);
const titleText = el.text().trim();
const qualityMatch = titleText.match(/\d+p\b/)?.[0];
const fullTitle = titleText;
const downloadButtons = el.next(".downloads-btns-div").find("a");
// The download buttons are usually in the next <p> tag
const downloadButtons = el.nextAll().find("a").first();
if (downloadButtons.length && qualityMatch) {
if (downloadButtons.length && qualityMatch && titleText.length < 350) {
if (result.type === "series") {
links.push({
title: fullTitle,
@@ -134,17 +171,14 @@ export const getMeta = async function ({
// Movie: collect all direct download buttons
const directLinks: Link["directLinks"] = [];
downloadButtons.each((i, btn) => {
const btnEl = $(btn);
const link = btnEl.attr("href");
if (link) {
directLinks.push({
title: btnEl.text().trim() || "Download",
link,
type: "movie", // literal type
});
}
});
const link = downloadButtons.attr("href");
if (link) {
directLinks.push({
title: downloadButtons.text().trim() || "Download",
link,
type: "movie", // literal type
});
}
if (directLinks.length) {
links.push({
@@ -158,7 +192,15 @@ export const getMeta = async function ({
}
});
result.linkList = links;
// Deduplicate links by href
const uniqueLinks = new Map<string, Link>();
links.forEach((link) => {
const href = link.episodesLink || link.directLinks?.[0]?.link;
if (href && !uniqueLinks.has(href)) {
uniqueLinks.set(href, link);
}
});
result.linkList = Array.from(uniqueLinks.values());
return result;
} catch (err) {
console.log("getMeta error:", err);