45 lines
1.9 KiB
Python
45 lines
1.9 KiB
Python
|
|
|
|
class OriginEPG():
|
|
|
|
def __init__(self, fhdhr):
|
|
self.fhdhr = fhdhr
|
|
|
|
self.base_epg_url = "https://ott-gateway-stirr.sinclairstoryline.com/api/rest/v3/program/stirr/ott/"
|
|
|
|
def update_epg(self, fhdhr_channels):
|
|
programguide = {}
|
|
|
|
for fhdhr_id in list(fhdhr_channels.list.keys()):
|
|
chan_obj = fhdhr_channels.list[fhdhr_id]
|
|
|
|
if str(chan_obj.number) not in list(programguide.keys()):
|
|
programguide[str(chan_obj.number)] = chan_obj.epgdict
|
|
|
|
epg_opn = self.fhdhr.web.session.get(self.base_epg_url + str(chan_obj.dict["origin_id"]))
|
|
epg_json = epg_opn.json()
|
|
|
|
for listing in epg_json["channel"][0]["programme"]:
|
|
clean_prog_dict = {
|
|
"time_start": None,
|
|
"time_end": None,
|
|
"duration_minutes": None,
|
|
"title": "Unavailable",
|
|
"sub-title": "Unavailable",
|
|
"description": "Unavailable",
|
|
"rating": "N/A",
|
|
"episodetitle": None,
|
|
"releaseyear": None,
|
|
"genres": [],
|
|
"seasonnumber": None,
|
|
"episodenumber": None,
|
|
"isnew": False,
|
|
"id": None,
|
|
"thumbnail": None
|
|
}
|
|
|
|
if not any((d['time_start'] == clean_prog_dict['time_start'] and d['id'] == clean_prog_dict['id']) for d in programguide[chan_obj.number]["listing"]):
|
|
programguide[str(chan_obj.number)]["listing"].append(clean_prog_dict)
|
|
|
|
return programguide
|