Skip to content

Commit 53a22a6

Browse files
[投稿] 添加脚本: 小姐姐视频 — by 枕闲鱼
1 parent 35583a5 commit 53a22a6

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

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)