Spaces:
Sleeping
Sleeping
Update engine/live_game_engine.py
Browse files- engine/live_game_engine.py +15 -1
engine/live_game_engine.py
CHANGED
|
@@ -50,7 +50,21 @@ def enrich_game_from_live_feed(game: dict[str, Any], feed: dict[str, Any]) -> di
|
|
| 50 |
current_inning = linescore.get("currentInning")
|
| 51 |
outs = count.get("outs", linescore.get("outs"))
|
| 52 |
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
try:
|
| 56 |
out["outs"] = 0 if outs is None else int(outs)
|
|
|
|
| 50 |
current_inning = linescore.get("currentInning")
|
| 51 |
outs = count.get("outs", linescore.get("outs"))
|
| 52 |
|
| 53 |
+
existing_status = str(out.get("status", "")).strip()
|
| 54 |
+
game_status = feed.get("gameData", {}).get("status", {}) or {}
|
| 55 |
+
abstract_state = str(game_status.get("abstractGameState", "")).strip().lower()
|
| 56 |
+
detailed_state = str(game_status.get("detailedState", "")).strip()
|
| 57 |
+
|
| 58 |
+
is_final_game = (
|
| 59 |
+
"final" in existing_status.lower()
|
| 60 |
+
or abstract_state == "final"
|
| 61 |
+
or "final" in detailed_state.lower()
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
if is_final_game:
|
| 65 |
+
out["status"] = detailed_state if detailed_state else "Final"
|
| 66 |
+
else:
|
| 67 |
+
out["status"] = format_status(inning_half, current_inning, existing_status)
|
| 68 |
|
| 69 |
try:
|
| 70 |
out["outs"] = 0 if outs is None else int(outs)
|