diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b61eb19..f278b557 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 - Bug in dash storyboard +- Adjust live video detection to reduce error rate happening on iOS client ## [0.41.8] - 2025-09-07 diff --git a/playlet-lib/src/components/Services/Innertube/InnertubeService.bs b/playlet-lib/src/components/Services/Innertube/InnertubeService.bs index bb3f38b4..e90f21b9 100644 --- a/playlet-lib/src/components/Services/Innertube/InnertubeService.bs +++ b/playlet-lib/src/components/Services/Innertube/InnertubeService.bs @@ -64,7 +64,7 @@ namespace InnertubeService ' # Start of iOS fallback playbackTrackingUrls = invalid responseJson = playerResponse.Json() - if ValidBool(ObjectUtils.Dig(responseJson, ["videoDetails", "isLive"])) or ValidBool(ObjectUtils.Dig(responseJson, ["videoDetails", "isLiveContent"])) + if ValidBool(ObjectUtils.Dig(responseJson, ["videoDetails", "isLive"])) or ValidBool(ObjectUtils.Dig(responseJson, ["videoDetails", "hasLiveStreamingData"])) LogDebug("Live video detected, falling back to iOS for HLS streams.") isLoggedIn = Innertube.ParseIsLoggedIn(responseJson) playbackTrackingUrls = Innertube.ParsePlaybackTrackingUrls(responseJson, isLoggedIn) diff --git a/playlet-lib/src/components/Services/Innertube/PlayerEndpoint.bs b/playlet-lib/src/components/Services/Innertube/PlayerEndpoint.bs index dfd3fdcb..50da51ee 100644 --- a/playlet-lib/src/components/Services/Innertube/PlayerEndpoint.bs +++ b/playlet-lib/src/components/Services/Innertube/PlayerEndpoint.bs @@ -86,7 +86,8 @@ namespace Innertube lengthSeconds = videoDetails["lengthSeconds"].ToInt() isLive = ValidBool(videoDetails["isLive"]) - isLiveContent = ValidBool(videoDetails["isLiveContent"]) + adaptiveFormats = ParseAdaptiveFormats(payload, signatureTimestamp, isLive, cancellation) + hasLiveStreamingData = FormatsHaveLiveStreamingData(adaptiveFormats) videoInfo = { "type": "video" @@ -98,10 +99,10 @@ namespace Innertube "authorId": videoDetails["channelId"] "lengthSeconds": lengthSeconds "liveNow": isLive - "isLiveContent": isLiveContent + "hasLiveStreamingData": hasLiveStreamingData "hlsUrl": streamingData["hlsManifestUrl"] "dashUrl": streamingData["dashManifestUrl"] - "adaptiveFormats": ParseAdaptiveFormats(payload, signatureTimestamp, isLive or isLiveContent, cancellation) + "adaptiveFormats": adaptiveFormats "formatStreams": [] "captions": ParseCaptions(payload) "recommendedVideos": [] @@ -510,4 +511,19 @@ namespace Innertube "videostatsWatchtimeUrl": ObjectUtils.Dig(playbackTracking, ["videostatsWatchtimeUrl", "baseUrl"]) } end function + + function FormatsHaveLiveStreamingData(adaptiveFormats as object) as boolean + if not IsArray(adaptiveFormats) + return false + end if + + for each fmt in adaptiveFormats + url = fmt["url"] + if IsString(url) and url.InStr("yt_live_broadcast") <> -1 + return true + end if + end for + + return false + end function end namespace diff --git a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/HlsRouter.bs b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/HlsRouter.bs index a10a37ce..58996d26 100644 --- a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/HlsRouter.bs +++ b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/HlsRouter.bs @@ -122,7 +122,7 @@ namespace Http end if ' TODO:P2: handle live videos - if ValidBool(metadata.liveNow) or ValidBool(metadata.isLiveContent) + if ValidBool(metadata.liveNow) or ValidBool(metadata.hasLiveStreamingData) return hlsManifest end if