jf-roku/components/liveTv/LoadSheduleTask.brs

51 lines
1.1 KiB
Plaintext
Raw Normal View History

import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
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 = {
UserId: m.global.session.user.id,
2021-07-09 20:08:32 +00:00
SortBy: "startDate",
2022-05-30 12:59:24 +00:00
EnableImages: false,
2021-07-09 20:08:32 +00:00
EnableTotalRecordCount: false,
2022-05-30 12:59:24 +00:00
EnableUserData: false,
channelIds: m.top.channelIds,
2021-07-09 20:08:32 +00:00
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:52 +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