Merge branch 'master' into remove-overhand-background

This commit is contained in:
Neil Burrows 2021-04-04 20:39:42 +01:00 committed by GitHub
commit 5f698225c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 119 additions and 17 deletions

View File

@ -19,8 +19,10 @@
translation="[150, 450]" />
<label text=""
id="alert"
wrap="true"
width="1620"
font="font:MediumSystemFont"
translation="[150, 555]" />
translation="[150, 580]" />
</children>
<script type="text/brightscript" uri="ConfigScene.brs"/>
</component>

View File

@ -115,23 +115,28 @@ sub programUpdated()
day = getRelativeDayName(startDate)
' Get Start Date in local timezone for display to user
localStartDate = createObject("roDateTime")
localStartDate.FromISO8601String(prog.StartDate)
localStartDate.ToLocalTime()
if startDate.AsSeconds() < now.AsSeconds() and endDate.AsSeconds() > now.AsSeconds() then
if day = "today" then
m.broadcastDetails.text = tr("Started at") + " " + formatTime(startDate)
m.broadcastDetails.text = tr("Started at") + " " + formatTime(localStartDate)
else
m.broadcastDetails.text = tr("Started") + " " + tr(day) + ", " + formatTime(startDate)
m.broadcastDetails.text = tr("Started") + " " + tr(day) + ", " + formatTime(localStartDate)
end if
else if startDate.AsSeconds() > now.AsSeconds()
if day = "today" then
m.broadcastDetails.text = tr("Starts at") + " " + formatTime(startDate)
m.broadcastDetails.text = tr("Starts at") + " " + formatTime(localStartDate)
else
m.broadcastDetails.text = tr("Starts") + " " + tr(day) + ", " + formatTime(startDate)
m.broadcastDetails.text = tr("Starts") + " " + tr(day) + ", " + formatTime(localStartDate)
end if
else
if day = "today" then
m.broadcastDetails.text = tr("Ended at") + " " + formatTime(endDate)
m.broadcastDetails.text = tr("Ended at") + " " + formatTime(localStartDate)
else
m.broadcastDetails.text = tr("Ended") + " " + tr(day) + ", " + formatTime(endDate)
m.broadcastDetails.text = tr("Ended") + " " + tr(day) + ", " + formatTime(localStartDate)
end if
end if

View File

@ -300,6 +300,11 @@
<translation>TV Guide</translation>
<extracomment>Menu option for showing Live TV Guide / Schedule</extracomment>
</message>
<message>
<source>Connecting to Server</source>
<translation>Connecting to Server</translation>
<extracomment>Message to display to user while client is attempting to connect to the server</extracomment>
</message>
</context>
<context>
<name></name>

View File

@ -414,6 +414,10 @@
<translation>TV Guide</translation>
<extracomment>Menu option for showing Live TV Guide / Schedule</extracomment>
</message>
<message>
<source>Connecting to Server</source>
<translation>Connecting to Server</translation>
<extracomment>Message to display to user while client is attempting to connect to the server</extracomment>
</message>
</context>
</TS>

View File

@ -414,6 +414,10 @@
<translation>TV Guide</translation>
<extracomment>Menu option for showing Live TV Guide / Schedule</extracomment>
</message>
<message>
<source>Connecting to Server</source>
<translation>Connecting to Server</translation>
<extracomment>Message to display to user while client is attempting to connect to the server</extracomment>
</message>
</context>
</TS>

View File

@ -441,7 +441,21 @@ function LoginFlow(startOver = false as boolean)
end if
'Collect Jellyfin server and user information
start_login:
if get_setting("server") = invalid or ServerInfo() = invalid or startOver = true then
if get_setting("server") = invalid then startOver = true
if not startOver then
' Show Connecting to Server spinner
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Connecting to Server")
m.scene.dialog = dialog
serverInfoResult = ServerInfo()
dialog.close = true
end if
if startOver or serverInfoResult.Error then
print "Get server details"
SendPerformanceBeacon("AppDialogInitiate") ' Roku Performance monitoring - Dialog Starting
serverSelection = CreateServerGroup()

View File

