From c6853cd2fcd8b0ddcc8d9ac8b7be3433a35b032c Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Mon, 23 Dec 2024 13:29:23 -0500 Subject: [PATCH] Content region and locale for playlet backend --- CHANGELOG.md | 4 ++++ .../components/Services/Innertube/Context.bs | 20 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbee2c8a..e5dc13fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Region and locale support for Playlet backend + ### Fixed - Start up crash on older OS version (11.5) diff --git a/playlet-lib/src/components/Services/Innertube/Context.bs b/playlet-lib/src/components/Services/Innertube/Context.bs index 5c0957f1..ef32bf0f 100644 --- a/playlet-lib/src/components/Services/Innertube/Context.bs +++ b/playlet-lib/src/components/Services/Innertube/Context.bs @@ -68,8 +68,8 @@ namespace Innertube function CreateContextClientWeb(deviceInfo as object) as object return { - "hl": "en" - "gl": "US" + "hl": deviceInfo.GetCurrentLocale() + "gl": GetContentRegion(deviceInfo) "remoteHost": "" "screenDensityFloat": 1 "screenHeightPoints": 1440 @@ -102,8 +102,8 @@ namespace Innertube function CreateContextClientIOS(deviceInfo as object) as object return { - "hl": "en" - "gl": "US" + "hl": deviceInfo.GetCurrentLocale() + "gl": GetContentRegion(deviceInfo) "remoteHost": "" "screenDensityFloat": 1 "screenHeightPoints": 1440 @@ -128,8 +128,8 @@ namespace Innertube function CreateContextClientTv(deviceInfo as object) as object return { - "hl": "en" - "gl": "US" + "hl": deviceInfo.GetCurrentLocale() + "gl": GetContentRegion(deviceInfo) "remoteHost": "" "deviceMake": INNERTUBE_TV_DEVICE_MAKE "deviceModel": INNERTUBE_TV_DEVICE_MODEL @@ -157,4 +157,12 @@ namespace Innertube "utcOffsetMinutes": -300 } end function + + function GetContentRegion(deviceInfo as object) as string + region = deviceInfo.GetUserCountryCode() + if region.len() <> 2 or region = "OT" + region = "US" + end if + return region + end function end namespace