1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 10:16:58 -05:00

Merge pull request #63 from deathbybandaid/dev

Dev
This commit is contained in:
Deathbybandaid 2020-11-29 12:01:54 -05:00 committed by GitHub
commit 6deaabe56a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 55 additions and 14 deletions

View File

@ -61,7 +61,12 @@
"value": false,
"config_file": true,
"config_web": true
}
},
"chanscan_on_start":{
"value": true,
"config_file": true,
"config_web": true
}
},
"epg":{
"images":{

View File

@ -2,7 +2,7 @@
{% 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%">
<tr>

View File

@ -1,4 +1,5 @@
import datetime
import time
from fHDHR.tools import hours_between_datetime
@ -19,7 +20,9 @@ class Channels():
self.list_update_time = None
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):
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:
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.fhdhr.db.set_fhdhr_value("channels", "scanned_time", time.time())
channel_list = []
for chan_obj in list(self.list.keys()):

View File

@ -12,9 +12,19 @@ class Channel():
channel_id = id_system.get(origin_id)
else:
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)
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):
"""Some Channel Information is Critical"""
@ -46,16 +56,23 @@ class Channel():
if not self.dict["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)
def create_empty_channel(self, channel_id):
def default_dict(self, channel_id):
return {
"id": str(channel_id), "origin_id": None,
"name": None, "origin_name": None,
"callsign": None, "origin_callsign": None,
"number": None, "origin_number": None,
"tags": [], "origin_tags": [],
"enabled": True
"enabled": True,
"thumbnail": None, "origin_thumbnail": None
}
def destroy(self):
@ -67,6 +84,8 @@ class Channel():
def set_status(self, updatedict):
for key in list(updatedict.keys()):
if key == "number":
updatedict[key] = str(float(updatedict[key]))
self.dict[key] = updatedict[key]
self.fhdhr.db.set_channel_value(self.dict["id"], "dict", self.dict)

View File

@ -29,7 +29,9 @@ class blocksEPG():
}
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()):
programguide[str(c["number"])] = {
"callsign": c["callsign"],

View File

@ -96,14 +96,14 @@ class Direct_Stream():
self.fhdhr.logger.info("Loaded %s segments." % str(len(segments)))
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:
keys = [None for i in range(0, len(segments))]
for segment, key in zip(segments, keys):
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)
if (not self.stream_args["duration"] == 0 and
@ -116,9 +116,10 @@ class Direct_Stream():
break
# raise TunerError("807 - No Video Data")
if key:
keyfile = self.fhdhr.web.session.get(key["url"]).content
cryptor = AES.new(keyfile, AES.MODE_CBC, keyfile)
chunk = cryptor.decrypt(chunk)
if key["url"]:
keyfile = self.fhdhr.web.session.get(key["url"]).content
cryptor = AES.new(keyfile, AES.MODE_CBC, keyfile)
chunk = cryptor.decrypt(chunk)
self.fhdhr.logger.info("Passing Through Chunk: %s" % chunkurl)
yield chunk

View File

@ -46,7 +46,7 @@ class M3U():
channel_obj = self.fhdhr.device.channels.list[fhdhr_id]
if channel_obj.enabled:
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)
fileName = str(channel_obj.number) + ".m3u"
if channel_obj.enabled:

View File

@ -34,7 +34,7 @@ class Watch():
if not channel_number:
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.headers["X-fHDHR-Error"] = "801 - Unknown Channel"
self.fhdhr.logger.error(response.headers["X-fHDHR-Error"])

View File

@ -8,6 +8,15 @@ class OriginChannels():
self.fhdhr = fhdhr
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):
data_url = ('%s%s:%s/service?method=channel.list&sid=%s' %
@ -36,6 +45,7 @@ class OriginChannels():
"callsign": channel_dict["name"],
"number": channel_dict["formatted-number"],
"id": channel_dict["id"],
"thumbnail": self.get_channel_thumbnail(channel_dict["id"])
}
channel_list.append(clean_station_item)
return channel_list