提交 ff5936ef 编写于 作者: H hjdhnx

增加了一堆Bug

上级 4167eeed
......@@ -22,7 +22,9 @@ def create_flask_app():
app.register_blueprint(vod.vod, url_prefix='')
app.register_blueprint(cls.cls, url_prefix='/cls')
app.logger.name = "drLogger"
logger.info(f"自定义播放解析地址:{app.config.get('PLAY_URL')}")
# lsg = service.storage_service()
logger.info(f"默认解析地址:{app.config.get('PLAY_URL')}")
# logger.info(f"自定义播放解析地址:{lsg.getItem('PLAY_URL')}")
logger.info(f'当前操作系统{sys.platform}')
rule_list = getRuleLists()
wlan_info,_ = get_wlan_info()
......
无法预览此类型文件
......@@ -31,15 +31,37 @@ admin = Blueprint("admin", __name__)
@admin.route('/')
def admin_index(): # 管理员界面
if not verfy_token():
return render_template('login.html')
lsg = storage_service()
live_url = lsg.getItem('LIVE_URL')
use_py = lsg.getItem('USE_PY')
print(f'live_url:',live_url)
print(f'live_url:', live_url)
return render_template('admin.html', pystate=use_py,rules=getRules('js'), ver=getLocalVer(), live_url=live_url)
@admin.route('/settings')
def admin_settings(): # 管理员界面
if not verfy_token():
return render_template('login.html')
lsg = storage_service()
# conf_list = 'LIVE_URL|USE_PY|PLAY_URL|PLAY_DISABLE|LAZYPARSE_MODE|WALL_PAPER_ENABLE|WALL_PAPER|UNAME|PWD|LIVE_MODE|LIVE_URL|CATE_EXCLUDE|TAB_EXCLUDE'.split('|')
conf_lists = lsg.getStoreConf()
# print(conf_lists)
return render_template('settings.html', conf_lists=conf_lists,ver=getLocalVer())
@admin.route('/save_conf',methods=['POST'])
def admin_save_conf(): # 管理员界面
if not verfy_token():
if not verfy_token():
# return render_template('login.html')
return R.error('请登录后再试')
key = getParmas('key')
value = getParmas('value')
print(f'key:{key},value:{value}')
lsg = storage_service()
res_id = lsg.setItem(key,value)
return R.success(f'修改成功,记录ID为:{res_id}')
live_url = lsg.getItem('LIVE_URL')
return render_template('admin.html', pystate=use_py,rules=getRules('js'), ver=getLocalVer(), live_url=live_url)
@admin.route("/view/<name>",methods=['GET'])
def admin_view_rule(name):
......
......@@ -21,6 +21,7 @@ from urllib.parse import urljoin
from concurrent.futures import ThreadPoolExecutor # 引入线程池
from flask import url_for,redirect
from easydict import EasyDict as edict
from controllers.service import storage_service
py_ctx = {
'requests':requests,'print':print,'base64Encode':base64Encode,'baseDecode':baseDecode,
......@@ -34,17 +35,22 @@ class CMS:
def __init__(self, rule, db=None, RuleClass=None, PlayParse=None,new_conf=None):
if new_conf is None:
new_conf = {}
self.lsg = storage_service()
self.title = rule.get('title', '')
self.id = rule.get('id', self.title)
cate_exclude = rule.get('cate_exclude','')
tab_exclude = rule.get('tab_exclude','')
self.lazy = rule.get('lazy', False)
self.play_disable = new_conf.get('PLAY_DISABLE',False)
# self.play_disable = new_conf.get('PLAY_DISABLE',False)
self.play_disable = self.lsg.getItem('PLAY_DISABLE',False)
self.retry_count = new_conf.get('RETRY_CNT',3)
self.lazy_mode = new_conf.get('LAZYPARSE_MODE')
# self.lazy_mode = new_conf.get('LAZYPARSE_MODE')
self.lazy_mode = self.lsg.getItem('LAZYPARSE_MODE')
self.ocr_api = new_conf.get('OCR_API')
self.cate_exclude = new_conf.get('CATE_EXCLUDE','')
self.tab_exclude = new_conf.get('TAB_EXCLUDE','')
# self.cate_exclude = new_conf.get('CATE_EXCLUDE','')
self.cate_exclude = self.lsg.getItem('CATE_EXCLUDE','')
# self.tab_exclude = new_conf.get('TAB_EXCLUDE','')
self.tab_exclude = self.lsg.getItem('TAB_EXCLUDE','')
if cate_exclude:
if not str(cate_exclude).startswith('|') and not str(self.cate_exclude).endswith('|'):
self.cate_exclude = self.cate_exclude+'|'+cate_exclude
......
......@@ -13,7 +13,8 @@ from utils.web import getParmas
from utils.files import getPics,custom_merge
from js.rules import getRules,getPys
from base.R import R
from utils.system import cfg,getHost,is_linux
from utils.system import getHost,is_linux
from utils.cfg import cfg
from utils import parser
from utils.log import logger
from utils.files import getAlist,get_live_url
......@@ -61,8 +62,8 @@ def random_pics():
id = getParmas('id')
# print(f'id:{id}')
pics = getPics()
print(pics)
if len(pics) > 0:
# print(pics)
if not cfg.WALL_PAPER and len(pics) > 0:
if id and f'images/{id}.jpg' in pics:
pic = f'images/{id}.jpg'
else:
......@@ -172,6 +173,9 @@ def config_render(mode):
jyw_ip = getHost(mode)
logger.info(jyw_ip)
new_conf = cfg
lsg = storage_service()
store_conf_dict = lsg.getStoreConfDict()
new_conf.update(store_conf_dict)
host = getHost(mode)
try:
with open(customFile,'r',encoding='utf-8') as f:
......@@ -203,6 +207,9 @@ def config_gen():
# 生成文件
os.makedirs('txt',exist_ok=True)
new_conf = cfg
lsg = storage_service()
store_conf_dict = lsg.getStoreConfDict()
new_conf.update(store_conf_dict)
jxs = getJxs()
# pys = getPys() if cfg.get('USE_PY') else []
lsg = storage_service()
......
......@@ -6,7 +6,7 @@
from base.R import copy_utils
from models.storage import Storage
from utils.system import cfg
from utils.cfg import cfg
class storage_service(object):
......@@ -17,17 +17,47 @@ class storage_service(object):
return copy_utils.obj_to_list(res)
def __init__(self):
if not self.getItem('LIVE_URL'):
print('开始初始化lsg')
self.setItem('LIVE_URL', cfg.get('LIVE_URL'))
conf_list = ['LIVE_URL', 'USE_PY', 'PLAY_URL', 'PLAY_DISABLE', 'LAZYPARSE_MODE', 'WALL_PAPER_ENABLE',
'WALL_PAPER', 'UNAME', 'PWD', 'LIVE_MODE', 'CATE_EXCLUDE', 'TAB_EXCLUDE']
for conf in conf_list:
if not self.hasItem(conf):
print(f'开始初始化{conf}')
self.setItem(conf, cfg.get(conf))
# if not self.getItem('USE_PY'):
# print('开始初始化USE_PY')
# self.setItem('USE_PY', '1' if cfg.get('USE_PY') else '')
@classmethod
def getStoreConf(self):
conf_list = ['LIVE_URL', 'USE_PY', 'PLAY_URL', 'PLAY_DISABLE', 'LAZYPARSE_MODE', 'WALL_PAPER_ENABLE',
'WALL_PAPER', 'UNAME', 'PWD', 'LIVE_MODE', 'CATE_EXCLUDE', 'TAB_EXCLUDE']
conf_name_list = ['直播地址', '启用py源', '远程地址', '禁用免嗅', '免嗅模式', '启用壁纸', '壁纸链接', '管理账号',
'管理密码', '直播模式', '分类排除', '线路排除']
conf_lists = []
for i in range(len(conf_list)):
conf = conf_list[i]
conf_lists.append({
'key': conf,
'value': self.getItem(conf),
'name': conf_name_list[i]
})
return conf_lists
@classmethod
def getStoreConfDict(self):
store_conf = self.getStoreConf()
store_conf_dict = {}
for stc in store_conf:
store_conf_dict[stc['key']] = stc['value']
return store_conf_dict
@classmethod
def getItem(self, key, value=''):
return Storage.getItem(key,value)
res = Storage.getItem(key,value)
if str(res) == '0' or str(res) == 'false' or str(res) == 'False':
return 0
return res
@classmethod
def hasItem(self, key):
return Storage.hasItem(key)
@classmethod
def setItem(self,key, value):
......
3.4.7
\ No newline at end of file
3.5.0
\ No newline at end of file
......@@ -6,7 +6,6 @@
from base.database import db
from functools import lru_cache
from utils.system import cfg
class Storage(db.Model):
__tablename__ = 'storage'
......@@ -47,6 +46,16 @@ class Storage(db.Model):
else:
return value
@classmethod
@lru_cache(maxsize=200)
def hasItem(self, key):
exists = db.session.query(self).filter(self.key == key).scalar() is not None
# res = db.session.query(self).filter(self.key == key).
if exists:
return True
else:
return False
@classmethod
def clearItem(self, key):
self.clearCache()
......
......@@ -46,6 +46,8 @@
[dockerfile教程](https://blog.csdn.net/qq_46158060/article/details/125718218)
[获取本地设备信息](https://blog.csdn.net/cui_yonghua/article/details/125508991)
[获取本地设备信息](https://m.jb51.net/article/140716.htm)
###### 2022/09/11
- [X] 1.升级至3.5.0.后台管理增加设置中心 (可能会存在bug)
###### 2022/09/10
- [X] 1.升级至3.4.4.增加小强迷源,增加二级重定向属性(提供重定向后的源码,让代码重新取重定向过后的线路和播放列表)
- [X] 2.升级至3.4.5.增加兔小贝儿歌源,优化json:细节处理以及详情页拼接细节
......
.save_conf{
border-radius: 50px;
border-style: solid;
color: #FFFFFF;
text-align: center;
padding: 1px 3px 1px 3px;
border-style: solid;
border-color: #5c6cf6;
text-decoration: none;
background-color: #1379cb;
}
input.conf{
margin-bottom: 10px;
width: 240px;
}
label{
font-size: 12px;
color: #5c6cf6;
font-weight: bold;
}
\ No newline at end of file
......@@ -188,20 +188,22 @@ function getFileSize(fileObj) {
</h2>
<h4>
<button type="button" class="yongyin"><a href="/index">返回首页</a></button>
<button type="button" class="yongyin"><a href="/admin/settings">设置中心</a></button>
<button type="button" class="yongyin1"><a href="javascript:void(0);" class="funcbtn"
id="checkUpdate">检测升级</a></button>
<button type="button" class="yongyin2"><a href="javascript:copy('cp ./tmp/dr_py-master/app.py ./app.py');"
class="funcbtn" id="update_by_self">升级指令</a></button>
<button type="button" class="yongyin2"><a href="javascript:copy('cp ./tmp/dr_py-master/base/custom.conf base');"
class="funcbtn" id="user_custom">用户配置</a></button>
<button type="button" class="yongyin1"><a href="javascript:void(0);" class="funcbtn"
id="force_update">强制升级</a></button>
<!-- <button type="button" class="yongyin2"><a href="javascript:copy('cp ./tmp/dr_py-master/app.py ./app.py');"-->
<!-- class="funcbtn" id="update_by_self">升级指令</a></button>-->
<!-- <button type="button" class="yongyin2"><a href="javascript:copy('cp ./tmp/dr_py-master/base/custom.conf base');"-->
<!-- class="funcbtn" id="user_custom">用户配置</a></button>-->
<button type="button" class="yongyin3"><a href="javascript:void(0);" class="funcbtn"
id="write_lives">修改直播源</a></button>
<button type="button" class="yongyin4"><a href="javascript:void(0);" class="funcbtn"
id="update_lives">同步直播源</a></button>
<button type="button" class="yongyin3"><a href="javascript:void(0);" class="funcbtn"
id="use_py">已{% if pystate=='1' %}启用{% else %}关闭{% endif %}py源</a></button>
<button type="button" class="yongyin1"><a href="javascript:void(0);" class="funcbtn"
id="force_update">强制升级</a></button>
<input id="live_url" value="{{live_url}}" style="display: none">
<p class="box">你可以在此界面在线管理JS目录里规则文件的上传/删除</p>
</h4>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>管理员操作中心-配置修改</title>
<meta name="description" content="particles.js is a lightweight JavaScript library for creating particles.">
<meta name="author" content="道长"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" media="screen" href="/static/css/admin.css">
<link rel="stylesheet" media="screen" href="/static/css/settings.css">
<link rel="icon" href="/static/img/logo.png" type="image/x-icon">
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/common.js"></script>
</head>
<body>
<script>
function saveConf(obj){
let thisObj=$(obj);//js对象转jquery对象
let key = thisObj.attr("value");
let value = $('.conf[name="'+key+'"]').val();
console.log('key:'+key+',value:'+value);
let params = {
key:key,
value:value
};
$.post("/admin/save_conf",params,function(data,status){
// console.log(data);
if(data.code === 200){
alert(data.msg);
console.log('保存'+key+'成功了...');
// location.reload();
}else{
if(/登录/.test(data.msg)){
location.href = '/admin'
}else{
alert(data.msg);
console.log('保存'+key+'失败了...');
return false
}
}
});
}
$(document).ready(function() {
$(".save_conf1").click(function () {
console.log(this);
});
});
</script>
<h2 class="title">欢迎使用DR-PY配置界面<div><span class="ver_title">当前版本: {{ ver }}</span><span
class="ver_title">框架开发:道长</span><span class="ver_title">框架美化:蓝莓</span></div>
</h2>
<h4>
<button type="button" class="yongyin"><a href="/admin">返回管理页</a></button>
<!-- <button type="button" class="yongyin"><a href="/index">返回首页</a></button>-->
<button type="button" class="yongyin2"><a href="javascript:copy('cp ./tmp/dr_py-master/app.py ./app.py');"
class="funcbtn" id="update_by_self">升级指令</a></button>
<button type="button" class="yongyin2"><a href="javascript:copy('cp ./tmp/dr_py-master/base/custom.conf base');"
class="funcbtn" id="user_custom">用户配置</a></button>
</h4>
<form action="#">
{% for conf in conf_lists %}
<label>{{ conf.name }}</label>: <input class="conf" type="text" name="{{ conf.key }}" placeholder="请输入{{ conf.key }}..." value="{{ conf.value }}"/>
<a class="save_conf" href="javascript:void(0);" onclick="saveConf(this)" value="{{ conf.key }}">保存</a>
{% if loop.last==False %}</br>{% endif %}{% endfor %}
</form>
</body>
</html>
\ No newline at end of file
{
"wallpaper": "http://localhost:5705/pics",
"dr_count": 30,
"dr_count": 27,
"mode": 0,
"spider": "http://localhost:5705/liveslib",
"drives": [
......@@ -213,15 +213,6 @@
"quickSearch": 0,
"filterable": 0
},
{
"key": "dr_养端",
"name": "养端(道长)",
"type": 1,
"api": "http://localhost:5705/vod?rule=养端",
"searchable": 0,
"quickSearch": 0,
"filterable": 0
},
{
"key": "dr_剧白白",
"name": "剧白白(道长)",
......@@ -231,15 +222,6 @@
"quickSearch": 1,
"filterable": 0
},
{
"key": "dr_吸瓜",
"name": "吸瓜(道长)",
"type": 1,
"api": "http://localhost:5705/vod?rule=吸瓜",
"searchable": 0,
"quickSearch": 0,
"filterable": 0
},
{
"key": "dr_喵喵",
"name": "喵喵(道长)",
......@@ -321,15 +303,6 @@
"quickSearch": 1,
"filterable": 0
},
{
"key": "dr_玩偶姐姐",
"name": "玩偶姐姐(道长)",
"type": 1,
"api": "http://localhost:5705/vod?rule=玩偶姐姐",
"searchable": 0,
"quickSearch": 0,
"filterable": 0
},
{
"key": "dr_瓜皮TV",
"name": "瓜皮TV(道长)",
......@@ -843,7 +816,7 @@
{
"name": "直播",
"urls": [
"proxy://do=live&type=txt&ext=aHR0cDovL2xvY2FsaG9zdDo1NzA1L2xpdmVz"
"proxy://do=live&type=txt&ext=aHR0cHM6Ly9naXRjb2RlLm5ldC9xcV8yNjg5ODIzMS9UVkJveC8tL3Jhdy9tYWluL2xpdmUvemIudHh0"
]
}
]
......
{
"wallpaper": "http://192.168.3.224:5705/pics",
"dr_count": 30,
"dr_count": 27,
"mode": 1,
"spider": "http://192.168.3.224:5705/liveslib",
"drives": [
......@@ -213,15 +213,6 @@
"quickSearch": 0,
"filterable": 0
},
{
"key": "dr_养端",
"name": "养端(道长)",
"type": 1,
"api": "http://192.168.3.224:5705/vod?rule=养端",
"searchable": 0,
"quickSearch": 0,
"filterable": 0
},
{
"key": "dr_剧白白",
"name": "剧白白(道长)",
......@@ -231,15 +222,6 @@
"quickSearch": 1,
"filterable": 0
},
{
"key": "dr_吸瓜",
"name": "吸瓜(道长)",
"type": 1,
"api": "http://192.168.3.224:5705/vod?rule=吸瓜",
"searchable": 0,
"quickSearch": 0,
"filterable": 0
},
{
"key": "dr_喵喵",
"name": "喵喵(道长)",
......@@ -321,15 +303,6 @@
"quickSearch": 1,
"filterable": 0
},
{
"key": "dr_玩偶姐姐",
"name": "玩偶姐姐(道长)",
"type": 1,
"api": "http://192.168.3.224:5705/vod?rule=玩偶姐姐",
"searchable": 0,
"quickSearch": 0,
"filterable": 0
},
{
"key": "dr_瓜皮TV",
"name": "瓜皮TV(道长)",
......@@ -843,7 +816,7 @@
{
"name": "直播",
"urls": [
"proxy://do=live&type=txt&ext=aHR0cDovLzE5Mi4xNjguMy4yMjQ6NTcwNS9saXZlcw=="
"proxy://do=live&type=txt&ext=aHR0cHM6Ly9naXRjb2RlLm5ldC9xcV8yNjg5ODIzMS9UVkJveC8tL3Jhdy9tYWluL2xpdmUvemIudHh0"
]
}
]
......
{
"wallpaper": "http://cms.nokia.press/pics",
"dr_count": 30,
"dr_count": 27,
"mode": 1,
"spider": "http://cms.nokia.press/liveslib",
"drives": [
......@@ -213,15 +213,6 @@
"quickSearch": 0,
"filterable": 0
},
{
"key": "dr_养端",
"name": "养端(道长)",
"type": 1,
"api": "http://cms.nokia.press/vod?rule=养端",
"searchable": 0,
"quickSearch": 0,
"filterable": 0
},
{
"key": "dr_剧白白",
"name": "剧白白(道长)",
......@@ -231,15 +222,6 @@
"quickSearch": 1,
"filterable": 0
},
{
"key": "dr_吸瓜",
"name": "吸瓜(道长)",
"type": 1,
"api": "http://cms.nokia.press/vod?rule=吸瓜",
"searchable": 0,
"quickSearch": 0,
"filterable": 0
},
{
"key": "dr_喵喵",
"name": "喵喵(道长)",
......@@ -321,15 +303,6 @@
"quickSearch": 1,
"filterable": 0
},
{
"key": "dr_玩偶姐姐",
"name": "玩偶姐姐(道长)",
"type": 1,
"api": "http://cms.nokia.press/vod?rule=玩偶姐姐",
"searchable": 0,
"quickSearch": 0,
"filterable": 0
},
{
"key": "dr_瓜皮TV",
"name": "瓜皮TV(道长)",
......@@ -843,7 +816,7 @@
{
"name": "直播",
"urls": [
"proxy://do=live&type=txt&ext=aHR0cDovL2Ntcy5ub2tpYS5wcmVzcy9saXZlcw=="
"proxy://do=live&type=txt&ext=aHR0cHM6Ly9naXRjb2RlLm5ldC9xcV8yNjg5ODIzMS9UVkJveC8tL3Jhdy9tYWluL2xpdmUvemIudHh0"
]
}
]
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File : cfg.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/9/10
from werkzeug.utils import import_string
from base import config
from easydict import EasyDict as edict
def get_conf(obj):
new_conf = {}
if isinstance(obj, str):
obj = import_string(obj)
for key in dir(obj):
if key.isupper():
new_conf[key] = getattr(obj, key)
return new_conf
cfg = edict(get_conf(config))
\ No newline at end of file
......@@ -16,7 +16,7 @@ def getPics(path='images'):
file_name = os.listdir(img_path)
# file_name = list(filter(lambda x: str(x).endswith('.js') and str(x).find('模板') < 0, file_name))
# print(file_name)
pic_list = [base_path+file for file in file_name]
pic_list = [img_path+'/'+file for file in file_name]
# pic_list = file_name
# print(type(pic_list))
return pic_list
......@@ -25,7 +25,8 @@ def get_live_url(new_conf,mode):
host = getHost(mode)
lsg = storage_service()
# t1 = time()
live_url = host + '/lives' if new_conf.get('LIVE_MODE',1) == 0 else lsg.getItem('LIVE_URL',getHost(2)+'/lives')
# live_url = host + '/lives' if new_conf.get('LIVE_MODE',1) == 0 else lsg.getItem('LIVE_URL',getHost(2)+'/lives')
live_url = host + '/lives' if lsg.getItem('LIVE_MODE',1) == 0 else lsg.getItem('LIVE_URL',getHost(2)+'/lives')
live_url = base64Encode(live_url)
# print(f'{get_interval(t1)}毫秒')
return live_url
......
......@@ -4,23 +4,10 @@
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/9/6
from werkzeug.utils import import_string
from base import config
from flask import request
import psutil
import sys
from easydict import EasyDict as edict
def get_conf(obj):
new_conf = {}
if isinstance(obj, str):
obj = import_string(obj)
for key in dir(obj):
if key.isupper():
new_conf[key] = getattr(obj, key)
return new_conf
cfg = edict(get_conf(config))
from utils.cfg import cfg
def get_wlan_info():
info = psutil.net_if_addrs()
......@@ -51,7 +38,11 @@ def getHost(mode=0,port=None):
ip = REAL_IP
host = f'http://{ip}:{port}'
else:
host = cfg.get('PLAY_URL','http://cms.nokia.press')
# host = cfg.get('PLAY_URL','http://cms.nokia.press')
from controllers.service import storage_service
lsg = storage_service()
host = lsg.getItem('PLAY_URL',cfg.get('PLAY_URL',''))
# print(mode,host)
return host
def is_linux():
......
......@@ -8,7 +8,8 @@ import os
from flask import request
import hashlib
from time import time
from utils.system import cfg
from utils.cfg import cfg
from controllers.service import storage_service
MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36'
PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36'
......@@ -53,8 +54,11 @@ def verfy_token(token=None):
token = cookies.get('token', '')
if not token or len(str(token)) != 32:
return False
username = cfg.get('UNAME','')
pwd = cfg.get('PWD','')
lsg = storage_service()
# username = cfg.get('UNAME','')
username = lsg.getItem('UNAME','')
# pwd = cfg.get('PWD','')
pwd = lsg.getItem('PWD','')
ctoken = md5(f'{username};{pwd}')
# print(f'username:{username},pwd:{pwd},current_token:{ctoken},input_token:{ctoken}')
if token != ctoken:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册