mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
1 line
1.7 KiB
JavaScript
1 line
1.7 KiB
JavaScript
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(r,o){function a(t){try{c(n.next(t))}catch(t){o(t)}}function s(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(a,s)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getEpisodes=void 0,exports.extractKmhdLink=extractKmhdLink;const getEpisodes=function(t){return __awaiter(this,arguments,void 0,function*({url:t,providerContext:e}){var i;const{axios:n,cheerio:r}=e,o=[];try{if(t.includes("gdflix")){const e=null===(i=t.split("/pack"))||void 0===i?void 0:i[0],a=(yield n.get(t)).data,s=r.load(a),c=s(".list-group-item");if(null==c||c.map((t,i)=>{o.push({title:s(i).text()||"",link:e+s(i).find("a").attr("href")||""})}),o.length>0)return o}if(t.includes("/pack")){const i=yield extractKmhdEpisodes(t,e);null==i||i.forEach((e,i)=>{o.push({title:`Episode ${i+1}`,link:t.split("/pack")[0]+"/file/"+e})})}const a=(yield n.get(t,{headers:{Cookie:"_ga_GNR438JY8N=GS1.1.1722240350.5.0.1722240350.0.0.0; _ga=GA1.1.372196696.1722150754; unlocked=true"}})).data,s=r.load(a),c=s(".autohyperlink");return null==c||c.map((t,e)=>{o.push({title:s(e).parent().children().remove().end().text()||"",link:s(e).attr("href")||""})}),o}catch(t){return[]}})};function extractKmhdLink(t,e){return __awaiter(this,void 0,void 0,function*(){const{axios:i}=e,n=(yield i.get(t)).data,r=n.match(/hubdrive_res:\s*"([^"]+)"/)[1];return n.match(/hubdrive_res\s*:\s*{[^}]*?link\s*:\s*"([^"]+)"/)[1]+r})}function extractKmhdEpisodes(t,e){return __awaiter(this,void 0,void 0,function*(){const{axios:i}=e;return(yield i.get(t)).data.match(/[\w]+_[a-f0-9]{8}/g)})}exports.getEpisodes=getEpisodes; |