mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
1 line
4.6 KiB
JavaScript
1 line
4.6 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())})};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:link,signal:signal,providerContext:providerContext}){const{axios:axios,cheerio:cheerio,commonHeaders:headers}=providerContext;try{const data=(yield axios.get(link,{signal:signal})).data,$=cheerio.load(data),streams=[],promises=$(".button2,.button1,.button3,.button4,.button").toArray().map(element=>__awaiter(this,void 0,void 0,function*(){const title=$(element).text();let link=$(element).attr("href");if(title.includes("GDFLIX")&&link){const gdLinks=yield gdflixExtractor(link,signal,axios,cheerio,headers);streams.push(...gdLinks)}const alreadyAdded=streams.find(s=>s.link===link);!title||!link||title.includes("Watch")||title.includes("Login")||title.includes("GoFile")||alreadyAdded||streams.push({server:title,link:link,type:"mkv"})}));return yield Promise.all(promises),streams}catch(err){return[]}})};exports.getStream=getStream; |