Update overlay service to use match_active boolean instead of 404 status
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 21s
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 21s
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user