mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
1 line
9.6 KiB
JavaScript
1 line
9.6 KiB
JavaScript
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__name=(target,value)=>__defProp(target,"name",{value:value,configurable:!0}),__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),__async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())}),stream_exports={};__export(stream_exports,{getStream:()=>getStream});var hubcloudDecode=__name(function(value){return void 0===value?"":atob(value.toString())},"hubcloudDecode");function hubcloudExtractor(link,signal,axios,cheerio,headers){return __async(this,null,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",console.log("hubcloudExtractor",link),console.log("headers",headers);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.split("r="))?void 0:_b[1])||vLinkRedirect[1]||$vLink(".fa-file-download.fa-lg").parent().attr("href")||link;console.log("vcloudLink",vcloudLink),(null==vcloudLink?void 0:vcloudLink.startsWith("/"))&&(vcloudLink=`${baseUrl}${vcloudLink}`,console.log("New vcloudLink",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 link2=$(element).attr("href")||"";switch(!0){case null==link2?void 0:link2.includes("pixeld"):if(!(null==link2?void 0:link2.includes("api"))){const token=link2.split("/").pop(),baseUrl2=link2.split("/").slice(0,-2).join("/");link2=`${baseUrl2}/api/file/${token}?download`}streamLinks.push({server:"Pixeldrain",link:link2,type:"mkv"});break;case(null==link2?void 0:link2.includes(".dev"))&&!(null==link2?void 0:link2.includes("/?id=")):streamLinks.push({server:"Cf Worker",link:link2,type:"mkv"});break;case(null==link2?void 0:link2.includes("hubcloud"))||(null==link2?void 0:link2.includes("/?id=")):try{const newLinkRes=yield fetch(link2,{method:"HEAD",headers:headers,signal:signal,redirect:"manual"});let newLink=link2;if(newLink=newLinkRes.status>=300&&newLinkRes.status<400?newLinkRes.headers.get("location")||link2:newLinkRes.url&&newLinkRes.url!==link2?newLinkRes.url:newLinkRes.headers.get("location")||link2,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.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.split("?link=")[1])||newLink}streamLinks.push({server:"hubcloud",link:newLink,type:"mkv"})}catch(error){console.log("hubcloudExtractor error in hubcloud link: ",error)}break;case null==link2?void 0:link2.includes("cloudflarestorage"):streamLinks.push({server:"CfStorage",link:link2,type:"mkv"});break;case(null==link2?void 0:link2.includes("fastdl"))||(null==link2?void 0:link2.includes("fsl.")):streamLinks.push({server:"FastDl",link:link2,type:"mkv"});break;case link2.includes("hubcdn")&&!link2.includes("/?id="):streamLinks.push({server:"HubCdn",link:link2,type:"mkv"});break;default:if((null==link2?void 0:link2.includes(".mkv"))||(null==link2?void 0:link2.includes("?token="))){const serverName=(null==(_f=null==(_e=link2.match(/^(?:https?:\/\/)?(?:www\.)?([^\/]+)/i))?void 0:_e[1])?void 0:_f.replace(/\./g," "))||"Unknown";streamLinks.push({server:serverName,link:link2,type:"mkv"})}}}return console.log("streamLinks",streamLinks),streamLinks}catch(error){return console.log("hubcloudExtractor error: ",(null==error?void 0:error.message)||error),[]}})}function gdflixExtractor(link,signal,axios,cheerio,headers){return __async(this,null,function*(){var _a,_b,_c,_d,_e,_f,_g,_h;try{const streamLinks=[],res=yield axios(`${link}`,{headers:headers,signal:signal});console.log("gdflixExtractor",link);const data=res.data;let $drive=cheerio.load(data);if(null==(_a=$drive("body").attr("onload"))?void 0:_a.includes("location.replace")){const newLink=null==(_d=null==(_c=null==(_b=$drive("body").attr("onload"))?void 0:_b.split("location.replace('"))?void 0:_c[1].split("'"))?void 0:_d[0];if(console.log("newLink",newLink),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(console.log("resumeDrive",resumeDrive),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();console.log("resumeBotDownloadData",resumeBotDownloadData.url),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){console.log("Resume link not found")}try{const seed=$drive(".btn-danger").attr("href")||"";if(console.log("seed",seed),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 console.log("Instant link not found",instantLinkData)}else{const newLinkRes=yield axios.head(seed,{headers:headers,signal:signal});console.log("newLinkRes",null==(_e=newLinkRes.request)?void 0:_e.responseURL);const newLink=(null==(_h=null==(_g=null==(_f=newLinkRes.request)?void 0:_f.responseURL)?void 0:_g.split("?url="))?void 0:_h[1])||seed;streamLinks.push({server:"G-Drive",link:newLink,type:"mkv"})}}catch(err){console.log("Instant link not found",err)}return streamLinks}catch(error){return console.log("gdflix error: ",error),[]}})}__name(hubcloudExtractor,"hubcloudExtractor"),__name(gdflixExtractor,"gdflixExtractor");var getStream=__name(function(_0){return __async(this,arguments,function*({link:url,type:type,signal:signal,providerContext:providerContext}){var _a,_b;const{axios:axios,cheerio:cheerio,commonHeaders:headers}=providerContext;try{if("movie"===type){const html=(yield axios.get(url,{headers:headers})).data;url=cheerio.load(html)('a:contains("HubCloud")').attr("href")||url}let redirectUrl="";try{const res=yield axios.get(url,{headers:headers});redirectUrl=null==(_a=res.data.match(/<meta\s+http-equiv="refresh"\s+content="[^"]*?;\s*url=([^"]+)"\s*\/?>/i))?void 0:_a[1],url.includes("/archives/")&&(redirectUrl=null==(_b=res.data.match(/<a\s+[^>]*href="(https:\/\/hubcloud\.[^\/]+\/[^"]+)"/i))?void 0:_b[1])}catch(err){console.error("Hubcloud redirect err",(null==err?void 0:err.message)||err)}if(!redirectUrl){if(url.includes("hubcloud"))return console.log(" hubcloud link found in:",url),yield hubcloudExtractor(url,signal,axios,cheerio,headers);if(url.includes("gdflix"))return console.log("gdflix link found:",url),yield gdflixExtractor(url,signal,axios,cheerio,headers)}console.log("redirectUrl",redirectUrl);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 console.error("Movies Drive err",(null==err?void 0:err.message)||err),[]}})},"getStream");exports.getStream=getStream; |