diff --git a/visual.py b/visual.py index 8130314..99d0778 100644 --- a/visual.py +++ b/visual.py @@ -426,6 +426,9 @@ prefix = _ipcheck() load_data_from_json("game") cached_game_online = st.session_state.get("game") +load_data_from_json("api_game") +cached_api_game = st.session_state.get("api_game") + load_data_from_json("team1") cached_team1 = st.session_state.get("team1") @@ -437,9 +440,9 @@ cached_referee = st.session_state.get("referee") # standings — может не быть тега/файла league_tag = None -if isinstance(cached_game_online, dict): - league_tag = (cached_game_online.get("league") or {}).get("tag") - comp_name = (cached_game_online.get("comp") or {}).get("name").replace(" ", "_").replace("|", "") +if isinstance(cached_api_game, dict): + league_tag = (cached_api_game["result"].get("league") or {}).get("tag") + comp_name = (cached_api_game["result"].get("comp") or {}).get("name").replace(" ", "_").replace("|", "") if league_tag: load_data_from_json(f"standings_{league_tag}_{comp_name}") cached_standings = ( @@ -556,8 +559,8 @@ if isinstance(cached_play_by_play, list) and isinstance(cached_game_online, dict timeout1 = [] timeout2 = [] -if isinstance(cached_game_online, dict): - result = cached_game_online +if isinstance(cached_api_game, dict): + result = cached_api_game["result"] plays = result.get("plays") or [] timeout1, timeout2 = [], [] @@ -1241,8 +1244,8 @@ column_config_ref = { def highlight_teams(s): try: if s.iloc[0] in ( - cached_game_online["result"]["team1"]["teamId"], - cached_game_online["result"]["team2"]["teamId"], + cached_api_game["result"]["team1"]["teamId"], + cached_api_game["result"]["team2"]["teamId"], ): return ["background-color: #FF4B4B"] * len(s) else: @@ -1256,8 +1259,8 @@ if cached_standings: def highlight_teams(s): try: - t1 = (cached_game_online or {}).get("team1", {}).get("teamId") - t2 = (cached_game_online or {}).get("team2", {}).get("teamId") + t1 = (cached_api_game["result"] or {}).get("team1", {}).get("teamId") + t2 = (cached_api_game["result"] or {}).get("team2", {}).get("teamId") if s.iloc[0] in (t1, t2): return ["background-color: #FF4B4B"] * len(s) if s.iloc[0] in (t1, t2):