From 33bb74d9760adaa49d9078984e3cf73bc2ee3342 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 6 Nov 2025 12:26:28 -0500 Subject: [PATCH] [skip ci] Fix in url decipher logic --- CHANGELOG.md | 6 ++++ .../Services/Innertube/PlayerEndpoint.bs | 28 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df011ff0..21884100 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Fix in url decipher logic + ## [0.43.7] - 2025-11-06 ### Fixed diff --git a/playlet-lib/src/components/Services/Innertube/PlayerEndpoint.bs b/playlet-lib/src/components/Services/Innertube/PlayerEndpoint.bs index df276aec..4c91b5ec 100644 --- a/playlet-lib/src/components/Services/Innertube/PlayerEndpoint.bs +++ b/playlet-lib/src/components/Services/Innertube/PlayerEndpoint.bs @@ -547,8 +547,7 @@ namespace Innertube for i = 0 to decipheredFormats.Count() - 1 fmt = formats[i] decipheredFmt = decipheredFormats[i] - - fmt["url"] = decipheredFmt["url"] + fmt["url"] = ResetUrlClientVersion(decipheredFmt["url"]) end for decipheredAdaptiveFormats = json["adaptiveFormats"] @@ -562,11 +561,34 @@ namespace Innertube for i = 0 to decipheredAdaptiveFormats.Count() - 1 fmt = adaptiveFormats[i] decipheredFmt = decipheredAdaptiveFormats[i] - fmt["url"] = decipheredFmt["url"] + fmt["url"] = ResetUrlClientVersion(decipheredFmt["url"]) end for return invalid end function + ' YouTube.js sets cver to hardcoded values that might be different from + ' What's used in Playlet. There's no indication that this makes a difference, + ' but it makes sense to keep it consistent. + function ResetUrlClientVersion(url as dynamic) as dynamic + if StringUtils.IsNullOrEmpty(url) + return url + end if + + queryComponents = UrlUtils.ParseQueryComponents(url) + client = ValidString(queryComponents["c"]) + if client = "TVHTML5" + queryComponents["cver"] = INNERTUBE_TV_CLIENT_VERSION + else if client = "IOS" + queryComponents["cver"] = INNERTUBE_IOS_CLIENT_VERSION + else if client = "WEB" + queryComponents["cver"] = INNERTUBE_WEB_CLIENT_VERSION + else + return url + end if + + return UrlUtils.SetQueryParams(url, queryComponents) + end function + function ParseIsLoggedIn(payload as object) as boolean trackingParams = ObjectUtils.Dig(payload, ["responseContext", "serviceTrackingParams"]) if not IsArray(trackingParams)