Files
vega-providers/dist/drive/stream.js

1 line
9.0 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=void 0;__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[]}})}__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())})};function gdflixExtractor(link,signal,axios,cheerio,headers){return __awaiter(this,void 0,void 0,function*(){var _a,_b,_c,_d,_f,_g,_h;try{const streamLinks=[],data=(yield axios(`${link}`,{headers:headers,signal:signal})).data;let $drive=cheerio.load(data);if(null===(_a=$drive("body").attr("onload"))||void 0===_a?void 0:_a.includes("location.replace")){const newLink=null===(_d=null===(_c=null===(_b=$drive("body").attr("onload"))||void 0===_b?void 0:_b.split("location.replace('"))||void 0===_c?void 0:_c[1].split("'"))||void 0===_d?void 0:_d[0];if(newLink){const newRes=yield axios.get(newLink,{headers:headers,signal:signal});$drive=cheerio.load(newRes.data)}}try{const baseUrl=link.split("/").slice(0,3).join("/"),resumeDrive=$drive(".btn-secondary").attr("href")||"";if(resumeDrive.includes("indexbot")){const resumeBotRes=yield axios.get(resumeDrive,{headers:headers}),resumeBotToken=resumeBotRes.data.match(/formData\.append\('token', '([a-f0-9]+)'\)/)[1],resumeBotBody=new FormData;resumeBotBody.append("token",resumeBotToken);const resumeBotPath=resumeBotRes.data.match(/fetch\('\/download\?id=([a-zA-Z0-9\/+]+)'/)[1],resumeBotBaseUrl=resumeDrive.split("/download")[0],resumeBotDownload=yield fetch(resumeBotBaseUrl+"/download?id="+resumeBotPath,{method:"POST",body:resumeBotBody,headers:{Referer:resumeDrive,Cookie:"PHPSESSID=7e9658ce7c805dab5bbcea9046f7f308"}}),resumeBotDownloadData=yield resumeBotDownload.json();streamLinks.push({server:"ResumeBot",link:resumeBotDownloadData.url,type:"mkv"})}else{const url=baseUrl+resumeDrive,resumeDriveHtml=(yield axios.get(url,{headers:headers})).data,resumeLink=cheerio.load(resumeDriveHtml)(".btn-success").attr("href");resumeLink&&streamLinks.push({server:"ResumeCloud",link:resumeLink,type:"mkv"})}}catch(err){}try{const seed=$drive(".btn-danger").attr("href")||"";if(seed.includes("?url=")){const instantToken=seed.split("=")[1],InstantFromData=new FormData;InstantFromData.append("keys",instantToken);const videoSeedUrl=seed.split("/").slice(0,3).join("/")+"/api",instantLinkRes=yield fetch(videoSeedUrl,{method:"POST",body:InstantFromData,headers:{"x-token":videoSeedUrl}}),instantLinkData=yield instantLinkRes.json();if(!1===instantLinkData.error){const instantLink=instantLinkData.url;streamLinks.push({server:"Gdrive-Instant",link:instantLink,type:"mkv"})}}else{const newLink=(null===(_h=null===(_g=null===(_f=(yield axios.head(seed,{headers:headers,signal:signal})).request)||void 0===_f?void 0:_f.responseURL)||void 0===_g?void 0:_g.split("?url="))||void 0===_h?void 0:_h[1])||seed;streamLinks.push({server:"G-Drive",link:newLink,type:"mkv"})}}catch(err){}return streamLinks}catch(error){return[]}})}const getStream=function(_a){return __awaiter(this,arguments,void 0,function*({link:url,type:type,signal:signal,providerContext:providerContext}){var _b,_c;const{axios:axios,cheerio:cheerio,commonHeaders:headers}=providerContext;try{if("movie"===type){const html=(yield axios.get(url,{headers:headers})).data,$=cheerio.load(html);url=$('a:contains("HubCloud")').attr("href")||url}let redirectUrl="";try{const res=yield axios.get(url,{headers:headers});redirectUrl=null===(_b=res.data.match(/<meta\s+http-equiv="refresh"\s+content="[^"]*?;\s*url=([^"]+)"\s*\/?>/i))||void 0===_b?void 0:_b[1],url.includes("/archives/")&&(redirectUrl=null===(_c=res.data.match(/<a\s+[^>]*href="(https:\/\/hubcloud\.[^\/]+\/[^"]+)"/i))||void 0===_c?void 0:_c[1])}catch(err){}if(!redirectUrl){if(url.includes("hubcloud"))return yield hubcloudExtractor(url,signal,axios,cheerio,headers);if(url.includes("gdflix")){return yield gdflixExtractor(url,signal,axios,cheerio,headers)}}const data=(yield axios.get(redirectUrl,{headers:headers})).data,hubcloudLink=cheerio.load(data)(".fa-file-download").parent().attr("href");return yield hubcloudExtractor((null==hubcloudLink?void 0:hubcloudLink.includes("https://hubcloud"))?hubcloudLink:redirectUrl,signal,axios,cheerio,headers)}catch(err){return[]}})};exports.getStream=getStream;