update to handle new structure from spectra, no more gobs (#1266)

This commit is contained in:
NotSoToothless
2026-05-23 17:16:53 -07:00
committed by GitHub
parent 2d5adfcbe0
commit f6f4e33a65
11 changed files with 459 additions and 313 deletions
+10 -10
View File
@@ -1828,7 +1828,7 @@ app.get('/api/match/:sessionId/video', async (req, res) => {
const sessionDir = resolveReplaySessionDir(sessionId);
const videoPath = path.join(sessionDir, 'replay_video.mp4');
const gobPath = path.join(sessionDir, 'replay.gob');
const replayPath = path.join(sessionDir, 'replay_data.json');
// 1. Serve from disk if cached
if (fs.existsSync(videoPath)) {
@@ -1837,9 +1837,9 @@ app.get('/api/match/:sessionId/video', async (req, res) => {
});
}
// 2. Check if compressed gob exists for generation
if (!fs.existsSync(gobPath)) {
return res.status(404).json({ available: false, reason: 'No GOB replay data available for this session' });
// 2. Check if replay JSON exists for generation
if (!fs.existsSync(replayPath)) {
return res.status(404).json({ available: false, reason: 'No replay data available for this session' });
}
// 3. Generate video on demand (decompress + render)
@@ -1850,7 +1850,7 @@ app.get('/api/match/:sessionId/video', async (req, res) => {
try {
await new Promise((resolve, reject) => {
const pythonBin = path.join(__dirname, '..', '.venv', 'bin', 'python');
execFile(pythonBin, ['-m', 'BOT.gob', gobPath, videoPath], {
execFile(pythonBin, ['-m', 'BOT.render_replay', replayPath, videoPath], {
timeout: 120000,
cwd: path.join(__dirname, '..')
}, (error, stdout, stderr) => {
@@ -1891,7 +1891,7 @@ app.get('/api/match/:sessionId/replay-canvas', async (req, res) => {
const sessionDir = resolveReplaySessionDir(sessionId);
const jsonPath = path.join(sessionDir, 'replay_canvas.json');
const gobPath = path.join(sessionDir, 'replay.gob');
const replayPath = path.join(sessionDir, 'replay_data.json');
// 1. Serve from disk if cached
if (fs.existsSync(jsonPath)) {
@@ -1900,9 +1900,9 @@ app.get('/api/match/:sessionId/replay-canvas', async (req, res) => {
});
}
// 2. Check if GOB exists
if (!fs.existsSync(gobPath)) {
return res.status(404).json({ available: false, reason: 'No GOB replay data available' });
// 2. Check if replay JSON exists
if (!fs.existsSync(replayPath)) {
return res.status(404).json({ available: false, reason: 'No replay data available' });
}
// 3. Generate on demand
@@ -1913,7 +1913,7 @@ app.get('/api/match/:sessionId/replay-canvas', async (req, res) => {
try {
await new Promise((resolve, reject) => {
const pythonBin = path.join(__dirname, '..', '.venv', 'bin', 'python');
execFile(pythonBin, ['-m', 'BOT.gob', gobPath, jsonPath], {
execFile(pythonBin, ['-m', 'BOT.render_replay', replayPath, jsonPath], {
timeout: 30000,
cwd: path.join(__dirname, '..')
}, (error, stdout, stderr) => {