Skip to content

Commit 00f43e0

Browse files
Merge pull request #122 from jinwandalaohu66/submission/script_mo9oqex4
2 parents 35583a5 + 0ce0ccd commit 00f43e0

2 files changed

Lines changed: 102 additions & 2 deletions

File tree

script_library/index.json

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"format_version": 1,
3-
"data_version": 99,
4-
"updated": "2026-04-21T12:29:23.484Z",
3+
"data_version": 100,
4+
"updated": "2026-04-22T06:42:07.854Z",
55
"announcement": null,
66
"categories": [
77
{
@@ -1654,6 +1654,29 @@
16541654
"updated": null,
16551655
"status": "active",
16561656
"lines": 642
1657+
},
1658+
{
1659+
"id": "script_mo9oqex4",
1660+
"name": "小姐姐视频",
1661+
"name_en": "小姐姐视频",
1662+
"desc": "没事瞎闹",
1663+
"desc_en": "没事瞎闹",
1664+
"category": "ui",
1665+
"file": "scripts/ui/script_mo9oqex4.py",
1666+
"thumbnail": null,
1667+
"version": 1,
1668+
"file_type": "py",
1669+
"author": "枕闲鱼",
1670+
"author_en": "枕闲鱼",
1671+
"tags": [
1672+
"community"
1673+
],
1674+
"requires": [],
1675+
"min_app_version": "1.5.0",
1676+
"added": "2026-04-22",
1677+
"updated": null,
1678+
"status": "active",
1679+
"lines": 77
16571680
}
16581681
]
16591682
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import ui
2+
import requests
3+
import storage
4+
import dialogs
5+
6+
# ===== 接口 =====
7+
API = "http://api.yujn.cn/api/zzxjj.php"
8+
9+
# ===== 获取真实视频 =====
10+
def get_real_url():
11+
try:
12+
r = requests.get(API, timeout=10)
13+
14+
# 跳转地址
15+
if r.url != API:
16+
return r.url
17+
18+
# 返回文本是URL
19+
if r.text.startswith("http"):
20+
return r.text.strip()
21+
22+
except Exception as e:
23+
print("获取失败:", e)
24+
25+
return None
26+
27+
# ===== HTML播放器 =====
28+
def build_html(url):
29+
return f"""
30+
<html>
31+
<head>
32+
<meta name="viewport" content="width=device-width, initial-scale=1">
33+
</head>
34+
<body style="margin:0;background:black;">
35+
<video src="{url}" autoplay controls playsinline webkit-playsinline
36+
style="width:100%;height:100%;object-fit:cover;"></video>
37+
</body>
38+
</html>
39+
"""
40+
41+
# ===== 主程序 =====
42+
class VideoApp(ui.View):
43+
44+
def __init__(self):
45+
super().__init__()
46+
47+
self.background_color = "black"
48+
49+
# 播放器
50+
self.web = ui.WebView(frame=self.bounds, flex="WH")
51+
self.add_subview(self.web)
52+
# 按钮
53+
self.button = ui.Button(title="切换视频", frame=(0, 0, 150, 50)) # 初始位置设为 (0, 0)
54+
self.button.action = self.play_video
55+
self.add_subview(self.button)
56+
57+
# 首次运行显示使用说明
58+
59+
dialogs.alert("使用说明", "欢迎使用本应用!\n刷新视频点击切换视频\n播放后找不到切换按钮点击右上X按钮\n换视频较慢!")
60+
61+
# ===== 播放视频 =====
62+
def play_video(self, sender):
63+
url = get_real_url()
64+
if url:
65+
print("播放:", url)
66+
self.web.load_html(build_html(url))
67+
else:
68+
print("无法获取视频 URL")
69+
70+
# ===== 启动 =====
71+
if __name__ == "__main__":
72+
73+
v = VideoApp()
74+
w, h = ui.get_screen_size()
75+
v.frame = (0, 0, w, h)
76+
# 设置按钮位置为屏幕中心,并以模态形式显示
77+
v.present("sheet", animated=True, hide_title_bar=True)

0 commit comments

Comments
 (0)