Get rid of optional chaining (Roku 11 feature)
This commit is contained in:
1 parent
af1fa0b401
commit
6cf735e089
3 files changed
+35
-14
No files matched your search
+11
-4
@@ -105,14 +105,21 @@ function IsReachable(instance as string, testNode as object) as void
|
||||
return
|
||||
end if
|
||||
|
||||
name = json.software?.name
|
||||
if not IsString(name)
|
||||
software = json.software
|
||||
if software = invalid
|
||||
testNode.state = "failed"
|
||||
testNode.details = `Invalid json from ${url} (couldn't read software.name)`
|
||||
testNode.details = `Invalid json from ${url} (couldn't read $.software)`
|
||||
return
|
||||
end if
|
||||
|
||||
version = json.software?.version
|
||||
name = software.name
|
||||
if not IsString(name)
|
||||
testNode.state = "failed"
|
||||
testNode.details = `Invalid json from ${url} (couldn't read $.software.name)`
|
||||
return
|
||||
end if
|
||||
|
||||
version = software.version
|
||||
if not IsString(version)
|
||||
testNode.state = "failed"
|
||||
testNode.details = `Invalid json from ${url} (couldn't read software.version)`
|
||||
|
||||
@@ -185,8 +185,8 @@ function OnVideoPlayerStateChange() as void
|
||||
end if
|
||||
|
||||
if state = "finished"
|
||||
metadata = content?.metadata
|
||||
if not PlayNext(metadata?.recommendedVideos)
|
||||
metadata = content.metadata
|
||||
if metadata <> invalid and not PlayNext(metadata.recommendedVideos)
|
||||
m.container@.watchedVideosClear(invalid)
|
||||
VideoUtils.CloseVideo()
|
||||
end if
|
||||
@@ -231,7 +231,10 @@ function PlayNextRecommendedVideo(recommendedVideos as object) as boolean
|
||||
end if
|
||||
|
||||
for each metadata in recommendedVideos
|
||||
videoId = metadata?.videoId
|
||||
if metadata = invalid
|
||||
continue for
|
||||
end if
|
||||
videoId = metadata.videoId
|
||||
if videoId = invalid
|
||||
continue for
|
||||
end if
|
||||
|
||||
@@ -53,26 +53,37 @@ namespace Http
|
||||
response = context.response
|
||||
invidiousNode = context.server.task.invidious
|
||||
|
||||
feedSource = request.query["feed-source"]
|
||||
if feedSource = invalid
|
||||
response.Default(400, "Expected feed-source")
|
||||
return true
|
||||
end if
|
||||
|
||||
token = invidiousNode.authToken
|
||||
if token = invalid
|
||||
response.Default(403, "No token, not logged in")
|
||||
return true
|
||||
end if
|
||||
|
||||
feedSource = request.query["feed-source"]
|
||||
if feedSource = invalid
|
||||
response.Default(400, "Expected feed-source")
|
||||
return true
|
||||
end if
|
||||
|
||||
feedSource = ParseJson(feedSource)
|
||||
if feedSource = invalid
|
||||
response.Default(400, "Expected valid JSON for feed-source")
|
||||
return true
|
||||
end if
|
||||
|
||||
invService = new Invidious.InvidiousService(invidiousNode)
|
||||
invResponse = invService.MakeRequest(feedSource, feedSource.state?.queryParams)
|
||||
|
||||
additionalQueryParams = invalid
|
||||
if feedSource.state <> invalid and feedSource.state.queryParams <> invalid
|
||||
additionalQueryParams = feedSource.state.queryParams
|
||||
end if
|
||||
|
||||
invResponse = invService.MakeRequest(feedSource, additionalQueryParams)
|
||||
if not invResponse.success
|
||||
response.Default(500, `Failed to make request: ${invResponse.error}`)
|
||||
return true
|
||||
end if
|
||||
|
||||
response.Json(invResponse.result)
|
||||
return true
|
||||
end function)
|
||||
|
||||
Reference in new issue
Block a user