importcheeriofrom"https://gitcode.net/qq_32394351/dr_py/-/raw/master/libs/cheerio.min.js";import"https://gitcode.net/qq_32394351/dr_py/-/raw/master/libs/crypto-js.js";import"https://gitcode.net/qq_32394351/dr_py/-/raw/master/libs/drT.js";functioninit_test(){console.log("init_test_start");console.log("当前版本号:"+VERSION);console.log(RKEY);console.log(JSON.stringify(rule));console.log("init_test_end")}functionpre(){if(typeofrule.预处理==="string"&&rule.预处理&&rule.预处理.trim()){letcode=rule.预处理.trim();console.log("执行预处理代码:"+code);if(code.startsWith("js:")){code=code.replace("js:","")}try{eval(code)}catch(e){console.log("预处理执行失败:"+e.message)}}}letrule={};constVERSION="3.9.18";constMOBILE_UA="Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36";constPC_UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36";constUA="Mozilla/5.0";constUC_UA="Mozilla/5.0 (Linux; U; Android 9; zh-CN; MI 9 Build/PKQ1.181121.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.5.5.1035 Mobile Safari/537.36";constIOS_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";constRULE_CK="cookie";constCATE_EXCLUDE="首页|留言|APP|下载|资讯|新闻|动态";constTAB_EXCLUDE="猜你|喜欢|APP|下载|剧情|热播";constOCR_RETRY=3;constOCR_API="http://cms.nokia.press:5706/parse/ocr";if(typeofMY_URL==="undefined"){varMY_URL}varRKEY;varfetch;varprint;varlog;varrule_fetch_params;varfetch_params;varoheaders;var_pdfh;var_pdfa;var_pd;constDOM_CHECK_ATTR=/(url|src|href|-original|-src|-play|-url)$/;constSELECT_REGEX=/:eq|:lt|:gt|#/g;constSELECT_REGEX_A=/:eq|:lt|:gt/g;if(typeofObject.assign!="function"){Object.assign=function(){vartarget=arguments[0];for(vari=1;i<arguments.length;i++){varsource=arguments[i];for(varkeyinsource){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}returntarget}}if(!String.prototype.includes){String.prototype.includes=function(search,start){if(typeofstart!=="number"){start=0}if(start+search.length>this.length){returnfalse}else{returnthis.indexOf(search,start)!==-1}}}if(!Array.prototype.includes){Object.defineProperty(Array.prototype,"includes",{value:function(searchElement,fromIndex){if(this==null){thrownewTypeError('"this" is null or not defined')}varo=Object(this);varlen=o.length>>>0;if(len===0){returnfalse}varn=fromIndex|0;vark=Math.max(n>=0?n:len-Math.abs(n),0);while(k<len){if(o[k]===searchElement){returntrue}k++}returnfalse}})}if(typeofString.prototype.startsWith!="function"){String.prototype.startsWith=function(prefix){returnthis.slice(0,prefix.length)===prefix}}if(typeofString.prototype.endsWith!="function"){String.prototype.endsWith=function(suffix){returnthis.indexOf(suffix,this.length-suffix.length)!==-1}}Object.prototype.myValues=function(obj){if(obj==null){thrownewTypeError("Cannot convert undefined or null to object")}varres=[];for(varkinobj){if(obj.hasOwnProperty(k)){res.push(obj[k])}}returnres};if(typeofObject.prototype.values!="function"){Object.prototype.values=function(obj){if(obj==null){thrownewTypeError("Cannot convert undefined or null to object")}varres=[];for(varkinobj){if(obj.hasOwnProperty(k)){res.push(obj[k])}}returnres}}if(typeofArray.prototype.join!="function"){Array.prototype.join=function(emoji){emoji=emoji||"";letself=this;letstr="";leti=0;if(!Array.isArray(self)){throwString(self)+"is not Array"}if(self.length===0){return""}if(self.length===1){returnString(self[0])}i=1;str=this[0];for(;i<self.length;i++){str+=String(emoji)+String(self[i])}returnstr}}String.prototype.rstrip=function(chars){letregex=newRegExp(chars+"$");returnthis.replace(regex,"")};Array.prototype.append=Array.prototype.push;String.prototype.strip=String.prototype.trim;function是否正版(vipUrl){letflag=newRegExp("qq.com|iqiyi.com|youku.com|mgtv.com|bilibili.com|sohu.com|ixigua.com|pptv.com|miguvideo.com|le.com|1905.com|fun.tv");returnflag.test(vipUrl)}functionurlDeal(vipUrl){if(!vipUrl){return""}if(!是否正版(vipUrl)){returnvipUrl}if(!/miguvideo/.test(vipUrl)){vipUrl=vipUrl.split("#")[0].split("?")[0]}returnvipUrl}functionsetResult(d){if(!Array.isArray(d)){return[]}VODS=[];d.forEach(function(it){letobj={vod_id:it.url||"",vod_name:it.title||"",vod_remarks:it.desc||"",vod_content:it.content||"",vod_pic:it.pic_url||it.img||""};letkeys=Object.keys(it);if(keys.includes("tname")){obj.type_name=it.tname||""}if(keys.includes("tid")){obj.type_id=it.tid||""}if(keys.includes("year")){obj.vod_year=it.year||""}if(keys.includes("actor")){obj.vod_actor=it.actor||""}if(keys.includes("director")){obj.vod_director=it.director||""}if(keys.includes("area")){obj.vod_area=it.area||""}VODS.push(obj)});returnVODS}functionsetResult2(res){VODS=res.list||[];returnVODS}functionsetHomeResult(res){if(!res||typeofres!=="object"){return[]}returnsetResult(res.list)}functionrc(js){if(js==="maomi_aes.js"){vara=CryptoJS.enc.Utf8.parse("625222f9149e961d");vart=CryptoJS.enc.Utf8.parse("5efdtf6060e2o330");return{De:function(word){word=CryptoJS.enc.Hex.parse(word);returnCryptoJS.AES.decrypt(CryptoJS.enc.Base64.stringify(word),a,{iv:t,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)},En:function(word){varEncrypted=CryptoJS.AES.encrypt(word,a,{iv:t,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});returnEncrypted.ciphertext.toString()}}}return{}}functionmaoss(jxurl,ref,key){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));eval(getCryptoJS());try{vargetVideoInfo=function(text){returnCryptoJS.AES.decrypt(text,key,{iv:iv,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)};vartoken_key=key==undefined?"dvyYRQlnPRCMdQSe":key;if(ref){varhtml=request(jxurl,{headers:{Referer:ref}})}else{varhtml=request(jxurl)}if(html.indexOf("&btwaf=")!=-1){html=request(jxurl+"&btwaf"+html.match(/&btwaf(.*?)"/)[1],{headers:{Referer:ref}})}vartoken_iv=html.split('_token = "')[1].split('"')[0];varkey=CryptoJS.enc.Utf8.parse(token_key);variv=CryptoJS.enc.Utf8.parse(token_iv);eval(html.match(/var config = {[\s\S]*?}/)[0]+"");if(!config.url.startsWith("http")){config.url=CryptoJS.AES.decrypt(config.url,key,{iv:iv,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)}returnconfig.url}catch(e){return""}}functionurlencode(str){str=(str+"").toString();returnencodeURIComponent(str).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")}functionbase64Encode(text){returnCryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(text))}functionbase64Decode(text){returnCryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(text))}functionmd5(text){returnCryptoJS.MD5(text).toString()}functiongetCryptoJS(){return'console.log("CryptoJS已装载");'}letVODS=[];letVOD={};letTABS=[];letLISTS=[];globalThis.encodeUrl=urlencode;globalThis.urlencode=urlencode;functionurljoin(fromPath,nowPath){fromPath=fromPath||"";nowPath=nowPath||"";returnjoinUrl(fromPath,nowPath)}varurljoin2=urljoin;constdefaultParser={pdfh:pdfh,pdfa:pdfa,pd(html,parse,uri){letret=this.pdfh(html,parse);if(typeofuri==="undefined"||!uri){uri=""}if(DOM_CHECK_ATTR.test(parse)){if(/http/.test(ret)){ret=ret.substr(ret.indexOf("http"))}else{ret=urljoin(MY_URL,ret)}}returnret}};functionpdfh2(html,parse){lethtml2=html;try{if(typeofhtml!=="string"){html2=html.rr(html.ele).toString()}}catch(e){print("html对象转文本发生了错误:"+e.message)}letresult=defaultParser.pdfh(html2,parse);letoption=parse.includes("&&")?parse.split("&&").slice(-1)[0]:parse.split("").slice(-1)[0];if(/style/.test(option.toLowerCase())&&/url\(/.test(result)){try{result=result.match(/url\((.*?)\)/)[1]}catch(e){}}returnresult}functionpdfa2(html,parse){lethtml2=html;try{if(typeofhtml!=="string"){html2=html.rr(html.ele).toString()}}catch(e){print("html对象转文本发生了错误:"+e.message)}returndefaultParser.pdfa(html2,parse)}functionpd2(html,parse,uri){letret=pdfh2(html,parse);if(typeofuri==="undefined"||!uri){uri=""}if(DOM_CHECK_ATTR.test(parse)){if(/http/.test(ret)){ret=ret.substr(ret.indexOf("http"))}else{ret=urljoin(MY_URL,ret)}}returnret}constparseTags={jsp:{pdfh:pdfh2,pdfa:pdfa2,pd:pd2},json:{pdfh(html,parse){if(!parse||!parse.trim()){return""}if(typeofhtml==="string"){html=JSON.parse(html)}parse=parse.trim();if(!parse.startsWith("$.")){parse="$."+parse}parse=parse.split("||");for(letpsofparse){letret=cheerio.jp(ps,html);if(Array.isArray(ret)){ret=ret[0]||""}else{ret=ret||""}if(ret&&typeofret!=="string"){ret=ret.toString()}if(ret){returnret}}return""},pdfa(html,parse){if(!parse||!parse.trim()){return""}if(typeofhtml==="string"){html=JSON.parse(html)}parse=parse.trim();if(!parse.startsWith("$.")){parse="$."+parse}letret=cheerio.jp(parse,html);if(Array.isArray(ret)&&Array.isArray(ret[0])&&ret.length===1){returnret[0]||[]}returnret||[]},pd(html,parse){letret=parseTags.json.pdfh(html,parse);if(ret){returnurljoin(MY_URL,ret)}returnret}},jq:{pdfh(html,parse,base_url){if(!parse||!parse.trim()){return""}leteleFind=typeofhtml==="object";letoption=undefined;if(eleFind&&parse.startsWith("body&&")){parse=parse.substr(6);if(parse.indexOf("&&")<0){option=parse.trim();parse="*=*"}}if(parse.indexOf("&&")>-1){letsp=parse.split("&&");option=sp[sp.length-1];sp.splice(sp.length-1);if(sp.length>1){for(letiinsp){if(sp.hasOwnProperty(i)){if(!SELECT_REGEX.test(sp[i])){sp[i]=sp[i]+":eq(0)"}}}}else{if(!SELECT_REGEX.test(sp[0])){sp[0]=sp[0]+":eq(0)"}}parse=sp.join("")}letresult="";const$=eleFind?html.rr:cheerio.load(html);letret=eleFind?parse==="*=*"||$(html.ele).is(parse)?html.ele:$(html.ele).find(parse):$(parse);if(option){if(option==="Text"){result=$(ret).text()}elseif(option==="Html"){result=$(ret).html()}else{result=$(ret).attr(option);if(/style/.test(option.toLowerCase())&&/url\(/.test(result)){try{result=result.match(/url\((.*?)\)/)[1]}catch(e){}}}if(result&&base_url&&DOM_CHECK_ATTR.test(option)){if(/http/.test(result)){result=result.substr(result.indexOf("http"))}else{result=urljoin(base_url,result)}}}else{result=$(ret).toString()}returnresult},pdfa(html,parse){if(!parse||!parse.trim()){print("!parse");return[]}leteleFind=typeofhtml==="object";if(parse.indexOf("&&")>-1){letsp=parse.split("&&");for(letiinsp){if(sp.hasOwnProperty(i)){if(!SELECT_REGEX_A.test(sp[i])&&i<sp.length-1){if(sp[i]!=="body"){sp[i]=sp[i]+":first"}}}}parse=sp.join("")}const$=eleFind?html.rr:cheerio.load(html);letret=eleFind?$(html.ele).is(parse)?html.ele:$(html.ele).find(parse):$(parse);letresult=[];if(ret){ret.each(function(idx,ele){result.push({rr:$,ele:ele})})}returnresult},pd(html,parse,uri){returnparseTags.jq.pdfh(html,parse,MY_URL)}},getParse(p0){if(p0.startsWith("jsp:")){returnthis.jsp}elseif(p0.startsWith("json:")){returnthis.json}elseif(p0.startsWith("jq:")){returnthis.jq}else{returnthis.jq}}};conststringify=JSON.stringify;constjsp=parseTags.jsp;constjq=parseTags.jq;functionreadFile(filePath){filePath=filePath||"./uri.min.js";varfd=os.open(filePath);varbuffer=newArrayBuffer(1024);varlen=os.read(fd,buffer,0,1024);console.log(len);lettext=String.fromCharCode.apply(null,newUint8Array(buffer));console.log(text);returntext}functiondealJson(html){try{html=html.trim();if(!(html.startsWith("{")&&html.endsWith("}")||html.startsWith("[")&&html.endsWith("]"))){html="{"+html.match(/.*?\{(.*)\}/m)[1]+"}"}}catch(e){}try{html=JSON.parse(html)}catch(e){}returnhtml}varOcrApi={api:OCR_API,classification:function(img){letcode="";try{lethtml=request(this.api,{data:{img:img},headers:{"User-Agent":PC_UA},method:"POST"},true);html=JSON.parse(html);code=html.url||""}catch(e){}returncode}};functionverifyCode(url){letcnt=0;lethost=getHome(url);letcookie="";while(cnt<OCR_RETRY){try{letyzm_url=`${host}/index.php/verify/index.html`;console.log(`验证码链接:${yzm_url}`);lethhtml=request(yzm_url,{withHeaders:true,toBase64:true},true);letjson=JSON.parse(hhtml);if(!cookie){letsetCk=Object.keys(json).find(it=>it.toLowerCase()==="set-cookie");cookie=setCk?json[setCk].split(";")[0]:""}console.log("cookie:"+cookie);letimg=json.body;letcode=OcrApi.classification(img);console.log(`第${cnt+1}次验证码识别结果:${code}`);letsubmit_url=`${host}/index.php/ajax/verify_check?type=search&verify=${code}`;console.log(submit_url);lethtml=request(submit_url,{headers:{Cookie:cookie,"User-Agent":MOBILE_UA},method:"POST"});html=JSON.parse(html);if(html.msg==="ok"){console.log(`第${cnt+1}次验证码提交成功`);returncookie}elseif(html.msg!=="ok"&&cnt+1>=OCR_RETRY){cookie=""}}catch(e){console.log(`第${cnt+1}次验证码提交失败:${e.message}`);if(cnt+1>=OCR_RETRY){cookie=""}}cnt+=1}returncookie}functionsetItem(k,v){local.set(RKEY,k,v);console.log(`规则${RKEY}设置${k} => ${v}`)}functiongetItem(k,v){returnlocal.get(RKEY,k)||v}functionclearItem(k){local.delete(RKEY,k)}functiongetHome(url){if(!url){return""}lettmp=url.split("//");url=tmp[0]+"//"+tmp[1].split("/")[0];try{url=decodeURIComponent(url)}catch(e){}returnurl}functionbuildUrl(url,obj){obj=obj||{};if(url.indexOf("?")<0){url+="?"}letparam_list=[];letkeys=Object.keys(obj);keys.forEach(it=>{param_list.push(it+"="+obj[it])});letprs=param_list.join("&");if(keys.length>0&&!url.endsWith("?")){url+="&"}url+=prs;returnurl}functionrequire(url){eval(request(url))}functionrequest(url,obj,ocr_flag){ocr_flag=ocr_flag||false;if(typeofobj==="undefined"||!obj||obj==={}){if(!fetch_params||!fetch_params.headers){letheaders={"User-Agent":MOBILE_UA};if(rule.headers){Object.assign(headers,rule.headers)}fetch_params.headers=headers}if(!fetch_params.headers.Referer){fetch_params.headers.Referer=getHome(url)}obj=fetch_params}else{letheaders=obj.headers||{};letkeys=Object.keys(headers).map(it=>it.toLowerCase());if(!keys.includes("user-agent")){headers["User-Agent"]=MOBILE_UA}if(!keys.includes("referer")){headers["Referer"]=getHome(url)}obj.headers=headers}if(rule.encoding&&rule.encoding!=="utf-8"&&!ocr_flag){if(!obj.headers.hasOwnProperty("Content-Type")){obj.headers["Content-Type"]="text/html; charset="+rule.encoding}}if(typeofobj.body!="undefined"&&obj.body&&typeofobj.body==="string"){letdata={};obj.body.split("&").forEach(it=>{data[it.split("=")[0]]=it.split("=")[1]});obj.data=data;deleteobj.body}elseif(typeofobj.body!="undefined"&&obj.body&&typeofobj.body==="object"){obj.data=obj.body;deleteobj.body}if(!url){returnobj.withHeaders?"{}":""}if(obj.toBase64){obj.buffer=2;deleteobj.toBase64}console.log(JSON.stringify(obj.headers));console.log("request:"+url);letres=req(url,obj);lethtml=res.content||"";if(obj.withHeaders){lethtmlWithHeaders=res.headers;htmlWithHeaders.body=html;returnJSON.stringify(htmlWithHeaders)}else{returnhtml}}functionpost(url,obj){obj.method="POST";returnrequest(url,obj)}fetch=request;print=function(data){data=data||"";if(typeofdata!=="string"){try{data=JSON.stringify(data)}catch(e){console.log("print:"+e.message)}}if(typeofdata!=="string"){console.log(typeofdata+":"+data.length)}else{console.log(data)}};log=print;functioncheckHtml(html,url,obj){if(/\?btwaf=/.test(html)){letbtwaf=html.match(/btwaf(.*?)"/)[1];url=url.split("#")[0]+"?btwaf"+btwaf;print("宝塔验证访问链接:"+url);html=request(url,obj)}returnhtml}functiongetCode(url,obj){lethtml=request(url,obj);html=checkHtml(html,url,obj);returnhtml}functiongetHtml(url){letobj={};if(rule.headers){obj.headers=rule.headers}letcookie=getItem(RULE_CK,"");if(cookie){if(obj.headers&&!Object.keys(obj.headers).map(it=>it.toLowerCase()).includes("cookie")){obj.headers["Cookie"]=cookie}elseif(!obj.headers){obj.headers={Cookie:cookie}}}lethtml=getCode(url,obj);returnhtml}functionhomeParse(homeObj){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));letclasses=[];if(homeObj.class_name&&homeObj.class_url){letnames=homeObj.class_name.split("&");leturls=homeObj.class_url.split("&");letcnt=Math.min(names.length,urls.length);for(leti=0;i<cnt;i++){classes.push({type_id:urls[i],type_name:names[i]})}}if(homeObj.class_parse){letp=homeObj.class_parse.split(";");let_ps=parseTags.getParse(p[0]);_pdfa=_ps.pdfa;_pdfh=_ps.pdfh;_pd=_ps.pd;MY_URL=rule.url;if(p.length>=3){try{lethtml=getHtml(homeObj.MY_URL);if(html){homeHtmlCache=html;letlist=_pdfa(html,p[0]);if(list&&list.length>0){list.forEach((it,idex)=>{try{letname=_pdfh(it,p[1]);if(homeObj.cate_exclude&&newRegExp(homeObj.cate_exclude).test(name)){return}leturl=_pd(it,p[2]);if(p.length>3&&p[3]){letexp=newRegExp(p[3]);url=url.match(exp)[1]}classes.push({type_id:url.trim(),type_name:name.trim()})}catch(e){console.log(`分类列表定位第${idex}个元素正常报错:${e.message}`)}})}}}catch(e){console.log(e.message)}}}classes=classes.filter(it=>!homeObj.cate_exclude||!newRegExp(homeObj.cate_exclude).test(it.type_name));letresp={class:classes};if(homeObj.filter){resp.filters=homeObj.filter}console.log(JSON.stringify(resp));returnJSON.stringify(resp)}functiongetPP(p,pn,pp,ppn){letps=p[pn]==="*"&&pp.length>ppn?pp[ppn]:p[pn];returnps}functionhomeVodParse(homeVodObj){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));letd=[];MY_URL=homeVodObj.homeUrl;console.log(MY_URL);lett1=(newDate).getTime();letp=homeVodObj.推荐;print("p:"+p);if(p==="*"&&rule.一级){p=rule.一级;homeVodObj.double=false}if(!p||typeofp!=="string"){return"{}"}p=p.trim();letpp=rule.一级.split(";");if(p.startsWith("js:")){constTYPE="home";varinput=MY_URL;constHOST=rule.host;eval(p.replace("js:",""));d=VODS}else{p=p.split(";");if(!homeVodObj.double&&p.length<5){return"{}"}elseif(homeVodObj.double&&p.length<6){return"{}"}letp0=getPP(p,0,pp,0);let_ps=parseTags.getParse(p0);_pdfa=_ps.pdfa;_pdfh=_ps.pdfh;_pd=_ps.pd;letis_json=p0.startsWith("json:");p0=p0.replace(/^(jsp:|json:|jq:)/,"");lethtml=homeHtmlCache||getHtml(MY_URL);homeHtmlCache=undefined;if(is_json){html=dealJson(html)}try{console.log("double:"+homeVodObj.double);if(homeVodObj.double){letitems=_pdfa(html,p0);for(letitemofitems){letitems2=_pdfa(item,p[1]);for(letitem2ofitems2){try{letp2=getPP(p,2,pp,1);lettitle=_pdfh(item2,p2);letimg="";try{letp3=getPP(p,3,pp,2);img=_pd(item2,p3)}catch(e){}letdesc="";try{letp4=getPP(p,4,pp,3);desc=_pdfh(item2,p4)}catch(e){}letp5=getPP(p,5,pp,4);letlinks=[];for(let_p5ofp5.split("+")){letlink=!homeVodObj.detailUrl?_pd(item2,_p5,MY_URL):_pdfh(item2,_p5);links.push(link)}letcontent;if(p.length>6&&p[6]){letp6=getPP(p,6,pp,5);content=_pdfh(item2,p6)}else{content=""}letvid=links.join("$");if(rule.二级==="*"){vid=vid+"@@"+title+"@@"+img}letvod={vod_name:title,vod_pic:img,vod_remarks:desc,vod_content:content,vod_id:vid};d.push(vod)}catch(e){console.log("首页列表处理发生错误:"+e.message)}}}}else{letitems=_pdfa(html,p0);for(letitemofitems){try{letp1=getPP(p,1,pp,1);lettitle=_pdfh(item,p1);letimg="";try{letp2=getPP(p,2,pp,2);img=_pd(item,p2,MY_URL)}catch(e){}letdesc="";try{letp3=getPP(p,3,pp,3);desc=_pdfh(item,p3)}catch(e){}letp4=getPP(p,4,pp,4);letlinks=[];for(let_p5ofp4.split("+")){letlink=!homeVodObj.detailUrl?_pd(item,_p5,MY_URL):_pdfh(item,_p5);links.push(link)}letcontent;if(p.length>5&&p[5]){letp5=getPP(p,5,pp,5);content=_pdfh(item,p5)}else{content=""}letvid=links.join("$");if(rule.二级==="*"){vid=vid+"@@"+title+"@@"+img}letvod={vod_name:title,vod_pic:img,vod_remarks:desc,vod_content:content,vod_id:vid};d.push(vod)}catch(e){}}}}catch(e){}}lett2=(newDate).getTime();console.log("加载首页推荐耗时:"+(t2-t1)+"毫秒");if(rule.图片来源){d.forEach(it=>{if(it.vod_pic&&it.vod_pic.startsWith("http")){it.vod_pic=it.vod_pic+rule.图片来源}})}returnJSON.stringify({list:d})}functioncategoryParse(cateObj){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));letp=cateObj.一级;if(!p||typeofp!=="string"){return"{}"}letd=[];leturl=cateObj.url.replaceAll("fyclass",cateObj.tid);if(rule.filter_url){if(!/fyfilter/.test(url)){if(!url.endsWith("&")&&!rule.filter_url.startsWith("&")){url+="&"}url+=rule.filter_url}else{url=url.replace("fyfilter",rule.filter_url)}letfl=cateObj.filter?cateObj.extend:{};if(rule.filter_def&&typeofrule.filter_def==="object"){try{if(Object.keys(rule.filter_def).length>0&&rule.filter_def.hasOwnProperty(cateObj.tid)){letself_fl_def=rule.filter_def[cateObj.tid];if(self_fl_def&&typeofself_fl_def==="object"){letfl_def=JSON.parse(JSON.stringify(self_fl_def));fl=Object.assign(fl_def,fl)}}}catch(e){print("合并不同分类对应的默认筛选出错:"+e.message)}}letnew_url;new_url=cheerio.jinja2(url,{fl:fl});if(/object Object/.test(new_url)){new_url=drT.renderText(url,fl)}url=new_url}if(/fypage/.test(url)){if(url.includes("(")&&url.includes(")")){leturl_rep=url.match(/.*?\((.*)\)/)[1];letcnt_page=url_rep.replaceAll("fypage",cateObj.pg);letcnt_pg=eval(cnt_page);url=url.replaceAll(url_rep,cnt_pg).replaceAll("(","").replaceAll(")","")}else{url=url.replaceAll("fypage",cateObj.pg)}}if(cateObj.pg===1&&url.includes("[")&&url.includes("]")){url=url.split("[")[1].split("]")[0]}elseif(cateObj.pg>1&&url.includes("[")&&url.includes("]")){url=url.split("[")[0]}MY_URL=url;console.log(MY_URL);p=p.trim();constMY_CATE=cateObj.tid;if(p.startsWith("js:")){varMY_FL=cateObj.extend;constTYPE="cate";varinput=MY_URL;constMY_PAGE=cateObj.pg;vardesc="";eval(p.trim().replace("js:",""));d=VODS}else{p=p.split(";");if(p.length<5){return"{}"}let_ps=parseTags.getParse(p[0]);_pdfa=_ps.pdfa;_pdfh=_ps.pdfh;_pd=_ps.pd;letis_json=p[0].startsWith("json:");p[0]=p[0].replace(/^(jsp:|json:|jq:)/,"");try{lethtml=getHtml(MY_URL);if(html){if(is_json){html=dealJson(html)}letlist=_pdfa(html,p[0]);list.forEach(it=>{letlinks=p[4].split("+").map(p4=>{return!rule.detailUrl?_pd(it,p4,MY_URL):_pdfh(it,p4)});letlink=links.join("$");letvod_id=rule.detailUrl?MY_CATE+"$"+link:link;letvod_name=_pdfh(it,p[1]).replace(/\n|\t/g,"").trim();letvod_pic=_pd(it,p[2],MY_URL);if(rule.二级==="*"){vod_id=vod_id+"@@"+vod_name+"@@"+vod_pic}d.push({vod_id:vod_id,vod_name:vod_name,vod_pic:vod_pic,vod_remarks:_pdfh(it,p[3]).replace(/\n|\t/g,"").trim()})})}}catch(e){console.log(e.message)}}if(rule.图片来源){d.forEach(it=>{if(it.vod_pic&&it.vod_pic.startsWith("http")){it.vod_pic=it.vod_pic+rule.图片来源}})}returnd.length<1?"{}":JSON.stringify({page:parseInt(cateObj.pg),pagecount:999,limit:20,total:999,list:d})}functionsearchParse(searchObj){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));letd=[];if(!searchObj.searchUrl){return"{}"}letp=searchObj.搜索==="*"&&rule.一级?rule.一级:searchObj.搜索;if(!p||typeofp!=="string"){return"{}"}p=p.trim();letpp=rule.一级.split(";");leturl=searchObj.searchUrl.replaceAll("**",searchObj.wd).replaceAll("fypage",searchObj.pg);MY_URL=url;console.log(MY_URL);if(p.startsWith("js:")){constTYPE="search";constMY_PAGE=searchObj.pg;constKEY=searchObj.wd;varinput=MY_URL;vardetailUrl=rule.detailUrl||"";eval(p.trim().replace("js:",""));d=VODS}else{p=p.split(";");if(p.length<5){return"{}"}letp0=getPP(p,0,pp,0);let_ps=parseTags.getParse(p0);_pdfa=_ps.pdfa;_pdfh=_ps.pdfh;_pd=_ps.pd;letis_json=p0.startsWith("json:");p0=p0.replace(/^(jsp:|json:|jq:)/,"");try{lethtml=getHtml(MY_URL);if(html){if(/系统安全验证|输入验证码/.test(html)){letcookie=verifyCode(MY_URL);if(cookie){console.log(`本次成功过验证,cookie:${cookie}`);setItem(RULE_CK,cookie)}else{console.log(`本次自动过搜索验证失败,cookie:${cookie}`)}html=getHtml(MY_URL)}if(!html.includes(searchObj.wd)){console.log("搜索结果源码未包含关键字,疑似搜索失败,正为您打印结果源码");console.log(html)}if(is_json){html=dealJson(html)}console.log(JSON.stringify(html));console.log(html);letlist=_pdfa(html,p0);list.forEach(it=>{letp1=getPP(p,1,pp,1);letp2=getPP(p,2,pp,2);letp3=getPP(p,3,pp,3);letp4=getPP(p,4,pp,4);letlinks=p4.split("+").map(_p4=>{return!rule.detailUrl?_pd(it,_p4,MY_URL):_pdfh(it,_p4)});letlink=links.join("$");letcontent;if(p.length>5&&p[5]){letp5=getPP(p,5,pp,5);content=_pdfh(it,p5)}else{content=""}letvod_id=link;letvod_name=_pdfh(it,p1).replace(/\n|\t/g,"").trim();letvod_pic=_pd(it,p2,MY_URL);if(rule.二级==="*"){vod_id=vod_id+"@@"+vod_name+"@@"+vod_pic}letob={vod_id:vod_id,vod_name:vod_name,vod_pic:vod_pic,vod_remarks:_pdfh(it,p3).replace(/\n|\t/g,"").trim(),vod_content:content.replace(/\n|\t/g,"").trim()};d.push(ob)})}}catch(e){print("搜索发生错误:"+e.message);return"{}"}}if(rule.图片来源){d.forEach(it=>{if(it.vod_pic&&it.vod_pic.startsWith("http")){it.vod_pic=it.vod_pic+rule.图片来源}})}returnJSON.stringify({page:parseInt(searchObj.pg),pagecount:10,limit:20,total:100,list:d})}functiondetailParse(detailObj){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));letorId=detailObj.orId;letvod_name="片名";letvod_pic="";letvod_id=orId;if(rule.二级==="*"){letextra=orId.split("@@");vod_name=extra.length>1?extra[1]:vod_name;vod_pic=extra.length>2?extra[2]:vod_pic}letvod={vod_id:vod_id,vod_name:vod_name,vod_pic:vod_pic,type_name:"类型",vod_year:"年份",vod_area:"地区",vod_remarks:"更新信息",vod_actor:"主演",vod_director:"导演",vod_content:"简介"};letp=detailObj.二级;leturl=detailObj.url;letdetailUrl=detailObj.detailUrl;letfyclass=detailObj.fyclass;lettab_exclude=detailObj.tab_exclude;lethtml=detailObj.html||"";MY_URL=url;console.log(MY_URL);if(p==="*"){vod.vod_play_from="道长在线";vod.vod_remarks=detailUrl;vod.vod_actor="没有二级,只有一级链接直接嗅探播放";vod.vod_content=MY_URL;vod.vod_play_url="嗅探播放$"+MY_URL.split("@@")[0]}elseif(typeofp==="string"&&p.trim().startsWith("js:")){constTYPE="detail";varinput=MY_URL;varplay_url="";eval(p.trim().replace("js:",""));vod=VOD;console.log(JSON.stringify(vod))}elseif(p&&typeofp==="object"){if(!html){html=getHtml(MY_URL)}let_impJQP=true;let_ps;if(p.is_json){_ps=parseTags.json;html=dealJson(html);_impJQP=false}elseif(p.is_jsp){_ps=parseTags.jsp}elseif(p.is_jq){_ps=parseTags.jq}else{_ps=parseTags.jq}if(_impJQP){letc$=cheerio.load(html);html={rr:c$,ele:c$("html")[0]}}_pdfa=_ps.pdfa;_pdfh=_ps.pdfh;_pd=_ps.pd;if(p.title){letp1=p.title.split(";");vod.vod_name=_pdfh(html,p1[0]).replace(/\n|\t/g,"").trim();lettype_name=p1.length>1?_pdfh(html,p1[1]).replace(/\n|\t/g,"").replace(/ /g,"").trim():"";vod.type_name=type_name||vod.type_name}if(p.desc){try{letp1=p.desc.split(";");vod.vod_remarks=_pdfh(html,p1[0]).replace(/\n|\t/g,"").trim();vod.vod_year=p1.length>1?_pdfh(html,p1[1]).replace(/\n|\t/g,"").trim():"";vod.vod_area=p1.length>2?_pdfh(html,p1[2]).replace(/\n|\t/g,"").trim():"";vod.vod_actor=p1.length>3?_pdfh(html,p1[3]).replace(/\n|\t/g,"").trim():"";vod.vod_director=p1.length>4?_pdfh(html,p1[4]).replace(/\n|\t/g,"").trim():""}catch(e){}}if(p.content){try{letp1=p.content.split(";");vod.vod_content=_pdfh(html,p1[0]).replace(/\n|\t/g,"").trim()}catch(e){}}if(p.img){try{letp1=p.img.split(";");vod.vod_pic=_pd(html,p1[0],MY_URL)}catch(e){}}letvod_play_from="$$$";letplayFrom=[];if(p.重定向&&p.重定向.startsWith("js:")){print("开始执行重定向代码:"+p.重定向);html=eval(p.重定向.replace("js:",""));if(_impJQP){letc$=cheerio.load(html);html={rr:c$,ele:c$("html")[0]}}}if(p.tabs){if(p.tabs.startsWith("js:")){print("开始执行tabs代码:"+p.tabs);if(html&&typeofhtml!=="string"){try{html=html.rr(html.ele).toString()}catch(e){}}varinput=MY_URL;eval(p.tabs.replace("js:",""));playFrom=TABS}else{letp_tab=p.tabs.split(";")[0];letvHeader=_pdfa(html,p_tab);console.log(vHeader.length);lettab_text=p.tab_text||"body&&Text";for(letvofvHeader){letv_title=_pdfh(v,tab_text).trim();console.log(v_title);if(tab_exclude&&newRegExp(tab_exclude).test(v_title)){continue}playFrom.push(v_title)}}console.log(JSON.stringify(playFrom))}else{playFrom=["道长在线"]}vod.vod_play_from=playFrom.join(vod_play_from);letvod_play_url="$$$";letvod_tab_list=[];if(p.lists){if(p.lists.startsWith("js:")){print("开始执行lists代码:"+p.lists);try{if(html&&typeofhtml!=="string"){try{html=html.rr(html.ele).toString()}catch(e){}}varinput=MY_URL;varplay_url="";eval(p.lists.replace("js:",""));for(letiinLISTS){if(LISTS.hasOwnProperty(i)){try{LISTS[i]=LISTS[i].map(it=>it.split("$").slice(0,2).join("$"))}catch(e){print("格式化LISTS发生错误:"+e.message)}}}vod_play_url=LISTS.map(it=>it.join("#")).join(vod_play_url)}catch(e){print("js执行lists: 发生错误:"+e.message)}}else{letlist_text=p.list_text||"body&&Text";letlist_url=p.list_url||"a&&href";letis_tab_js=p.tabs.trim().startsWith("js:");for(leti=0;i<playFrom.length;i++){lettab_name=playFrom[i];lettab_ext=p.tabs.split(";").length>1&&!is_tab_js?p.tabs.split(";")[1]:"";letp1=p.lists.replaceAll("#idv",tab_name).replaceAll("#id",i);tab_ext=tab_ext.replaceAll("#idv",tab_name).replaceAll("#id",i);console.log(p1);letvodList=[];try{vodList=_pdfa(html,p1);console.log("len(vodList):"+vodList.length)}catch(e){}letnew_vod_list=[];lettabName=tab_ext?_pdfh(html,tab_ext):tab_name;console.log(tabName);vodList.forEach(it=>{new_vod_list.push(_pdfh(it,list_text).trim()+"$"+_pd(it,list_url,MY_URL))});letvlist=new_vod_list.join("#");vod_tab_list.push(vlist)}vod_play_url=vod_tab_list.join(vod_play_url)}}vod.vod_play_url=vod_play_url}if(rule.图片来源&&vod.vod_pic&&vod.vod_pic.startsWith("http")){vod.vod_pic=vod.vod_pic+rule.图片来源}if(!vod.vod_id){vod.vod_id=vod_id}returnJSON.stringify({list:[vod]})}functiontellIsJx(url){try{letis_vip=!/\.(m3u8|mp4|m4a)$/.test(url.split("?")[0])&&是否正版(url);returnis_vip?1:0}catch(e){return1}}functionplayParse(playObj){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));MY_URL=playObj.url;if(!/http/.test(MY_URL)){try{MY_URL=base64Decode(MY_URL)}catch(e){}}MY_URL=decodeURIComponent(MY_URL);varinput=MY_URL;letcommon_play={parse:1,url:input,jx:tellIsJx(input)};letlazy_play;if(!rule.play_parse||!rule.lazy){lazy_play=common_play}elseif(rule.play_parse&&rule.lazy&&typeofrule.lazy==="string"){try{letlazy_code=rule.lazy.replace("js:","").trim();print("开始执行js免嗅=>"+lazy_code);eval(lazy_code);lazy_play=typeofinput==="object"?input:{parse:1,jx:tellIsJx(input),url:input}}catch(e){print("js免嗅错误:"+e.message);lazy_play=common_play}}else{lazy_play=common_play}if(Array.isArray(rule.play_json)&&rule.play_json.length>0){letweb_url=lazy_play.url;for(letpjsonofrule.play_json){if(pjson.re&&(pjson.re==="*"||web_url.match(newRegExp(pjson.re)))){if(pjson.json&&typeofpjson.json==="object"){letbase_json=pjson.json;lazy_play=Object.assign(lazy_play,base_json);break}}}}elseif(rule.play_json&&!Array.isArray(rule.play_json)){letbase_json={jx:1,parse:1};lazy_play=Object.assign(lazy_play,base_json)}elseif(!rule.play_json){letbase_json={jx:0,parse:1};lazy_play=Object.assign(lazy_play,base_json)}console.log(JSON.stringify(lazy_play));returnJSON.stringify(lazy_play)}functioninit(ext){console.log("init");try{if(typeofglobalThis.mubanJs==="undefined"){letmubanJs=request("https://gitcode.net/qq_32394351/dr_py/-/raw/master/js/模板.js",{"User-Agent":MOBILE_UA});mubanJs=mubanJs.replace("export default","(function() {return muban;}()) // export default");globalThis.mubanJs=mubanJs}letmuban=eval(globalThis.mubanJs);if(typeofext=="object"){rule=ext}elseif(typeofext=="string"){if(ext.startsWith("http")){letjs=request(ext,{method:"GET"});if(js){eval(js.replace("var rule","rule"))}}}else{eval(ext.replace("var rule","rule"))}if(rule.模板&&muban.hasOwnProperty(rule.模板)){print("继承模板:"+rule.模板);rule=Object.assign(muban[rule.模板],rule)}letrule_cate_excludes=(rule.cate_exclude||"").split("|").filter(it=>it.trim());letrule_tab_excludes=(rule.tab_exclude||"").split("|").filter(it=>it.trim());rule_cate_excludes=rule_cate_excludes.concat(CATE_EXCLUDE.split("|").filter(it=>it.trim()));rule_tab_excludes=rule_tab_excludes.concat(TAB_EXCLUDE.split("|").filter(it=>it.trim()));rule.cate_exclude=rule_cate_excludes.join("|");rule.tab_exclude=rule_tab_excludes.join("|");rule.host=(rule.host||"").rstrip("/");rule.url=rule.url||"";rule.double=rule.double||false;rule.homeUrl=rule.homeUrl||"";rule.detailUrl=rule.detailUrl||"";rule.searchUrl=rule.searchUrl||"";rule.homeUrl=rule.host&&rule.homeUrl?urljoin(rule.host,rule.homeUrl):rule.homeUrl||rule.host;rule.detailUrl=rule.host&&rule.detailUrl?urljoin(rule.host,rule.detailUrl):rule.detailUrl;if(rule.url.includes("[")&&rule.url.includes("]")){letu1=rule.url.split("[")[0];letu2=rule.url.split("[")[1].split("]")[0];rule.url=rule.host&&rule.url?urljoin(rule.host,u1)+"["+urljoin(rule.host,u2)+"]":rule.url}else{rule.url=rule.host&&rule.url?urljoin(rule.host,rule.url):rule.url}rule.searchUrl=rule.host&&rule.searchUrl?urljoin(rule.host,rule.searchUrl):rule.searchUrl;rule.timeout=rule.timeout||5e3;rule.encoding=rule.编码||rule.encoding||"utf-8";rule.图片来源=rule.图片来源||"";rule.play_json=rule.hasOwnProperty("play_json")?rule.play_json:[];if(rule.headers&&typeofrule.headers==="object"){try{letheader_keys=Object.keys(rule.headers);for(letkofheader_keys){if(k.toLowerCase()==="user-agent"){letv=rule.headers[k];console.log(v);if(["MOBILE_UA","PC_UA","UC_UA","IOS_UA","UA"].includes(v)){rule.headers[k]=eval(v)}}}}catch(e){console.log("处理headers发生错误:"+e.message)}}rule_fetch_params={headers:rule.headers||false,timeout:rule.timeout,encoding:rule.encoding};oheaders=rule.headers||{};RKEY=typeofkey!=="undefined"&&key?key:"drpy_"+(rule.title||rule.host);pre();init_test()}catch(e){console.log("init_test发生错误:"+e.message)}}lethomeHtmlCache=undefined;functionhome(filter){console.log("home");lethomeObj={filter:rule.filter||false,MY_URL:rule.homeUrl,class_name:rule.class_name||"",class_url:rule.class_url||"",class_parse:rule.class_parse||"",cate_exclude:rule.cate_exclude};returnhomeParse(homeObj)}functionhomeVod(params){console.log("homeVod");lethomeVodObj={"推荐":rule.推荐,double:rule.double,homeUrl:rule.homeUrl,detailUrl:rule.detailUrl};returnhomeVodParse(homeVodObj)}functioncategory(tid,pg,filter,extend){letcateObj={url:rule.url,"一级":rule.一级,tid:tid,pg:parseInt(pg),filter:filter,extend:extend};returncategoryParse(cateObj)}functiondetail(vod_url){letorId=vod_url;letfyclass="";if(vod_url.indexOf("$")>-1){lettmp=vod_url.split("$");fyclass=tmp[0];vod_url=tmp[1]}letdetailUrl=vod_url.split("@@")[0];leturl;if(!detailUrl.startsWith("http")&&!detailUrl.includes("/")){url=rule.detailUrl.replaceAll("fyid",detailUrl).replaceAll("fyclass",fyclass)}elseif(detailUrl.includes("/")){url=urljoin(rule.homeUrl,detailUrl)}else{url=detailUrl}letdetailObj={orId:orId,url:url,"二级":rule.二级,detailUrl:detailUrl,fyclass:fyclass,tab_exclude:rule.tab_exclude};returndetailParse(detailObj)}functionplay(flag,id,flags){letplayObj={url:id,flag:flag,flags:flags};returnplayParse(playObj)}functionsearch(wd,quick){letsearchObj={searchUrl:rule.searchUrl,"搜索":rule.搜索,wd:wd,pg:1,quick:quick};returnsearchParse(searchObj)}functionDRPY(){return{init:init,home:home,homeVod:homeVod,category:category,detail:detail,play:play,search:search}}exportdefault{init:init,home:home,homeVod:homeVod,category:category,detail:detail,play:play,search:search,DRPY:DRPY};
\ No newline at end of file
importcheeriofrom"https://gitcode.net/qq_32394351/dr_py/-/raw/master/libs/cheerio.min.js";import"https://gitcode.net/qq_32394351/dr_py/-/raw/master/libs/crypto-js.js";import"https://gitcode.net/qq_32394351/dr_py/-/raw/master/libs/drT.js";functioninit_test(){console.log("init_test_start");console.log("当前版本号:"+VERSION);console.log(RKEY);console.log(JSON.stringify(rule));console.log("init_test_end")}functionpre(){if(typeofrule.预处理==="string"&&rule.预处理&&rule.预处理.trim()){letcode=rule.预处理.trim();console.log("执行预处理代码:"+code);if(code.startsWith("js:")){code=code.replace("js:","")}try{eval(code)}catch(e){console.log("预处理执行失败:"+e.message)}}}letrule={};constVERSION="3.9.18";constMOBILE_UA="Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36";constPC_UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36";constUA="Mozilla/5.0";constUC_UA="Mozilla/5.0 (Linux; U; Android 9; zh-CN; MI 9 Build/PKQ1.181121.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.5.5.1035 Mobile Safari/537.36";constIOS_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";constRULE_CK="cookie";constCATE_EXCLUDE="首页|留言|APP|下载|资讯|新闻|动态";constTAB_EXCLUDE="猜你|喜欢|APP|下载|剧情|热播";constOCR_RETRY=3;constOCR_API="http://cms.nokia.press:5706/parse/ocr";if(typeofMY_URL==="undefined"){varMY_URL}varRKEY;varfetch;varprint;varlog;varrule_fetch_params;varfetch_params;varoheaders;var_pdfh;var_pdfa;var_pd;constDOM_CHECK_ATTR=/(url|src|href|-original|-src|-play|-url)$/;constSELECT_REGEX=/:eq|:lt|:gt|#/g;constSELECT_REGEX_A=/:eq|:lt|:gt/g;if(typeofObject.assign!="function"){Object.assign=function(){vartarget=arguments[0];for(vari=1;i<arguments.length;i++){varsource=arguments[i];for(varkeyinsource){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}returntarget}}if(!String.prototype.includes){String.prototype.includes=function(search,start){if(typeofstart!=="number"){start=0}if(start+search.length>this.length){returnfalse}else{returnthis.indexOf(search,start)!==-1}}}if(!Array.prototype.includes){Object.defineProperty(Array.prototype,"includes",{value:function(searchElement,fromIndex){if(this==null){thrownewTypeError('"this" is null or not defined')}varo=Object(this);varlen=o.length>>>0;if(len===0){returnfalse}varn=fromIndex|0;vark=Math.max(n>=0?n:len-Math.abs(n),0);while(k<len){if(o[k]===searchElement){returntrue}k++}returnfalse}})}if(typeofString.prototype.startsWith!="function"){String.prototype.startsWith=function(prefix){returnthis.slice(0,prefix.length)===prefix}}if(typeofString.prototype.endsWith!="function"){String.prototype.endsWith=function(suffix){returnthis.indexOf(suffix,this.length-suffix.length)!==-1}}Object.prototype.myValues=function(obj){if(obj==null){thrownewTypeError("Cannot convert undefined or null to object")}varres=[];for(varkinobj){if(obj.hasOwnProperty(k)){res.push(obj[k])}}returnres};if(typeofObject.prototype.values!="function"){Object.prototype.values=function(obj){if(obj==null){thrownewTypeError("Cannot convert undefined or null to object")}varres=[];for(varkinobj){if(obj.hasOwnProperty(k)){res.push(obj[k])}}returnres}}if(typeofArray.prototype.join!="function"){Array.prototype.join=function(emoji){emoji=emoji||"";letself=this;letstr="";leti=0;if(!Array.isArray(self)){throwString(self)+"is not Array"}if(self.length===0){return""}if(self.length===1){returnString(self[0])}i=1;str=this[0];for(;i<self.length;i++){str+=String(emoji)+String(self[i])}returnstr}}String.prototype.rstrip=function(chars){letregex=newRegExp(chars+"$");returnthis.replace(regex,"")};Array.prototype.append=Array.prototype.push;String.prototype.strip=String.prototype.trim;function是否正版(vipUrl){letflag=newRegExp("qq.com|iqiyi.com|youku.com|mgtv.com|bilibili.com|sohu.com|ixigua.com|pptv.com|miguvideo.com|le.com|1905.com|fun.tv");returnflag.test(vipUrl)}functionurlDeal(vipUrl){if(!vipUrl){return""}if(!是否正版(vipUrl)){returnvipUrl}if(!/miguvideo/.test(vipUrl)){vipUrl=vipUrl.split("#")[0].split("?")[0]}returnvipUrl}functionsetResult(d){if(!Array.isArray(d)){return[]}VODS=[];d.forEach(function(it){letobj={vod_id:it.url||"",vod_name:it.title||"",vod_remarks:it.desc||"",vod_content:it.content||"",vod_pic:it.pic_url||it.img||""};letkeys=Object.keys(it);if(keys.includes("tname")){obj.type_name=it.tname||""}if(keys.includes("tid")){obj.type_id=it.tid||""}if(keys.includes("year")){obj.vod_year=it.year||""}if(keys.includes("actor")){obj.vod_actor=it.actor||""}if(keys.includes("director")){obj.vod_director=it.director||""}if(keys.includes("area")){obj.vod_area=it.area||""}VODS.push(obj)});returnVODS}functionsetResult2(res){VODS=res.list||[];returnVODS}functionsetHomeResult(res){if(!res||typeofres!=="object"){return[]}returnsetResult(res.list)}functionrc(js){if(js==="maomi_aes.js"){vara=CryptoJS.enc.Utf8.parse("625222f9149e961d");vart=CryptoJS.enc.Utf8.parse("5efdtf6060e2o330");return{De:function(word){word=CryptoJS.enc.Hex.parse(word);returnCryptoJS.AES.decrypt(CryptoJS.enc.Base64.stringify(word),a,{iv:t,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)},En:function(word){varEncrypted=CryptoJS.AES.encrypt(word,a,{iv:t,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});returnEncrypted.ciphertext.toString()}}}return{}}functionmaoss(jxurl,ref,key){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));eval(getCryptoJS());try{vargetVideoInfo=function(text){returnCryptoJS.AES.decrypt(text,key,{iv:iv,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)};vartoken_key=key==undefined?"dvyYRQlnPRCMdQSe":key;if(ref){varhtml=request(jxurl,{headers:{Referer:ref}})}else{varhtml=request(jxurl)}if(html.indexOf("&btwaf=")!=-1){html=request(jxurl+"&btwaf"+html.match(/&btwaf(.*?)"/)[1],{headers:{Referer:ref}})}vartoken_iv=html.split('_token = "')[1].split('"')[0];varkey=CryptoJS.enc.Utf8.parse(token_key);variv=CryptoJS.enc.Utf8.parse(token_iv);eval(html.match(/var config = {[\s\S]*?}/)[0]+"");if(!config.url.startsWith("http")){config.url=CryptoJS.AES.decrypt(config.url,key,{iv:iv,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)}returnconfig.url}catch(e){return""}}functionurlencode(str){str=(str+"").toString();returnencodeURIComponent(str).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")}functionbase64Encode(text){returnCryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(text))}functionbase64Decode(text){returnCryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(text))}functionmd5(text){returnCryptoJS.MD5(text).toString()}functiongetCryptoJS(){return'console.log("CryptoJS已装载");'}letVODS=[];letVOD={};letTABS=[];letLISTS=[];globalThis.encodeUrl=urlencode;globalThis.urlencode=urlencode;functionurljoin(fromPath,nowPath){fromPath=fromPath||"";nowPath=nowPath||"";returnjoinUrl(fromPath,nowPath)}varurljoin2=urljoin;constdefaultParser={pdfh:pdfh,pdfa:pdfa,pd(html,parse,uri){letret=this.pdfh(html,parse);if(typeofuri==="undefined"||!uri){uri=""}if(DOM_CHECK_ATTR.test(parse)){if(/http/.test(ret)){ret=ret.substr(ret.indexOf("http"))}else{ret=urljoin(MY_URL,ret)}}returnret}};functionpdfh2(html,parse){lethtml2=html;try{if(typeofhtml!=="string"){html2=html.rr(html.ele).toString()}}catch(e){print("html对象转文本发生了错误:"+e.message)}letresult=defaultParser.pdfh(html2,parse);letoption=parse.includes("&&")?parse.split("&&").slice(-1)[0]:parse.split("").slice(-1)[0];if(/style/.test(option.toLowerCase())&&/url\(/.test(result)){try{result=result.match(/url\((.*?)\)/)[1]}catch(e){}}returnresult}functionpdfa2(html,parse){lethtml2=html;try{if(typeofhtml!=="string"){html2=html.rr(html.ele).toString()}}catch(e){print("html对象转文本发生了错误:"+e.message)}returndefaultParser.pdfa(html2,parse)}functionpd2(html,parse,uri){letret=pdfh2(html,parse);if(typeofuri==="undefined"||!uri){uri=""}if(DOM_CHECK_ATTR.test(parse)){if(/http/.test(ret)){ret=ret.substr(ret.indexOf("http"))}else{ret=urljoin(MY_URL,ret)}}returnret}constparseTags={jsp:{pdfh:pdfh2,pdfa:pdfa2,pd:pd},json:{pdfh(html,parse){if(!parse||!parse.trim()){return""}if(typeofhtml==="string"){html=JSON.parse(html)}parse=parse.trim();if(!parse.startsWith("$.")){parse="$."+parse}parse=parse.split("||");for(letpsofparse){letret=cheerio.jp(ps,html);if(Array.isArray(ret)){ret=ret[0]||""}else{ret=ret||""}if(ret&&typeofret!=="string"){ret=ret.toString()}if(ret){returnret}}return""},pdfa(html,parse){if(!parse||!parse.trim()){return""}if(typeofhtml==="string"){html=JSON.parse(html)}parse=parse.trim();if(!parse.startsWith("$.")){parse="$."+parse}letret=cheerio.jp(parse,html);if(Array.isArray(ret)&&Array.isArray(ret[0])&&ret.length===1){returnret[0]||[]}returnret||[]},pd(html,parse){letret=parseTags.json.pdfh(html,parse);if(ret){returnurljoin(MY_URL,ret)}returnret}},jq:{pdfh(html,parse,base_url){if(!parse||!parse.trim()){return""}leteleFind=typeofhtml==="object";letoption=undefined;if(eleFind&&parse.startsWith("body&&")){parse=parse.substr(6);if(parse.indexOf("&&")<0){option=parse.trim();parse="*=*"}}if(parse.indexOf("&&")>-1){letsp=parse.split("&&");option=sp[sp.length-1];sp.splice(sp.length-1);if(sp.length>1){for(letiinsp){if(sp.hasOwnProperty(i)){if(!SELECT_REGEX.test(sp[i])){sp[i]=sp[i]+":eq(0)"}}}}else{if(!SELECT_REGEX.test(sp[0])){sp[0]=sp[0]+":eq(0)"}}parse=sp.join("")}letresult="";const$=eleFind?html.rr:cheerio.load(html);letret=eleFind?parse==="*=*"||$(html.ele).is(parse)?html.ele:$(html.ele).find(parse):$(parse);if(option){if(option==="Text"){result=$(ret).text()}elseif(option==="Html"){result=$(ret).html()}else{result=$(ret).attr(option);if(/style/.test(option.toLowerCase())&&/url\(/.test(result)){try{result=result.match(/url\((.*?)\)/)[1]}catch(e){}}}if(result&&base_url&&DOM_CHECK_ATTR.test(option)){if(/http/.test(result)){result=result.substr(result.indexOf("http"))}else{result=urljoin(base_url,result)}}}else{result=$(ret).toString()}returnresult},pdfa(html,parse){if(!parse||!parse.trim()){print("!parse");return[]}leteleFind=typeofhtml==="object";if(parse.indexOf("&&")>-1){letsp=parse.split("&&");for(letiinsp){if(sp.hasOwnProperty(i)){if(!SELECT_REGEX_A.test(sp[i])&&i<sp.length-1){if(sp[i]!=="body"){sp[i]=sp[i]+":first"}}}}parse=sp.join("")}const$=eleFind?html.rr:cheerio.load(html);letret=eleFind?$(html.ele).is(parse)?html.ele:$(html.ele).find(parse):$(parse);letresult=[];if(ret){ret.each(function(idx,ele){result.push({rr:$,ele:ele})})}returnresult},pd(html,parse,uri){returnparseTags.jq.pdfh(html,parse,MY_URL)}},getParse(p0){if(p0.startsWith("jsp:")){returnthis.jsp}elseif(p0.startsWith("json:")){returnthis.json}elseif(p0.startsWith("jq:")){returnthis.jq}else{returnthis.jq}}};conststringify=JSON.stringify;constjsp=parseTags.jsp;constjq=parseTags.jq;functionreadFile(filePath){filePath=filePath||"./uri.min.js";varfd=os.open(filePath);varbuffer=newArrayBuffer(1024);varlen=os.read(fd,buffer,0,1024);console.log(len);lettext=String.fromCharCode.apply(null,newUint8Array(buffer));console.log(text);returntext}functiondealJson(html){try{html=html.trim();if(!(html.startsWith("{")&&html.endsWith("}")||html.startsWith("[")&&html.endsWith("]"))){html="{"+html.match(/.*?\{(.*)\}/m)[1]+"}"}}catch(e){}try{html=JSON.parse(html)}catch(e){}returnhtml}varOcrApi={api:OCR_API,classification:function(img){letcode="";try{lethtml=request(this.api,{data:{img:img},headers:{"User-Agent":PC_UA},method:"POST"},true);html=JSON.parse(html);code=html.url||""}catch(e){}returncode}};functionverifyCode(url){letcnt=0;lethost=getHome(url);letcookie="";while(cnt<OCR_RETRY){try{letyzm_url=`${host}/index.php/verify/index.html`;console.log(`验证码链接:${yzm_url}`);lethhtml=request(yzm_url,{withHeaders:true,toBase64:true},true);letjson=JSON.parse(hhtml);if(!cookie){letsetCk=Object.keys(json).find(it=>it.toLowerCase()==="set-cookie");cookie=setCk?json[setCk].split(";")[0]:""}console.log("cookie:"+cookie);letimg=json.body;letcode=OcrApi.classification(img);console.log(`第${cnt+1}次验证码识别结果:${code}`);letsubmit_url=`${host}/index.php/ajax/verify_check?type=search&verify=${code}`;console.log(submit_url);lethtml=request(submit_url,{headers:{Cookie:cookie,"User-Agent":MOBILE_UA},method:"POST"});html=JSON.parse(html);if(html.msg==="ok"){console.log(`第${cnt+1}次验证码提交成功`);returncookie}elseif(html.msg!=="ok"&&cnt+1>=OCR_RETRY){cookie=""}}catch(e){console.log(`第${cnt+1}次验证码提交失败:${e.message}`);if(cnt+1>=OCR_RETRY){cookie=""}}cnt+=1}returncookie}functionsetItem(k,v){local.set(RKEY,k,v);console.log(`规则${RKEY}设置${k} => ${v}`)}functiongetItem(k,v){returnlocal.get(RKEY,k)||v}functionclearItem(k){local.delete(RKEY,k)}functiongetHome(url){if(!url){return""}lettmp=url.split("//");url=tmp[0]+"//"+tmp[1].split("/")[0];try{url=decodeURIComponent(url)}catch(e){}returnurl}functionbuildUrl(url,obj){obj=obj||{};if(url.indexOf("?")<0){url+="?"}letparam_list=[];letkeys=Object.keys(obj);keys.forEach(it=>{param_list.push(it+"="+obj[it])});letprs=param_list.join("&");if(keys.length>0&&!url.endsWith("?")){url+="&"}url+=prs;returnurl}functionrequire(url){eval(request(url))}functionrequest(url,obj,ocr_flag){ocr_flag=ocr_flag||false;if(typeofobj==="undefined"||!obj||obj==={}){if(!fetch_params||!fetch_params.headers){letheaders={"User-Agent":MOBILE_UA};if(rule.headers){Object.assign(headers,rule.headers)}fetch_params.headers=headers}if(!fetch_params.headers.Referer){fetch_params.headers.Referer=getHome(url)}obj=fetch_params}else{letheaders=obj.headers||{};letkeys=Object.keys(headers).map(it=>it.toLowerCase());if(!keys.includes("user-agent")){headers["User-Agent"]=MOBILE_UA}if(!keys.includes("referer")){headers["Referer"]=getHome(url)}obj.headers=headers}if(rule.encoding&&rule.encoding!=="utf-8"&&!ocr_flag){if(!obj.headers.hasOwnProperty("Content-Type")){obj.headers["Content-Type"]="text/html; charset="+rule.encoding}}if(typeofobj.body!="undefined"&&obj.body&&typeofobj.body==="string"){letdata={};obj.body.split("&").forEach(it=>{data[it.split("=")[0]]=it.split("=")[1]});obj.data=data;deleteobj.body}elseif(typeofobj.body!="undefined"&&obj.body&&typeofobj.body==="object"){obj.data=obj.body;deleteobj.body}if(!url){returnobj.withHeaders?"{}":""}if(obj.toBase64){obj.buffer=2;deleteobj.toBase64}console.log(JSON.stringify(obj.headers));console.log("request:"+url);letres=req(url,obj);lethtml=res.content||"";if(obj.withHeaders){lethtmlWithHeaders=res.headers;htmlWithHeaders.body=html;returnJSON.stringify(htmlWithHeaders)}else{returnhtml}}functionpost(url,obj){obj.method="POST";returnrequest(url,obj)}fetch=request;print=function(data){data=data||"";if(typeofdata!=="string"){try{data=JSON.stringify(data)}catch(e){console.log("print:"+e.message)}}if(typeofdata!=="string"){console.log(typeofdata+":"+data.length)}else{console.log(data)}};log=print;functioncheckHtml(html,url,obj){if(/\?btwaf=/.test(html)){letbtwaf=html.match(/btwaf(.*?)"/)[1];url=url.split("#")[0]+"?btwaf"+btwaf;print("宝塔验证访问链接:"+url);html=request(url,obj)}returnhtml}functiongetCode(url,obj){lethtml=request(url,obj);html=checkHtml(html,url,obj);returnhtml}functiongetHtml(url){letobj={};if(rule.headers){obj.headers=rule.headers}letcookie=getItem(RULE_CK,"");if(cookie){if(obj.headers&&!Object.keys(obj.headers).map(it=>it.toLowerCase()).includes("cookie")){obj.headers["Cookie"]=cookie}elseif(!obj.headers){obj.headers={Cookie:cookie}}}lethtml=getCode(url,obj);returnhtml}functionhomeParse(homeObj){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));letclasses=[];if(homeObj.class_name&&homeObj.class_url){letnames=homeObj.class_name.split("&");leturls=homeObj.class_url.split("&");letcnt=Math.min(names.length,urls.length);for(leti=0;i<cnt;i++){classes.push({type_id:urls[i],type_name:names[i]})}}if(homeObj.class_parse){letp=homeObj.class_parse.split(";");let_ps=parseTags.getParse(p[0]);_pdfa=_ps.pdfa;_pdfh=_ps.pdfh;_pd=_ps.pd;MY_URL=rule.url;if(p.length>=3){try{lethtml=getHtml(homeObj.MY_URL);if(html){homeHtmlCache=html;letlist=_pdfa(html,p[0]);if(list&&list.length>0){list.forEach((it,idex)=>{try{letname=_pdfh(it,p[1]);if(homeObj.cate_exclude&&newRegExp(homeObj.cate_exclude).test(name)){return}leturl=_pd(it,p[2]);if(p.length>3&&p[3]){letexp=newRegExp(p[3]);url=url.match(exp)[1]}classes.push({type_id:url.trim(),type_name:name.trim()})}catch(e){console.log(`分类列表定位第${idex}个元素正常报错:${e.message}`)}})}}}catch(e){console.log(e.message)}}}classes=classes.filter(it=>!homeObj.cate_exclude||!newRegExp(homeObj.cate_exclude).test(it.type_name));letresp={class:classes};if(homeObj.filter){resp.filters=homeObj.filter}console.log(JSON.stringify(resp));returnJSON.stringify(resp)}functiongetPP(p,pn,pp,ppn){letps=p[pn]==="*"&&pp.length>ppn?pp[ppn]:p[pn];returnps}functionhomeVodParse(homeVodObj){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));letd=[];MY_URL=homeVodObj.homeUrl;console.log(MY_URL);lett1=(newDate).getTime();letp=homeVodObj.推荐;print("p:"+p);if(p==="*"&&rule.一级){p=rule.一级;homeVodObj.double=false}if(!p||typeofp!=="string"){return"{}"}p=p.trim();letpp=rule.一级.split(";");if(p.startsWith("js:")){constTYPE="home";varinput=MY_URL;constHOST=rule.host;eval(p.replace("js:",""));d=VODS}else{p=p.split(";");if(!homeVodObj.double&&p.length<5){return"{}"}elseif(homeVodObj.double&&p.length<6){return"{}"}letp0=getPP(p,0,pp,0);let_ps=parseTags.getParse(p0);_pdfa=_ps.pdfa;_pdfh=_ps.pdfh;_pd=_ps.pd;letis_json=p0.startsWith("json:");p0=p0.replace(/^(jsp:|json:|jq:)/,"");lethtml=homeHtmlCache||getHtml(MY_URL);homeHtmlCache=undefined;if(is_json){html=dealJson(html)}try{console.log("double:"+homeVodObj.double);if(homeVodObj.double){letitems=_pdfa(html,p0);for(letitemofitems){letitems2=_pdfa(item,p[1]);for(letitem2ofitems2){try{letp2=getPP(p,2,pp,1);lettitle=_pdfh(item2,p2);letimg="";try{letp3=getPP(p,3,pp,2);img=_pd(item2,p3)}catch(e){}letdesc="";try{letp4=getPP(p,4,pp,3);desc=_pdfh(item2,p4)}catch(e){}letp5=getPP(p,5,pp,4);letlinks=[];for(let_p5ofp5.split("+")){letlink=!homeVodObj.detailUrl?_pd(item2,_p5,MY_URL):_pdfh(item2,_p5);links.push(link)}letcontent;if(p.length>6&&p[6]){letp6=getPP(p,6,pp,5);content=_pdfh(item2,p6)}else{content=""}letvid=links.join("$");if(rule.二级==="*"){vid=vid+"@@"+title+"@@"+img}letvod={vod_name:title,vod_pic:img,vod_remarks:desc,vod_content:content,vod_id:vid};d.push(vod)}catch(e){console.log("首页列表处理发生错误:"+e.message)}}}}else{letitems=_pdfa(html,p0);for(letitemofitems){try{letp1=getPP(p,1,pp,1);lettitle=_pdfh(item,p1);letimg="";try{letp2=getPP(p,2,pp,2);img=_pd(item,p2,MY_URL)}catch(e){}letdesc="";try{letp3=getPP(p,3,pp,3);desc=_pdfh(item,p3)}catch(e){}letp4=getPP(p,4,pp,4);letlinks=[];for(let_p5ofp4.split("+")){letlink=!homeVodObj.detailUrl?_pd(item,_p5,MY_URL):_pdfh(item,_p5);links.push(link)}letcontent;if(p.length>5&&p[5]){letp5=getPP(p,5,pp,5);content=_pdfh(item,p5)}else{content=""}letvid=links.join("$");if(rule.二级==="*"){vid=vid+"@@"+title+"@@"+img}letvod={vod_name:title,vod_pic:img,vod_remarks:desc,vod_content:content,vod_id:vid};d.push(vod)}catch(e){}}}}catch(e){}}lett2=(newDate).getTime();console.log("加载首页推荐耗时:"+(t2-t1)+"毫秒");if(rule.图片来源){d.forEach(it=>{if(it.vod_pic&&it.vod_pic.startsWith("http")){it.vod_pic=it.vod_pic+rule.图片来源}})}returnJSON.stringify({list:d})}functioncategoryParse(cateObj){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));letp=cateObj.一级;if(!p||typeofp!=="string"){return"{}"}letd=[];leturl=cateObj.url.replaceAll("fyclass",cateObj.tid);if(rule.filter_url){if(!/fyfilter/.test(url)){if(!url.endsWith("&")&&!rule.filter_url.startsWith("&")){url+="&"}url+=rule.filter_url}else{url=url.replace("fyfilter",rule.filter_url)}letfl=cateObj.filter?cateObj.extend:{};if(rule.filter_def&&typeofrule.filter_def==="object"){try{if(Object.keys(rule.filter_def).length>0&&rule.filter_def.hasOwnProperty(cateObj.tid)){letself_fl_def=rule.filter_def[cateObj.tid];if(self_fl_def&&typeofself_fl_def==="object"){letfl_def=JSON.parse(JSON.stringify(self_fl_def));fl=Object.assign(fl_def,fl)}}}catch(e){print("合并不同分类对应的默认筛选出错:"+e.message)}}letnew_url;new_url=cheerio.jinja2(url,{fl:fl});if(/object Object/.test(new_url)){new_url=drT.renderText(url,fl)}url=new_url}if(/fypage/.test(url)){if(url.includes("(")&&url.includes(")")){leturl_rep=url.match(/.*?\((.*)\)/)[1];letcnt_page=url_rep.replaceAll("fypage",cateObj.pg);letcnt_pg=eval(cnt_page);url=url.replaceAll(url_rep,cnt_pg).replaceAll("(","").replaceAll(")","")}else{url=url.replaceAll("fypage",cateObj.pg)}}if(cateObj.pg===1&&url.includes("[")&&url.includes("]")){url=url.split("[")[1].split("]")[0]}elseif(cateObj.pg>1&&url.includes("[")&&url.includes("]")){url=url.split("[")[0]}MY_URL=url;console.log(MY_URL);p=p.trim();constMY_CATE=cateObj.tid;if(p.startsWith("js:")){varMY_FL=cateObj.extend;constTYPE="cate";varinput=MY_URL;constMY_PAGE=cateObj.pg;vardesc="";eval(p.trim().replace("js:",""));d=VODS}else{p=p.split(";");if(p.length<5){return"{}"}let_ps=parseTags.getParse(p[0]);_pdfa=_ps.pdfa;_pdfh=_ps.pdfh;_pd=_ps.pd;letis_json=p[0].startsWith("json:");p[0]=p[0].replace(/^(jsp:|json:|jq:)/,"");try{lethtml=getHtml(MY_URL);if(html){if(is_json){html=dealJson(html)}letlist=_pdfa(html,p[0]);list.forEach(it=>{letlinks=p[4].split("+").map(p4=>{return!rule.detailUrl?_pd(it,p4,MY_URL):_pdfh(it,p4)});letlink=links.join("$");letvod_id=rule.detailUrl?MY_CATE+"$"+link:link;letvod_name=_pdfh(it,p[1]).replace(/\n|\t/g,"").trim();letvod_pic=_pd(it,p[2],MY_URL);if(rule.二级==="*"){vod_id=vod_id+"@@"+vod_name+"@@"+vod_pic}d.push({vod_id:vod_id,vod_name:vod_name,vod_pic:vod_pic,vod_remarks:_pdfh(it,p[3]).replace(/\n|\t/g,"").trim()})})}}catch(e){console.log(e.message)}}if(rule.图片来源){d.forEach(it=>{if(it.vod_pic&&it.vod_pic.startsWith("http")){it.vod_pic=it.vod_pic+rule.图片来源}})}returnd.length<1?"{}":JSON.stringify({page:parseInt(cateObj.pg),pagecount:999,limit:20,total:999,list:d})}functionsearchParse(searchObj){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));letd=[];if(!searchObj.searchUrl){return"{}"}letp=searchObj.搜索==="*"&&rule.一级?rule.一级:searchObj.搜索;if(!p||typeofp!=="string"){return"{}"}p=p.trim();letpp=rule.一级.split(";");leturl=searchObj.searchUrl.replaceAll("**",searchObj.wd).replaceAll("fypage",searchObj.pg);MY_URL=url;console.log(MY_URL);if(p.startsWith("js:")){constTYPE="search";constMY_PAGE=searchObj.pg;constKEY=searchObj.wd;varinput=MY_URL;vardetailUrl=rule.detailUrl||"";eval(p.trim().replace("js:",""));d=VODS}else{p=p.split(";");if(p.length<5){return"{}"}letp0=getPP(p,0,pp,0);let_ps=parseTags.getParse(p0);_pdfa=_ps.pdfa;_pdfh=_ps.pdfh;_pd=_ps.pd;letis_json=p0.startsWith("json:");p0=p0.replace(/^(jsp:|json:|jq:)/,"");try{lethtml=getHtml(MY_URL);if(html){if(/系统安全验证|输入验证码/.test(html)){letcookie=verifyCode(MY_URL);if(cookie){console.log(`本次成功过验证,cookie:${cookie}`);setItem(RULE_CK,cookie)}else{console.log(`本次自动过搜索验证失败,cookie:${cookie}`)}html=getHtml(MY_URL)}if(!html.includes(searchObj.wd)){console.log("搜索结果源码未包含关键字,疑似搜索失败,正为您打印结果源码");console.log(html)}if(is_json){html=dealJson(html)}console.log(JSON.stringify(html));console.log(html);letlist=_pdfa(html,p0);list.forEach(it=>{letp1=getPP(p,1,pp,1);letp2=getPP(p,2,pp,2);letp3=getPP(p,3,pp,3);letp4=getPP(p,4,pp,4);letlinks=p4.split("+").map(_p4=>{return!rule.detailUrl?_pd(it,_p4,MY_URL):_pdfh(it,_p4)});letlink=links.join("$");letcontent;if(p.length>5&&p[5]){letp5=getPP(p,5,pp,5);content=_pdfh(it,p5)}else{content=""}letvod_id=link;letvod_name=_pdfh(it,p1).replace(/\n|\t/g,"").trim();letvod_pic=_pd(it,p2,MY_URL);if(rule.二级==="*"){vod_id=vod_id+"@@"+vod_name+"@@"+vod_pic}letob={vod_id:vod_id,vod_name:vod_name,vod_pic:vod_pic,vod_remarks:_pdfh(it,p3).replace(/\n|\t/g,"").trim(),vod_content:content.replace(/\n|\t/g,"").trim()};d.push(ob)})}}catch(e){print("搜索发生错误:"+e.message);return"{}"}}if(rule.图片来源){d.forEach(it=>{if(it.vod_pic&&it.vod_pic.startsWith("http")){it.vod_pic=it.vod_pic+rule.图片来源}})}returnJSON.stringify({page:parseInt(searchObj.pg),pagecount:10,limit:20,total:100,list:d})}functiondetailParse(detailObj){lett1=(newDate).getTime();fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));letorId=detailObj.orId;letvod_name="片名";letvod_pic="";letvod_id=orId;if(rule.二级==="*"){letextra=orId.split("@@");vod_name=extra.length>1?extra[1]:vod_name;vod_pic=extra.length>2?extra[2]:vod_pic}letvod={vod_id:vod_id,vod_name:vod_name,vod_pic:vod_pic,type_name:"类型",vod_year:"年份",vod_area:"地区",vod_remarks:"更新信息",vod_actor:"主演",vod_director:"导演",vod_content:"简介"};letp=detailObj.二级;leturl=detailObj.url;letdetailUrl=detailObj.detailUrl;letfyclass=detailObj.fyclass;lettab_exclude=detailObj.tab_exclude;lethtml=detailObj.html||"";MY_URL=url;if(p==="*"){vod.vod_play_from="道长在线";vod.vod_remarks=detailUrl;vod.vod_actor="没有二级,只有一级链接直接嗅探播放";vod.vod_content=MY_URL;vod.vod_play_url="嗅探播放$"+MY_URL.split("@@")[0]}elseif(typeofp==="string"&&p.trim().startsWith("js:")){constTYPE="detail";varinput=MY_URL;varplay_url="";eval(p.trim().replace("js:",""));vod=VOD;console.log(JSON.stringify(vod))}elseif(p&&typeofp==="object"){if(!html){html=getHtml(MY_URL)}let_impJQP=true;let_ps;if(p.is_json){_ps=parseTags.json;html=dealJson(html);_impJQP=false}elseif(p.is_jsp){_ps=parseTags.jsp}elseif(p.is_jq){_ps=parseTags.jq}else{_ps=parseTags.jq}if(_impJQP){letc$=cheerio.load(html);html={rr:c$,ele:c$("html")[0]}}_pdfa=_ps.pdfa;_pdfh=_ps.pdfh;_pd=_ps.pd;if(p.title){letp1=p.title.split(";");vod.vod_name=_pdfh(html,p1[0]).replace(/\n|\t/g,"").trim();lettype_name=p1.length>1?_pdfh(html,p1[1]).replace(/\n|\t/g,"").replace(/ /g,"").trim():"";vod.type_name=type_name||vod.type_name}if(p.desc){try{letp1=p.desc.split(";");vod.vod_remarks=_pdfh(html,p1[0]).replace(/\n|\t/g,"").trim();vod.vod_year=p1.length>1?_pdfh(html,p1[1]).replace(/\n|\t/g,"").trim():"";vod.vod_area=p1.length>2?_pdfh(html,p1[2]).replace(/\n|\t/g,"").trim():"";vod.vod_actor=p1.length>3?_pdfh(html,p1[3]).replace(/\n|\t/g,"").trim():"";vod.vod_director=p1.length>4?_pdfh(html,p1[4]).replace(/\n|\t/g,"").trim():""}catch(e){}}if(p.content){try{letp1=p.content.split(";");vod.vod_content=_pdfh(html,p1[0]).replace(/\n|\t/g,"").trim()}catch(e){}}if(p.img){try{letp1=p.img.split(";");vod.vod_pic=_pd(html,p1[0],MY_URL)}catch(e){}}letvod_play_from="$$$";letplayFrom=[];if(p.重定向&&p.重定向.startsWith("js:")){print("开始执行重定向代码:"+p.重定向);html=eval(p.重定向.replace("js:",""));if(_impJQP){letc$=cheerio.load(html);html={rr:c$,ele:c$("html")[0]}}}if(p.tabs){if(p.tabs.startsWith("js:")){print("开始执行tabs代码:"+p.tabs);if(html&&typeofhtml!=="string"){try{html=html.rr(html.ele).toString()}catch(e){}}varinput=MY_URL;eval(p.tabs.replace("js:",""));playFrom=TABS}else{letp_tab=p.tabs.split(";")[0];letvHeader=_pdfa(html,p_tab);console.log(vHeader.length);lettab_text=p.tab_text||"body&&Text";for(letvofvHeader){letv_title=_pdfh(v,tab_text).trim();console.log(v_title);if(tab_exclude&&newRegExp(tab_exclude).test(v_title)){continue}playFrom.push(v_title)}}console.log(JSON.stringify(playFrom))}else{playFrom=["道长在线"]}vod.vod_play_from=playFrom.join(vod_play_from);letvod_play_url="$$$";letvod_tab_list=[];if(p.lists){if(p.lists.startsWith("js:")){print("开始执行lists代码:"+p.lists);try{if(html&&typeofhtml!=="string"){try{html=html.rr(html.ele).toString()}catch(e){}}varinput=MY_URL;varplay_url="";eval(p.lists.replace("js:",""));for(letiinLISTS){if(LISTS.hasOwnProperty(i)){try{LISTS[i]=LISTS[i].map(it=>it.split("$").slice(0,2).join("$"))}catch(e){print("格式化LISTS发生错误:"+e.message)}}}vod_play_url=LISTS.map(it=>it.join("#")).join(vod_play_url)}catch(e){print("js执行lists: 发生错误:"+e.message)}}else{letlist_text=p.list_text||"body&&Text";letlist_url=p.list_url||"a&&href";letis_tab_js=p.tabs.trim().startsWith("js:");for(leti=0;i<playFrom.length;i++){lettab_name=playFrom[i];lettab_ext=p.tabs.split(";").length>1&&!is_tab_js?p.tabs.split(";")[1]:"";letp1=p.lists.replaceAll("#idv",tab_name).replaceAll("#id",i);tab_ext=tab_ext.replaceAll("#idv",tab_name).replaceAll("#id",i);console.log(p1);letvodList=[];try{vodList=_pdfa(html,p1);console.log("len(vodList):"+vodList.length)}catch(e){}letnew_vod_list=[];lettabName=tab_ext?_pdfh(html,tab_ext):tab_name;console.log(tabName);lettt1=(newDate).getTime();vodList.forEach((it,idex)=>{new_vod_list.push(_pdfh(it,list_text).trim()+"$"+_pd(it,list_url,MY_URL))});console.log(`drpy影响性能代码共计列表数循环次数:${vodList.length},耗时:${(newDate).getTime()-tt1}毫秒`);letvlist=new_vod_list.join("#");vod_tab_list.push(vlist)}vod_play_url=vod_tab_list.join(vod_play_url)}}vod.vod_play_url=vod_play_url}if(rule.图片来源&&vod.vod_pic&&vod.vod_pic.startsWith("http")){vod.vod_pic=vod.vod_pic+rule.图片来源}if(!vod.vod_id){vod.vod_id=vod_id}lett2=(newDate).getTime();console.log(`加载二级界面${MY_URL}耗时:${t2-t1}毫秒`);returnJSON.stringify({list:[vod]})}functiontellIsJx(url){try{letis_vip=!/\.(m3u8|mp4|m4a)$/.test(url.split("?")[0])&&是否正版(url);returnis_vip?1:0}catch(e){return1}}functionplayParse(playObj){fetch_params=JSON.parse(JSON.stringify(rule_fetch_params));MY_URL=playObj.url;if(!/http/.test(MY_URL)){try{MY_URL=base64Decode(MY_URL)}catch(e){}}MY_URL=decodeURIComponent(MY_URL);varinput=MY_URL;letcommon_play={parse:1,url:input,jx:tellIsJx(input)};letlazy_play;if(!rule.play_parse||!rule.lazy){lazy_play=common_play}elseif(rule.play_parse&&rule.lazy&&typeofrule.lazy==="string"){try{letlazy_code=rule.lazy.replace("js:","").trim();print("开始执行js免嗅=>"+lazy_code);eval(lazy_code);lazy_play=typeofinput==="object"?input:{parse:1,jx:tellIsJx(input),url:input}}catch(e){print("js免嗅错误:"+e.message);lazy_play=common_play}}else{lazy_play=common_play}if(Array.isArray(rule.play_json)&&rule.play_json.length>0){letweb_url=lazy_play.url;for(letpjsonofrule.play_json){if(pjson.re&&(pjson.re==="*"||web_url.match(newRegExp(pjson.re)))){if(pjson.json&&typeofpjson.json==="object"){letbase_json=pjson.json;lazy_play=Object.assign(lazy_play,base_json);break}}}}elseif(rule.play_json&&!Array.isArray(rule.play_json)){letbase_json={jx:1,parse:1};lazy_play=Object.assign(lazy_play,base_json)}elseif(!rule.play_json){letbase_json={jx:0,parse:1};lazy_play=Object.assign(lazy_play,base_json)}console.log(JSON.stringify(lazy_play));returnJSON.stringify(lazy_play)}functioninit(ext){console.log("init");try{if(typeofglobalThis.mubanJs==="undefined"){letmubanJs=request("https://gitcode.net/qq_32394351/dr_py/-/raw/master/js/模板.js",{"User-Agent":MOBILE_UA});mubanJs=mubanJs.replace("export default","(function() {return muban;}()) // export default");globalThis.mubanJs=mubanJs}letmuban=eval(globalThis.mubanJs);if(typeofext=="object"){rule=ext}elseif(typeofext=="string"){if(ext.startsWith("http")){letjs=request(ext,{method:"GET"});if(js){eval(js.replace("var rule","rule"))}}}else{eval(ext.replace("var rule","rule"))}if(rule.模板&&muban.hasOwnProperty(rule.模板)){print("继承模板:"+rule.模板);rule=Object.assign(muban[rule.模板],rule)}letrule_cate_excludes=(rule.cate_exclude||"").split("|").filter(it=>it.trim());letrule_tab_excludes=(rule.tab_exclude||"").split("|").filter(it=>it.trim());rule_cate_excludes=rule_cate_excludes.concat(CATE_EXCLUDE.split("|").filter(it=>it.trim()));rule_tab_excludes=rule_tab_excludes.concat(TAB_EXCLUDE.split("|").filter(it=>it.trim()));rule.cate_exclude=rule_cate_excludes.join("|");rule.tab_exclude=rule_tab_excludes.join("|");rule.host=(rule.host||"").rstrip("/");rule.url=rule.url||"";rule.double=rule.double||false;rule.homeUrl=rule.homeUrl||"";rule.detailUrl=rule.detailUrl||"";rule.searchUrl=rule.searchUrl||"";rule.homeUrl=rule.host&&rule.homeUrl?urljoin(rule.host,rule.homeUrl):rule.homeUrl||rule.host;rule.detailUrl=rule.host&&rule.detailUrl?urljoin(rule.host,rule.detailUrl):rule.detailUrl;if(rule.url.includes("[")&&rule.url.includes("]")){letu1=rule.url.split("[")[0];letu2=rule.url.split("[")[1].split("]")[0];rule.url=rule.host&&rule.url?urljoin(rule.host,u1)+"["+urljoin(rule.host,u2)+"]":rule.url}else{rule.url=rule.host&&rule.url?urljoin(rule.host,rule.url):rule.url}rule.searchUrl=rule.host&&rule.searchUrl?urljoin(rule.host,rule.searchUrl):rule.searchUrl;rule.timeout=rule.timeout||5e3;rule.encoding=rule.编码||rule.encoding||"utf-8";rule.图片来源=rule.图片来源||"";rule.play_json=rule.hasOwnProperty("play_json")?rule.play_json:[];if(rule.headers&&typeofrule.headers==="object"){try{letheader_keys=Object.keys(rule.headers);for(letkofheader_keys){if(k.toLowerCase()==="user-agent"){letv=rule.headers[k];console.log(v);if(["MOBILE_UA","PC_UA","UC_UA","IOS_UA","UA"].includes(v)){rule.headers[k]=eval(v)}}}}catch(e){console.log("处理headers发生错误:"+e.message)}}rule_fetch_params={headers:rule.headers||false,timeout:rule.timeout,encoding:rule.encoding};oheaders=rule.headers||{};RKEY=typeofkey!=="undefined"&&key?key:"drpy_"+(rule.title||rule.host);pre();init_test()}catch(e){console.log("init_test发生错误:"+e.message)}}lethomeHtmlCache=undefined;functionhome(filter){console.log("home");lethomeObj={filter:rule.filter||false,MY_URL:rule.homeUrl,class_name:rule.class_name||"",class_url:rule.class_url||"",class_parse:rule.class_parse||"",cate_exclude:rule.cate_exclude};returnhomeParse(homeObj)}functionhomeVod(params){console.log("homeVod");lethomeVodObj={"推荐":rule.推荐,double:rule.double,homeUrl:rule.homeUrl,detailUrl:rule.detailUrl};returnhomeVodParse(homeVodObj)}functioncategory(tid,pg,filter,extend){letcateObj={url:rule.url,"一级":rule.一级,tid:tid,pg:parseInt(pg),filter:filter,extend:extend};returncategoryParse(cateObj)}functiondetail(vod_url){letorId=vod_url;letfyclass="";if(vod_url.indexOf("$")>-1){lettmp=vod_url.split("$");fyclass=tmp[0];vod_url=tmp[1]}letdetailUrl=vod_url.split("@@")[0];leturl;if(!detailUrl.startsWith("http")&&!detailUrl.includes("/")){url=rule.detailUrl.replaceAll("fyid",detailUrl).replaceAll("fyclass",fyclass)}elseif(detailUrl.includes("/")){url=urljoin(rule.homeUrl,detailUrl)}else{url=detailUrl}letdetailObj={orId:orId,url:url,"二级":rule.二级,detailUrl:detailUrl,fyclass:fyclass,tab_exclude:rule.tab_exclude};returndetailParse(detailObj)}functionplay(flag,id,flags){letplayObj={url:id,flag:flag,flags:flags};returnplayParse(playObj)}functionsearch(wd,quick){letsearchObj={searchUrl:rule.searchUrl,"搜索":rule.搜索,wd:wd,pg:1,quick:quick};returnsearchParse(searchObj)}functionDRPY(){return{init:init,home:home,homeVod:homeVod,category:category,detail:detail,play:play,search:search}}exportdefault{init:init,home:home,homeVod:homeVod,category:category,detail:detail,play:play,search:search,DRPY:DRPY};