Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4588e9dbbb | ||
|
|
95dff3bc07 | ||
|
|
9980b591b3 | ||
|
|
e8f1a98cfe | ||
|
|
513c13420a | ||
|
|
c32431fefc | ||
|
|
d03909f8d6 | ||
|
|
bbabb3184d |
No files matched your search
@@ -5,6 +5,16 @@ 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).
|
||||||
|
|
||||||
|
## [0.47.2] - 2026-06-21
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Attempt to fix the "The page needs to be reloaded" error by refreshing the signature timestamp automatically
|
||||||
|
- Playlists with more than one page of videos no longer stop loading after the first ~100 videos
|
||||||
|
- Report previous-run crashes to diagnostics
|
||||||
|
- Live streams no longer fail with a 502 error on transient segment failures
|
||||||
|
- Attempt to fix low quality videos, by downgrading tv client version
|
||||||
|
|
||||||
## [0.47.1] - 2026-06-18
|
## [0.47.1] - 2026-06-18
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.47.1",
|
"version": "0.47.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.47.1",
|
"version": "0.47.2",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rokucommunity/bslint": "^0.8.44",
|
"@rokucommunity/bslint": "^0.8.44",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.47.1",
|
"version": "0.47.2",
|
||||||
"description": "Unofficial YouTube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rokucommunity/bslint": "^0.8.44",
|
"@rokucommunity/bslint": "^0.8.44",
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.47.1",
|
"version": "0.47.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.47.1"
|
"version": "0.47.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.47.1",
|
"version": "0.47.2",
|
||||||
"description": "Unofficial YouTube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "node ../tools/rm.js ../build/playlet-app",
|
"prebuild": "node ../tools/rm.js ../build/playlet-app",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<field id="playletLibLoadedUrl" type="assocarray" />
|
<field id="playletLibLoadedUrl" type="assocarray" />
|
||||||
<field id="systemLogEvent" type="assocarray" alwaysNotify="true" />
|
<field id="systemLogEvent" type="assocarray" alwaysNotify="true" />
|
||||||
<field id="enableSystemLogType" type="string" />
|
<field id="enableSystemLogType" type="string" />
|
||||||
|
<field id="lastExitInfo" type="assocarray" />
|
||||||
</interface>
|
</interface>
|
||||||
<script type="text/brightscript" uri="pkg:/source/Dialog.bs" />
|
<script type="text/brightscript" uri="pkg:/source/Dialog.bs" />
|
||||||
<script type="text/brightscript" uri="pkg:/source/Manifest.bs" />
|
<script type="text/brightscript" uri="pkg:/source/Manifest.bs" />
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title=Playlet
|
|||||||
# Do not update version manually, it is auto updated from package.json
|
# Do not update version manually, it is auto updated from package.json
|
||||||
major_version=0
|
major_version=0
|
||||||
minor_version=47
|
minor_version=47
|
||||||
build_version=00001
|
build_version=00002
|
||||||
|
|
||||||
ui_resolutions=hd
|
ui_resolutions=hd
|
||||||
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
namespace AppManager
|
||||||
|
|
||||||
|
function CaptureLastExitInfo(scene as object) as void
|
||||||
|
manager = CreateObject("roAppManager")
|
||||||
|
' roAppManager.GetLastExitInfo() is only available on Roku OS 13 and above
|
||||||
|
if FindMemberFunction(manager, "GetLastExitInfo") = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
lastExitInfo = manager.GetLastExitInfo()
|
||||||
|
Logger.LogLastExitInfo(lastExitInfo)
|
||||||
|
scene.lastExitInfo = lastExitInfo
|
||||||
|
end function
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
namespace Tests
|
||||||
|
|
||||||
|
@suite
|
||||||
|
class AppManagerTests extends Rooibos.BaseTestSuite
|
||||||
|
|
||||||
|
@describe("AppManager")
|
||||||
|
|
||||||
|
@it("captures the device's last exit info onto the scene")
|
||||||
|
function _()
|
||||||
|
manager = CreateObject("roAppManager")
|
||||||
|
scene = {}
|
||||||
|
AppManager.CaptureLastExitInfo(scene)
|
||||||
|
|
||||||
|
if FindMemberFunction(manager, "GetLastExitInfo") = invalid
|
||||||
|
' Roku OS < 13: nothing to capture
|
||||||
|
m.assertInvalid(scene.lastExitInfo)
|
||||||
|
else
|
||||||
|
info = scene.lastExitInfo
|
||||||
|
m.assertAAHasKeys(info, ["exit_code", "timestamp", "app_state", "console_log"])
|
||||||
|
m.assertTrue(info.exit_code.StartsWith("EXIT_"), "exit_code should be an EXIT_* string")
|
||||||
|
m.assertTrue(Len(info.timestamp) > 0, "timestamp should be a non-empty string")
|
||||||
|
m.assertTrue(Len(info.app_state) > 0, "app_state should be a non-empty string")
|
||||||
|
m.assertTrue(GetInterface(info.console_log, "ifString") <> invalid, "console_log should be a string")
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
end class
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -16,15 +16,7 @@ namespace Logger
|
|||||||
buffer.AppendFile(LOGS_FILE_PATH)
|
buffer.AppendFile(LOGS_FILE_PATH)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function LogLastExitInfo() as void
|
function LogLastExitInfo(lastExitInfo as object) as void
|
||||||
' roAppManager.GetLastExitInfo() is only available on Roku OS 13 and above
|
|
||||||
appManager = CreateObject("roAppManager")
|
|
||||||
hasMethod = FindMemberFunction(appManager, "GetLastExitInfo") <> invalid
|
|
||||||
if not hasMethod
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
|
|
||||||
lastExitInfo = appManager.GetLastExitInfo()
|
|
||||||
if lastExitInfo = invalid
|
if lastExitInfo = invalid
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ function Main(args as object) as void
|
|||||||
Registry.ClearPlayletLibUrlsIfNeeded(args)
|
Registry.ClearPlayletLibUrlsIfNeeded(args)
|
||||||
Registry.ClearRegistryIfNeeded(args)
|
Registry.ClearRegistryIfNeeded(args)
|
||||||
|
|
||||||
Logger.LogLastExitInfo()
|
|
||||||
|
|
||||||
scene = screen.CreateScene("BootstrapScene")
|
scene = screen.CreateScene("BootstrapScene")
|
||||||
screen.show()
|
screen.show()
|
||||||
|
|
||||||
|
AppManager.CaptureLastExitInfo(scene)
|
||||||
|
|
||||||
SetScenePalette(scene)
|
SetScenePalette(scene)
|
||||||
scene.ObserveField("exitChannel", port)
|
scene.ObserveField("exitChannel", port)
|
||||||
scene.launchArgs = args
|
scene.launchArgs = args
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.47.1",
|
"version": "0.47.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.47.1"
|
"version": "0.47.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.47.1",
|
"version": "0.47.2",
|
||||||
"description": "Unofficial YouTube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "node ../tools/rm.js ../build/playlet-lib",
|
"prebuild": "node ../tools/rm.js ../build/playlet-lib",
|
||||||
|
|||||||
@@ -23,3 +23,5 @@ const INNERTUBE_TV_DEVICE_MODEL = "SmartTV"
|
|||||||
const INNERTUBE_TV_OS_NAME = "Tizen"
|
const INNERTUBE_TV_OS_NAME = "Tizen"
|
||||||
const INNERTUBE_TV_OS_VERSION = "4.0.0.2"
|
const INNERTUBE_TV_OS_VERSION = "4.0.0.2"
|
||||||
const INNERTUBE_TV_USER_AGENT = "Mozilla/5.0(SMART-TV; Linux; Tizen 4.0.0.2) AppleWebkit/605.1.15 (KHTML, like Gecko) SamsungBrowser/9.2 TV Safari/605.1.15"
|
const INNERTUBE_TV_USER_AGENT = "Mozilla/5.0(SMART-TV; Linux; Tizen 4.0.0.2) AppleWebkit/605.1.15 (KHTML, like Gecko) SamsungBrowser/9.2 TV Safari/605.1.15"
|
||||||
|
|
||||||
|
const INNERTUBE_TV_CLIENT_VERSION_DOWNGRADED = "5.20260114"
|
||||||
@@ -8,6 +8,7 @@ namespace Innertube
|
|||||||
Web = "WEB"
|
Web = "WEB"
|
||||||
IOS = "IOS"
|
IOS = "IOS"
|
||||||
Tv = "TV"
|
Tv = "TV"
|
||||||
|
TvDowngraded = "TV_DOWNGRADED"
|
||||||
end enum
|
end enum
|
||||||
|
|
||||||
function CreateHeaders(client as Innertube.ClientType) as object
|
function CreateHeaders(client as Innertube.ClientType) as object
|
||||||
@@ -35,6 +36,14 @@ namespace Innertube
|
|||||||
"x-youtube-client-name": INNERTUBE_TV_CLIENT_NAME
|
"x-youtube-client-name": INNERTUBE_TV_CLIENT_NAME
|
||||||
"x-youtube-client-version": INNERTUBE_TV_CLIENT_VERSION
|
"x-youtube-client-version": INNERTUBE_TV_CLIENT_VERSION
|
||||||
}
|
}
|
||||||
|
else if client = ClientType.TvDowngraded
|
||||||
|
return {
|
||||||
|
"accept": "*/*"
|
||||||
|
"accept-language": "*"
|
||||||
|
"user-agent": INNERTUBE_TV_USER_AGENT
|
||||||
|
"x-youtube-client-name": INNERTUBE_TV_CLIENT_NAME
|
||||||
|
"x-youtube-client-version": INNERTUBE_TV_CLIENT_VERSION_DOWNGRADED
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw "Invalid client type"
|
throw "Invalid client type"
|
||||||
end if
|
end if
|
||||||
@@ -46,8 +55,8 @@ namespace Innertube
|
|||||||
contextClient = CreateContextClientWeb(deviceInfo)
|
contextClient = CreateContextClientWeb(deviceInfo)
|
||||||
else if client = ClientType.IOS
|
else if client = ClientType.IOS
|
||||||
contextClient = CreateContextClientIOS(deviceInfo)
|
contextClient = CreateContextClientIOS(deviceInfo)
|
||||||
else if client = ClientType.Tv
|
else if client = ClientType.Tv or client = ClientType.TvDowngraded
|
||||||
contextClient = CreateContextClientTv(deviceInfo)
|
contextClient = CreateContextClientTv(deviceInfo, client)
|
||||||
else
|
else
|
||||||
throw "Invalid client type"
|
throw "Invalid client type"
|
||||||
end if
|
end if
|
||||||
@@ -58,8 +67,8 @@ namespace Innertube
|
|||||||
accessToken = OptionUtils.Get(options, "accessToken")
|
accessToken = OptionUtils.Get(options, "accessToken")
|
||||||
videoId = OptionUtils.Get(options, "videoId")
|
videoId = OptionUtils.Get(options, "videoId")
|
||||||
|
|
||||||
useAccessToken = client = Innertube.ClientType.TV and not StringUtils.IsNullOrEmpty(accessToken)
|
useAccessToken = (client = ClientType.Tv or client = ClientType.TvDowngraded) and not StringUtils.IsNullOrEmpty(accessToken)
|
||||||
useCtt = client = Innertube.ClientType.TV and IsAssociativeArray(credentialTransferToken) and not StringUtils.IsNullOrEmpty(videoId)
|
useCtt = (client = ClientType.Tv or client = ClientType.TvDowngraded) and IsAssociativeArray(credentialTransferToken) and not StringUtils.IsNullOrEmpty(videoId)
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"client": contextClient
|
"client": contextClient
|
||||||
@@ -154,7 +163,11 @@ namespace Innertube
|
|||||||
}
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function CreateContextClientTv(deviceInfo as object) as object
|
function CreateContextClientTv(deviceInfo as object, client as Innertube.ClientType) as object
|
||||||
|
tvClientVersion = INNERTUBE_TV_CLIENT_VERSION
|
||||||
|
if client = ClientType.TvDowngraded
|
||||||
|
tvClientVersion = INNERTUBE_TV_CLIENT_VERSION_DOWNGRADED
|
||||||
|
end if
|
||||||
return {
|
return {
|
||||||
"hl": GetCurrentLocale(deviceInfo)
|
"hl": GetCurrentLocale(deviceInfo)
|
||||||
"gl": GetContentRegion(deviceInfo)
|
"gl": GetContentRegion(deviceInfo)
|
||||||
@@ -163,7 +176,7 @@ namespace Innertube
|
|||||||
"deviceModel": INNERTUBE_TV_DEVICE_MODEL
|
"deviceModel": INNERTUBE_TV_DEVICE_MODEL
|
||||||
"userAgent": INNERTUBE_TV_USER_AGENT
|
"userAgent": INNERTUBE_TV_USER_AGENT
|
||||||
"clientName": "TVHTML5"
|
"clientName": "TVHTML5"
|
||||||
"clientVersion": INNERTUBE_TV_CLIENT_VERSION
|
"clientVersion": tvClientVersion
|
||||||
"osName": INNERTUBE_TV_OS_NAME
|
"osName": INNERTUBE_TV_OS_NAME
|
||||||
"osVersion": INNERTUBE_TV_OS_VERSION
|
"osVersion": INNERTUBE_TV_OS_VERSION
|
||||||
"originalUrl": "https://www.youtube.com/tv"
|
"originalUrl": "https://www.youtube.com/tv"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import "pkg:/components/Services/Innertube/ResolveUrlEndpoint.bs"
|
|||||||
import "pkg:/components/Services/Innertube/SearchEndpoint.bs"
|
import "pkg:/components/Services/Innertube/SearchEndpoint.bs"
|
||||||
import "pkg:/components/Services/Innertube/SearchFilters.bs"
|
import "pkg:/components/Services/Innertube/SearchFilters.bs"
|
||||||
import "pkg:/components/Services/Innertube/SubscriptionEndpoint.bs"
|
import "pkg:/components/Services/Innertube/SubscriptionEndpoint.bs"
|
||||||
|
import "pkg:/components/Services/Innertube/TvClientDowngradeExperiment.bs"
|
||||||
import "pkg:/source/services/HttpClient.bs"
|
import "pkg:/source/services/HttpClient.bs"
|
||||||
import "pkg:/source/utils/CancellationUtils.bs"
|
import "pkg:/source/utils/CancellationUtils.bs"
|
||||||
import "pkg:/source/utils/ObjectUtils.bs"
|
import "pkg:/source/utils/ObjectUtils.bs"
|
||||||
@@ -36,13 +37,18 @@ namespace InnertubeService
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
playerResponseJson = invalid
|
playerResponseJson = invalid
|
||||||
client = Innertube.ClientType.Tv
|
client = Innertube.Experiment.InitialPlayerClient()
|
||||||
totalPlayerRequests = 0
|
totalPlayerRequests = 0
|
||||||
|
triedReloadRefresh = false
|
||||||
|
downgradeRetryAttempted = false
|
||||||
|
downgradeRetryArm = invalid
|
||||||
|
downgradeOutcomeReported = false
|
||||||
while true
|
while true
|
||||||
' We shouldn't be making more than 2 requests:
|
' We shouldn't be making more than 3 requests:
|
||||||
' 1. Make request with TV client.
|
' 1. Make request with TV client.
|
||||||
' 2. Make request, but STS_MISMATCH error -> retry with new STS.
|
' 2. Make request, but STS_MISMATCH error -> retry with new STS.
|
||||||
if totalPlayerRequests >= 2
|
' 3. useServerDrivenAbr -> retry with control/treatment client version to recover format URLs.
|
||||||
|
if totalPlayerRequests >= 3
|
||||||
LogError("Too many player requests, aborting.")
|
LogError("Too many player requests, aborting.")
|
||||||
return {
|
return {
|
||||||
error: "Too many player requests"
|
error: "Too many player requests"
|
||||||
@@ -50,7 +56,7 @@ namespace InnertubeService
|
|||||||
end if
|
end if
|
||||||
totalPlayerRequests += 1
|
totalPlayerRequests += 1
|
||||||
playerRequest = Innertube.CreatePlayerRequest(client, options)
|
playerRequest = Innertube.CreatePlayerRequest(client, options)
|
||||||
if not StringUtils.IsNullOrEmpty(accessToken) and client = Innertube.ClientType.Tv
|
if not StringUtils.IsNullOrEmpty(accessToken) and (client = Innertube.ClientType.Tv or client = Innertube.ClientType.TvDowngraded)
|
||||||
playerRequest.Header("Authorization", "Bearer " + accessToken)
|
playerRequest.Header("Authorization", "Bearer " + accessToken)
|
||||||
end if
|
end if
|
||||||
playerRequest.Cancellation(cancellation)
|
playerRequest.Cancellation(cancellation)
|
||||||
@@ -67,6 +73,10 @@ namespace InnertubeService
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if not playerResponse.IsSuccess()
|
if not playerResponse.IsSuccess()
|
||||||
|
if downgradeRetryArm <> invalid and not downgradeOutcomeReported
|
||||||
|
downgradeOutcomeReported = true
|
||||||
|
Innertube.Experiment.ReportDowngradeOutcome(downgradeRetryArm, Innertube.Experiment.DowngradeOutcome.RetryFailed, videoId, playerRequest, playerResponse)
|
||||||
|
end if
|
||||||
parsedResponse = {
|
parsedResponse = {
|
||||||
error: playerResponse.ErrorMessage()
|
error: playerResponse.ErrorMessage()
|
||||||
}
|
}
|
||||||
@@ -76,6 +86,24 @@ namespace InnertubeService
|
|||||||
|
|
||||||
playerResponseJson = playerResponse.Json()
|
playerResponseJson = playerResponse.Json()
|
||||||
|
|
||||||
|
if not downgradeRetryAttempted
|
||||||
|
downgradePlan = Innertube.Experiment.PlanTvClientDowngradeRetry(playerResponseJson)
|
||||||
|
if downgradePlan <> invalid
|
||||||
|
downgradeRetryAttempted = true
|
||||||
|
downgradeRetryArm = downgradePlan.arm
|
||||||
|
client = downgradePlan.client
|
||||||
|
LogInfo("[DOWNGRADE-RETRY] trigger arm=", downgradeRetryArm, " client=", client, " videoId=", videoId)
|
||||||
|
continue while
|
||||||
|
end if
|
||||||
|
else if downgradeRetryArm <> invalid and not downgradeOutcomeReported
|
||||||
|
downgradeOutcomeReported = true
|
||||||
|
outcome = Innertube.Experiment.DowngradeOutcome.NotRecovered
|
||||||
|
if Innertube.Experiment.ResponseHasUsableAdaptive(playerResponseJson)
|
||||||
|
outcome = Innertube.Experiment.DowngradeOutcome.Recovered
|
||||||
|
end if
|
||||||
|
Innertube.Experiment.ReportDowngradeOutcome(downgradeRetryArm, outcome, videoId, playerRequest, playerResponse)
|
||||||
|
end if
|
||||||
|
|
||||||
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerRequest, playerResponse, client, cancellation)
|
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerRequest, playerResponse, client, cancellation)
|
||||||
|
|
||||||
if parsedResponse.error = invalid
|
if parsedResponse.error = invalid
|
||||||
@@ -86,6 +114,11 @@ namespace InnertubeService
|
|||||||
if parsedResponse.errorCode = "STS_MISMATCH"
|
if parsedResponse.errorCode = "STS_MISMATCH"
|
||||||
LogInfo("STS_MISMATCH error, retrying...")
|
LogInfo("STS_MISMATCH error, retrying...")
|
||||||
continue while
|
continue while
|
||||||
|
else if parsedResponse.errorCode = "RELOAD_PAGE" and not triedReloadRefresh
|
||||||
|
triedReloadRefresh = true
|
||||||
|
LogInfo("RELOAD_PAGE: clearing stale STS cache and retrying...")
|
||||||
|
DeleteFile("tmp:/sts_cache.json")
|
||||||
|
continue while
|
||||||
else if parsedResponse.errorCode = "MISSING_FORMAT_FIELD"
|
else if parsedResponse.errorCode = "MISSING_FORMAT_FIELD"
|
||||||
useServerDrivenAbr = `${ObjectUtils.Dig(playerResponseJson, ["playerConfig", "mediaCommonConfig", "useServerDrivenAbr"])}`
|
useServerDrivenAbr = `${ObjectUtils.Dig(playerResponseJson, ["playerConfig", "mediaCommonConfig", "useServerDrivenAbr"])}`
|
||||||
LogTelemetryEvent({
|
LogTelemetryEvent({
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ namespace Innertube
|
|||||||
"feedFilterChipBarRenderer": ParseFeedFilterChipBarRenderer
|
"feedFilterChipBarRenderer": ParseFeedFilterChipBarRenderer
|
||||||
"chipBarViewModel": ParseChipBarViewModel
|
"chipBarViewModel": ParseChipBarViewModel
|
||||||
"continuationItemRenderer": ParseContinuationItemRenderer
|
"continuationItemRenderer": ParseContinuationItemRenderer
|
||||||
|
"continuationItemViewModel": ParseContinuationItemViewModel
|
||||||
"appendContinuationItemsAction": ParseAppendContinuationItemsAction
|
"appendContinuationItemsAction": ParseAppendContinuationItemsAction
|
||||||
"reloadContinuationItemsCommand": ParseReloadContinuationItemsCommand
|
"reloadContinuationItemsCommand": ParseReloadContinuationItemsCommand
|
||||||
"gridContinuation": ParseGridContinuation
|
"gridContinuation": ParseGridContinuation
|
||||||
@@ -1850,6 +1851,19 @@ namespace Innertube
|
|||||||
return invalid
|
return invalid
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function ParseContinuationItemViewModel(nodeData as object, context as object) as object
|
||||||
|
if not StringUtils.IsNullOrEmpty(context.currentFeed.continuation)
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
|
continuation = ObjectUtils.Dig(nodeData, ["continuationCommand", "innertubeCommand", "continuationCommand", "token"])
|
||||||
|
if IsString(continuation)
|
||||||
|
context.currentFeed.continuation = continuation
|
||||||
|
end if
|
||||||
|
|
||||||
|
return invalid
|
||||||
|
end function
|
||||||
|
|
||||||
function ParseContinuationItemRenderer(nodeData as object, context as object) as object
|
function ParseContinuationItemRenderer(nodeData as object, context as object) as object
|
||||||
' In Playlists there are 2 continuation items:
|
' In Playlists there are 2 continuation items:
|
||||||
' - The first one (innermost) we encounter is the continuation for the next page of videos
|
' - The first one (innermost) we encounter is the continuation for the next page of videos
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ namespace Innertube
|
|||||||
accessToken = OptionUtils.Get(options, "accessToken")
|
accessToken = OptionUtils.Get(options, "accessToken")
|
||||||
cpn = InnertubeService.CreateClientPlaybackNonce()
|
cpn = InnertubeService.CreateClientPlaybackNonce()
|
||||||
|
|
||||||
useAccessToken = client = Innertube.ClientType.TV and not StringUtils.IsNullOrEmpty(accessToken)
|
useAccessToken = (client = Innertube.ClientType.Tv or client = Innertube.ClientType.TvDowngraded) and not StringUtils.IsNullOrEmpty(accessToken)
|
||||||
|
|
||||||
deviceInfo = CreateObject("roDeviceInfo")
|
deviceInfo = CreateObject("roDeviceInfo")
|
||||||
|
|
||||||
context = Innertube.CreateContext(client, deviceInfo, options)
|
context = Innertube.CreateContext(client, deviceInfo, options)
|
||||||
|
|
||||||
if client = Innertube.ClientType.TV
|
if client = Innertube.ClientType.Tv or client = Innertube.ClientType.TvDowngraded
|
||||||
referer = "https://www.youtube.com/tv#/watch?v=" + videoId
|
referer = "https://www.youtube.com/tv#/watch?v=" + videoId
|
||||||
else
|
else
|
||||||
referer = "https://www.youtube.com/watch?v=" + videoId
|
referer = "https://www.youtube.com/watch?v=" + videoId
|
||||||
@@ -77,6 +77,9 @@ namespace Innertube
|
|||||||
error = ParsePlayerResponseForError(payload, playerRequest)
|
error = ParsePlayerResponseForError(payload, playerRequest)
|
||||||
if error <> ""
|
if error <> ""
|
||||||
parsedResponse["error"] = error
|
parsedResponse["error"] = error
|
||||||
|
if PlayerResponseRequiresPageReload(payload)
|
||||||
|
parsedResponse["errorCode"] = "RELOAD_PAGE"
|
||||||
|
end if
|
||||||
return parsedResponse
|
return parsedResponse
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -99,7 +102,7 @@ namespace Innertube
|
|||||||
adaptiveFormats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"]))
|
adaptiveFormats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"]))
|
||||||
formats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "formats"]))
|
formats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "formats"]))
|
||||||
|
|
||||||
error = DecipherUrls(formats, adaptiveFormats, playerRequest.signatureTimestamp, cancellation)
|
error = DecipherUrls(formats, adaptiveFormats, playerRequest.signatureTimestamp, cancellation, client)
|
||||||
if error <> invalid
|
if error <> invalid
|
||||||
parsedResponse["error"] = error.error
|
parsedResponse["error"] = error.error
|
||||||
if error.DoesExist("errorCode")
|
if error.DoesExist("errorCode")
|
||||||
@@ -231,6 +234,11 @@ namespace Innertube
|
|||||||
return errorLines.Join(`\n`)
|
return errorLines.Join(`\n`)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function PlayerResponseRequiresPageReload(payload as object) as boolean
|
||||||
|
signal = ObjectUtils.Dig(payload, ["playabilityStatus", "errorScreen", "playerErrorMessageRenderer", "proceedButton", "buttonRenderer", "command", "signalAction", "signal"])
|
||||||
|
return IsString(signal) and signal = "RELOAD_PAGE"
|
||||||
|
end function
|
||||||
|
|
||||||
function ParseStoryboards(payload as object, lengthSeconds as integer) as object
|
function ParseStoryboards(payload as object, lengthSeconds as integer) as object
|
||||||
storyboard = ObjectUtils.Dig(payload, ["storyboards", "playerLiveStoryboardSpecRenderer", "spec"])
|
storyboard = ObjectUtils.Dig(payload, ["storyboards", "playerLiveStoryboardSpecRenderer", "spec"])
|
||||||
if IsString(storyboard)
|
if IsString(storyboard)
|
||||||
@@ -491,7 +499,7 @@ namespace Innertube
|
|||||||
return json["sts"]
|
return json["sts"]
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function DecipherUrls(formats as object, adaptiveFormats as object, signatureTimestamp as dynamic, cancellation as object) as object
|
function DecipherUrls(formats as object, adaptiveFormats as object, signatureTimestamp as dynamic, cancellation as object, client = invalid as dynamic) as object
|
||||||
if signatureTimestamp = invalid
|
if signatureTimestamp = invalid
|
||||||
' No need to decipher if signatureTimestamp is not available
|
' No need to decipher if signatureTimestamp is not available
|
||||||
return invalid
|
return invalid
|
||||||
@@ -573,7 +581,7 @@ namespace Innertube
|
|||||||
for i = 0 to decipheredFormats.Count() - 1
|
for i = 0 to decipheredFormats.Count() - 1
|
||||||
fmt = formats[i]
|
fmt = formats[i]
|
||||||
decipheredFmt = decipheredFormats[i]
|
decipheredFmt = decipheredFormats[i]
|
||||||
fmt["url"] = ResetUrlClientVersion(decipheredFmt["url"])
|
fmt["url"] = ResetUrlClientVersion(decipheredFmt["url"], client)
|
||||||
end for
|
end for
|
||||||
|
|
||||||
decipheredAdaptiveFormats = json["adaptiveFormats"]
|
decipheredAdaptiveFormats = json["adaptiveFormats"]
|
||||||
@@ -587,7 +595,7 @@ namespace Innertube
|
|||||||
for i = 0 to decipheredAdaptiveFormats.Count() - 1
|
for i = 0 to decipheredAdaptiveFormats.Count() - 1
|
||||||
fmt = adaptiveFormats[i]
|
fmt = adaptiveFormats[i]
|
||||||
decipheredFmt = decipheredAdaptiveFormats[i]
|
decipheredFmt = decipheredAdaptiveFormats[i]
|
||||||
fmt["url"] = ResetUrlClientVersion(decipheredFmt["url"])
|
fmt["url"] = ResetUrlClientVersion(decipheredFmt["url"], client)
|
||||||
end for
|
end for
|
||||||
return invalid
|
return invalid
|
||||||
end function
|
end function
|
||||||
@@ -595,7 +603,7 @@ namespace Innertube
|
|||||||
' YouTube.js sets cver to hardcoded values that might be different from
|
' YouTube.js sets cver to hardcoded values that might be different from
|
||||||
' What's used in Playlet. There's no indication that this makes a difference,
|
' What's used in Playlet. There's no indication that this makes a difference,
|
||||||
' but it makes sense to keep it consistent.
|
' but it makes sense to keep it consistent.
|
||||||
function ResetUrlClientVersion(url as dynamic) as dynamic
|
function ResetUrlClientVersion(url as dynamic, requestClient = invalid as dynamic) as dynamic
|
||||||
if StringUtils.IsNullOrEmpty(url)
|
if StringUtils.IsNullOrEmpty(url)
|
||||||
return url
|
return url
|
||||||
end if
|
end if
|
||||||
@@ -603,7 +611,11 @@ namespace Innertube
|
|||||||
queryComponents = UrlUtils.ParseQueryComponents(url)
|
queryComponents = UrlUtils.ParseQueryComponents(url)
|
||||||
client = ValidString(queryComponents["c"])
|
client = ValidString(queryComponents["c"])
|
||||||
if client = "TVHTML5"
|
if client = "TVHTML5"
|
||||||
|
if requestClient = Innertube.ClientType.TvDowngraded
|
||||||
|
queryComponents["cver"] = INNERTUBE_TV_CLIENT_VERSION_DOWNGRADED
|
||||||
|
else
|
||||||
queryComponents["cver"] = INNERTUBE_TV_CLIENT_VERSION
|
queryComponents["cver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||||
|
end if
|
||||||
else if client = "IOS"
|
else if client = "IOS"
|
||||||
queryComponents["cver"] = INNERTUBE_IOS_CLIENT_VERSION
|
queryComponents["cver"] = INNERTUBE_IOS_CLIENT_VERSION
|
||||||
else if client = "WEB"
|
else if client = "WEB"
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
' TV client-version downgrade experiment (recover VOD per-format URLs withheld under useServerDrivenAbr).
|
||||||
|
' Self-contained so it can be ripped out wholesale once the experiment concludes: delete this file and the
|
||||||
|
' call sites in InnertubeService.GetVideoMetadata (InitialPlayerClient, PlanTvClientDowngradeRetry,
|
||||||
|
' ResponseHasUsableAdaptive, ReportDowngradeOutcome) plus the downgradeRetry* / downgradeOutcomeReported locals,
|
||||||
|
' then drop ClientType.TvDowngraded + its branches if the downgrade isn't kept.
|
||||||
|
'
|
||||||
|
' DEBUG-only (compiled out of prod by #if DEBUG):
|
||||||
|
' DEBUG_FORCE_DOWNGRADED_CLIENT - downgrade the FIRST player request too, not just the retry.
|
||||||
|
' DEBUG_FORCE_DOWNGRADE_RETRY - force the downgrade-retry path on every non-live VOD.
|
||||||
|
#const DEBUG_FORCE_DOWNGRADE_RETRY = false
|
||||||
|
#const DEBUG_FORCE_DOWNGRADED_CLIENT = false
|
||||||
|
|
||||||
|
import "pkg:/components/Services/Innertube/Context.bs"
|
||||||
|
import "pkg:/source/utils/ObjectUtils.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
|
||||||
|
namespace Innertube.Experiment
|
||||||
|
|
||||||
|
enum DowngradeArm
|
||||||
|
Control = "control_7x"
|
||||||
|
Treatment = "treatment_5x"
|
||||||
|
end enum
|
||||||
|
|
||||||
|
enum DowngradeOutcome
|
||||||
|
Recovered = "recovered"
|
||||||
|
NotRecovered = "not_recovered"
|
||||||
|
RetryFailed = "retry_failed"
|
||||||
|
end enum
|
||||||
|
|
||||||
|
' Client for the first player request: Tv normally, TvDowngraded only under the debug flag.
|
||||||
|
function InitialPlayerClient() as Innertube.ClientType
|
||||||
|
#if DEBUG
|
||||||
|
#if DEBUG_FORCE_DOWNGRADED_CLIENT
|
||||||
|
return Innertube.ClientType.TvDowngraded
|
||||||
|
#end if
|
||||||
|
#end if
|
||||||
|
return Innertube.ClientType.Tv
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Plan a one-shot retry only when the player signals useServerDrivenAbr AND no adaptive format has a usable
|
||||||
|
' URL (the stuck-at-360p state - SABR can be signaled while URLs are still present, in which case we keep them).
|
||||||
|
' Coin-flip control (same version - intermittency baseline) vs treatment (downgrade - the fix).
|
||||||
|
' Returns invalid otherwise (URLs present, not SABR, live, or no streamingData).
|
||||||
|
function PlanTvClientDowngradeRetry(playerResponseJson as object) as object
|
||||||
|
if not IsAssociativeArray(ObjectUtils.Dig(playerResponseJson, ["streamingData"]))
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
if ValidBool(ObjectUtils.Dig(playerResponseJson, ["videoDetails", "isLive"]))
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
serverDrivenAbr = ValidBool(ObjectUtils.Dig(playerResponseJson, ["playerConfig", "mediaCommonConfig", "useServerDrivenAbr"]))
|
||||||
|
shouldRetry = serverDrivenAbr and not ResponseHasUsableAdaptive(playerResponseJson)
|
||||||
|
#if DEBUG
|
||||||
|
#if DEBUG_FORCE_DOWNGRADE_RETRY
|
||||||
|
shouldRetry = true
|
||||||
|
#end if
|
||||||
|
#end if
|
||||||
|
if not shouldRetry
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
arm = DowngradeArm.Control
|
||||||
|
retryClient = Innertube.ClientType.Tv
|
||||||
|
if Rnd(0) < 0.5
|
||||||
|
arm = DowngradeArm.Treatment
|
||||||
|
retryClient = Innertube.ClientType.TvDowngraded
|
||||||
|
end if
|
||||||
|
return {
|
||||||
|
arm: arm
|
||||||
|
client: retryClient
|
||||||
|
}
|
||||||
|
end function
|
||||||
|
|
||||||
|
' True if any adaptive format carries a playable field (url / signatureCipher / cipher).
|
||||||
|
function ResponseHasUsableAdaptive(playerResponseJson as object) as boolean
|
||||||
|
adaptiveFormats = ObjectUtils.Dig(playerResponseJson, ["streamingData", "adaptiveFormats"])
|
||||||
|
if not IsArray(adaptiveFormats)
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
for each format in adaptiveFormats
|
||||||
|
if IsAssociativeArray(format) and (not StringUtils.IsNullOrEmpty(format["url"]) or not StringUtils.IsNullOrEmpty(format["signatureCipher"]) or not StringUtils.IsNullOrEmpty(format["cipher"]))
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
return false
|
||||||
|
end function
|
||||||
|
|
||||||
|
' One telemetry event per outcome; fingerprint splits GlitchTip into 6 buckets:
|
||||||
|
' {control_7x, treatment_5x} x {recovered, not_recovered, retry_failed}.
|
||||||
|
' Attaches the retry request + response so each bucket is diagnosable, not just a count.
|
||||||
|
function ReportDowngradeOutcome(arm as Innertube.Experiment.DowngradeArm, outcome as Innertube.Experiment.DowngradeOutcome, videoId as string, playerRequest as object, playerResponse as object) as void
|
||||||
|
LogInfo("[DOWNGRADE-RETRY] outcome arm=", arm, " outcome=", outcome, " videoId=", videoId)
|
||||||
|
LogTelemetryEvent({
|
||||||
|
level: "warning"
|
||||||
|
message: "[DOWNGRADE-RETRY] arm=" + arm + " outcome=" + outcome
|
||||||
|
fingerprint: ["downgrade-retry", arm, outcome]
|
||||||
|
attachments: [{
|
||||||
|
filename: "request.txt"
|
||||||
|
content_type: "text/plain"
|
||||||
|
data: playerRequest.ToCurlCommand()
|
||||||
|
}, {
|
||||||
|
filename: "response.json"
|
||||||
|
content_type: "application/json"
|
||||||
|
data: playerResponse.Text()
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
end function
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
#const DEBUG_THROW_ON_UNKNOWN_EXIT_CODE = true
|
||||||
|
|
||||||
|
import "pkg:/components/Telemetry/Sentry.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
|
function ReportLastExitCrash() as void
|
||||||
|
scene = m.top.getScene()
|
||||||
|
if scene = invalid or not scene.hasField("lastExitInfo")
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
lastExitInfo = scene.lastExitInfo
|
||||||
|
scene.lastExitInfo = invalid
|
||||||
|
if not IsAssociativeArray(lastExitInfo)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
crashExitCodes = {
|
||||||
|
"EXIT_BRIGHTSCRIPT_CRASH": true
|
||||||
|
"EXIT_BRIGHTSCRIPT_STOP": true
|
||||||
|
"EXIT_BRIGHTSCRIPT_UNK_FUNC": true
|
||||||
|
"EXIT_BRIGHTSCRIPT_TIMEOUT": true
|
||||||
|
"EXIT_OUT_OF_MEMORY": true
|
||||||
|
"EXIT_CHANNEL_MEM_LIMIT_FG": true
|
||||||
|
"EXIT_CHANNEL_MEM_LIMIT_BG": true
|
||||||
|
"EXIT_SYSTEM_KILL": true
|
||||||
|
"EXIT_GRAPHICS_NOT_RELEASED": true
|
||||||
|
"EXIT_DECODER_NOT_RELEASED": true
|
||||||
|
"EXIT_RUNNING_AFTER_SUSPEND": true
|
||||||
|
"EXIT_NOT_RESUMED": true
|
||||||
|
"EXIT_SIGNAL_TIMEOUT": true
|
||||||
|
"EXIT_APP_ERROR": true
|
||||||
|
"EXIT_UNKNOWN": false
|
||||||
|
"EXIT_POWER_MODE": false
|
||||||
|
"EXIT_DIAL_DELETE": false
|
||||||
|
"EXIT_IDLE_AUTO_EXIT": false
|
||||||
|
"EXIT_USER_KILL": false
|
||||||
|
"EXIT_USER_NAV": false
|
||||||
|
"EXIT_AM_LOWRESOURCE": false
|
||||||
|
"EXIT_UNLOADED": false
|
||||||
|
"EXIT_GUEST_MODE_ENABLED": false
|
||||||
|
"EXIT_GUEST_MODE_DISABLED": false
|
||||||
|
"EXIT_GUEST_CHECKOUT": false
|
||||||
|
"EXIT_OS_UPDATE": false
|
||||||
|
"EXIT_CHANNEL_UPDATE": false
|
||||||
|
"EXIT_CHANNEL_SIDELOAD": false
|
||||||
|
"EXIT_CHANNEL_RESTART": false
|
||||||
|
"EXIT_TILE_HIDDEN": false
|
||||||
|
"EXIT_SETTINGS_UPDATE": false
|
||||||
|
"EXIT_ADDON_DEPENDENCY": false
|
||||||
|
"EXIT_SOFTFAIL": false
|
||||||
|
}
|
||||||
|
exitCode = ValidString(lastExitInfo.exit_code)
|
||||||
|
|
||||||
|
#if DEBUG_THROW_ON_UNKNOWN_EXIT_CODE
|
||||||
|
#if DEBUG
|
||||||
|
if not crashExitCodes.DoesExist(exitCode)
|
||||||
|
throw "Unhandled exit code: " + exitCode
|
||||||
|
end if
|
||||||
|
#end if
|
||||||
|
#end if
|
||||||
|
|
||||||
|
if crashExitCodes[exitCode] = false
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
message = `[FATAL][LastExit] App crashed: ${exitCode}`
|
||||||
|
for each key in lastExitInfo
|
||||||
|
message += `\n${key}: ${ToString(lastExitInfo[key])}`
|
||||||
|
end for
|
||||||
|
message = RedactAuthHeaders(message)
|
||||||
|
|
||||||
|
Sentry.SendEvents([{
|
||||||
|
level: "fatal"
|
||||||
|
message: message
|
||||||
|
timestamp: ValidString(lastExitInfo.timestamp)
|
||||||
|
fingerprint: [exitCode]
|
||||||
|
release: m.release
|
||||||
|
dist: m.dist
|
||||||
|
tags: m.tags
|
||||||
|
userId: m.userId
|
||||||
|
}])
|
||||||
|
end function
|
||||||
|
|
||||||
|
function RedactAuthHeaders(text as string) as string
|
||||||
|
authRegex = /Authorization: [^\r\n]*/i
|
||||||
|
matches = authRegex.MatchAll(text)
|
||||||
|
for each match in matches
|
||||||
|
text = text.Replace(match[0], "Authorization: <REDACTED>")
|
||||||
|
end for
|
||||||
|
return text
|
||||||
|
end function
|
||||||
@@ -67,14 +67,13 @@ namespace Sentry
|
|||||||
hasAttachments = IsArray(event.attachments) and event.attachments.Count() > 0
|
hasAttachments = IsArray(event.attachments) and event.attachments.Count() > 0
|
||||||
|
|
||||||
if (not SUPPORTS_ATTACHMENTS) and hasAttachments
|
if (not SUPPORTS_ATTACHMENTS) and hasAttachments
|
||||||
message += `\nAttachments: (${event.attachments.Count()} files)`
|
extra = {}
|
||||||
for each attachment in event.attachments
|
for each attachment in event.attachments
|
||||||
message += `\nAttachment: ${attachment.filename} (${attachment.content_type})\n${attachment.data}`
|
extra[attachment.filename] = `content_type:${attachment.content_type}\n${attachment.data}`
|
||||||
end for
|
end for
|
||||||
message += `\nEnd of attachments.`
|
eventPayload.extra = extra
|
||||||
end if
|
end if
|
||||||
|
|
||||||
' TODO:P1 compress if message is larger than 8192
|
|
||||||
eventPayload.logentry = {
|
eventPayload.logentry = {
|
||||||
formatted: message
|
formatted: message
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#const SUPPORTS_BATCHING = false
|
#const SUPPORTS_BATCHING = false
|
||||||
|
|
||||||
|
import "pkg:/components/Telemetry/LastExitCrash.bs"
|
||||||
import "pkg:/components/Telemetry/Sentry.bs"
|
import "pkg:/components/Telemetry/Sentry.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
@@ -47,6 +48,8 @@ function TelemetryLoop() as void
|
|||||||
m.dist = GetDist(m.tags)
|
m.dist = GetDist(m.tags)
|
||||||
m.userId = GetUserId()
|
m.userId = GetUserId()
|
||||||
|
|
||||||
|
ReportLastExitCrash()
|
||||||
|
|
||||||
m.top.observeField("LogInfo", msgPort)
|
m.top.observeField("LogInfo", msgPort)
|
||||||
m.top.observeField("LogWarn", msgPort)
|
m.top.observeField("LogWarn", msgPort)
|
||||||
m.top.observeField("LogError", msgPort)
|
m.top.observeField("LogError", msgPort)
|
||||||
|
|||||||
@@ -10,6 +10,27 @@ import "pkg:/source/utils/Types.bs"
|
|||||||
' playback; when the player asks for them the Await is short/instant. Small on
|
' playback; when the player asks for them the Await is short/instant. Small on
|
||||||
' purpose to bound concurrent roUrlTransfers (x2 representations).
|
' purpose to bound concurrent roUrlTransfers (x2 representations).
|
||||||
const LIVE_PREFETCH_SEGMENTS = 2
|
const LIVE_PREFETCH_SEGMENTS = 2
|
||||||
|
' Bounded retry of transient segment failures before surfacing a 502 (one 502 on an
|
||||||
|
' init segment kills that bitrate). Retried: 204 (sq past the live edge), reset/error
|
||||||
|
' (-7/-10001), 5xx. Not retried: timeout (status 0 = slow/hung; a refetch would abandon
|
||||||
|
' a progressing download) and 4xx (signature/availability). Per-attempt timeout left at
|
||||||
|
' HttpClient's default; the Roku Video node's ~30s segment timeout bounds the freeze.
|
||||||
|
const LIVE_SEG_MAX_ATTEMPTS = 3
|
||||||
|
' Pause between attempts only on an empty (204) fragment (not yet produced), so the
|
||||||
|
' refetch doesn't busy-loop the edge. Small: the web server is single-threaded.
|
||||||
|
const LIVE_SEG_RETRY_BACKOFF_MS = 300
|
||||||
|
|
||||||
|
' Why a live-segment fetch failed. The string values double as the telemetry message
|
||||||
|
' and fingerprint (see ReportSegmentFailure), so they must stay stable - changing one
|
||||||
|
' forks its Bugsink issue and orphans the history.
|
||||||
|
enum LiveSegFailure
|
||||||
|
NoFormatUrl = "no live format url"
|
||||||
|
FormatsNotArray = "adaptiveFormats not an array"
|
||||||
|
FetchFailed = "fragment fetch failed"
|
||||||
|
EmptyFragment = "empty fragment file"
|
||||||
|
NoMoov = "no moov in fragment"
|
||||||
|
NoMoof = "no moof in fragment"
|
||||||
|
end enum
|
||||||
|
|
||||||
namespace Http
|
namespace Http
|
||||||
|
|
||||||
@@ -58,6 +79,13 @@ namespace Http
|
|||||||
' so they don't leak until the next video change.
|
' so they don't leak until the next video change.
|
||||||
m.lastVideoItag = invalid
|
m.lastVideoItag = invalid
|
||||||
m.lastAudioItag = invalid
|
m.lastAudioItag = invalid
|
||||||
|
' itag -> transformed init bytes (ftyp+moov). moov is constant per
|
||||||
|
' representation, so fetch once and serve later init requests from memory.
|
||||||
|
' Cleared per video in RebuildLiveCache.
|
||||||
|
m.cachedInit = {}
|
||||||
|
' Highest native sq requested; sources the init from a current fragment (the
|
||||||
|
' load-time live edge ages out of the DVR window over a long session).
|
||||||
|
m.lastSeenSq = 0
|
||||||
end function
|
end function
|
||||||
|
|
||||||
' Returns the cached metadata AA for video id `v`, digging the videoQueue
|
' Returns the cached metadata AA for video id `v`, digging the videoQueue
|
||||||
@@ -257,30 +285,38 @@ namespace Http
|
|||||||
baseUrl = m.cachedUrls[itag]
|
baseUrl = m.cachedUrls[itag]
|
||||||
if StringUtils.IsNullOrEmpty(baseUrl)
|
if StringUtils.IsNullOrEmpty(baseUrl)
|
||||||
LogErrorNoTelemetry("[LIVE-SEG] no live format url for v:", v, "itag:", itag, "-> 404")
|
LogErrorNoTelemetry("[LIVE-SEG] no live format url for v:", v, "itag:", itag, "-> 404")
|
||||||
m.ReportSegmentFailure("no live format url", { v: v, itag: itag, sq: sq })
|
m.ReportSegmentFailure(LiveSegFailure.NoFormatUrl, { v: v, itag: itag, sq: sq })
|
||||||
response.Default(404, "No live format url for itag " + itag)
|
response.Default(404, "No live format url for itag " + itag)
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if sq = "init"
|
if sq = "init"
|
||||||
' Init segment: ftyp+moov. We must NOT use fragment 0 - for a
|
' ftyp+moov, served from the per-itag cache after the first fetch.
|
||||||
' long-running live stream (e.g. a 24/7 channel up for weeks) sq=0 is
|
output = m.cachedInit[itag]
|
||||||
' far outside the DVR window and googlevideo 404s it. Every live
|
if output = invalid
|
||||||
' fragment is self-initializing with an identical moov (constant
|
' Source from a current fragment: sq=0 is outside the DVR window (404)
|
||||||
' codec config), so we source the init from the live-edge fragment
|
' and the load-time edge ages out, so prefer lastSeenSq; fall back to
|
||||||
' (cachedInitSeqnum), which is always within the DVR window.
|
' the load-time seqnum only before any media segment is served.
|
||||||
output = m.AwaitTransformedSegment(m.StartSegmentFetch(baseUrl, m.cachedInitSeqnum, v, itag), true)
|
initSq = m.cachedInitSeqnum
|
||||||
|
if m.lastSeenSq > 0
|
||||||
|
initSq = m.lastSeenSq
|
||||||
|
end if
|
||||||
|
output = m.AwaitSegmentWithRetry(baseUrl, initSq, v, itag, true, invalid)
|
||||||
if output = invalid
|
if output = invalid
|
||||||
' Root-cause telemetry already emitted by AwaitTransformedSegment.
|
|
||||||
LogErrorNoTelemetry("[LIVE-SEG] INIT fetch failed v:", v, "itag:", itag, "-> 502")
|
LogErrorNoTelemetry("[LIVE-SEG] INIT fetch failed v:", v, "itag:", itag, "-> 502")
|
||||||
response.Default(502, "Failed to fetch live init segment")
|
response.Default(502, "Failed to fetch live init segment")
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
m.cachedInit[itag] = output
|
||||||
|
end if
|
||||||
else
|
else
|
||||||
' Media DASH segment = one native YouTube fragment, reduced to moof+mdat
|
' Media DASH segment = one native YouTube fragment, reduced to moof+mdat
|
||||||
' so Roku reads the init segment only once. The manifest addresses the
|
' so Roku reads the init segment only once. The manifest addresses the
|
||||||
' proxy 1:1, so the DASH segment number is the native sq.
|
' proxy 1:1, so the DASH segment number is the native sq.
|
||||||
nativeSq = sq.ToInt()
|
nativeSq = sq.ToInt()
|
||||||
|
if nativeSq > m.lastSeenSq
|
||||||
|
m.lastSeenSq = nativeSq
|
||||||
|
end if
|
||||||
|
|
||||||
' Representation switch (ABR video / audio track): the previous itag of
|
' Representation switch (ABR video / audio track): the previous itag of
|
||||||
' this kind stops being requested, so evict its warmed fragments now -
|
' this kind stops being requested, so evict its warmed fragments now -
|
||||||
@@ -306,9 +342,8 @@ namespace Http
|
|||||||
m.PrefetchAhead(baseUrl, v, itag, nativeSq, LIVE_PREFETCH_SEGMENTS)
|
m.PrefetchAhead(baseUrl, v, itag, nativeSq, LIVE_PREFETCH_SEGMENTS)
|
||||||
m.EvictPrefetchOutside(itag, nativeSq + 1, nativeSq + LIVE_PREFETCH_SEGMENTS)
|
m.EvictPrefetchOutside(itag, nativeSq + 1, nativeSq + LIVE_PREFETCH_SEGMENTS)
|
||||||
|
|
||||||
output = m.AwaitTransformedSegment(entry, false)
|
output = m.AwaitSegmentWithRetry(baseUrl, nativeSq, v, itag, false, entry)
|
||||||
if output = invalid
|
if output = invalid
|
||||||
' Root-cause telemetry already emitted by AwaitTransformedSegment.
|
|
||||||
LogErrorNoTelemetry("[LIVE-SEG] media fragment failed v:", v, "itag:", itag, "sq:", nativeSq, "-> 502")
|
LogErrorNoTelemetry("[LIVE-SEG] media fragment failed v:", v, "itag:", itag, "sq:", nativeSq, "-> 502")
|
||||||
response.Default(502, "Failed to fetch live media segment")
|
response.Default(502, "Failed to fetch live media segment")
|
||||||
return true
|
return true
|
||||||
@@ -338,6 +373,9 @@ namespace Http
|
|||||||
m.CleanupTempSegments()
|
m.CleanupTempSegments()
|
||||||
' Re-arm the per-video telemetry dedupe (see ReportSegmentFailure).
|
' Re-arm the per-video telemetry dedupe (see ReportSegmentFailure).
|
||||||
m.reportedFailures = {}
|
m.reportedFailures = {}
|
||||||
|
' Init bytes and the sq high-water mark belong to the previous video.
|
||||||
|
m.cachedInit = {}
|
||||||
|
m.lastSeenSq = 0
|
||||||
|
|
||||||
urls = {}
|
urls = {}
|
||||||
types = {}
|
types = {}
|
||||||
@@ -355,7 +393,7 @@ namespace Http
|
|||||||
end for
|
end for
|
||||||
else
|
else
|
||||||
LogErrorNoTelemetry("[LIVE-SEG] RebuildLiveCache: adaptiveFormats not an array for v:", metadata.videoId)
|
LogErrorNoTelemetry("[LIVE-SEG] RebuildLiveCache: adaptiveFormats not an array for v:", metadata.videoId)
|
||||||
m.ReportSegmentFailure("adaptiveFormats not an array", { v: ValidString(metadata.videoId) })
|
m.ReportSegmentFailure(LiveSegFailure.FormatsNotArray, { v: ValidString(metadata.videoId) })
|
||||||
end if
|
end if
|
||||||
|
|
||||||
m.cachedUrls = urls
|
m.cachedUrls = urls
|
||||||
@@ -475,22 +513,65 @@ namespace Http
|
|||||||
DeleteFile(entry.tmpPath)
|
DeleteFile(entry.tmpPath)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
' Await a fetch started by StartSegmentFetch and return just the bytes Roku
|
' Await `entry` (invalid -> fetch from scratch), transform to the bytes Roku
|
||||||
' needs:
|
' needs (wantInit: true -> ftyp+moov, false -> moof+mdat), and retry transient
|
||||||
' wantInit = true -> ftyp+moov (init segment)
|
' failures up to LIVE_SEG_MAX_ATTEMPTS before giving up (invalid). Each retry
|
||||||
' wantInit = false -> moof+mdat (media segment)
|
' discards the entry and starts a fresh fetch for the same sq - rides an edge
|
||||||
' Reads only the required byte range from the temp file and always deletes
|
' blip AND un-poisons a prefetched 204 (warmed before the edge produced it).
|
||||||
' it. Returns invalid on failure.
|
' Telemetry fires once, on give-up.
|
||||||
function AwaitTransformedSegment(entry as object, wantInit as boolean) as dynamic
|
function AwaitSegmentWithRetry(baseUrl as string, sq as integer, v as string, itag as string, wantInit as boolean, entry as object) as dynamic
|
||||||
|
if entry = invalid
|
||||||
|
entry = m.StartSegmentFetch(baseUrl, sq, v, itag)
|
||||||
|
end if
|
||||||
|
|
||||||
|
attempt = 1
|
||||||
|
while true
|
||||||
|
result = m.AttemptSegment(entry, wantInit)
|
||||||
|
if result.ok
|
||||||
|
return result.bytes
|
||||||
|
end if
|
||||||
|
|
||||||
|
if (not result.retryable) or attempt >= LIVE_SEG_MAX_ATTEMPTS
|
||||||
|
m.ReportSegmentFailure(result.reason, { v: v, itag: itag, sq: sq, segUrl: entry.segUrl, response: result.response })
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
|
' Empty (204) = sq not produced yet: drop the warmed siblings (also fetched
|
||||||
|
' too early) so they refetch fresh, and pause so the refetch doesn't
|
||||||
|
' busy-loop the edge. Network/5xx already spent time in the await -> no pause.
|
||||||
|
if result.reason = LiveSegFailure.EmptyFragment
|
||||||
|
if not wantInit
|
||||||
|
m.EvictPrefetchItag(itag)
|
||||||
|
end if
|
||||||
|
sleep(LIVE_SEG_RETRY_BACKOFF_MS)
|
||||||
|
end if
|
||||||
|
LogWarnNoTelemetry("[LIVE-SEG] retry sq", sq, "itag", itag, "(", result.reason, ") attempt", attempt + 1, "of", LIVE_SEG_MAX_ATTEMPTS)
|
||||||
|
|
||||||
|
attempt += 1
|
||||||
|
entry = m.StartSegmentFetch(baseUrl, sq, v, itag)
|
||||||
|
end while
|
||||||
|
|
||||||
|
return invalid
|
||||||
|
end function
|
||||||
|
|
||||||
|
' One fetch+transform attempt. Reads only the needed byte range from the temp
|
||||||
|
' file and always deletes it. Returns:
|
||||||
|
' { ok: true, bytes } - the transformed segment bytes
|
||||||
|
' { ok: false, retryable, reason, response } - failed; `retryable` separates
|
||||||
|
' fast transient errors (204/empty, reset/-10001, 5xx) from ones a refetch
|
||||||
|
' won't fix: a plain timeout (slow/hung), 4xx, or a malformed box.
|
||||||
|
function AttemptSegment(entry as object, wantInit as boolean) as object
|
||||||
tmpPath = entry.tmpPath
|
tmpPath = entry.tmpPath
|
||||||
sq = entry.sq
|
sq = entry.sq
|
||||||
|
|
||||||
response = entry.req.Await()
|
response = entry.req.Await()
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
LogErrorNoTelemetry("[LIVE-SEG] fetch sq", sq, "failed:", response.StatusCode())
|
status = response.StatusCode()
|
||||||
m.ReportSegmentFailure("fragment fetch failed", { v: entry.v, itag: entry.itag, sq: sq, segUrl: entry.segUrl, response: response })
|
LogErrorNoTelemetry("[LIVE-SEG] fetch sq", sq, "failed:", status)
|
||||||
DeleteFile(tmpPath)
|
DeleteFile(tmpPath)
|
||||||
return invalid
|
' status<0 = active error event (reset/-10001), 5xx = server error: both
|
||||||
|
' transient -> retried. status 0 = timeout (slow/hung) -> not retried.
|
||||||
|
return { ok: false, retryable: status < 0 or status >= 500, reason: LiveSegFailure.FetchFailed, response: response }
|
||||||
end if
|
end if
|
||||||
|
|
||||||
stat = m.fs.Stat(tmpPath)
|
stat = m.fs.Stat(tmpPath)
|
||||||
@@ -499,10 +580,9 @@ namespace Http
|
|||||||
fileLen = ValidInt(stat.size)
|
fileLen = ValidInt(stat.size)
|
||||||
end if
|
end if
|
||||||
if fileLen <= 0
|
if fileLen <= 0
|
||||||
LogErrorNoTelemetry("[LIVE-SEG] fetch sq", sq, "empty file")
|
LogErrorNoTelemetry("[LIVE-SEG] fetch sq", sq, "empty file (status", response.StatusCode(), ")")
|
||||||
m.ReportSegmentFailure("empty fragment file", { v: entry.v, itag: entry.itag, sq: sq, segUrl: entry.segUrl, response: response })
|
|
||||||
DeleteFile(tmpPath)
|
DeleteFile(tmpPath)
|
||||||
return invalid
|
return { ok: false, retryable: true, reason: LiveSegFailure.EmptyFragment, response: response }
|
||||||
end if
|
end if
|
||||||
|
|
||||||
boxes = m.LocateBoxes(tmpPath, fileLen)
|
boxes = m.LocateBoxes(tmpPath, fileLen)
|
||||||
@@ -511,23 +591,21 @@ namespace Http
|
|||||||
if wantInit
|
if wantInit
|
||||||
if boxes.moovEnd <= 0 or boxes.moovEnd > fileLen
|
if boxes.moovEnd <= 0 or boxes.moovEnd > fileLen
|
||||||
LogErrorNoTelemetry("[LIVE-SEG] no moov in fragment sq", sq, "(moovEnd:", boxes.moovEnd, ")")
|
LogErrorNoTelemetry("[LIVE-SEG] no moov in fragment sq", sq, "(moovEnd:", boxes.moovEnd, ")")
|
||||||
m.ReportSegmentFailure("no moov in fragment", { v: entry.v, itag: entry.itag, sq: sq, segUrl: entry.segUrl, response: response })
|
|
||||||
DeleteFile(tmpPath)
|
DeleteFile(tmpPath)
|
||||||
return invalid
|
return { ok: false, retryable: false, reason: LiveSegFailure.NoMoov, response: response }
|
||||||
end if
|
end if
|
||||||
out.ReadFile(tmpPath, 0, boxes.moovEnd)
|
out.ReadFile(tmpPath, 0, boxes.moovEnd)
|
||||||
else
|
else
|
||||||
if boxes.moofStart <= 0 or boxes.moofStart >= fileLen
|
if boxes.moofStart <= 0 or boxes.moofStart >= fileLen
|
||||||
LogErrorNoTelemetry("[LIVE-SEG] no moof in fragment sq", sq, "(moofStart:", boxes.moofStart, ")")
|
LogErrorNoTelemetry("[LIVE-SEG] no moof in fragment sq", sq, "(moofStart:", boxes.moofStart, ")")
|
||||||
m.ReportSegmentFailure("no moof in fragment", { v: entry.v, itag: entry.itag, sq: sq, segUrl: entry.segUrl, response: response })
|
|
||||||
DeleteFile(tmpPath)
|
DeleteFile(tmpPath)
|
||||||
return invalid
|
return { ok: false, retryable: false, reason: LiveSegFailure.NoMoof, response: response }
|
||||||
end if
|
end if
|
||||||
out.ReadFile(tmpPath, boxes.moofStart, fileLen - boxes.moofStart)
|
out.ReadFile(tmpPath, boxes.moofStart, fileLen - boxes.moofStart)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
DeleteFile(tmpPath)
|
DeleteFile(tmpPath)
|
||||||
return out
|
return { ok: true, bytes: out }
|
||||||
end function
|
end function
|
||||||
|
|
||||||
' Read the leading boxes of a fragment temp file and return moov/moof offsets.
|
' Read the leading boxes of a fragment temp file and return moov/moof offsets.
|
||||||
@@ -584,7 +662,7 @@ namespace Http
|
|||||||
' capture a transient blip and a later persistent failure separately, without
|
' capture a transient blip and a later persistent failure separately, without
|
||||||
' flooding identical failures every few seconds (Sentry quota). Re-armed per
|
' flooding identical failures every few seconds (Sentry quota). Re-armed per
|
||||||
' video in RebuildLiveCache.
|
' video in RebuildLiveCache.
|
||||||
function ReportSegmentFailure(reason as string, info as object) as void
|
function ReportSegmentFailure(reason as LiveSegFailure, info as object) as void
|
||||||
statusText = "n/a"
|
statusText = "n/a"
|
||||||
errorMessage = ""
|
errorMessage = ""
|
||||||
response = info.response
|
response = info.response
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title=PlayletLib
|
|||||||
# Do not update version manually, it is auto updated from package.json
|
# Do not update version manually, it is auto updated from package.json
|
||||||
major_version=0
|
major_version=0
|
||||||
minor_version=47
|
minor_version=47
|
||||||
build_version=00001
|
build_version=00002
|
||||||
|
|
||||||
ui_resolutions=hd
|
ui_resolutions=hd
|
||||||
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-web",
|
"name": "playlet-web",
|
||||||
"version": "0.47.1",
|
"version": "0.47.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-web",
|
"name": "playlet-web",
|
||||||
"version": "0.47.1",
|
"version": "0.47.2",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
||||||
"@tailwindcss/postcss": "^4.3.1",
|
"@tailwindcss/postcss": "^4.3.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-web",
|
"name": "playlet-web",
|
||||||
"version": "0.47.1",
|
"version": "0.47.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
Reference in new issue
Block a user