Fix bug in op25 config where it would not create liquidsoap if saved config was loaded
This commit is contained in:
@@ -3,9 +3,10 @@ import json
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from models.models import TalkgroupTag
|
||||
from models.models import TalkgroupTag, IcecastConfig
|
||||
from typing import List, Dict
|
||||
from internal.logger import create_logger
|
||||
from internal.liquidsoap_config_utils import generate_liquid_script
|
||||
|
||||
LOGGER = create_logger(__name__)
|
||||
|
||||
@@ -66,6 +67,27 @@ def activate_config_from_library(system_name: str) -> bool:
|
||||
if src_whitelist.exists():
|
||||
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
|
||||
except Exception as e:
|
||||
LOGGER.error(f"Failed to copy config: {e}")
|
||||
|
||||
Reference in New Issue
Block a user