исмчисми
This commit is contained in:
55
get_data.py
55
get_data.py
@@ -876,6 +876,7 @@ def build_pretty_status_message():
|
|||||||
)
|
)
|
||||||
src_lines = []
|
src_lines = []
|
||||||
for k in keys:
|
for k in keys:
|
||||||
|
if "excel" not in k.lower():
|
||||||
d = latest_data.get(k) or {}
|
d = latest_data.get(k) or {}
|
||||||
ts = d.get("ts", "—")
|
ts = d.get("ts", "—")
|
||||||
dat = d.get("data")
|
dat = d.get("data")
|
||||||
@@ -1231,7 +1232,8 @@ def excel_worker():
|
|||||||
|
|
||||||
# logger.info("[excel] Все вкладки Excel обновлены")
|
# logger.info("[excel] Все вкладки Excel обновлены")
|
||||||
|
|
||||||
else:pass
|
else:
|
||||||
|
pass
|
||||||
# logger.warning("[excel] get_excel() вернул не словарь")
|
# logger.warning("[excel] get_excel() вернул не словарь")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -1531,12 +1533,16 @@ async def status(request: Request):
|
|||||||
sorted_keys = [k for k in sort_order if k in latest_data] + sorted(
|
sorted_keys = [k for k in sort_order if k in latest_data] + sorted(
|
||||||
[k for k in latest_data if k not in sort_order]
|
[k for k in latest_data if k not in sort_order]
|
||||||
)
|
)
|
||||||
|
# убираем excel_* из списка ключей
|
||||||
|
sorted_keys = [k for k in sorted_keys if "excel" not in k.lower()]
|
||||||
|
|
||||||
cached_game_id = get_cached_game_id() or GAME_ID
|
cached_game_id = get_cached_game_id() or GAME_ID
|
||||||
note = ""
|
note = ""
|
||||||
if cached_game_id and GAME_ID and str(cached_game_id) != str(GAME_ID):
|
if cached_game_id and GAME_ID and str(cached_game_id) != str(GAME_ID):
|
||||||
note = (
|
note = (
|
||||||
f' <span style="color:#ffb84d;">(предзагружены данные прошлой игры)</span>'
|
f' <span style="color:#ffb84d;">(предзагружены данные прошлой игры)</span>'
|
||||||
)
|
)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"league": LEAGUE,
|
"league": LEAGUE,
|
||||||
"team": TEAM,
|
"team": TEAM,
|
||||||
@@ -1547,7 +1553,9 @@ async def status(request: Request):
|
|||||||
"name": TEAM,
|
"name": TEAM,
|
||||||
"status": STATUS,
|
"status": STATUS,
|
||||||
"ts": (
|
"ts": (
|
||||||
GAME_START_DT.strftime("%Y-%m-%d %H:%M") if GAME_START_DT else "N/A"
|
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),
|
"color": color_for_status(STATUS),
|
||||||
@@ -1577,13 +1585,13 @@ async def status(request: Request):
|
|||||||
else latest_data[item]["data"]
|
else latest_data[item]["data"]
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
for item in sorted_keys # ← используем отсортированный порядок
|
for item in sorted_keys
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
||||||
# print(status_raw)
|
|
||||||
if status_raw in ["live", "online"]:
|
if status_raw in ["live", "online"]:
|
||||||
gs_class = "live"
|
gs_class = "live"
|
||||||
gs_text = "🟢 LIVE"
|
gs_text = "🟢 LIVE"
|
||||||
@@ -1592,13 +1600,11 @@ async def status(request: Request):
|
|||||||
gs_text = "🟢 GAME TODAY (soon)"
|
gs_text = "🟢 GAME TODAY (soon)"
|
||||||
elif status_raw in ["finished_wait"]:
|
elif status_raw in ["finished_wait"]:
|
||||||
gs_class = "upcoming"
|
gs_class = "upcoming"
|
||||||
# покажем, что он ДОЖИДАЕТСЯ оффлайна
|
|
||||||
off_at = OFFLINE_SWITCH_AT
|
off_at = OFFLINE_SWITCH_AT
|
||||||
if off_at:
|
if off_at:
|
||||||
human = datetime.fromtimestamp(off_at).strftime("%H:%M:%S")
|
human = datetime.fromtimestamp(off_at).strftime("%H:%M:%S")
|
||||||
gs_text = f"🟡 Game finished, cooling down → OFFLINE at {human}"
|
gs_text = f"🟡 Game finished, cooling down → OFFLINE at {human}"
|
||||||
else:
|
else:
|
||||||
human = "N/A"
|
|
||||||
gs_text = "🟡 Game finished, cooling down"
|
gs_text = "🟡 Game finished, cooling down"
|
||||||
elif status_raw in ["finished_today", "finished"]:
|
elif status_raw in ["finished_today", "finished"]:
|
||||||
gs_class = "finished"
|
gs_class = "finished"
|
||||||
@@ -1634,6 +1640,7 @@ async def status(request: Request):
|
|||||||
}}
|
}}
|
||||||
tr:nth-child(even) {{ background-color: #1a1a1a; }}
|
tr:nth-child(even) {{ background-color: #1a1a1a; }}
|
||||||
.ok {{ color: #00ff7f; font-weight: bold; }}
|
.ok {{ color: #00ff7f; font-weight: bold; }}
|
||||||
|
.warn {{ color: #ffff66; font-weight: bold; }}
|
||||||
.fail {{ color: #ff4d4d; font-weight: bold; }}
|
.fail {{ color: #ff4d4d; font-weight: bold; }}
|
||||||
.live {{ color: #00ff7f; font-weight: bold; }}
|
.live {{ color: #00ff7f; font-weight: bold; }}
|
||||||
.finished {{ color: #ff4d4d; font-weight: bold; }}
|
.finished {{ color: #ff4d4d; font-weight: bold; }}
|
||||||
@@ -1660,6 +1667,7 @@ async def status(request: Request):
|
|||||||
<tr><th>Name</th><th>Status</th><th>Timestamp</th><th>Link</th></tr>
|
<tr><th>Name</th><th>Status</th><th>Timestamp</th><th>Link</th></tr>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# ВАЖНО: цикл только добавляет строки, return будет ПОСЛЕ цикла
|
||||||
for s in data["statuses"]:
|
for s in data["statuses"]:
|
||||||
status_text = str(s["status"]).strip().lower()
|
status_text = str(s["status"]).strip().lower()
|
||||||
|
|
||||||
@@ -1679,6 +1687,7 @@ async def status(request: Request):
|
|||||||
color_class = "fail"
|
color_class = "fail"
|
||||||
else:
|
else:
|
||||||
color_class = "unknown"
|
color_class = "unknown"
|
||||||
|
|
||||||
html += f"""
|
html += f"""
|
||||||
<tr>
|
<tr>
|
||||||
<td>{s["name"]}</td>
|
<td>{s["name"]}</td>
|
||||||
@@ -1688,12 +1697,14 @@ async def status(request: Request):
|
|||||||
</tr>
|
</tr>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# закрываем таблицу и страницу УЖЕ ПОСЛЕ цикла
|
||||||
html += """
|
html += """
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
return HTMLResponse(content=html, media_type="text/html")
|
return HTMLResponse(content=html, media_type="text/html")
|
||||||
|
|
||||||
# JSON для API (красиво отформатированный)
|
# JSON для API (красиво отформатированный)
|
||||||
formatted = json.dumps(data, indent=4, ensure_ascii=False)
|
formatted = json.dumps(data, indent=4, ensure_ascii=False)
|
||||||
response = Response(content=formatted, media_type="application/json")
|
response = Response(content=formatted, media_type="application/json")
|
||||||
@@ -3166,8 +3177,12 @@ async def games_online():
|
|||||||
ls = resp.get("result") or resp
|
ls = resp.get("result") or resp
|
||||||
msg = str(ls.get("message") or "").lower()
|
msg = str(ls.get("message") or "").lower()
|
||||||
status = str(ls.get("status") or "").lower()
|
status = str(ls.get("status") or "").lower()
|
||||||
if msg == "not found" or status == "404": pass
|
if msg == "not found" or status == "404":
|
||||||
elif ls.get("message") != "Not found" and str(ls.get("gameStatus")).lower() == "online":
|
pass
|
||||||
|
elif (
|
||||||
|
ls.get("message") != "Not found"
|
||||||
|
and str(ls.get("gameStatus")).lower() == "online"
|
||||||
|
):
|
||||||
game["score1"] = ls.get("scoreA", game.get("score1", ""))
|
game["score1"] = ls.get("scoreA", game.get("score1", ""))
|
||||||
game["score2"] = ls.get("scoreB", game.get("score2", ""))
|
game["score2"] = ls.get("scoreB", game.get("score2", ""))
|
||||||
game["period"] = resolve_period(ls, game)
|
game["period"] = resolve_period(ls, game)
|
||||||
@@ -3180,8 +3195,12 @@ async def games_online():
|
|||||||
todays_games.append(
|
todays_games.append(
|
||||||
{
|
{
|
||||||
"gameStatus": game["gameStatus"],
|
"gameStatus": game["gameStatus"],
|
||||||
"score1": game["score1"] if any((s or 0) > 0 for s in scores) else "",
|
"score1": (
|
||||||
"score2": game["score2"] if any((s or 0) > 0 for s in scores) else "",
|
game["score1"] if any((s or 0) > 0 for s in scores) else ""
|
||||||
|
),
|
||||||
|
"score2": (
|
||||||
|
game["score2"] if any((s or 0) > 0 for s in scores) else ""
|
||||||
|
),
|
||||||
"period": game["period"] if "period" in game else "",
|
"period": game["period"] if "period" in game else "",
|
||||||
"defaultZoneTime": game["defaultZoneTime"],
|
"defaultZoneTime": game["defaultZoneTime"],
|
||||||
"team1": item["team1"]["name"],
|
"team1": item["team1"]["name"],
|
||||||
@@ -3190,9 +3209,19 @@ async def games_online():
|
|||||||
"team1_logo_xls": game["team1_logo_xls"],
|
"team1_logo_xls": game["team1_logo_xls"],
|
||||||
"team2_xls": game["team2_xls"],
|
"team2_xls": game["team2_xls"],
|
||||||
"team2_logo_xls": game["team2_logo_xls"],
|
"team2_logo_xls": game["team2_logo_xls"],
|
||||||
"mask1": "#FFFFFF00" if any((s or 0) > 0 for s in scores) else "#FFFFFF",
|
"mask1": (
|
||||||
"mask2": "#FFFFFF00" if (game["period"] if "period" in game else "") == "" else "#FFFFFF",
|
"#FFFFFF00" if any((s or 0) > 0 for s in scores) else "#FFFFFF"
|
||||||
"mask3": "#FFFFFF00" if (game["period"] if "period" in game else "") != "" else "#FFFFFF",
|
),
|
||||||
|
"mask2": (
|
||||||
|
"#FFFFFF00"
|
||||||
|
if (game["period"] if "period" in game else "") == ""
|
||||||
|
else "#FFFFFF"
|
||||||
|
),
|
||||||
|
"mask3": (
|
||||||
|
"#FFFFFF00"
|
||||||
|
if (game["period"] if "period" in game else "") != ""
|
||||||
|
else "#FFFFFF"
|
||||||
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return todays_games
|
return todays_games
|
||||||
|
|||||||
Reference in New Issue
Block a user