Update API URL format to use club code + court number (e.g., otog2 for Otago Court 2)
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 22s
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 22s
This commit is contained in:
@@ -62,7 +62,9 @@ services:
|
||||
- score-data:/tmp:rw
|
||||
environment:
|
||||
- SQUASHKIWI_API=${SQUASHKIWI_API}
|
||||
- COURT_ID=${COURT_ID}
|
||||
- CLUB_CODE=${CLUB_CODE}
|
||||
- COURT_NUMBER=${COURT_NUMBER}
|
||||
- COURT_NAME=${COURT_NAME}
|
||||
- MEDIAMTX_API=http://localhost:9997
|
||||
- RECORDING_PATH=/recordings
|
||||
- IDLE_TIMEOUT=${IDLE_TIMEOUT}
|
||||
|
@@ -26,7 +26,9 @@ class ScoreOverlayService:
|
||||
def __init__(self):
|
||||
# Load configuration from environment
|
||||
self.api_url = os.getenv('SQUASHKIWI_API', 'https://squash.kiwi/api')
|
||||
self.court_id = os.getenv('COURT_ID', 'court1')
|
||||
self.club_code = os.getenv('CLUB_CODE', 'OTOG')
|
||||
self.court_number = os.getenv('COURT_NUMBER', '1')
|
||||
self.court_id = f"{self.club_code.lower()}{self.court_number}"
|
||||
self.mediamtx_api = os.getenv('MEDIAMTX_API', 'http://localhost:9997')
|
||||
self.recording_path = os.getenv('RECORDING_PATH', '/recordings')
|
||||
|
||||
@@ -59,7 +61,8 @@ class ScoreOverlayService:
|
||||
try:
|
||||
timeout = aiohttp.ClientTimeout(total=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
url = f"{self.api_url}/court/{self.court_id}/score"
|
||||
# Use format: https://squash.kiwi/api/otog2/score
|
||||
url = f"{self.api_url}/{self.court_id}/score"
|
||||
async with session.get(url) as resp:
|
||||
if resp.status == 200:
|
||||
data = await resp.json()
|
||||
@@ -242,8 +245,9 @@ class ScoreOverlayService:
|
||||
logger.info("Starting main service loop")
|
||||
|
||||
# Initialize overlay text
|
||||
court_name = os.getenv('COURT_NAME', f'Court {self.court_number}')
|
||||
with open('/tmp/score.txt', 'w') as f:
|
||||
f.write(f"Court {self.court_id} - Waiting for match...")
|
||||
f.write(f"{court_name} - Waiting for match...")
|
||||
|
||||
await self.cleanup_old_recordings()
|
||||
last_cleanup = datetime.now()
|
||||
@@ -280,8 +284,9 @@ class ScoreOverlayService:
|
||||
await self.stop_recording()
|
||||
|
||||
# Update overlay to show no active match
|
||||
court_name = os.getenv('COURT_NAME', f'Court {self.court_number}')
|
||||
with open('/tmp/score.txt', 'w') as f:
|
||||
f.write(f"Court {self.court_id} - No active match")
|
||||
f.write(f"{court_name} - No active match")
|
||||
|
||||
if datetime.now() - last_cleanup > timedelta(days=1):
|
||||
await self.cleanup_old_recordings()
|
||||
|
Reference in New Issue
Block a user