From b247030174c351169fd63a6b1bc46d826227b2f0 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Thu, 13 May 2021 15:24:22 +0200 Subject: [PATCH] sources test --- stream.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/stream.py b/stream.py index 96447bd..3f634c1 100755 --- a/stream.py +++ b/stream.py @@ -56,19 +56,22 @@ stream_server = os.environ.get("STREAM_SERVER") proxy_server = os.environ.get("PROXY_SERVER") if icecast_server is not None and stream_server is not None: - with open("/app/sources.json", "r") as f: - data = json.loads(f.read()) - playlist = "#EXTM3U\n" - for key in data: - current = data[key] - name = current["name"] - radio = current["radio"] - if radio: - playlist += f'#EXTINF:0 radio="true", {name}\n' - playlist += icecast_server + key + "\n" - else: - playlist += f'#EXTINF:0 radio="false", {name}\n' - playlist += stream_server + key + "\n" + try: + with open("/app/sources.json", "r") as f: + data = json.loads(f.read()) + playlist = "#EXTM3U\n" + for key in data: + current = data[key] + name = current["name"] + radio = current["radio"] + if radio: + playlist += f'#EXTINF:0 radio="true", {name}\n' + playlist += icecast_server + key + "\n" + else: + playlist += f'#EXTINF:0 radio="false", {name}\n' + playlist += stream_server + key + "\n" + except Exception as e: + logger.info(e) template_html = None template_js = None