diff --git a/origin/origin_channels.py b/origin/origin_channels.py index 12a83f2..91a9d76 100644 --- a/origin/origin_channels.py +++ b/origin/origin_channels.py @@ -11,10 +11,6 @@ class OriginChannels(): self.base_api_url = "https://ott-gateway-stirr.sinclairstoryline.com/api/rest/v3" self.base_station_url = "https://ott-stationselection.sinclairstoryline.com/stationSelectionByAllStates" - "https://ott-gateway-stirr.sinclairstoryline.com/api/rest/v3/channels/stirr?station=abc3340" - - "https://ott-gateway-stirr.sinclairstoryline.com/api/rest/v3/status/40b80f75-2efc-49af-813b-2a674e69ea59" - def get_channels(self): channel_list = [] diff --git a/origin/origin_epg.py b/origin/origin_epg.py index 18f4068..a9f5ed1 100644 --- a/origin/origin_epg.py +++ b/origin/origin_epg.py @@ -1,3 +1,4 @@ +import datetime class OriginEPG(): @@ -20,13 +21,16 @@ class OriginEPG(): epg_json = epg_opn.json() for listing in epg_json["channel"][0]["programme"]: + + timestampdict = self.stirr_time_convert(listing["start"], listing["stop"]) + clean_prog_dict = { - "time_start": None, - "time_end": None, - "duration_minutes": None, - "title": "Unavailable", + "time_start": timestampdict["start"], + "time_end": timestampdict["end"], + "duration_minutes": timestampdict["duration"], + "title": listing["title"]["value"], "sub-title": "Unavailable", - "description": "Unavailable", + "description": listing["desc"]["value"], "rating": "N/A", "episodetitle": None, "releaseyear": None, @@ -34,7 +38,7 @@ class OriginEPG(): "seasonnumber": None, "episodenumber": None, "isnew": False, - "id": None, + "id": "%s_%s" % (chan_obj.dict["origin_id"], timestampdict['time_start']), "thumbnail": None } @@ -42,3 +46,9 @@ class OriginEPG(): programguide[str(chan_obj.number)]["listing"].append(clean_prog_dict) return programguide + + def stirr_time_convert(self, starttime, endtime): + starttime = datetime.datetime.strptime(str(starttime), "%Y%m%d%H%M%S").timestamp() + endtime = datetime.datetime.strptime(str(endtime), "%Y%m%d%H%M%S").timestamp() + duration = (endtime - starttime) / 60 + return {"start": starttime, "end": endtime, "duration": duration}