Add live Dunnellon weather and clean up Roku guide titles
This commit is contained in:
@@ -43,6 +43,8 @@ sub runRequest()
|
||||
registry.Write("id", request.server.id)
|
||||
registry.Flush()
|
||||
m.top.result = {data: readJson(request.server.baseUrl + "/api/v1/channels")}
|
||||
else if request.kind = "weather"
|
||||
m.top.result = {data: readJson(request.url, 12000)}
|
||||
else
|
||||
m.top.result = {data: readJson(request.url)}
|
||||
end if
|
||||
@@ -55,14 +57,14 @@ function readServer(baseUrl as string) as dynamic
|
||||
return {id: data.id, name: data.name, baseUrl: baseUrl}
|
||||
end function
|
||||
|
||||
function readJson(url as string) as dynamic
|
||||
function readJson(url as string, timeoutMs = 3500 as integer) as dynamic
|
||||
port = CreateObject("roMessagePort")
|
||||
transfer = CreateObject("roUrlTransfer")
|
||||
transfer.SetMessagePort(port)
|
||||
transfer.SetUrl(url)
|
||||
transfer.AddHeader("Accept", "application/json")
|
||||
if not transfer.AsyncGetToString() then return invalid
|
||||
event = Wait(3500, port)
|
||||
event = Wait(timeoutMs, port)
|
||||
if Type(event) = "roUrlEvent" and event.GetResponseCode() = 200
|
||||
data = ParseJson(event.GetString())
|
||||
if GetInterface(data, "ifAssociativeArray") <> invalid then return data
|
||||
|
||||
Reference in New Issue
Block a user