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

Add Channel Thumbnail Attribute

This commit is contained in:
deathbybandaid 2020-11-28 19:03:54 -05:00
parent 3b766f380e
commit 283aee262f
2 changed files with 30 additions and 3 deletions

View File

@ -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):

View File

@ -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