diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c315ea4..0e5d8b78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Display issues for 720p devices +- Attempt to fix session data fetch errors ## [0.48.2] - 2026-07-11 diff --git a/playlet-lib/src/components/Services/Innertube/Innertube.bs b/playlet-lib/src/components/Services/Innertube/Innertube.bs index 38c3e472..d90aa3fd 100644 --- a/playlet-lib/src/components/Services/Innertube/Innertube.bs +++ b/playlet-lib/src/components/Services/Innertube/Innertube.bs @@ -1,22 +1,17 @@ import "pkg:/components/JobSystem/Jobs.bs" import "pkg:/components/JobSystem/JobSystem.bs" import "pkg:/components/Services/Innertube/Constants.bs" -import "pkg:/source/utils/StringUtils.bs" function Init() - m.top.observeField("requestSessionData", FuncName(OnRequestSessionData)) end function function OnNodeReady() QueueSessionDataJob() end function -function OnRequestSessionData() as void - sessionData = m.top.sessionData - if IsAssociativeArray(sessionData) and not StringUtils.IsNullOrEmpty(sessionData.visitorData) and not StringUtils.IsNullOrEmpty(sessionData.livingRoomPoTokenId) - return - end if +function EnsureSessionDataJob(_unused as dynamic) as object QueueSessionDataJob() + return m.innertubeSessionDataJob end function function QueueSessionDataJob() as void @@ -33,6 +28,9 @@ function QueueSessionDataJob() as void end function function OnInnertubeSessionDataJobDone(event as object) as void - JobSystem.UnobserveCallback(event.getRoSGNode()) - m.innertubeSessionDataJob = invalid + node = event.getRoSGNode() + JobSystem.UnobserveCallback(node) + if m.innertubeSessionDataJob <> invalid and m.innertubeSessionDataJob.isSameNode(node) + m.innertubeSessionDataJob = invalid + end if end function diff --git a/playlet-lib/src/components/Services/Innertube/Innertube.xml b/playlet-lib/src/components/Services/Innertube/Innertube.xml index a54d68e7..1afcbdd0 100644 --- a/playlet-lib/src/components/Services/Innertube/Innertube.xml +++ b/playlet-lib/src/components/Services/Innertube/Innertube.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/playlet-lib/src/components/VideoPlayer/VideoContentJob.bs b/playlet-lib/src/components/VideoPlayer/VideoContentJob.bs index 409055fa..67d6b977 100644 --- a/playlet-lib/src/components/VideoPlayer/VideoContentJob.bs +++ b/playlet-lib/src/components/VideoPlayer/VideoContentJob.bs @@ -177,17 +177,30 @@ function GetSessionData(innertubeNode as object, cancellation as object) as obje return sessionData end if + callback = innertubeNode.callFunc("EnsureSessionDataJob", invalid) + port = CreateObject("roMessagePort") MessagePortUtils.ObserveFieldScopedExSafe(innertubeNode, "sessionData", port) + MessagePortUtils.ObserveFieldScopedExSafe(callback, "done", port) CancellationUtils.ObserveCancellationScoped(cancellation, port) - innertubeNode.requestSessionData = true - message = wait(30000, port) + cancelled = false + while not SessionDataComplete(innertubeNode.sessionData) and callback.done <> true + message = wait(30000, port) + if message = invalid + exit while + end if + if CancellationUtils.IsCancellationEvent(cancellation, message) + cancelled = true + exit while + end if + end while innertubeNode.unobserveFieldScoped("sessionData") + callback.unobserveFieldScoped("done") CancellationUtils.UnobserveCancellationScoped(cancellation) - if message <> invalid and CancellationUtils.IsCancellationEvent(cancellation, message) + if cancelled return { cancel: true }