добавлены цвета статусов текстом для vMix
This commit is contained in:
22
get_data.py
22
get_data.py
@@ -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,11 +602,16 @@ 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
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user