Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yan11xx
dr_py
提交
5a4aa3eb
dr_py
项目概览
yan11xx
/
dr_py
与 Fork 源项目一致
Fork自
晚风拂柳颜 / dr_py
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
dr_py
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5a4aa3eb
编写于
9月 06, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
重要更新
上级
6ed8dedc
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
119 addition
and
21 deletion
+119
-21
app.py
app.py
+43
-8
classes/cms.py
classes/cms.py
+2
-1
config.py
config.py
+2
-2
js/version.txt
js/version.txt
+1
-1
js/直播.txt
js/直播.txt
+0
-0
models/rules.db
models/rules.db
+0
-0
readme.md
readme.md
+3
-0
static/css/admin.css
static/css/admin.css
+3
-3
templates/admin.html
templates/admin.html
+37
-1
utils/update.py
utils/update.py
+28
-5
未找到文件。
app.py
浏览文件 @
5a4aa3eb
...
@@ -18,7 +18,7 @@ from werkzeug.utils import secure_filename
...
@@ -18,7 +18,7 @@ from werkzeug.utils import secure_filename
from
js.rules
import
getRuleLists
from
js.rules
import
getRuleLists
from
utils
import
error
,
parser
from
utils
import
error
,
parser
from
utils.web
import
*
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
sys
import
codecs
import
codecs
from
classes.cms
import
CMS
,
logger
from
classes.cms
import
CMS
,
logger
...
@@ -59,10 +59,13 @@ else:
...
@@ -59,10 +59,13 @@ else:
RuleClass
=
rule_classes
.
init
(
db
)
RuleClass
=
rule_classes
.
init
(
db
)
PlayParse
=
play_parse
.
init
(
db
)
PlayParse
=
play_parse
.
init
(
db
)
lsg
=
storage
.
init
(
db
)
lsg
=
storage
.
init
(
db
)
print
(
lsg
.
setItem
(
'直播地址'
,
'https://gitcode.net/qq_26898231/TVBox/-/raw/main/live/zb.txt'
))
t12
=
time
()
def
initConfToDb
():
print
(
lsg
.
getItem
(
'直播地址'
,
'111'
))
if
not
lsg
.
getItem
(
'LIVE_URL'
):
print
(
get_interval
(
t12
))
lsg
.
setItem
(
'LIVE_URL'
,
app
.
config
.
get
(
'LIVE_URL'
))
initConfToDb
()
def
is_linux
():
def
is_linux
():
return
not
'win'
in
sys
.
platform
return
not
'win'
in
sys
.
platform
...
@@ -120,7 +123,8 @@ def admin_home(): # 管理员界面
...
@@ -120,7 +123,8 @@ def admin_home(): # 管理员界面
if
not
verfy_token
(
token
):
if
not
verfy_token
(
token
):
return
render_template
(
'login.html'
)
return
render_template
(
'login.html'
)
# return jsonify(error.success('登录成功'))
# 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'
])
@
app
.
route
(
'/api/login'
,
methods
=
[
'GET'
,
'POST'
])
def
login_api
():
def
login_api
():
...
@@ -189,6 +193,36 @@ def admin_update_ver():
...
@@ -189,6 +193,36 @@ def admin_update_ver():
msg
=
download_new_version
()
msg
=
download_new_version
()
return
jsonify
(
error
.
success
(
msg
))
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'
])
@
app
.
route
(
'/upload'
,
methods
=
[
'GET'
,
'POST'
])
def
upload_file
():
def
upload_file
():
cookies
=
request
.
cookies
cookies
=
request
.
cookies
...
@@ -486,9 +520,10 @@ def random_pics():
...
@@ -486,9 +520,10 @@ def random_pics():
def
get_live_url
(
new_conf
,
mode
):
def
get_live_url
(
new_conf
,
mode
):
host
=
getHost
(
mode
)
host
=
getHost
(
mode
)
live_url
=
host
+
'/lives'
if
new_conf
.
get
(
'LIVE_MODE'
,
# t1 = time()
1
)
==
0
else
new_conf
.
get
(
'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
=
base64Encode
(
live_url
)
live_url
=
base64Encode
(
live_url
)
# print(f'{get_interval(t1)}毫秒')
return
live_url
return
live_url
@
app
.
route
(
'/config/<int:mode>'
)
@
app
.
route
(
'/config/<int:mode>'
)
...
...
classes/cms.py
浏览文件 @
5a4aa3eb
...
@@ -466,7 +466,8 @@ class CMS:
...
@@ -466,7 +466,8 @@ class CMS:
})
})
except
:
except
:
pass
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
[
'code'
]
=
1
result
[
'msg'
]
=
'数据列表'
result
[
'msg'
]
=
'数据列表'
result
[
'page'
]
=
fypage
result
[
'page'
]
=
fypage
...
...
config.py
浏览文件 @
5a4aa3eb
...
@@ -32,7 +32,7 @@ OCR_API = 'http://dm.mudery.com:10000' # 验证码识别接口,传参数data
...
@@ -32,7 +32,7 @@ OCR_API = 'http://dm.mudery.com:10000' # 验证码识别接口,传参数data
UNAME
=
'admin'
# 管理员账号
UNAME
=
'admin'
# 管理员账号
PWD
=
'drpy'
# 管理员密码
PWD
=
'drpy'
# 管理员密码
MAX_CONTENT_LENGTH
=
1
*
1024
*
1024
/
100
# 100 kB
MAX_CONTENT_LENGTH
=
1
*
1024
*
1024
/
100
# 100 kB
LIVE_MODE
=
1
# 0 本地 1外网
LIVE_MODE
=
0
# 0 本地 1外网
LIVE_URL
=
'https://gitcode.net/qq_26898231/TVBox/-/raw/main/live/zb.txt'
#
外网直播地址
LIVE_URL
=
'https://gitcode.net/qq_26898231/TVBox/-/raw/main/live/zb.txt'
#
初始化外网直播地址(后续在管理界面改)
CATE_EXCLUDE
=
'首页|留言|APP|下载|资讯|新闻|动态'
# 动态分类过滤
CATE_EXCLUDE
=
'首页|留言|APP|下载|资讯|新闻|动态'
# 动态分类过滤
# {% if config.WALL_PAPER %}"wallpaper":"{{ config.WALL_PAPER }}",{% endif %}
# {% if config.WALL_PAPER %}"wallpaper":"{{ config.WALL_PAPER }}",{% endif %}
\ No newline at end of file
js/version.txt
浏览文件 @
5a4aa3eb
3.1.5
3.1.6
\ No newline at end of file
\ No newline at end of file
js/直播.txt
浏览文件 @
5a4aa3eb
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
models/rules.db
浏览文件 @
5a4aa3eb
无法预览此类型文件
readme.md
浏览文件 @
5a4aa3eb
...
@@ -48,6 +48,9 @@
...
@@ -48,6 +48,9 @@
[
获取本地设备信息
](
https://m.jb51.net/article/140716.htm
)
[
获取本地设备信息
](
https://m.jb51.net/article/140716.htm
)
###### 2022/09/06
###### 2022/09/06
-
[X] 1.增加了后台管理界面在线检测升级系统功能
-
[X] 1.增加了后台管理界面在线检测升级系统功能
-
[X] 2.增加了后台管理界面修改直播源地址和同步直播源
-
[X] 3.首页推荐内容不限制数量(新版pluto牛逼!!!)
-
[X] 4.增加lsg配置模型和缓存
###### 2022/09/05
###### 2022/09/05
-
[X] 1.内置jar修复了原本tv_box无法播放直播的问题
-
[X] 1.内置jar修复了原本tv_box无法播放直播的问题
-
[X] 2.重新构建了三种平台的镜像 amd64,armv7,arm64
-
[X] 2.重新构建了三种平台的镜像 amd64,armv7,arm64
...
...
static/css/admin.css
浏览文件 @
5a4aa3eb
...
@@ -57,13 +57,13 @@
...
@@ -57,13 +57,13 @@
/* display: block !important;*/
/* display: block !important;*/
/*}*/
/*}*/
.ver_title
{
.ver_title
{
font-size
:
15px
;
margin-
left
:
2
0px
font-size
:
15px
;
margin-
right
:
1
0px
}
}
.ver
{
.ver
{
font-size
:
16px
;
margin-left
:
5
px
;
color
:
#ea7d7d
;
font-size
:
16px
;
margin-left
:
1
px
;
color
:
#ea7d7d
;
}
}
a
.funcbtn
{
a
.funcbtn
{
margin-
lef
t
:
10px
;
margin-
righ
t
:
10px
;
}
}
\ No newline at end of file
templates/admin.html
浏览文件 @
5a4aa3eb
...
@@ -105,6 +105,41 @@
...
@@ -105,6 +105,41 @@
alert
(
ret
.
msg
);
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
)
{
function
getFileSize
(
fileObj
)
{
$
(
'
#file_size
'
).
text
(
'
文件大小为:
'
+
fileObj
.
files
[
0
].
size
/
1024
+
'
kb
'
);
$
(
'
#file_size
'
).
text
(
'
文件大小为:
'
+
fileObj
.
files
[
0
].
size
/
1024
+
'
kb
'
);
...
@@ -120,8 +155,10 @@ function getFileSize(fileObj) {
...
@@ -120,8 +155,10 @@ function getFileSize(fileObj) {
<a
href=
"javascript:void(0);"
class=
"funcbtn"
id=
"checkUpdate"
>
检测升级
</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: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>
<a
href=
"javascript:void(0);"
class=
"funcbtn"
id=
"update_lives"
>
同步直播源
</a>
</h4>
</h4>
<input
id=
"live_url"
value=
"{{live_url}}"
style=
"display: none"
/>
<p>
你可以在此页面在线上传规则文件到js目录或者删除js目录的文件
</p>
<p>
你可以在此页面在线上传规则文件到js目录或者删除js目录的文件
</p>
<form
action =
"/upload"
method =
"POST"
enctype =
"multipart/form-data"
>
<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" accept=".js" onchange="getFileSize(this)"/>-->
...
@@ -130,7 +167,6 @@ function getFileSize(fileObj) {
...
@@ -130,7 +167,6 @@ function getFileSize(fileObj) {
<input
type=
"button"
id=
"upload"
value=
"上传"
class=
"btn"
/>
<input
type=
"button"
id=
"upload"
value=
"上传"
class=
"btn"
/>
</form>
</form>
<p
id=
"file_size"
></p>
<p
id=
"file_size"
></p>
<h1>
内置规则列表-共{{rules.count}}条
</h1>
<h1>
内置规则列表-共{{rules.count}}条
</h1>
{% if rules.count
<
1
%}
{% if rules.count
<
1
%}
<
h3
>
暂无内置的规则
</h3>
<
h3
>
暂无内置的规则
</h3>
...
...
utils/update.py
浏览文件 @
5a4aa3eb
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
# File : update.py
# File : update.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/9/6
# Date : 2022/9/6
import
re
from
time
import
time
as
getTime
from
time
import
time
as
getTime
import
requests
import
requests
...
@@ -12,6 +13,11 @@ import shutil # https://blog.csdn.net/weixin_33130113/article/details/112336581
...
@@ -12,6 +13,11 @@ import shutil # https://blog.csdn.net/weixin_33130113/article/details/112336581
from
utils.log
import
logger
from
utils.log
import
logger
from
utils.web
import
get_interval
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
():
def
getLocalVer
():
base_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)))
# 上级目录
base_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)))
# 上级目录
version_path
=
os
.
path
.
join
(
base_path
,
f
'js/version.txt'
)
version_path
=
os
.
path
.
join
(
base_path
,
f
'js/version.txt'
)
...
@@ -84,10 +90,6 @@ def download_new_version():
...
@@ -84,10 +90,6 @@ def download_new_version():
# print(f'清除缓存文件:{tp}')
# print(f'清除缓存文件:{tp}')
# os.remove(os.path.join(tmp_path, tp))
# os.remove(os.path.join(tmp_path, tp))
del_file
(
tmp_path
)
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
=
''
msg
=
''
try
:
try
:
# print(f'开始下载:{url}')
# print(f'开始下载:{url}')
...
@@ -112,4 +114,25 @@ def download_new_version():
...
@@ -112,4 +114,25 @@ def download_new_version():
except
Exception
as
e
:
except
Exception
as
e
:
msg
=
f
'升级失败:
{
e
}
'
msg
=
f
'升级失败:
{
e
}
'
logger
.
info
(
f
'系统升级共计耗时:
{
get_interval
(
t1
)
}
毫秒'
)
logger
.
info
(
f
'系统升级共计耗时:
{
get_interval
(
t1
)
}
毫秒'
)
return
msg
return
msg
\ No newline at end of file
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录