import{Crypto,dayjs,jinja2,Uri,_}from"assets://js/lib/cat.js";let key="kunyu77",url="http://api.tyun77.cn",device={},timeOffset=0,siteKey="",siteType=0;async function request(reqUrl,agentSp){var sj=dayjs().unix()-timeOffset,uri=new Uri(reqUrl);uri.addQueryParam("pcode","010110005"),uri.addQueryParam("version","2.1.6"),uri.addQueryParam("devid",device.id),uri.addQueryParam("package","com.sevenVideo.app.android"),uri.addQueryParam("sys","android"),uri.addQueryParam("sysver",device.release),uri.addQueryParam("brand",device.brand),uri.addQueryParam("model",device.model.replaceAll(" ","_")),uri.addQueryParam("sj",sj);let keys=[];for(var k,i=0;i{yearValues.push({n:e.name,v:e.value})}),year.value=yearValues;var area={key:"area",name:"地区",init:""};let areaValues=[];areaValues.push({n:"全部",v:""}),filterData.a.forEach(e=>{areaValues.push({n:e.name,v:e.value})}),area.value=areaValues;var type={key:"category",name:"类型",init:""};let typeValues=[];typeValues.push({n:"全部",v:""}),filterData.scat.forEach(e=>{typeValues.push({n:e.name,v:e.value})}),type.value=typeValues,filterAll.push(year,area,type)}_.isEmpty(filterAll)||(filterObj[typeId]=filterAll)}catch(e){console.log(e)}return JSON.stringify({class:classes,filters:filterObj})}async function homeVod(){var videos=[];for(const block of JSON.parse(await request(url+"/api.php/provide/homeBlock?type_id=0")).data.blocks){var name=block.block_name;if(!(0<=name.indexOf("热播")))for(const content of block.contents)videos.push({vod_id:content.id,vod_name:content.title,vod_pic:content.videoCover,vod_remarks:content.msg})}return JSON.stringify({list:videos})}async function category(tid,pg,filter,extend){var tid=url+"/api.php/provide/searchFilter?type_id="+tid+"&pagenum="+pg+"&pagesize=24&",pg=(tid+=jinja2("year={{ext.year}}&category={{ext.category}}&area={{ext.area}}",{ext:extend}),JSON.parse(await request(tid)).data),videos=[];for(const vod of pg.result)videos.push({vod_id:vod.id,vod_name:vod.title,vod_pic:vod.videoCover,vod_remarks:vod.msg});return JSON.stringify({page:parseInt(pg.page),pagecount:pg.pagesize,limit:24,total:pg.total,list:videos})}async function detail(id){var data=JSON.parse(await request(url+"/api.php/provide/videoDetail?ids="+id)).data,vod=(console.log(data),{vod_id:data.id,vod_name:data.videoName,vod_pic:data.videoCover,type_name:data.subCategory,vod_year:data.year,vod_area:data.area,vod_remarks:data.msg,vod_actor:data.actor,vod_director:data.director,vod_content:data.brief.trim()}),playlist={};for(const episode of JSON.parse(await request(url+"/api.php/provide/videoPlaylist?ids="+id)).data.episodes)for(const playurl of episode.playurls){var from=playurl.playfrom;let t=formatPlayUrl(vod.vod_name,playurl.title);0==t.length&&(t=playurl.title.trim()),playlist.hasOwnProperty(from)||(playlist[from]=[]),playlist[from].push(t+"$"+playurl.playurl)}vod.vod_play_from=_.keys(playlist).join("$$$");var vod_play_url=[];for(const urlist of _.values(playlist))vod_play_url.push(urlist.join("#"));return vod.vod_play_url=vod_play_url.join("$$$"),JSON.stringify({list:[vod]})}async function play(flag,id,flags){try{var data=JSON.parse(await request(url+"/api.php/provide/parserUrl?url="+id+"&retryNum=0")).data,playHeader=data.playHeader,jxUrl=data.url,res=await req(jxUrl,{headers:{"user-agent":"okhttp/3.12.0"}}),result=jsonParse(id,JSON.parse(res.content));return result.parse=0,playHeader&&(result.header=_.merge(result.header,playHeader)),JSON.stringify(result)}catch(e){return JSON.stringify({parse:0,url:id})}}async function search(wd,quick){var videos=[];for(const vod of JSON.parse(await request(url+"/api.php/provide/searchVideo?searchName="+wd+"&pg=1","okhttp/3.12.0")).data)videos.push({vod_id:vod.id,vod_name:vod.videoName,vod_pic:vod.videoCover,vod_remarks:vod.msg});return JSON.stringify({list:videos})}const charStr="abacdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789";function randStr(len,withNum){for(var _str="",containsNum=void 0===withNum||withNum,i=0;i|《|》/g,"").replace(/\$|#/g," ").trim()}function jsonParse(input,json){try{let url=json.url??"";var headers,ua,referer;return(url=url.startsWith("//")?"https:"+url:url).startsWith("http")?(headers=json.headers||{},0<(ua=(json["user-agent"]||"").trim()).length&&(headers["User-Agent"]=ua),0<(referer=(json.referer||"").trim()).length&&(headers.Referer=referer),{header:headers,url:url}):{}}catch(error){console.log(error)}return{}}function __jsEvalReturn(){return{init:init,home:home,homeVod:homeVod,category:category,detail:detail,play:play,search:search}}export{__jsEvalReturn};