mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
1 line
1.8 KiB
JavaScript
1 line
1.8 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 r in t)__defProp(e,r,{get:t[r],enumerable:!0})},__copyProps=(e,t,r,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of __getOwnPropNames(t))__hasOwnProp.call(e,s)||s===r||__defProp(e,s,{get:()=>t[s],enumerable:!(o=__getOwnPropDesc(t,s))||o.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),__async=(e,t,r)=>new Promise((o,s)=>{var n=e=>{try{_(r.next(e))}catch(e){s(e)}},a=e=>{try{_(r.throw(e))}catch(e){s(e)}},_=e=>e.done?o(e.value):Promise.resolve(e.value).then(n,a);_((r=r.apply(e,t)).next())}),posts_exports={};__export(posts_exports,{getPosts:()=>getPosts,getSearchPosts:()=>getSearchPosts});var getPosts=__name(function(e){return __async(this,arguments,function*({filter:e,page:t,signal:r,providerContext:o}){const{getBaseUrl:s,cheerio:n}=o;return posts({url:`${yield s("moviezwap")}${e}`,signal:r,cheerio:n})})},"getPosts"),getSearchPosts=__name(function(e){return __async(this,arguments,function*({searchQuery:e,page:t,signal:r,providerContext:o}){const{getBaseUrl:s,cheerio:n}=o;return posts({url:`${yield s("moviezwap")}/search.php?q=${encodeURIComponent(e)}`,signal:r,cheerio:n})})},"getSearchPosts");function posts(e){return __async(this,arguments,function*({url:e,signal:t,cheerio:r}){try{const o=yield fetch(e,{signal:t}),s=yield o.text(),n=r.load(s),a=[];return n('a[href^="/movie/"]').each((e,t)=>{const r=n(t).text().trim(),o=n(t).attr("href");r&&o&&a.push({title:r,link:o,image:""})}),a}catch(e){return[]}})}__name(posts,"posts"),exports.getPosts=getPosts,exports.getSearchPosts=getSearchPosts; |