Skip to content

Commit e134af9

Browse files
Merge pull request #49 from jinwandalaohu66/submission/script_mn9r95l0
2 parents 6a67e71 + fdc0aff commit e134af9

2 files changed

Lines changed: 112 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": 31,
4-
"updated": "2026-03-27T15:15:38.324Z",
3+
"data_version": 32,
4+
"updated": "2026-03-28T03:12:59.398Z",
55
"announcement": null,
66
"categories": [
77
{
@@ -798,6 +798,29 @@
798798
"updated": null,
799799
"status": "active",
800800
"lines": 113
801+
},
802+
{
803+
"id": "script_mn9r95l0",
804+
"name": "实时电影票房",
805+
"name_en": "实时电影票房",
806+
"desc": "建议用中号小组件",
807+
"desc_en": "建议用中号小组件",
808+
"category": "widgets",
809+
"file": "scripts/widgets/script_mn9r95l0.py",
810+
"thumbnail": null,
811+
"version": 1,
812+
"file_type": "py",
813+
"author": "一只菜鸡",
814+
"author_en": "一只菜鸡",
815+
"tags": [
816+
"community"
817+
],
818+
"requires": [],
819+
"min_app_version": "1.5.0",
820+
"added": "2026-03-28",
821+
"updated": null,
822+
"status": "active",
823+
"lines": 87
801824
}
802825
]
803826
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
from widget import Widget, family, SMALL, MEDIUM, LARGE
2+
import requests
3+
4+
def safe_text(val, default=""):
5+
return val if val and val.strip() else default
6+
7+
try:
8+
headers = {"Content-Type": "application/x-www-form-urlencoded;charset:utf-8"}
9+
resp = requests.post(
10+
"https://api.taolale.com/api/hot_rankings/get",
11+
data={"key": "DoG1KYTwfGhcTACTpgAk4eFiDf"},
12+
headers=headers,
13+
timeout=10
14+
)
15+
data = resp.json()
16+
movies = data.get("data", [])[:5] if data.get("code") == 200 else []
17+
except:
18+
movies = []
19+
20+
bg = ("#F8FAFC", "#0F172A")
21+
title_color = ("#0F172A", "#F8FAFC")
22+
subtitle_color = ("#647B94", "#94A3B8")
23+
accent = "#EF4444"
24+
25+
w = Widget(background=bg, padding=14)
26+
27+
if family == SMALL:
28+
top = movies[0] if movies else None
29+
with w.vstack(spacing=0, align="leading"):
30+
w.spacer(24)
31+
if top:
32+
w.icon("film.fill", size=18, color=accent)
33+
w.spacer(8)
34+
w.text(top["title"], size=17, weight="bold", color=title_color, max_lines=1)
35+
w.spacer(6)
36+
w.text(top["sumBoxDesc"], size=24, weight="bold", design="rounded", color=title_color)
37+
release_info = safe_text(top.get("releaseInfo"))
38+
if release_info:
39+
w.spacer(6)
40+
w.text(release_info, size=12, color=subtitle_color)
41+
else:
42+
w.text("暂无数据", size=16, color=subtitle_color)
43+
w.spacer()
44+
45+
elif family == MEDIUM:
46+
with w.hstack(spacing=0):
47+
w.icon("film.fill", size=15, color=accent)
48+
w.spacer(6)
49+
w.text("实时票房前三", size=14, weight="semibold", color=title_color)
50+
w.spacer()
51+
#w.text(f"共{len(movies)}部", size=12, color=subtitle_color)
52+
w.spacer()
53+
for movie in movies[:3]:
54+
rank = movie["index"]
55+
rc = "#F59E0B" if rank == 1 else "#94A3B8" if rank == 2 else "#CD7F32"
56+
with w.hstack(spacing=0, align="center"):
57+
w.text(f"#{rank}", size=13, weight="bold", color=rc)
58+
w.spacer(6)
59+
w.text(movie["title"], size=13, weight="medium", color=title_color)
60+
w.spacer()
61+
w.text(movie["sumBoxDesc"], size=13, weight="bold", design="rounded", color=title_color)
62+
w.spacer(4)
63+
w.spacer()
64+
65+
else:
66+
with w.hstack(spacing=0):
67+
w.icon("film.fill", size=17, color=accent)
68+
w.spacer(8)
69+
w.text("实时票房榜", size=17, weight="bold", color=title_color)
70+
w.spacer()
71+
w.text(f"共{len(movies)}部", size=13, color=subtitle_color)
72+
w.spacer(12)
73+
for movie in movies:
74+
rank = movie["index"]
75+
rc = "#F59E0B" if rank == 1 else "#94A3B8" if rank == 2 else "#CD7F32"
76+
release_info = safe_text(movie.get("releaseInfo"))
77+
with w.hstack(spacing=0, align="center"):
78+
w.text(f"#{rank}", size=15, weight="bold", color=rc)
79+
w.spacer(8)
80+
w.text(movie["title"], size=15, weight="semibold", color=title_color)
81+
if release_info:
82+
w.text(f" · {release_info}", size=12, color=subtitle_color)
83+
w.spacer()
84+
w.text(movie["sumBoxDesc"], size=16, weight="bold", design="rounded", color=title_color)
85+
w.spacer(6)
86+
87+
w.render()

0 commit comments

Comments
 (0)