From 49390ab0ae5e6eb2649adf4d25c27e6461120dbb Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Sat, 3 May 2025 22:34:57 -0400 Subject: [PATCH] Fixed Playlet backend error caused by Roku 14.5 update on Canada devices --- CHANGELOG.md | 4 +++- .../src/components/Services/Innertube/Context.bs | 7 ++++++- .../components/Services/Innertube/SearchEndpoint.bs | 4 ++++ .../Middleware/PlayletInvidiousBackendRouter.bs | 11 ++++++----- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5f6453b..1150ce04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing worth mentioning yet. +### Fixed + +- Playlet backend error caused by Roku 14.5 update on Canada devices ## [0.36.6] - 2025-05-03 diff --git a/playlet-lib/src/components/Services/Innertube/Context.bs b/playlet-lib/src/components/Services/Innertube/Context.bs index 6445bb8a..d5b00f25 100644 --- a/playlet-lib/src/components/Services/Innertube/Context.bs +++ b/playlet-lib/src/components/Services/Innertube/Context.bs @@ -162,7 +162,12 @@ namespace Innertube end function function GetCurrentLocale(deviceInfo as object) as string - return deviceInfo.GetCurrentLocale() + currentLocale = deviceInfo.GetCurrentLocale() + ' en_CA is not a valid locale for Innertube + if currentLocale = "en_CA" + currentLocale = "en_US" + end if + return currentLocale end function function GetContentRegion(deviceInfo as object) as string diff --git a/playlet-lib/src/components/Services/Innertube/SearchEndpoint.bs b/playlet-lib/src/components/Services/Innertube/SearchEndpoint.bs index c28fbed1..ed2d28a9 100644 --- a/playlet-lib/src/components/Services/Innertube/SearchEndpoint.bs +++ b/playlet-lib/src/components/Services/Innertube/SearchEndpoint.bs @@ -35,6 +35,10 @@ namespace Innertube }) request.Cancellation(cancellation) + if raw + request.NoCache() + request.LogCurlCommand() + end if response = request.Await() if not response.IsSuccess() diff --git a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs index 761a65d6..6d1ed234 100644 --- a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs +++ b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs @@ -316,17 +316,18 @@ namespace Http end if result = InnertubeService.Search(query, options) - if result.error <> invalid - response.Json(result) - response.http_code = 500 - return true - end if if raw response.Json(result) return true end if + if result.error <> invalid + response.Json(result) + response.http_code = 500 + return true + end if + if not IsArray(result.feeds) or result.feeds.Count() = 0 response.Json({ "error": "Failed to search"