diff --git a/dist/world4u/stream.js b/dist/world4u/stream.js index 18e52d5..2e9fa83 100644 --- a/dist/world4u/stream.js +++ b/dist/world4u/stream.js @@ -1 +1 @@ -"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){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){var value;result.done?resolve(result.value):(value=result.value,value instanceof P?value:new P(function(resolve){resolve(value)})).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStream=void 0;const getStream=function(_a){return __awaiter(this,arguments,void 0,function*({link:url,type:type,providerContext:providerContext}){var _b;const{axios:axios,cheerio:cheerio}=providerContext,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("movie"===type){const linkData=(yield axios.get(url,{headers:headers})).data;url=cheerio.load(linkData)('strong:contains("INSTANT")').parent().attr("href")||url}if(url.includes("fastilinks")){const fastilinksData=(yield axios.get(url,{headers:headers})).data,fastilinksKey=cheerio.load(fastilinksData)('input[name="_csrf_token_645a83a41868941e4692aa31e7235f2"]').attr("value"),fastilinksFormData=new FormData;fastilinksFormData.append("_csrf_token_645a83a41868941e4692aa31e7235f2",fastilinksKey||"");const fastilinksRes2=yield fetch(url,{method:"POST",headers:headers,body:fastilinksFormData}),fastilinksHtml=yield fastilinksRes2.text(),$$$=cheerio.load(fastilinksHtml);url=$$$('a:contains("mediafire")').attr("href")||$$$('a:contains("photolinx")').attr("href")||url}if(url.includes("photolinx")){const photolinxData=(yield axios.get(url,{headers:headers})).data,$$$=cheerio.load(photolinxData),access_token=$$$("#generate_url").attr("data-token"),body={type:"DOWNLOAD_GENERATE",payload:{access_token:access_token,uid:$$$("#generate_url").attr("data-uid")}},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"}),photolinxData2=yield photolinxRes2.json(),dwUrl=null==photolinxData2?void 0:photolinxData2.download_url;if(dwUrl){return[{server:"Photolinx",link:dwUrl,type:"mkv"}]}}const html=(yield axios.get(url,{headers:headers})).data,streamLinks=[];let data={download:""};try{const key=(null===(_b=html.match(/formData\.append\('key',\s*'(\d+)'\);/))||void 0===_b?void 0:_b[1])||"",formData=new FormData;formData.append("key",key);const streamRes=yield fetch(url,{method:"POST",headers:headers,body:formData});data=yield streamRes.json()}catch(err){}let $=cheerio.load(html);const mediafireUrl=$('h1:contains("Download")').find("a").attr("href")||$(".input.popsok").attr("href");if(mediafireUrl){const urlContentType=(yield axios.head(mediafireUrl)).headers["content-type"];if(urlContentType&&urlContentType.includes("video"))return streamLinks.push({server:"Mediafire",link:mediafireUrl,type:"mkv"}),streamLinks;{const repairHtml=(yield axios.get(mediafireUrl,{headers:{Referer:url}})).data,hrefRegex=/window\.location\.href\s*=\s*['"]([^'"]+)['"]/,match=repairHtml.match(hrefRegex);let downloadLInk=match?match[1]:null;return downloadLInk&&streamLinks.push({server:"Mediafire",link:downloadLInk,type:"mkv"}),streamLinks}}const contentType=(yield axios.head(data.download)).headers["content-type"];if(contentType&&contentType.includes("video"))return streamLinks.push({server:"Mediafire",link:data.download,type:"mkv"}),streamLinks;{const repairHtml=(yield axios.get(data.download,{headers:{Referer:url}})).data,repairLink=cheerio.load(repairHtml)("#continue-btn").attr("href"),repairRequireRepairRes=yield axios.get("https://www.mediafire.com"+repairLink),repairDownloadLink=cheerio.load(repairRequireRepairRes.data)(".input.popsok").attr("href");repairDownloadLink&&streamLinks.push({server:"Mediafire",link:repairDownloadLink,type:"mkv"})}return streamLinks}catch(err){return[]}})};exports.getStream=getStream; \ No newline at end of file +"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){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){var value;result.done?resolve(result.value):(value=result.value,value instanceof P?value:new P(function(resolve){resolve(value)})).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStream=void 0;const getStream=function(_a){return __awaiter(this,arguments,void 0,function*({link:url,type:type,providerContext:providerContext}){var _b;const{axios:axios,cheerio:cheerio}=providerContext,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",Cookie:"61cn=1; 61wk=1; __cf_bm=wtv9Eoa2wrUDgevtAnJ6wUOZrxtVYBcddhUDtT0Wj_M-1757137848-1.0.1.1-8Tr7rV19zNgUcRYe_5567LKb2IZrKyxwrc1VWgTmMDd06Givhil3U2kMtUYTYkTnuD3sHUgfh8CO9Y5LrEcZACBbrPE.3Sq5F_JLXaK7Hrw; conv_tracking_data-2=%7B%22mf_source%22%3A%22regular_download-59%22%2C%22mf_content%22%3A%22Free%22%2C%22mf_medium%22%3A%22unknown%5C%2FDefault%20Browser%22%2C%22mf_campaign%22%3A%22616qpccbrq0y4oe%22%2C%22mf_term%22%3A%22d11b8f533377139aa38d757e5057630e%22%7D; ukey=pu2dyp35fyongstav3km969l8d6u2z82"};try{if("movie"===type){const linkData=(yield axios.get(url,{headers:headers})).data;url=cheerio.load(linkData)('strong:contains("INSTANT")').parent().attr("href")||url}if(url.includes("fastilinks")){const fastilinksData=(yield axios.get(url,{headers:headers})).data,fastilinksKey=cheerio.load(fastilinksData)('input[name="_csrf_token_645a83a41868941e4692aa31e7235f2"]').attr("value"),fastilinksFormData=new FormData;fastilinksFormData.append("_csrf_token_645a83a41868941e4692aa31e7235f2",fastilinksKey||"");const fastilinksRes2=yield fetch(url,{method:"POST",headers:headers,body:fastilinksFormData}),fastilinksHtml=yield fastilinksRes2.text(),$$$=cheerio.load(fastilinksHtml);url=$$$('a:contains("mediafire")').attr("href")||$$$('a:contains("photolinx")').attr("href")||url}if(url.includes("photolinx")){const photolinxData=(yield axios.get(url,{headers:headers})).data,$$$=cheerio.load(photolinxData),access_token=$$$("#generate_url").attr("data-token"),body={type:"DOWNLOAD_GENERATE",payload:{access_token:access_token,uid:$$$("#generate_url").attr("data-uid")}},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"}),photolinxData2=yield photolinxRes2.json(),dwUrl=null==photolinxData2?void 0:photolinxData2.download_url;if(dwUrl){return[{server:"Photolinx",link:dwUrl,type:"mkv"}]}}const html=(yield axios.get(url,{headers:headers})).data,streamLinks=[];let data={download:""};try{const key=(null===(_b=html.match(/formData\.append\('key',\s*'(\d+)'\);/))||void 0===_b?void 0:_b[1])||"",formData=new FormData;formData.append("key",key);const streamRes=yield fetch(url,{method:"POST",headers:headers,body:formData});data=yield streamRes.json()}catch(err){}let $=cheerio.load(html);const mediafireUrl=$('h1:contains("Download")').find("a").attr("href")||$(".input.popsok").attr("href");if(mediafireUrl){const urlContentType=(yield fetch(mediafireUrl,{headers:{Referer:url}})).headers.get("content-type");if(urlContentType&&urlContentType.includes("video"))return streamLinks.push({server:"Mediafire",link:mediafireUrl,type:"mkv"}),streamLinks;{const repairRes=yield fetch(mediafireUrl,{headers:{Referer:url}}),repairHtml=yield repairRes.text(),base64Link=cheerio.load(repairHtml)(".input.popsok").attr("data-scrambled-url"),href=base64Link?atob(base64Link):null;let downloadLInk=(null==href?void 0:href.startsWith("https://"))?href:null;return downloadLInk&&streamLinks.push({server:"Mediafire",link:downloadLInk,type:"mkv"}),streamLinks}}const contentType=(yield fetch(data.download)).headers.get("content-type");if(contentType&&contentType.includes("video"))return streamLinks.push({server:"Mediafire",link:data.download,type:"mkv"}),streamLinks;{const repairRes=yield fetch(data.download,{headers:{Referer:url}}),repairHtml=yield repairRes.text(),repairLink=cheerio.load(repairHtml)("#continue-btn").attr("href"),repairRequireRepairRes=yield fetch("https://www.mediafire.com"+repairLink),repairDownloadLink=cheerio.load(yield repairRequireRepairRes.text())(".input.popsok").attr("href");repairDownloadLink&&streamLinks.push({server:"Mediafire",link:repairDownloadLink,type:"mkv"})}return streamLinks}catch(err){return[]}})};exports.getStream=getStream; \ No newline at end of file diff --git a/providers/world4u/stream.ts b/providers/world4u/stream.ts index 27e467c..17bbe61 100644 --- a/providers/world4u/stream.ts +++ b/providers/world4u/stream.ts @@ -20,6 +20,8 @@ export const getStream = async function ({ "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", + Cookie: + "61cn=1; 61wk=1; __cf_bm=wtv9Eoa2wrUDgevtAnJ6wUOZrxtVYBcddhUDtT0Wj_M-1757137848-1.0.1.1-8Tr7rV19zNgUcRYe_5567LKb2IZrKyxwrc1VWgTmMDd06Givhil3U2kMtUYTYkTnuD3sHUgfh8CO9Y5LrEcZACBbrPE.3Sq5F_JLXaK7Hrw; conv_tracking_data-2=%7B%22mf_source%22%3A%22regular_download-59%22%2C%22mf_content%22%3A%22Free%22%2C%22mf_medium%22%3A%22unknown%5C%2FDefault%20Browser%22%2C%22mf_campaign%22%3A%22616qpccbrq0y4oe%22%2C%22mf_term%22%3A%22d11b8f533377139aa38d757e5057630e%22%7D; ukey=pu2dyp35fyongstav3km969l8d6u2z82", }; try { @@ -110,7 +112,7 @@ export const getStream = async function ({ try { const key = html.match(/formData\.append\('key',\s*'(\d+)'\);/)?.[1] || ""; - console.log("key", key); + console.log("key", key, "url", url); const formData = new FormData(); formData.append("key", key); const streamRes = await fetch(url, { @@ -120,7 +122,10 @@ export const getStream = async function ({ }); data = await streamRes.json(); } catch (err) { - console.log("error in world4uGetStream", err); + console.log( + "error in world4uGetStream", + err instanceof Error ? err.message : err + ); } // console.log('streamRes', streamRes); @@ -131,8 +136,12 @@ export const getStream = async function ({ $(".input.popsok").attr("href"); console.log("mediafireUrl", mediafireUrl); if (mediafireUrl) { - const directUrl = await axios.head(mediafireUrl); - const urlContentType = directUrl.headers["content-type"]; + const directUrl = await fetch(mediafireUrl, { + headers: { + Referer: url, + }, + }); + const urlContentType = directUrl.headers.get("content-type"); console.log("mfcontentType", urlContentType); if (urlContentType && urlContentType.includes("video")) { streamLinks.push({ @@ -142,19 +151,23 @@ export const getStream = async function ({ }); return streamLinks; } else { - const repairRes = await axios.get(mediafireUrl, { + const repairRes = await fetch(mediafireUrl, { headers: { Referer: url, }, }); - const repairHtml = repairRes.data; + const repairHtml = await repairRes.text(); // Regex to match the window.location.href assignment in the script content - const hrefRegex = /window\.location\.href\s*=\s*['"]([^'"]+)['"]/; - const match = repairHtml.match(hrefRegex); + const base64Link = cheerio + .load(repairHtml)(".input.popsok") + .attr("data-scrambled-url"); + console.log("base64Link", base64Link); + const href = base64Link ? atob(base64Link) : null; + console.log("href", href); // If a match is found, return the URL; otherwise return null - let downloadLInk = match ? match[1] : null; + let downloadLInk = href?.startsWith("https://") ? href : null; console.log("downloadLInk", downloadLInk); if (downloadLInk) { @@ -168,8 +181,8 @@ export const getStream = async function ({ } } - const requireRepairRes = await axios.head(data.download); - const contentType = requireRepairRes.headers["content-type"]; + const requireRepairRes = await fetch(data.download); + const contentType = requireRepairRes.headers.get("content-type"); console.log("contentType", contentType); if (contentType && contentType.includes("video")) { streamLinks.push({ @@ -179,19 +192,19 @@ export const getStream = async function ({ }); return streamLinks; } else { - const repairRes = await axios.get(data.download, { + const repairRes = await fetch(data.download, { headers: { Referer: url, }, }); - const repairHtml = repairRes.data; + const repairHtml = await repairRes.text(); const $ = cheerio.load(repairHtml); const repairLink = $("#continue-btn").attr("href"); console.log("repairLink", "https://www.mediafire.com" + repairLink); - const repairRequireRepairRes = await axios.get( + const repairRequireRepairRes = await fetch( "https://www.mediafire.com" + repairLink ); - const $$ = cheerio.load(repairRequireRepairRes.data); + const $$ = cheerio.load(await repairRequireRepairRes.text()); const repairDownloadLink = $$(".input.popsok").attr("href"); console.log("repairDownloadLink", repairDownloadLink); if (repairDownloadLink) { @@ -205,7 +218,7 @@ export const getStream = async function ({ return streamLinks; } catch (err) { - console.log(err); + console.log(err instanceof Error ? err.message : err); return []; } };