提交 0a895a89 编写于 作者: H hjdhnx

开始drpy

上级 6f70bc53
......@@ -35,6 +35,7 @@ OCR_API = 'http://dm.mudery.com:10000' # 验证码识别接口,传参数data
UNAME = 'admin' # 管理员账号
PWD = 'drpy' # 管理员密码
USE_PY = 0 # 开启py源
JS_MODE = 0 # js模式 0 drpy服务器解析 1 pluto本地解析
MAX_CONTENT_LENGTH = 1 * 1024 * 100 # 100 kB
LIVE_MODE = 0 # 0 本地 1外网
LIVE_URL = 'https://gitcode.net/bd/v/-/raw/main/live/zb.txt' # 初始化外网直播地址(后续在管理界面改)
......
无法预览此类型文件
......@@ -124,11 +124,17 @@ def get_files(name):
return response
@home.route('/txt/<path:filename>')
def custom_static(filename):
def custom_static_txt(filename):
# 自定义静态目录 {{ url_for('custom_static',filename='help.txt')}}
# print(filename)
return send_from_directory('txt', filename)
@home.route('/libs/<path:filename>')
def custom_static_libs(filename):
# 自定义静态目录 {{ url_for('custom_static',filename='help.txt')}}
# print(filename)
return send_from_directory('libs', filename)
# @home.route('/txt/<name>')
# def get_txt_files(name):
# base_path = 'txt'
......@@ -207,6 +213,8 @@ def config_render(mode):
host = getHost(mode)
# ali_token = lsg.getItem('ALI_TOKEN')
ali_token = new_conf.ALI_TOKEN
js_mode = new_conf.JS_MODE
print('jsmode:',js_mode)
# print(ali_token)
customConfig = getCustonDict(host,ali_token)
# print(customConfig)
......@@ -221,7 +229,7 @@ def config_render(mode):
rules = getRules('js')
rules = get_multi_rules(rules)
# html = render_template('config.txt',rules=getRules('js'),host=host,mode=mode,jxs=jxs,base64Encode=base64Encode,config=new_conf)
html = render_template('config.txt',pys=pys,rules=rules,host=host,mode=mode,jxs=jxs,alists=alists,alists_str=alists_str,live_url=live_url,config=new_conf)
html = render_template('config.txt',pys=pys,rules=rules,host=host,mode=mode,js_mode=js_mode,jxs=jxs,alists=alists,alists_str=alists_str,live_url=live_url,config=new_conf)
merged_config = custom_merge(parseText(html),customConfig)
# print(merged_config['sites'])
......
......@@ -19,7 +19,7 @@ class storage_service(object):
return copy_utils.obj_to_list(res)
def __init__(self):
conf_list = ['LIVE_URL', 'USE_PY', 'PLAY_URL', 'PLAY_DISABLE', 'LAZYPARSE_MODE', 'WALL_PAPER_ENABLE',
conf_list = ['LIVE_URL', 'USE_PY', 'JS_MODE','PLAY_URL', 'PLAY_DISABLE', 'LAZYPARSE_MODE', 'WALL_PAPER_ENABLE',
'WALL_PAPER', 'UNAME', 'PWD', 'LIVE_MODE', 'CATE_EXCLUDE', 'TAB_EXCLUDE','SEARCH_TIMEOUT','MULTI_MODE','ALI_TOKEN']
for conf in conf_list:
if not self.hasItem(conf):
......@@ -29,9 +29,9 @@ class storage_service(object):
@classmethod
def getStoreConf(self):
# MAX_CONTENT_LENGTH 最大上传和端口ip一样是顶级配置,无法外部修改的
conf_list = ['LIVE_URL', 'LIVE_MODE','PLAY_URL', 'PID_URL','USE_PY', 'PLAY_DISABLE', 'LAZYPARSE_MODE', 'WALL_PAPER_ENABLE',
conf_list = ['LIVE_URL', 'LIVE_MODE','PLAY_URL', 'PID_URL','USE_PY','JS_MODE', 'PLAY_DISABLE', 'LAZYPARSE_MODE', 'WALL_PAPER_ENABLE',
'WALL_PAPER', 'UNAME', 'PWD', 'CATE_EXCLUDE', 'TAB_EXCLUDE','SEARCH_TIMEOUT','MULTI_MODE','ALI_TOKEN']
conf_name_list = ['直播地址', '直播模式','远程地址', '进程管理链接','启用py源', '禁用免嗅', '免嗅模式', '启用壁纸', '壁纸链接', '管理账号',
conf_name_list = ['直播地址', '直播模式','远程地址', '进程管理链接','启用py源', 'js模式','禁用免嗅', '免嗅模式', '启用壁纸', '壁纸链接', '管理账号',
'管理密码', '分类排除', '线路排除','聚搜超时','多源模式','阿里tk']
conf_lists = []
for i in range(len(conf_list)):
......
Object.assign = function () {
if (typeof Object.assign != 'function') {
Object.assign = function () {
var target = arguments[0];
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
......@@ -10,6 +11,8 @@ Object.assign = function () {
}
return target;
};
}
var mubanDict = { // 模板字典
mxpro:{
title:'',
......@@ -151,4 +154,5 @@ vfed:{
};
var muban = JSON.parse(JSON.stringify(mubanDict));
\ No newline at end of file
var muban = JSON.parse(JSON.stringify(mubanDict));
export default muban;
\ No newline at end of file
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
// 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 = { "&": "&#38;", "<": "&#60;", ">": "&#62;", '"': "&#34;", "'": "&#39;", "/": "&#47;" },
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+"<l"+sid+"){"
+vname+"=arr"+sid+"["+indv+"+=1];out+='";
})
.replace(c.evaluate || skip, function(m, code) {
return "';" + unescape(code) + "out+='";
})
+ "';return out;")
.replace(/\n/g, "\\n").replace(/\t/g, '\\t').replace(/\r/g, "\\r")
.replace(/(\s|;|\}|^|\{)out\+='';/g, '$1').replace(/\+''/g, "");
//.replace(/(\s|;|\}|^|\{)out\+=''\+/g,'$1out+=');
if (needhtmlencode) {
// console.log('需要编码');
// console.log(c.doNotSkipEncoded);
if (!c.selfcontained && _globals && !_globals._encodeHTML) _globals._encodeHTML = drT.encodeHTMLSource(c.doNotSkipEncoded);
str = "var encodeHTML = typeof _encodeHTML !== 'undefined' ? _encodeHTML : ("
+ drT.encodeHTMLSource.toString() + "(" + (c.doNotSkipEncoded || '') + "));"
+ str;
// console.log(str);
}else{
// console.log('不需要编码');
}
// console.log(c.varname);
// console.log(str);
try {
return new Function(c.varname, str);
} catch (e) {
/* istanbul ignore else */
// console.log(e.message);
if (typeof console !== "undefined") console.log("Could not create a template function: " + str);
throw e;
}
};
drT.compile = function(tmpl, def) {
return drT.template(tmpl, null, def);
};
drT.renderText = function (tmpl,dict,varname){
varname = varname||'';
if(varname){
drT.templateSettings.varname = varname;
}
dict = dict||{};
return drT.compile(tmpl)(dict);
};
}());
\ No newline at end of file
此差异已折叠。
......@@ -5,7 +5,7 @@
"spider": "{{ host }}/liveslib",
{% if alists|length > 0 %}"drives": {{alists_str}},{% endif %}
"homepage":"https://gitcode.net/qq_32394351/dr_py",
"sites": [{% for rule in rules.list %}{% if mode == 0 %}
"sites": [{% for rule in rules.list %}{% if js_mode == 0 %}
{
"key":"dr_{{ rule.name }}",
"name":"{{ rule.name }}(道长)",
......@@ -17,12 +17,13 @@
}{% else %}
{
"key":"dr_{{ rule.name }}",
"name":"{{ rule.name }}(道长)",
"type":1,
"api":"{{ host }}/vod?rule={{ rule.name }}",
"name":"{{ rule.name }}(drpy)",
"type":3,
"api":"{{ host }}/libs/drpy.js",
"searchable": {{ rule.searchable }},
"quickSearch": {{ rule.quickSearch }},
"filterable": {{ rule.filterable }}
"filterable": {{ rule.filterable }},
"ext":"{{ host }}/admin/view/{{ rule.name }}.js"
}{% endif %}{% if loop.last==False %},{% endif %}{% endfor %}
{% if pys %}
,{% for py in pys %}{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册