diff --git a/squashkiwi-streaming/config/docker-compose.yml b/squashkiwi-streaming/config/docker-compose.yml index ad10e45..67da2b5 100644 --- a/squashkiwi-streaming/config/docker-compose.yml +++ b/squashkiwi-streaming/config/docker-compose.yml @@ -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} diff --git a/squashkiwi-streaming/config/overlay/overlay_service.py b/squashkiwi-streaming/config/overlay/overlay_service.py index e3f0a0e..31be1fd 100644 --- a/squashkiwi-streaming/config/overlay/overlay_service.py +++ b/squashkiwi-streaming/config/overlay/overlay_service.py @@ -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() diff --git a/squashkiwi-streaming/install.sh b/squashkiwi-streaming/install.sh index c9f02a1..93ae1f4 100755 --- a/squashkiwi-streaming/install.sh +++ b/squashkiwi-streaming/install.sh @@ -3,7 +3,7 @@ source "${AGENT_PATH}/common.sh" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${SCRIPT_DIR}/_paths.sh" -_check_required_env_vars "PROJECT_NAME" "LOCAL_DATA_FOLDER" "CAMERA_IP" "COURT_ID" "RECORDINGS_FOLDER" +_check_required_env_vars "PROJECT_NAME" "LOCAL_DATA_FOLDER" "CAMERA_IP" "CLUB_CODE" "COURT_NUMBER" "RECORDINGS_FOLDER" # Create directories # shellcheck disable=SC2046 @@ -36,7 +36,9 @@ MTX_PATHS_COURT_SUB_SOURCE=rtsp://${CAMERA_USER}:${CAMERA_PASSWORD}@${CAMERA_IP} MEDIAMTX_USER=${MEDIAMTX_USER} MEDIAMTX_PASS=${MEDIAMTX_PASS} SQUASHKIWI_API=${SQUASHKIWI_API} -COURT_ID=${COURT_ID} +CLUB_CODE=${CLUB_CODE} +COURT_NUMBER=${COURT_NUMBER} +COURT_NAME=${COURT_NAME} IDLE_TIMEOUT=${IDLE_TIMEOUT} RECORDING_RETENTION_DAYS=${RECORDING_RETENTION_DAYS} HOST_PORT=${HOST_PORT}