update to handle new structure from spectra, no more gobs (#1266)
This commit is contained in:
+36
-11
@@ -1216,11 +1216,15 @@ def transform_to_local_format(api_data: Dict[str, Any]) -> Optional[Dict[str, An
|
||||
|
||||
replay = api_data["completed"][0]
|
||||
|
||||
winner_winged = replay.get("winner")
|
||||
loser_winged = replay.get("loser")
|
||||
winner_winged = str(replay.get("winner") or "")
|
||||
loser_winged = str(replay.get("loser") or "")
|
||||
|
||||
winner_squadron = winner_winged[1:-1] if winner_winged else ""
|
||||
loser_squadron = loser_winged[1:-1] if loser_winged else ""
|
||||
def _normalize_squadron_tag(raw: str) -> str:
|
||||
cleaned = re.sub(r"[^A-Za-z0-9_-]", "", raw or "")
|
||||
return cleaned or (raw or "").strip()
|
||||
|
||||
winner_squadron = _normalize_squadron_tag(winner_winged)
|
||||
loser_squadron = _normalize_squadron_tag(loser_winged)
|
||||
|
||||
is_draw = replay.get("draw", False)
|
||||
|
||||
@@ -1310,7 +1314,7 @@ def transform_to_local_format(api_data: Dict[str, Any]) -> Optional[Dict[str, An
|
||||
"offended_uid": str(kill["offended_uid"]) if kill.get("offended_uid") is not None else None,
|
||||
"offended_unit": kill.get("offended_unit"),
|
||||
"crashed": kill.get("crashed", False),
|
||||
"weapon": kill.get("weapon", ""),
|
||||
"weapon": kill.get("used_weapon", "") or kill.get("weapon", ""),
|
||||
"afire": False,
|
||||
})
|
||||
|
||||
@@ -1402,9 +1406,23 @@ def transform_to_local_format(api_data: Dict[str, Any]) -> Optional[Dict[str, An
|
||||
f"{prefix}[{time_str}] {sq_tag:<7} {name} ({vehicle}) damaged {afire}{victim_name} ({victim_vehicle})"
|
||||
)
|
||||
|
||||
raw_id = replay.get("_id")
|
||||
start_ts = replay.get("start_ts") or 0
|
||||
end_ts = replay.get("end_ts") or 0
|
||||
raw_id = replay.get("_id")
|
||||
if raw_id is None:
|
||||
raw_id = replay.get("id")
|
||||
start_ts = int(replay.get("start_ts") or 0)
|
||||
end_ts = int(replay.get("end_ts") or 0)
|
||||
|
||||
mission_name = str(replay.get("mission_name") or "").strip()
|
||||
if not mission_name:
|
||||
mission_name = str(replay.get("level_path") or "").strip()
|
||||
|
||||
mission_mode = str(replay.get("mission_mode") or "").strip()
|
||||
if not mission_mode:
|
||||
mission_mode = str(replay.get("difficulty") or "").strip()
|
||||
|
||||
duration = replay.get("duration")
|
||||
if duration is None:
|
||||
duration = max(0, end_ts - start_ts)
|
||||
|
||||
session_id_dec = str(raw_id) if raw_id is not None else ""
|
||||
try:
|
||||
@@ -1420,9 +1438,11 @@ def transform_to_local_format(api_data: Dict[str, Any]) -> Optional[Dict[str, An
|
||||
"session_id_dec": session_id_dec,
|
||||
"session_id_hex": session_id_hex,
|
||||
"timestamp": end_ts,
|
||||
"map": replay.get("mission_name", ""),
|
||||
"mode": replay.get("mission_mode", ""),
|
||||
"duration": end_ts - start_ts,
|
||||
"start_ts": start_ts,
|
||||
"end_ts": end_ts,
|
||||
"map": mission_name,
|
||||
"mode": mission_mode,
|
||||
"duration": duration,
|
||||
"draw": is_draw,
|
||||
"teams": [
|
||||
{
|
||||
@@ -1444,6 +1464,11 @@ def transform_to_local_format(api_data: Dict[str, Any]) -> Optional[Dict[str, An
|
||||
],
|
||||
"chat_log": chat_log,
|
||||
"battle_log": battle_log,
|
||||
"events": raw_events,
|
||||
"entities": replay.get("entities", []),
|
||||
"level_path": replay.get("level_path"),
|
||||
"mission_path": replay.get("mission_path"),
|
||||
"difficulty": replay.get("difficulty"),
|
||||
"type": replay.get("type", ""),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user