retry sts, http client fix
This commit is contained in:
1 parent
2e1a4c9ea3
commit
17ff6b940b
4 files changed
+26
-8
No files matched your search
+4
-1
@@ -7,7 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [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
|
## [0.47.5] - 2026-06-28
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,16 @@ namespace InnertubeService
|
|||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
totalPlayerRequests += 1
|
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)
|
playerRequest = Innertube.CreatePlayerRequest(client, options)
|
||||||
if not StringUtils.IsNullOrEmpty(accessToken) and (client = Innertube.ClientType.Tv or client = Innertube.ClientType.TvDowngraded)
|
if not StringUtils.IsNullOrEmpty(accessToken) and (client = Innertube.ClientType.Tv or client = Innertube.ClientType.TvDowngraded)
|
||||||
playerRequest.Header("Authorization", "Bearer " + accessToken)
|
playerRequest.Header("Authorization", "Bearer " + accessToken)
|
||||||
@@ -359,6 +369,11 @@ namespace InnertubeService
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
options["videoId"] = videoId
|
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 = Innertube.CreatePlayerRequest(Innertube.ClientType.Tv, options)
|
||||||
playerRequest.Cancellation(cancellation)
|
playerRequest.Cancellation(cancellation)
|
||||||
playerRequest.Header("Authorization", "Bearer " + accessToken)
|
playerRequest.Header("Authorization", "Bearer " + accessToken)
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ namespace Innertube
|
|||||||
|
|
||||||
function CreatePlayerRequest(client as Innertube.ClientType, options = invalid as object) as object
|
function CreatePlayerRequest(client as Innertube.ClientType, options = invalid as object) as object
|
||||||
videoId = OptionUtils.Get(options, "videoId")
|
videoId = OptionUtils.Get(options, "videoId")
|
||||||
cancellation = OptionUtils.Get(options, "cancellation")
|
|
||||||
visitorData = OptionUtils.Get(options, "visitorData")
|
visitorData = OptionUtils.Get(options, "visitorData")
|
||||||
accessToken = OptionUtils.Get(options, "accessToken")
|
accessToken = OptionUtils.Get(options, "accessToken")
|
||||||
livingRoomPoTokenId = OptionUtils.Get(options, "livingRoomPoTokenId")
|
livingRoomPoTokenId = OptionUtils.Get(options, "livingRoomPoTokenId")
|
||||||
@@ -55,7 +54,7 @@ namespace Innertube
|
|||||||
"contentCheckOk": true
|
"contentCheckOk": true
|
||||||
}
|
}
|
||||||
|
|
||||||
signatureTimestamp = GetSignatureTimestamp(cancellation)
|
signatureTimestamp = OptionUtils.Get(options, "signatureTimestamp")
|
||||||
if signatureTimestamp <> invalid
|
if signatureTimestamp <> invalid
|
||||||
payload["playbackContext"]["contentPlaybackContext"]["signatureTimestamp"] = signatureTimestamp
|
payload["playbackContext"]["contentPlaybackContext"]["signatureTimestamp"] = signatureTimestamp
|
||||||
end if
|
end if
|
||||||
@@ -500,16 +499,17 @@ namespace Innertube
|
|||||||
return result
|
return result
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetSignatureTimestamp(cancellation as object) as dynamic
|
function GetSignatureTimestamp(cancellation as object) as object
|
||||||
LogDebug(`ReadAsciiFile("tmp:/sts_cache.json")`)
|
LogDebug(`ReadAsciiFile("tmp:/sts_cache.json")`)
|
||||||
cache = ReadAsciiFile("tmp:/sts_cache.json")
|
cache = ReadAsciiFile("tmp:/sts_cache.json")
|
||||||
if not StringUtils.IsNullOrEmpty(cache)
|
if not StringUtils.IsNullOrEmpty(cache)
|
||||||
json = StringUtils.ParseJsonSafe(cache)
|
json = StringUtils.ParseJsonSafe(cache)
|
||||||
return json["sts"]
|
return { sts: json["sts"] }
|
||||||
end if
|
end if
|
||||||
|
|
||||||
request = HttpClient.Get(`${PLAYLET_SUPPORT_SERVER}/v1/sts`)
|
request = HttpClient.Get(`${PLAYLET_SUPPORT_SERVER}/v1/sts`)
|
||||||
request.Cancellation(cancellation)
|
request.Cancellation(cancellation)
|
||||||
|
request.TryCount(3)
|
||||||
request.NoCache()
|
request.NoCache()
|
||||||
response = request.Await()
|
response = request.Await()
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
@@ -518,13 +518,13 @@ namespace Innertube
|
|||||||
else
|
else
|
||||||
LogError(response.ErrorMessage())
|
LogError(response.ErrorMessage())
|
||||||
end if
|
end if
|
||||||
return invalid
|
return { error: response.ErrorMessage() }
|
||||||
end if
|
end if
|
||||||
|
|
||||||
text = response.Text()
|
text = response.Text()
|
||||||
WriteAsciiFile("tmp:/sts_cache.json", text)
|
WriteAsciiFile("tmp:/sts_cache.json", text)
|
||||||
json = response.Json()
|
json = response.Json()
|
||||||
return json["sts"]
|
return { sts: json["sts"] }
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function HasPotParam(formats as object) as boolean
|
function HasPotParam(formats as object) as boolean
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ namespace HttpClient
|
|||||||
sleep(backoffMs)
|
sleep(backoffMs)
|
||||||
|
|
||||||
response = m.AwaitInternal()
|
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
|
return response
|
||||||
end if
|
end if
|
||||||
triesLeft -= 1
|
triesLeft -= 1
|
||||||
|
|||||||
Reference in new issue
Block a user