jf-roku/components/liveTv/LoadChannelsTask.brs

46 lines
960 B
Plaintext
Raw Normal View History

2020-11-23 17:13:57 +00:00
sub init()
m.top.functionName = "loadChannels"
2021-07-09 20:08:32 +00:00
end sub
sub loadChannels()
2020-11-23 17:13:57 +00:00
results = []
2021-07-09 20:08:32 +00:00
params = {
2022-05-30 13:00:14 +00:00
UserId: get_setting("active_user")
2020-11-23 17:13:57 +00:00
}
2021-07-09 20:08:32 +00:00
2021-08-01 08:49:08 +00:00
if m.top.filter = "Favorites"
params.append({ isFavorite: true })
end if
2020-11-23 17:13:57 +00:00
url = "LiveTv/Channels"
resp = APIRequest(url, params)
data = getJson(resp)
2021-07-09 20:08:32 +00:00
if data.TotalRecordCount = invalid
2020-11-23 17:13:57 +00:00
m.top.channels = results
return
end if
2021-07-09 20:08:32 +00:00
2020-11-23 17:13:57 +00:00
for each item in data.Items
2021-07-09 20:08:32 +00:00
channel = createObject("roSGNode", "ChannelData")
channel.json = item
2022-05-14 10:13:28 +00:00
if item.UserData <> invalid and item.UserData.isFavorite <> invalid
channel.favorite = item.UserData.isFavorite
if channel.favorite = true
results.Unshift(channel)
else
results.push(channel)
end if
else
results.push(channel)
end if
2021-07-09 20:08:32 +00:00
end for
2020-11-23 17:13:57 +00:00
m.top.channels = results
2021-07-09 20:08:32 +00:00
end sub