@ -34,11 +34,11 @@ function CreateServerGroup()
if node = "submit"
'Append default ports
maxSlashes = 0
if left(server_hostname.value,8) = "https://" or left(server_hostname.value,7) = "http://" then maxSlashes = 2
if left(lcase(server_hostname.value),8) = "https://" or left(lcase(server_hostname.value),7) = "http://" then maxSlashes = 2
'Check to make sure entry has no extra slashes before adding default ports.
if Instr(0, server_hostname.value, "/") = maxSlashes then
if server_hostname.value.len() > 5 and mid(server_hostname.value, server_hostname.value.len()-4,1) <> ":" and mid(server_hostname.value, server_hostname.value.len()-5,1) <> ":" then
if left(server_hostname.value ,5) = "https" then
if left(lcase(server_hostname.value) ,5) = "https" then
server_hostname.value = server_hostname.value + ":8920"
else
server_hostname.value = server_hostname.value + ":8096"
@ -46,19 +46,41 @@ function CreateServerGroup()
end if
end if
'Append http:// to server
if left(server_hostname.value,4) <> "http" then server_hostname.value = "http://" + server_hostname.value
if left(lcase(server_hostname.value),4) <> "http" then server_hostname.value = "http://" + server_hostname.value
'If this is a different server from what we know, reset username/password setting
if get_setting("server") <> server_hostname.value then
set_setting("username", "")
set_setting("password", "")
endif
end if
set_setting("server", server_hostname.value)
if ServerInfo() = invalid then
' Show Connecting to Server spinner
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Connecting to Server")
m.scene.dialog = dialog
serverInfoResult = ServerInfo()
dialog.close = true
if serverInfoResult = invalid then
' Maybe don't unset setting, but offer as a prompt
' Server not found, is it online? New values / Retry
print "Server not found, is it online? New values / Retry"
group.findNode("alert").text = tr("Server not found, is it online?")
SignOut()
else if serverInfoResult.Error <> invalid and serverInfoResult.Error
' If server redirected received, update the URL
if serverInfoResult.UpdatedUrl <> invalid then
server_hostname.value = serverInfoResult.UpdatedUrl
end if
' Display Error Message to user
message = tr("Error: ")
if serverInfoResult.ErrorCode <> invalid then
message = message + "[" + serverInfoResult.ErrorCode.toStr() + "] "
end if
group.findNode("alert").text = message + tr(serverInfoResult.ErrorMessage)
SignOut()
else
group.visible = false
return "true"

View File

@ -58,8 +58,54 @@ end function
function ServerInfo()
url = "System/Info/Public"
resp = APIRequest(url)
return getJson(resp)
req = APIRequest(url)
req.setMessagePort(CreateObject("roMessagePort"))
req.AsyncGetToString()
' wait 15 seconds for a server response
resp = wait(35000, req.GetMessagePort())
' handle unknown errors
if type(resp) <> "roUrlEvent"
return { "Error": true, "ErrorMessage": "Unknown" }
end if
' check for a location redirect header in the response
headers = resp.GetResponseHeaders()
if headers <> invalid and headers.location <> invalid then
' only follow redirect if it the API Endpoint path is the same (/System/Info/Public)
' set the server to new location and try again
if right(headers.location, 19) = "/System/Info/Public" then
set_setting("server", left(headers.location, len(headers.location) - 19))
info = ServerInfo()
if info.Error then
info.UpdatedUrl = left(headers.location, len(headers.location) - 19)
info.ErrorMessage = info.ErrorMessage + " (Note: Server redirected us to " + info.UpdatedUrl + ")"
end if
return info
end if
end if
' handle any non 200 responses, returning the error code and message
if resp.GetResponseCode() <> 200 then
return { "Error": true, "ErrorCode": resp.GetResponseCode(), "ErrorMessage": resp.GetFailureReason() }
end if
' return the parsed response string
responseString = resp.GetString()
if responseString <> invalid and responseString <> "" then
result = ParseJson(responseString)
if result <> invalid then
result.Error = false
return result
end if
end if
' otherwise return error message
return { "Error": true, "ErrorMessage": "Does not appear to be a Jellyfin Server" }
end function
function GetPublicUsers()