diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs index b5c9ee64..b1308232 100644 --- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs +++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs @@ -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)` diff --git a/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs b/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs index 3855dfeb..febb097c 100644 --- a/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs +++ b/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs @@ -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 diff --git a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/InvidiousRouter.bs b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/InvidiousRouter.bs index d0c2e8b9..3f934d7f 100644 --- a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/InvidiousRouter.bs +++ b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/InvidiousRouter.bs @@ -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)