From 0757eebb5fb450d44f651725cd04296b04ffc6d3 Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Sat, 10 Sep 2022 14:20:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0py=E6=BA=90=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/config.py | 1 + controllers/admin.py | 25 ++++++++++++++++++++++++- controllers/home.py | 12 +++++++++--- controllers/service.py | 4 ++++ js/version.txt | 2 +- models/rules.db | Bin 40960 -> 40960 bytes readme.md | 3 ++- templates/admin.html | 16 ++++++++++++++++ templates/config.txt | 2 ++ txt/pycms0.json | 20 +++++++++++++++++++- txt/pycms1.json | 20 +++++++++++++++++++- txt/pycms2.json | 20 +++++++++++++++++++- 12 files changed, 116 insertions(+), 9 deletions(-) diff --git a/base/config.py b/base/config.py index 6883e17..50e7a9c 100644 --- a/base/config.py +++ b/base/config.py @@ -31,6 +31,7 @@ RETRY_CNT = 3 # 验证码重试次数 OCR_API = 'http://dm.mudery.com:10000' # 验证码识别接口,传参数data UNAME = 'admin' # 管理员账号 PWD = 'drpy' # 管理员密码 +USE_PY = 0 # 开启py源 MAX_CONTENT_LENGTH = 1 * 1024 * 1024/100 # 100 kB LIVE_MODE = 0 # 0 本地 1外网 LIVE_URL = 'https://gitcode.net/qq_26898231/TVBox/-/raw/main/live/zb.txt' # 初始化外网直播地址(后续在管理界面改) diff --git a/controllers/admin.py b/controllers/admin.py index dc4862b..1f69750 100644 --- a/controllers/admin.py +++ b/controllers/admin.py @@ -33,11 +33,13 @@ admin = Blueprint("admin", __name__) def admin_index(): # 管理员界面 lsg = storage_service() live_url = lsg.getItem('LIVE_URL') + use_py = lsg.getItem('USE_PY') print(f'live_url:',live_url) if not verfy_token(): return render_template('login.html') + live_url = lsg.getItem('LIVE_URL') - return render_template('admin.html', rules=getRules('js'), ver=getLocalVer(), live_url=live_url) + return render_template('admin.html', pystate=use_py,rules=getRules('js'), ver=getLocalVer(), live_url=live_url) @admin.route("/view/",methods=['GET']) def admin_view_rule(name): @@ -115,6 +117,27 @@ def admin_write_live_url(): msg = f'已修改的配置记录id为:{id}' return R.success(msg) +@admin.route('/change_use_py') +def admin_change_use_py(): + if not verfy_token(): + return R.failed('请登录后再试') + lsg = storage_service() + use_py = lsg.getItem('USE_PY') + new_use_py = '' if use_py else '1' + state = '开启' if new_use_py else '关闭' + id = lsg.setItem('USE_PY', new_use_py) + msg = f'已修改的配置记录id为:{id},结果为{state}' + return R.success(msg) + +# @admin.route('/get_use_py') +# def admin_get_use_py(): +# if not verfy_token(): +# return R.failed('请登录后再试') +# lsg = storage_service() +# use_py = lsg.getItem('USE_PY') +# state = 1 if use_py else 0 +# return R.success(state) + @admin.route('/upload', methods=['GET', 'POST']) def upload_file(): if not verfy_token(): diff --git a/controllers/home.py b/controllers/home.py index e21e569..b45e5fd 100644 --- a/controllers/home.py +++ b/controllers/home.py @@ -180,8 +180,11 @@ def config_render(mode): except Exception as e: logger.info(f'用户自定义配置加载失败:{e}') jxs = getJxs() - pys = getPys() - print(pys) + lsg = storage_service() + use_py = lsg.getItem('USE_PY') + # pys = getPys() if cfg.get('USE_PY') else [] + pys = getPys() if use_py else [] + # print(pys) alists = getAlist() alists_str = json.dumps(alists, ensure_ascii=False) live_url = get_live_url(new_conf,mode) @@ -201,7 +204,10 @@ def config_gen(): os.makedirs('txt',exist_ok=True) new_conf = cfg jxs = getJxs() - pys = getPys() + # pys = getPys() if cfg.get('USE_PY') else [] + lsg = storage_service() + use_py = lsg.getItem('USE_PY') + pys = getPys() if use_py else False alists = getAlist() alists_str = json.dumps(alists,ensure_ascii=False) set_local = render_template('config.txt',pys=pys,rules=getRules('js'),alists=alists,alists_str=alists_str,live_url=get_live_url(new_conf,0),mode=0,host=getHost(0),jxs=jxs) diff --git a/controllers/service.py b/controllers/service.py index 0c74244..b7d44af 100644 --- a/controllers/service.py +++ b/controllers/service.py @@ -21,6 +21,10 @@ class storage_service(object): print('开始初始化lsg') self.setItem('LIVE_URL', cfg.get('LIVE_URL')) + # if not self.getItem('USE_PY'): + # print('开始初始化USE_PY') + # self.setItem('USE_PY', '1' if cfg.get('USE_PY') else '') + @classmethod def getItem(self, key, value=''): return Storage.getItem(key,value) diff --git a/js/version.txt b/js/version.txt index 3ec370e..81f1b89 100644 --- a/js/version.txt +++ b/js/version.txt @@ -1 +1 @@ -3.4.5 \ No newline at end of file +3.4.7 \ No newline at end of file diff --git a/models/rules.db b/models/rules.db index 7f162051936025886c761008807a1aafedec958d..fd82c28ca2ca2db7f55d5a6ca635e52a2d218de8 100644 GIT binary patch delta 99 zcmZoTz|?SnX@WH4s);hrjH@;#EUD*U;$OkQzmdr*F1*}KEDVzTp~0^4 y0g;B2xAyx3)x2cj|HA(gsOCDqEDy6RqmL&Svm_%#4HGxBET@lWm}`7!kPiSDSR97{ delta 99 zcmZoTz|?SnX@WH4jEOSNj59VSEUD*U修改直播源 + diff --git a/templates/config.txt b/templates/config.txt index 1f18e0a..01a1ac8 100644 --- a/templates/config.txt +++ b/templates/config.txt @@ -24,6 +24,7 @@ "quickSearch": {{ rule.quickSearch }}, "filterable": {{ rule.filterable }} }{% endif %}{% if loop.last==False %},{% endif %}{% endfor %} +{% if pys %} ,{% for py in pys %}{ "key":"{{ py.name }}", "name":"{{ py.name }}(Pyramid)", @@ -34,6 +35,7 @@ "filterable": {{ py.filterable }}, "ext": "{{ host }}/txt/py/{{ py.name }}.py" }{% if loop.last==False %},{% endif %}{% endfor %} +{% endif %} ], "parses": [{ "name": "🌐Ⓤ", diff --git a/txt/pycms0.json b/txt/pycms0.json index b95ea2e..038aa70 100644 --- a/txt/pycms0.json +++ b/txt/pycms0.json @@ -1,6 +1,6 @@ { "wallpaper": "http://localhost:5705/pics", - "dr_count": 28, + "dr_count": 30, "mode": 0, "spider": "http://localhost:5705/liveslib", "drives": [ @@ -204,6 +204,15 @@ "quickSearch": 1, "filterable": 0 }, + { + "key": "dr_兔小贝", + "name": "兔小贝(道长)", + "type": 1, + "api": "http://localhost:5705/vod?rule=兔小贝", + "searchable": 1, + "quickSearch": 0, + "filterable": 0 + }, { "key": "dr_养端", "name": "养端(道长)", @@ -267,6 +276,15 @@ "quickSearch": 1, "filterable": 0 }, + { + "key": "dr_小强迷", + "name": "小强迷(道长)", + "type": 1, + "api": "http://localhost:5705/vod?rule=小强迷", + "searchable": 1, + "quickSearch": 1, + "filterable": 0 + }, { "key": "dr_小猫咪", "name": "小猫咪(道长)", diff --git a/txt/pycms1.json b/txt/pycms1.json index 4e44971..dbea2e5 100644 --- a/txt/pycms1.json +++ b/txt/pycms1.json @@ -1,6 +1,6 @@ { "wallpaper": "http://192.168.3.224:5705/pics", - "dr_count": 28, + "dr_count": 30, "mode": 1, "spider": "http://192.168.3.224:5705/liveslib", "drives": [ @@ -204,6 +204,15 @@ "quickSearch": 1, "filterable": 0 }, + { + "key": "dr_兔小贝", + "name": "兔小贝(道长)", + "type": 1, + "api": "http://192.168.3.224:5705/vod?rule=兔小贝", + "searchable": 1, + "quickSearch": 0, + "filterable": 0 + }, { "key": "dr_养端", "name": "养端(道长)", @@ -267,6 +276,15 @@ "quickSearch": 1, "filterable": 0 }, + { + "key": "dr_小强迷", + "name": "小强迷(道长)", + "type": 1, + "api": "http://192.168.3.224:5705/vod?rule=小强迷", + "searchable": 1, + "quickSearch": 1, + "filterable": 0 + }, { "key": "dr_小猫咪", "name": "小猫咪(道长)", diff --git a/txt/pycms2.json b/txt/pycms2.json index 8606bf9..e5b8c6e 100644 --- a/txt/pycms2.json +++ b/txt/pycms2.json @@ -1,6 +1,6 @@ { "wallpaper": "http://cms.nokia.press/pics", - "dr_count": 28, + "dr_count": 30, "mode": 1, "spider": "http://cms.nokia.press/liveslib", "drives": [ @@ -204,6 +204,15 @@ "quickSearch": 1, "filterable": 0 }, + { + "key": "dr_兔小贝", + "name": "兔小贝(道长)", + "type": 1, + "api": "http://cms.nokia.press/vod?rule=兔小贝", + "searchable": 1, + "quickSearch": 0, + "filterable": 0 + }, { "key": "dr_养端", "name": "养端(道长)", @@ -267,6 +276,15 @@ "quickSearch": 1, "filterable": 0 }, + { + "key": "dr_小强迷", + "name": "小强迷(道长)", + "type": 1, + "api": "http://cms.nokia.press/vod?rule=小强迷", + "searchable": 1, + "quickSearch": 1, + "filterable": 0 + }, { "key": "dr_小猫咪", "name": "小猫咪(道长)", -- GitLab