This commit is contained in:
deathbybandaid 2020-12-15 15:53:56 -05:00
parent d5363522c2
commit 2d5ca0d90d

View File

@ -18,6 +18,10 @@ class OriginChannels():
def get_channels(self): def get_channels(self):
channel_list = []
channel_ids = []
station_locations = ["national", "abc3340"] station_locations = ["national", "abc3340"]
station_by_state_opn = self.fhdhr.web.session.get(self.base_station_url) station_by_state_opn = self.fhdhr.web.session.get(self.base_station_url)
@ -30,36 +34,38 @@ class OriginChannels():
state_url_req = self.fhdhr.web.session.get(state_url) state_url_req = self.fhdhr.web.session.get(state_url)
state_url_json = state_url_req.json() state_url_json = state_url_req.json()
for item in state_url_json["rss"]["channel"]["pagecomponent"]["component"]: for item in state_url_json["rss"]["channel"]["pagecomponent"]["component"]:
print(item["item"]["media:content"]['sinclair:action_value']) stationitem = item["item"]["media:content"]['sinclair:action_value']
return [] if stationitem not in station_locations:
station_locations.append(stationitem)
chan_list_url = "%s/channels/stirr?station=national" % (self.base_api_url) for station_item in station_locations:
chan_list_urlopn = self.fhdhr.web.session.get(chan_list_url)
stirr_chan_list = chan_list_urlopn.json()
channel_list = [] chan_list_url = "%s/channels/stirr?station=%s" % (self.base_api_url, station_item)
# chanindex = 0 chan_list_urlopn = self.fhdhr.web.session.get(chan_list_url)
for channel_dict in stirr_chan_list["channel"]: stirr_chan_list = chan_list_urlopn.json()
# chanindex += 1 for channel_dict in stirr_chan_list["channel"]:
chan_item_url = "%s/status/%s" % (self.base_api_url, str(channel_dict["id"])) if str(channel_dict["id"]) not in channel_ids:
chan_item_urlopn = self.fhdhr.web.session.get(chan_item_url)
stirr_chan_item = chan_item_urlopn.json()
try: chan_item_url = "%s/status/%s" % (self.base_api_url, str(channel_dict["id"]))
thumbnail = channel_dict["icon"]["src"].split("?")[0] chan_item_urlopn = self.fhdhr.web.session.get(chan_item_url)
except TypeError: stirr_chan_item = chan_item_urlopn.json()
thumbnail = None
clean_station_item = { channel_ids.append(str(channel_dict["id"]))
"name": stirr_chan_item['rss']["channel"]["title"],
"callsign": channel_dict["display-name"], try:
# "number": chanindex, thumbnail = channel_dict["icon"]["src"].split("?")[0]
"id": str(channel_dict["id"]), except TypeError:
"thumbnail": thumbnail thumbnail = None
}
channel_list.append(clean_station_item) clean_station_item = {
"name": stirr_chan_item['rss']["channel"]["title"],
"callsign": channel_dict["display-name"],
"id": str(channel_dict["id"]),
"thumbnail": thumbnail
}
channel_list.append(clean_station_item)
return channel_list return channel_list