diff --git a/base/custom.conf b/base/custom.conf index 814f2b651ebae8bef625d0c82a3f81f47aa43610..5a8603ec2651cc47d7a5f7066759f740a708f007 100644 --- a/base/custom.conf +++ b/base/custom.conf @@ -20,7 +20,7 @@ "filterable":0 }, # 缓存js -{"key":"drpy_zbk","name":"真不卡(drpy)","type":3,"api":"js_drpy_zbk","searchable":1,"quickSearch":1,"filterable":1,"ext":"{{host}}/txt/muban/drpy模板.js"}, +{"key":"drpy_zbk","name":"真不卡(drpy)","type":3,"api":"js_drpy_zbk","searchable":1,"quickSearch":1,"filterable":1,"ext":"{{host}}/txt/pluto/drpy.js"}, {"key": "dr_MXONE", "name": "MXONE(道长)", "type": 1, "api": "{{host}}/vod?rule=MXONE&ext=txt/js/tg/MXONE.js", "searchable": 2, "quickSearch": 0, "filterable": 0}, {"key": "dr_Nike影视", "name": "Nike影视(道长)", "type": 1, "api": "{{host}}/vod?rule=Nike影视&ext=txt/js/tg/Nike影视.js", "searchable": 2, "quickSearch": 0, "filterable": 0}, {"key": "dr_TV云播", "name": "TV云播(道长)", "type": 1, "api": "{{host}}/vod?rule=TV云播&ext=txt/js/tg/TV云播.js", "searchable": 2, "quickSearch": 0, "filterable": 0}, diff --git "a/txt/muban/drpy\346\250\241\346\235\277.js" "b/txt/muban/drpy\346\250\241\346\235\277.js" index 014565c374a1dbeb37f0c1ffd56f1e393efaecf8..29d5066388f947a7ee4e5deef2fc52062b74b9bc 100644 --- "a/txt/muban/drpy\346\250\241\346\235\277.js" +++ "b/txt/muban/drpy\346\250\241\346\235\277.js" @@ -1,12 +1,42 @@ import ch from './cheerio.min.js'; -import './uri.min.js'; +// import Uri from './uri.min.js'; // var URI = require('urijs'); // import 模板 from 'https://gitcode.net/qq_32394351/dr_py/-/raw/master/js/模板.js' // var rule = Object.assign(模板.首图2,{ // host: 'https://www.zbkk.net', // }); +import template from 'https://gitcode.net/qq_32394351/dr_py/-/raw/master/txt/pluto/template-web.js' + +var ahtml = template.render('hi, <%=value%>.', {value: 'aui'}); +console.log(ahtml); const key = 'drpy_zbk'; +// 二进制数据流 +// let d = req('https://www.baidu.com/favicon.ico', { +// buffer: 1 +// }); +// // header +// console.log(JSON.stringify(d.headers)); +// // 图片 +// let array = []; +// for(var i in d.content){ +// array.push(d.content[i]); +// } +// console.log(array.length); +// let outbuf = new Uint8Array(array); +// console.log(outbuf.byteLength); + + +// base64 +let d = req('https://www.baidu.com/favicon.ico', { + buffer: 2 +}); +// header +console.log(JSON.stringify(d.headers)); +// 图片 base64 +console.log(d.content); + + let rule = { title: '真不卡', host: 'https://www.zbkk.net', @@ -168,29 +198,30 @@ function clearItem(k){ * @returns {*} */ function urljoin(fromPath, nowPath) { - fromPath = fromPath||''; - nowPath = nowPath||''; - try { - // import Uri from './uri.min.js'; - // var Uri = require('./uri.min.js'); - // eval(request('https://cdn.bootcdn.net/ajax/libs/URI.js/1.19.11/URI.min.js')); - // let new_uri = URI(nowPath, fromPath); - - let new_uri = Uri(nowPath, fromPath); - new_uri = new_uri.toString(); - // console.log(new_uri); - // return fromPath + nowPath - return new_uri - } - catch (e) { - console.log('urljoin发生错误:'+e.message); - if(nowPath.startsWith('http')){ - return nowPath - }if(nowPath.startsWith('/')){ - return getHome(fromPath)+nowPath - } - return fromPath+nowPath - } + return joinUrl(fromPath, nowPath); + // fromPath = fromPath||''; + // nowPath = nowPath||''; + // try { + // // import Uri from './uri.min.js'; + // // var Uri = require('./uri.min.js'); + // // eval(request('https://cdn.bootcdn.net/ajax/libs/URI.js/1.19.11/URI.min.js')); + // // let new_uri = URI(nowPath, fromPath); + + // let new_uri = Uri(nowPath, fromPath); + // new_uri = new_uri.toString(); + // // console.log(new_uri); + // // return fromPath + nowPath + // return new_uri + // } + // catch (e) { + // console.log('urljoin发生错误:'+e.message); + // if(nowPath.startsWith('http')){ + // return nowPath + // }if(nowPath.startsWith('/')){ + // return getHome(fromPath)+nowPath + // } + // return fromPath+nowPath + // } } /** @@ -445,7 +476,7 @@ function homeVodParse(homeVodObj){ }; d.push(vod); }catch (e) { - + } } @@ -465,7 +496,7 @@ function homeVodParse(homeVodObj){ try { img = pD(item, p[2],MY_URL); }catch (e) { - + } let desc = pdfh(item, p[3]); let links = []; @@ -626,7 +657,7 @@ function detailParse(detailObj){ let html = detailObj.html||''; MY_URL = url; // setItem('MY_URL',MY_URL); - console.log(MY_URL); + // console.log(MY_URL); if(p==='*'){ vod.vod_play_from = '道长在线'; vod.vod_remarks = detailUrl; @@ -676,8 +707,8 @@ function detailParse(detailObj){ if(p.重定向&&p.重定向.startsWith('js:')){ html = eval(p.重定向.replace('js:','')); } - -console.log(2); + +// console.log(2); if(p.tabs){ let p_tab = p.tabs.split(';')[0]; console.log(p_tab); @@ -698,7 +729,7 @@ console.log(2); } vod.vod_play_from = playFrom.join(vod_play_from); -console.log(3); +// console.log(3); let vod_play_url = '$$$'; let vod_tab_list = []; if(p.lists){ @@ -729,7 +760,7 @@ console.log(3); } vod.vod_play_url = vod_tab_list.join(vod_play_url); } -console.log(JSON.stringify(vod)); +// console.log(JSON.stringify(vod)); return JSON.stringify({ list: [vod] }) @@ -755,6 +786,7 @@ function playParse(playObj){ eval(rule.lazy.replace('js:').trim()); lazy_play = typeof(input) === 'object'?input:{ parse:1, + jx:1, url:input }; }catch (e) { diff --git a/txt/pluto/drT.js b/txt/pluto/drT.js new file mode 100644 index 0000000000000000000000000000000000000000..f05905e7c8f9740b7df7eda400db190afd9776fd --- /dev/null +++ b/txt/pluto/drT.js @@ -0,0 +1,189 @@ +// drT.js +// 2022/09/30 write by hjdhnx +// Licensed under the MIT license. + +(function () { + "use strict"; + + var drT = { + name: "drT", + version: "1.0.0", + templateSettings: { + evaluate: /\{\{([\s\S]+?(\}?)+)\}\}/g, + interpolate: /\{\{([\s\S]+?)\}\}/g, // 变量渲染 + encode: /\{\{@([\s\S]+?)\}\}/g, // 变量自动url编码 + use: /\{\{#([\s\S]+?)\}\}/g, + useParams: /(^|[^\w$])def(?:\.|\[[\'\"])([\w$\.]+)(?:[\'\"]\])?\s*\:\s*([\w$\.]+|\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})/g, + define: /\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g, + defineParams:/^\s*([\w$]+):([\s\S]+)/, + conditional: /\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g, // ? if ?? else if ?? else + iterate: /\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g, + varname: "fl", + strip: true, + append: true, + selfcontained: false, + doNotSkipEncoded: false + }, + template: undefined, //fn, compile template + compile: undefined, //fn, for express + log: true + }, _globals; + + drT.encodeHTMLSource = function(doNotSkipEncoded) { + var encodeHTMLRules = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'", "/": "/" }, + matchHTML = doNotSkipEncoded ? /[&<>"'\/]/g : /&(?!#?\w+;)|<|>|"|'|\//g; + return function(code) { + return code ? code.toString().replace(matchHTML, function(m) {return encodeHTMLRules[m] || m;}) : ""; + }; + }; + + _globals = (function(){ return this || (0,eval)("this"); }()); + + /* istanbul ignore else */ + if (typeof module !== "undefined" && module.exports) { + module.exports = drT; + } else if (typeof define === "function" && define.amd) { + define(function(){return drT;}); + } else { + _globals.drT = drT; + } + + var startend = { + append: { start: "'+(", end: ")+'", startencode: "'+encodeHTML(" }, + split: { start: "';out+=(", end: ");out+='", startencode: "';out+=encodeHTML(" } + }, skip = /$^/; + + function resolveDefs(c, block, def) { + return ((typeof block === "string") ? block : block.toString()) + .replace(c.define || skip, function(m, code, assign, value) { + if (code.indexOf("def.") === 0) { + code = code.substring(4); + } + if (!(code in def)) { + if (assign === ":") { + if (c.defineParams) value.replace(c.defineParams, function(m, param, v) { + def[code] = {arg: param, text: v}; + }); + if (!(code in def)) def[code]= value; + } else { + new Function("def", "def['"+code+"']=" + value)(def); + } + } + return ""; + }) + .replace(c.use || skip, function(m, code) { + if (c.useParams) code = code.replace(c.useParams, function(m, s, d, param) { + if (def[d] && def[d].arg && param) { + var rw = (d+":"+param).replace(/'|\\/g, "_"); + def.__exp = def.__exp || {}; + def.__exp[rw] = def[d].text.replace(new RegExp("(^|[^\\w$])" + def[d].arg + "([^\\w$])", "g"), "$1" + param + "$2"); + return s + "def.__exp['"+rw+"']"; + } + }); + var v = new Function("def", "return " + code)(def); + return v ? resolveDefs(c, v, def) : v; + }); + } + + function unescape(code) { + return code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, " "); + } + + drT.template = function(tmpl, c, def) { + c = c || drT.templateSettings; + var cse = c.append ? startend.append : startend.split, needhtmlencode, sid = 0, indv, + str = (c.use || c.define) ? resolveDefs(c, tmpl, def || {}) : tmpl; + + // console.log(str); + let beforeCode = ''; + if(str.match(c.interpolate || skip)){ + let inter_codes = str.match(c.interpolate || skip); + let inter_dict = {}; + inter_codes.forEach(item=>{ + item.replace(c.interpolate || skip,function (m,code) { + let varname = code.split('.')[0]; + if(!inter_dict.hasOwnProperty(varname)){ + let beginCode = `if(typeof(${varname})==='undefined'){${varname}={}}`; + inter_dict[varname] = beginCode; + }if(!inter_dict.hasOwnProperty(code)){ + let beginCode = `if(typeof(${code})==='undefined'){${code}=''};`; + inter_dict[code] = beginCode; + } + }); + }); + let beginCode = Object.values(inter_dict).join('\n'); + // console.log(beginCode); + beforeCode += beginCode; + } + str = beforeCode+("var out='" + (c.strip ? str.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ") + .replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,""): str) + .replace(/'|\\/g, "\\$&") + .replace(c.encode || skip, function(m, code) { + needhtmlencode = true; + return cse.startencode + unescape(code) + cse.end; + }) + .replace(c.interpolate || skip, function(m, code) { + let varname = code.split('.')[0]; + // console.log(varname === code); + // console.log(`varname:${varname},code:${code}`); + if(varname === code){ + let res = cse.start + `JSON.stringify(${unescape(code)})` + cse.end; + // console.log(res); + return res + } + return cse.start + unescape(code) + cse.end; + }) + .replace(c.conditional || skip, function(m, elsecase, code) { + return elsecase ? + (code ? "';}else if(" + unescape(code) + "){out+='" : "';}else{out+='") : + (code ? "';if(" + unescape(code) + "){out+='" : "';}out+='"); + }) + .replace(c.iterate || skip, function(m, iterate, vname, iname) { + if (!iterate) return "';} } out+='"; + sid+=1; indv=iname || "i"+sid; iterate=unescape(iterate); + return "';var arr"+sid+"="+iterate+";if(arr"+sid+"){var "+vname+","+indv+"=-1,l"+sid+"=arr"+sid+".length-1;while("+indv+"/g, reExp = /(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g, code = 'var r=[];\n', cursor = 0; + + var add = function(line, js) { + + js? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') : + + (code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : ''); + + return add; + + } + + while(match = re.exec(html)) { + console.log(match) + add(html.slice(cursor, match.index))(match[1], true); + + cursor = match.index + match[0].length; + + } + + add(html.substr(cursor, html.length - cursor)); + + code += 'return r.join("");'; + + return new Function(code.replace(/[\r\t\n]/g, '')).apply(options); + +} + +function init_test(){ + // eval(request('https://gitcode.net/qq_32394351/dr_py/-/raw/master/txt/pluto/template-web.js')); + // eval(request('http://192.168.10.99:5705/txt/pluto/template-web.js')); + // eval(request('http://192.168.10.99:5705/txt/pluto/doT.js')); + eval(request('http://192.168.10.99:5705/txt/pluto/drT.js')); + // var ahtml = template.render('hi, <%=value%>.', {value: 'aui'}); + // console.log(ahtml); + console.log(typeof(drT)) + // drT.templateSettings.varname = 'fl'; + // drT.templateSettings.interpolate = /\{\{([\s\S]+?)\}\}/g; + // var ahtml = drT.compile('hi, {{fl.value}}哈哈.{{fl.value}}')({value: 'aui'}); + // console.log(ahtml); + // ahtml = drT.compile('hi, {{fl}}哈哈.{{fl}}')({sort: 1,cate:'movie'}); + // console.log(ahtml); + // + console.log(drT.renderText('hi, {{fl}}哈哈.{{fl}}',{sort: 1,cate:'movie'},'fl')) +} // 二进制数据流 // let d = req('https://www.baidu.com/favicon.ico', { @@ -68,6 +131,7 @@ let rule = { * quickjs发生一次崩溃后除非重启软件,否则该源后续操作点击二级都没有数据 * setItem系列存在问题,用的公用变量实现没法持久化,需要一个数据库存储持久化,下次进来也能获取储存的cookie * 电脑看日志调试 + adb tcpip 5555 adb connect 192.168.10.192 adb devices -l adb logcat -c @@ -801,6 +865,7 @@ function playParse(playObj){ */ function init(ext) { console.log("init"); + init_test(); } /**