Run the retroLabs backend and add the Roku tuner

This commit is contained in:
Josh
2026-11-13 11:38:39 -05:00
parent a668681d2b
commit fceda10d90
21 changed files with 1447 additions and 0 deletions

105
roku/components/Guide.brs Normal file
View File

@@ -0,0 +1,105 @@
sub showPanel(mode as string, title as string, status as string, titles as object)
m.panelMode = mode
m.panelTitle.text = title
m.panelStatus.text = status
content = CreateObject("roSGNode", "ContentNode")
for each labelText in titles
item = content.CreateChild("ContentNode")
item.title = labelText
end for
m.menu.content = content
m.menu.jumpToItem = 0
m.panel.visible = true
if titles.Count() = 0
m.top.SetFocus(true)
else
m.menu.SetFocus(true)
end if
end sub
sub closePanel()
m.panelMode = ""
m.panel.visible = false
m.top.SetFocus(true)
end sub
sub onMenuSelect(event as object)
index = event.GetData()
if m.panelMode = "servers"
if index < m.servers.Count()
connectServer(m.servers[index])
else if index = m.servers.Count()
openAddressDialog()
else
findServer("", false)
end if
else if m.panelMode = "lineup"
if index = 0
loadLineup()
else
findServer("", false)
end if
else if m.panelMode = "options"
if index = 0
openGuide()
else if index = 1
m.channelIndex = -1
m.video.control = "stop"
m.retryTimer.control = "stop"
loadLineup()
else
findServer("", false)
end if
else if m.panelMode = "guide"
id = m.guideIds[index]
for i = 0 to m.channels.Count() - 1
if m.channels[i].id = id
closePanel()
tune(i)
exit for
end if
end for
else if m.panelMode = "guideError"
openGuide()
end if
end sub
sub openGuide()
if m.guideRequest <> invalid
m.guideRequest.UnobserveFieldScoped("result")
m.guideRequest.control = "stop"
end if
showPanel("guideLoading", "Program guide", "Loading the schedule…", [])
m.guideRequest = startRequest({url: m.server.baseUrl + "/api/v1/guide?hours=3"}, "onGuide")
end sub
sub onGuide(event as object)
m.guideRequest = invalid
if m.panelMode <> "guideLoading" then return
data = event.GetData().data
if data = invalid or GetInterface(data.channels, "ifArray") = invalid
showPanel("guideError", "Program guide", "Could not load the schedule.", ["Retry"])
return
end if
syncClock(data.serverTime)
now = currentEpoch()
m.guideIds = []
titles = []
for each channel in data.channels
current = invalid
upcoming = invalid
if GetInterface(channel.programs, "ifArray") <> invalid
for each program in channel.programs
if parseUtc(program.start) > now
upcoming = program
exit for
else if parseUtc(program.stop) > now
current = program
end if
end for
end if
titles.Push(channelLabel(channel) + " | " + programTitle(current) + " / " + programTitle(upcoming))
m.guideIds.Push(channel.id)
end for
showPanel("guide", "Program guide", "CHANNEL | NOW / NEXT", titles)
end sub