2022-01-09 00:04:38 +00:00
|
|
|
sub init()
|
2022-01-09 05:43:17 +00:00
|
|
|
m.top.functionName = "RecordOrCancelProgram"
|
2022-01-09 00:04:38 +00:00
|
|
|
end sub
|
|
|
|
|
2022-01-09 05:43:17 +00:00
|
|
|
sub RecordOrCancelProgram()
|
2022-01-09 00:04:38 +00:00
|
|
|
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 00:04:38 +00:00
|
|
|
|
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 00:04:38 +00:00
|
|
|
|
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))
|
|
|
|
else
|
|
|
|
' Error msg to user?
|
|
|
|
print "Error getting Live TV Defaults from Server"
|
|
|
|
end if
|
|
|
|
else
|
|
|
|
' Cancelling a recording...
|
2022-01-09 04:40:25 +00:00
|
|
|
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)
|
2022-01-09 04:40:25 +00:00
|
|
|
else
|
2022-01-09 05:43:17 +00:00
|
|
|
url = Substitute("LiveTv/Timers/{0}", TimerId)
|
2022-01-09 04:40:25 +00:00
|
|
|
end if
|
2022-01-09 00:04:38 +00:00
|
|
|
resp = APIRequest(url)
|
2022-01-09 05:43:17 +00:00
|
|
|
deleteVoid(resp)
|
2022-01-09 00:04:38 +00:00
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
2022-01-09 05:43:17 +00:00
|
|
|
m.top.recordOperationDone = true
|
2022-01-09 00:04:38 +00:00
|
|
|
end sub
|