Skip to content
This repository was archived by the owner on Jul 8, 2024. It is now read-only.

Commit 291d1b3

Browse files
author
hjdhnx
committed
电视直播功能增强
1 parent 7368689 commit 291d1b3

File tree

10 files changed

+3226
-3066
lines changed

10 files changed

+3226
-3066
lines changed

base/直播.txt

Lines changed: 58 additions & 3061 deletions
Large diffs are not rendered by default.

controllers/admin.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,3 +552,31 @@ def get_lives():
552552
response = make_response(files)
553553
response.headers['Content-Type'] = 'text/plain; charset=utf-8'
554554
return response
555+
556+
@admin.route('/lives_web')
557+
def admin_lives_web():
558+
if not verfy_token():
559+
return R.failed('请登录后再试')
560+
561+
# host_url = request.host_url
562+
def get_lives():
563+
base_path = os.path.dirname(os.path.abspath(os.path.dirname(__file__))) # 上级目录
564+
live_path = os.path.join(base_path, f'base/直播.txt')
565+
with open(live_path,encoding='utf-8') as f:
566+
text = f.read()
567+
return text
568+
569+
text = get_lives()
570+
# response = make_response(text)
571+
# response.headers['Content-Type'] = 'text/plain; charset=utf-8'
572+
# return response
573+
lives = []
574+
for line in text.split('\n'):
575+
if ',http' in line:
576+
lives.append({
577+
'title':line.split(',')[0],
578+
'url':line.split(',')[1],
579+
})
580+
print(lives)
581+
# lsg = storage_service()
582+
return render_template('lives.html',ver=getLocalVer(),lives=lives)

controllers/home.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,18 @@ def rules_to_view():
7171
def random_pics():
7272
id = getParmas('id')
7373
# print(f'id:{id}')
74-
pics = getPics()
74+
base_path = os.path.dirname(os.path.abspath(os.path.dirname(__file__))) # 上级目录
75+
path = 'images'
76+
img_path = os.path.join(base_path, f'{path}')
77+
pics = getPics(img_path)
7578
# print(pics)
7679
new_conf = cfg
7780
lsg = storage_service()
7881
store_conf_dict = lsg.getStoreConfDict()
7982
new_conf.update(store_conf_dict)
80-
if not new_conf.WALL_PAPER and len(pics) > 0:
81-
if id and f'images/{id}.jpg' in pics:
82-
pic = f'images/{id}.jpg'
83+
if not new_conf.WALL_PAPER or (id and len(pics) > 0):
84+
if id and f'{img_path}/{id}.jpg' in pics:
85+
pic = f'{img_path}/{id}.jpg'
8386
else:
8487
pic = random.choice(pics)
8588
file = open(pic, "rb").read()

doc/更新日志.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
###### 2023/11/22
2+
- [X] 3.9.49beta1 增加网页直播功能
3+
14
###### 2023/11/18
25
- [X] 修复腾云驾雾
36
- [X] 增加手动升级功能,手动上传升级文件.zip后进行强制升级即可

images/odoo.jpg

318 KB
Loading

images/zb.jpg

319 KB
Loading

js/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.9.48beta29
1+
3.9.49beta1

templates/admin.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@
298298
$('#lives').click(function () {
299299
location.href = '/admin/lives'
300300
});
301+
$('#lives_web').click(function () {
302+
location.href = '/admin/lives_web'
303+
});
304+
301305
$("summary").click(function() {
302306
// console.log('summary被点击');
303307
const details = $('details');
@@ -360,6 +364,7 @@
360364
<li><a href="javascript:void(0);" class="funcbtn" id="update_lives">同步直播源</a></li>
361365
<li><a href="javascript:void(0);" class="funcbtn" id="use_py">已{% if pystate=='1' %}启用{% else %}关闭{% endif %}py源</a></li>
362366
<li><a href="javascript:void(0);" class="funcbtn" id="lives">直播源列表</a></li>
367+
<li><a href="javascript:void(0);" class="funcbtn" id="lives_web">网页在线直播</a></li>
363368
</ul>
364369
</li>
365370

templates/lives.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
<title>电视直播页面-{{ver}}</title>
6+
<meta charset="UTF-8"> <!-- 设置字符编码为UTF-8 -->
7+
<meta name="description" content="drpy在线电视直播by道长">
8+
<meta name="author" content="道长" />
9+
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">-->
10+
<link rel="stylesheet" media="screen" href="/static/css/admin.css">
11+
<link rel="icon" href="/static/img/logo.png" type="image/x-icon">
12+
<script src="/static/js/jquery.min.js"></script>
13+
<script src="/static/js/common.js"></script>
14+
<script src="/static/js/grey.js"></script>
15+
<style>
16+
.container {
17+
text-align: center; /* 设置文本居中对齐,将块水平居中 */
18+
}
19+
20+
.block {
21+
display: inline-block; /* 将块设置为行内块元素,每行显示两个 */
22+
width: 300px; /* 每个块的宽度,可以根据需要自定义 */
23+
margin: 20px;
24+
padding: 10px;
25+
border: 1px solid #d5d1d1;
26+
border-radius: 10px; /* 设置圆角半径为10px */
27+
text-align: center; /* 使块内文本左对齐 */
28+
background: rgb(71, 143, 250,0.8); /* 背景颜色 */
29+
opacity: 0.8; /* 透明度 */
30+
}
31+
32+
.block h2 {
33+
color: rgb(254, 254, 254); /* 设置文字颜色为红色 */
34+
}
35+
36+
.block img {
37+
max-width: 100%;
38+
height: auto; /* 保持图片宽高比例 */
39+
}
40+
body {
41+
background-image: url("/pics?id=zb"); /* 设置背景图像的URL */
42+
background-size: cover; /* 使图像覆盖整个页面,不变形 */
43+
background-repeat: no-repeat; /* 防止图像重复平铺 */
44+
background-attachment: fixed; /* 固定背景图像,使其在滚动时保持固定 */
45+
background-position: center center; /* 居中显示背景图像 */
46+
}
47+
48+
</style>
49+
</head>
50+
<body>
51+
<div class="container">
52+
{% for live in lives %}
53+
<div class="block">
54+
<a href="/web/player1?url={{ live.url }}" target="_blank">
55+
<h2>{{ live.title }}</h2>
56+
</a>
57+
</div>
58+
59+
{% endfor %}
60+
<!-- 可以根据需要添加更多块 -->
61+
</div>
62+
</body>
63+
</html>

0 commit comments

Comments
 (0)