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

1 line
2.3 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{c(o.next(e))}catch(e){s(e)}},a=e=>{try{c(o.throw(e))}catch(e){s(e)}},c=e=>e.done?r(e.value):Promise.resolve(e.value).then(n,a);c((o=o.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:o,providerContext:r}){const{getBaseUrl:s,axios:n,cheerio:a}=r,c=yield s("vadapav");return t>1?[]:posts({baseUrl:c,url:`${c+e}`,signal:o,axios:n,cheerio:a})})},"getPosts"),getSearchPosts=__name(function(e){return __async(this,arguments,function*({searchQuery:e,page:t,signal:o,providerContext:r}){const{getBaseUrl:s,axios:n,cheerio:a}=r,c=yield s("vadapav");return t>1?[]:posts({baseUrl:c,url:`${c}/s/${e}`,signal:o,axios:n,cheerio:a})})},"getSearchPosts");function posts(e){return __async(this,arguments,function*({url:e,signal:t,axios:o,cheerio:r}){try{const s=(yield o.get(e,{signal:t})).data,n=r.load(s),a=[];return n('.directory-entry:not(:contains("Parent Directory"))').map((e,t)=>{var o;const r=n(t).text(),s=n(t).attr("href"),c=(null==r?void 0:r.length)>30?null==(o=null==r?void 0:r.slice(0,30))?void 0:o.replace(/\./g," "):null==r?void 0:r.replace(/\./g," "),i=`https://placehold.jp/23/000000/ffffff/200x400.png?text=${encodeURIComponent(c)}&css=%7B%22background%22%3A%22%20-webkit-gradient(linear%2C%20left%20bottom%2C%20left%20top%2C%20from(%233f3b3b)%2C%20to(%23000000))%22%2C%22text-transform%22%3A%22%20capitalize%22%7D`;r&&s&&a.push({title:r,link:s,image:i})}),a}catch(e){return[]}})}__name(posts,"posts"),exports.getPosts=getPosts,exports.getSearchPosts=getSearchPosts;