From fea19c756c412f77d5aed0e76c3e90158f1689fc Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Tue, 30 Aug 2022 11:05:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=AF=B9=E6=BA=90?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=90=AF=E7=94=A8=E6=90=9C=E7=B4=A2=E7=9A=84?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 38 ++++++++++++++++--- classes/cms.py | 2 +- config.py | 6 ++- "js/555\345\275\261\350\247\206.js" | 2 + js/cokemv.js | 2 + "js/\345\226\265\345\226\265.js" | 2 + "js/\345\244\234\347\251\272.js" | 6 ++- ...62\351\245\255\345\275\261\350\247\206.js" | 2 + "js/\346\250\241\346\235\277.js" | 2 + "js/\347\223\234\347\232\256TV.js" | 2 + "js/\347\234\213\350\247\206\347\225\214.js" | 6 ++- "js/\350\216\253\346\211\216\345\205\224.js" | 2 + ...35\350\216\223\345\275\261\350\247\206.js" | 4 +- "js/\351\270\255\345\245\210\351\243\236.js" | 2 + readme.md | 8 ++++ templates/config.txt | 22 +++++------ templates/index.html | 18 +++++---- utils/web.py | 7 ++-- 18 files changed, 99 insertions(+), 34 deletions(-) diff --git a/app.py b/app.py index 5aff043..793a004 100644 --- a/app.py +++ b/app.py @@ -5,6 +5,7 @@ # Date : 2022/8/25 import random +import js2py from flask_sqlalchemy import SQLAlchemy import config # import settings @@ -34,7 +35,7 @@ db = SQLAlchemy(app) rule_list = getRuleLists() logger.info(rule_list) -logger.info(f'http://{getHost(1, 5705)}/index\nhttp://localhost:5705/index') +logger.info(f'局域网: {getHost(1, 5705)}/index\n本地: {getHost(0, 5705)}/index') from models import * from gevent.pywsgi import WSGIServer @@ -69,9 +70,13 @@ def forbidden(): # put application's code here @app.route('/index') def index(): # put application's code here # logger.info("进入了首页") - manager = getHost(1).split(':')[0] + ':9001' - manager2 = getHost(0).split(':')[0] + ':9001' - return render_template('index.html',getHost=getHost,manager=manager,manager2=manager2,is_linux=is_linux()) + sup_port = app.config.get('SUP_PORT',9001) + manager0 = ':'.join(getHost(0).split(':')[0:2]) + f':{sup_port}' + manager1 = ':'.join(getHost(1).split(':')[0:2]) + f':{sup_port}' + manager2 = ':'.join(getHost(2).split(':')[0:2]) + f':{sup_port}' + # print(manager2) + # print(manager2) + return render_template('index.html',getHost=getHost,manager0=manager0,manager1=manager1,manager2=manager2,is_linux=is_linux()) @app.route('/vod') def vod(): @@ -155,6 +160,7 @@ def clear(): return jsonify(error.success('成功删除文件:'+cache_path)) def getRules(path='cache'): + t1 = time() base_path = path+'/' # 当前文件所在目录 # print(base_path) os.makedirs(base_path,exist_ok=True) @@ -162,7 +168,29 @@ def getRules(path='cache'): file_name = list(filter(lambda x: str(x).endswith('.js') and str(x).find('模板') < 0, file_name)) # print(file_name) rule_list = [file.replace('.js', '') for file in file_name] - rules = {'list': rule_list, 'count': len(rule_list)} + js_path = [f'{path}/{rule}.js' for rule in rule_list] + with open('js/模板.js', encoding='utf-8') as f: + before = f.read() + rule_codes = [] + for js in js_path: + with open(js,encoding='utf-8') as f: + rule_codes.append(js2py.eval_js(before+f.read())) + + # print(rule_codes) + # print(type(rule_codes[0]),rule_codes[0]) + # print(rule_codes[0].title) + # print(rule_codes[0].searchable) + # print(rule_codes[0].quickSearch) + new_rule_list = [] + for i in range(len(rule_list)): + new_rule_list.append({ + 'name':rule_list[i], + 'searchable':rule_codes[i].searchable or 0, + 'quickSearch':rule_codes[i].quickSearch or 0 + }) + # print(new_rule_list) + rules = {'list': new_rule_list, 'count': len(rule_list)} + logger.info(f'自动配置装载耗时:{get_interval(t1)}毫秒') return rules def getPics(path='images'): diff --git a/classes/cms.py b/classes/cms.py index 9ddba58..1fee134 100644 --- a/classes/cms.py +++ b/classes/cms.py @@ -39,7 +39,7 @@ class CMS: # if not self.play_disable and self.lazy: if not self.play_disable: self.play_parse = rule.get('play_parse', False) - play_url = new_conf.get('PLAY_URL',getHost(1)) + play_url = new_conf.get('PLAY_URL',getHost(2)) if not play_url.startswith('http'): play_url = 'http://'+play_url if self.play_parse: diff --git a/config.py b/config.py index c330992..994c6c3 100644 --- a/config.py +++ b/config.py @@ -17,9 +17,11 @@ SQLALCHEMY_DATABASE_URI = DB_URI SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_ECHO = False # 打印sql语句 JSON_AS_ASCII = False # jsonify返回的中文正常显示 -# PLAY_URL = 'http://localhost:5705' # 匹配远程解析服务器链接 -# PLAY_URL = PLAY_URL.rstrip('/') +PLAY_URL = 'http://cms.nokia.press' # 匹配远程解析服务器链接 远程接口主页地址,后面不能有/ +PLAY_URL = PLAY_URL.rstrip('/') PLAY_DISABLE = False # 全局禁用播放解析 +LAZYPARSE_MODE = 1 # 播放解析模式(0 本地 1 局域网 2远程 仅在全局禁用为False的时候生效) WALL_PAPER_ENABLE = True # 启用自定义壁纸 WALL_PAPER = "https://picsum.photos/1280/720/?blur=10" # 自定义壁纸,可注释 +SUP_PORT = 9001 # supervisord 服务端口 # {% if config.WALL_PAPER %}"wallpaper":"{{ config.WALL_PAPER }}",{% endif %} \ No newline at end of file diff --git "a/js/555\345\275\261\350\247\206.js" "b/js/555\345\275\261\350\247\206.js" index becabad..d94027e 100644 --- "a/js/555\345\275\261\350\247\206.js" +++ "b/js/555\345\275\261\350\247\206.js" @@ -4,6 +4,8 @@ var rule = { // homeUrl:'/', url:'/vodshow/fyclass--------fypage---.html', searchUrl:'/vodsearch/**----------fypage---.html', + searchable:1, + quickSearch:1, headers:{//网站的请求头,完整支持所有的,常带ua和cookies 'User-Agent':'MOBILE_UA', "Cookie": "searchneed=ok" diff --git a/js/cokemv.js b/js/cokemv.js index 851c4da..a87c1d7 100644 --- a/js/cokemv.js +++ b/js/cokemv.js @@ -4,6 +4,8 @@ var rule = { // homeUrl:'/', url:'/vodshow/fyclass--------fypage---.html', searchUrl:'/vodsearch/**----------fypage---.html', + searchable:0, + quickSearch:0, headers:{ 'User-Agent':'MOBILE_UA', "Cookie": "showBtn=true;PHPSESSID=58nhbq5r54jivukrk4o27dn7m6" diff --git "a/js/\345\226\265\345\226\265.js" "b/js/\345\226\265\345\226\265.js" index e42073c..996d340 100644 --- "a/js/\345\226\265\345\226\265.js" +++ "b/js/\345\226\265\345\226\265.js" @@ -4,6 +4,8 @@ var rule = { // homeUrl:'/', url:'/t/fyclass/fypage.html', searchUrl:'/s/**/fypage.html', + searchable:1, + quickSearch:1, headers:{ 'User-Agent':'UC_UA' }, diff --git "a/js/\345\244\234\347\251\272.js" "b/js/\345\244\234\347\251\272.js" index d73aebd..fb75453 100644 --- "a/js/\345\244\234\347\251\272.js" +++ "b/js/\345\244\234\347\251\272.js" @@ -2,6 +2,8 @@ var rule = Object.assign(muban.mxpro,{ title:'夜空', host:'https://www.yekong.cc', url:'/pianku-fyclass--------fypage---/', - searchUrl:'/search-**----------fypage---/', - class_parse:'.navbar-items li:gt(1):lt(7);a&&Text;a&&href;.*v/(.*?)/', +searchUrl:'/search-**----------fypage---/', +searchable:0, +quickSearch:0, +class_parse:'.navbar-items li:gt(1):lt(7);a&&Text;a&&href;.*v/(.*?)/', }); \ No newline at end of file diff --git "a/js/\345\271\262\351\245\255\345\275\261\350\247\206.js" "b/js/\345\271\262\351\245\255\345\275\261\350\247\206.js" index 0b5b309..7a7d1e1 100644 --- "a/js/\345\271\262\351\245\255\345\275\261\350\247\206.js" +++ "b/js/\345\271\262\351\245\255\345\275\261\350\247\206.js" @@ -7,6 +7,8 @@ var rule = { 'User-Agent':'MOBILE_UA' }, searchUrl:'/search/**-fypage.html', + searchable:1, + quickSearch:1, // class_name:'电影&网剧&剧集&动漫&综艺&记录', // class_url:'20&1&2&3&4&23', class_parse:'.stui-header__menu li:gt(0):lt(5);a&&Text;a&&href;/(\\d+).html', diff --git "a/js/\346\250\241\346\235\277.js" "b/js/\346\250\241\346\235\277.js" index 17abcda..8fc98fb 100644 --- "a/js/\346\250\241\346\235\277.js" +++ "b/js/\346\250\241\346\235\277.js" @@ -17,6 +17,8 @@ var muban = { // homeUrl:'/', url:'/vodshow/fyclass--------fypage---.html', searchUrl:'/vodsearch/**----------fypage---.html', + searchable:0,//是否启用全局搜索, + quickSearch:0,//是否启用快速搜索, headers:{//网站的请求头,完整支持所有的,常带ua和cookies 'User-Agent':'MOBILE_UA', "Cookie": "searchneed=ok" diff --git "a/js/\347\223\234\347\232\256TV.js" "b/js/\347\223\234\347\232\256TV.js" index d022fe4..0e4e407 100644 --- "a/js/\347\223\234\347\232\256TV.js" +++ "b/js/\347\223\234\347\232\256TV.js" @@ -4,6 +4,8 @@ var rule = { // homeUrl:'/', url:'/vodshow/fyclass--------fypage---.html', searchUrl:'/vodsearch/**----------fypage---.html', + searchable:0, + quickSearch:0, headers:{//网站的请求头,完整支持所有的,常带ua和cookies 'User-Agent':'MOBILE_UA', "Cookie": "searchneed=ok" diff --git "a/js/\347\234\213\350\247\206\347\225\214.js" "b/js/\347\234\213\350\247\206\347\225\214.js" index 2ffe1b6..c2e15be 100644 --- "a/js/\347\234\213\350\247\206\347\225\214.js" +++ "b/js/\347\234\213\350\247\206\347\225\214.js" @@ -2,6 +2,8 @@ var rule = Object.assign(muban.mxpro,{ title:'看视界', host:'https://www.1080kan.cc', url:'/show/fyclass--------fypage---.html', - searchUrl:'/search/**-------------.html', - class_parse:'.navbar-items li:gt(1):lt(6);a&&Text;a&&href;.*/(.*?).html', +searchUrl:'/search/**-------------.html', +searchable:0, +quickSearch:0, +class_parse:'.navbar-items li:gt(1):lt(6);a&&Text;a&&href;.*/(.*?).html', }); \ No newline at end of file diff --git "a/js/\350\216\253\346\211\216\345\205\224.js" "b/js/\350\216\253\346\211\216\345\205\224.js" index d6a2c0c..45e071c 100644 --- "a/js/\350\216\253\346\211\216\345\205\224.js" +++ "b/js/\350\216\253\346\211\216\345\205\224.js" @@ -4,6 +4,8 @@ var rule = { // homeUrl:'/', url:'/index.php/vod/show/id/fyclass/page/fypage.html', searchUrl:'/vodsearch/**----------fypage---.html', + searchable:0, + quickSearch:0, headers:{//网站的请求头,完整支持所有的,常带ua和cookies 'User-Agent':'MOBILE_UA', "Cookie": "searchneed=ok" diff --git "a/js/\350\223\235\350\216\223\345\275\261\350\247\206.js" "b/js/\350\223\235\350\216\223\345\275\261\350\247\206.js" index bbfe61b..9f54f93 100644 --- "a/js/\350\223\235\350\216\223\345\275\261\350\247\206.js" +++ "b/js/\350\223\235\350\216\223\345\275\261\350\247\206.js" @@ -1,5 +1,5 @@ var rule = { - title:'蓝莓影视1', + title:'蓝莓影视', host:'https://lanmeiguojiang.com', // homeUrl:'/', url:'/show/fyclass--------fypage---.html', @@ -7,6 +7,8 @@ var rule = { 'User-Agent':'MOBILE_UA' }, searchUrl:'/search/**-fypage.html', + searchable:1, + quickSearch:1, // class_name:'电影&网剧&剧集&动漫&综艺&记录', // class_url:'20&1&2&3&4&23', class_parse:'.navbar-items li:gt(1):lt(8);a&&Text;a&&href;/(\\d+).html', diff --git "a/js/\351\270\255\345\245\210\351\243\236.js" "b/js/\351\270\255\345\245\210\351\243\236.js" index ac7bbdf..239265d 100644 --- "a/js/\351\270\255\345\245\210\351\243\236.js" +++ "b/js/\351\270\255\345\245\210\351\243\236.js" @@ -5,6 +5,8 @@ var rule = { url:'/vodshow/fyclass--------fypage---.html', detailUrl:'https://yanetflix.com/voddetail/fyid.html',//非必填 searchUrl:'/vodsearch/**----------fypage---.html', + searchable:0, + quickSearch:0, // class_name:'电影&连续剧&综艺&动漫', // class_url:'dianying&lianxuju&zongyi&dongman', class_parse:'.navbar-items li:gt(1):lt(6);a&&Text;a&&href;.*/(.*?).html', diff --git a/readme.md b/readme.md index 6690a7d..bfada65 100644 --- a/readme.md +++ b/readme.md @@ -6,6 +6,9 @@ - [X] 3.增加视界的加密库 - [X] 4.增加蓝莓影视免嗅探 - [X] 5.增加免嗅耗时毫秒数统计 +- [X] 6.增加自动装载配置 +- [X] 7.增加js里单独设置某个源是否可搜索 +- [X] 8.增加外网免嗅(自定义config.py里面改) ###### 2022/08/29 - [X] 1.更换js引擎,速度更快性能更好 - [X] 2.新版js支持与python互动,后期可能支持js免嗅(lazy:'js:xxx') @@ -60,6 +63,7 @@ [远程服务配置地址](http://cms.nokia.press/config/2) ### 配置相关 +直接复制对应的三种地址就行了,不需要生成本地文件(下面教程不要了) 本地地址 clan://localhost/pycms_local.json 推荐把文件放到 /storage/emulated/0/PlutoPlayer/pycms_local.json 并且pluto要自己切换路径为PlutoPlayer @@ -78,6 +82,10 @@ var rule = { url:'/fyclass/fypage.html[/fyclass/]',//网站的分类页面链接 detailUrl:'https://yanetflix.com/voddetail/fyid.html',//非必填,二级详情拼接链接,感觉没啥卵用 searchUrl:'',//搜索链接 可以是完整路径或者相对路径,用于分类获取和推荐获取 **代表搜索词 fypage代表页数 + searchable:0,//是否启用全局搜索, + quickSearch:0,//是否启用快速搜索, + // 注意,由于猫有配置缓存,搜索配置没法热加载,修改了js不需要重启服务器 + // 但是需要tv_box进设置里换源使配置重新装载 headers:{//网站的请求头,完整支持所有的,常带ua和cookies 'User-Agent':'MOBILE_UA', "Cookie": "searchneed=ok" diff --git a/templates/config.txt b/templates/config.txt index 9fe6b7c..ea5cd4e 100644 --- a/templates/config.txt +++ b/templates/config.txt @@ -1,24 +1,24 @@ { -{% if config.WALL_PAPER_ENABLE %}"wallpaper":"http://{{ host }}/pics",{% endif %} +{% if config.WALL_PAPER_ENABLE %}"wallpaper":"{{ host }}/pics",{% endif %} "dr_count": {{rules.list|length}}, "mode": {{ mode }}, "sites": [{% for rule in rules.list %}{% if mode == 0 %} { - "key":"dr_{{ rule }}", - "name":"{{ rule }}(道长)", + "key":"dr_{{ rule.name }}", + "name":"{{ rule.name }}(道长)", "type":1, - "api":"http://{{ host }}/vod?rule={{ rule }}", - "searchable": 1, - "quickSearch": 1, + "api":"{{ host }}/vod?rule={{ rule.name }}", + "searchable": {{ rule.searchable }}, + "quickSearch": {{ rule.quickSearch }}, "filterable": 1 }{% else %} { - "key":"dr_{{ rule }}", - "name":"{{ rule }}(道长)", + "key":"dr_{{ rule.name }}", + "name":"{{ rule.name }}(道长)", "type":1, - "api":"http://{{ host }}/vod?rule={{ rule }}", - "searchable": 1, - "quickSearch": 1, + "api":"{{ host }}/vod?rule={{ rule.name }}", + "searchable": {{ rule.searchable }}, + "quickSearch": {{ rule.quickSearch }}, "filterable": 1 }{% endif %}{% if loop.last==False %},{% endif %}{% endfor %}], "parses": [{ diff --git a/templates/index.html b/templates/index.html index 9e62a7b..2e890d7 100644 --- a/templates/index.html +++ b/templates/index.html @@ -66,32 +66,36 @@ a { 缓存文件列表-查看
- 本地配置地址 + 本地配置地址
{% if is_linux %}
- 本地在线进程管理[linux] + 本地在线进程管理[linux]
{% endif %} 局域网:{{ getHost(1) }} {% if '192.168' in getHost(1) %}
- 局域网配置地址 + 局域网配置地址
{% if is_linux %}
- 局域网在线进程管理[linux] + 局域网在线进程管理[linux]
{% endif %}
- 局域网随机图片 + 局域网随机图片
{% endif %}
- 远程配置地址 + 远程配置地址
- +{% if is_linux %} +
+ 远程在线进程管理[linux] +
+{% endif %}
生成配置文件
diff --git a/utils/web.py b/utils/web.py index 697c3ee..3e1b0bd 100644 --- a/utils/web.py +++ b/utils/web.py @@ -18,6 +18,7 @@ headers = { 'user-agent': UA, } from time import time +import config as settings def get_host_ip2(): # 获取局域网ip s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -47,13 +48,13 @@ def getHost(mode=0,port=None): # print(ip) # mode 为0是本地,1是局域网 2是线上 if mode == 0: - host = f'localhost:{port}' + host = f'http://localhost:{port}' elif mode == 1: REAL_IP = get_host_ip() ip = REAL_IP - host = f'{ip}:{port}' + host = f'http://{ip}:{port}' else: - host = 'cms.nokia.press' + host = get_conf(settings).get('PLAY_URL','http://cms.nokia.press') return host def get_conf(obj): -- GitLab