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

This commit is contained in:
Your Name
2025-09-02 10:03:20 +12:00
parent 1a6306a39d
commit 97c4e8f925
3 changed files with 16 additions and 7 deletions

View File

@@ -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}

View File

@@ -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()

View File

@@ -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}