From a88c319cce7e97f8114a9e4057bcb9a63532cf4b Mon Sep 17 00:00:00 2001 From: spameier Date: Sun, 5 Nov 2023 21:03:45 +0100 Subject: [PATCH] fix(cli): reload jingles playlist in liquidsoap after expiring --- klangbecken/cli.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/klangbecken/cli.py b/klangbecken/cli.py index de98caf..e2e68ef 100644 --- a/klangbecken/cli.py +++ b/klangbecken/cli.py @@ -397,6 +397,27 @@ def disable_expired_cmd(data_dir): [MetadataChange("weight", 0)], ) + # currently liquidsoap does not notify when the playlist changes + # solving this the dirty way, because we hope that liquidsoap supports + # inotify properly in newer version than 1.3.7 which would make reloading + # the playlist obsolete. + from .player import LiquidsoapClient + from os import environ + + if "KLANGBECKEN_PLAYER_SOCKET" in environ: + player_socket = environ["KLANGBECKEN_PLAYER_SOCKET"] + try: + with LiquidsoapClient(player_socket) as client: + client.command("jingles.reload") + except FileNotFoundError: + print(f"Could not communicate with Liquidsoap via socket {player_socket}") + exit(1) + else: + print( + "Liquidsoap player socket environment variable (KLANGBECKEN_PLAYER_SOCKET) is not defined." + ) + exit(1) + def main(): """Klangbecken audio playout system.