Skip to content

Commit 0514c1f

Browse files
Merge pull request #32 from jinwandalaohu66/submission/script_mmxnexoi
2 parents f017825 + 27291c3 commit 0514c1f

2 files changed

Lines changed: 110 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": 10,
4-
"updated": "2026-03-19T08:48:04.318Z",
3+
"data_version": 11,
4+
"updated": "2026-03-19T15:52:16.644Z",
55
"announcement": null,
66
"categories": [
77
{
@@ -426,6 +426,29 @@
426426
"updated": null,
427427
"status": "active",
428428
"lines": 201
429+
},
430+
{
431+
"id": "script_mmxnexoi",
432+
"name": "流量小组件",
433+
"name_en": "流量小组件",
434+
"desc": "这里省略了一万字",
435+
"desc_en": "这里省略了一万字",
436+
"category": "widgets",
437+
"file": "scripts/widgets/script_mmxnexoi.py",
438+
"thumbnail": null,
439+
"version": 1,
440+
"file_type": "py",
441+
"author": "Silence",
442+
"author_en": "Silence",
443+
"tags": [
444+
"community"
445+
],
446+
"requires": [],
447+
"min_app_version": "1.5.0",
448+
"added": "2026-03-19",
449+
"updated": null,
450+
"status": "active",
451+
"lines": 85
429452
}
430453
]
431454
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# 欢迎使用 PythonIDE!如果觉得好用,请给个好评哦~
2+
import requests
3+
from widget import Widget, family
4+
from widget import SMALL, MEDIUM, LARGE, CIRCULAR, RECTANGULAR
5+
6+
7+
def get_unicom_data():
8+
9+
url = ''
10+
headers = {
11+
'Host': '',
12+
'User-Agent': '',
13+
'Cookie':
14+
#这里把你抓到的cookie放里面即可.
15+
'这里....'
16+
}
17+
try:
18+
res = requests.get(url, headers=headers, timeout=5)
19+
if res.status_code == 200:
20+
data = res.json()
21+
flow = data.get('flowResource', {}).get('flowPersent', '0')
22+
fee = data.get('feeResource', {}).get('feePersent', '0')
23+
voice = data.get('voiceResource', {}).get('voicePersent', '0')
24+
t = data.get("flush_date_time", "").split(" ")[-1] if " " in data.get("flush_date_time", "") else "刚刚"
25+
return True, flow, fee, voice, t
26+
except:
27+
pass
28+
return False, "0", "0", "0", "--"
29+
30+
31+
success, flow, fee, voice, update_time = get_unicom_data()
32+
33+
34+
w = Widget(
35+
background=("#FFFFFF", "#0B0F1A"), #
36+
padding=16
37+
)
38+
39+
if family == MEDIUM:
40+
41+
with w.hstack(spacing=0):
42+
43+
44+
with w.vstack(align="leading", spacing=0):
45+
46+
with w.hstack(spacing=6):
47+
w.icon("antenna.radiowaves.left.and.right", size=16, color="#E63946")
48+
w.text("中国联通", size=14, weight="bold", color=("#111", "#EEE"))
49+
50+
w.spacer(14)
51+
w.text("剩余通用流量", size=12, color=("#64748B", "#94A3B8"))
52+
w.spacer(4)
53+
54+
55+
with w.hstack(spacing=4, align="bottom"):
56+
57+
w.text(flow, size=36, weight="bold", design="rounded", color=("#000", "#FFF"))
58+
59+
w.text("GB", size=14, weight="bold", color="#E63946")
60+
61+
62+
w.spacer()
63+
64+
65+
with w.vstack(align="leading", spacing=10):
66+
w.spacer(6)
67+
68+
69+
with w.hstack(spacing=8):
70+
w.icon("yensign.circle.fill", size=14, color="#F59E0B")
71+
w.text(f"{fee} 元", size=11, weight="semibold", color="#F59E0B")
72+
73+
74+
with w.hstack(spacing=8):
75+
w.icon("phone.fill", size=14, color="#10B981")
76+
w.text(f"{voice} 分钟", size=11, weight="semibold", color="#10B981")
77+
78+
79+
with w.hstack(spacing=8):
80+
w.icon("clock", size=14, color=("#94A3B8", "#64748B"))
81+
w.text(update_time, size=11, color=("#94A3B8", "#64748B"))
82+
83+
84+
w.render()
85+
#2026-3-19

0 commit comments

Comments
 (0)