mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
1 line
2.8 KiB
JavaScript
1 line
2.8 KiB
JavaScript
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(s,r){function o(t){try{a(n.next(t))}catch(t){r(t)}}function l(t){try{a(n.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,l)}a((n=n.apply(t,e||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSearchPosts=exports.getPosts=void 0;const headers={"Accept-Encoding":"gzip","API-KEY":"2pm95lc6prpdbk0ppji9rsqo",Connection:"Keep-Alive","If-Modified-Since":"Wed, 14 Aug 2024 13:00:04 GMT","User-Agent":"okhttp/3.14.9"},getPosts=function(t){return __awaiter(this,arguments,void 0,function*({filter:t,page:e,signal:i,providerContext:n}){try{const{axios:s,getBaseUrl:r}=n,o=yield r("dooflix"),l=[],a=""+(o+t+`?page=${e}`),d=(yield s.get(a,{headers:headers,signal:i})).data;if(!d||"string"!=typeof d)return[];let u;try{const t=d.indexOf("["),e=d.lastIndexOf("]")+1;if(-1===t||e<=t)u=JSON.parse(d);else{const i=d.substring(t,e),n=JSON.parse(i);u=n.length>0?n:d}}catch(t){return[]}return Array.isArray(u)?(u.forEach(t=>{const e=null==t?void 0:t.videos_id;if(!e)return;const i=(null==t?void 0:t.is_tvseries)?"movie":"tvseries",n=`${o}/rest-api//v130/single_details?type=${i}&id=${e}`,s=null==t?void 0:t.thumbnail_url,r=(null==s?void 0:s.includes("https"))?s:null==s?void 0:s.replace("http","https");l.push({title:(null==t?void 0:t.title)||"",link:n,image:r})}),l):[]}catch(t){return[]}})};exports.getPosts=getPosts;const getSearchPosts=function(t){return __awaiter(this,arguments,void 0,function*({searchQuery:t,page:e,providerContext:i,signal:n}){var s,r;try{if(e>1)return[];const{axios:o,getBaseUrl:l}=i,a=[],d=yield l("dooflix"),u=`${d}/rest-api//v130/search?q=${t}&type=movietvserieslive&range_to=0&range_from=0&tv_category_id=0&genre_id=0&country_id=0`,c=(yield o.get(u,{headers:headers,signal:n})).data;if(!c||"string"!=typeof c)return[];let v;try{const t=c.indexOf("{"),e=c.lastIndexOf("}")+1;if(-1===t||e<=t)v=c;else{const i=c.substring(t,e),n=JSON.parse(i);v=(null==n?void 0:n.movie)?n:c}}catch(t){return[]}return null===(s=null==v?void 0:v.movie)||void 0===s||s.forEach(t=>{const e=null==t?void 0:t.videos_id;if(!e)return;const i=`${d}/rest-api//v130/single_details?type=movie&id=${e}`,n=null==t?void 0:t.thumbnail_url,s=(null==n?void 0:n.includes("https"))?n:null==n?void 0:n.replace("http","https");a.push({title:(null==t?void 0:t.title)||"",link:i,image:s})}),null===(r=null==v?void 0:v.tvseries)||void 0===r||r.forEach(t=>{const e=null==t?void 0:t.videos_id;if(!e)return;const i=`${d}/rest-api//v130/single_details?type=tvseries&id=${e}`,n=null==t?void 0:t.thumbnail_url,s=(null==n?void 0:n.includes("https"))?n:null==n?void 0:n.replace("http","https");a.push({title:(null==t?void 0:t.title)||"",link:i,image:s})}),a}catch(t){return[]}})};exports.getSearchPosts=getSearchPosts; |