retry sts, http client fix

This commit is contained in:
Brahim Hadriche committed 2026-06-30 09:28:56 -04:00
1 parent 2e1a4c9ea3
commit 17ff6b940b
4 files changed
+26 -8

No files matched your search

+4 -1
View File
@@ -7,7 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- Nothing worth mentioning yet.
### Fixed
- Retry condition issue in http client
- Attempt to fix "page needs to be reloaded" edge case
## [0.47.5] - 2026-06-28
@@ -54,6 +54,16 @@ namespace InnertubeService
}
end if
totalPlayerRequests += 1
stsResult = Innertube.GetSignatureTimestamp(cancellation)
if CancellationUtils.IsCancelled(cancellation)
return {
error: "Cancelled"
}
end if
if stsResult.error <> invalid
return stsResult
end if
options["signatureTimestamp"] = stsResult.sts
playerRequest = Innertube.CreatePlayerRequest(client, options)
if not StringUtils.IsNullOrEmpty(accessToken) and (client = Innertube.ClientType.Tv or client = Innertube.ClientType.TvDowngraded)
playerRequest.Header("Authorization", "Bearer " + accessToken)
@@ -359,6 +369,11 @@ namespace InnertubeService
end if
options["videoId"] = videoId
stsResult = Innertube.GetSignatureTimestamp(cancellation)
if stsResult.error <> invalid
return stsResult
end if
options["signatureTimestamp"] = stsResult.sts
playerRequest = Innertube.CreatePlayerRequest(Innertube.ClientType.Tv, options)
playerRequest.Cancellation(cancellation)
playerRequest.Header("Authorization", "Bearer " + accessToken)
@@ -13,7 +13,6 @@ namespace Innertube
function CreatePlayerRequest(client as Innertube.ClientType, options = invalid as object) as object
videoId = OptionUtils.Get(options, "videoId")
cancellation = OptionUtils.Get(options, "cancellation")
visitorData = OptionUtils.Get(options, "visitorData")
accessToken = OptionUtils.Get(options, "accessToken")
livingRoomPoTokenId = OptionUtils.Get(options, "livingRoomPoTokenId")
@@ -55,7 +54,7 @@ namespace Innertube
"contentCheckOk": true
}
signatureTimestamp = GetSignatureTimestamp(cancellation)
signatureTimestamp = OptionUtils.Get(options, "signatureTimestamp")
if signatureTimestamp <> invalid
payload["playbackContext"]["contentPlaybackContext"]["signatureTimestamp"] = signatureTimestamp
end if
@@ -500,16 +499,17 @@ namespace Innertube
return result
end function
function GetSignatureTimestamp(cancellation as object) as dynamic
function GetSignatureTimestamp(cancellation as object) as object
LogDebug(`ReadAsciiFile("tmp:/sts_cache.json")`)
cache = ReadAsciiFile("tmp:/sts_cache.json")
if not StringUtils.IsNullOrEmpty(cache)
json = StringUtils.ParseJsonSafe(cache)
return json["sts"]
return { sts: json["sts"] }
end if
request = HttpClient.Get(`${PLAYLET_SUPPORT_SERVER}/v1/sts`)
request.Cancellation(cancellation)
request.TryCount(3)
request.NoCache()
response = request.Await()
if not response.IsSuccess()
@@ -518,13 +518,13 @@ namespace Innertube
else
LogError(response.ErrorMessage())
end if
return invalid
return { error: response.ErrorMessage() }
end if
text = response.Text()
WriteAsciiFile("tmp:/sts_cache.json", text)
json = response.Json()
return json["sts"]
return { sts: json["sts"] }
end function
function HasPotParam(formats as object) as boolean
@@ -485,7 +485,7 @@ namespace HttpClient
sleep(backoffMs)
response = m.AwaitInternal()
if response.IsSuccess() or response.IsTimedOut() or response.IsCancelled() or response.StatusCode() < 500
if response.IsTimedOut() or response.IsCancelled() or (response.StatusCode() >= 200 and response.StatusCode() < 500)
return response
end if
triesLeft -= 1