jf-roku/components/liveTv/LoadSheduleTask.brs

48 lines
1.0 KiB
Plaintext
Raw Normal View History

2020-11-23 17:13:57 +00:00
sub init()
m.top.functionName = "loadSchedule"
2021-07-09 20:08:32 +00:00
end sub
sub loadSchedule()
2020-11-23 17:13:57 +00:00
results = []
2021-07-09 20:08:32 +00:00
2020-11-23 17:13:57 +00:00
params = {
2021-07-09 20:08:32 +00:00
UserId: get_setting("active_user"),
SortBy: "startDate",
EnableImages: false
EnableTotalRecordCount: false,
EnableUserData: false
channelIds: m.top.channelIds
MaxStartDate: m.top.endTime,
MinEndDate: m.top.startTime
2020-11-23 17:13:57 +00:00
}
2021-07-09 20:08:32 +00:00
2020-11-23 17:13:57 +00:00
url = "LiveTv/Programs"
resp = APIRequest(url)
2021-07-09 20:08:32 +00:00
data = postJson(resp, FormatJson(params))
if data = invalid
2020-11-23 17:13:57 +00:00
m.top.schedule = results
return
end if
results = []
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
program = createObject("roSGNode", "ScheduleProgramData")
program.json = item
' Are we currently recording this program?
2022-01-09 14:56:10 +00:00
if program.json.TimerId <> invalid and program.json.TimerId <> ""
program.hdSmallIconUrl = "pkg:/images/red.png"
2022-01-09 14:56:10 +00:00
else
program.hdSmallIconUrl = invalid
end if
2021-07-09 20:08:32 +00:00
results.push(program)
2020-11-23 17:13:57 +00:00
end for
2021-07-09 20:08:32 +00:00
2020-11-23 17:13:57 +00:00
m.top.schedule = results
2021-07-09 20:08:32 +00:00
end sub