mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
1 line
6.8 KiB
JavaScript
1 line
6.8 KiB
JavaScript
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())})};exports.getStream=getStream;__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())})};const hubcloudDecode=function(value){return void 0===value?"":atob(value.toString())};function hubcloudExtractor(link,signal,axios,cheerio,headers){return __awaiter(this,void 0,void 0,function*(){var _a,_b,_c,_d,_e,_f;try{headers.Cookie="ext_name=ojplmecpdpgccookcobabopnaifgidhf; xla=s4t; cf_clearance=woQrFGXtLfmEMBEiGUsVHrUBMT8s3cmguIzmMjmvpkg-1770053679-1.2.1.1-xBrQdciOJsweUF6F2T_OtH6jmyanN_TduQ0yslc_XqjU6RcHSxI7.YOKv6ry7oYo64868HYoULnVyww536H2eVI3R2e4wKzsky6abjPdfQPxqpUaXjxfJ02o6jl3_Vkwr4uiaU7Wy596Vdst3y78HXvVmKdIohhtPvp.vZ9_L7wvWdce0GRixjh_6JiqWmWMws46hwEt3hboaS1e1e4EoWCvj5b0M_jVwvSxBOAW5emFzvT3QrnRh4nyYmKDERnY";const baseUrl=link.split("/").slice(0,3).join("/"),streamLinks=[],vLinkText=(yield axios(`${link}`,{headers:headers,signal:signal})).data,$vLink=cheerio.load(vLinkText),vLinkRedirect=vLinkText.match(/var\s+url\s*=\s*'([^']+)';/)||[];let vcloudLink=hubcloudDecode(null===(_b=null===(_a=vLinkRedirect[1])||void 0===_a?void 0:_a.split("r="))||void 0===_b?void 0:_b[1])||vLinkRedirect[1]||$vLink(".fa-file-download.fa-lg").parent().attr("href")||link;(null==vcloudLink?void 0:vcloudLink.startsWith("/"))&&(vcloudLink=`${baseUrl}${vcloudLink}`);const vcloudRes=yield fetch(vcloudLink,{headers:headers,signal:signal,redirect:"follow"}),$=cheerio.load(yield vcloudRes.text()),linkClass=$(".btn-success.btn-lg.h6,.btn-danger,.btn-secondary");for(const element of linkClass){let link=$(element).attr("href")||"";switch(!0){case null==link?void 0:link.includes("pixeld"):if(!(null==link?void 0:link.includes("api"))){const token=link.split("/").pop(),baseUrl=link.split("/").slice(0,-2).join("/");link=`${baseUrl}/api/file/${token}?download`}streamLinks.push({server:"Pixeldrain",link:link,type:"mkv"});break;case(null==link?void 0:link.includes(".dev"))&&!(null==link?void 0:link.includes("/?id=")):streamLinks.push({server:"Cf Worker",link:link,type:"mkv"});break;case(null==link?void 0:link.includes("hubcloud"))||(null==link?void 0:link.includes("/?id=")):try{const newLinkRes=yield fetch(link,{method:"HEAD",headers:headers,signal:signal,redirect:"manual"});let newLink=link;if(newLink=newLinkRes.status>=300&&newLinkRes.status<400?newLinkRes.headers.get("location")||link:newLinkRes.url&&newLinkRes.url!==link?newLinkRes.url:newLinkRes.headers.get("location")||link,newLink.includes("googleusercontent"))newLink=newLink.split("?link=")[1];else{const newLinkRes2=yield fetch(newLink,{method:"HEAD",headers:headers,signal:signal,redirect:"manual"});newLink=newLinkRes2.status>=300&&newLinkRes2.status<400?(null===(_c=newLinkRes2.headers.get("location"))||void 0===_c?void 0:_c.split("?link=")[1])||newLink:newLinkRes2.url&&newLinkRes2.url!==newLink?newLinkRes2.url.split("?link=")[1]||newLinkRes2.url:(null===(_d=newLinkRes2.headers.get("location"))||void 0===_d?void 0:_d.split("?link=")[1])||newLink}streamLinks.push({server:"hubcloud",link:newLink,type:"mkv"})}catch(error){}break;case null==link?void 0:link.includes("cloudflarestorage"):streamLinks.push({server:"CfStorage",link:link,type:"mkv"});break;case(null==link?void 0:link.includes("fastdl"))||(null==link?void 0:link.includes("fsl.")):streamLinks.push({server:"FastDl",link:link,type:"mkv"});break;case link.includes("hubcdn")&&!link.includes("/?id="):streamLinks.push({server:"HubCdn",link:link,type:"mkv"});break;default:if((null==link?void 0:link.includes(".mkv"))||(null==link?void 0:link.includes("?token="))){const serverName=(null===(_f=null===(_e=link.match(/^(?:https?:\/\/)?(?:www\.)?([^\/]+)/i))||void 0===_e?void 0:_e[1])||void 0===_f?void 0:_f.replace(/\./g," "))||"Unknown";streamLinks.push({server:serverName,link:link,type:"mkv"})}}}return streamLinks}catch(error){return[]}})}const headers={accept:"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7","accept-language":"en-US,en;q=0.9,en-IN;q=0.8","cache-control":"no-cache",pragma:"no-cache",priority:"u=0, i","sec-ch-ua":'"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"document","sec-fetch-mode":"navigate","sec-fetch-site":"none","sec-fetch-user":"?1","upgrade-insecure-requests":"1"};function getStream(_a){return __awaiter(this,arguments,void 0,function*({link:link,type:type,signal:signal,providerContext:providerContext}){var _b,_c,_d,_e;const{axios:axios,cheerio:cheerio,commonHeaders:commonHeaders}=providerContext;try{const streamLinks=[];if("movie"===type){const dotlinkRes=yield fetch(`${link}`,{headers:headers}),dotlinkText=yield dotlinkRes.text();link=(dotlinkText.match(/<a\s+href="([^"]*cloud\.[^"]*)"/i)||[])[1];try{const filepressLink=cheerio.load(dotlinkText)('.btn.btn-sm.btn-outline[style="background:linear-gradient(135deg,rgb(252,185,0) 0%,rgb(0,0,0)); color: #fdf8f2;"]').parent().attr("href"),filepressID=null==filepressLink?void 0:filepressLink.split("/").pop(),filepressBaseUrl=null==filepressLink?void 0:filepressLink.split("/").slice(0,-2).join("/"),filepressTokenRes=yield axios.post(filepressBaseUrl+"/api/file/downlaod/",{id:filepressID,method:"indexDownlaod",captchaValue:null},{headers:{"Content-Type":"application/json",Referer:filepressBaseUrl}});if(null===(_b=filepressTokenRes.data)||void 0===_b?void 0:_b.status){const filepressToken=null===(_c=filepressTokenRes.data)||void 0===_c?void 0:_c.data,filepressStreamLink=yield axios.post(filepressBaseUrl+"/api/file/downlaod2/",{id:filepressToken,method:"indexDownlaod",captchaValue:null},{headers:{"Content-Type":"application/json",Referer:filepressBaseUrl}});streamLinks.push({server:"filepress",link:null===(_e=null===(_d=filepressStreamLink.data)||void 0===_d?void 0:_d.data)||void 0===_e?void 0:_e[0],type:"mkv"})}}catch(error){}}return yield hubcloudExtractor(link,signal,axios,cheerio,commonHeaders)}catch(error){return error.message.includes("Aborted"),[]}})} |