mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 11:16:58 -05:00
commit
6deaabe56a
@ -61,7 +61,12 @@
|
|||||||
"value": false,
|
"value": false,
|
||||||
"config_file": true,
|
"config_file": true,
|
||||||
"config_web": true
|
"config_web": true
|
||||||
}
|
},
|
||||||
|
"chanscan_on_start":{
|
||||||
|
"value": true,
|
||||||
|
"config_file": true,
|
||||||
|
"config_web": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"epg":{
|
"epg":{
|
||||||
"images":{
|
"images":{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h4 style="text-align: center;">What's On {{ fhdhr.config.dict["fhdhr"]["friendlyname"] }}</h4>
|
<h4 style="text-align: center;">{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels</h4>
|
||||||
|
|
||||||
<table class="center" style="width:100%">
|
<table class="center" style="width:100%">
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
import time
|
||||||
|
|
||||||
from fHDHR.tools import hours_between_datetime
|
from fHDHR.tools import hours_between_datetime
|
||||||
|
|
||||||
@ -19,7 +20,9 @@ class Channels():
|
|||||||
self.list_update_time = None
|
self.list_update_time = None
|
||||||
|
|
||||||
self.get_db_channels()
|
self.get_db_channels()
|
||||||
self.get_channels()
|
haseverscanned = self.fhdhr.db.get_fhdhr_value("channels", "scanned_time")
|
||||||
|
if (self.fhdhr.config.dict["fhdhr"]["chanscan_on_start"] or not haseverscanned):
|
||||||
|
self.get_channels()
|
||||||
|
|
||||||
def get_channel_obj(self, keyfind, valfind):
|
def get_channel_obj(self, keyfind, valfind):
|
||||||
return next(self.list[fhdhr_id] for fhdhr_id in list(self.list.keys()) if self.list[fhdhr_id].dict[keyfind] == valfind)
|
return next(self.list[fhdhr_id] for fhdhr_id in list(self.list.keys()) if self.list[fhdhr_id].dict[keyfind] == valfind)
|
||||||
@ -68,6 +71,7 @@ class Channels():
|
|||||||
if not self.list_update_time:
|
if not self.list_update_time:
|
||||||
self.fhdhr.logger.info("Found " + str(len(self.list)) + " channels for " + str(self.fhdhr.config.dict["main"]["servicename"]))
|
self.fhdhr.logger.info("Found " + str(len(self.list)) + " channels for " + str(self.fhdhr.config.dict["main"]["servicename"]))
|
||||||
self.list_update_time = datetime.datetime.now()
|
self.list_update_time = datetime.datetime.now()
|
||||||
|
self.fhdhr.db.set_fhdhr_value("channels", "scanned_time", time.time())
|
||||||
|
|
||||||
channel_list = []
|
channel_list = []
|
||||||
for chan_obj in list(self.list.keys()):
|
for chan_obj in list(self.list.keys()):
|
||||||
|
|||||||
@ -12,9 +12,19 @@ class Channel():
|
|||||||
channel_id = id_system.get(origin_id)
|
channel_id = id_system.get(origin_id)
|
||||||
else:
|
else:
|
||||||
channel_id = id_system.assign()
|
channel_id = id_system.assign()
|
||||||
self.dict = self.fhdhr.db.get_channel_value(str(channel_id), "dict") or self.create_empty_channel(channel_id)
|
self.dict = self.fhdhr.db.get_channel_value(str(channel_id), "dict") or self.default_dict(channel_id)
|
||||||
|
self.verify_dict()
|
||||||
self.fhdhr.db.set_channel_value(self.dict["id"], "dict", self.dict)
|
self.fhdhr.db.set_channel_value(self.dict["id"], "dict", self.dict)
|
||||||
|
|
||||||
|
def verify_dict(self):
|
||||||
|
"""Development Purposes
|
||||||
|
Add new Channel dict keys
|
||||||
|
"""
|
||||||
|
default_dict = self.default_dict(self.dict["id"])
|
||||||
|
for key in list(default_dict.keys()):
|
||||||
|
if key not in list(self.dict.keys()):
|
||||||
|
self.dict[key] = default_dict[key]
|
||||||
|
|
||||||
def basics(self, channel_info):
|
def basics(self, channel_info):
|
||||||
"""Some Channel Information is Critical"""
|
"""Some Channel Information is Critical"""
|
||||||
|
|
||||||
@ -46,16 +56,23 @@ class Channel():
|
|||||||
if not self.dict["number"]:
|
if not self.dict["number"]:
|
||||||
self.dict["number"] = self.dict["origin_number"]
|
self.dict["number"] = self.dict["origin_number"]
|
||||||
|
|
||||||
|
if "thumbnail" not in list(channel_info.keys()):
|
||||||
|
channel_info["thumbnail"] = None
|
||||||
|
self.dict["origin_thumbnail"] = channel_info["thumbnail"]
|
||||||
|
if not self.dict["thumbnail"]:
|
||||||
|
self.dict["thumbnail"] = self.dict["origin_thumbnail"]
|
||||||
|
|
||||||
self.fhdhr.db.set_channel_value(self.dict["id"], "dict", self.dict)
|
self.fhdhr.db.set_channel_value(self.dict["id"], "dict", self.dict)
|
||||||
|
|
||||||
def create_empty_channel(self, channel_id):
|
def default_dict(self, channel_id):
|
||||||
return {
|
return {
|
||||||
"id": str(channel_id), "origin_id": None,
|
"id": str(channel_id), "origin_id": None,
|
||||||
"name": None, "origin_name": None,
|
"name": None, "origin_name": None,
|
||||||
"callsign": None, "origin_callsign": None,
|
"callsign": None, "origin_callsign": None,
|
||||||
"number": None, "origin_number": None,
|
"number": None, "origin_number": None,
|
||||||
"tags": [], "origin_tags": [],
|
"tags": [], "origin_tags": [],
|
||||||
"enabled": True
|
"enabled": True,
|
||||||
|
"thumbnail": None, "origin_thumbnail": None
|
||||||
}
|
}
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
@ -67,6 +84,8 @@ class Channel():
|
|||||||
|
|
||||||
def set_status(self, updatedict):
|
def set_status(self, updatedict):
|
||||||
for key in list(updatedict.keys()):
|
for key in list(updatedict.keys()):
|
||||||
|
if key == "number":
|
||||||
|
updatedict[key] = str(float(updatedict[key]))
|
||||||
self.dict[key] = updatedict[key]
|
self.dict[key] = updatedict[key]
|
||||||
self.fhdhr.db.set_channel_value(self.dict["id"], "dict", self.dict)
|
self.fhdhr.db.set_channel_value(self.dict["id"], "dict", self.dict)
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,9 @@ class blocksEPG():
|
|||||||
}
|
}
|
||||||
timestamps.append(timestampdict)
|
timestamps.append(timestampdict)
|
||||||
|
|
||||||
for c in self.channels.get_channels():
|
for fhdhr_id in list(self.channels.list.keys()):
|
||||||
|
c = self.channels.list[fhdhr_id].dict
|
||||||
|
|
||||||
if str(c["number"]) not in list(programguide.keys()):
|
if str(c["number"]) not in list(programguide.keys()):
|
||||||
programguide[str(c["number"])] = {
|
programguide[str(c["number"])] = {
|
||||||
"callsign": c["callsign"],
|
"callsign": c["callsign"],
|
||||||
|
|||||||
@ -96,14 +96,14 @@ class Direct_Stream():
|
|||||||
self.fhdhr.logger.info("Loaded %s segments." % str(len(segments)))
|
self.fhdhr.logger.info("Loaded %s segments." % str(len(segments)))
|
||||||
|
|
||||||
if playlist.keys != [None]:
|
if playlist.keys != [None]:
|
||||||
keys = [{"url": key.uri, "method": key.method, "iv": key.iv} for key in playlist.keys if key]
|
keys = [{"url": key.absolute_uri, "method": key.method, "iv": key.iv} for key in playlist.keys if key]
|
||||||
else:
|
else:
|
||||||
keys = [None for i in range(0, len(segments))]
|
keys = [None for i in range(0, len(segments))]
|
||||||
|
|
||||||
for segment, key in zip(segments, keys):
|
for segment, key in zip(segments, keys):
|
||||||
chunkurl = segment.absolute_uri
|
chunkurl = segment.absolute_uri
|
||||||
|
|
||||||
if chunkurl not in played_chunk_urls:
|
if chunkurl and chunkurl not in played_chunk_urls:
|
||||||
played_chunk_urls.append(chunkurl)
|
played_chunk_urls.append(chunkurl)
|
||||||
|
|
||||||
if (not self.stream_args["duration"] == 0 and
|
if (not self.stream_args["duration"] == 0 and
|
||||||
@ -116,9 +116,10 @@ class Direct_Stream():
|
|||||||
break
|
break
|
||||||
# raise TunerError("807 - No Video Data")
|
# raise TunerError("807 - No Video Data")
|
||||||
if key:
|
if key:
|
||||||
keyfile = self.fhdhr.web.session.get(key["url"]).content
|
if key["url"]:
|
||||||
cryptor = AES.new(keyfile, AES.MODE_CBC, keyfile)
|
keyfile = self.fhdhr.web.session.get(key["url"]).content
|
||||||
chunk = cryptor.decrypt(chunk)
|
cryptor = AES.new(keyfile, AES.MODE_CBC, keyfile)
|
||||||
|
chunk = cryptor.decrypt(chunk)
|
||||||
|
|
||||||
self.fhdhr.logger.info("Passing Through Chunk: %s" % chunkurl)
|
self.fhdhr.logger.info("Passing Through Chunk: %s" % chunkurl)
|
||||||
yield chunk
|
yield chunk
|
||||||
|
|||||||
@ -46,7 +46,7 @@ class M3U():
|
|||||||
channel_obj = self.fhdhr.device.channels.list[fhdhr_id]
|
channel_obj = self.fhdhr.device.channels.list[fhdhr_id]
|
||||||
if channel_obj.enabled:
|
if channel_obj.enabled:
|
||||||
channel_items.append(channel_obj)
|
channel_items.append(channel_obj)
|
||||||
elif channel in self.fhdhr.device.channels.get_channel_list("number"):
|
elif str(channel) in [str(x) for x in self.fhdhr.device.channels.get_channel_list("number")]:
|
||||||
channel_obj = self.fhdhr.device.channels.get_channel_obj("number", channel)
|
channel_obj = self.fhdhr.device.channels.get_channel_obj("number", channel)
|
||||||
fileName = str(channel_obj.number) + ".m3u"
|
fileName = str(channel_obj.number) + ".m3u"
|
||||||
if channel_obj.enabled:
|
if channel_obj.enabled:
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class Watch():
|
|||||||
if not channel_number:
|
if not channel_number:
|
||||||
return "Missing Channel"
|
return "Missing Channel"
|
||||||
|
|
||||||
if channel_number not in self.fhdhr.device.channels.get_channel_list("number"):
|
if str(channel_number) not in [str(x) for x in self.fhdhr.device.channels.get_channel_list("number")]:
|
||||||
response = Response("Not Found", status=404)
|
response = Response("Not Found", status=404)
|
||||||
response.headers["X-fHDHR-Error"] = "801 - Unknown Channel"
|
response.headers["X-fHDHR-Error"] = "801 - Unknown Channel"
|
||||||
self.fhdhr.logger.error(response.headers["X-fHDHR-Error"])
|
self.fhdhr.logger.error(response.headers["X-fHDHR-Error"])
|
||||||
|
|||||||
@ -8,6 +8,15 @@ class OriginChannels():
|
|||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
self.origin = origin
|
self.origin = origin
|
||||||
|
|
||||||
|
def get_channel_thumbnail(self, channel_id):
|
||||||
|
channel_thumb_url = ("%s%s:%s/service?method=channel.icon&channel_id=%s" %
|
||||||
|
("https://" if self.fhdhr.config.dict["origin"]["ssl"] else "http://",
|
||||||
|
self.fhdhr.config.dict["origin"]["address"],
|
||||||
|
str(self.fhdhr.config.dict["origin"]["port"]),
|
||||||
|
str(channel_id)
|
||||||
|
))
|
||||||
|
return channel_thumb_url
|
||||||
|
|
||||||
def get_channels(self):
|
def get_channels(self):
|
||||||
|
|
||||||
data_url = ('%s%s:%s/service?method=channel.list&sid=%s' %
|
data_url = ('%s%s:%s/service?method=channel.list&sid=%s' %
|
||||||
@ -36,6 +45,7 @@ class OriginChannels():
|
|||||||
"callsign": channel_dict["name"],
|
"callsign": channel_dict["name"],
|
||||||
"number": channel_dict["formatted-number"],
|
"number": channel_dict["formatted-number"],
|
||||||
"id": channel_dict["id"],
|
"id": channel_dict["id"],
|
||||||
|
"thumbnail": self.get_channel_thumbnail(channel_dict["id"])
|
||||||
}
|
}
|
||||||
channel_list.append(clean_station_item)
|
channel_list.append(clean_station_item)
|
||||||
return channel_list
|
return channel_list
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user