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

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( 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] [k for k in latest_data if k not in sort_order]
) )
data = { data = {
"league": LEAGUE, "league": LEAGUE,
"team": TEAM, "team": TEAM,
@@ -1075,14 +1074,13 @@ async def status(request: Request):
for item in sorted_keys # ← используем отсортированный порядок for item in sorted_keys # ← используем отсортированный порядок
], ],
} }
accept = request.headers.get("accept", "") accept = request.headers.get("accept", "")
if "text/html" in accept: if "text/html" in accept:
status_raw = str(STATUS).lower() status_raw = str(STATUS).lower()
if status_raw in ["live"]: if status_raw in ["live"]:
gs_class = "live" gs_class = "live"
gs_text = "🟢 LIVE" gs_text = "🟢 LIVE"
elif status_raw in ["live_soon"]: elif status_raw in ["live_soon", "today_not_started"]:
gs_class = "live" gs_class = "live"
gs_text = "🟢 GAME TODAY (soon)" gs_text = "🟢 GAME TODAY (soon)"
elif status_raw in ["finished_wait"]: elif status_raw in ["finished_wait"]:
@@ -1093,10 +1091,15 @@ async def status(request: Request):
human = datetime.fromtimestamp(off_at).strftime("%H:%M:%S") human = datetime.fromtimestamp(off_at).strftime("%H:%M:%S")
gs_text = f"🟡 Game finished, cooling down → OFFLINE at {human}" gs_text = f"🟡 Game finished, cooling down → OFFLINE at {human}"
else: else:
human = "N/A"
gs_text = "🟡 Game finished, cooling down" gs_text = "🟡 Game finished, cooling down"
elif status_raw in ["finished_today", "finished"]: elif status_raw in ["finished_today", "finished"]:
gs_class = "finished" gs_class = "finished"
gs_text = "🔴 Game finished" gs_text = "🔴 Game finished"
else:
gs_class = status_raw
gs_text = "⚪ Unknown"
html = f""" html = f"""
<html> <html>
@@ -1185,7 +1188,6 @@ async def status(request: Request):
</html> </html>
""" """
return HTMLResponse(content=html, media_type="text/html") return HTMLResponse(content=html, media_type="text/html")
# JSON для API (красиво отформатированный) # JSON для API (красиво отформатированный)
formatted = json.dumps(data, indent=4, ensure_ascii=False) formatted = json.dumps(data, indent=4, ensure_ascii=False)
response = Response(content=formatted, media_type="application/json") response = Response(content=formatted, media_type="application/json")
@@ -2004,5 +2006,5 @@ async def live_status():
if __name__ == "__main__": if __name__ == "__main__":
uvicorn.run( 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"
) )