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