diff --git a/squashkiwi-streaming/config/overlay/overlay_service.py b/squashkiwi-streaming/config/overlay/overlay_service.py index 1e8ab44..e3f0a0e 100644 --- a/squashkiwi-streaming/config/overlay/overlay_service.py +++ b/squashkiwi-streaming/config/overlay/overlay_service.py @@ -62,10 +62,13 @@ class ScoreOverlayService: url = f"{self.api_url}/court/{self.court_id}/score" async with session.get(url) as resp: if resp.status == 200: - return await resp.json() - elif resp.status == 404: - logger.debug(f"No active match on court {self.court_id}") - return None + data = await resp.json() + # Check if match is active + if data.get('match_active', False): + return data + else: + logger.debug(f"No active match on court {self.court_id}") + return None else: logger.warning(f"API returned status {resp.status}") return None @@ -238,6 +241,10 @@ class ScoreOverlayService: """Main service loop""" logger.info("Starting main service loop") + # Initialize overlay text + with open('/tmp/score.txt', 'w') as f: + f.write(f"Court {self.court_id} - Waiting for match...") + await self.cleanup_old_recordings() last_cleanup = datetime.now() @@ -271,6 +278,10 @@ class ScoreOverlayService: if self.recording_process: logger.info("No active match detected") await self.stop_recording() + + # Update overlay to show no active match + with open('/tmp/score.txt', 'w') as f: + f.write(f"Court {self.court_id} - No active match") if datetime.now() - last_cleanup > timedelta(days=1): await self.cleanup_old_recordings()