#!/usr/bin/env python3 import xml.dom.minidom import requests import json playlist = None try: resp = requests.get("https://git.purser.it/roypur/icecast-relay/raw/branch/master/icecast.xml") dom = xml.dom.minidom.parseString(resp.text) except Exception as e: print(e) else: playlist = {} mounts = dom.getElementsByTagName("mount") for mount in mounts: mount_names = mount.getElementsByTagName("mount-name") stream_names = mount.getElementsByTagName("stream-name") if len(mount_names) == 1 and len(stream_names) == 1: mount_name = mount_names[0].firstChild.nodeValue stream_name = stream_names[0].firstChild.nodeValue value = {} value["radio"] = True value["name"] = stream_name playlist[mount_name] = value if playlist is not None: with open("/app/setup/tv.json", "r") as f: tv = json.loads(f.read()) for name in tv: playlist[name] = tv[name] with open("/app/sources.json", "w+") as f: f.write(json.dumps(playlist)) try: resp = requests.get("https://registry.npmjs.org/@silvermine/videojs-chromecast") data = json.loads(resp.text) chromecast_version = data["dist-tags"]["latest"] except Exception as e: print(e) else: try: resp = requests.get(f'https://cdn.jsdelivr.net/npm/@silvermine/videojs-chromecast@{chromecast_version}/dist/silvermine-videojs-chromecast.min.css') except Exception as e: print(e) else: with open("/app/setup/chromecast.css", "w") as f: f.write(resp.text) with open("/app/version/chromecast.txt", "w") as f: f.write(chromecast_version) def store_cdnjs(name): version = None try: resp = requests.get(f'https://api.cdnjs.com/libraries/{name}?fields=version') data = json.loads(resp.text) version = data["version"] except Exception as e: print(e) else: with open(f'/app/version/{name}.txt', "w") as f: f.write(version) store_cdnjs("video.js") store_cdnjs("font-awesome")