Files
vega-providers/dist/multi/posts.js
Himanshu a179a130d6 build
2026-02-03 21:48:37 +05:30

1 line
2.0 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,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of __getOwnPropNames(t))__hasOwnProp.call(e,o)||o===r||__defProp(e,o,{get:()=>t[o],enumerable:!(s=__getOwnPropDesc(t,o))||s.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),__async=(e,t,r)=>new Promise((s,o)=>{var n=e=>{try{i(r.next(e))}catch(e){o(e)}},a=e=>{try{i(r.throw(e))}catch(e){o(e)}},i=e=>e.done?s(e.value):Promise.resolve(e.value).then(n,a);i((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:s}){const{getBaseUrl:o,cheerio:n}=s;return posts({url:`${(yield o("multi"))+e}page/${t}/`,signal:r,cheerio:n})})},"getPosts"),getSearchPosts=__name(function(e){return __async(this,arguments,function*({searchQuery:e,signal:t,providerContext:r}){const{getBaseUrl:s,cheerio:o}=r;return posts({url:`${yield s("multi")}/?s=${e}`,signal:t,cheerio:o})})},"getSearchPosts");function posts(e){return __async(this,arguments,function*({url:e,signal:t,cheerio:r}){try{const s=yield fetch(e,{signal:t}),o=yield s.text(),n=r.load(o),a=[];return n(".items.full,.result-item").children().map((e,t)=>{const r=n(t).find(".poster,.image").find("img").attr("alt"),s=n(t).find(".poster,.image").find("a").attr("href"),o=n(t).find(".poster,.image").find("img").attr("data-src")||n(t).find(".poster,.image").find("img").attr("src");r&&s&&o&&a.push({title:r,link:s,image:o})}),a}catch(e){return[]}})}__name(posts,"posts"),exports.getPosts=getPosts,exports.getSearchPosts=getSearchPosts;