Add "isLivingRoomDeeplink" param to /player payload, and remove auto-refresh of browser based tokens
browser based tokens are fallbacks now.
This commit is contained in:
1 parent
ce32d2f762
commit
5c5fe19440
9 files changed
+14
-77
No files matched your search
+1
-1
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Fixed
|
||||
|
||||
- Attempt to fix `No valid bitrates` error by adding PoToken generation in web app
|
||||
- Attempt to fix `No valid bitrates` error by adding PoToken generation in server and web app
|
||||
|
||||
### Removed
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Services/Innertube/PoTokens.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
|
||||
function Init()
|
||||
m.top.focusable = true
|
||||
m.top.itemSpacings = [8]
|
||||
m.button = m.top.findNode("Button")
|
||||
m.button.observeField("buttonSelected", FuncName(OnButtonSelected))
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
NodeSetFocus(m.button, true)
|
||||
end function
|
||||
|
||||
function BindPreference(_preferences as object, _key as string)
|
||||
' Do nothing
|
||||
end function
|
||||
|
||||
function OnButtonSelected()
|
||||
Innertube.PoTokens.ClearAllPoTokens()
|
||||
DialogUtils.ShowDialogEx({
|
||||
message: Tr(Locale.Settings.PoTokensCleared)
|
||||
title: Tr(Locale.Generic.Success)
|
||||
})
|
||||
end function
|
||||
@@ -1,19 +0,0 @@
|
||||
<component name="ClearPoTokensControl" extends="LayoutGroup" includes="Focus">
|
||||
<interface>
|
||||
<field id="displayText" type="string" alias="Button.text" />
|
||||
<field id="description" type="string" alias="DescriptionLabel.text" />
|
||||
<function name="BindPreference" />
|
||||
</interface>
|
||||
<children>
|
||||
<Button
|
||||
id="Button"
|
||||
minWidth="340"
|
||||
showFocusFootprint="true" />
|
||||
<Label id="DescriptionLabel"
|
||||
width="450"
|
||||
color="0xb4b4b4ff"
|
||||
wrap="true">
|
||||
<Font role="font" uri="font:SystemFontFile" size="18" />
|
||||
</Label>
|
||||
</children>
|
||||
</component>
|
||||
@@ -18,7 +18,8 @@ namespace Innertube
|
||||
datasyncIdToken = OptionUtils.Get(options, "datasyncIdToken")
|
||||
cpn = InnertubeService.CreateClientPlaybackNonce()
|
||||
|
||||
useAccessToken = (client = Innertube.ClientType.Tv or client = Innertube.ClientType.TvDowngraded) and not StringUtils.IsNullOrEmpty(accessToken)
|
||||
isTv = (client = Innertube.ClientType.Tv or client = Innertube.ClientType.TvDowngraded)
|
||||
useAccessToken = isTv and not StringUtils.IsNullOrEmpty(accessToken)
|
||||
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
@@ -58,6 +59,10 @@ namespace Innertube
|
||||
payload["playbackContext"]["contentPlaybackContext"]["signatureTimestamp"] = signatureTimestamp
|
||||
end if
|
||||
|
||||
if isTv
|
||||
payload["playbackContext"]["contentPlaybackContext"]["isLivingRoomDeeplink"] = true
|
||||
end if
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/player?prettyPrint=false&alt=json", payload)
|
||||
request.Headers(Innertube.CreateHeaders(client))
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@
|
||||
{
|
||||
displayText: "Mint PoToken",
|
||||
key: "dev.mint_potoken",
|
||||
description: "Force-mint a PoToken for the current identity.",
|
||||
description: "Mint a PoToken for the current identity.",
|
||||
visibility: "web",
|
||||
svelteComponent: "MintPoTokenControl",
|
||||
},
|
||||
@@ -325,13 +325,6 @@
|
||||
visibility: "web",
|
||||
svelteComponent: "ClearPoTokensControl",
|
||||
},
|
||||
{
|
||||
displayText: "Clear PoTokens",
|
||||
key: "dev.clear_potokens",
|
||||
description: "Clear all stored PoTokens.",
|
||||
visibility: "tv",
|
||||
rokuComponent: "ClearPoTokensControl",
|
||||
},
|
||||
{
|
||||
displayText: "Enable Diagnostics",
|
||||
key: "dev.diagnostics.enabled",
|
||||
|
||||
@@ -24,19 +24,9 @@
|
||||
import BookmarksScreen from "lib/Screens/BookmarksScreen.svelte";
|
||||
import RemoteControlScreen from "lib/Screens/RemoteControlScreen.svelte";
|
||||
import { fetchLocale } from "lib/Api/Locale";
|
||||
import { ensureDevicePoTokenWithToast } from "lib/ensureDevicePoToken";
|
||||
import Toast from "lib/Toast.svelte";
|
||||
|
||||
// Mint on load, then refresh hourly while the page is open.
|
||||
const POTOKEN_REFRESH_INTERVAL_MS = 60 * 60 * 1000;
|
||||
|
||||
onMount(() => {
|
||||
ensureDevicePoTokenWithToast();
|
||||
const poTokenRefreshInterval = setInterval(
|
||||
ensureDevicePoTokenWithToast,
|
||||
POTOKEN_REFRESH_INTERVAL_MS,
|
||||
);
|
||||
|
||||
PlayletApi.getState().then((value) => {
|
||||
playletStateStore.set(value);
|
||||
fetchLocale(value.device?.current_locale);
|
||||
@@ -73,8 +63,6 @@
|
||||
PlayletApi.getBookmarkFeeds().then((value) => {
|
||||
bookmarksStore.set(value);
|
||||
});
|
||||
|
||||
return () => clearInterval(poTokenRefreshInterval);
|
||||
});
|
||||
|
||||
let currentScreen: AppState["screen"];
|
||||
|
||||
@@ -180,8 +180,8 @@ export class PoTokenMinter {
|
||||
return now - device.mintedAt >= REFRESH_AGE_SECONDS;
|
||||
}
|
||||
|
||||
// Mints + uploads a poToken when the device's token needs refreshing, or always when forced.
|
||||
static async ensureDevicePoToken(force = false): Promise<EnsurePoTokenResult> {
|
||||
// Mints + uploads a poToken when the device's token needs refreshing.
|
||||
static async ensureDevicePoToken(): Promise<EnsurePoTokenResult> {
|
||||
let device: DevicePoToken;
|
||||
try {
|
||||
device = await PlayletApi.getDevicePoToken();
|
||||
@@ -194,7 +194,7 @@ export class PoTokenMinter {
|
||||
if (!identity) {
|
||||
return { status: "no-session" };
|
||||
}
|
||||
if (!force && !PoTokenMinter.shouldRefresh(device)) {
|
||||
if (!PoTokenMinter.shouldRefresh(device)) {
|
||||
return { status: "current" };
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<div class="m-5">
|
||||
<div class={textSizes[level]}>{$translate(displayText)}</div>
|
||||
<div class="text-xs text-gray-500">{@html $translate(description)}</div>
|
||||
<button class="btn m-1" on:click={() => ensureDevicePoTokenWithToast(true)}
|
||||
<button class="btn m-1" on:click={() => ensureDevicePoTokenWithToast()}
|
||||
>{$translate("Mint PoToken")}</button
|
||||
>
|
||||
</div>
|
||||
@@ -2,8 +2,8 @@ import { PoTokenMinter } from "lib/Api/PoTokenMinter";
|
||||
import { addToast } from "lib/Toast";
|
||||
|
||||
// Mints for the current identity if needed, surfacing the outcome as a toast.
|
||||
export async function ensureDevicePoTokenWithToast(force = false) {
|
||||
const result = await PoTokenMinter.ensureDevicePoToken(force);
|
||||
export async function ensureDevicePoTokenWithToast() {
|
||||
const result = await PoTokenMinter.ensureDevicePoToken();
|
||||
switch (result.status) {
|
||||
case "minted":
|
||||
addToast("PoToken minted on device", "success");
|
||||
|
||||
Reference in new issue
Block a user