jf-roku/components/liveTv/RecordProgramTask.brs

56 lines
1.8 KiB
Plaintext
Raw Normal View History

sub init()
2022-01-09 05:43:17 +00:00
m.top.functionName = "RecordOrCancelProgram"
end sub
2022-01-09 05:43:17 +00:00
sub RecordOrCancelProgram()
if m.top.programDetails <> invalid
2022-01-09 05:43:17 +00:00
' Are we setting up a recording or canceling one?
TimerId = invalid
if m.top.programDetails.json.TimerId <> invalid and m.top.programDetails.json.TimerId <> ""
TimerId = m.top.programDetails.json.TimerId
end if
if TimerId = invalid
' Setting up a recording...
programId = m.top.programDetails.Id
2022-01-09 06:06:56 +00:00
' Get Live TV default params from server...
2022-01-09 05:43:17 +00:00
url = "LiveTv/Timers/Defaults"
params = {
programId: programId
}
2022-01-09 05:43:17 +00:00
resp = APIRequest(url, params)
data = getJson(resp)
if data <> invalid
' Create recording timer...
if m.top.recordSeries = true
url = "LiveTv/SeriesTimers"
else
url = "LiveTv/Timers"
end if
resp = APIRequest(url)
postJson(resp, FormatJson(data))
2022-01-09 14:56:10 +00:00
m.top.programDetails.hdSmallIconUrl = "pkg:/images/red.png"
2022-01-09 05:43:17 +00:00
else
' Error msg to user?
print "Error getting Live TV Defaults from Server"
end if
else
' Cancelling a recording...
if m.top.recordSeries = true
2022-01-09 05:43:17 +00:00
TimerId = m.top.programDetails.json.SeriesTimerId
url = Substitute("LiveTv/SeriesTimers/{0}", TimerId)
else
2022-01-09 05:43:17 +00:00
url = Substitute("LiveTv/Timers/{0}", TimerId)
end if
resp = APIRequest(url)
2022-01-09 05:43:17 +00:00
deleteVoid(resp)
2022-01-09 14:56:10 +00:00
m.top.programDetails.hdSmallIconUrl = invalid
end if
end if
2022-01-09 05:43:17 +00:00
m.top.recordOperationDone = true
end sub