提交 6ed8dedc 编写于 作者: H hjdhnx

增加了缓存数据库

上级 f8bfb61f
......@@ -58,7 +58,11 @@ else:
# from geventwebsocket.handler import WebSocketHandler
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 is_linux():
return not 'win' in sys.platform
......
......@@ -33,6 +33,6 @@ 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/0830zb.txt' # 外网直播地址
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
{
"🔮嗨翻":"https://pan.hikerfans.com",
"🦀9T(Adult)":"https://drive.9t.ee",
"🐱梓澪の妙妙屋":"https://xn--i0v44m.xyz",
"🚆资源小站":"https://pan.142856.xyz",
"🌤晴园的宝藏库":"https://alist.52qy.repl.co",
"🐭米奇妙妙屋":"https://anime.mqmmw.ga",
"💂小兵组网盘影视":"https://6vv.app",
"📀小光盘":"https://alist.xiaoguanxiaocheng.life",
"🐋一只鱼":"https://alist.youte.ml",
"🌊七米蓝":"https://al.chirmyram.com",
"🌴非盘":"http://www.feifwp.top",
"🥼帅盘":"https://hi.shuaipeng.wang",
"🐉神族九帝":"https://alist.shenzjd.com",
"☃姬路白雪":"https://pan.jlbx.xyz",
"🎧听闻网盘":"https://wangpan.sangxuesheng.com",
"💾DISK":"http://124.222.140.243:8080",
"🌨云播放":"https://quanzi.laoxianghuijia.cn",
"✨星梦":"https://pan.bashroot.top",
"🌊小江":"https://dyj.me",
"💫触光":"https://pan.ichuguang.com",
"🕵好汉吧":"https://8023.haohanba.cn",
"🥗AUNEY":"http://121.227.25.116:8008",
"🎡资源小站":"https://960303.xyz/",
"🏝fenwe":"http://www.fenwe.tk:5244",
"🎢轻弹浅唱":"https://g.xiang.lol"
}
......@@ -5,4 +5,5 @@
# Date : 2022/8/25
from . import rule_classes
from . import play_parse
\ No newline at end of file
from . import play_parse
from . import storage
\ No newline at end of file
无法预览此类型文件
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File : storage.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/9/6
from functools import lru_cache
def init(db):
class Storage(db.Model):
__tablename__ = 'storage'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
key = db.Column(db.String(20),unique=True)
value = db.Column(db.UnicodeText())
# value = db.Column(db.Text())
def __repr__(self):
return "<Storage(key='%s', value='%s')>" % (
self.key, self.value)
@classmethod
def setItem(self, key, value=None):
res = db.session.query(self).filter(self.key == key).first()
if res:
res.value = value
db.session.add(res)
else:
res = Storage(key=key, value=value)
db.session.add(res)
db.session.flush()
try:
db.session.commit()
self.clearCache()
return res.id
except Exception as e:
print(f'发生了错误:{e}')
return None
@classmethod
@lru_cache(maxsize=200)
def getItem(self, key, value=''):
res = db.session.query(self).filter(self.key == key).first()
if res:
return res.value or value
else:
return value
@classmethod
def clearItem(self, key):
self.clearCache()
res = db.session.query(self).filter(self.key == key).first()
if res:
res.delete()
ret = db.session.commit()
self.clearCache()
return ret
else:
return True
@classmethod
def clearCache(self):
self.getItem.cache_clear()
# db.create_all()
db.create_all()
return Storage
\ No newline at end of file
......@@ -2,4 +2,68 @@
/*font-size: 18px;*/
color: #5dc2f1;
}
\ No newline at end of file
}
.red {
color:red;
font-weight: bold;
padding-left:10px;
/*padding-top:10px;*/
margin-left:10px;
width: 360px;
height: 30px;
}
.green {
color:forestgreen;
font-weight: bold;
padding-left:10px;
/*padding-top:10px;*/
margin-left:10px;
width: 360px;
height: 30px;
}
.btn{
color:#FFFFFF;
background-color: #1379cb;
}
.clear{
/*word-spacing:2px;*/
letter-spacing:5px;
margin-left:20px;
width: 120px;
height: 30px;
text-align: center;
border-style: solid;
/*border-color: #8CD4F5;*/
border-color: #1379cb;
text-decoration:none;
color:#FFFFFF;
background-color: #1379cb;
}
.view_home{
letter-spacing:5px;
margin-left:20px;
width: 150px;
height: 30px;
text-align: center;
border-style: solid;
/*border-color: #8CD4F5;*/
border-color: #17af30;
text-decoration:none;
color:#FFFFFF;
background-color: #17af30;
}
/*li a {*/
/* display: block !important;*/
/*}*/
.ver_title{
font-size: 15px;margin-left: 20px
}
.ver{
font-size: 16px;margin-left: 5px;color: #ea7d7d;
}
a.funcbtn{
margin-left: 10px;
}
\ No newline at end of file
function copy(text,mode){
mode = mode||0;
if(mode === 0){
let el = $('<input id="input_to_copy" style="position: absolute;top: 0;left: 0;opacity: 0;z-index: -10"/>');
   $('body').prepend(el); //添加到元素内部的前面
el.val(text); // 修改文本框的内容
el.select(); //选中
console.log('复制的内容:\n'+text);
document.execCommand("copy"); // 执行浏览器复制命令
el.remove();
}else{
let el = $(text);
console.log('复制的内容:\n'+el.val());
el.select(); //选中
document.execCommand("copy"); // 执行浏览器复制命令
}
alert("复制成功");
}
\ No newline at end of file
......@@ -9,86 +9,17 @@
<link rel="stylesheet" media="screen" href="/static/css/admin.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>
<style>
.red {
color:red;
font-weight: bold;
padding-left:10px;
/*padding-top:10px;*/
margin-left:10px;
width: 360px;
height: 30px;
}
.green {
color:forestgreen;
font-weight: bold;
padding-left:10px;
/*padding-top:10px;*/
margin-left:10px;
width: 360px;
height: 30px;
}
.btn{
color:#FFFFFF;
background-color: #1379cb;
}
.clear{
/*word-spacing:2px;*/
letter-spacing:5px;
margin-left:20px;
width: 120px;
height: 30px;
text-align: center;
border-style: solid;
/*border-color: #8CD4F5;*/
border-color: #1379cb;
text-decoration:none;
color:#FFFFFF;
background-color: #1379cb;
}
.view_home{
letter-spacing:5px;
margin-left:20px;
width: 150px;
height: 30px;
text-align: center;
border-style: solid;
/*border-color: #8CD4F5;*/
border-color: #17af30;
text-decoration:none;
color:#FFFFFF;
background-color: #17af30;
}
/*li a {*/
/* display: block !important;*/
/*}*/
.ver_title{
font-size: 15px;margin-left: 20px
}
.ver{
font-size: 16px;margin-left: 5px;color: #ea7d7d;
}
a.funcbtn{
margin-left: 10px;
}
.wrapper {position: relative;}
#input {position: absolute;top: 0;left: 0;opacity: 0;z-index: -10;}
</style>
<body>
<script>
$(document).ready(function(){
$(".view").click(function(){
// location.reload();
let rule = this.innerText.trim();
location.href = '/admin/view/'+rule+'.js';
});
$(".view_home").click(function(){
// location.reload();
let rule = this.getAttribute('value').trim();
location.href = '/vod?rule='+rule;
});
......@@ -128,8 +59,6 @@
});
$(".clear").click(function(){
// location.reload();
// let rule = this.innerText.trim();
let rule = this.getAttribute('value').trim();
if(confirm('确认删除内置规则:'+rule+'?')){
let code = $.ajax({url:'/admin/clear/'+rule+'.js',async:false}).responseText;
......@@ -141,12 +70,11 @@
alert('操作失败!\n'+code.msg);
}
}
// location.href = '/admin/clear/'+rule;
});
$('#upload').click(function(){
var file_data = $("input[name='file']").prop("files")[0];
console.log(file_data);
// console.log(file_data);
if(!file_data){
alert('文件必选');
return false
......@@ -176,35 +104,25 @@
console.log(ret);
alert(ret.msg);
});
});
});
function getFileSize(fileObj)
{
$('#file_size').text('文件大小为:'+fileObj.files[0].size/1024+'kb');
}
function copyText(id) {
console.log(id);
var text = document.getElementById(id).innerText;
var input = document.getElementById("input");
input.value = text; // 修改文本框的内容
console.log(text);
input.select(); // 选中文本
document.execCommand("copy"); // 执行浏览器复制命令
alert("复制成功");
function getFileSize(fileObj) {
$('#file_size').text('文件大小为:'+fileObj.files[0].size/1024+'kb');
}
</script>
<h2 class="title">欢迎使用drpy管理员界面<span class="ver_title">当前版本:</span><span class="ver">{{ ver }}</span></h2>
<h2 class="title">欢迎使用drpy管理员界面</h2>
<h3 class="title">
<span class="ver_title">当前版本:</span><span class="ver">{{ ver }}</span>
</h3>
<h4>
<a href="/index" class="funcbtn">返回首页</a>
<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: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="update_lives">同步直播源</a>
</h4>
<p>你可以在此页面在线上传规则文件到js目录或者删除js目录的文件</p>
<input id="input"/>
<form action = "/upload" method = "POST" enctype = "multipart/form-data">
<!-- <input type = "file" name = "file" class="btn" accept=".js" onchange="getFileSize(this)"/>-->
<input type = "file" name = "file" class="btn" onchange="getFileSize(this)"/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册