separate style file
This commit is contained in:
parent
8d29d58f76
commit
612d8143f4
@ -3,8 +3,9 @@ RUN ["apk", "add", "--no-cache", "--repository", "https://dl-cdn.alpinelinux.org
|
||||
RUN ["mkdir", "/app"]
|
||||
COPY ["stream.py", "/app/stream.py"]
|
||||
COPY ["sources.py", "/app/sources.py"]
|
||||
COPY ["index.html", "/app/index.html"]
|
||||
COPY ["script.js", "/app/script.js"]
|
||||
COPY ["frontend/index.html", "/app/index.html"]
|
||||
COPY ["frontend/script.js", "/app/script.js"]
|
||||
COPY ["frontend/style.css", "/app/style.css"]
|
||||
RUN ["chmod", "-R", "755", "/app"]
|
||||
COPY ["tv.json", "/app/tv.json"]
|
||||
RUN ["python3", "/app/sources.py"]
|
||||
|
@ -1,13 +1,12 @@
|
||||
<html>
|
||||
<head>
|
||||
<style>body { margin: 0px; }</style>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/video.js/{{ videojs_version }}/video-js.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@silvermine/videojs-chromecast@latest/dist/silvermine-videojs-chromecast.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/video.js/{{ videojs_version }}/video.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@silvermine/videojs-chromecast@latest/dist/silvermine-videojs-chromecast.min.js"></script>
|
||||
<script src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
|
||||
<script src="{{ script }}"></script>
|
||||
<style>@media(max-device-width:500px){.vjs-control-bar{font-size:3em;}}</style>
|
||||
<link rel="stylesheet" href="{{ custom_style }}">
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
6
frontend/style.css
Normal file
6
frontend/style.css
Normal file
@ -0,0 +1,6 @@
|
||||
body {
|
||||
margin: 0px;
|
||||
}
|
||||
.vjs-control-bar {
|
||||
font-size: 1rem;
|
||||
}
|
@ -35,12 +35,12 @@ if playlist is not None:
|
||||
try:
|
||||
resp = requests.get("https://api.cdnjs.com/libraries/castjs?fields=version")
|
||||
data = json.loads(resp.text)
|
||||
castjs_version = data["version"]
|
||||
chromecast_version = data["version"]
|
||||
except Exception as e:
|
||||
print(e)
|
||||
else:
|
||||
with open("/app/castjs-version.txt", "w") as f:
|
||||
f.write(castjs_version)
|
||||
with open("/app/chromecast-version.txt", "w") as f:
|
||||
f.write(chromecast_version)
|
||||
try:
|
||||
resp = requests.get("https://api.cdnjs.com/libraries/video.js?fields=version")
|
||||
data = json.loads(resp.text)
|
||||
|
13
stream.py
13
stream.py
@ -74,6 +74,7 @@ template_html = None
|
||||
template_js = None
|
||||
videojs_version = None
|
||||
castjs_version = None
|
||||
custom_style = None
|
||||
try:
|
||||
with open("/app/index.html", "r") as f:
|
||||
template_html = tornado.template.Template(f.read().strip())
|
||||
@ -81,8 +82,12 @@ try:
|
||||
template_js = tornado.template.Template(f.read().strip())
|
||||
with open("/app/videojs-version.txt", "r") as f:
|
||||
videojs_version = f.read().strip()
|
||||
with open("/app/castjs-version.txt", "r") as f:
|
||||
castjs_version = f.read().strip()
|
||||
with open("/app/chromecast-version.txt", "r") as f:
|
||||
chromecast_version = f.read().strip()
|
||||
with open("/app/style.css", "r") as f:
|
||||
custom_style_raw = bytes(f.read().strip(), "utf-8")
|
||||
b64 = str(base64.b64encode(custom_style_raw), "ascii")
|
||||
custom_style = f'data:text/css;charset=utf-8;base64,{b64}'
|
||||
except Exception as e:
|
||||
logger.info(e)
|
||||
|
||||
@ -170,8 +175,8 @@ class MainHandler(tornado.web.RequestHandler):
|
||||
stream_path = f'{self.request.path}?provider={provider}'
|
||||
rendered_js = template_js.generate(stream=stream_path);
|
||||
b64 = str(base64.b64encode(rendered_js), "ascii")
|
||||
script = f'data:text/javascript;charset=utf8;base64,{b64}'
|
||||
rendered_html = template_html.generate(script=script, videojs_version=videojs_version, castjs_version=castjs_version)
|
||||
script = f'data:text/javascript;charset=utf-8;base64,{b64}'
|
||||
rendered_html = template_html.generate(script=script, videojs_version=videojs_version, chromecast_version=chromecast_version, custom_style=custom_style)
|
||||
self.write(rendered_html)
|
||||
else:
|
||||
self.set_status(404)
|
||||
|
Loading…
Reference in New Issue
Block a user