Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.

Commit 710884d

Browse files
committed
chore: 更新额外脚本提供更多信息
1 parent a5d0cfe commit 710884d

File tree

1 file changed

+36
-0
lines changed
  • extra-scripts/travellings-cn-api

1 file changed

+36
-0
lines changed

extra-scripts/travellings-cn-api/main.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,48 @@ def main() -> None:
2626

2727
# 读取 all.json,将 status 不为 RUN 的 url 写入 input.txt
2828

29+
run_counts = {}
30+
all_counts = {}
31+
2932
with open("./temp/all.json", "r", encoding="utf-8") as f:
3033
data = json.load(f)
3134
with open("input.txt", "w", encoding="utf-8") as f:
3235
for item in data["data"]:
36+
index = (item["id"] - 1) // 100 + 1 # index = 1 : 1-100
37+
if index not in all_counts:
38+
all_counts[index] = 0
39+
all_counts[index] += 1
40+
3341
if item["status"] != "RUN":
3442
f.write(item["url"].strip() + "\n")
43+
else:
44+
if index not in run_counts:
45+
run_counts[index] = 0
46+
run_counts[index] += 1
47+
48+
print("RUN counts in ranges:")
49+
for key in sorted(run_counts.keys()):
50+
total = all_counts[key]
51+
percentage = (run_counts[key] / total) * 100
52+
percentage_color = (
53+
"\033[35m"
54+
if percentage < 40
55+
else (
56+
"\033[91m"
57+
if percentage < 60
58+
else "\033[93m" if percentage < 80 else "\033[92m"
59+
)
60+
)
61+
all_count_percentage = (all_counts[key] / 100) * 100
62+
all_count_percentage_color = (
63+
"\033[91m"
64+
if all_count_percentage < 60
65+
else "\033[93m" if all_count_percentage < 80 else "\033[92m"
66+
)
67+
reset = "\033[0m"
68+
print(
69+
f"{(key-1)*100+1:>4}-{key*100:<4}: {run_counts[key]:>3}/{all_count_percentage_color}{all_counts[key]:<3}{reset} ({percentage_color}{percentage:.2f}%{reset})"
70+
)
3571

3672

3773
if __name__ == "__main__":

0 commit comments

Comments
 (0)