mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
1 line
4.9 KiB
JavaScript
1 line
4.9 KiB
JavaScript
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__name=(target,value)=>__defProp(target,"name",{value:value,configurable:!0}),__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),__async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())}),posts_exports={};__export(posts_exports,{getPosts:()=>getPosts,getSearchPosts:()=>getSearchPosts});var 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=__name(function(_0){return __async(this,arguments,function*({filter:filter,page:page,signal:signal,providerContext:providerContext}){try{const{axios:axios,getBaseUrl:getBaseUrl}=providerContext,baseUrl=yield getBaseUrl("dooflix"),catalog=[],url=baseUrl+filter+`?page=${page}`,resData=(yield axios.get(url,{headers:headers,signal:signal})).data;if(!resData||"string"!=typeof resData)return console.warn("Unexpected response format from dooflix API"),[];let data;try{const jsonStart=resData.indexOf("["),jsonEnd=resData.lastIndexOf("]")+1;if(-1===jsonStart||jsonEnd<=jsonStart)data=JSON.parse(resData);else{const jsonSubstring=resData.substring(jsonStart,jsonEnd),parsedArray=JSON.parse(jsonSubstring);data=parsedArray.length>0?parsedArray:resData}}catch(parseError){return console.error("Error parsing dooflix response:",parseError),[]}return Array.isArray(data)?(data.forEach(result=>{const id=null==result?void 0:result.videos_id;if(!id)return;const type=(null==result?void 0:result.is_tvseries)?"movie":"tvseries",link=`${baseUrl}/rest-api//v130/single_details?type=${type}&id=${id}`,thumbnailUrl=null==result?void 0:result.thumbnail_url,image=(null==thumbnailUrl?void 0:thumbnailUrl.includes("https"))?thumbnailUrl:null==thumbnailUrl?void 0:thumbnailUrl.replace("http","https");catalog.push({title:(null==result?void 0:result.title)||"",link:link,image:image})}),catalog):(console.warn("Unexpected data format from dooflix API"),[])}catch(err){return console.error("dooflix error:",err),[]}})},"getPosts"),getSearchPosts=__name(function(_0){return __async(this,arguments,function*({searchQuery:searchQuery,page:page,providerContext:providerContext,signal:signal}){var _a,_b;try{if(page>1)return[];const{axios:axios,getBaseUrl:getBaseUrl}=providerContext,catalog=[],baseUrl=yield getBaseUrl("dooflix"),url=`${baseUrl}/rest-api//v130/search?q=${searchQuery}&type=movietvserieslive&range_to=0&range_from=0&tv_category_id=0&genre_id=0&country_id=0`,resData=(yield axios.get(url,{headers:headers,signal:signal})).data;if(!resData||"string"!=typeof resData)return console.warn("Unexpected search response format from dooflix API"),[];let data;try{const jsonStart=resData.indexOf("{"),jsonEnd=resData.lastIndexOf("}")+1;if(-1===jsonStart||jsonEnd<=jsonStart)data=resData;else{const jsonSubstring=resData.substring(jsonStart,jsonEnd),parsedData=JSON.parse(jsonSubstring);data=(null==parsedData?void 0:parsedData.movie)?parsedData:resData}}catch(parseError){return console.error("Error parsing dooflix search response:",parseError),[]}return null==(_a=null==data?void 0:data.movie)||_a.forEach(result=>{const id=null==result?void 0:result.videos_id;if(!id)return;const link=`${baseUrl}/rest-api//v130/single_details?type=movie&id=${id}`,thumbnailUrl=null==result?void 0:result.thumbnail_url,image=(null==thumbnailUrl?void 0:thumbnailUrl.includes("https"))?thumbnailUrl:null==thumbnailUrl?void 0:thumbnailUrl.replace("http","https");catalog.push({title:(null==result?void 0:result.title)||"",link:link,image:image})}),null==(_b=null==data?void 0:data.tvseries)||_b.forEach(result=>{const id=null==result?void 0:result.videos_id;if(!id)return;const link=`${baseUrl}/rest-api//v130/single_details?type=tvseries&id=${id}`,thumbnailUrl=null==result?void 0:result.thumbnail_url,image=(null==thumbnailUrl?void 0:thumbnailUrl.includes("https"))?thumbnailUrl:null==thumbnailUrl?void 0:thumbnailUrl.replace("http","https");catalog.push({title:(null==result?void 0:result.title)||"",link:link,image:image})}),catalog}catch(error){return console.error("dooflix search error:",error),[]}})},"getSearchPosts");exports.getPosts=getPosts,exports.getSearchPosts=getSearchPosts; |