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,8 +62,11 @@ class ScoreOverlayService:
|
|||||||
url = f"{self.api_url}/court/{self.court_id}/score"
|
url = f"{self.api_url}/court/{self.court_id}/score"
|
||||||
async with session.get(url) as resp:
|
async with session.get(url) as resp:
|
||||||
if resp.status == 200:
|
if resp.status == 200:
|
||||||
return await resp.json()
|
data = await resp.json()
|
||||||
elif resp.status == 404:
|
# 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}")
|
logger.debug(f"No active match on court {self.court_id}")
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
@@ -238,6 +241,10 @@ class ScoreOverlayService:
|
|||||||
"""Main service loop"""
|
"""Main service loop"""
|
||||||
logger.info("Starting 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()
|
await self.cleanup_old_recordings()
|
||||||
last_cleanup = datetime.now()
|
last_cleanup = datetime.now()
|
||||||
|
|
||||||
@@ -272,6 +279,10 @@ class ScoreOverlayService:
|
|||||||
logger.info("No active match detected")
|
logger.info("No active match detected")
|
||||||
await self.stop_recording()
|
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):
|
if datetime.now() - last_cleanup > timedelta(days=1):
|
||||||
await self.cleanup_old_recordings()
|
await self.cleanup_old_recordings()
|
||||||
last_cleanup = datetime.now()
|
last_cleanup = datetime.now()
|
||||||
|
Reference in New Issue
Block a user