поправил статусы

This commit is contained in:
2025-11-01 16:55:27 +03:00
parent 7152ac608f
commit bc396cb90d

View File

@@ -1031,7 +1031,6 @@ 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]
)
data = {
"league": LEAGUE,
"team": TEAM,
@@ -1075,14 +1074,13 @@ async def status(request: Request):
for item in sorted_keys # ← используем отсортированный порядок
],
}
accept = request.headers.get("accept", "")
if "text/html" in accept:
status_raw = str(STATUS).lower()
if status_raw in ["live"]:
gs_class = "live"
gs_text = "🟢 LIVE"
elif status_raw in ["live_soon"]:
elif status_raw in ["live_soon", "today_not_started"]:
gs_class = "live"
gs_text = "🟢 GAME TODAY (soon)"
elif status_raw in ["finished_wait"]:
@@ -1093,10 +1091,15 @@ async def status(request: Request):
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"
gs_text = "🔴 Game finished"
else:
gs_class = status_raw
gs_text = "⚪ Unknown"
html = f"""
<html>
@@ -1185,7 +1188,6 @@ async def status(request: Request):
</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")
@@ -2004,5 +2006,5 @@ async def live_status():
if __name__ == "__main__":
uvicorn.run(
"get_data:app", host="0.0.0.0", port=8000, reload=True, log_level="critical"
"get_data:app", host="0.0.0.0", port=8000, reload=True, log_level="debug"
)