mirror of
https://github.com/alantang1977/X.git
synced 2024-12-27 05:13:13 +02:00
1 line
6.4 KiB
JavaScript
1 line
6.4 KiB
JavaScript
|
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<uri.queryPairs.length;i++)keys.push(uri.queryPairs[i][0]);keys=_.sortBy(keys,function(name){return name});let tkSrc=uri.path();for(k of keys){var v=uri.getQueryParamValue(k),v=encodeURIComponent(v);tkSrc+=v}tkSrc=tkSrc+sj+"XSpeUFjJ",console.log(tkSrc);reqUrl=Crypto.MD5(tkSrc).toString().toLowerCase(),console.log(reqUrl),agentSp={"user-agent":agentSp||"okhttp/3.12.0",t:sj,TK:reqUrl},sj=await req(uri.toString(),{headers:agentSp}),reqUrl=sj.headers.date,agentSp=sj.content,sj=dayjs(reqUrl).unix();return timeOffset=dayjs().unix()-sj,agentSp}async function init(cfg){siteKey=cfg.skey,siteType=cfg.stype;cfg=await local.get(key,"device");if(0<cfg.length)try{device=JSON.parse(cfg)}catch(error){}_.isEmpty(device)&&((device=randDevice()).id=randStr(32).toLowerCase(),device.ua="Dalvik/2.1.0 (Linux; U; Android "+device.release+"; "+device.model+" Build/"+device.buildId+")",await local.set(key,"device",JSON.stringify(device))),await request(url+"/api.php/provide/getDomain"),await request(url+"/api.php/provide/config"),await request(url+"/api.php/provide/checkUpgrade"),await request(url+"/api.php/provide/channel")}async function home(filter){var data=JSON.parse(await request(url+"/api.php/provide/filter")).data,classes=[],filterObj={},filterAll=[];for(const key in data)if(classes.push({type_id:key,type_name:data[key][0].cat}),filter)try{var typeId=key.toString();if(_.isEmpty(filterAll)){var filterData=JSON.parse(await request(url+"/api.php/provide/searchFilter?type_id=0&pagenum=1&pagesize=1")).data.conditions,year={key:"year",name:"年份",init:""};let yearValues=[];yearValues.push({n:"全部",v:""}),filterData.y.forEach(e=>{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,
|