update for spectra changes (#1363)
This commit is contained in:
@@ -31,6 +31,7 @@ from websockets.asyncio.client import connect as wsconnect
|
||||
from BOT.storage import insert_match, insert_player_games, upsert_tss_teams
|
||||
from BOT.autologging import process_game as autolog_process_game
|
||||
from BOT.receiver_bridge import publish_replay_batch
|
||||
from spectra_replay_normalize import normalize_spectra_replay
|
||||
from spectra_ws_payload import SpectraPayloadError, decode_spectra_ws_payload
|
||||
|
||||
_HERE = Path(__file__).resolve().parent
|
||||
@@ -73,6 +74,7 @@ def _session_id(game: Dict[str, Any]) -> str:
|
||||
|
||||
def _write_game(game: Dict[str, Any]) -> Path:
|
||||
"""Normalize _id to hex, then write to REPLAYS/TSS/<session_id>/replay_data.json.gz."""
|
||||
game.update(normalize_spectra_replay(game))
|
||||
sid = _session_id(game)
|
||||
game["_id"] = sid # hex from this point forward
|
||||
session_dir = REPLAYS_DIR / sid
|
||||
@@ -91,6 +93,10 @@ def normalize(data: Any) -> Optional[List[Dict[str, Any]]]:
|
||||
if isinstance(data, dict):
|
||||
if "_id" in data or "id" in data:
|
||||
return [data]
|
||||
if isinstance(data.get("data"), dict):
|
||||
return [data["data"]]
|
||||
if isinstance(data.get("data"), list):
|
||||
return data["data"]
|
||||
if "completed" in data:
|
||||
return data["completed"]
|
||||
log.warning("Unknown WS frame shape: %s", type(data))
|
||||
|
||||
Reference in New Issue
Block a user