Watch history fix
This commit is contained in:
1 parent
4706d71639
commit
d427989576
6 files changed
+21
-34
No files matched your search
@@ -5,6 +5,13 @@ 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
|
||||
|
||||
- Always use `signatureTimestamp` in `/player` calls to prevent "reload page" errors. This affects watch history.
|
||||
- Attempt 2 to fix watch history and watch progress
|
||||
|
||||
## [0.44.7] - 2026-04-23
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -363,8 +363,6 @@ namespace InnertubeService
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
|
||||
cpn = OptionUtils.Get(options, "cpn")
|
||||
cmt = OptionUtils.GetOrDefault(options, "cmt", 0)
|
||||
cmtStr = cmt.ToStr("%.3f")
|
||||
|
||||
videostatsPlaybackUrl = videostatsPlaybackUrl.replace("https://s.", "https://www.")
|
||||
queryParams = UrlUtils.ParseQueryComponents(videostatsPlaybackUrl)
|
||||
@@ -372,8 +370,9 @@ namespace InnertubeService
|
||||
queryParams["cbrver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||
queryParams["cver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||
queryParams["ver"] = "2"
|
||||
queryParams["cmt"] = "0"
|
||||
queryParams["cpn"] = cpn
|
||||
queryParams["cmt"] = cmtStr
|
||||
queryParams["final"] = "1"
|
||||
videostatsPlaybackUrl = UrlUtils.SetQueryParams(videostatsPlaybackUrl, queryParams)
|
||||
|
||||
request = HttpClient.Get(videostatsPlaybackUrl)
|
||||
@@ -395,15 +394,13 @@ namespace InnertubeService
|
||||
return true
|
||||
end function
|
||||
|
||||
function AuthMarkVideoWatchTime(startTime as float, endTime as float, videostatsWatchtimeUrl as string, options = invalid as object) as boolean
|
||||
function AuthMarkVideoWatchTime(time as float, videostatsWatchtimeUrl as string, options = invalid as object) as boolean
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
|
||||
|
||||
timeStr = time.ToStr("%.3f")
|
||||
cpn = OptionUtils.Get(options, "cpn")
|
||||
cmt = OptionUtils.GetOrDefault(options, "cmt", 0)
|
||||
cmtStr = cmt.ToStr("%.3f")
|
||||
stStr = startTime.ToStr("%.3f")
|
||||
etStr = endTime.ToStr("%.3f")
|
||||
|
||||
videostatsWatchtimeUrl = videostatsWatchtimeUrl.replace("https://s.", "https://www.")
|
||||
queryParams = UrlUtils.ParseQueryComponents(videostatsWatchtimeUrl)
|
||||
@@ -412,9 +409,10 @@ namespace InnertubeService
|
||||
queryParams["cver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||
queryParams["ver"] = "2"
|
||||
queryParams["cpn"] = cpn
|
||||
queryParams["cmt"] = cmtStr
|
||||
queryParams["st"] = stStr
|
||||
queryParams["et"] = etStr
|
||||
queryParams["cmt"] = "0"
|
||||
queryParams["st"] = timeStr
|
||||
queryParams["et"] = timeStr
|
||||
queryParams["final"] = "1"
|
||||
videostatsWatchtimeUrl = UrlUtils.SetQueryParams(videostatsWatchtimeUrl, queryParams)
|
||||
|
||||
request = HttpClient.Get(videostatsWatchtimeUrl)
|
||||
@@ -432,7 +430,7 @@ namespace InnertubeService
|
||||
return false
|
||||
end if
|
||||
|
||||
LogDebug("Marked video watch time:", stStr, "-", etStr)
|
||||
LogDebug("Marked video watch time:", timeStr)
|
||||
return true
|
||||
end function
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ namespace Innertube
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
visitorData = OptionUtils.Get(options, "visitorData")
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
doSignatureTimestamp = ValidBool(OptionUtils.Get(options, "signatureTimestamp"))
|
||||
|
||||
cpn = InnertubeService.CreateClientPlaybackNonce()
|
||||
|
||||
useAccessToken = client = Innertube.ClientType.TV and not StringUtils.IsNullOrEmpty(accessToken)
|
||||
@@ -52,12 +50,9 @@ namespace Innertube
|
||||
"contentCheckOk": true
|
||||
}
|
||||
|
||||
signatureTimestamp = invalid
|
||||
if doSignatureTimestamp
|
||||
signatureTimestamp = GetSignatureTimestamp(cancellation)
|
||||
if signatureTimestamp <> invalid
|
||||
payload["playbackContext"]["contentPlaybackContext"]["signatureTimestamp"] = signatureTimestamp
|
||||
end if
|
||||
signatureTimestamp = GetSignatureTimestamp(cancellation)
|
||||
if signatureTimestamp <> invalid
|
||||
payload["playbackContext"]["contentPlaybackContext"]["signatureTimestamp"] = signatureTimestamp
|
||||
end if
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/player?prettyPrint=false&alt=json", payload)
|
||||
|
||||
@@ -74,7 +74,6 @@ function ExecuteJob() as void
|
||||
MessagePortUtils.ObserveFieldScopedExSafe(callbackNode, "watchTime", port)
|
||||
CancellationUtils.ObserveCancellationScoped(cancellation, port)
|
||||
successiveFailures = 0
|
||||
lastReportedTime = 0.0
|
||||
while true
|
||||
message = wait(60000, port)
|
||||
if CancellationUtils.IsCancellationEvent(cancellation, message)
|
||||
@@ -97,27 +96,17 @@ function ExecuteJob() as void
|
||||
end while
|
||||
|
||||
watchTime = message.getData()
|
||||
' On seek-back, clamp st to not exceed et - I don't know if we really need to
|
||||
if lastReportedTime > watchTime
|
||||
lastReportedTime = watchTime - 20
|
||||
if lastReportedTime < 0
|
||||
lastReportedTime = 0
|
||||
end if
|
||||
end if
|
||||
|
||||
success = InnertubeService.AuthMarkVideoWatchTime(lastReportedTime, watchTime, playbackTrackingUrls.videostatsWatchtimeUrl, {
|
||||
success = InnertubeService.AuthMarkVideoWatchTime(watchTime, playbackTrackingUrls.videostatsWatchtimeUrl, {
|
||||
accessToken: authToken.token
|
||||
onBehalfOfUser: authToken.activeIdentifyToken
|
||||
cpn: cpn
|
||||
' TODO:P1 if we pass cancellation here, http client will remove scoped
|
||||
' observer, which is stored on the current node.
|
||||
' This requires an extra observer node to be independent.
|
||||
cmt: lastReportedTime
|
||||
cancellation: invalid
|
||||
})
|
||||
if success
|
||||
successiveFailures = 0
|
||||
lastReportedTime = watchTime
|
||||
else
|
||||
successiveFailures += 1
|
||||
end if
|
||||
|
||||
@@ -61,7 +61,6 @@ function ExecuteJob() as void
|
||||
"visitorData": visitorData
|
||||
"accessToken": accessToken
|
||||
"onBehalfOfUser": onBehalfOfUser
|
||||
"signatureTimestamp": true
|
||||
})
|
||||
else
|
||||
metadata = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
|
||||
|
||||
-1
@@ -584,7 +584,6 @@ namespace Http
|
||||
}
|
||||
end if
|
||||
else
|
||||
options["signatureTimestamp"] = true
|
||||
options["credentialTransferToken"] = m.loungeService.credentialTransferToken
|
||||
metadata = InnertubeService.GetVideoMetadata(videoId, options)
|
||||
end if
|
||||
|
||||
Reference in new issue
Block a user