feat(playout): move liquidsoap auth to notify cli
This commit is contained in:
parent
114a599993
commit
3f4ebab788
|
@ -125,7 +125,7 @@ def make_input_auth_handler(input_name)
|
||||||
log("user '#{user}' connected", label="#{input_name}_input")
|
log("user '#{user}' connected", label="#{input_name}_input")
|
||||||
|
|
||||||
# Check auth based on return value from auth script
|
# Check auth based on return value from auth script
|
||||||
ret = test_process("python3 '#{auth_path}' '#{input_name}' '#{user}' '#{password}'")
|
ret = test_process("libretime-playout-notify live-auth '#{input_name}' '#{user}' '#{password}'")
|
||||||
if ret then
|
if ret then
|
||||||
log("user '#{user}' authenticated", label="#{input_name}_input")
|
log("user '#{user}' authenticated", label="#{input_name}_input")
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,7 +25,6 @@ def generate_entrypoint(
|
||||||
version: Tuple[int, int, int],
|
version: Tuple[int, int, int],
|
||||||
) -> str:
|
) -> str:
|
||||||
paths = {}
|
paths = {}
|
||||||
paths["auth_filepath"] = here / "liquidsoap_auth.py"
|
|
||||||
paths["lib_filepath"] = here / f"{version[0]}.{version[1]}/ls_script.liq"
|
paths["lib_filepath"] = here / f"{version[0]}.{version[1]}/ls_script.liq"
|
||||||
|
|
||||||
if log_filepath is not None:
|
if log_filepath is not None:
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
from argparse import ArgumentParser
|
|
||||||
from typing import Literal
|
|
||||||
|
|
||||||
from libretime_api_client.v1 import ApiClient as LegacyClient
|
|
||||||
|
|
||||||
|
|
||||||
def main(input_name: Literal["main", "show"], username: str, password: str) -> int:
|
|
||||||
legacy_client = LegacyClient()
|
|
||||||
|
|
||||||
input_name_map = {"main": "master", "show": "dj"}
|
|
||||||
response: dict = legacy_client.check_live_stream_auth(
|
|
||||||
username,
|
|
||||||
password,
|
|
||||||
input_name_map[input_name],
|
|
||||||
)
|
|
||||||
|
|
||||||
if response.get("msg", False) is True:
|
|
||||||
return 0
|
|
||||||
return 1
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
parser = ArgumentParser()
|
|
||||||
|
|
||||||
parser.add_argument("input_name", choices=["main", "show"])
|
|
||||||
parser.add_argument("username")
|
|
||||||
parser.add_argument("password")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
raise SystemExit(
|
|
||||||
main(
|
|
||||||
input_name=args.input_name,
|
|
||||||
username=args.username,
|
|
||||||
password=args.password,
|
|
||||||
)
|
|
||||||
)
|
|
|
@ -9,8 +9,6 @@ input_show_mount = {{ config.stream.inputs.show.mount | quote }}
|
||||||
input_show_port = {{ config.stream.inputs.show.port }}
|
input_show_port = {{ config.stream.inputs.show.port }}
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
auth_path = {{ paths.auth_filepath | quote }}
|
|
||||||
|
|
||||||
{% if paths.log_filepath is defined -%}
|
{% if paths.log_filepath is defined -%}
|
||||||
set("log.file.path", "{{ paths.log_filepath }}")
|
set("log.file.path", "{{ paths.log_filepath }}")
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
|
|
|
@ -14,7 +14,7 @@ Main case:
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Literal, Optional
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from libretime_api_client.v1 import ApiClient as LegacyClient
|
from libretime_api_client.v1 import ApiClient as LegacyClient
|
||||||
|
@ -101,6 +101,39 @@ def live(app: App, name, status):
|
||||||
app.api_client.notify_source_status(name, status)
|
app.api_client.notify_source_status(name, status)
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command()
|
||||||
|
@click.argument("input_name", type=click.Choice(["main", "show"]))
|
||||||
|
@click.argument("username")
|
||||||
|
@click.argument("password")
|
||||||
|
@pass_app
|
||||||
|
def live_auth(
|
||||||
|
app: App,
|
||||||
|
input_name: Literal["main", "show"],
|
||||||
|
username: str,
|
||||||
|
password: str,
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Check live stream user authentication.
|
||||||
|
"""
|
||||||
|
input_name_map = {"main": "master", "show": "dj"}
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
"Checking '%s' live stream user authentication '%s'",
|
||||||
|
input_name,
|
||||||
|
username,
|
||||||
|
)
|
||||||
|
resp = app.api_client.check_live_stream_auth(
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
input_name_map[input_name],
|
||||||
|
)
|
||||||
|
|
||||||
|
payload: dict = resp.json()
|
||||||
|
if payload.get("msg", False) is True:
|
||||||
|
raise SystemExit(0)
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.argument("stream_id")
|
@click.argument("stream_id")
|
||||||
@click.argument("time")
|
@click.argument("time")
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
input_show_port = 8002
|
input_show_port = 8002
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
auth_path = "/fake/liquidsoap_auth.py"
|
|
||||||
|
|
||||||
set("log.file.path", "/var/log/radio.log")
|
set("log.file.path", "/var/log/radio.log")
|
||||||
|
|
||||||
set("server.telnet", true)
|
set("server.telnet", true)
|
||||||
|
@ -49,8 +47,6 @@
|
||||||
input_show_port = 8002
|
input_show_port = 8002
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
auth_path = "/fake/liquidsoap_auth.py"
|
|
||||||
|
|
||||||
set("log.file.path", "/var/log/radio.log")
|
set("log.file.path", "/var/log/radio.log")
|
||||||
|
|
||||||
set("server.telnet", true)
|
set("server.telnet", true)
|
||||||
|
@ -111,8 +107,6 @@
|
||||||
input_show_port = 8002
|
input_show_port = 8002
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
auth_path = "/fake/liquidsoap_auth.py"
|
|
||||||
|
|
||||||
set("log.file.path", "/var/log/radio.log")
|
set("log.file.path", "/var/log/radio.log")
|
||||||
|
|
||||||
set("server.telnet", true)
|
set("server.telnet", true)
|
||||||
|
@ -169,8 +163,6 @@
|
||||||
input_show_port = 8002
|
input_show_port = 8002
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
auth_path = "/fake/liquidsoap_auth.py"
|
|
||||||
|
|
||||||
set("log.file.path", "/var/log/radio.log")
|
set("log.file.path", "/var/log/radio.log")
|
||||||
|
|
||||||
set("server.telnet", true)
|
set("server.telnet", true)
|
||||||
|
@ -252,8 +244,6 @@
|
||||||
input_show_port = 8002
|
input_show_port = 8002
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
auth_path = "/fake/liquidsoap_auth.py"
|
|
||||||
|
|
||||||
set("log.file.path", "/var/log/radio.log")
|
set("log.file.path", "/var/log/radio.log")
|
||||||
|
|
||||||
set("server.telnet", true)
|
set("server.telnet", true)
|
||||||
|
@ -297,8 +287,6 @@
|
||||||
input_show_port = 8002
|
input_show_port = 8002
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
auth_path = "/fake/liquidsoap_auth.py"
|
|
||||||
|
|
||||||
set("log.file.path", "/var/log/radio.log")
|
set("log.file.path", "/var/log/radio.log")
|
||||||
|
|
||||||
set("server.telnet", true)
|
set("server.telnet", true)
|
||||||
|
|
Loading…
Reference in New Issue