добавлены цвета статусов текстом для vMix
This commit is contained in:
20
get_data.py
20
get_data.py
@@ -560,18 +560,18 @@ async def game():
|
||||
@app.get("/status.json")
|
||||
async def status(request: Request):
|
||||
def color_for_status(status_value: str) -> str:
|
||||
"""Подбор цвета для статуса"""
|
||||
"""Подбор текстового цвета для статуса"""
|
||||
status_value = str(status_value).lower()
|
||||
if status_value in ["ok", "success", "live", "live_soon", "online"]:
|
||||
return "🟢"
|
||||
return "green"
|
||||
elif status_value in ["scheduled", "today_not_started", "upcoming"]:
|
||||
return "🟡"
|
||||
return "yellow"
|
||||
elif status_value in ["result", "resultconfirmed", "finished", "finished_today"]:
|
||||
return "🔴"
|
||||
return "red"
|
||||
elif status_value in ["no_game_today", "unknown", "none"]:
|
||||
return "⚪"
|
||||
return "white"
|
||||
else:
|
||||
return "🔘"
|
||||
return "gray"
|
||||
|
||||
data = {
|
||||
"league": LEAGUE,
|
||||
@@ -583,7 +583,8 @@ 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",
|
||||
"link": LEAGUE
|
||||
"link": LEAGUE,
|
||||
"color": color_for_status(STATUS) # ← добавлено
|
||||
}
|
||||
] + [
|
||||
{
|
||||
@@ -601,6 +602,11 @@ async def status(request: Request):
|
||||
lang=LANG,
|
||||
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
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user