Introduce usage of potoken for GVS for visitor data users
This commit is contained in:
1 parent
5e34ce8067
commit
7e21e46ec0
4 files changed
+47
-4
No files matched your search
@@ -61,6 +61,7 @@ namespace Innertube
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(visitorData) and not useAccessToken
|
||||
request.Header("x-goog-visitor-id", visitorData)
|
||||
request.poTokenIdentity = visitorData
|
||||
end if
|
||||
|
||||
request.signatureTimestamp = signatureTimestamp
|
||||
@@ -102,7 +103,7 @@ namespace Innertube
|
||||
adaptiveFormats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"]))
|
||||
formats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "formats"]))
|
||||
|
||||
error = DecipherUrls(formats, adaptiveFormats, playerRequest.signatureTimestamp, cancellation, client)
|
||||
error = DecipherUrls(formats, adaptiveFormats, playerRequest.signatureTimestamp, cancellation, client, playerRequest.poTokenIdentity)
|
||||
if error <> invalid
|
||||
parsedResponse["error"] = error.error
|
||||
if error.DoesExist("errorCode")
|
||||
@@ -111,6 +112,9 @@ namespace Innertube
|
||||
return parsedResponse
|
||||
end if
|
||||
|
||||
parsedResponse["potAttached"] = HasPotParam(adaptiveFormats) or HasPotParam(formats)
|
||||
LogDebug("poToken attached to deciphered urls:", parsedResponse["potAttached"])
|
||||
|
||||
' if isLive and adaptiveFormats.Count() > 0
|
||||
' LogInfo("[LIVE-INFO] post-decipher, sts:", playerRequest.signatureTimestamp, "format[0].itag:", adaptiveFormats[0]["itag"], "url:", adaptiveFormats[0]["url"])
|
||||
' end if
|
||||
@@ -499,7 +503,19 @@ namespace Innertube
|
||||
return json["sts"]
|
||||
end function
|
||||
|
||||
function DecipherUrls(formats as object, adaptiveFormats as object, signatureTimestamp as dynamic, cancellation as object, client = invalid as dynamic) as object
|
||||
function HasPotParam(formats as object) as boolean
|
||||
for each fmt in formats
|
||||
url = fmt["url"]
|
||||
if not StringUtils.IsNullOrEmpty(url)
|
||||
if url.Instr("&pot=") <> -1
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
return false
|
||||
end function
|
||||
|
||||
function DecipherUrls(formats as object, adaptiveFormats as object, signatureTimestamp as dynamic, cancellation as object, client = invalid as dynamic, poTokenIdentity = invalid as dynamic) as object
|
||||
if signatureTimestamp = invalid
|
||||
' No need to decipher if signatureTimestamp is not available
|
||||
return invalid
|
||||
@@ -523,11 +539,16 @@ namespace Innertube
|
||||
})
|
||||
end for
|
||||
|
||||
request = HttpClient.PostJson(`${PLAYLET_SUPPORT_SERVER}/v2/decipher`, {
|
||||
body = {
|
||||
"sts": signatureTimestamp
|
||||
"formats": reqFormats
|
||||
"adaptiveFormats": reqAdaptiveFormats
|
||||
})
|
||||
}
|
||||
if not StringUtils.IsNullOrEmpty(poTokenIdentity)
|
||||
body["identity"] = poTokenIdentity
|
||||
end if
|
||||
|
||||
request = HttpClient.PostJson(`${PLAYLET_SUPPORT_SERVER}/v2/decipher`, body)
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
request.LogCurlCommand(false)
|
||||
|
||||
@@ -60,6 +60,12 @@ function ExecuteJob() as void
|
||||
"accessToken": accessToken
|
||||
"onBehalfOfUser": onBehalfOfUser
|
||||
})
|
||||
if IsAssociativeArray(metadata)
|
||||
contentNode.addFields({
|
||||
potAttached: ValidBool(metadata.potAttached)
|
||||
loggedIn: not StringUtils.IsNullOrEmpty(accessToken)
|
||||
})
|
||||
end if
|
||||
else
|
||||
metadata = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
|
||||
end if
|
||||
|
||||
@@ -1404,6 +1404,17 @@ function ReportVideoError(errorData as object, url as dynamic, urls as object, u
|
||||
data: ValidString(ReadAsciiFile("cachefs:/last_player_response.json"))
|
||||
}]
|
||||
end if
|
||||
potAttached = "false"
|
||||
loggedIn = "false"
|
||||
content = m.top.content
|
||||
if content <> invalid
|
||||
if ValidBool(content.potAttached)
|
||||
potAttached = "true"
|
||||
end if
|
||||
if ValidBool(content.loggedIn)
|
||||
loggedIn = "true"
|
||||
end if
|
||||
end if
|
||||
message = [
|
||||
errorData.title
|
||||
errorData.body
|
||||
@@ -1413,8 +1424,12 @@ function ReportVideoError(errorData as object, url as dynamic, urls as object, u
|
||||
`Url: ${url}`
|
||||
"Urls: " + FormatJson(urls)
|
||||
`Url index: ${urlIndex}`
|
||||
`pot_attached: ${potAttached}`
|
||||
`logged_in: ${loggedIn}`
|
||||
].Join(Chr(10))
|
||||
errorData.fingerprint.Push(shownInDialog)
|
||||
errorData.fingerprint.Push(potAttached)
|
||||
errorData.fingerprint.Push(loggedIn)
|
||||
if shownInDialog
|
||||
level = "error"
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user