2021-05-01 18:01:24 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import xml.dom.minidom
|
|
|
|
import requests
|
2021-05-06 13:23:43 +00:00
|
|
|
import json
|
2021-05-01 18:01:24 +00:00
|
|
|
|
|
|
|
playlist = None
|
|
|
|
|
|
|
|
try:
|
2022-02-04 16:44:47 +00:00
|
|
|
resp = requests.get(
|
|
|
|
"https://git.purser.it/roypur/icecast-relay/raw/branch/master/icecast.xml"
|
|
|
|
)
|
2021-05-01 18:01:24 +00:00
|
|
|
dom = xml.dom.minidom.parseString(resp.text)
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
else:
|
2021-05-06 13:23:43 +00:00
|
|
|
playlist = {}
|
2021-05-01 18:01:24 +00:00
|
|
|
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
|
2021-05-06 13:23:43 +00:00
|
|
|
value = {}
|
|
|
|
value["radio"] = True
|
|
|
|
value["name"] = stream_name
|
|
|
|
playlist[mount_name] = value
|
2021-05-01 18:01:24 +00:00
|
|
|
|
|
|
|
if playlist is not None:
|
2021-05-19 08:40:18 +00:00
|
|
|
with open("/app/setup/tv.json", "r") as f:
|
2021-05-06 13:23:43 +00:00
|
|
|
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))
|
2021-05-12 12:57:50 +00:00
|
|
|
try:
|
2021-05-13 11:02:20 +00:00
|
|
|
resp = requests.get("https://registry.npmjs.org/@silvermine/videojs-chromecast")
|
2021-05-12 12:57:50 +00:00
|
|
|
data = json.loads(resp.text)
|
2021-05-13 11:02:20 +00:00
|
|
|
chromecast_version = data["dist-tags"]["latest"]
|
2021-05-12 12:57:50 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
else:
|
2021-06-09 07:35:12 +00:00
|
|
|
try:
|
2022-02-04 16:44:47 +00:00
|
|
|
resp = requests.get(
|
|
|
|
f"https://cdn.jsdelivr.net/npm/@silvermine/videojs-chromecast@{chromecast_version}/dist/silvermine-videojs-chromecast.min.css"
|
|
|
|
)
|
2021-06-09 07:35:12 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
else:
|
2021-06-09 13:01:19 +00:00
|
|
|
with open("/app/setup/chromecast.css", "w") as f:
|
2021-06-09 07:35:12 +00:00
|
|
|
f.write(resp.text)
|
2021-05-19 13:54:42 +00:00
|
|
|
with open("/app/version/chromecast.txt", "w") as f:
|
2021-05-13 09:15:40 +00:00
|
|
|
f.write(chromecast_version)
|
2021-05-19 13:54:42 +00:00
|
|
|
|
2022-02-04 16:44:47 +00:00
|
|
|
|
2021-05-19 13:54:42 +00:00
|
|
|
def store_cdnjs(name):
|
|
|
|
version = None
|
|
|
|
try:
|
2022-02-04 16:44:47 +00:00
|
|
|
resp = requests.get(f"https://api.cdnjs.com/libraries/{name}?fields=version")
|
2021-05-19 13:54:42 +00:00
|
|
|
data = json.loads(resp.text)
|
|
|
|
version = data["version"]
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
else:
|
2022-02-04 16:44:47 +00:00
|
|
|
with open(f"/app/version/{name}.txt", "w") as f:
|
2021-05-19 13:54:42 +00:00
|
|
|
f.write(version)
|
|
|
|
|
2022-02-04 16:44:47 +00:00
|
|
|
|
2021-05-19 13:54:42 +00:00
|
|
|
store_cdnjs("video.js")
|
|
|
|
store_cdnjs("font-awesome")
|