mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 09:26:57 -05:00
commit
017d2dea42
54
data/www/templates/base.html
Normal file
54
data/www/templates/base.html
Normal file
@ -0,0 +1,54 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
table, th, td {border: 1px solid black;}
|
||||
</style>
|
||||
<link href="style.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<h1 style="text-align: center;">
|
||||
<span style="text-decoration: underline;"><strong><em>{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }}</em></strong>
|
||||
</span>
|
||||
<img class="pull-left" src="/favicon.ico" alt="fHDHR Logo" width="100" height="100">
|
||||
</h1>
|
||||
<br><br>
|
||||
<div>
|
||||
|
||||
<button class="pull-left" onclick="OpenLink('/')">fHDHR</a></button>
|
||||
<button class="pull-left" onclick="OpenLink('/origin')">{{ fhdhr.config.dict["main"]["servicename"] }}</a></button>
|
||||
<button class="pull-left" onclick="OpenLink('/guide')">Guide</a></button>
|
||||
<button class="pull-left" onclick="OpenLink('/cluster')">Cluster</a></button>
|
||||
<button class="pull-left" onclick="OpenLink('/streams')">Streams</a></button>
|
||||
<button class="pull-left" onclick="OpenLink('/xmltv')">xmltv</a></button>
|
||||
<button class="pull-left" onclick="OpenLink('/version')">Version</a></button>
|
||||
<button class="pull-left" onclick="OpenLink('/diagnostics')">Diagnostics</a></button>
|
||||
|
||||
<a class="pull-right" style="padding: 5px;" href="/api/xmltv?method=get&source={{ fhdhr.device.epg.def_method }}">xmltv</a>
|
||||
<a class="pull-right" style="padding: 5px;" href="/api/m3u?method=get&channel=all">m3u</a>
|
||||
|
||||
</div>
|
||||
<hr align="center" width="100%">
|
||||
|
||||
{% set locations = fhdhr.device.cluster.get_cluster_dicts_web() %}
|
||||
{% if locations %}
|
||||
<div>
|
||||
{% for location in locations %}
|
||||
<button class="pull-left" onclick="OpenLink('{{ location["base_url"] }}')">{{ location["name"] }}</a></button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<hr align="center" width="100%">
|
||||
{% endif %}
|
||||
|
||||
{% set retmessage = request.args.get('retmessage', default=None) %}
|
||||
{% if retmessage %}
|
||||
<p>{{ retmessage }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
<script>
|
||||
function OpenLink(NewURL) {window.open(NewURL, "_self");}
|
||||
</script>
|
||||
50
data/www/templates/cluster.html
Normal file
50
data/www/templates/cluster.html
Normal file
@ -0,0 +1,50 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h4 style="text-align: center;">Cluster</h4>
|
||||
{% if not fhdhr.config.dict["fhdhr"]["discovery_address"] %}
|
||||
<p style="text-align: center;">Discovery Address must be set for SSDP/Cluster</p>
|
||||
{% else %}
|
||||
|
||||
<div style="text-align: center;">
|
||||
<button onclick="OpenLink('/api/cluster?method=scan&redirect=%2Fcluster')">Force Scan</a></button>
|
||||
<button onclick="OpenLink('/api/cluster?method=disconnect&redirect=%2Fcluster')">Disconnect</a></button>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<table class="center" style="width:50%">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Location</th>
|
||||
<th>Joined</th>
|
||||
<th>Options</th>
|
||||
</tr>
|
||||
|
||||
{% for location in locations_list %}
|
||||
<tr>
|
||||
<td>{{ location["name"] }}</td>
|
||||
<td>{{ location["location"] }}</td>
|
||||
<td>{{ location["joined"] }}</td>
|
||||
|
||||
<td>
|
||||
<div>
|
||||
|
||||
{% if location["joined"] in ["True", "False"] %}
|
||||
<button onclick="OpenLink('{{ location["location"] }}')">Visit</a></button>
|
||||
{% endif %}
|
||||
|
||||
{% if location["joined"] == "True" %}
|
||||
<button onclick="OpenLink('/api/cluster?method=del&location={{ location["url_query"] }}&redirect=%2Fcluster')">Remove</a></button>
|
||||
{% elif location["joined"] == "False" %}
|
||||
<button onclick="OpenLink('/api/cluster?method=add&location={{ location["url_query"] }}&redirect=%2Fcluster')">Add</a></button>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
11
data/www/templates/diagnostics.html
Normal file
11
data/www/templates/diagnostics.html
Normal file
@ -0,0 +1,11 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% for button_item in button_list %}
|
||||
<div style="text-align: center;">
|
||||
<p><button onclick="OpenLink('{{ button_item[1] }}')">{{ button_item[0] }}</a></button></p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
32
data/www/templates/guide.html
Normal file
32
data/www/templates/guide.html
Normal file
@ -0,0 +1,32 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h4 style="text-align: center;">What's On {{ fhdhr.config.dict["fhdhr"]["friendlyname"] }}</h4>
|
||||
|
||||
<table class="center" style="width:100%">
|
||||
<tr>
|
||||
<th>Play</th>
|
||||
<th>Channel Name</th>
|
||||
<th>Channel Number</th>
|
||||
<th>Channel Thumbnail</th>
|
||||
<th>Content Title</th>
|
||||
<th>Content Thumbnail</th>
|
||||
<th>Content Description</th>
|
||||
<th>Content Remaining Time</th>
|
||||
</tr>
|
||||
|
||||
{% for chan_dict in chan_guide_list %}
|
||||
<tr>
|
||||
<td><a href="{{ chan_dict["play_url"] }}">Play</a>
|
||||
<td>{{ chan_dict["name"] }}</td>
|
||||
<td>{{ chan_dict["number"] }}</td>
|
||||
<td><img src="{{ chan_dict["chan_thumbnail"] }}" alt="{{ chan_dict["name"] }}" width="100" height="100">
|
||||
<td>{{ chan_dict["listing_title"] }}</td>
|
||||
<td><img src="{{ chan_dict["listing_thumbnail"] }}" alt="{{ chan_dict["listing_title"] }}" width="100" height="100">
|
||||
<td>{{ chan_dict["listing_description"] }}</td>
|
||||
<td>{{ chan_dict["remaining_time"] }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
20
data/www/templates/index.html
Normal file
20
data/www/templates/index.html
Normal file
@ -0,0 +1,20 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h4 style="text-align: center;">fHDHR Status</h4>
|
||||
|
||||
<table class="center" style="width:50%">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
{% for key in list(fhdhr_status_dict.keys()) %}
|
||||
<tr>
|
||||
<td>{{ key }}</td>
|
||||
<td>{{ fhdhr_status_dict[key] }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
25
data/www/templates/origin.html
Normal file
25
data/www/templates/origin.html
Normal file
@ -0,0 +1,25 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h4 style="text-align: center;">{{ fhdhr.config.dict["main"]["servicename"] }} Status</h4>
|
||||
|
||||
<div style="text-align: center;">
|
||||
<button onclick="OpenLink('/api/channels?method=scan&redirect=%2Forigin')">Force Channel Update</a></button>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<table class="center" style="width:50%">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
{% for key in list(origin_status_dict.keys()) %}
|
||||
<tr>
|
||||
<td>{{ key }}</td>
|
||||
<td>{{ origin_status_dict[key] }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
40
data/www/templates/streams.html
Normal file
40
data/www/templates/streams.html
Normal file
@ -0,0 +1,40 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h4 style="text-align: center;">fHDHR Streams</h4>
|
||||
|
||||
<table class="center" style="width:100%">
|
||||
<tr>
|
||||
<th>Tuner</th>
|
||||
<th>Status</th>
|
||||
<th>Channel</th>
|
||||
<th>Method</th>
|
||||
<th>Time Active</th>
|
||||
<th>Options</th>
|
||||
</tr>
|
||||
|
||||
{% for tuner_dict in tuner_list %}
|
||||
<tr>
|
||||
<td>{{ tuner_dict["number"] }}</td>
|
||||
<td>{{ tuner_dict["status"] }}</td>
|
||||
{% if tuner_dict["status"] == "Active" %}
|
||||
<td>{{ tuner_dict["channel_number"] }}</td>
|
||||
<td>{{ tuner_dict["method"] }}</td>
|
||||
<td>{{ tuner_dict["play_duration"] }}</td>
|
||||
{% else %}
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
{% endif %}
|
||||
<td>
|
||||
<div>
|
||||
{% if tuner_dict["status"] in ["Active", "Acquired"] %}
|
||||
<button onclick="OpenLink('/api/watch?method=close&tuner={{ tuner_dict["number"] }}&redirect=%2Fstreams')">Close</a></button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
20
data/www/templates/version.html
Normal file
20
data/www/templates/version.html
Normal file
@ -0,0 +1,20 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h4 style="text-align: center;">fHDHR Version Information</h4>
|
||||
|
||||
<table class="center" style="width:50%">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
{% for key in list(version_dict.keys()) %}
|
||||
<tr>
|
||||
<td>{{ key }}</td>
|
||||
<td>{{ version_dict[key] }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
38
data/www/templates/xmltv.html
Normal file
38
data/www/templates/xmltv.html
Normal file
@ -0,0 +1,38 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h4 style="text-align: center;">xmltv</h4>
|
||||
|
||||
<table class="center" style="width:50%">
|
||||
<tr>
|
||||
<th>Version</th>
|
||||
<th>XMLTV Link</th>
|
||||
<th>EPG Link</th>
|
||||
<th>Options</th>
|
||||
</tr>
|
||||
|
||||
{% for epg_method in fhdhr.config.dict["main"]["valid_epg_methods"] %}
|
||||
{% if epg_method not in [None, "None"] %}
|
||||
{% set epg_method_name = epg_method %}
|
||||
{% if epg_method == "origin" %}
|
||||
{% set epg_method_name = fhdhr.config.dict["main"]["dictpopname"] %}
|
||||
{% endif %}
|
||||
|
||||
<tr>
|
||||
<td>{{ epg_method_name }}</td>
|
||||
<td><a href="/api/xmltv?method=get&source="{{ epg_method }}>{{ epg_method_name }}</a></td>
|
||||
<td><a href="/api/epg?method=get&source="{{ epg_method }}>{{ epg_method_name }}</a></td>
|
||||
<td>
|
||||
<div>
|
||||
<button onclick="OpenLink('/api/xmltv?method=update&source={{ epg_method }}&redirect=%2Fxmltv')">Update</a></button>
|
||||
<button onclick="OpenLink('/api/xmltv?method=clearcache&source={{ epg_method }}&redirect=%2Fxmltv')">Clear Cache</a></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
@ -28,7 +28,6 @@ class Config():
|
||||
|
||||
data_dir = pathlib.Path(script_dir).joinpath('data')
|
||||
www_dir = pathlib.Path(data_dir).joinpath('www')
|
||||
www_images_dir = pathlib.Path(www_dir).joinpath('images')
|
||||
|
||||
self.dict["filedir"] = {
|
||||
"script_dir": script_dir,
|
||||
@ -37,7 +36,8 @@ class Config():
|
||||
"cache_dir": pathlib.Path(data_dir).joinpath('cache'),
|
||||
"internal_config": pathlib.Path(data_dir).joinpath('internal_config'),
|
||||
"www_dir": www_dir,
|
||||
"www_images_dir": www_images_dir,
|
||||
"www_images_dir": pathlib.Path(www_dir).joinpath('images'),
|
||||
"www_templates_dir": pathlib.Path(www_dir).joinpath('templates'),
|
||||
"font": pathlib.Path(data_dir).joinpath('garamond.ttf'),
|
||||
"favicon": pathlib.Path(data_dir).joinpath('favicon.ico'),
|
||||
"epg_cache": {},
|
||||
@ -45,7 +45,8 @@ class Config():
|
||||
|
||||
for conffile in os.listdir(self.dict["filedir"]["internal_config"]):
|
||||
conffilepath = os.path.join(self.dict["filedir"]["internal_config"], conffile)
|
||||
self.read_config(conffilepath)
|
||||
if str(conffilepath).endswith(".ini"):
|
||||
self.read_config(conffilepath)
|
||||
|
||||
def read_config(self, conffilepath):
|
||||
config_handler = configparser.ConfigParser()
|
||||
|
||||
@ -22,6 +22,22 @@ class fHDHR_Cluster():
|
||||
def cluster(self):
|
||||
return self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
|
||||
|
||||
def get_cluster_dicts_web(self):
|
||||
fhdhr_list = self.cluster()
|
||||
locations = []
|
||||
for location in list(fhdhr_list.keys()):
|
||||
item_dict = {
|
||||
"base_url": fhdhr_list[location]["base_url"],
|
||||
"name": fhdhr_list[location]["name"]
|
||||
}
|
||||
if item_dict["base_url"] != self.location:
|
||||
locations.append(item_dict)
|
||||
if len(locations):
|
||||
locations = sorted(locations, key=lambda i: i['name'])
|
||||
return locations
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_list(self):
|
||||
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
|
||||
return_dict = {}
|
||||
|
||||
@ -13,7 +13,9 @@ class fHDHR_HTTP_Server():
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
|
||||
self.app = Flask("fHDHR")
|
||||
self.template_folder = fhdhr.config.dict["filedir"]["www_templates_dir"]
|
||||
|
||||
self.app = Flask("fHDHR", template_folder=self.template_folder)
|
||||
|
||||
self.pages = fHDHR_Pages(fhdhr)
|
||||
self.add_endpoints(self.pages, "pages")
|
||||
|
||||
@ -5,6 +5,7 @@ import urllib.parse
|
||||
class Channels():
|
||||
endpoints = ["/api/channels"]
|
||||
endpoint_name = "api_channels"
|
||||
endpoint_methods = ["GET", "POST"]
|
||||
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
|
||||
@ -6,6 +6,7 @@ import json
|
||||
class Cluster():
|
||||
endpoints = ["/api/cluster"]
|
||||
endpoint_name = "api_cluster"
|
||||
endpoint_methods = ["GET", "POST"]
|
||||
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
|
||||
@ -5,6 +5,7 @@ import json
|
||||
class Debug_JSON():
|
||||
endpoints = ["/api/debug"]
|
||||
endpoint_name = "api_debug"
|
||||
endpoint_methods = ["GET", "POST"]
|
||||
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
|
||||
@ -7,6 +7,7 @@ class EPG():
|
||||
"""Methods to create xmltv.xml"""
|
||||
endpoints = ["/api/epg"]
|
||||
endpoint_name = "api_epg"
|
||||
endpoint_methods = ["GET", "POST"]
|
||||
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
|
||||
@ -4,6 +4,7 @@ from flask import request, Response, abort
|
||||
class Images():
|
||||
endpoints = ["/api/images"]
|
||||
endpoint_name = "api_images"
|
||||
endpoint_methods = ["GET", "POST"]
|
||||
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
|
||||
@ -6,7 +6,7 @@ from io import StringIO
|
||||
class M3U():
|
||||
endpoints = ["/api/m3u", "/api/channels.m3u"]
|
||||
endpoint_name = "api_m3u"
|
||||
xmltv_xml = None
|
||||
endpoint_methods = ["GET", "POST"]
|
||||
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
@ -75,7 +75,7 @@ class M3U():
|
||||
|
||||
return Response(status=200,
|
||||
response=channels_m3u,
|
||||
mimetype='text/plain')
|
||||
mimetype='audio/x-mpegurl')
|
||||
|
||||
if redirect_url:
|
||||
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method))
|
||||
|
||||
@ -8,6 +8,7 @@ class Watch():
|
||||
"""Methods to create xmltv.xml"""
|
||||
endpoints = ["/api/watch"]
|
||||
endpoint_name = "api_watch"
|
||||
endpoint_methods = ["GET", "POST"]
|
||||
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
|
||||
@ -10,7 +10,7 @@ class xmlTV():
|
||||
"""Methods to create xmltv.xml"""
|
||||
endpoints = ["/api/xmltv", "/xmltv.xml"]
|
||||
endpoint_name = "api_xmltv"
|
||||
xmltv_xml = None
|
||||
endpoint_methods = ["GET", "POST"]
|
||||
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
|
||||
|
||||
from .htmlerror import HTMLerror
|
||||
from .page_elements import fHDHR_Page_Elements
|
||||
from .index_html import Index_HTML
|
||||
from .origin_html import Origin_HTML
|
||||
from .cluster_html import Cluster_HTML
|
||||
@ -17,17 +15,11 @@ class fHDHR_Pages():
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
|
||||
self.page_elements = fHDHR_Page_Elements(fhdhr)
|
||||
|
||||
self.index = Index_HTML(fhdhr, self.page_elements)
|
||||
|
||||
self.htmlerror = HTMLerror(fhdhr)
|
||||
|
||||
self.index = Index_HTML(fhdhr, self.page_elements)
|
||||
self.origin = Origin_HTML(fhdhr, self.page_elements)
|
||||
self.cluster = Cluster_HTML(fhdhr, self.page_elements)
|
||||
self.diagnostics = Diagnostics_HTML(fhdhr, self.page_elements)
|
||||
self.version = Version_HTML(fhdhr, self.page_elements)
|
||||
self.guide = Guide_HTML(fhdhr, self.page_elements)
|
||||
self.streams = Streams_HTML(fhdhr, self.page_elements)
|
||||
self.xmltv = xmlTV_HTML(fhdhr, self.page_elements)
|
||||
self.index = Index_HTML(fhdhr)
|
||||
self.origin = Origin_HTML(fhdhr)
|
||||
self.cluster = Cluster_HTML(fhdhr)
|
||||
self.diagnostics = Diagnostics_HTML(fhdhr)
|
||||
self.version = Version_HTML(fhdhr)
|
||||
self.guide = Guide_HTML(fhdhr)
|
||||
self.streams = Streams_HTML(fhdhr)
|
||||
self.xmltv = xmlTV_HTML(fhdhr)
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
from flask import request
|
||||
from io import StringIO
|
||||
from flask import request, render_template
|
||||
import urllib.parse
|
||||
|
||||
|
||||
@ -7,82 +6,45 @@ class Cluster_HTML():
|
||||
endpoints = ["/cluster", "/cluster.html"]
|
||||
endpoint_name = "cluster"
|
||||
|
||||
def __init__(self, fhdhr, page_elements):
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
self.page_elements = page_elements
|
||||
self.location_dict = {
|
||||
"name": self.fhdhr.config.dict["fhdhr"]["friendlyname"],
|
||||
"location": self.fhdhr.device.cluster.location,
|
||||
"joined": "N/A",
|
||||
"url_query": self.fhdhr.device.cluster.location_url
|
||||
}
|
||||
|
||||
def __call__(self, *args):
|
||||
return self.get(*args)
|
||||
|
||||
def get(self, *args):
|
||||
|
||||
fakefile = StringIO()
|
||||
|
||||
page_elements = self.page_elements.get(request)
|
||||
|
||||
for line in page_elements["top"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
fakefile.write("<h4 style=\"text-align: center;\">Cluster</h4>")
|
||||
fakefile.write("\n")
|
||||
locations_list = []
|
||||
|
||||
if self.fhdhr.config.dict["fhdhr"]["discovery_address"]:
|
||||
|
||||
fakefile.write("<div style=\"text-align: center;\">\n")
|
||||
fakefile.write(" <button onclick=\"OpenLink('%s')\">%s</a></button>\n" % ("/api/cluster?method=scan&redirect=%2Fcluster", "Force Scan"))
|
||||
fakefile.write(" <button onclick=\"OpenLink('%s')\">%s</a></button>\n" % ("/api/cluster?method=disconnect&redirect=%2Fcluster", "Disconnect"))
|
||||
fakefile.write("</div><br>\n")
|
||||
|
||||
fakefile.write("<table class=\"center\" style=\"width:50%\">\n")
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <th>Name</th>\n")
|
||||
fakefile.write(" <th>Location</th>\n")
|
||||
fakefile.write(" <th>Joined</th>\n")
|
||||
fakefile.write(" <th>Options</th>\n")
|
||||
fakefile.write(" </tr>\n")
|
||||
locations_list.append(self.location_dict)
|
||||
|
||||
fhdhr_list = self.fhdhr.device.cluster.get_list()
|
||||
for location in list(fhdhr_list.keys()):
|
||||
fakefile.write(" <tr>\n")
|
||||
|
||||
if location in list(self.fhdhr.device.cluster.cluster().keys()):
|
||||
location_name = self.fhdhr.device.cluster.cluster()[location]["name"]
|
||||
else:
|
||||
try:
|
||||
location_info_url = location + "/discover.json"
|
||||
locatation_info_req = self.fhdhr.web.session.get(location_info_url)
|
||||
location_info = locatation_info_req.json()
|
||||
location_info_req = self.fhdhr.web.session.get(location_info_url)
|
||||
location_info = location_info_req.json()
|
||||
location_name = location_info["FriendlyName"]
|
||||
except self.fhdhr.web.exceptions.ConnectionError:
|
||||
self.fhdhr.logger.error("Unreachable: " + location)
|
||||
fakefile.write(" <td>%s</td>\n" % (str(location_name)))
|
||||
location_dict = {
|
||||
"name": location_name,
|
||||
"location": location,
|
||||
"joined": str(fhdhr_list[location]["Joined"]),
|
||||
"url_query": urllib.parse.quote(location)
|
||||
}
|
||||
locations_list.append(location_dict)
|
||||
|
||||
fakefile.write(" <td>%s</td>\n" % (str(location)))
|
||||
|
||||
fakefile.write(" <td>%s</td>\n" % (str(fhdhr_list[location]["Joined"])))
|
||||
|
||||
fakefile.write(" <td>\n")
|
||||
fakefile.write(" <div>\n")
|
||||
location_url_query = urllib.parse.quote(location)
|
||||
fakefile.write(
|
||||
" <button onclick=\"OpenLink('%s')\">%s</a></button>\n" %
|
||||
(location, "Visit"))
|
||||
if not fhdhr_list[location]["Joined"]:
|
||||
fakefile.write(
|
||||
" <button onclick=\"OpenLink('%s')\">%s</a></button>\n" %
|
||||
("/api/cluster?method=add&location=" + location_url_query + "&redirect=%2Fcluster", "Add"))
|
||||
else:
|
||||
fakefile.write(
|
||||
" <button onclick=\"OpenLink('%s')\">%s</a></button>\n" %
|
||||
("/api/cluster?method=del&location=" + location_url_query + "&redirect=%2Fcluster", "Remove"))
|
||||
fakefile.write(" </div>\n")
|
||||
fakefile.write(" </td>\n")
|
||||
|
||||
fakefile.write(" </tr>\n")
|
||||
else:
|
||||
fakefile.write("<p style=\"text-align: center;\">Discovery Address must be set for SSDP/Cluster</p>\n")
|
||||
|
||||
for line in page_elements["end"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
return fakefile.getvalue()
|
||||
return render_template('cluster.html', request=request, fhdhr=self.fhdhr, locations_list=locations_list)
|
||||
|
||||
@ -1,27 +1,18 @@
|
||||
from flask import request
|
||||
from io import StringIO
|
||||
from flask import request, render_template
|
||||
|
||||
|
||||
class Diagnostics_HTML():
|
||||
endpoints = ["/diagnostics", "/diagnostics.html"]
|
||||
endpoint_name = "diagnostics"
|
||||
|
||||
def __init__(self, fhdhr, page_elements):
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
self.diagnostics_html = None
|
||||
self.page_elements = page_elements
|
||||
|
||||
def __call__(self, *args):
|
||||
return self.get(*args)
|
||||
|
||||
def get(self, *args):
|
||||
|
||||
fakefile = StringIO()
|
||||
page_elements = self.page_elements.get(request)
|
||||
|
||||
for line in page_elements["top"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
# a list of 2 part lists containing button information
|
||||
button_list = [
|
||||
["debug.json", "/api/debug"],
|
||||
@ -33,15 +24,4 @@ class Diagnostics_HTML():
|
||||
["cluster.json", "/api/cluster?method=get"]
|
||||
]
|
||||
|
||||
for button_item in button_list:
|
||||
button_label = button_item[0]
|
||||
button_path = button_item[1]
|
||||
fakefile.write("<div style=\"text-align: center;\">\n")
|
||||
fakefile.write(" <p><button onclick=\"OpenLink('%s')\">%s</a></button></p>\n" % (button_path, button_label))
|
||||
fakefile.write("</div>\n")
|
||||
fakefile.write("\n")
|
||||
|
||||
for line in page_elements["end"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
return fakefile.getvalue()
|
||||
return render_template('diagnostics.html', request=request, fhdhr=self.fhdhr, button_list=button_list)
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
from flask import request
|
||||
from io import StringIO
|
||||
from flask import request, render_template
|
||||
import datetime
|
||||
|
||||
from fHDHR.tools import humanized_time
|
||||
@ -9,59 +8,33 @@ class Guide_HTML():
|
||||
endpoints = ["/guide", "/guide.html"]
|
||||
endpoint_name = "guide"
|
||||
|
||||
def __init__(self, fhdhr, page_elements):
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
self.page_elements = page_elements
|
||||
|
||||
def __call__(self, *args):
|
||||
return self.get(*args)
|
||||
|
||||
def get(self, *args):
|
||||
|
||||
friendlyname = self.fhdhr.config.dict["fhdhr"]["friendlyname"]
|
||||
|
||||
nowtime = datetime.datetime.utcnow()
|
||||
|
||||
fakefile = StringIO()
|
||||
page_elements = self.page_elements.get(request)
|
||||
|
||||
for line in page_elements["top"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
fakefile.write("<h4 id=\"mcetoc_1cdobsl3g0\" style=\"text-align: center;\"><span style=\"text-decoration: underline;\"><strong><em>What's On %s</em></strong></span></h4>\n" % friendlyname)
|
||||
fakefile.write("\n")
|
||||
|
||||
fakefile.write("<table style=\"width:100%\">\n")
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <th>Play</th>\n")
|
||||
fakefile.write(" <th>Channel Name</th>\n")
|
||||
fakefile.write(" <th>Channel Number</th>\n")
|
||||
fakefile.write(" <th>Channel Thumbnail</th>\n")
|
||||
fakefile.write(" <th>Content Title</th>\n")
|
||||
fakefile.write(" <th>Content Thumbnail</th>\n")
|
||||
fakefile.write(" <th>Content Description</th>\n")
|
||||
fakefile.write(" <th>Content Remaining Time</th>\n")
|
||||
fakefile.write(" </tr>\n")
|
||||
chan_guide_list = []
|
||||
|
||||
for channel in self.fhdhr.device.epg.whats_on_allchans():
|
||||
end_time = datetime.datetime.strptime(channel["listing"][0]["time_end"], '%Y%m%d%H%M%S +0000')
|
||||
remaining_time = humanized_time(int((end_time - nowtime).total_seconds()))
|
||||
play_url = ("/api/m3u?method=get&channel=%s\n" % (channel["number"]))
|
||||
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <td><a href=\"%s\">%s</a>\n" % (play_url, "Play"))
|
||||
fakefile.write(" <td>%s</td>\n" % (channel["name"]))
|
||||
fakefile.write(" <td>%s</td>\n" % (channel["number"]))
|
||||
fakefile.write(" <td><img src=\"%s\" alt=\"%s\" width=\"100\" height=\"100\">\n" % (channel["thumbnail"], channel["name"]))
|
||||
fakefile.write(" <td>%s</td>\n" % (channel["listing"][0]["title"]))
|
||||
fakefile.write(" <td><img src=\"%s\" alt=\"%s\" width=\"100\" height=\"100\">\n" % (channel["listing"][0]["thumbnail"], channel["listing"][0]["title"]))
|
||||
fakefile.write(" <td>%s</td>\n" % (channel["listing"][0]["description"]))
|
||||
fakefile.write(" <td>%s</td>\n" % (str(remaining_time)))
|
||||
fakefile.write(" </tr>\n")
|
||||
chan_dict = {
|
||||
"play_url": play_url,
|
||||
"name": channel["name"],
|
||||
"number": channel["number"],
|
||||
"chan_thumbnail": channel["thumbnail"],
|
||||
"listing_title": channel["listing"][0]["title"],
|
||||
"listing_thumbnail": channel["listing"][0]["thumbnail"],
|
||||
"listing_description": channel["listing"][0]["description"],
|
||||
"remaining_time": str(remaining_time)
|
||||
}
|
||||
chan_guide_list.append(chan_dict)
|
||||
|
||||
for line in page_elements["end"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
channel_guide_html = fakefile.getvalue()
|
||||
|
||||
return channel_guide_html
|
||||
return render_template('guide.html', request=request, fhdhr=self.fhdhr, chan_guide_list=chan_guide_list)
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
|
||||
class HTMLerror():
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
|
||||
def get_html_error(self, message):
|
||||
htmlerror = """<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<h2>{}</h2>
|
||||
</body>
|
||||
</html>"""
|
||||
return htmlerror.format(message)
|
||||
@ -1,55 +1,27 @@
|
||||
from flask import request
|
||||
from io import StringIO
|
||||
from flask import request, render_template
|
||||
|
||||
|
||||
class Index_HTML():
|
||||
endpoints = ["/", "/index.html"]
|
||||
endpoints = ["/", "/index", "/index.html"]
|
||||
endpoint_name = "root"
|
||||
|
||||
def __init__(self, fhdhr, page_elements):
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
self.page_elements = page_elements
|
||||
|
||||
def __call__(self, *args):
|
||||
return self.get(*args)
|
||||
|
||||
def get(self, *args):
|
||||
|
||||
fakefile = StringIO()
|
||||
page_elements = self.page_elements.get(request)
|
||||
|
||||
for line in page_elements["top"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
fakefile.write("<h4 style=\"text-align: center;\">fHDHR Status</h4>")
|
||||
fakefile.write("\n")
|
||||
|
||||
fakefile.write("<table class=\"center\" style=\"width:50%\">\n")
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <th></th>\n")
|
||||
fakefile.write(" <th></th>\n")
|
||||
fakefile.write(" </tr>\n")
|
||||
|
||||
total_channels = self.fhdhr.device.channels.get_station_total()
|
||||
|
||||
tuners_in_use = self.fhdhr.device.tuners.inuse_tuner_count()
|
||||
max_tuners = self.fhdhr.device.tuners.max_tuners
|
||||
|
||||
tableguts = [
|
||||
["Script Directory", str(self.fhdhr.config.dict["filedir"]["script_dir"])],
|
||||
["Config File", str(self.fhdhr.config.config_file)],
|
||||
["Cache Path", str(self.fhdhr.config.dict["filedir"]["cache_dir"])],
|
||||
["Total Channels", str(total_channels)],
|
||||
["Tuner Usage", "%s/%s" % (str(tuners_in_use), str(max_tuners))]
|
||||
]
|
||||
fhdhr_status_dict = {
|
||||
"Script Directory": str(self.fhdhr.config.dict["filedir"]["script_dir"]),
|
||||
"Config File": str(self.fhdhr.config.config_file),
|
||||
"Cache Path": str(self.fhdhr.config.dict["filedir"]["cache_dir"]),
|
||||
"Total Channels": str(self.fhdhr.device.channels.get_station_total()),
|
||||
"Tuner Usage": ("%s/%s" % (str(tuners_in_use), str(max_tuners))),
|
||||
}
|
||||
|
||||
for guts in tableguts:
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <td>%s</td>\n" % (guts[0]))
|
||||
fakefile.write(" <td>%s</td>\n" % (guts[1]))
|
||||
fakefile.write(" </tr>\n")
|
||||
|
||||
for line in page_elements["end"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
return fakefile.getvalue()
|
||||
return render_template('index.html', request=request, fhdhr=self.fhdhr, fhdhr_status_dict=fhdhr_status_dict, list=list)
|
||||
|
||||
@ -1,64 +1,18 @@
|
||||
from flask import request
|
||||
from io import StringIO
|
||||
from flask import request, render_template
|
||||
|
||||
|
||||
class Origin_HTML():
|
||||
endpoints = ["/origin", "/origin.html"]
|
||||
endpoint_name = "origin"
|
||||
|
||||
def __init__(self, fhdhr, page_elements):
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
self.page_elements = page_elements
|
||||
|
||||
def __call__(self, *args):
|
||||
return self.get(*args)
|
||||
|
||||
def get(self, *args):
|
||||
|
||||
servicename = str(self.fhdhr.config.dict["main"]["servicename"])
|
||||
|
||||
fakefile = StringIO()
|
||||
page_elements = self.page_elements.get(request)
|
||||
|
||||
for line in page_elements["top"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
fakefile.write("<h4 style=\"text-align: center;\">%s Status</h4>" % (servicename))
|
||||
fakefile.write("\n")
|
||||
|
||||
# a list of 2 part lists containing button information
|
||||
button_list = [
|
||||
["Force Channel Update", "/api/channels?method=scan&redirect=%2Forigin"],
|
||||
]
|
||||
|
||||
fakefile.write("<div style=\"text-align: center;\">\n")
|
||||
for button_item in button_list:
|
||||
button_label = button_item[0]
|
||||
button_path = button_item[1]
|
||||
fakefile.write(" <p><button onclick=\"OpenLink('%s')\">%s</a></button></p>\n" % (button_path, button_label))
|
||||
fakefile.write("</div>\n")
|
||||
fakefile.write("\n")
|
||||
|
||||
fakefile.write("<table class=\"center\" style=\"width:50%\">\n")
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <th></th>\n")
|
||||
fakefile.write(" <th></th>\n")
|
||||
fakefile.write(" </tr>\n")
|
||||
|
||||
origin_status_dict = self.fhdhr.device.channels.get_origin_status()
|
||||
for key in list(origin_status_dict.keys()):
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <td>%s</td>\n" % (str(key)))
|
||||
fakefile.write(" <td>%s</td>\n" % (str(origin_status_dict[key])))
|
||||
fakefile.write(" </tr>\n")
|
||||
|
||||
total_channels = self.fhdhr.device.channels.get_station_total()
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <td>%s</td>\n" % ("Total Channels"))
|
||||
fakefile.write(" <td>%s</td>\n" % (str(total_channels)))
|
||||
fakefile.write(" </tr>\n")
|
||||
|
||||
for line in page_elements["end"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
return fakefile.getvalue()
|
||||
origin_status_dict["Total Channels"] = str(self.fhdhr.device.channels.get_station_total())
|
||||
return render_template('origin.html', request=request, fhdhr=self.fhdhr, origin_status_dict=origin_status_dict, list=list)
|
||||
|
||||
@ -1,87 +0,0 @@
|
||||
|
||||
|
||||
class fHDHR_Page_Elements():
|
||||
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
self.location = self.fhdhr.device.cluster.location
|
||||
|
||||
def get(self, request):
|
||||
return {"top": self.pagetop(request), "end": self.pageend(request)}
|
||||
|
||||
def pagetop(self, request):
|
||||
friendlyname = self.fhdhr.config.dict["fhdhr"]["friendlyname"]
|
||||
servicename = str(self.fhdhr.config.dict["main"]["servicename"])
|
||||
|
||||
upper_part = [
|
||||
"<!DOCTYPE html>",
|
||||
"<html>",
|
||||
|
||||
"<head>",
|
||||
"<title>%s</title>" % friendlyname,
|
||||
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">",
|
||||
"<style>",
|
||||
"table, th, td {",
|
||||
"border: 1px solid black;",
|
||||
"}",
|
||||
"</style>",
|
||||
"<link href=\"style.css\" rel=\"stylesheet\">",
|
||||
"</head>",
|
||||
"<h1 style=\"text-align: center;\">",
|
||||
"<span style=\"text-decoration: underline;\"><strong><em>%s</em></strong>" % friendlyname,
|
||||
"</span>",
|
||||
"<img class=\"pull-left\" src=\"%s\" alt=\"%s\" width=\"100\" height=\"100\">\n" % ("/favicon.ico", "fHDHR Logo"),
|
||||
"</h1>"
|
||||
"<br><br>",
|
||||
"<h2>"
|
||||
"<div>",
|
||||
|
||||
"<button class=\"pull-left\" onclick=\"OpenLink('%s')\">%s</a></button>" % ("/", "fHDHR"),
|
||||
"<button class=\"pull-left\" onclick=\"OpenLink('%s')\">%s</a></button>" % ("/origin", servicename),
|
||||
"<button class=\"pull-left\" onclick=\"OpenLink('%s')\">%s</a></button>" % ("/guide", "Guide"),
|
||||
"<button class=\"pull-left\" onclick=\"OpenLink('%s')\">%s</a></button>" % ("/cluster", "Cluster"),
|
||||
"<button class=\"pull-left\" onclick=\"OpenLink('%s')\">%s</a></button>" % ("/streams", "Streams"),
|
||||
"<button class=\"pull-left\" onclick=\"OpenLink('%s')\">%s</a></button>" % ("/xmltv", "xmltv"),
|
||||
"<button class=\"pull-left\" onclick=\"OpenLink('%s')\">%s</a></button>" % ("/version", "Version"),
|
||||
"<button class=\"pull-left\" onclick=\"OpenLink('%s')\">%s</a></button>" % ("/diagnostics", "Diagnostics"),
|
||||
|
||||
"<a class=\"pull-right\" style=\"padding: 5px;\" href=\"%s\">%s</a>" % ("/api/xmltv?method=get&source=" + self.fhdhr.device.epg.def_method, "xmltv"),
|
||||
"<a class=\"pull-right\" style=\"padding: 5px;\" href=\"%s\">%s</a>" % ("/api/m3u?method=get&channel=all", "m3u"),
|
||||
|
||||
"</div>",
|
||||
"<hr align=\"center\" width=\"100%\">"
|
||||
]
|
||||
fhdhr_list = self.fhdhr.device.cluster.cluster()
|
||||
locations = []
|
||||
for location in list(fhdhr_list.keys()):
|
||||
item_dict = {
|
||||
"base_url": fhdhr_list[location]["base_url"],
|
||||
"name": fhdhr_list[location]["name"]
|
||||
}
|
||||
if item_dict["base_url"] != self.location:
|
||||
locations.append(item_dict)
|
||||
if len(locations):
|
||||
upper_part.append("<div>")
|
||||
locations = sorted(locations, key=lambda i: i['name'])
|
||||
for location in locations:
|
||||
upper_part.append("<button class=\"pull-left\" onclick=\"OpenLink('%s')\">%s</a></button>" % (location["base_url"], location["name"]))
|
||||
upper_part.append("</div>")
|
||||
upper_part.append("<hr align=\"center\" width=\"100%\">")
|
||||
|
||||
retmessage = request.args.get('retmessage', default=None, type=str)
|
||||
if retmessage:
|
||||
upper_part.append("<p>%s</p>" % retmessage)
|
||||
|
||||
return upper_part
|
||||
|
||||
def pageend(self, request):
|
||||
return [
|
||||
"</html>",
|
||||
"",
|
||||
|
||||
"<script>",
|
||||
"function OpenLink(NewURL) {",
|
||||
" window.open(NewURL, \"_self\");",
|
||||
"}",
|
||||
"</script>"
|
||||
]
|
||||
@ -1,73 +1,30 @@
|
||||
from flask import request
|
||||
from io import StringIO
|
||||
from flask import request, render_template
|
||||
|
||||
|
||||
class Streams_HTML():
|
||||
endpoints = ["/streams", "/streams.html"]
|
||||
endpoint_name = "streams"
|
||||
|
||||
def __init__(self, fhdhr, page_elements):
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
self.page_elements = page_elements
|
||||
|
||||
def __call__(self, *args):
|
||||
return self.get(*args)
|
||||
|
||||
def get(self, *args):
|
||||
|
||||
fakefile = StringIO()
|
||||
page_elements = self.page_elements.get(request)
|
||||
|
||||
for line in page_elements["top"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
fakefile.write("<h4 style=\"text-align: center;\">fHDHR Streams</h4>")
|
||||
fakefile.write("\n")
|
||||
|
||||
fakefile.write("<table style=\"width:100%\">\n")
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <th>Tuner</th>\n")
|
||||
fakefile.write(" <th>Status</th>\n")
|
||||
fakefile.write(" <th>Channel</th>\n")
|
||||
fakefile.write(" <th>Method</th>\n")
|
||||
fakefile.write(" <th>Time Active</th>\n")
|
||||
fakefile.write(" <th>Options</th>\n")
|
||||
fakefile.write(" </tr>\n")
|
||||
|
||||
tuner_list = []
|
||||
tuner_status = self.fhdhr.device.tuners.status()
|
||||
for tuner in list(tuner_status.keys()):
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <td>%s</td>\n" % (str(tuner)))
|
||||
fakefile.write(" <td>%s</td>\n" % (str(tuner_status[tuner]["status"])))
|
||||
tuner_dict = {
|
||||
"number": str(tuner),
|
||||
"status": str(tuner_status[tuner]["status"]),
|
||||
}
|
||||
if tuner_status[tuner]["status"] == "Active":
|
||||
try:
|
||||
channel_name = tuner_status[tuner]["epg"]["name"]
|
||||
channel_number = tuner_status[tuner]["epg"]["number"]
|
||||
channel_thumbnail = tuner_status[tuner]["epg"]["thumbnail"]
|
||||
fakefile.write(" <td>%s<img src=\"%s\" alt=\"%s\" width=\"100\" height=\"100\">%s</td>\n" % (
|
||||
channel_name, channel_thumbnail, channel_name, str(channel_number)))
|
||||
except TypeError:
|
||||
fakefile.write(" <td>%s</td>\n" % (str(tuner_status[tuner]["channel"])))
|
||||
fakefile.write(" <td>%s</td>\n" % (str(tuner_status[tuner]["method"])))
|
||||
fakefile.write(" <td>%s</td>\n" % (str(tuner_status[tuner]["Play Time"])))
|
||||
else:
|
||||
fakefile.write(" <td>%s</td>\n" % "N/A")
|
||||
fakefile.write(" <td>%s</td>\n" % "N/A")
|
||||
fakefile.write(" <td>%s</td>\n" % "N/A")
|
||||
tuner_dict["channel_number"] = tuner_status[tuner]["channel"]
|
||||
tuner_dict["method"] = tuner_status[tuner]["method"]
|
||||
tuner_dict["play_duration"] = str(tuner_status[tuner]["Play Time"])
|
||||
|
||||
fakefile.write(" <td>\n")
|
||||
fakefile.write(" <div>\n")
|
||||
tuner_list.append(tuner_dict)
|
||||
|
||||
if tuner_status[tuner]["status"] in ["Active", "Acquired"]:
|
||||
fakefile.write(
|
||||
" <button onclick=\"OpenLink('%s')\">%s</a></button>\n" %
|
||||
("/api/watch?method=close&tuner=" + str(tuner) + "&redirect=%2Fstreams", "Close"))
|
||||
fakefile.write(" </div>\n")
|
||||
fakefile.write(" </td>\n")
|
||||
|
||||
fakefile.write(" </tr>\n")
|
||||
|
||||
for line in page_elements["end"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
return fakefile.getvalue()
|
||||
return render_template('streams.html', request=request, fhdhr=self.fhdhr, tuner_list=tuner_list)
|
||||
|
||||
@ -1,52 +1,25 @@
|
||||
import sys
|
||||
from flask import request
|
||||
from io import StringIO
|
||||
from flask import request, render_template
|
||||
|
||||
|
||||
class Version_HTML():
|
||||
endpoints = ["/version", "/version.html"]
|
||||
endpoint_name = "version"
|
||||
|
||||
def __init__(self, fhdhr, page_elements):
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
self.page_elements = page_elements
|
||||
|
||||
def __call__(self, *args):
|
||||
return self.get(*args)
|
||||
|
||||
def get(self, *args):
|
||||
|
||||
fakefile = StringIO()
|
||||
page_elements = self.page_elements.get(request)
|
||||
|
||||
for line in page_elements["top"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
fakefile.write("<h4 style=\"text-align: center;\">fHDHR Version Information</h4>")
|
||||
fakefile.write("\n")
|
||||
|
||||
fakefile.write("<table class=\"center\" style=\"width:50%\">\n")
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <th></th>\n")
|
||||
fakefile.write(" <th></th>\n")
|
||||
fakefile.write(" </tr>\n")
|
||||
|
||||
table_guts = [
|
||||
["fHDHR", self.fhdhr.version],
|
||||
["Python", sys.version],
|
||||
["Operating System", self.fhdhr.config.dict["main"]["opersystem"]],
|
||||
["Using Docker", self.fhdhr.config.dict["main"]["isdocker"]],
|
||||
["ffmpeg", self.fhdhr.config.dict["ffmpeg"]["version"]],
|
||||
["vlc", self.fhdhr.config.dict["vlc"]["version"]]
|
||||
]
|
||||
|
||||
for item in table_guts:
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <td>%s</td>\n" % (str(item[0])))
|
||||
fakefile.write(" <td>%s</td>\n" % (str(item[1])))
|
||||
fakefile.write(" </tr>\n")
|
||||
|
||||
for line in page_elements["end"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
return fakefile.getvalue()
|
||||
version_dict = {
|
||||
"fHDHR": self.fhdhr.version,
|
||||
"Python": sys.version,
|
||||
"Operating System": self.fhdhr.config.dict["main"]["opersystem"],
|
||||
"Using Docker": self.fhdhr.config.dict["main"]["isdocker"],
|
||||
"ffmpeg": self.fhdhr.config.dict["ffmpeg"]["version"],
|
||||
"vlc": self.fhdhr.config.dict["vlc"]["version"],
|
||||
}
|
||||
return render_template('version.html', request=request, fhdhr=self.fhdhr, version_dict=version_dict, list=list)
|
||||
|
||||
@ -1,61 +1,16 @@
|
||||
from flask import request
|
||||
from io import StringIO
|
||||
from flask import request, render_template
|
||||
|
||||
|
||||
class xmlTV_HTML():
|
||||
endpoints = ["/xmltv"]
|
||||
endpoints = ["/xmltv", "/xmltv.html"]
|
||||
endpoint_name = "xmltv"
|
||||
|
||||
def __init__(self, fhdhr, page_elements):
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
self.page_elements = page_elements
|
||||
|
||||
def __call__(self, *args):
|
||||
return self.get(*args)
|
||||
|
||||
def get(self, *args):
|
||||
|
||||
fakefile = StringIO()
|
||||
page_elements = self.page_elements.get(request)
|
||||
|
||||
for line in page_elements["top"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
fakefile.write("<h4 style=\"text-align: center;\">fHDHR xmltv Options</h4>")
|
||||
fakefile.write("\n")
|
||||
|
||||
fakefile.write("<table class=\"center\" style=\"width:50%\">\n")
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <th>Version</th>\n")
|
||||
fakefile.write(" <th>XMLTV Link</th>\n")
|
||||
fakefile.write(" <th>EPG Link</th>\n")
|
||||
fakefile.write(" <th>Options</th>\n")
|
||||
fakefile.write(" </tr>\n")
|
||||
|
||||
for epg_method in self.fhdhr.config.dict["main"]["valid_epg_methods"]:
|
||||
if epg_method not in [None, "None"]:
|
||||
epg_method_name = epg_method
|
||||
if epg_method == "origin":
|
||||
epg_method_name = self.fhdhr.config.dict["main"]["dictpopname"]
|
||||
fakefile.write(" <tr>\n")
|
||||
fakefile.write(" <td>%s</td>\n" % (epg_method_name))
|
||||
fakefile.write(" <td><a href=\"%s\">%s</a>\n" % ("/api/xmltv?method=get&source=" + epg_method, epg_method_name))
|
||||
fakefile.write(" <td><a href=\"%s\">%s</a>\n" % ("/api/epg?method=get&source=" + epg_method, epg_method_name))
|
||||
|
||||
fakefile.write(" <td>\n")
|
||||
fakefile.write(" <div>\n")
|
||||
fakefile.write(
|
||||
" <button onclick=\"OpenLink('%s')\">%s</a></button>\n" %
|
||||
("/api/xmltv?method=update&source=" + epg_method + "&redirect=%2Fxmltv", "Update"))
|
||||
fakefile.write(
|
||||
" <button onclick=\"OpenLink('%s')\">%s</a></button>\n" %
|
||||
("/api/xmltv?method=clearcache&source=" + epg_method + "&redirect=%2Fxmltv", "Clear Cache"))
|
||||
fakefile.write(" </div>\n")
|
||||
fakefile.write(" </td>\n")
|
||||
|
||||
fakefile.write(" </tr>\n")
|
||||
|
||||
for line in page_elements["end"]:
|
||||
fakefile.write(line + "\n")
|
||||
|
||||
return fakefile.getvalue()
|
||||
return render_template('xmltv.html', request=request, fhdhr=self.fhdhr)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user