From aa3ced07d11c04f169a6c2b540ecb73656ef7e68 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 5 Dec 2020 14:32:05 -0500 Subject: [PATCH] test --- fHDHR/origin/origin_epg.py | 51 +++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/fHDHR/origin/origin_epg.py b/fHDHR/origin/origin_epg.py index 45c4fa9..225606c 100644 --- a/fHDHR/origin/origin_epg.py +++ b/fHDHR/origin/origin_epg.py @@ -59,26 +59,32 @@ class OriginEPG(): elif c["origin_id"] in ["snick-est", "snick-pst"]: schedule_name = "Snickelodeon" schedulename_quote = urllib.parse.quote("%s EST" % schedule_name) + epgguide = [] for datestring in datestrings: schedule_url = ("%s?scheduleName=%s" "&dateString=%s" "&count=150" % (self.media_url, schedulename_quote, datestring)) - epgguide = self.get_cached(epgname, todaydate, schedule_url) + epgguide.extend(self.get_cached(epgname, todaydate, schedule_url)) - progindex = 0 - for program_dict in epgguide: + progindex = 0 + for program_dict in epgguide: - epgguide[progindex + 1] + try: + nextprog_dict = epgguide[progindex + 1] + except IndexError: + nextprog_dict = None + if nextprog_dict: + + timedict = self.get_prog_timedict(program_dict["startDate"], nextprog_dict["startDate"]) - """ clean_prog_dict = { - "time_start": timestamp['time_start'], - "time_end": timestamp['time_end'], - "duration_minutes": 60, - "thumbnail": ("/api/images?method=generate&type=content&message=%s" % (str(c["origin_id"]) + "_" + str(timestamp['time_start']).split(" ")[0])), - "title": "Unavailable", - "sub-title": "Unavailable", + "time_start": timedict['time_start'], + "time_end": timedict['time_end'], + "duration_minutes": timedict["duration"], + "thumbnail": program_dict["info"]["image"], + "title": program_dict["info"]["fullname"], + "sub-title": program_dict["name"], "description": "Unavailable", "rating": "N/A", "episodetitle": None, @@ -87,11 +93,11 @@ class OriginEPG(): "seasonnumber": None, "episodenumber": None, "isnew": False, - "id": str(c["origin_id"]) + "_" + str(timestamp['time_start']).split(" ")[0], + "id": str(c["origin_id"]) + "_" + str(timedict['time_start']).split(" ")[0], } programguide[str(c["number"])]["listing"].append(clean_prog_dict) - """ - progindex += 1 + + progindex += 1 else: @@ -118,6 +124,23 @@ class OriginEPG(): return programguide + def xmltimestamp_toonami(self, inputtime): + xmltime = inputtime.replace('Z', '+00:00') + xmltime = datetime.datetime.fromisoformat(xmltime) + xmltime = xmltime.strftime('%Y%m%d%H%M%S %z') + return xmltime + + def get_prog_timedict(self, starttime, endtime): + "2020-12-05T00:01:00.098Z" + "2020-11-22T00:00:00.000Z" + print(self.xmltimestamp_toonami(starttime)) + timedict = { + "time_start": None, + "time_end": None, + "duration": None + } + return timedict + def get_cached(self, jsonid, cache_key, url): cacheitem = self.fhdhr.db.get_cacheitem_value(jsonid + "_" + str(cache_key), "offline_cache", "origin") if cacheitem: