Implement Metadata Watcher #1

Merged
logan merged 9 commits from metadata-watcher into main 2025-12-29 19:04:07 -05:00
Showing only changes of commit 0a6b565651 - Show all commits

View File

@@ -3,9 +3,10 @@ import json
import os import os
import shutil import shutil
from pathlib import Path from pathlib import Path
from models.models import TalkgroupTag from models.models import TalkgroupTag, IcecastConfig
from typing import List, Dict from typing import List, Dict
from internal.logger import create_logger from internal.logger import create_logger
from internal.liquidsoap_config_utils import generate_liquid_script
LOGGER = create_logger(__name__) LOGGER = create_logger(__name__)
@@ -65,7 +66,28 @@ def activate_config_from_library(system_name: str) -> bool:
src_whitelist = src.with_suffix(".whitelist.tsv") src_whitelist = src.with_suffix(".whitelist.tsv")
if src_whitelist.exists(): if src_whitelist.exists():
shutil.copy2(src_whitelist, config_path / "active.cfg.whitelist.tsv") shutil.copy2(src_whitelist, config_path / "active.cfg.whitelist.tsv")
# Generate Liquidsoap Script by reading the activated config
with open(dst, 'r') as f:
data = json.load(f)
if "trunking" in data and "metadata" in data:
streams = data.get("metadata", {}).get("streams", [])
if streams:
stream = streams[0]
address = stream.get("icecastServerAddress", "127.0.0.1:8000")
host, port = address.split(":") if ":" in address else (address, 8000)
ice_config = IcecastConfig(
icecast_host=host,
icecast_port=int(port),
icecast_mountpoint=stream.get("icecastMountpoint", "/stream"),
icecast_password=stream.get("icecastPass", "hackme"),
icecast_description="OP25 Stream",
icecast_genre="Scanner"
)
generate_liquid_script(ice_config)
return True return True
except Exception as e: except Exception as e:
LOGGER.error(f"Failed to copy config: {e}") LOGGER.error(f"Failed to copy config: {e}")