This commit is contained in:
himanshu8443
2025-07-11 19:45:14 +05:30
parent 13f71510d5
commit 35f1e57a0b
139 changed files with 10578 additions and 139 deletions

199
dist/world4u/stream.js vendored
View File

@@ -1 +1,198 @@
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,a,o){return new(a||(a=Promise))(function(r,n){function i(e){try{s(o.next(e))}catch(e){n(e)}}function d(e){try{s(o.throw(e))}catch(e){n(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof a?t:new a(function(e){e(t)})).then(i,d)}s((o=o.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStream=void 0;const getStream=function(e){return __awaiter(this,arguments,void 0,function*({link:e,type:t,providerContext:a}){var o;const{axios:r,cheerio:n}=a,i={"sec-ch-ua":'"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"Sec-Fetch-Site":"none","Sec-Fetch-User":"?1","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0"};try{if("movie"===t){const t=(yield r.get(e,{headers:i})).data;e=n.load(t)('strong:contains("INSTANT")').parent().attr("href")||e}if(e.includes("fastilinks")){const t=(yield r.get(e,{headers:i})).data,a=n.load(t)('input[name="_csrf_token_645a83a41868941e4692aa31e7235f2"]').attr("value"),o=new FormData;o.append("_csrf_token_645a83a41868941e4692aa31e7235f2",a||"");const d=yield fetch(e,{method:"POST",headers:i,body:o}),s=yield d.text(),c=n.load(s);e=c('a:contains("mediafire")').attr("href")||c('a:contains("photolinx")').attr("href")||e}if(e.includes("photolinx")){const t=(yield r.get(e,{headers:i})).data,a=n.load(t),o=a("#generate_url").attr("data-token"),d={type:"DOWNLOAD_GENERATE",payload:{access_token:o,uid:a("#generate_url").attr("data-uid")}},s=yield fetch("https://photolinx.shop/action",{headers:{"sec-fetch-site":"same-origin","x-requested-with":"xmlhttprequest",cookie:"PHPSESSID=9a8d855c700cf0711831c04960c2e2b4",Referer:"https://photolinx.shop/download/5mPkrBD0D2x","Referrer-Policy":"strict-origin-when-cross-origin"},body:JSON.stringify(d),method:"POST"}),c=yield s.json(),l=null==c?void 0:c.download_url;if(l){return[{server:"Photolinx",link:l,type:"mkv"}]}}const a=(yield r.get(e,{headers:i})).data,d=[];let s={download:""};try{const t=(null===(o=a.match(/formData\.append\('key',\s*'(\d+)'\);/))||void 0===o?void 0:o[1])||"",r=new FormData;r.append("key",t);const n=yield fetch(e,{method:"POST",headers:i,body:r});s=yield n.json()}catch(e){}let c=n.load(a);const l=c('h1:contains("Download")').find("a").attr("href")||c(".input.popsok").attr("href");if(l){const t=(yield r.head(l)).headers["content-type"];if(t&&t.includes("video"))return d.push({server:"Mediafire",link:l,type:"mkv"}),d;{const t=(yield r.get(l,{headers:{Referer:e}})).data,a=/window\.location\.href\s*=\s*['"]([^'"]+)['"]/,o=t.match(a);let n=o?o[1]:null;return n&&d.push({server:"Mediafire",link:n,type:"mkv"}),d}}const h=(yield r.head(s.download)).headers["content-type"];if(h&&h.includes("video"))return d.push({server:"Mediafire",link:s.download,type:"mkv"}),d;{const t=(yield r.get(s.download,{headers:{Referer:e}})).data,a=n.load(t)("#continue-btn").attr("href"),o=yield r.get("https://www.mediafire.com"+a),i=n.load(o.data)(".input.popsok").attr("href");i&&d.push({server:"Mediafire",link:i,type:"mkv"})}return d}catch(e){return[]}})};exports.getStream=getStream;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStream = void 0;
const getStream = function (_a) {
return __awaiter(this, arguments, void 0, function* ({ link: url, type, providerContext, }) {
var _b;
const { axios, cheerio } = providerContext;
const headers = {
"sec-ch-ua": '"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0",
};
try {
if (type === "movie") {
const linkRes = yield axios.get(url, { headers });
const linkData = linkRes.data;
const $ = cheerio.load(linkData);
url = $('strong:contains("INSTANT")').parent().attr("href") || url;
}
// fastilinks
if (url.includes("fastilinks")) {
const fastilinksRes = yield axios.get(url, { headers });
const fastilinksData = fastilinksRes.data;
const $$ = cheerio.load(fastilinksData);
const fastilinksKey = $$('input[name="_csrf_token_645a83a41868941e4692aa31e7235f2"]').attr("value");
console.log("fastilinksKey", fastilinksKey);
const fastilinksFormData = new FormData();
fastilinksFormData.append("_csrf_token_645a83a41868941e4692aa31e7235f2", fastilinksKey || "");
const fastilinksRes2 = yield fetch(url, {
method: "POST",
headers: headers,
body: fastilinksFormData,
});
const fastilinksHtml = yield fastilinksRes2.text();
// console.log('fastilinksHtml', fastilinksHtml);
const $$$ = cheerio.load(fastilinksHtml);
const fastilinksLink = $$$('a:contains("mediafire")').attr("href") ||
$$$('a:contains("photolinx")').attr("href");
console.log("fastilinksLink", fastilinksLink);
url = fastilinksLink || url;
}
console.log("world4uGetStream", type, url);
if (url.includes("photolinx")) {
console.log("photolinx", url);
// const photolinxBaseUrl = url.split('/').slice(0, 3).join('/');
const photolinxRes = yield axios.get(url, { headers });
const photolinxData = photolinxRes.data;
const $$$ = cheerio.load(photolinxData);
const access_token = $$$("#generate_url").attr("data-token");
const uid = $$$("#generate_url").attr("data-uid");
const body = {
type: "DOWNLOAD_GENERATE",
payload: {
access_token,
uid,
},
};
console.log("photolinxData", JSON.stringify(body));
const photolinxRes2 = yield fetch("https://photolinx.shop/action", {
headers: {
"sec-fetch-site": "same-origin",
"x-requested-with": "xmlhttprequest",
cookie: "PHPSESSID=9a8d855c700cf0711831c04960c2e2b4",
Referer: "https://photolinx.shop/download/5mPkrBD0D2x",
"Referrer-Policy": "strict-origin-when-cross-origin",
},
body: JSON.stringify(body),
method: "POST",
});
const photolinxData2 = yield photolinxRes2.json();
console.log("photolinxData2", photolinxData2);
const dwUrl = photolinxData2 === null || photolinxData2 === void 0 ? void 0 : photolinxData2.download_url;
if (dwUrl) {
const streamLinks = [
{
server: "Photolinx",
link: dwUrl,
type: "mkv",
},
];
return streamLinks;
}
}
const res = yield axios.get(url, { headers });
const html = res.data;
const streamLinks = [];
let data = { download: "" };
try {
const key = ((_b = html.match(/formData\.append\('key',\s*'(\d+)'\);/)) === null || _b === void 0 ? void 0 : _b[1]) || "";
console.log("key", key);
const formData = new FormData();
formData.append("key", key);
const streamRes = yield fetch(url, {
method: "POST",
headers: headers,
body: formData,
});
data = yield streamRes.json();
}
catch (err) {
console.log("error in world4uGetStream", err);
}
// console.log('streamRes', streamRes);
let $ = cheerio.load(html);
// console.log('data', html);
const mediafireUrl = $('h1:contains("Download")').find("a").attr("href") ||
$(".input.popsok").attr("href");
console.log("mediafireUrl", mediafireUrl);
if (mediafireUrl) {
const directUrl = yield axios.head(mediafireUrl);
const urlContentType = directUrl.headers["content-type"];
console.log("mfcontentType", urlContentType);
if (urlContentType && urlContentType.includes("video")) {
streamLinks.push({
server: "Mediafire",
link: mediafireUrl,
type: "mkv",
});
return streamLinks;
}
else {
const repairRes = yield axios.get(mediafireUrl, {
headers: {
Referer: url,
},
});
const repairHtml = repairRes.data;
// Regex to match the window.location.href assignment in the script content
const hrefRegex = /window\.location\.href\s*=\s*['"]([^'"]+)['"]/;
const match = repairHtml.match(hrefRegex);
// If a match is found, return the URL; otherwise return null
let downloadLInk = match ? match[1] : null;
console.log("downloadLInk", downloadLInk);
if (downloadLInk) {
streamLinks.push({
server: "Mediafire",
link: downloadLInk,
type: "mkv",
});
}
return streamLinks;
}
}
const requireRepairRes = yield axios.head(data.download);
const contentType = requireRepairRes.headers["content-type"];
console.log("contentType", contentType);
if (contentType && contentType.includes("video")) {
streamLinks.push({
server: "Mediafire",
link: data.download,
type: "mkv",
});
return streamLinks;
}
else {
const repairRes = yield axios.get(data.download, {
headers: {
Referer: url,
},
});
const repairHtml = repairRes.data;
const $ = cheerio.load(repairHtml);
const repairLink = $("#continue-btn").attr("href");
console.log("repairLink", "https://www.mediafire.com" + repairLink);
const repairRequireRepairRes = yield axios.get("https://www.mediafire.com" + repairLink);
const $$ = cheerio.load(repairRequireRepairRes.data);
const repairDownloadLink = $$(".input.popsok").attr("href");
console.log("repairDownloadLink", repairDownloadLink);
if (repairDownloadLink) {
streamLinks.push({
server: "Mediafire",
link: repairDownloadLink,
type: "mkv",
});
}
}
return streamLinks;
}
catch (err) {
console.log(err);
return [];
}
});
};
exports.getStream = getStream;