добавлены цвета статусов текстом для vMix

This commit is contained in:
2025-10-31 18:08:44 +03:00
parent 735af0e81d
commit 2795c0f6c2

View File

@@ -560,18 +560,18 @@ async def game():
@app.get("/status.json") @app.get("/status.json")
async def status(request: Request): async def status(request: Request):
def color_for_status(status_value: str) -> str: def color_for_status(status_value: str) -> str:
"""Подбор цвета для статуса""" """Подбор текстового цвета для статуса"""
status_value = str(status_value).lower() status_value = str(status_value).lower()
if status_value in ["ok", "success", "live", "live_soon", "online"]: if status_value in ["ok", "success", "live", "live_soon", "online"]:
return "🟢" return "green"
elif status_value in ["scheduled", "today_not_started", "upcoming"]: elif status_value in ["scheduled", "today_not_started", "upcoming"]:
return "🟡" return "yellow"
elif status_value in ["result", "resultconfirmed", "finished", "finished_today"]: elif status_value in ["result", "resultconfirmed", "finished", "finished_today"]:
return "🔴" return "red"
elif status_value in ["no_game_today", "unknown", "none"]: elif status_value in ["no_game_today", "unknown", "none"]:
return "" return "white"
else: else:
return "🔘" return "gray"
data = { data = {
"league": LEAGUE, "league": LEAGUE,
@@ -583,7 +583,8 @@ async def status(request: Request):
"name": TEAM, "name": TEAM,
"status": STATUS, "status": STATUS,
"ts": GAME_START_DT.strftime("%Y-%m-%d %H:%M") if GAME_START_DT else "N/A", "ts": GAME_START_DT.strftime("%Y-%m-%d %H:%M") if GAME_START_DT else "N/A",
"link": LEAGUE "link": LEAGUE,
"color": color_for_status(STATUS) # ← добавлено
} }
] + [ ] + [
{ {
@@ -601,6 +602,11 @@ async def status(request: Request):
lang=LANG, lang=LANG,
game_id=GAME_ID, game_id=GAME_ID,
), ),
"color": color_for_status(
latest_data[item]["data"]["status"]
if isinstance(latest_data[item]["data"], dict) and "status" in latest_data[item]["data"]
else latest_data[item]["data"]
) # ← добавлено
} }
for item in latest_data for item in latest_data
], ],