исмчисми
This commit is contained in:
55
get_data.py
55
get_data.py
@@ -876,6 +876,7 @@ def build_pretty_status_message():
|
||||
)
|
||||
src_lines = []
|
||||
for k in keys:
|
||||
if "excel" not in k.lower():
|
||||
d = latest_data.get(k) or {}
|
||||
ts = d.get("ts", "—")
|
||||
dat = d.get("data")
|
||||
@@ -1231,7 +1232,8 @@ def excel_worker():
|
||||
|
||||
# logger.info("[excel] Все вкладки Excel обновлены")
|
||||
|
||||
else:pass
|
||||
else:
|
||||
pass
|
||||
# logger.warning("[excel] get_excel() вернул не словарь")
|
||||
|
||||
except Exception as e:
|
||||
@@ -1531,12 +1533,16 @@ async def status(request: Request):
|
||||
sorted_keys = [k for k in sort_order if k in latest_data] + sorted(
|
||||
[k for k in latest_data if k not in sort_order]
|
||||
)
|
||||
# убираем excel_* из списка ключей
|
||||
sorted_keys = [k for k in sorted_keys if "excel" not in k.lower()]
|
||||
|
||||
cached_game_id = get_cached_game_id() or GAME_ID
|
||||
note = ""
|
||||
if cached_game_id and GAME_ID and str(cached_game_id) != str(GAME_ID):
|
||||
note = (
|
||||
f' <span style="color:#ffb84d;">(предзагружены данные прошлой игры)</span>'
|
||||
)
|
||||
|
||||
data = {
|
||||
"league": LEAGUE,
|
||||
"team": TEAM,
|
||||
@@ -1547,7 +1553,9 @@ async def status(request: Request):
|
||||
"name": TEAM,
|
||||
"status": STATUS,
|
||||
"ts": (
|
||||
GAME_START_DT.strftime("%Y-%m-%d %H:%M") if GAME_START_DT else "N/A"
|
||||
GAME_START_DT.strftime("%Y-%m-%d %H:%M")
|
||||
if GAME_START_DT
|
||||
else "N/A"
|
||||
),
|
||||
"link": LEAGUE,
|
||||
"color": color_for_status(STATUS),
|
||||
@@ -1577,13 +1585,13 @@ async def status(request: Request):
|
||||
else latest_data[item]["data"]
|
||||
),
|
||||
}
|
||||
for item in sorted_keys # ← используем отсортированный порядок
|
||||
for item in sorted_keys
|
||||
],
|
||||
}
|
||||
|
||||
accept = request.headers.get("accept", "")
|
||||
if "text/html" in accept:
|
||||
status_raw = str(STATUS).lower()
|
||||
# print(status_raw)
|
||||
if status_raw in ["live", "online"]:
|
||||
gs_class = "live"
|
||||
gs_text = "🟢 LIVE"
|
||||
@@ -1592,13 +1600,11 @@ async def status(request: Request):
|
||||
gs_text = "🟢 GAME TODAY (soon)"
|
||||
elif status_raw in ["finished_wait"]:
|
||||
gs_class = "upcoming"
|
||||
# покажем, что он ДОЖИДАЕТСЯ оффлайна
|
||||
off_at = OFFLINE_SWITCH_AT
|
||||
if off_at:
|
||||
human = datetime.fromtimestamp(off_at).strftime("%H:%M:%S")
|
||||
gs_text = f"🟡 Game finished, cooling down → OFFLINE at {human}"
|
||||
else:
|
||||
human = "N/A"
|
||||
gs_text = "🟡 Game finished, cooling down"
|
||||
elif status_raw in ["finished_today", "finished"]:
|
||||
gs_class = "finished"
|
||||
@@ -1634,6 +1640,7 @@ async def status(request: Request):
|
||||
}}
|
||||
tr:nth-child(even) {{ background-color: #1a1a1a; }}
|
||||
.ok {{ color: #00ff7f; font-weight: bold; }}
|
||||
.warn {{ color: #ffff66; font-weight: bold; }}
|
||||
.fail {{ color: #ff4d4d; font-weight: bold; }}
|
||||
.live {{ color: #00ff7f; font-weight: bold; }}
|
||||
.finished {{ color: #ff4d4d; font-weight: bold; }}
|
||||
@@ -1660,6 +1667,7 @@ async def status(request: Request):
|
||||
<tr><th>Name</th><th>Status</th><th>Timestamp</th><th>Link</th></tr>
|
||||
"""
|
||||
|
||||
# ВАЖНО: цикл только добавляет строки, return будет ПОСЛЕ цикла
|
||||
for s in data["statuses"]:
|
||||
status_text = str(s["status"]).strip().lower()
|
||||
|
||||
@@ -1679,6 +1687,7 @@ async def status(request: Request):
|
||||
color_class = "fail"
|
||||
else:
|
||||
color_class = "unknown"
|
||||
|
||||
html += f"""
|
||||
<tr>
|
||||
<td>{s["name"]}</td>
|
||||
@@ -1688,12 +1697,14 @@ async def status(request: Request):
|
||||
</tr>
|
||||
"""
|
||||
|
||||
# закрываем таблицу и страницу УЖЕ ПОСЛЕ цикла
|
||||
html += """
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
return HTMLResponse(content=html, media_type="text/html")
|
||||
|
||||
# JSON для API (красиво отформатированный)
|
||||
formatted = json.dumps(data, indent=4, ensure_ascii=False)
|
||||
response = Response(content=formatted, media_type="application/json")
|
||||
@@ -3166,8 +3177,12 @@ async def games_online():
|
||||
ls = resp.get("result") or resp
|
||||
msg = str(ls.get("message") or "").lower()
|
||||
status = str(ls.get("status") or "").lower()
|
||||
if msg == "not found" or status == "404": pass
|
||||
elif ls.get("message") != "Not found" and str(ls.get("gameStatus")).lower() == "online":
|
||||
if msg == "not found" or status == "404":
|
||||
pass
|
||||
elif (
|
||||
ls.get("message") != "Not found"
|
||||
and str(ls.get("gameStatus")).lower() == "online"
|
||||
):
|
||||
game["score1"] = ls.get("scoreA", game.get("score1", ""))
|
||||
game["score2"] = ls.get("scoreB", game.get("score2", ""))
|
||||
game["period"] = resolve_period(ls, game)
|
||||
@@ -3180,8 +3195,12 @@ async def games_online():
|
||||
todays_games.append(
|
||||
{
|
||||
"gameStatus": game["gameStatus"],
|
||||
"score1": game["score1"] if any((s or 0) > 0 for s in scores) else "",
|
||||
"score2": game["score2"] if any((s or 0) > 0 for s in scores) else "",
|
||||
"score1": (
|
||||
game["score1"] if any((s or 0) > 0 for s in scores) else ""
|
||||
),
|
||||
"score2": (
|
||||
game["score2"] if any((s or 0) > 0 for s in scores) else ""
|
||||
),
|
||||
"period": game["period"] if "period" in game else "",
|
||||
"defaultZoneTime": game["defaultZoneTime"],
|
||||
"team1": item["team1"]["name"],
|
||||
@@ -3190,9 +3209,19 @@ async def games_online():
|
||||
"team1_logo_xls": game["team1_logo_xls"],
|
||||
"team2_xls": game["team2_xls"],
|
||||
"team2_logo_xls": game["team2_logo_xls"],
|
||||
"mask1": "#FFFFFF00" if any((s or 0) > 0 for s in scores) else "#FFFFFF",
|
||||
"mask2": "#FFFFFF00" if (game["period"] if "period" in game else "") == "" else "#FFFFFF",
|
||||
"mask3": "#FFFFFF00" if (game["period"] if "period" in game else "") != "" else "#FFFFFF",
|
||||
"mask1": (
|
||||
"#FFFFFF00" if any((s or 0) > 0 for s in scores) else "#FFFFFF"
|
||||
),
|
||||
"mask2": (
|
||||
"#FFFFFF00"
|
||||
if (game["period"] if "period" in game else "") == ""
|
||||
else "#FFFFFF"
|
||||
),
|
||||
"mask3": (
|
||||
"#FFFFFF00"
|
||||
if (game["period"] if "period" in game else "") != ""
|
||||
else "#FFFFFF"
|
||||
),
|
||||
}
|
||||
)
|
||||
return todays_games
|
||||
|
||||
Reference in New Issue
Block a user