diff --git a/get_data.py b/get_data.py index ffecf94..8c061fa 100644 --- a/get_data.py +++ b/get_data.py @@ -133,6 +133,7 @@ def results_consumer(): and "teams" in payload["result"] ): # обновляем команды + game["data"]["result"]["game"]["fullScore"] = payload["result"]["fullScore"] for team in game["data"]["result"]["teams"]: if team["teamNumber"] != 0: box_team = [ @@ -561,12 +562,33 @@ 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 "🟢" + elif status_value in ["scheduled", "today_not_started", "upcoming"]: + return "🟡" + elif status_value in ["result", "resultconfirmed", "finished", "finished_today"]: + return "🔴" + elif status_value in ["no_game_today", "unknown", "none"]: + return "⚪" + else: + return "🔘" + data = { "league": LEAGUE, "team": TEAM, "game_id": GAME_ID, - "game_status": STATUS, # <= сюда приходит твой индикатор состояния + "game_status": STATUS, "statuses": [ + { + "name": TEAM, + "status": STATUS, + "ts": GAME_START_DT.strftime("%Y-%m-%d %H:%M") if GAME_START_DT else "N/A", + "link": LEAGUE + } + ] + [ { "name": item, "status": ( @@ -663,8 +685,16 @@ async def status(request: Request): """ for s in data["statuses"]: - status_text = str(s["status"]).strip() - color_class = "ok" if status_text.lower() == "ok" else "fail" + status_text = str(s["status"]).strip().lower() + + if any(x in status_text for x in ["ok", "success", "live", "live_soon", "online"]): + color_class = "ok" + elif any(x in status_text for x in ["scheduled", "today_not_started", "upcoming"]): + color_class = "warn" + elif any(x in status_text for x in ["result", "resultconfirmed", "finished", "finished_today"]): + color_class = "fail" + else: + color_class = "unknown" html += f"""