提交 5a4aa3eb 编写于 作者: H hjdhnx

重要更新

上级 6ed8dedc
......@@ -18,7 +18,7 @@ from werkzeug.utils import secure_filename
from js.rules import getRuleLists
from utils import error,parser
from utils.web import *
from utils.update import checkUpdate,getOnlineVer,getLocalVer,download_new_version
from utils.update import checkUpdate,getOnlineVer,getLocalVer,download_new_version,download_lives
import sys
import codecs
from classes.cms import CMS,logger
......@@ -59,10 +59,13 @@ else:
RuleClass = rule_classes.init(db)
PlayParse = play_parse.init(db)
lsg = storage.init(db)
print(lsg.setItem('直播地址','https://gitcode.net/qq_26898231/TVBox/-/raw/main/live/zb.txt'))
t12 = time()
print(lsg.getItem('直播地址','111'))
print(get_interval(t12))
def initConfToDb():
if not lsg.getItem('LIVE_URL'):
lsg.setItem('LIVE_URL', app.config.get('LIVE_URL'))
initConfToDb()
def is_linux():
return not 'win' in sys.platform
......@@ -120,7 +123,8 @@ def admin_home(): # 管理员界面
if not verfy_token(token):
return render_template('login.html')
# return jsonify(error.success('登录成功'))
return render_template('admin.html',rules=getRules('js'),ver=getLocalVer())
live_url = lsg.getItem('LIVE_URL')
return render_template('admin.html',rules=getRules('js'),ver=getLocalVer(),live_url=live_url)
@app.route('/api/login',methods=['GET','POST'])
def login_api():
......@@ -189,6 +193,36 @@ def admin_update_ver():
msg = download_new_version()
return jsonify(error.success(msg))
@app.route('/admin/update_lives')
def admin_update_lives():
url = getParmas('url')
if not url:
return jsonify(error.failed('未提供被同步的直播源远程地址!'))
cookies = request.cookies
token = cookies.get('token', '')
if not verfy_token(token):
return jsonify(error.failed('请登录后再试'))
live_url = url
success = download_lives(live_url)
if success:
return jsonify(error.success(f'直播源{live_url}同步成功'))
else:
return jsonify(error.failed(f'直播源{live_url}同步失败'))
@app.route('/admin/write_live_url')
def admin_write_live_url():
url = getParmas('url')
if not url:
return jsonify(error.failed('未提供修改后的直播源地址!'))
cookies = request.cookies
token = cookies.get('token', '')
if not verfy_token(token):
return jsonify(error.failed('请登录后再试'))
id = lsg.setItem('LIVE_URL',url)
msg = f'已修改的配置记录id为:{id}'
return jsonify(error.success(msg))
@app.route('/upload', methods=['GET', 'POST'])
def upload_file():
cookies = request.cookies
......@@ -486,9 +520,10 @@ def random_pics():
def get_live_url(new_conf,mode):
host = getHost(mode)
live_url = host + '/lives' if new_conf.get('LIVE_MODE',
1) == 0 else new_conf.get('LIVE_URL',getHost(2)+'/lives')
# t1 = time()
live_url = host + '/lives' if new_conf.get('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
@app.route('/config/<int:mode>')
......
......@@ -466,7 +466,8 @@ class CMS:
})
except:
pass
result['list'] = videos[min((fypage-1)*self.limit,len(videos)-1):min(fypage*self.limit,len(videos))]
# result['list'] = videos[min((fypage-1)*self.limit,len(videos)-1):min(fypage*self.limit,len(videos))]
result['list'] = videos
result['code'] = 1
result['msg'] = '数据列表'
result['page'] = fypage
......
......@@ -32,7 +32,7 @@ OCR_API = 'http://dm.mudery.com:10000' # 验证码识别接口,传参数data
UNAME = 'admin' # 管理员账号
PWD = 'drpy' # 管理员密码
MAX_CONTENT_LENGTH = 1 * 1024 * 1024/100 # 100 kB
LIVE_MODE = 1 # 0 本地 1外网
LIVE_URL = 'https://gitcode.net/qq_26898231/TVBox/-/raw/main/live/zb.txt' # 外网直播地址
LIVE_MODE = 0 # 0 本地 1外网
LIVE_URL = 'https://gitcode.net/qq_26898231/TVBox/-/raw/main/live/zb.txt' # 初始化外网直播地址(后续在管理界面改)
CATE_EXCLUDE = '首页|留言|APP|下载|资讯|新闻|动态' # 动态分类过滤
# {% if config.WALL_PAPER %}"wallpaper":"{{ config.WALL_PAPER }}",{% endif %}
\ No newline at end of file
3.1.5
\ No newline at end of file
3.1.6
\ No newline at end of file
因为 它太大了无法显示 source diff 。你可以改为 查看blob
无法预览此类型文件
......@@ -48,6 +48,9 @@
[获取本地设备信息](https://m.jb51.net/article/140716.htm)
###### 2022/09/06
- [X] 1.增加了后台管理界面在线检测升级系统功能
- [X] 2.增加了后台管理界面修改直播源地址和同步直播源
- [X] 3.首页推荐内容不限制数量(新版pluto牛逼!!!)
- [X] 4.增加lsg配置模型和缓存
###### 2022/09/05
- [X] 1.内置jar修复了原本tv_box无法播放直播的问题
- [X] 2.重新构建了三种平台的镜像 amd64,armv7,arm64
......
......@@ -57,13 +57,13 @@
/* display: block !important;*/
/*}*/
.ver_title{
font-size: 15px;margin-left: 20px
font-size: 15px;margin-right: 10px
}
.ver{
font-size: 16px;margin-left: 5px;color: #ea7d7d;
font-size: 16px;margin-left: 1px;color: #ea7d7d;
}
a.funcbtn{
margin-left: 10px;
margin-right: 10px;
}
\ No newline at end of file
......@@ -105,6 +105,41 @@
alert(ret.msg);
});
});
$('#update_lives').click(function(){
let live_url = $('#live_url').val();
// console.log(live_url);
let new_live_url = prompt('输入临时同步远程直播源地址(自动获取当前配置)',live_url);
if(new_live_url.startsWith('http')){
$.get("/admin/update_lives?url="+new_live_url,function(data,status){
console.log("数据: " + data + "\n状态: " + status);
if(data.code === 200){
alert('操作成功!\n'+data.msg);
// location.reload();
}else{
alert('操作失败!\n'+data.msg);
}
});
}
});
$('#write_lives').click(function(){
let live_url = $('#live_url').val();
let new_live_url = prompt('请修改默认的远程直播源地址',live_url);
if(new_live_url){
console.log('修改直播源地址为:'+new_live_url);
$.get("/admin/write_live_url?url="+new_live_url,function(data,status){
console.log("数据: " + data + "\n状态: " + status);
if(data.code === 200){
alert('操作成功!\n'+data.msg);
location.reload();
}else{
alert('操作失败!\n'+data.msg);
}
});
}
});
});
function getFileSize(fileObj) {
$('#file_size').text('文件大小为:'+fileObj.files[0].size/1024+'kb');
......@@ -120,8 +155,10 @@ function getFileSize(fileObj) {
<a href="javascript:void(0);" class="funcbtn" id="checkUpdate">检测升级</a>
<!--<a href="javascript:copyText('update_by_self');" class="funcbtn" id="update_by_self">cp ./tmp/dr_py-master/app.py ./app.py</a>-->
<a href="javascript:copy('cp ./tmp/dr_py-master/app.py ./app.py');" class="funcbtn" id="update_by_self">复制主程升级指令</a>
<a href="javascript:void(0);" class="funcbtn" id="write_lives">修改默认直播源</a>
<a href="javascript:void(0);" class="funcbtn" id="update_lives">同步直播源</a>
</h4>
<input id="live_url" value="{{live_url}}" style="display: none"/>
<p>你可以在此页面在线上传规则文件到js目录或者删除js目录的文件</p>
<form action = "/upload" method = "POST" enctype = "multipart/form-data">
<!-- <input type = "file" name = "file" class="btn" accept=".js" onchange="getFileSize(this)"/>-->
......@@ -130,7 +167,6 @@ function getFileSize(fileObj) {
<input type="button" id="upload" value="上传" class="btn"/>
</form>
<p id="file_size"></p>
<h1>内置规则列表-共{{rules.count}}条</h1>
{% if rules.count < 1 %}
<h3>暂无内置的规则</h3>
......
......@@ -3,6 +3,7 @@
# File : update.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/9/6
import re
from time import time as getTime
import requests
......@@ -12,6 +13,11 @@ import shutil # https://blog.csdn.net/weixin_33130113/article/details/112336581
from utils.log import logger
from utils.web import get_interval
headers = {
'Referer': 'https://gitcode.net/',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36',
}
def getLocalVer():
base_path = os.path.dirname(os.path.abspath(os.path.dirname(__file__))) # 上级目录
version_path = os.path.join(base_path, f'js/version.txt')
......@@ -84,10 +90,6 @@ def download_new_version():
# print(f'清除缓存文件:{tp}')
# os.remove(os.path.join(tmp_path, tp))
del_file(tmp_path)
headers = {
'Referer': 'https://gitcode.net/',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36',
}
msg = ''
try:
# print(f'开始下载:{url}')
......@@ -112,4 +114,25 @@ def download_new_version():
except Exception as e:
msg = f'升级失败:{e}'
logger.info(f'系统升级共计耗时:{get_interval(t1)}毫秒')
return msg
\ No newline at end of file
return msg
def download_lives(live_url:str):
t1 = getTime()
base_path = os.path.dirname(os.path.abspath(os.path.dirname(__file__))) # 上级目录
live_path = os.path.join(base_path, f'js/直播.txt')
logger.info(f'尝试同步{live_url}远程内容到{live_path}')
try:
r = requests.get(live_url,headers=headers,timeout=3)
html = r.text
# print(len(html))
if re.search('cctv|.m3u8',html,re.M|re.I) and len(html) > 1000:
logger.info(f'直播源同步成功,耗时{get_interval(t1)}毫秒')
with open(live_path,mode='w+',encoding='utf-8') as f:
f.write(html)
return True
else:
logger.info(f'直播源同步失败,远程文件看起来不是直播源。耗时{get_interval(t1)}毫秒')
return False
except Exception as e:
logger.info(f'直播源同步失败,耗时{get_interval(t1)}毫秒\n{e}')
return False
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册