mirror of
https://github.com/alantang1977/X.git
synced 2024-12-27 05:13:13 +02:00
1 line
3.7 KiB
JavaScript
1 line
3.7 KiB
JavaScript
|
import{Crypto,load,_}from"assets://js/lib/cat.js";let key="ikanbot",url="https://www.ikanbot.com",siteKey="",siteType=0;const UA="Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1";async function request(reqUrl,agentSp){return(await req(reqUrl,{method:"get",headers:{"User-Agent":agentSp||UA}})).content}async function init(cfg){siteKey=cfg.skey,siteType=cfg.stype}function getClass($){var nav=$("ul.nav-pills:eq(1) > li > a"),nav={key:"tag",name:"标签",value:_.map(nav,n=>({n:n.children[0].data,v:n.attribs.href}))},$=(nav.init=nav.value[0].v,$("title:first").text().split("-")[0].substring(2));return{cls:{type_id:nav.value[0].v,type_name:$},tags:[nav]}}async function home(filter){var classes=[],filterObj={};for(const cate of["/hot/index-movie-热门.html","/hot/index-tv-热门.html"]){var html=await request(url+cate),{cls:html,tags}=getClass(load(html));classes.push(html),filterObj[html.type_id]=tags}return JSON.stringify({class:classes,filters:filterObj})}async function homeVod(){return"{}"}async function category(tid,pg,filter,extend){pg<=0&&(pg=1);extend=await request(url+(extend.tag||tid).replace(".html",1<pg?`-p-${pg}.html`:".html"));const $=load(extend);var tid=$("div.v-list a.item"),jsBase=await js2Proxy(!0,siteType,siteKey,"img/",{}),extend=_.map(tid,item=>{var img=$(item).find("img:first")[0];return{vod_id:item.attribs.href,vod_name:img.attribs.alt,vod_pic:jsBase+base64Encode(img.attribs["data-src"]),vod_remarks:""}}),tid=0<$("div.page-more > a:contains(下一页)").length?parseInt(pg)+1:parseInt(pg);return JSON.stringify({page:parseInt(pg),pagecount:tid,limit:24,total:24*tid,list:extend})}async function detail(id){var html=await request(url+id),$=load(html),html=await js2Proxy(!0,siteType,siteKey,"img/",{}),detail=$("div.detail > .meta"),vod={vod_id:id,vod_pic:html+base64Encode($("div.item-root > img")[0].attribs["data-src"]),vod_remarks:""};for(const info of detail)$(info).hasClass("title")?vod.vod_name=info.children[0].data:$(info).hasClass("year")||$(info).hasClass("country")?vod.vod_area=info.children[0].data:$(info).hasClass("celebrity")&&(vod.vod_actor=info.children[0].data);var html=await req(url+"/api/getResN?videoId="+id.substring(id.lastIndexOf("/")+1)+"&mtype=2",{headers:{Referer:url,"User-Agent":UA}}),playlist={};for(const l of JSON.parse(html.content).data.list)for(const f of JSON.parse(l.resData)){var from=f.flag,urls=f.url;from&&urls&&(playlist[from]||(playlist[from]=urls))}return vod.vod_play_from=_.keys(playlist).join("$$$"),vod.vod_play_url=_.values(playlist).join("$$$"),JSON.stringify({list:[vod]})}function base64Encode(text){return Crypto.enc.Base64.stringify(Crypto.enc.Utf8.parse(text))}function base64Decode(text){return Crypto.enc.Utf8.stringify(Crypto.enc.Base64.parse(text))}async function proxy(segments,headers){var what=segments[0],segments=base64Decode(segments[1]);return"img"==what?(what=await req(segments,{buffer:2,headers:{Referer:segments,"User-Agent":UA}}),JSON.stringify({code:what.code,buffer:2,content:what.content,headers:what.headers})):JSON.stringify({code:500,content:""})}async function play(flag,id,flags){return JSON.stringify({parse:0,url:id})}async function search(wd,quick){wd=await request(url+"/search?q="+wd);const $=load(wd);var wd=$("div.media > div.media-left > a"),jsBase=await js2Proxy(!0,siteType,siteKey,"img/",{}),wd=_.map(wd,item=>{var img=$(item).find("img:first")[0];return{vod_id:item.attribs.href,vod_name:img.attribs.alt,vod_pic:jsBase+base64Encode(img.attribs["data-src"]),vod_remarks:""}});return JSON.stringify({list:wd})}function __jsEvalReturn(){return{init:init,home:home,homeVod:homeVod,category:category,detail:detail,play:play,proxy:proxy,search:search}}export{__jsEvalReturn};
|