mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
1 line
1.9 KiB
JavaScript
1 line
1.9 KiB
JavaScript
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__name=(e,t)=>__defProp(e,"name",{value:t,configurable:!0}),__export=(e,t)=>{for(var o in t)__defProp(e,o,{get:t[o],enumerable:!0})},__copyProps=(e,t,o,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of __getOwnPropNames(t))__hasOwnProp.call(e,s)||s===o||__defProp(e,s,{get:()=>t[s],enumerable:!(r=__getOwnPropDesc(t,s))||r.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),__async=(e,t,o)=>new Promise((r,s)=>{var n=e=>{try{i(o.next(e))}catch(e){s(e)}},a=e=>{try{i(o.throw(e))}catch(e){s(e)}},i=e=>e.done?r(e.value):Promise.resolve(e.value).then(n,a);i((o=o.apply(e,t)).next())}),episodes_exports={};__export(episodes_exports,{getEpisodes:()=>getEpisodes});var formatEpisodeTitle=__name(e=>{try{const t=e.match(/S(\d+)E(\d+)/i);if(t){return`S${t[1].padStart(2,"0")} E${t[2].padStart(2,"0")}`}return e}catch(t){return e}},"formatEpisodeTitle"),getEpisodes=__name(function(e){return __async(this,arguments,function*({url:e,providerContext:t}){var o,r,s,n;const{axios:a,cheerio:i,commonHeaders:p}=t;try{const t=e.split("/").slice(0,3).join("/"),i=e.split("/").filter(Boolean).pop()||"",_=`${t}/api/packs/${i}`;let l;try{l=yield a.get(_,{headers:p})}catch(e){if(404===(null==(o=e.response)?void 0:o.status)){const e=`${t}/api/s/${i}/`,o=yield a.get(e,{headers:p});if(null==(r=o.data)?void 0:r.hasHubcloud){const e=`${t}/api/s/${i}/hubcloud`;return[{title:formatEpisodeTitle(o.data.fileName||"Movie"),link:e}]}return[]}throw e}const c=[],d=(null==(n=null==(s=l.data)?void 0:s.pack)?void 0:n.items)||[];for(const e of d)e.file_name&&e.hubcloud_link&&c.push({title:formatEpisodeTitle(e.file_name),link:e.hubcloud_link});return c}catch(e){throw e}})},"getEpisodes");exports.getEpisodes=getEpisodes; |