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
|
- score-data:/tmp:rw
|
||||||
environment:
|
environment:
|
||||||
- SQUASHKIWI_API=${SQUASHKIWI_API}
|
- 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
|
- MEDIAMTX_API=http://localhost:9997
|
||||||
- RECORDING_PATH=/recordings
|
- RECORDING_PATH=/recordings
|
||||||
- IDLE_TIMEOUT=${IDLE_TIMEOUT}
|
- IDLE_TIMEOUT=${IDLE_TIMEOUT}
|
||||||
|
@@ -26,7 +26,9 @@ class ScoreOverlayService:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Load configuration from environment
|
# Load configuration from environment
|
||||||
self.api_url = os.getenv('SQUASHKIWI_API', 'https://squash.kiwi/api')
|
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.mediamtx_api = os.getenv('MEDIAMTX_API', 'http://localhost:9997')
|
||||||
self.recording_path = os.getenv('RECORDING_PATH', '/recordings')
|
self.recording_path = os.getenv('RECORDING_PATH', '/recordings')
|
||||||
|
|
||||||
@@ -59,7 +61,8 @@ class ScoreOverlayService:
|
|||||||
try:
|
try:
|
||||||
timeout = aiohttp.ClientTimeout(total=5)
|
timeout = aiohttp.ClientTimeout(total=5)
|
||||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
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:
|
async with session.get(url) as resp:
|
||||||
if resp.status == 200:
|
if resp.status == 200:
|
||||||
data = await resp.json()
|
data = await resp.json()
|
||||||
@@ -242,8 +245,9 @@ class ScoreOverlayService:
|
|||||||
logger.info("Starting main service loop")
|
logger.info("Starting main service loop")
|
||||||
|
|
||||||
# Initialize overlay text
|
# Initialize overlay text
|
||||||
|
court_name = os.getenv('COURT_NAME', f'Court {self.court_number}')
|
||||||
with open('/tmp/score.txt', 'w') as f:
|
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()
|
await self.cleanup_old_recordings()
|
||||||
last_cleanup = datetime.now()
|
last_cleanup = datetime.now()
|
||||||
@@ -280,8 +284,9 @@ class ScoreOverlayService:
|
|||||||
await self.stop_recording()
|
await self.stop_recording()
|
||||||
|
|
||||||
# Update overlay to show no active match
|
# 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:
|
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):
|
if datetime.now() - last_cleanup > timedelta(days=1):
|
||||||
await self.cleanup_old_recordings()
|
await self.cleanup_old_recordings()
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
source "${AGENT_PATH}/common.sh"
|
source "${AGENT_PATH}/common.sh"
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/_paths.sh"
|
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
|
# Create directories
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
@@ -36,7 +36,9 @@ MTX_PATHS_COURT_SUB_SOURCE=rtsp://${CAMERA_USER}:${CAMERA_PASSWORD}@${CAMERA_IP}
|
|||||||
MEDIAMTX_USER=${MEDIAMTX_USER}
|
MEDIAMTX_USER=${MEDIAMTX_USER}
|
||||||
MEDIAMTX_PASS=${MEDIAMTX_PASS}
|
MEDIAMTX_PASS=${MEDIAMTX_PASS}
|
||||||
SQUASHKIWI_API=${SQUASHKIWI_API}
|
SQUASHKIWI_API=${SQUASHKIWI_API}
|
||||||
COURT_ID=${COURT_ID}
|
CLUB_CODE=${CLUB_CODE}
|
||||||
|
COURT_NUMBER=${COURT_NUMBER}
|
||||||
|
COURT_NAME=${COURT_NAME}
|
||||||
IDLE_TIMEOUT=${IDLE_TIMEOUT}
|
IDLE_TIMEOUT=${IDLE_TIMEOUT}
|
||||||
RECORDING_RETENTION_DAYS=${RECORDING_RETENTION_DAYS}
|
RECORDING_RETENTION_DAYS=${RECORDING_RETENTION_DAYS}
|
||||||
HOST_PORT=${HOST_PORT}
|
HOST_PORT=${HOST_PORT}
|
||||||
|
Reference in New Issue
Block a user