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"
@@ -240,6 +240,14 @@
<source>Please sign in again with this profile, or switch to another profile.</source>
<translation>Please sign in again with this profile, or switch to another profile.</translation>
</message>
<message>
<source>Backend changed</source>
<translation>Backend changed</translation>
</message>
<message>
<source>Backend changed to Playlet, because no Invidious instance is set.</source>
<translation>Backend changed to Playlet, because no Invidious instance is set.</translation>
</message>
<message>
<source>Lounge service setup error</source>
<translation>Lounge service setup error</translation>
+2
View File
@@ -80,6 +80,8 @@ namespace Locale
ProfileNeedsReauthMessage = "The session has expired. Please sign in again with this profile, or switch to another profile."
ProfileNeedsReauthMessageLine1 = "The session has expired."
ProfileNeedsReauthMessageLine2 = "Please sign in again with this profile, or switch to another profile."
BackendSwitchedToPlayletTitle = "Backend changed"
BackendSwitchedToPlayletMessage = "Backend changed to Playlet, because no Invidious instance is set."
LoungeServiceSetupError = "Lounge service setup error"
LoungeFailedToGetScreenId = "Failed to get screen ID. Please restart Playlet to use the cast function."
LoungeNotAValidScreenId = "Not a valid screen id: %1"