提交 a5dc3eff 编写于 作者: H hjdhnx

修改模板.js兼容性

上级 dc04952d
...@@ -38,8 +38,11 @@ def admin_index(): # 管理员界面 ...@@ -38,8 +38,11 @@ def admin_index(): # 管理员界面
live_url = lsg.getItem('LIVE_URL') live_url = lsg.getItem('LIVE_URL')
use_py = lsg.getItem('USE_PY') use_py = lsg.getItem('USE_PY')
# print(f'live_url:', live_url) # print(f'live_url:', live_url)
rules = getRules('js')
# print(rules)
cache_count = getCacheCount() cache_count = getCacheCount()
return render_template('admin.html', pystate=use_py,rules=getRules('js'),cache_count=cache_count, ver=getLocalVer(), live_url=live_url) # print(cache_count)
return render_template('admin.html', pystate=use_py,rules=rules,cache_count=cache_count, ver=getLocalVer(), live_url=live_url)
@admin.route('/settings') @admin.route('/settings')
def admin_settings(): # 管理员界面 def admin_settings(): # 管理员界面
...@@ -214,7 +217,7 @@ def upload_file(): ...@@ -214,7 +217,7 @@ def upload_file():
if os.path.exists(savePath): if os.path.exists(savePath):
return R.failed(f'上传失败,文件已存在,请先查看删除再试') return R.failed(f'上传失败,文件已存在,请先查看删除再试')
with open('js/模板.js', encoding='utf-8') as f2: with open('js/模板.js', encoding='utf-8') as f2:
before = f2.read() before = f2.read().split('export')[0]
upcode = file.stream.read().decode('utf-8') upcode = file.stream.read().decode('utf-8')
check_to_run = before + upcode check_to_run = before + upcode
# print(check_to_run) # print(check_to_run)
......
...@@ -1245,7 +1245,7 @@ if __name__ == '__main__': ...@@ -1245,7 +1245,7 @@ if __name__ == '__main__':
# js_path = f'js/玩偶姐姐.js' # js_path = f'js/玩偶姐姐.js'
# js_path = f'js/555影视.js' # js_path = f'js/555影视.js'
with open('../js/模板.js', encoding='utf-8') as f: with open('../js/模板.js', encoding='utf-8') as f:
before = f.read() before = f.read().split('export')[0]
js_path = f'js/360影视.js' js_path = f'js/360影视.js'
ctx, js_code = parser.runJs(js_path,before=before) ctx, js_code = parser.runJs(js_path,before=before)
ruleDict = ctx.rule.to_dict() ruleDict = ctx.rule.to_dict()
......
...@@ -27,7 +27,7 @@ def search_one(rule, wd, before: str = ''): ...@@ -27,7 +27,7 @@ def search_one(rule, wd, before: str = ''):
t1 = time() t1 = time()
if not before: if not before:
with open('js/模板.js', encoding='utf-8') as f: with open('js/模板.js', encoding='utf-8') as f:
before = f.read() before = f.read().split('export')[0]
js_path = f'js/{rule}.js' js_path = f'js/{rule}.js'
try: try:
ctx, js_code = parser.runJs(js_path, before=before) ctx, js_code = parser.runJs(js_path, before=before)
...@@ -63,7 +63,7 @@ def multi_search2(wd): ...@@ -63,7 +63,7 @@ def multi_search2(wd):
# print(search_sites) # print(search_sites)
res = [] res = []
with open('js/模板.js', encoding='utf-8') as f: with open('js/模板.js', encoding='utf-8') as f:
before = f.read() before = f.read().split('export')[0]
logger.info(f'聚搜准备工作耗时:{get_interval(t1)}毫秒') logger.info(f'聚搜准备工作耗时:{get_interval(t1)}毫秒')
t2 = time() t2 = time()
thread_pool = ThreadPoolExecutor(len(search_sites)) # 定义线程池来启动多线程执行此任务 thread_pool = ThreadPoolExecutor(len(search_sites)) # 定义线程池来启动多线程执行此任务
...@@ -109,7 +109,7 @@ def multi_search(wd): ...@@ -109,7 +109,7 @@ def multi_search(wd):
# print(search_sites) # print(search_sites)
res = [] res = []
with open('js/模板.js', encoding='utf-8') as f: with open('js/模板.js', encoding='utf-8') as f:
before = f.read() before = f.read().split('export')[0]
with ThreadPoolExecutor(max_workers=len(search_sites)) as executor: with ThreadPoolExecutor(max_workers=len(search_sites)) as executor:
to_do = [] to_do = []
for site in search_sites: for site in search_sites:
...@@ -159,7 +159,7 @@ def vod_home(): ...@@ -159,7 +159,7 @@ def vod_home():
# js_path = f'js/{rule}.js' if not ext.startswith('http') else ext # js_path = f'js/{rule}.js' if not ext.startswith('http') else ext
js_path = f'js/{rule}.js' if not ext else ext js_path = f'js/{rule}.js' if not ext else ext
with open('js/模板.js', encoding='utf-8') as f: with open('js/模板.js', encoding='utf-8') as f:
before = f.read() before = f.read().split('export')[0]
# logger.info(f'js读取耗时:{get_interval(t1)}毫秒') # logger.info(f'js读取耗时:{get_interval(t1)}毫秒')
logger.info(f'参数检验js读取共计耗时:{get_interval(t0)}毫秒') logger.info(f'参数检验js读取共计耗时:{get_interval(t0)}毫秒')
t2 = time() t2 = time()
......
...@@ -40,7 +40,7 @@ def getRules(path='cache'): ...@@ -40,7 +40,7 @@ def getRules(path='cache'):
rule_list = [file.replace('.js', '') for file in file_name] rule_list = [file.replace('.js', '') for file in file_name]
js_path = [f'{path}/{rule}.js' for rule in rule_list] js_path = [f'{path}/{rule}.js' for rule in rule_list]
with open('js/模板.js', encoding='utf-8') as f: with open('js/模板.js', encoding='utf-8') as f:
before = f.read() before = f.read().split('export')[0]
rule_codes = [] rule_codes = []
# for js in js_path: # for js in js_path:
# with open(js,encoding='utf-8') as f: # with open(js,encoding='utf-8') as f:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册