2021-10-10 18:57:54 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
# imports
|
|
|
|
import flask
|
|
|
|
import urllib
|
|
|
|
from zomstream import Zomstream
|
|
|
|
|
|
|
|
streamList = []
|
|
|
|
zomstream = Zomstream()
|
|
|
|
|
|
|
|
frontend = flask.Blueprint('frontend', __name__)
|
|
|
|
|
|
|
|
@frontend.route("/")
|
|
|
|
def start():
|
|
|
|
mainTemplate = '%s/main.html.j2' % zomstream.configuration['template_folder']
|
2021-10-12 15:11:19 -04:00
|
|
|
itemList = zomstream.getStreamNames()
|
|
|
|
|
|
|
|
applications = []
|
|
|
|
appnames = []
|
|
|
|
for item in itemList:
|
|
|
|
if item[0] not in appnames:
|
|
|
|
appnames.append(item[0])
|
|
|
|
|
|
|
|
for appname in appnames:
|
|
|
|
streamnames = []
|
|
|
|
for item in itemList:
|
|
|
|
streamitem=item[1].split('_')[0]
|
|
|
|
if streamitem not in streamnames and item[0] == appname:
|
|
|
|
streamnames.append(streamitem)
|
|
|
|
|
|
|
|
streams = []
|
|
|
|
for streamname in streamnames:
|
|
|
|
substreams = []
|
|
|
|
for item in itemList:
|
|
|
|
if item[0] == appname:
|
|
|
|
if item[1].split('_')[0] == streamname:
|
|
|
|
substreams.append(item[1])
|
|
|
|
stream = [streamname, substreams]
|
|
|
|
streams.append(stream)
|
|
|
|
|
|
|
|
app = [appname, streams]
|
|
|
|
applications.append(app)
|
|
|
|
|
2021-10-10 18:57:54 -04:00
|
|
|
page = flask.render_template(
|
|
|
|
mainTemplate,
|
2021-10-12 15:11:19 -04:00
|
|
|
applications=applications,
|
2021-10-10 18:57:54 -04:00
|
|
|
configuration=zomstream.configuration
|
|
|
|
)
|
|
|
|
return page
|
|
|
|
|
2021-10-12 15:11:19 -04:00
|
|
|
@frontend.route("/player/<appname>/<stream>")
|
|
|
|
def show_player(appname, stream):
|
2021-10-10 18:57:54 -04:00
|
|
|
playerTemplate = '%s/player.html.j2' % zomstream.configuration['template_folder']
|
|
|
|
page = flask.render_template(
|
|
|
|
playerTemplate,
|
|
|
|
appname=appname,
|
2021-10-12 15:11:19 -04:00
|
|
|
stream=stream,
|
2021-10-10 18:57:54 -04:00
|
|
|
configuration=zomstream.configuration
|
|
|
|
)
|
|
|
|
return page
|