Auto switch backend if there's no server

This commit is contained in:
Brahim Hadriche committed 2026-10-05 20:58:22 -04:00
1 parent 6c9c87ce50
commit 2dbd5840c0
4 files changed
+38

No files matched your search

@@ -1,4 +1,5 @@
import "pkg:/components/ContentNode/ProfileContentAuthTokenUtils.bs"
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Services/Innertube/InnertubeService.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/source/utils/CancellationUtils.bs"
@@ -30,6 +31,10 @@ function ExecuteJob() as void
return
end if
if preferencesNode["backend.selected"] = "invidious" and StringUtils.IsNullOrEmpty(preferencesNode["invidious.instance"])
SwitchBackendToPlaylet(preferencesNode)
end if
DeleteFile("cachefs:/last_generated_dash.xml")
DeleteFile("cachefs:/last_generated_hls.m3u8")
@@ -234,6 +239,23 @@ function SessionDataComplete(sessionData as object) as boolean
return IsAssociativeArray(sessionData) and not StringUtils.IsNullOrEmpty(sessionData.visitorData) and not StringUtils.IsNullOrEmpty(sessionData.livingRoomPoTokenId)
end function
function SwitchBackendToPlaylet(preferencesNode as object) as void
preferencesNode["backend.selected"] = "playlet"
dialog = DialogUtils.ShowDialogEx({
title: Tr(Locale.Dialogs.BackendSwitchedToPlayletTitle)
message: Tr(Locale.Dialogs.BackendSwitchedToPlayletMessage)
})
if dialog = invalid
return
end if
port = CreateObject("roMessagePort")
MessagePortUtils.ObserveFieldScopedExSafe(dialog, "wasClosed", port)
wait(0, port)
dialog.unobserveFieldScoped("wasClosed")
end function
function ResolveBackendId(backend as string, service as Invidious.InvidiousService) as string
if backend = "playlet"
return "playlet"