Compare commits

..
8 Commits
Author SHA1 Message Date
Brahim Hadriche 04a1c9a9c4 Release v0.40.10 (#683) 2025-07-19 12:03:13 -04:00
Brahim Hadriche 0250fe8f01 Generate a PoToken per video in the web app when using ytjs (#682)
* Generate a PoToken per video in the web app when using ytjs

* Set a default user agent
2025-07-19 11:53:19 -04:00
Brahim Hadriche 84304cd26e [chore] update dependencies (#681)
* update dependencies

* Fix ytjs 15
2025-07-18 20:20:05 -04:00
Brahim Hadriche 64cad65e1a [chore] update dependencies (#676)
* update dependencies

* Fix "Open In Invidious" dialog buttons
2025-07-13 14:37:22 -04:00
Brahim Hadriche 933d425a19 Added option to export Playlet full state 2025-07-11 16:42:22 -04:00
Brahim Hadriche fd42b65a75 Revert "Use web safari for playback (#673)" 2025-07-08 17:02:38 -04:00
Brahim Hadriche 1b07e599e7 [skip ci] changelog 2025-07-06 20:42:08 -04:00
Brahim Hadriche 3bc25cc2d1 Use web safari for playback (#673)
* Use web safari for playback

* user agent
2025-07-06 20:38:00 -04:00
19 changed files with 990 additions and 786 deletions

No files matched your search

+11
View File
@@ -5,6 +5,17 @@ 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/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.40.10] - 2025-07-19
### Added
- An option to export Playlet's state from the web app for easier debugging.
- This is a zip file that contains logs, the app state, and the registry (local storage)
### Fixed
- Generate a PoToken per video in the web app when using ytjs
## [0.40.9] - 2025-07-06
### Fixed
+39 -39
View File
@@ -1,25 +1,25 @@
{
"name": "playlet",
"version": "0.40.9",
"version": "0.40.10",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet",
"version": "0.40.9",
"version": "0.40.10",
"hasInstallScript": true,
"devDependencies": {
"@rokucommunity/bslint": "^0.8.33",
"@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4",
"@types/node": "^24.0.10",
"@types/node": "^24.0.14",
"@types/xml2js": "^0.4.14",
"argparse": "^2.0.1",
"brighterscript": "0.68.5",
"brighterscript-formatter": "^1.7.16",
"convert-svg-to-png": "^0.7.1",
"crypto-js": "^4.2.0",
"dotenv": "^17.0.1",
"dotenv": "^17.2.0",
"fs-extra": "^11.3.0",
"glob": "^11.0.3",
"imap": "^0.8.19",
@@ -27,7 +27,7 @@
"json5": "^2.2.3",
"mailparser": "^3.7.4",
"protocol-buffers-schema": "^3.6.0",
"puppeteer": "^24.11.2",
"puppeteer": "^24.14.0",
"roku-deploy": "^3.12.6",
"roku-test-automation": "^2.0.13",
"rooibos-roku": "5.15.7",
@@ -43,7 +43,7 @@
"node": "22"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "^4.44.2"
"@rollup/rollup-linux-x64-gnu": "^4.45.1"
}
},
"node_modules/@babel/code-frame": {
@@ -573,9 +573,9 @@
}
},
"node_modules/@rollup/rollup-linux-x64-gnu": {
"version": "4.44.2",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.44.2.tgz",
"integrity": "sha512-/bXb0bEsWMyEkIsUL2Yt5nFB5naLAwyOWMEviQfQY1x3l5WsLKgvZf66TM7UTfED6erckUVUJQ/jJ1FSpm3pRQ==",
"version": "4.45.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.45.1.tgz",
"integrity": "sha512-+E/lYl6qu1zqgPEnTrs4WysQtvc/Sh4fC2nByfFExqgYrqkKWp1tWIbe+ELhixnenSpBbLXNi6vbEEJ8M7fiHw==",
"cpu": [
"x64"
],
@@ -736,9 +736,9 @@
"license": "MIT"
},
"node_modules/@types/node": {
"version": "24.0.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.10.tgz",
"integrity": "sha512-ENHwaH+JIRTDIEEbDK6QSQntAYGtbvdDXnMXnZaZ6k13Du1dPMmprkEHIL7ok2Wl2aZevetwTAb5S+7yIF+enA==",
"version": "24.0.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.14.tgz",
"integrity": "sha512-4zXMWD91vBLGRtHK3YbIoFMia+1nqEz72coM42C5ETjnNCa/heoj7NT1G67iAfOqMmcfhuCZ4uNpyz8EjlAejw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -2830,9 +2830,9 @@
}
},
"node_modules/dotenv": {
"version": "17.0.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.0.1.tgz",
"integrity": "sha512-GLjkduuAL7IMJg/ZnOPm9AnWKJ82mSE2tzXLaJ/6hD6DhwGfZaXG77oB8qbReyiczNxnbxQKyh0OE5mXq0bAHA==",
"version": "17.2.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.0.tgz",
"integrity": "sha512-Q4sgBT60gzd0BB0lSyYD3xM4YxrXA9y4uBDof1JNYGzOXrQdQ6yX+7XIAqoFOGQFOTK1D3Hts5OllpxMDZFONQ==",
"dev": true,
"license": "BSD-2-Clause",
"engines": {
@@ -5441,18 +5441,18 @@
}
},
"node_modules/puppeteer": {
"version": "24.11.2",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-24.11.2.tgz",
"integrity": "sha512-HopdRZWHa5zk0HSwd8hU+GlahQ3fmesTAqMIDHVY9HasCvppcYuHYXyjml0nlm+nbwVCqAQWV+dSmiNCrZGTGQ==",
"version": "24.14.0",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-24.14.0.tgz",
"integrity": "sha512-GB7suRDkp9pUnxpNGAORICQCtw11KFbg6U2iJXVTflzJLK5D1qzq8xOOmLgN/QnDBpDMdpn96ri52XkuN83Giw==",
"dev": true,
"hasInstallScript": true,
"license": "Apache-2.0",
"dependencies": {
"@puppeteer/browsers": "2.10.5",
"chromium-bidi": "5.1.0",
"@puppeteer/browsers": "2.10.6",
"chromium-bidi": "7.1.1",
"cosmiconfig": "^9.0.0",
"devtools-protocol": "0.0.1464554",
"puppeteer-core": "24.11.2",
"puppeteer-core": "24.14.0",
"typed-query-selector": "^2.12.0"
},
"bin": {
@@ -5486,9 +5486,9 @@
"dev": true
},
"node_modules/puppeteer/node_modules/@puppeteer/browsers": {
"version": "2.10.5",
"resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.10.5.tgz",
"integrity": "sha512-eifa0o+i8dERnngJwKrfp3dEq7ia5XFyoqB17S4gK8GhsQE4/P8nxOfQSE0zQHxzzLo/cmF+7+ywEQ7wK7Fb+w==",
"version": "2.10.6",
"resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.10.6.tgz",
"integrity": "sha512-pHUn6ZRt39bP3698HFQlu2ZHCkS/lPcpv7fVQcGBSzNNygw171UXAKrCUhy+TEMw4lEttOKDgNpb04hwUAJeiQ==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
@@ -5497,7 +5497,7 @@
"progress": "^2.0.3",
"proxy-agent": "^6.5.0",
"semver": "^7.7.2",
"tar-fs": "^3.0.8",
"tar-fs": "^3.1.0",
"yargs": "^17.7.2"
},
"bin": {
@@ -5534,9 +5534,9 @@
}
},
"node_modules/puppeteer/node_modules/chromium-bidi": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-5.1.0.tgz",
"integrity": "sha512-9MSRhWRVoRPDG0TgzkHrshFSJJNZzfY5UFqUMuksg7zL1yoZIZ3jLB0YAgHclbiAxPI86pBnwDX1tbzoiV8aFw==",
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-7.1.1.tgz",
"integrity": "sha512-L2BKQ0rSLADgbPMIdDh3wnYHs3EiUiMay2Sq0CTolheaADmWIf6Pe+T9LJRcnh5rcMz0U7MVk0cQVvKsGRMa1g==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
@@ -5597,14 +5597,14 @@
"license": "MIT"
},
"node_modules/puppeteer/node_modules/puppeteer-core": {
"version": "24.11.2",
"resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-24.11.2.tgz",
"integrity": "sha512-c49WifNb8hix+gQH17TldmD6TC/Md2HBaTJLHexIUq4sZvo2pyHY/Pp25qFQjibksBu/SJRYUY7JsoaepNbiRA==",
"version": "24.14.0",
"resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-24.14.0.tgz",
"integrity": "sha512-NO9XpCl+i8oB0zJp81iPhzMo2QK8/JTj4ramSvTpGCo9CPCNo4AZ8qVOGpSgXzlcOfOT3VHOkzTfPo08GOE5jA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@puppeteer/browsers": "2.10.5",
"chromium-bidi": "5.1.0",
"@puppeteer/browsers": "2.10.6",
"chromium-bidi": "7.1.1",
"debug": "^4.4.1",
"devtools-protocol": "0.0.1464554",
"typed-query-selector": "^2.12.0",
@@ -5700,9 +5700,9 @@
}
},
"node_modules/puppeteer/node_modules/zod": {
"version": "3.25.74",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.74.tgz",
"integrity": "sha512-J8poo92VuhKjNknViHRAIuuN6li/EwFbAC8OedzI8uxpEPGiXHGQu9wemIAioIpqgfB4SySaJhdk0mH5Y4ICBg==",
"version": "3.25.76",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
"integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
"dev": true,
"license": "MIT",
"funding": {
@@ -7356,9 +7356,9 @@
}
},
"node_modules/tar-fs": {
"version": "3.0.10",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.10.tgz",
"integrity": "sha512-C1SwlQGNLe/jPNqapK8epDsXME7CAJR5RL3GcE6KWx1d9OUByzoHVcbu1VPI8tevg9H8Alae0AApHHFGzrD5zA==",
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.1.0.tgz",
"integrity": "sha512-5Mty5y/sOF1YWj1J6GiBodjlDc05CUR8PKXrsnFAiSG0xA+GHeWLovaZPYUDXkH/1iKRf2+M5+OrRgzC7O9b7w==",
"dev": true,
"license": "MIT",
"dependencies": {
+5 -5
View File
@@ -1,19 +1,19 @@
{
"name": "playlet",
"version": "0.40.9",
"version": "0.40.10",
"description": "Unofficial YouTube client for Roku",
"devDependencies": {
"@rokucommunity/bslint": "^0.8.33",
"@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4",
"@types/node": "^24.0.10",
"@types/node": "^24.0.14",
"@types/xml2js": "^0.4.14",
"argparse": "^2.0.1",
"brighterscript": "0.68.5",
"brighterscript-formatter": "^1.7.16",
"convert-svg-to-png": "^0.7.1",
"crypto-js": "^4.2.0",
"dotenv": "^17.0.1",
"dotenv": "^17.2.0",
"fs-extra": "^11.3.0",
"glob": "^11.0.3",
"imap": "^0.8.19",
@@ -21,7 +21,7 @@
"json5": "^2.2.3",
"mailparser": "^3.7.4",
"protocol-buffers-schema": "^3.6.0",
"puppeteer": "^24.11.2",
"puppeteer": "^24.14.0",
"roku-deploy": "^3.12.6",
"roku-test-automation": "^2.0.13",
"rooibos-roku": "5.15.7",
@@ -74,6 +74,6 @@
"shutdown": "node tools/shutdown.js"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "^4.44.2"
"@rollup/rollup-linux-x64-gnu": "^4.45.1"
}
}
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-app",
"version": "0.40.9",
"version": "0.40.10",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-app",
"version": "0.40.9"
"version": "0.40.10"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-app",
"version": "0.40.9",
"version": "0.40.10",
"description": "Unofficial YouTube client for Roku",
"scripts": {
"prebuild": "rm -rf ../build/playlet-app",
+1 -1
View File
@@ -3,7 +3,7 @@ title=Playlet
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=40
build_version=00009
build_version=00010
ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-lib",
"version": "0.40.9",
"version": "0.40.10",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-lib",
"version": "0.40.9"
"version": "0.40.10"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-lib",
"version": "0.40.9",
"version": "0.40.10",
"description": "Unofficial YouTube client for Roku",
"scripts": {
"prebuild": "rm -rf ../build/playlet-lib",
@@ -2,7 +2,6 @@
<interface>
<field id="timestamp" type="int" />
<field id="visitorData" type="string" />
<field id="poToken" type="string" />
<field id="requestVisitorData" type="boolean" alwaysNotify="true" onChange="OnRequestVisitorData" />
<field id="jobQueue" type="node" />
</interface>
@@ -22,8 +22,5 @@ function ExecuteJob() as void
innertubeNode.visitorData = sessionData.visitorData
end if
if not StringUtils.IsNullOrEmpty(sessionData.poToken)
innertubeNode.poToken = sessionData.poToken
end if
innertubeNode.queueFields(false)
end function
@@ -1,3 +1,4 @@
import "pkg:/components/Services/Innertube/Constants.bs"
import "pkg:/components/Services/Innertube/SessionData.bs"
import "pkg:/components/Web/WebServer/Http/HttpRouter.bs"
import "pkg:/source/services/HttpClient.bs"
@@ -19,7 +20,6 @@ namespace Http
sessionData = {
"timestamp": m.innertube.timestamp
"visitorData": m.innertube.visitorData
"poToken": m.innertube.poToken
}
response.Json(sessionData)
@@ -45,20 +45,14 @@ namespace Http
response.Default(400, "Invalid visitorData")
return true
end if
if StringUtils.IsNullOrEmpty(payload.poToken)
response.Default(400, "Invalid poToken")
return true
end if
Innertube.SaveSessionDataToRegistry({
"timestamp": payload.timestamp
"visitorData": payload.visitorData
"poToken": payload.poToken
})
m.innertube.timestamp = payload.timestamp
m.innertube.visitorData = payload.visitorData
m.innertube.poToken = payload.poToken
response.Default(204, "Session data updated successfully")
return true
end function
@@ -74,6 +68,13 @@ namespace Http
return true
end if
requestHeaders = requestArgs.Headers
' Ytjs can send requests without specifying a User-Agent.
' In this case, Roku would use its default User-Agent.
if StringUtils.IsNullOrEmpty(requestHeaders["User-Agent"])
requestHeaders["User-Agent"] = VIDEO_PLAYER_USER_AGENT
end if
httpReq = HttpClient.FromObject(requestArgs)
httpRes = httpReq.Await()
+1 -1
View File
@@ -3,7 +3,7 @@ title=PlayletLib
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=40
build_version=00009
build_version=00010
ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p
+738 -655
View File
File diff suppressed because it is too large. Load diff
+9 -8
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-web",
"version": "0.40.9",
"version": "0.40.10",
"type": "module",
"scripts": {
"dev": "vite",
@@ -9,26 +9,27 @@
"lint": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^5.1.0",
"@sveltejs/vite-plugin-svelte": "^6.1.0",
"@tailwindcss/typography": "^0.5.16",
"@tsconfig/svelte": "^5.0.4",
"@vitejs/plugin-legacy": "^6.1.1",
"@vitejs/plugin-legacy": "^7.0.1",
"autoprefixer": "^10.4.21",
"bgutils-js": "^3.2.0",
"daisyui": "^4.12.23",
"dotenv": "^17.0.1",
"dotenv": "^17.2.0",
"ip": "^2.0.1",
"jszip": "^3.10.1",
"postcss": "^8.5.6",
"svelte": "^5.35.2",
"svelte-check": "^4.2.2",
"svelte": "^5.36.8",
"svelte-check": "^4.3.0",
"svelte-preprocess": "^6.0.3",
"tailwindcss": "^3.4.17",
"terser": "^5.43.1",
"tslib": "^2.8.1",
"typescript": "^5.8.3",
"vite": "^6.3.5",
"vite": "^7.0.5",
"vite-plugin-compression": "^0.5.1",
"vite-tsconfig-paths": "^5.1.4",
"youtubei.js": "^14.0.0"
"youtubei.js": "^15.0.0"
}
}
+2 -14
View File
@@ -187,20 +187,8 @@ export class PlayletApi {
}
}
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
try {
a.href = url;
a.download = filename;
a.click();
} catch (error) {
throw error;
} finally {
a.remove();
URL.revokeObjectURL(url);
}
const content = await response.text();
return { filename, content };
}
static async setPlayletLibVersion(tag) {
+85 -42
View File
@@ -1,6 +1,6 @@
import { Innertube, UniversalCache } from 'youtubei.js/web';
import { getHost } from "lib/Api/Host";
import { BG } from "bgutils-js";
import { BG, buildURL, GOOG_API_KEY, type WebPoSignalOutput } from "bgutils-js";
import { type BgConfig } from "bgutils-js";
import type { VideoInfo } from 'node_modules/youtubei.js/dist/src/parser/youtube';
import type { StoryboardData } from 'node_modules/youtubei.js/dist/src/parser/classes/PlayerStoryboardSpec';
@@ -105,7 +105,9 @@ export class YoutubeJs {
static innerTube: Innertube;
static innerTubePromise: Promise<void>;
static poToken?: string = undefined;
static webPoMinter: BG.WebPoMinter;
static webPoMinterPromise: Promise<void>;
static visitorData?: string = undefined;
static async fetch(input: RequestInfo | URL, init?: RequestInit) {
@@ -159,29 +161,21 @@ export class YoutubeJs {
});
}
static async initSessionData() {
if (YoutubeJs.visitorData && YoutubeJs.poToken) {
static async initVisitorData() {
if (YoutubeJs.visitorData) {
return Promise.resolve();
}
const sessionData = await YoutubeJs.getSessionData();
if (sessionData.visitorData) {
YoutubeJs.visitorData = sessionData.visitorData;
if (sessionData.poToken) {
YoutubeJs.poToken = sessionData.poToken;
return;
}
return;
}
if (!YoutubeJs.visitorData) {
YoutubeJs.visitorData = await YoutubeJs.generateVisitorData();
}
YoutubeJs.poToken = await YoutubeJs.generatePoToken(YoutubeJs.visitorData);
YoutubeJs.visitorData = await YoutubeJs.generateVisitorData();
await YoutubeJs.setSessionData({
visitorData: YoutubeJs.visitorData,
poToken: YoutubeJs.poToken,
timestamp: Math.floor(Date.now() / 1000)
});
}
@@ -217,11 +211,10 @@ export class YoutubeJs {
YoutubeJs.innerTubePromise = new Promise(async (resolve, reject) => {
try {
await YoutubeJs.initSessionData()
await YoutubeJs.initVisitorData()
YoutubeJs.innerTube = await Innertube.create({
fetch: YoutubeJs.fetch,
cache: new UniversalCache(true),
po_token: YoutubeJs.poToken,
visitor_data: YoutubeJs.visitorData,
});
YoutubeJs.innerTubePromise = null;
@@ -229,6 +222,7 @@ export class YoutubeJs {
} catch (error) {
console.error(error);
YoutubeJs.innerTube = null;
YoutubeJs.innerTubePromise = null;
reject(error);
}
})
@@ -245,45 +239,94 @@ export class YoutubeJs {
return visitorData;
}
static async generatePoToken(visitorData: string) {
const requestKey = 'O43z0dpjhgX20SCx4KAo';
const bgConfig: BgConfig = {
fetch: (input: string | URL | globalThis.Request, init?: RequestInit) => YoutubeJs.fetch(input, init),
globalObj: globalThis,
identifier: visitorData,
requestKey
};
const bgChallenge = await BG.Challenge.create(bgConfig);
if (!bgChallenge) {
throw new Error('Could not get challenge');
static async initWebPoMinter() {
if (YoutubeJs.webPoMinter) {
return Promise.resolve();
}
const interpreterJavascript = bgChallenge.interpreterJavascript.privateDoNotAccessOrElseSafeScriptWrappedValue;
if (interpreterJavascript) {
new Function(interpreterJavascript)();
} else {
throw new Error('Could not load VM');
if (YoutubeJs.webPoMinterPromise) {
return YoutubeJs.webPoMinterPromise;
}
const poTokenResult = await BG.PoToken.generate({
program: bgChallenge.program,
globalName: bgChallenge.globalName,
bgConfig
YoutubeJs.webPoMinterPromise = new Promise(async (resolve, reject) => {
try {
const requestKey = 'O43z0dpjhgX20SCx4KAo';
const bgConfig: BgConfig = {
fetch: (input: string | URL | globalThis.Request, init?: RequestInit) => YoutubeJs.fetch(input, init),
globalObj: globalThis,
requestKey,
identifier: ''
};
const bgChallenge = await BG.Challenge.create(bgConfig);
if (!bgChallenge) {
throw new Error('Could not get challenge');
}
const interpreterJavascript = bgChallenge.interpreterJavascript.privateDoNotAccessOrElseSafeScriptWrappedValue;
if (interpreterJavascript) {
new Function(interpreterJavascript)();
} else {
throw new Error('Could not load VM');
}
const botguard = await BG.BotGuardClient.create({
globalName: bgChallenge.globalName,
globalObj: globalThis,
program: bgChallenge.program
});
const webPoSignalOutput: WebPoSignalOutput = [];
const botguardResponse = await botguard.snapshot({ webPoSignalOutput });
const integrityTokenResponse = await bgConfig.fetch(buildURL('GenerateIT', true), {
method: 'POST',
headers: {
'content-type': 'application/json+protobuf',
'x-goog-api-key': GOOG_API_KEY,
'x-user-agent': 'grpc-web-javascript/0.1'
},
body: JSON.stringify([requestKey, botguardResponse])
});
const response = await integrityTokenResponse.json() as unknown[];
if (typeof response[0] !== 'string')
throw new Error('Could not get integrity token');
YoutubeJs.webPoMinter = await BG.WebPoMinter.create({ integrityToken: response[0] }, webPoSignalOutput);
YoutubeJs.webPoMinterPromise = null;
resolve();
} catch (error) {
console.error(error);
YoutubeJs.webPoMinter = null;
YoutubeJs.webPoMinterPromise = null;
reject(error);
return;
}
});
if (!poTokenResult || !poTokenResult.poToken) {
throw new Error('Could not generate poToken');
return YoutubeJs.webPoMinterPromise;
}
static async generatePoToken(videoId: string) {
await YoutubeJs.initWebPoMinter();
if (!YoutubeJs.webPoMinter) {
throw new Error('WebPoMinter is not initialized');
}
return poTokenResult.poToken;
return await YoutubeJs.webPoMinter.mintAsWebsafeString(videoId);
}
static async getVideoInfo(videoId: string) {
await YoutubeJs.initInnertube();
const info = await YoutubeJs.innerTube.getBasicInfo(videoId, 'TV');
const info = await YoutubeJs.innerTube.getBasicInfo(videoId, {
client: 'TV',
po_token: await YoutubeJs.generatePoToken(videoId),
});
// We can't generate a proper dash from live videos.
// By returning null, we're telling Playlet to fetch video info itself.
+75 -2
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import JSZip from "jszip";
import { getHost } from "lib/Api/Host";
import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore, translate } from "lib/Stores";
@@ -168,10 +169,73 @@ ${JSON.stringify(profilesInfo, null, 2)}
if (!code) {
return;
}
await PlayletApi.exportRegistry(code);
const { filename, content } = await PlayletApi.exportRegistry(code);
triggerDownload(filename, content, "application/json");
} catch (error) {
console.error(error);
alert("Failed to export registry. Please try again.");
alert(
"Failed to export registry. Please try again. See console for details."
);
}
}
async function exportFullState() {
// creates a zip using JSzip that contains:
// - app_state.json
// - app_logs.txt
// - app_logs_previous.txt
// - playlet-registry.json
try {
var zip = new JSZip();
const appState = (await fetch(`${host}/api/state`)).text();
zip.file("app_state.json", appState);
const appLogs = (await fetch(`${host}/logs/app_logs.txt`)).text();
zip.file("app_logs.txt", appLogs);
const appLogsPrevious = (
await fetch(`${host}/logs/app_logs_previous.txt`)
).text();
zip.file("app_logs_previous.txt", appLogsPrevious);
await PlayletApi.showExportRegistryCode();
const code = prompt("Enter the code you see on your Roku device");
if (!code) {
return;
}
const { filename, content } = await PlayletApi.exportRegistry(code);
zip.file(filename, content);
const zipContent = await zip.generateAsync({
type: "blob",
compression: "DEFLATE",
});
triggerDownload("playlet_full_state.zip", zipContent, "application/zip");
} catch (error) {
console.error(error);
alert(
"Failed to export full state. Please try again. See console for details."
);
}
}
function triggerDownload(filename, content, mimeType) {
const blob = new Blob([content], { type: mimeType });
let url;
const a = document.createElement("a");
try {
url = URL.createObjectURL(blob);
a.href = url;
a.download = filename;
a.click();
} finally {
a.remove();
if (url) {
URL.revokeObjectURL(url);
}
}
}
</script>
@@ -234,6 +298,15 @@ ${JSON.stringify(profilesInfo, null, 2)}
></td
>
</tr>
<tr>
<td>{"Full state"}</td>
<td
><button class="btn btn-outline btn-sm" on:click={exportFullState}
>Export full state</button
></td
>
</tr>
</tbody>
</table>
</div>
@@ -21,7 +21,11 @@
playletStateStore.subscribe((value) => {
tvName = value?.device?.friendly_name ?? "Roku TV";
invidiousInstance = value?.invidious?.instance;
let instance = value?.invidious?.invidious_instance || "";
if (!instance) {
instance = "https://redirect.invidious.io";
}
invidiousInstance = instance;
});
async function openOnTv() {
@@ -24,7 +24,11 @@
playletStateStore.subscribe((value) => {
tvName = value?.device?.friendly_name ?? "Roku TV";
invidiousInstance = value?.invidious?.instance;
let instance = value?.invidious?.invidious_instance || "";
if (!instance) {
instance = "https://redirect.invidious.io";
}
invidiousInstance = instance;
});
async function playOnTv() {