Compare commits

..
72 Commits
Author SHA1 Message Date
Brahim Hadriche 91b17fa4a4 Release v0.36.5 (#594) 2025-05-02 19:51:07 -04:00
Brahim Hadriche 943d39af33 Update innertube versions 2025-05-02 19:43:25 -04:00
Brahim Hadriche e8015d52ff Log unknown nodes better 2025-05-02 19:43:07 -04:00
Brahim Hadriche d919489f50 Fixed small error handling bug in Playlet backend 2025-05-01 22:18:23 -04:00
Brahim Hadriche 62675446b2 Update readme link and changelog 2025-04-29 22:28:23 -04:00
Brahim Hadriche 4a8b12294d Update README.md 2025-04-22 15:05:54 -04:00
Brahim Hadriche 5583f55aae Release v0.36.4 (#586) 2025-04-19 11:44:28 -04:00
Brahim Hadriche d4f15e7dfb update dependencies (#585) 2025-04-19 11:38:22 -04:00
Brahim Hadriche de7c3f8a99 update dependencies (#581) 2025-04-12 16:59:10 -04:00
Brahim Hadriche b35dc4423e changelog 2025-04-12 16:55:09 -04:00
Weblate (bot)anddavbrasan 23146706ee Translated using Weblate (Portuguese (Brazil)) (#582)
Currently translated at 100.0% (319 of 319 strings)

Translation: Playlet/Playlet
Translate-URL: https://hosted.weblate.org/projects/playlet/playlet/pt_BR/

Co-authored-by: davbrasan <davidbrazps2@gmail.com>
2025-04-12 16:54:34 -04:00
Brahim Hadriche d10444b96c changelog 2025-04-10 16:27:58 -04:00
Weblate (bot)andEttore Atalan 2f7ba64488 Translated using Weblate (German) (#580)
Currently translated at 100.0% (319 of 319 strings)

Translation: Playlet/Playlet
Translate-URL: https://hosted.weblate.org/projects/playlet/playlet/de/

Co-authored-by: Ettore Atalan <atalanttore@googlemail.com>
2025-04-10 16:27:35 -04:00
Brahim Hadricheandgithub-action linter f1f50cc19e [chore] update dependencies (#579)
* update dependencies

* Lint fix

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2025-04-05 12:16:18 -04:00
Brahim Hadriche b3a9887634 [skip ci] remove announcement 2025-04-03 13:21:33 -04:00
Brahim Hadriche c56092144f [skip ci] changelog fix 2025-04-02 18:32:25 -04:00
Brahim Hadriche 750472912e Release v0.36.3 (#578) 2025-04-02 18:27:32 -04:00
Brahim Hadriche ae83c47bfe Fix bug with saving search history 2025-03-30 09:59:58 -04:00
Brahim Hadriche e08bc86334 update dependencies (#573) 2025-03-29 10:19:51 -04:00
Brahim Hadriche 10aaf74c38 update dependencies (#570) 2025-03-22 11:29:16 -04:00
Brahim Hadriche 79464a003e Fix Playlet backend parsing issue in search results 2025-03-17 19:52:51 -04:00
Brahim Hadriche f7b8aa6c29 Fix for web remote volume buttons being stuck when a Roku stick is used with Roku TV 2025-03-17 11:59:25 -04:00
Brahim Hadriche 59e378cc9c update dependencies (#568) 2025-03-17 11:57:53 -04:00
Brahim Hadriche a1c178830a [skip ci] update device script 2025-03-17 11:36:01 -04:00
Brahim Hadriche 173e6ffa6c Revert "Remove optional dep (#567)"
This reverts commit 207614ac5c.
2025-03-07 22:41:03 -05:00
Brahim Hadriche 207614ac5c Remove optional dep (#567) 2025-03-07 22:38:43 -05:00
Brahim Hadriche 5c7c6e83c3 update dependencies (#566) 2025-03-07 22:32:25 -05:00
Brahim Hadriche 9ceb1c8963 [chore] update dependencies (#565)
* update dependencies

* lock versions of bsc and daisyui
2025-03-02 14:33:32 -05:00
Brahim Hadriche 106a664c9f Transpiled files 2025-02-27 20:17:42 -05:00
Brahim Hadriche bd3ac7b9c1 App dialog signals to comply with certification 2025-02-27 20:16:58 -05:00
Brahim Hadriche afe61c2df7 Release v0.36.2 (#564) 2025-02-27 20:05:23 -05:00
Brahim Hadriche 943f348d87 [chore] update dependencies (#561)
* update dependencies

* revert bsc
2025-02-27 20:01:52 -05:00
Brahim Hadriche 30b6551356 [skip ci] comment 2025-02-27 19:00:23 -05:00
Brahim Hadriche a46397fa46 [chore] update dependencies (#556)
* update dependencies

* revert bsc
2025-02-16 17:14:10 -05:00
Brahim Hadriche 32afe5afd9 changelog 2025-02-16 15:00:05 -05:00
Weblate (bot)andJean Carton 371286344f Translated using Weblate (Spanish (Mexico)) (#557)
Currently translated at 100.0% (319 of 319 strings)

Translation: Playlet/Playlet
Translate-URL: https://hosted.weblate.org/projects/playlet/playlet/es_MX/

Co-authored-by: Jean Carton <intrinsiccyokai@users.noreply.hosted.weblate.org>
2025-02-16 14:59:07 -05:00
Brahim Hadriche ae39b8d0ab [skip ci] remove duplicate import 2025-02-03 19:40:41 -05:00
Brahim Hadriche 1c4067e7da Do not cache empty response data 2025-02-03 19:34:00 -05:00
Brahim Hadriche b327a37576 changelog 2025-02-03 14:00:03 -05:00
Weblate (bot)andBastian Veith 0d8aae6a75 Translated using Weblate (German) (#554)
Currently translated at 99.6% (318 of 319 strings)

Translation: Playlet/Playlet
Translate-URL: https://hosted.weblate.org/projects/playlet/playlet/de/

Co-authored-by: Bastian Veith <veith.bastian@pm.me>
2025-02-03 13:59:46 -05:00
Brahim Hadriche 8f79d91c29 [chore] update dependencies (#552)
* update dependencies

* Fix deps
2025-02-01 10:24:05 -05:00
Brahim Hadriche 5c02d46f1d [skip ci] enable colored logs in debug mode 2025-01-31 18:17:20 -05:00
Brahim Hadriche 83627b67ec [skip ci] oauth logout 2025-01-29 20:56:05 -05:00
Brahim Hadriche 2b11d4b71c Update profile view / thumbnail 2025-01-29 20:28:12 -05:00
Brahim Hadricheandgithub-action linter 29a3206f17 More OAuth work (#551)
* More OAuth work

* Lint fix

* tweaks

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2025-01-28 22:20:07 -05:00
Brahim Hadriche 12231fe2ec Logo adjustment 2025-01-26 22:08:46 -05:00
Brahim Hadriche 0b6cd0294f Add account type indicator 2025-01-26 21:37:27 -05:00
Brahim Hadriche 1964040900 Move image conversion out of plugins 2025-01-26 20:38:08 -05:00
Brahim Hadriche 3cb3c4b8ab Feature/yt oauth (#550)
* feature flag

* Move view

* Service selection UI

* tweak

* tweak
2025-01-26 18:21:05 -05:00
Brahim Hadriche 4acc1bd0c6 Format 2025-01-26 15:47:52 -05:00
Brahim Hadriche 3375ce9f4f Locale tweak 2025-01-26 15:45:19 -05:00
Brahim Hadriche 75c965fd8b [skip ci] update versions 2025-01-26 15:23:08 -05:00
Brahim Hadriche 345f26f0b2 [skip ci] rename plugin file 2025-01-25 19:50:51 -05:00
Brahim Hadriche 6a9fb2755d [skip ci] fix warnings 2025-01-24 20:58:54 -05:00
Brahim Hadriche 01103f7833 [chore] update dependencies (#549)
* update dependencies

* revert tailwind package

* svelte config fix

* exclude tailwind from updates
2025-01-24 20:56:25 -05:00
Brahim Hadriche 21a653571f [skip ci] Remove mixes video thumbnails Invidious patch 2025-01-24 16:50:15 -05:00
Brahim Hadriche caa3f18fcc [skip ci] tweak with dash url for testing 2025-01-23 19:01:50 -05:00
Brahim Hadriche 6b62532b48 [skip ci] shutdown script 2025-01-22 18:04:44 -05:00
Brahim Hadriche 6fd99afd8a [skip ci] test tweak 2025-01-22 17:40:12 -05:00
Brahim Hadriche 23401e7841 [skip ci] locale 2025-01-21 19:24:35 -05:00
Brahim Hadriche 54b4750e8e Changelog 2025-01-21 12:58:06 -05:00
Weblate (bot)andLacey Anaya 1587c8fd26 Translated using Weblate (German) (#547)
Currently translated at 99.6% (316 of 317 strings)

Translation: Playlet/Playlet
Translate-URL: https://hosted.weblate.org/projects/playlet/playlet/de/

Co-authored-by: Lacey Anaya <yecakeh263@anawalls.com>
2025-01-21 12:57:48 -05:00
Brahim Hadriche cef4679770 Release v0.36.1 (#546) 2025-01-19 11:47:22 -05:00
Brahim Hadriche fc3a9ce41f [skip ci] changelog typo 2025-01-19 11:43:05 -05:00
Brahim Hadriche dfaf3fa87e [skip ci] json bug testing update 2025-01-18 21:09:23 -05:00
Brahim Hadriche f8988e9d13 Add visitor data (#545)
* Add visitor data

* Tweak

* Changelog

* Do not load video details in video queue view
2025-01-18 18:21:23 -05:00
Brahim Hadriche 6f74ee61f6 Fix redirect missing timestamp param 2025-01-18 12:42:10 -05:00
Brahim Hadriche a598d362ba [chore] update dependencies (#544)
* update dependencies

* Strict node version
2025-01-18 12:30:05 -05:00
Brahim Hadriche 66ce75d62e Localize channel tabs from innertube 2025-01-17 16:29:36 -05:00
Brahim Hadriche 975980a3b5 Backend can return raw response 2025-01-17 16:28:16 -05:00
Brahim Hadriche 951a13be1f [skip ci] add few nodes to parser 2025-01-16 20:30:14 -05:00
Brahim Hadriche 14eba620ac [skip ci] comments 2025-01-16 18:06:36 -05:00
106 changed files with 3522 additions and 1029 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
engine-strict=true
+48
View File
@@ -5,6 +5,54 @@ 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.36.5] - 2025-05-02
### Fixed
- Small error handling bug in Playlet backend
## [0.36.4] - 2025-04-19
### Added
- Portuguese (Brazil) translations (Thanks to davbrasan)
### Removed
- Startup announcement dialog
### Fixed
- German translation (Thanks to Atalanttore)
## [0.36.3] - 2025-04-02
### Fixed
- Playlet backend parsing issue in search results
- Bug with saving search history
## [0.36.2] - 2025-02-28
### Added
- German translations (Thanks to Lacey Anaya and Bastian Veith)
- Spanish (Mexico) translations (Thanks to Jean Carton)
## [0.36.1] - 2025-01-19
### Fixed
- Added `Visitor Data` to payload in Playlet backend
- Session data persists for 24 hours
- It reduces the privacy of the app, but can help with `Sign in to confirm you're not a bot` errors
### Changed
- Video queue view might be missing video titles and durations
- This is done to reduce the risk of rate limiting. No video titles in the queue is better than no videos playing at all.
- Only affects casting playlists from the YouTube mobile app.
## [0.36.0] - 2025-01-16 ## [0.36.0] - 2025-01-16
### Added ### Added
+2 -2
View File
@@ -15,7 +15,7 @@
<a href="/LICENSE"> <a href="/LICENSE">
<img alt="AGPL-3.0 license" src="https://img.shields.io/github/license/iBicha/playlet.svg"/> <img alt="AGPL-3.0 license" src="https://img.shields.io/github/license/iBicha/playlet.svg"/>
</a> </a>
<a href="https://channelstore.roku.com/details/840aec36f51bfe6d96cf6db9055a372a/playlet"> <a href="https://channelstore.roku.com/details/4a41d0921265a5e31429a7679442153f:b5bcb5b630c28b01e93bf59856317b43/playlet">
<img alt="Roku Channel Store" src="https://img.shields.io/badge/Roku%20Store-Install-blueviolet?logo=roku&logoColor=blueviolet&labelColor=white"/> <img alt="Roku Channel Store" src="https://img.shields.io/badge/Roku%20Store-Install-blueviolet?logo=roku&logoColor=blueviolet&labelColor=white"/>
</a> </a>
<a href="https://github.com/iBicha/playlet/wiki"> <a href="https://github.com/iBicha/playlet/wiki">
@@ -40,7 +40,7 @@ More under [Screenshots](./docs/screenshots/README.md)
## Installation ## Installation
[Playlet on Roku channel store](https://channelstore.roku.com/details/840aec36f51bfe6d96cf6db9055a372a/playlet) or search "Playlet" in the Roku channel store on your device. [Playlet on Roku channel store](https://channelstore.roku.com/details/4a41d0921265a5e31429a7679442153f:b5bcb5b630c28b01e93bf59856317b43/playlet) or search "Playlet" in the Roku channel store on your device.
Can't install from the store? See [How to install Playlet as a sideloaded/dev app](https://github.com/iBicha/playlet/discussions/371) Can't install from the store? See [How to install Playlet as a sideloaded/dev app](https://github.com/iBicha/playlet/discussions/371)
-1
View File
@@ -91,7 +91,6 @@
"../tools/bs-plugins/json-yaml-plugin.ts", "../tools/bs-plugins/json-yaml-plugin.ts",
"../tools/bs-plugins/validation-plugin.ts", "../tools/bs-plugins/validation-plugin.ts",
"../tools/bs-plugins/logger-plugin.ts", "../tools/bs-plugins/logger-plugin.ts",
"../tools/bs-plugins/image-gen-plugin.ts",
"../tools/bs-plugins/type-gen-plugin.ts", "../tools/bs-plugins/type-gen-plugin.ts",
"../tools/bs-plugins/web-server-plugin.ts", "../tools/bs-plugins/web-server-plugin.ts",
"../tools/bs-plugins/locale-validation-plugin.ts", "../tools/bs-plugins/locale-validation-plugin.ts",
-1
View File
@@ -29,7 +29,6 @@
"../tools/bs-plugins/json-yaml-plugin.ts", "../tools/bs-plugins/json-yaml-plugin.ts",
"../tools/bs-plugins/validation-plugin.ts", "../tools/bs-plugins/validation-plugin.ts",
"../tools/bs-plugins/logger-plugin.ts", "../tools/bs-plugins/logger-plugin.ts",
"../tools/bs-plugins/image-gen-plugin.ts",
"../tools/bs-plugins/type-gen-plugin.ts", "../tools/bs-plugins/type-gen-plugin.ts",
"../tools/bs-plugins/web-server-plugin.ts", "../tools/bs-plugins/web-server-plugin.ts",
"../tools/bs-plugins/locale-validation-plugin.ts", "../tools/bs-plugins/locale-validation-plugin.ts",
+1 -1
View File
@@ -2,7 +2,7 @@ openapi: 3.0.0
info: info:
title: Playlet Web API title: Playlet Web API
version: 0.36.0 version: 0.36.5
description: description:
Playlet Web API is a RESTful API for controlling the Playlet app on Playlet Web API is a RESTful API for controlling the Playlet app on
Roku devices. The API is intended to be used by the Playlet web app, but can Roku devices. The API is intended to be used by the Playlet web app, but can
-16
View File
@@ -1,7 +1,6 @@
# Playlet Brighterscript Plugins # Playlet Brighterscript Plugins
- [Json5/Yaml support](#json5yaml-support) - [Json5/Yaml support](#json5yaml-support)
- [Convert images](#convert-images)
- [Manifest editing](#manifest-editing) - [Manifest editing](#manifest-editing)
- [Validation](#validation) - [Validation](#validation)
- [Includes](#includes) - [Includes](#includes)
@@ -33,21 +32,6 @@ Brightscript can only parse json natively using [ParseJson](https://developer.ro
At the end of the build, the plugin scans for certain files (`jsonc`, `json`, `json5` and `yaml`), and converts them to plain json, while keeping the original file name. That way they are all parsable by the [ParseJson](https://developer.roku.com/en-ca/docs/references/brightscript/language/global-utility-functions.md#parsejsonjsonstring-as-string-flags---as-string-as-object) function, even though their original format is not compatible. At the end of the build, the plugin scans for certain files (`jsonc`, `json`, `json5` and `yaml`), and converts them to plain json, while keeping the original file name. That way they are all parsable by the [ParseJson](https://developer.roku.com/en-ca/docs/references/brightscript/language/global-utility-functions.md#parsejsonjsonstring-as-string-flags---as-string-as-object) function, even though their original format is not compatible.
## Convert images
**[Source](/tools/bs-plugins/image-gen-plugin.ts)**
This plugin allows us to convert svg files to png files.
### Why
This is used to convert splash screen, app poster, as well as icons in the app. Having svg images (or vector images in general) as the source of truth is better, in case images need to be modified or resized. Since Roku can't load them, we convert them to png.
### How
Each `.svg` file found will have an associated `.svg.meta.json5` file, which will contain the hash (MD5) of the svg, conversion paramters, and the hash of the output files. This allows us to hash existing files and see if a conversion is needed.
Notice how each `.svg` file can be configured to generate multiple png files. This is especially the case to generate the app artwork (splash screen/poster) with different sizes from the same logo `.svg` file.
## Manifest editing ## Manifest editing
**[Source](/tools/bs-plugins/manifest-edit-plugin.ts)** **[Source](/tools/bs-plugins/manifest-edit-plugin.ts)**
+7 -2
View File
@@ -6,7 +6,12 @@ import { utils } from 'roku-test-automation';
const envFile = path.join(__dirname, '../.env'); const envFile = path.join(__dirname, '../.env');
const config = getEnvVars(['ROKU_DEV_TARGET', 'ROKU_DEVPASSWORD']); const config = getEnvVars(['ROKU_DEV_TARGET', 'ROKU_DEVPASSWORD']);
export function setupEnvironment() { export enum AppId {
DEV = 'dev',
PROD = '693751',
}
export function setupEnvironment(appId = AppId.DEV) {
utils.setupEnvironmentFromConfig({ utils.setupEnvironmentFromConfig({
RokuDevice: { RokuDevice: {
devices: [{ devices: [{
@@ -16,7 +21,7 @@ export function setupEnvironment() {
}, },
ECP: { ECP: {
default: { default: {
launchChannelId: 'dev' launchChannelId: appId,
} }
}, },
OnDeviceComponent: { OnDeviceComponent: {
+36 -8
View File
@@ -1,14 +1,14 @@
// integration test to play a video on the Roku device // integration test to play a video on the Roku device
// 1. Run dev channel on the Roku device (Playlet (dev))
// 2. npm run restart-app && npm run test:integration
import { ecp, odc } from 'roku-test-automation'; import { ecp, odc } from 'roku-test-automation';
import { setupEnvironment } from './common'; import { AppId, setupEnvironment } from './common';
import { Key } from 'roku-test-automation/client/dist/ECP'; import { Key } from 'roku-test-automation/client/dist/ECP';
setupEnvironment(); async function playVideoDev() {
setupEnvironment(AppId.DEV);
(async () => { await ecp.sendLaunchChannel({ params: { contentId: "jNQXAC9IVRw" } });
await ecp.sendInput({ params: { contentId: "jNQXAC9IVRw" } }); await ecp.sleep(5000);
await odc.onFieldChangeOnce({ await odc.onFieldChangeOnce({
base: "scene", base: "scene",
@@ -18,7 +18,35 @@ setupEnvironment();
console.log("Video started playing"); console.log("Video started playing");
await ecp.sendKeypress(Key.Back);
await odc.shutdown(); await odc.shutdown();
await ecp.sendKeypress(Key.Home);
}
async function playVideoProd() {
setupEnvironment(AppId.PROD);
let playerState = (await ecp.getMediaPlayer()).state;
await ecp.sendLaunchChannel({ params: { contentId: "jNQXAC9IVRw" } });
const TIMEOUT = 20000;
const start = Date.now();
while (Date.now() - start < TIMEOUT) {
const newPlayerState = (await ecp.getMediaPlayer()).state;
if (newPlayerState !== playerState) {
console.log("Player state changed: ", newPlayerState);
playerState = newPlayerState;
}
if (playerState === "play") {
console.log("Video started playing");
break;
}
await ecp.sleep(1000);
}
await ecp.sendKeypress(Key.Home);
}
(async () => {
await playVideoDev();
await playVideoProd();
})(); })();
+767 -385
View File
File diff suppressed because it is too large. Load diff
+21 -17
View File
@@ -1,36 +1,37 @@
{ {
"name": "playlet", "name": "playlet",
"version": "0.36.0", "version": "0.36.5",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"devDependencies": { "devDependencies": {
"@rokucommunity/bslint": "^0.8.27", "@rokucommunity/bslint": "^0.8.28",
"@types/crypto-js": "^4.2.2", "@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/node": "^22.10.5", "@types/node": "^22.14.1",
"@types/xml2js": "^0.4.14", "@types/xml2js": "^0.4.14",
"argparse": "^2.0.1", "argparse": "^2.0.1",
"brighterscript": "0.68.2", "brighterscript": "0.68.5",
"brighterscript-formatter": "^1.7.7", "brighterscript-formatter": "^1.7.12",
"cheerio": "1.0.0-rc.11",
"convert-svg-to-png": "^0.6.4", "convert-svg-to-png": "^0.6.4",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"dotenv": "^16.4.7", "dotenv": "^16.5.0",
"fs-extra": "^11.2.0", "fs-extra": "^11.3.0",
"glob": "^11.0.1", "glob": "^11.0.1",
"imap": "^0.8.19", "imap": "^0.8.19",
"ip": "^2.0.1", "ip": "^2.0.1",
"json5": "^2.2.3", "json5": "^2.2.3",
"mailparser": "^3.7.2", "mailparser": "^3.7.2",
"protocol-buffers-schema": "^3.6.0", "protocol-buffers-schema": "^3.6.0",
"roku-deploy": "^3.12.3", "roku-deploy": "^3.12.4",
"roku-test-automation": "^2.0.10", "roku-test-automation": "^2.0.13",
"rooibos-roku": "5.14.0", "rooibos-roku": "5.15.7",
"rounded-rect-9patch": "^1.1.2", "rounded-rect-9patch": "^1.1.2",
"semver": "^7.6.3", "semver": "^7.7.1",
"shelljs": "^0.8.5", "shelljs": "^0.9.2",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "5.7.3", "typescript": "5.8.3",
"xml2js": "^0.6.2", "xml2js": "^0.6.2",
"yaml": "^2.7.0" "yaml": "^2.7.1"
}, },
"engines": { "engines": {
"node": "20" "node": "20"
@@ -62,15 +63,18 @@
"sign-released-package": "node tools/sign-released-package.js", "sign-released-package": "node tools/sign-released-package.js",
"screenshot": "node tools/screenshot.js", "screenshot": "node tools/screenshot.js",
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js", "generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
"convert-images": "node tools/convert-images.js",
"update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip", "update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip",
"postinstall": "cd playlet-lib && npm install && cd ../playlet-app && npm install && cd ../playlet-web && npm install", "postinstall": "cd playlet-lib && npm install && cd ../playlet-app && npm install && cd ../playlet-web && npm install",
"update-deps": "npx npm-check-updates --deep --upgrade --install always", "update-deps": "npx npm-check-updates --deep --upgrade --install always --reject tailwindcss,cheerio,brighterscript,daisyui",
"registry:write": "node tools/registry.js --input registry.json", "registry:write": "node tools/registry.js --input registry.json",
"registry:read": "node tools/registry.js --output registry.json", "registry:read": "node tools/registry.js --output registry.json",
"registry:clear": "node tools/registry.js --clear", "registry:clear": "node tools/registry.js --clear",
"restart-app": "node tools/restart-app.js" "restart-app": "node tools/restart-app.js",
"check-for-updates": "node tools/check-for-updates.js",
"shutdown": "node tools/shutdown.js"
}, },
"optionalDependencies": { "optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "^4.30.1" "@rollup/rollup-linux-x64-gnu": "^4.40.0"
} }
} }
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.36.0", "version": "0.36.5",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-app", "name": "playlet-app",
"version": "0.36.0" "version": "0.36.5"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.36.0", "version": "0.36.5",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"scripts": { "scripts": {
"prebuild": "rm -rf ../build/playlet-app", "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 # Do not update version manually, it is auto updated from package.json
major_version=0 major_version=0
minor_version=36 minor_version=36
build_version=00000 build_version=00005
ui_resolutions=hd ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p uri_resolution_autosub=$$RES$$,480p,720p,1080p
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.36.0", "version": "0.36.5",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.36.0" "version": "0.36.5"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.36.0", "version": "0.36.5",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"scripts": { "scripts": {
"prebuild": "rm -rf ../build/playlet-lib", "prebuild": "rm -rf ../build/playlet-lib",
@@ -92,11 +92,11 @@ function OnContentSet() as void
if (authorId <> m.authorId or author <> m.author) and IsArray(content.tabs) if (authorId <> m.authorId or author <> m.author) and IsArray(content.tabs)
m.authorId = authorId m.authorId = authorId
m.author = author m.author = author
m.rowList.feeds = CreateChannelFeeds(m.authorId, author, content.tabs, content.tabsParams) m.rowList.feeds = CreateChannelFeeds(m.authorId, author, content.tabs, content.tabsParams, content.tabsTitles)
end if end if
end function end function
function CreateChannelFeeds(authorId as string, author as string, tabs as object, tabsParams as object) as object function CreateChannelFeeds(authorId as string, author as string, tabs as object, tabsParams as object, tabsTitles as object) as object
if authorId = "" if authorId = ""
return invalid return invalid
end if end if
@@ -111,7 +111,13 @@ function CreateChannelFeeds(authorId as string, author as string, tabs as object
params = "" params = ""
end if end if
feeds.Push(m.tabs[tabName](authorId, author, params)) if tabsTitles <> invalid and tabsTitles.DoesExist(tabName)
title = tabsTitles[tabName]
else
title = ""
end if
feeds.Push(m.tabs[tabName](authorId, author, title, params))
end if end if
end for end for
@@ -197,26 +203,47 @@ end function
function InitializeTabs() function InitializeTabs()
m.tabs = { m.tabs = {
"videos": function(authorId as string, author as string, params as string) as object "videos": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Videos", "channel_videos", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Videos"
end if
return CreateChannelFeed(title, "channel_videos", authorId, author, params)
end function end function
"shorts": function(authorId as string, author as string, params as string) as object "shorts": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Shorts", "channel_shorts", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Shorts"
end if
return CreateChannelFeed(title, "channel_shorts", authorId, author, params)
end function end function
"streams": function(authorId as string, author as string, params as string) as object "streams": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Live", "channel_streams", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Live"
end if
return CreateChannelFeed(title, "channel_streams", authorId, author, params)
end function end function
"releases": function(authorId as string, author as string, params as string) as object "releases": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Releases", "channel_releases", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Releases"
end if
return CreateChannelFeed(title, "channel_releases", authorId, author, params)
end function end function
"podcasts": function(authorId as string, author as string, params as string) as object "podcasts": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Podcasts", "channel_podcasts", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Podcasts"
end if
return CreateChannelFeed(title, "channel_podcasts", authorId, author, params)
end function end function
"playlists": function(authorId as string, author as string, params as string) as object "playlists": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Playlists", "channel_playlists", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Playlists"
end if
return CreateChannelFeed(title, "channel_playlists", authorId, author, params)
end function end function
"courses": function(authorId as string, author as string, params as string) as object "courses": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Courses", "channel_courses", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Courses"
end if
return CreateChannelFeed(title, "channel_courses", authorId, author, params)
end function end function
} }
end function end function
@@ -9,6 +9,7 @@
<field id="loadingBitmapUri" type="uri" alias="Poster.loadingBitmapUri" /> <field id="loadingBitmapUri" type="uri" alias="Poster.loadingBitmapUri" />
<field id="failedBitmapUri" type="uri" alias="Poster.failedBitmapUri" /> <field id="failedBitmapUri" type="uri" alias="Poster.failedBitmapUri" />
<field id="loadStatus" type="string" alias="Poster.loadStatus" /> <field id="loadStatus" type="string" alias="Poster.loadStatus" />
<field id="blendColor" type="color" alias="Poster.blendColor" />
<field id="maskUri" type="uri" value="pkg:/images/white-circle.png" alias="MaskGroup.maskuri" /> <field id="maskUri" type="uri" value="pkg:/images/white-circle.png" alias="MaskGroup.maskuri" />
<field id="maskSize" type="vector2d" alias="MaskGroup.maskSize" /> <field id="maskSize" type="vector2d" alias="MaskGroup.maskSize" />
@@ -0,0 +1,5 @@
<component name="BackendTypeContentNode" extends="ContentNode">
<interface>
<field id="backendLogoUri" type="uri" />
</interface>
</component>
@@ -18,6 +18,7 @@
<field id="subCountText" type="string" /> <field id="subCountText" type="string" />
<field id="tabs" type="array" /> <field id="tabs" type="array" />
<field id="tabsParams" type="assocarray" /> <field id="tabsParams" type="assocarray" />
<field id="tabsTitles" type="assocarray" />
<field id="thumbnail" type="string" /> <field id="thumbnail" type="string" />
<field id="videoCount" type="integer" /> <field id="videoCount" type="integer" />
<field id="videoCountText" type="string" /> <field id="videoCountText" type="string" />
@@ -54,17 +54,6 @@ function PlaylistContentTask(input as object) as object
} }
end if end if
' TODO:P2 To remove after https://github.com/iv-org/invidious/pull/5116
if IsString(metadata["mixId"]) and IsArray(metadata["videos"])
videos = metadata["videos"]
for i = 0 to videos.Count() - 1
thumbnails = videos[i].videoThumbnails
if thumbnails.Count() = 1 and IsArray(thumbnails[0])
videos[i].videoThumbnails = thumbnails[0]
end if
end for
end if
InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance) InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance)
childCount = contentNode.getChildCount() childCount = contentNode.getChildCount()
@@ -8,6 +8,7 @@
<field id="accessToken" type="string" /> <field id="accessToken" type="string" />
<!-- Innertube fields --> <!-- Innertube fields -->
<field id="thumbnail" type="uri" />
<field id="refreshToken" type="string" /> <field id="refreshToken" type="string" />
<field id="scope" type="string" /> <field id="scope" type="string" />
<field id="tokenType" type="string" /> <field id="tokenType" type="string" />
@@ -1,4 +1,4 @@
<component name="LoginDialog" extends="StandardDialog" initialFocus="buttonArea" includes="AutoBind"> <component name="InvidiousLoginDialog" extends="StandardDialog" initialFocus="buttonArea" includes="AutoBind">
<interface> <interface>
<field id="webServer" type="node" bind="/WebServer" /> <field id="webServer" type="node" bind="/WebServer" />
<field id="invidious" type="node" bind="/Invidious" /> <field id="invidious" type="node" bind="/Invidious" />
@@ -0,0 +1,51 @@
import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.qrCode = m.top.findNode("QrCodePoster")
codeLabel = m.top.findNode("codeLabel")
if codeLabel <> invalid
codeLabel = codeLabel.getChild(0)
if codeLabel <> invalid
codeFont = m.top.findNode("codeFont")
codeLabel.font = codeFont
end if
end if
m.top.width = "920"
m.top.observeFieldScoped("buttonSelected", FuncName(Close))
m.top.observeFieldScoped("wasClosed", FuncName(OnWasClosed))
scanLabel = m.top.findNode("scanLabel")
' TODO:P2 localize all dialog items
scanLabel.text = Tr(Locale.Dialogs.ScanTheQrCode)
end function
function OnNodeReady()
m.task = AsyncTask.Start(Tasks.YouTubeLoginTask, {
dialog: m.top
profilesService: m.top.profilesService
})
end function
function OnCodeSet(event as object)
code = event.getData()
m.qrCode.text = code
end function
function Close()
m.top.close = true
end function
function OnWasClosed()
if m.task <> invalid
m.task.cancel = true
m.task = invalid
end if
end function
function OnUrlSet()
m.qrCode.text = m.top.url
end function
@@ -0,0 +1,49 @@
<component name="YouTubeLoginDialog" extends="StandardDialog" initialFocus="buttonArea" includes="AutoBind">
<interface>
<field id="profilesService" type="node" bind="/ProfilesService" />
<field id="code" type="string" alias="codeLabel.text" />
<field id="url" type="string" onChange="OnUrlSet" />
<field id="alwaysOnTop" type="boolean" />
</interface>
<children>
<Font id="codeFont" uri="font:MediumSystemFontFile" size="36" />
<StdDlgTitleArea primaryTitle="Login to YouTube" />
<StdDlgContentArea>
<StdDlgTextItem text="Open the link 'https://yt.be/activate' and enter the following code:" />
<StdDlgTextItem id="codeLabel" text="Loading..." />
</StdDlgContentArea>
<StdDlgButtonArea id="buttonArea">
<StdDlgButton text="OK" />
</StdDlgButtonArea>
<StdDlgSideCardArea
id="sideCarArea"
horizAlign="right"
width="400"
extendToDialogEdge="false"
showDivider="false">
<Label
id="scanLabel"
text="Scan the QR Code"
horizAlign="center"
wrap="true" width="400">
<Font role="font" uri="font:SystemFontFile" size="24" />
</Label>
<QrCodePoster
id="QrCodePoster"
width="300"
height="300"
loadWidth="300"
loadHeight="300"
padding="10"
translation="[50, 50]" />
<Label
horizAlign="center"
width="400"
translation="[0, 380]"
text="https://yt.be/activate">
<Font role="font" uri="font:MediumSystemFontFile" size="18" />
</Label>
</StdDlgSideCardArea>
</children>
</component>
@@ -0,0 +1,118 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Services/Innertube/InnertubeService.bs"
import "pkg:/source/utils/CancellationUtils.bs"
import "pkg:/source/utils/Logging.bs"
@asynctask
function YouTubeLoginTask(input as object) as object
profilesNode = input.profilesService
dialogNode = input.dialog
cancellation = m.top.cancellation
' TODO:P2 cache client identity
authCode = InnertubeService.AuthGetCode(cancellation)
if CancellationUtils.IsCancelled(cancellation)
return invalid
end if
if authCode.error <> invalid
LogError(authCode.error)
DialogUtils.ShowDialogEx({
title: "Error"
message: authCode.error
large: true
})
return invalid
end if
url = InnertubeService.AuthGetActivationUrl(authCode)
LogInfo("Login url:", url)
dialogNode.url = url
dialogNode.code = authCode.userCode
accessToken = InnertubeService.AuthPollForAccessToken(authCode, cancellation)
if CancellationUtils.IsCancelled(cancellation)
return invalid
end if
if accessToken.error <> invalid
LogError(accessToken.error)
DialogUtils.ShowDialogEx({
title: "Error"
message: accessToken.error
large: true
})
return invalid
end if
accounts = InnertubeService.AuthListAccounts(accessToken.accessToken, cancellation)
if CancellationUtils.IsCancelled(cancellation)
return invalid
end if
if IsAssociativeArray(accounts) and accounts.error <> invalid
LogError(accounts.error)
DialogUtils.ShowDialogEx({
title: "Error"
message: accounts.error
large: true
})
return invalid
end if
if not IsArray(accounts) or accounts.Count() = 0
LogError("No accounts found")
DialogUtils.ShowDialogEx({
title: "Error"
message: "No accounts found"
large: true
})
return invalid
end if
selectedAccount = invalid
for each account in accounts
if ValidBool(account.isSelected)
selectedAccount = account
exit for
end if
end for
if selectedAccount = invalid
selectedAccount = accounts[0]
end if
profile = CreateProfileContentNode(selectedAccount, accessToken)
profilesNode@.LoginWithProfile(profile)
dialogNode.close = true
return invalid
end function
function CreateProfileContentNode(account as object, accessToken as object) as object
profile = CreateObject("roSGNode", "ProfileContentNode")
profile.type = "youtube"
profile.serverUrl = "http://127.0.0.1:8888/playlet-invidious-backend"
username = account.channelHandle
if StringUtils.IsNullOrEmpty(username)
username = account.accountByline
end if
profile.username = username
profile.thumbnail = account.accountPhoto
profile.accessToken = accessToken.accessToken
profile.refreshToken = accessToken.refreshToken
profile.scope = accessToken.scope
profile.tokenType = accessToken.tokenType
profile.expiresIn = accessToken.expiresIn
profile.expiresTimestamp = accessToken.expiresTimestamp
profile.clientId = accessToken.clientId
profile.clientSecret = accessToken.clientSecret
return profile
end function
+13 -3
View File
@@ -40,7 +40,6 @@ function MainSceneContainerChanged()
InitEcpArgs() InitEcpArgs()
m.scene.signalBeacon("AppLaunchComplete") m.scene.signalBeacon("AppLaunchComplete")
CopyLoadingMessagesToCache() CopyLoadingMessagesToCache()
ShowAnnouncement()
end function end function
function StartWebServer() function StartWebServer()
@@ -54,8 +53,8 @@ function StartWebServer()
m.dialServer@.StartServer() m.dialServer@.StartServer()
end function end function
function ShowAnnouncement() function ShowAnnouncement() as void
DialogUtils.ShowDialogOnce({ dialog = DialogUtils.ShowDialogOnce({
messageId: "1736288537" messageId: "1736288537"
title: "Announcement - Playlet backend" title: "Announcement - Playlet backend"
message: [ message: [
@@ -68,4 +67,15 @@ function ShowAnnouncement()
alwaysOnTop: true alwaysOnTop: true
marginWidth: 180 marginWidth: 180
}) })
if dialog = invalid
return
end if
m.scene.signalBeacon("AppDialogInitiate")
m.top.observeField("wasClosed", FuncName(OnAnnouncementDialogClosed))
end function
function OnAnnouncementDialogClosed()
m.scene.signalBeacon("AppDialogComplete")
end function end function
@@ -39,7 +39,6 @@ function MainSceneContainerChanged()
InitEcpArgs() InitEcpArgs()
m.scene.signalBeacon("AppLaunchComplete") m.scene.signalBeacon("AppLaunchComplete")
CopyLoadingMessagesToCache() CopyLoadingMessagesToCache()
ShowAnnouncement()
end function end function
function StartWebServer() function StartWebServer()
@@ -51,8 +50,8 @@ function StartWebServer()
m.dialServer.callfunc("StartServer", invalid) m.dialServer.callfunc("StartServer", invalid)
end function end function
function ShowAnnouncement() function ShowAnnouncement() as void
DialogUtils_ShowDialogOnce({ dialog = DialogUtils_ShowDialogOnce({
messageId: "1736288537" messageId: "1736288537"
title: "Announcement - Playlet backend" title: "Announcement - Playlet backend"
message: [ message: [
@@ -65,5 +64,14 @@ function ShowAnnouncement()
alwaysOnTop: true alwaysOnTop: true
marginWidth: 180 marginWidth: 180
}) })
if dialog = invalid
return
end if
m.scene.signalBeacon("AppDialogInitiate")
m.top.observeField("wasClosed", FuncName(OnAnnouncementDialogClosed))
end function
function OnAnnouncementDialogClosed()
m.scene.signalBeacon("AppDialogComplete")
end function end function
'//# sourceMappingURL=./MainScene.brs.map '//# sourceMappingURL=./MainScene.brs.map
@@ -47,6 +47,7 @@
<BookmarksService id="BookmarksService" /> <BookmarksService id="BookmarksService" />
<SearchHistory id="SearchHistory" /> <SearchHistory id="SearchHistory" />
<ProfilesService id="ProfilesService" /> <ProfilesService id="ProfilesService" />
<Innertube id="Innertube" />
<Invidious id="Invidious" /> <Invidious id="Invidious" />
<PlayletWebServer id="WebServer" port="8888" /> <PlayletWebServer id="WebServer" port="8888" />
<DialServer id="DialServer" /> <DialServer id="DialServer" />
+3
View File
@@ -56,6 +56,7 @@
<VideoQueue id="VideoQueue" <VideoQueue id="VideoQueue"
appController="bind:/AppController" appController="bind:/AppController"
videoContainer="bind:../VideoContainer" videoContainer="bind:../VideoContainer"
innertube="bind:../Innertube"
invidious="bind:../Invidious" invidious="bind:../Invidious"
notifications="bind:../Notifications" notifications="bind:../Notifications"
preferences="bind:../Preferences" preferences="bind:../Preferences"
@@ -70,6 +71,7 @@
<ProfilesService id="ProfilesService" <ProfilesService id="ProfilesService"
invidious="bind:../Invidious" /> invidious="bind:../Invidious" />
<Innertube id="Innertube" />
<Invidious id="Invidious" <Invidious id="Invidious"
webServer="bind:../WebServer" webServer="bind:../WebServer"
applicationInfo="bind:../ApplicationInfo" applicationInfo="bind:../ApplicationInfo"
@@ -81,6 +83,7 @@
port="8888" port="8888"
appController="bind:/AppController" appController="bind:/AppController"
applicationInfo="bind:../ApplicationInfo" applicationInfo="bind:../ApplicationInfo"
innertube="bind:../Innertube"
invidious="bind:../Invidious" invidious="bind:../Invidious"
profilesService="bind:../ProfilesService" profilesService="bind:../ProfilesService"
preferences="bind:../Preferences" preferences="bind:../Preferences"
@@ -18,6 +18,7 @@ function InitializeBindings()
"VideoQueue": { "VideoQueue": {
"appController": "/AppController", "appController": "/AppController",
"videoContainer": "../VideoContainer", "videoContainer": "../VideoContainer",
"innertube": "../Innertube",
"invidious": "../Invidious", "invidious": "../Invidious",
"notifications": "../Notifications", "notifications": "../Notifications",
"preferences": "../Preferences", "preferences": "../Preferences",
@@ -38,6 +39,7 @@ function InitializeBindings()
"WebServer": { "WebServer": {
"appController": "/AppController", "appController": "/AppController",
"applicationInfo": "../ApplicationInfo", "applicationInfo": "../ApplicationInfo",
"innertube": "../Innertube",
"invidious": "../Invidious", "invidious": "../Invidious",
"profilesService": "../ProfilesService", "profilesService": "../ProfilesService",
"preferences": "../Preferences", "preferences": "../Preferences",
@@ -23,13 +23,28 @@ function OnCurrentProfile() as void
return return
end if end if
username = currentProfile.username thumbnail = currentProfile.thumbnail
if not StringUtils.IsNullOrEmpty(username) if not StringUtils.IsNullOrEmpty(thumbnail)
m.letterLabel.text = UCase(username.Left(1)) m.circlePosterInner.uri = thumbnail
else ' bs:disable-next-line LINT3023
m.circlePosterInner.blendColor = "#FFFFFFFF"
m.letterLabel.text = "" m.letterLabel.text = ""
else
m.circlePosterInner.uri = "pkg:/images/white-circle.png"
m.circlePosterInner.blendColor = currentProfile.color
username = currentProfile.username
if not StringUtils.IsNullOrEmpty(username)
letter = username.Left(1)
if letter = "@" and Len(username) > 1
letter = username.Mid(1, 1)
end if
m.letterLabel.text = UCase(letter)
else
m.letterLabel.text = ""
end if
end if end if
m.circlePosterInner.blendColor = currentProfile.color
m.circlePoster.visible = true m.circlePoster.visible = true
m.buttonIcon.visible = false m.buttonIcon.visible = false
@@ -12,7 +12,7 @@
height="40" height="40"
blendColor="#DDDDDDFF" blendColor="#DDDDDDFF"
uri="pkg:/images/white-circle.png"> uri="pkg:/images/white-circle.png">
<Poster <CirclePoster
id="circlePosterInner" id="circlePosterInner"
width="36" width="36"
height="36" height="36"
@@ -27,7 +27,7 @@
horizAlign="center"> horizAlign="center">
<Font role="font" uri="font:SystemFontFile" size="24" /> <Font role="font" uri="font:SystemFontFile" size="24" />
</Label> </Label>
</Poster> </CirclePoster>
</Poster> </Poster>
</children> </children>
</component> </component>
@@ -0,0 +1,9 @@
function OnContentSet() as void
content = m.top.itemContent
if content = invalid
return
end if
m.top.backendName = content.title
m.top.backendLogoUri = content.backendLogoUri
end function
@@ -0,0 +1,24 @@
<component name="BackendTypeRowListCell" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="backendName" type="string" alias="BackendNameLabel.text" />
<field id="backendLogoUri" type="uri" alias="BackendLogoPoster.uri" />
</interface>
<children>
<Group translation="[20,20]">
<Poster
id="BackendLogoPoster"
width="160"
height="160"
translation="[20,20]">
</Poster>
<Label
id="BackendNameLabel"
width="200"
horizAlign="center"
translation="[0,240]">
</Label>
</Group>
</children>
</component>
@@ -0,0 +1,57 @@
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.rowList = m.top.FindNode("BackendRowList")
m.rowList.ObserveField("rowItemSelected", FuncName(OnRowItemSelected))
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
NodeSetFocus(m.rowList, true)
end function
function OnKeyEvent(key as string, press as boolean) as boolean
if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly
' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play
return false
end if
if key = RemoteKeys.Back and press
Close()
return true
end if
return true
end function
function Close()
m.top.appController@.PopScreen()
end function
function OnRowItemSelected(event as object) as void
index = event.GetData()
if index = invalid or index.count() <> 2
LogWarn("Invalid index:", index)
return
end if
Close()
content = m.rowList.content
rowIndex = index[0]
rowItemIndex = index[1]
row = content.GetChild(rowIndex)
rowItem = row.GetChild(rowItemIndex)
m.top.selectedBackendType = rowItem.id
end function
@@ -0,0 +1,46 @@
<component name="BackendTypeSelectionView" extends="Group" includes="AutoBind,Focus">
<interface>
<field id="selectedBackendType" type="string" />
<field id="appController" type="node" bind="/AppController" />
</interface>
<children>
<Rectangle
width="1280"
height="720"
color="#000000"
opacity="0.5">
</Rectangle>
<Rectangle
width="720"
height="420"
translation="[280,150]"
color="#242424">
<Label
width="720"
horizAlign="center"
translation="[0,38]"
text="Select a service to login">
<Font role="font" uri="font:SystemFontFile" size="24" />
</Label>
<RowList
id="BackendRowList"
translation="[120,100]"
numRows="2"
rowitemSize="[[240,240]]"
rowItemSpacing="[[0,0]]"
itemSize="[500,500]"
itemComponentName="BackendTypeRowListCell"
rowFocusAnimationStyle="floatingfocus"
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png">
<ContentNode role="content">
<ContentNode>
<BackendTypeContentNode id="BackendTypeYouTube" title="YouTube" backendLogoUri="pkg:/images/youtube-logo.png" />
<BackendTypeContentNode id="BackendTypeInvidious" title="Invidious" backendLogoUri="pkg:/images/invidious-logo.png" />
</ContentNode>
</ContentNode>
</RowList>
</Rectangle>
</children>
</component>
@@ -0,0 +1,11 @@
namespace BackendTypeSelectionViewUtils
function Open(appController as object) as object
backendTypeSelectionView = CreateObject("roSGNode", "BackendTypeSelectionView")
appController@.PushScreen(backendTypeSelectionView)
backendTypeSelectionView@.BindNode()
return backendTypeSelectionView
end function
end namespace
@@ -1,2 +0,0 @@
<component name="ProfileRowList" extends="RowList">
</component>
@@ -14,6 +14,7 @@ function OnContentSet() as void
if content.type = "login" if content.type = "login"
m.top.circlePosterInnerUri = "pkg:/images/icons/user-200.png" m.top.circlePosterInnerUri = "pkg:/images/icons/user-200.png"
m.top.backendTypePosterUri = ""
' bs:disable-next-line LINT3023 ' bs:disable-next-line LINT3023
m.top.circlePosterInnerBlendColor = "#FFFFFFFF" m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
m.top.letter = "" m.top.letter = ""
@@ -23,17 +24,43 @@ function OnContentSet() as void
return return
end if end if
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
m.top.circlePosterInnerBlendColor = content.color
username = content.username username = content.username
m.top.username = username m.top.username = username
if not StringUtils.IsNullOrEmpty(username)
m.top.letter = UCase(username.Left(1)) thumbnail = content.thumbnail
else if not StringUtils.IsNullOrEmpty(thumbnail)
m.top.circlePosterInnerUri = thumbnail
' bs:disable-next-line LINT3023
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
m.top.letter = "" m.top.letter = ""
else
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
m.top.circlePosterInnerBlendColor = content.color
if not StringUtils.IsNullOrEmpty(username)
letter = username.Left(1)
if letter = "@" and Len(username) > 1
letter = username.Mid(1, 1)
end if
m.top.letter = UCase(letter)
else
m.top.letter = ""
end if
end if end if
m.top.serverUrl = content.serverUrl
m.top.crownVisible = content.isSelected m.top.crownVisible = content.isSelected
backendType = content.type
if backendType = "invidious"
m.top.serverUrl = content.serverUrl
m.top.backendTypePosterUri = "pkg:/images/invidious-logo.png"
else if backendType = "youtube"
m.top.serverUrl = "YouTube"
m.top.backendTypePosterUri = "pkg:/images/youtube-logo.png"
else
m.top.serverUrl = ""
m.top.backendTypePosterUri = ""
end if
end function end function
function OnRowListHasFocus() function OnRowListHasFocus()
@@ -6,6 +6,7 @@
<field id="serverUrl" type="string" alias="ServerLabel.text" /> <field id="serverUrl" type="string" alias="ServerLabel.text" />
<field id="circlePosterInnerUri" type="uri" alias="circlePosterInner.uri" /> <field id="circlePosterInnerUri" type="uri" alias="circlePosterInner.uri" />
<field id="circlePosterInnerBlendColor" type="uri" alias="circlePosterInner.blendColor" /> <field id="circlePosterInnerBlendColor" type="uri" alias="circlePosterInner.blendColor" />
<field id="backendTypePosterUri" type="uri" alias="backendTypePoster.uri" />
<field id="UsernameLabelFont" type="boolean" alias="UsernameLabel.font" /> <field id="UsernameLabelFont" type="boolean" alias="UsernameLabel.font" />
<field id="rowListHasFocus" type="boolean" onChange="OnRowListHasFocus" /> <field id="rowListHasFocus" type="boolean" onChange="OnRowListHasFocus" />
<field id="itemHasFocus" type="boolean" onChange="OnItemHasFocus" /> <field id="itemHasFocus" type="boolean" onChange="OnItemHasFocus" />
@@ -45,7 +46,7 @@
translation="[20,20]" translation="[20,20]"
blendColor="#DDDDDDFF" blendColor="#DDDDDDFF"
uri="pkg:/images/white-circle.png"> uri="pkg:/images/white-circle.png">
<Poster <CirclePoster
id="circlePosterInner" id="circlePosterInner"
width="152" width="152"
height="152" height="152"
@@ -60,7 +61,13 @@
horizAlign="center"> horizAlign="center">
<Font role="font" uri="font:SystemFontFile" size="120" /> <Font role="font" uri="font:SystemFontFile" size="120" />
</Label> </Label>
</Poster> <Poster
id="backendTypePoster"
width="60"
height="60"
translation="[110,110]"
/>
</CirclePoster>
<Poster <Poster
id="CrownPoster" id="CrownPoster"
width="60" width="60"
@@ -1,7 +1,9 @@
import "pkg:/components/Dialog/DialogUtils.bs" import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Navigation/Navigation.bs" import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/ProfileView/ProfileViewUtils.bs" import "pkg:/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionViewUtils.bs"
import "pkg:/components/Screens/ProfileScreen/ProfileView/ProfileViewUtils.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs" import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -38,26 +40,79 @@ function OnRowItemSelected() as void
row = m.profileRowList.content.GetChild(0) row = m.profileRowList.content.GetChild(0)
selectedProfile = row.GetChild(index) selectedProfile = row.GetChild(index)
if selectedProfile.type = "login" if selectedProfile.type = "login"
invidiousInstance = m.preferences["invidious.instance"] #if YT_OAUTH_SUPPORT
if StringUtils.IsNullOrEmpty(invidiousInstance) backendTypeSelectionView = BackendTypeSelectionViewUtils.Open(m.appController)
DialogUtils.ShowDialogEx({ backendTypeSelectionView.observeFieldScoped("selectedBackendType", FuncName(OnBackEndSelected))
title: "No Invidious Instance"
message: [
"Playlet built-in backend does not support login yet.",
"Can only login if an Invidious instance is set in the settings."
]
})
return return
end if #else
dialog = CreateObject("roSGNode", "LoginDialog") LoginWithInvidious()
dialog@.BindNode() return
m.top.getScene().dialog = dialog #end if
return
end if end if
ProfileViewUtils.Open(selectedProfile, m.appController) ProfileViewUtils.Open(selectedProfile, m.appController)
end function end function
function OnBackEndSelected(event as object) as void
backendTypeSelectionView = event.GetRoSGNode()
backendTypeSelectionView.unobserveFieldScoped("selectedBackendType")
selectedBackendType = event.getData()
if selectedBackendType = "BackendTypeInvidious"
LoginWithInvidious()
else if selectedBackendType = "BackendTypeYouTube"
ShowLoginWithYouTubeDialog()
else
LogError("Unknown backend type:", selectedBackendType)
end if
end function
function LoginWithInvidious() as void
invidiousInstance = m.preferences["invidious.instance"]
if StringUtils.IsNullOrEmpty(invidiousInstance)
DialogUtils.ShowDialogEx({
title: "No Invidious Instance"
message: [
"Playlet built-in backend does not support login yet.",
"Can only login if an Invidious instance is set in the settings."
]
})
return
end if
dialog = CreateObject("roSGNode", "InvidiousLoginDialog")
dialog@.BindNode()
m.top.getScene().dialog = dialog
end function
function ShowLoginWithYouTubeDialog() as void
' TODO:P2 localize
dialog = DialogUtils.ShowDialogEx({
title: "Disclaimer"
message: "Playlet authors acknowledge that all trademarks and registered trademarks mentioned in this application and related pages are the property of their respective owners. The use of these trademarks or trade names is for identification purposes only and does not imply any endorsement, affiliation, or sponsorship by the trademark owner."
buttons: [
Tr(Locale.Buttons.OK)
Tr(Locale.Buttons.Cancel)
]
})
dialog.ObserveField("buttonSelected", FuncName(OnLoginWithYouTubeDialogButtonSelected))
end function
function OnLoginWithYouTubeDialogButtonSelected(event as object) as void
buttonSelected = event.getData()
if buttonSelected <> 0
return
end if
LoginWithYouTube()
end function
function LoginWithYouTube() as void
dialog = CreateObject("roSGNode", "YouTubeLoginDialog")
dialog@.BindNode()
m.top.getScene().dialog = dialog
end function
function OnCurrentProfileChanged() as void function OnCurrentProfileChanged() as void
currentProfile = m.profilesService.currentProfile currentProfile = m.profilesService.currentProfile
if currentProfile = invalid if currentProfile = invalid
@@ -7,7 +7,7 @@
</interface> </interface>
<children> <children>
<ProfileRowList <RowList
id="ProfileRowList" id="ProfileRowList"
translation="[0,160]" translation="[0,160]"
numRows="2" numRows="2"
@@ -32,17 +32,44 @@ function OnContentSet() as void
return return
end if end if
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
m.top.circlePosterInnerBlendColor = content.color
username = content.username username = content.username
m.top.username = username m.top.username = username
if not StringUtils.IsNullOrEmpty(username)
m.top.letter = UCase(username.Left(1)) thumbnail = content.thumbnail
else if not StringUtils.IsNullOrEmpty(thumbnail)
m.top.circlePosterInnerUri = thumbnail
' bs:disable-next-line LINT3023
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
m.top.letter = "" m.top.letter = ""
else
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
m.top.circlePosterInnerBlendColor = content.color
if not StringUtils.IsNullOrEmpty(username)
letter = username.Left(1)
if letter = "@" and Len(username) > 1
letter = username.Mid(1, 1)
end if
m.top.letter = UCase(letter)
else
m.top.letter = ""
end if
end if end if
m.top.serverUrl = content.serverUrl
m.top.crownVisible = content.isSelected m.top.crownVisible = content.isSelected
backendType = content.type
if backendType = "invidious"
m.top.serverUrl = content.serverUrl
m.top.backendTypePosterUri = "pkg:/images/invidious-logo.png"
else if backendType = "youtube"
m.top.serverUrl = "YouTube"
m.top.backendTypePosterUri = "pkg:/images/youtube-logo.png"
else
m.top.serverUrl = ""
m.top.backendTypePosterUri = ""
end if
UpdateActivateButton() UpdateActivateButton()
end function end function
@@ -5,6 +5,7 @@
<field id="username" type="string" alias="UsernameLabel.text" /> <field id="username" type="string" alias="UsernameLabel.text" />
<field id="serverUrl" type="string" alias="ServerLabel.text" /> <field id="serverUrl" type="string" alias="ServerLabel.text" />
<field id="circlePosterInnerUri" type="uri" alias="circlePosterInner.uri" /> <field id="circlePosterInnerUri" type="uri" alias="circlePosterInner.uri" />
<field id="backendTypePosterUri" type="uri" alias="backendTypePoster.uri" />
<field id="circlePosterInnerBlendColor" type="uri" alias="circlePosterInner.blendColor" /> <field id="circlePosterInnerBlendColor" type="uri" alias="circlePosterInner.blendColor" />
<field id="crownVisible" type="boolean" alias="CrownPoster.visible" /> <field id="crownVisible" type="boolean" alias="CrownPoster.visible" />
@@ -32,7 +33,7 @@
translation="[20,20]" translation="[20,20]"
blendColor="#DDDDDDFF" blendColor="#DDDDDDFF"
uri="pkg:/images/white-circle.png"> uri="pkg:/images/white-circle.png">
<Poster <CirclePoster
id="circlePosterInner" id="circlePosterInner"
width="152" width="152"
height="152" height="152"
@@ -47,7 +48,13 @@
horizAlign="center"> horizAlign="center">
<Font role="font" uri="font:SystemFontFile" size="120" /> <Font role="font" uri="font:SystemFontFile" size="120" />
</Label> </Label>
</Poster> <Poster
id="backendTypePoster"
width="60"
height="60"
translation="[110,110]"
/>
</CirclePoster>
<Poster <Poster
id="CrownPoster" id="CrownPoster"
width="60" width="60"
@@ -1,6 +1,7 @@
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs" import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs" import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -9,7 +10,7 @@ function Init()
m.top.itemSpacings = [8] m.top.itemSpacings = [8]
m.button = m.top.findNode("button") m.button = m.top.findNode("button")
m.button.text = Invidious.DEFAULT_INSTANCE_NAME m.button.text = Tr(Locale.Settings.PlayletBuiltinBackend)
AdjustButtonLabel(m.button) AdjustButtonLabel(m.button)
m.button.observeField("buttonSelected", FuncName(OpenInvidiousInstanceSettings)) m.button.observeField("buttonSelected", FuncName(OpenInvidiousInstanceSettings))
@@ -81,7 +82,7 @@ function OnValueChange() as void
m.preferences[m.key] = value m.preferences[m.key] = value
if StringUtils.IsNullOrEmpty(value) if StringUtils.IsNullOrEmpty(value)
m.button.text = Invidious.DEFAULT_INSTANCE_NAME m.button.text = Tr(Locale.Settings.PlayletBuiltinBackend)
else else
m.button.text = value m.button.text = value
end if end if
@@ -8,7 +8,7 @@ namespace Innertube
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"context": Innertube.CreateContext(clienType, deviceInfo, "") "context": Innertube.CreateContext(clienType, deviceInfo, "", "")
} }
if not StringUtils.IsNullOrEmpty(continuation) if not StringUtils.IsNullOrEmpty(continuation)
@@ -1,20 +1,21 @@
const INNERTUBE_IOS_CLIENT_NAME = "5" const INNERTUBE_IOS_CLIENT_NAME = "5"
const INNERTUBE_IOS_CLIENT_VERSION = "19.49.7" const INNERTUBE_IOS_CLIENT_VERSION = "19.49.7"
const INNERTUBE_IOS_OS_VERSION = "15.6" const INNERTUBE_IOS_DEVICE_MODEL = "iPhone16,2"
const INNERTUBE_IOS_USER_AGENT = "com.google.ios.youtube/19.49.7 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)" const INNERTUBE_IOS_OS_VERSION = "18.1"
const INNERTUBE_IOS_USER_AGENT = "com.google.ios.youtube/19.49.7 (iPhone16,2; U; CPU iOS 18_1_0 like Mac OS X)"
const INNERTUBE_WEB_CLIENT_NAME = "1"
const INNERTUBE_WEB_CLIENT_VERSION = "2.20241230.09.00"
const INNERTUBE_WEB_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0"
const INNERTUBE_WEB_BROWSER_NAME = "Chrome" const INNERTUBE_WEB_BROWSER_NAME = "Chrome"
const INNERTUBE_WEB_BROWSER_VERSION = "131.0.0.0" const INNERTUBE_WEB_BROWSER_VERSION = "135.0.0.0"
const INNERTUBE_WEB_CLIENT_NAME = "1"
const INNERTUBE_WEB_CLIENT_VERSION = "2.20250502.01.00"
const INNERTUBE_WEB_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0"
const INNERTUBE_TV_BROWSER_NAME = "LG Browser"
const INNERTUBE_TV_BROWSER_VERSION = "7.00.00"
const INNERTUBE_TV_CLIENT_NAME = "2" const INNERTUBE_TV_CLIENT_NAME = "2"
const INNERTUBE_TV_CLIENT_VERSION = "7.20241211.14.01" const INNERTUBE_TV_CLIENT_VERSION = "7.20241211.14.01"
const INNERTUBE_TV_USER_AGENT = "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/538.2 (KHTML, like Gecko) Large Screen Safari/538.2 LG Browser/7.00.00(LGE; 24LF4820-BU; 03.20.14; 1; DTV_W15L); webOS.TV-2015; LG NetCast.TV-2013 Compatible (LGE, 24LF4820-BU, wireless)"
const INNERTUBE_TV_DEVICE_MAKE = "LGE" const INNERTUBE_TV_DEVICE_MAKE = "LGE"
const INNERTUBE_TV_DEVICE_MODEL = "24LF4820-BU" const INNERTUBE_TV_DEVICE_MODEL = "24LF4820-BU"
const INNERTUBE_TV_OS_NAME = "webOS" const INNERTUBE_TV_OS_NAME = "webOS"
const INNERTUBE_TV_OS_VERSION = "2015" const INNERTUBE_TV_OS_VERSION = "2015"
const INNERTUBE_TV_BROWSER_NAME = "LG Browser" const INNERTUBE_TV_USER_AGENT = "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/538.2 (KHTML, like Gecko) Large Screen Safari/538.2 LG Browser/7.00.00(LGE; 24LF4820-BU; 03.20.14; 1; DTV_W15L); webOS.TV-2015; LG NetCast.TV-2013 Compatible (LGE, 24LF4820-BU, wireless)"
const INNERTUBE_TV_BROWSER_VERSION = "7.00.00"
@@ -33,7 +33,7 @@ namespace Innertube
end if end if
end function end function
function CreateContext(clienType as Innertube.ClientType, deviceInfo as object, ctt as string) as object function CreateContext(clienType as Innertube.ClientType, deviceInfo as object, ctt as string, visitorData as string) as object
client = invalid client = invalid
if clienType = ClientType.Web if clienType = ClientType.Web
client = CreateContextClientWeb(deviceInfo) client = CreateContextClientWeb(deviceInfo)
@@ -64,19 +64,22 @@ namespace Innertube
}] }]
end if end if
if not StringUtils.IsNullOrEmpty(visitorData)
context["client"]["visitorData"] = visitorData
end if
return context return context
end function end function
function CreateContextClientWeb(deviceInfo as object) as object function CreateContextClientWeb(deviceInfo as object) as object
return { return {
"hl": deviceInfo.GetCurrentLocale() "hl": GetCurrentLocale(deviceInfo)
"gl": GetContentRegion(deviceInfo) "gl": GetContentRegion(deviceInfo)
"remoteHost": "" "remoteHost": ""
"screenDensityFloat": 1 "screenDensityFloat": 1
"screenHeightPoints": 1440 "screenHeightPoints": 1440
"screenPixelDensity": 1 "screenPixelDensity": 1
"screenWidthPoints": 2560 "screenWidthPoints": 2560
"visitorData": ""
"clientName": "WEB" "clientName": "WEB"
"clientVersion": INNERTUBE_WEB_CLIENT_VERSION "clientVersion": INNERTUBE_WEB_CLIENT_VERSION
"osName": "Windows" "osName": "Windows"
@@ -103,14 +106,13 @@ namespace Innertube
function CreateContextClientIOS(deviceInfo as object) as object function CreateContextClientIOS(deviceInfo as object) as object
return { return {
"hl": deviceInfo.GetCurrentLocale() "hl": GetCurrentLocale(deviceInfo)
"gl": GetContentRegion(deviceInfo) "gl": GetContentRegion(deviceInfo)
"remoteHost": "" "remoteHost": ""
"screenDensityFloat": 1 "screenDensityFloat": 1
"screenHeightPoints": 1440 "screenHeightPoints": 1440
"screenPixelDensity": 1 "screenPixelDensity": 1
"screenWidthPoints": 2560 "screenWidthPoints": 2560
"visitorData": ""
"clientName": "iOS" "clientName": "iOS"
"clientVersion": INNERTUBE_IOS_CLIENT_VERSION "clientVersion": INNERTUBE_IOS_CLIENT_VERSION
"osName": "iOS" "osName": "iOS"
@@ -121,7 +123,7 @@ namespace Innertube
"timeZone": deviceInfo.GetTimeZone() "timeZone": deviceInfo.GetTimeZone()
"originalUrl": "https://www.youtube.com" "originalUrl": "https://www.youtube.com"
"deviceMake": "Apple" "deviceMake": "Apple"
"deviceModel": "iPhone10,6" "deviceModel": INNERTUBE_IOS_DEVICE_MODEL
"utcOffsetMinutes": -240 "utcOffsetMinutes": -240
"memoryTotalKbytes": "8000000" "memoryTotalKbytes": "8000000"
} }
@@ -129,7 +131,7 @@ namespace Innertube
function CreateContextClientTv(deviceInfo as object) as object function CreateContextClientTv(deviceInfo as object) as object
return { return {
"hl": deviceInfo.GetCurrentLocale() "hl": GetCurrentLocale(deviceInfo)
"gl": GetContentRegion(deviceInfo) "gl": GetContentRegion(deviceInfo)
"remoteHost": "" "remoteHost": ""
"deviceMake": INNERTUBE_TV_DEVICE_MAKE "deviceMake": INNERTUBE_TV_DEVICE_MAKE
@@ -159,6 +161,10 @@ namespace Innertube
} }
end function end function
function GetCurrentLocale(deviceInfo as object) as string
return deviceInfo.GetCurrentLocale()
end function
function GetContentRegion(deviceInfo as object) as string function GetContentRegion(deviceInfo as object) as string
region = deviceInfo.GetUserCountryCode() region = deviceInfo.GetUserCountryCode()
if region.len() <> 2 or region = "OT" if region.len() <> 2 or region = "OT"
@@ -0,0 +1,9 @@
import "pkg:/components/Services/Innertube/Constants.bs"
import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs"
function Init()
AsyncTask.Start(Tasks.InnertubeInitTask, {
innertube: m.top
})
end function
@@ -0,0 +1,5 @@
<component name="Innertube" extends="Node">
<interface>
<field id="visitorData" type="string" />
</interface>
</component>
@@ -0,0 +1,15 @@
import "pkg:/components/Services/Innertube/SessionData.bs"
@asynctask
function InnertubeInitTask(input as object) as object
innertubeNode = input.innertube
sessionData = Innertube.GetSessionData()
if sessionData = invalid
return invalid
end if
innertubeNode.visitorData = sessionData.visitorData
return invalid
end function
@@ -18,6 +18,8 @@ namespace InnertubeService
cancellation = invalid cancellation = invalid
fetchNext = true fetchNext = true
ctt = "" ctt = ""
visitorData = ""
raw = false
if options <> invalid if options <> invalid
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
@@ -29,9 +31,15 @@ namespace InnertubeService
if options.DoesExist("ctt") if options.DoesExist("ctt")
ctt = options.ctt ctt = options.ctt
end if end if
if options.DoesExist("raw")
raw = options.raw
end if
if options.DoesExist("visitorData")
visitorData = options.visitorData
end if
end if end if
playerRequest = Innertube.CreatePlayerRequest(videoId, ctt) playerRequest = Innertube.CreatePlayerRequest(videoId, ctt, visitorData)
playerRequest.Cancellation(cancellation) playerRequest.Cancellation(cancellation)
playerRequest.Send() playerRequest.Send()
@@ -60,6 +68,16 @@ namespace InnertubeService
nextResponse = nextRequest.Await() nextResponse = nextRequest.Await()
end if end if
if raw
rawResponse = {
"playerResponse": playerResponse.Json()
}
if fetchNext
rawResponse["nextResponse"] = nextResponse.Json()
end if
return rawResponse
end if
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerResponse.Json()) parsedResponse = Innertube.ParseInnertubePlayerResponse(playerResponse.Json())
if parsedResponse.error <> invalid if parsedResponse.error <> invalid
return parsedResponse return parsedResponse
@@ -158,6 +176,7 @@ namespace InnertubeService
searchFilters = invalid searchFilters = invalid
continuation = "" continuation = ""
cancellation = invalid cancellation = invalid
raw = false
if options <> invalid if options <> invalid
if options.DoesExist("searchFilters") if options.DoesExist("searchFilters")
@@ -169,14 +188,18 @@ namespace InnertubeService
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
cancellation = options.cancellation cancellation = options.cancellation
end if end if
if options.DoesExist("raw")
raw = options.raw
end if
end if end if
return Innertube.Search(query, searchFilters, continuation, cancellation) return Innertube.Search(query, searchFilters, continuation, cancellation, raw)
end function end function
function GetTrending(options = invalid as object) as object function GetTrending(options = invalid as object) as object
cancellation = invalid cancellation = invalid
params = "" params = ""
raw = false
if options <> invalid if options <> invalid
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
@@ -186,13 +209,19 @@ namespace InnertubeService
trendingType = LCase(ValidString(options.type)) trendingType = LCase(ValidString(options.type))
if trendingType = "music" if trendingType = "music"
' {"44:proto": {"3:string": "ytma_charts"}}
params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D" params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
else if trendingType = "gaming" else if trendingType = "gaming"
' {"44:proto": {"3:string": "gaming_corpus_most_popular"}}
params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D" params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
else if trendingType = "movies" else if trendingType = "movies"
' {"44:proto": {"3:string": "trailers"}}
params = "4gIKGgh0cmFpbGVycw%3D%3D" params = "4gIKGgh0cmFpbGVycw%3D%3D"
end if end if
end if end if
if options.DoesExist("raw")
raw = options.raw
end if
end if end if
request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, params) request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, params)
@@ -200,11 +229,16 @@ namespace InnertubeService
response = request.Await() response = request.Await()
if not response.IsSuccess() if not response.IsSuccess()
return invalid return {
error: response.ErrorMessage()
}
end if end if
json = response.Json() if raw
feeds = Innertube.ParseResponseDataForFeeds(json, { skipCreatorOnTheRise: true }) return response.Json()
end if
feeds = Innertube.ParseResponseDataForFeeds(response.Json(), { skipCreatorOnTheRise: true })
result = { result = {
feeds: feeds feeds: feeds
@@ -259,7 +293,9 @@ namespace InnertubeService
response = request.Await() response = request.Await()
if not response.IsSuccess() if not response.IsSuccess()
return invalid return {
error: response.ErrorMessage()
}
end if end if
json = response.Json() json = response.Json()
@@ -270,6 +306,7 @@ namespace InnertubeService
continuation = "" continuation = ""
params = "" params = ""
cancellation = invalid cancellation = invalid
raw = false
if options <> invalid if options <> invalid
if options.DoesExist("continuation") if options.DoesExist("continuation")
@@ -281,6 +318,9 @@ namespace InnertubeService
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
cancellation = options.cancellation cancellation = options.cancellation
end if end if
if options.DoesExist("raw")
raw = options.raw
end if
end if end if
request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Web, params, continuation) request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Web, params, continuation)
@@ -293,8 +333,14 @@ namespace InnertubeService
} }
end if end if
json = response.Json() if raw
result = Innertube.ParseChannelPageResponseData(json) return response.Json()
end if
result = Innertube.ParseChannelPageResponseData(response.Json())
if result.authorId = invalid and result.error = invalid
result["authorId"] = channelId
end if
cacheControl = Innertube.ParseResponseForCacheControl(response) cacheControl = Innertube.ParseResponseForCacheControl(response)
if cacheControl <> invalid if cacheControl <> invalid
@@ -307,6 +353,7 @@ namespace InnertubeService
function GetPlaylist(playlistId as string, options = invalid as object) as object function GetPlaylist(playlistId as string, options = invalid as object) as object
continuation = "" continuation = ""
cancellation = invalid cancellation = invalid
raw = false
if options <> invalid if options <> invalid
if options.DoesExist("continuation") if options.DoesExist("continuation")
@@ -315,6 +362,9 @@ namespace InnertubeService
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
cancellation = options.cancellation cancellation = options.cancellation
end if end if
if options.DoesExist("raw")
raw = options.raw
end if
end if end if
if not playlistId.StartsWith("VL") if not playlistId.StartsWith("VL")
@@ -331,8 +381,11 @@ namespace InnertubeService
} }
end if end if
json = response.Json() if raw
result = Innertube.ParsePlaylistPageResponseData(json) return response.Json()
end if
result = Innertube.ParsePlaylistPageResponseData(response.Json())
cacheControl = Innertube.ParseResponseForCacheControl(response) cacheControl = Innertube.ParseResponseForCacheControl(response)
if cacheControl <> invalid if cacheControl <> invalid
@@ -345,6 +398,7 @@ namespace InnertubeService
function GetMix(mixId as string, options = invalid as object) as object function GetMix(mixId as string, options = invalid as object) as object
videoId = "" videoId = ""
cancellation = invalid cancellation = invalid
raw = false
if options <> invalid if options <> invalid
if options.DoesExist("videoId") if options.DoesExist("videoId")
@@ -353,6 +407,9 @@ namespace InnertubeService
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
cancellation = options.cancellation cancellation = options.cancellation
end if end if
if options.DoesExist("raw")
raw = options.raw
end if
end if end if
args = { "playlistId": mixId } args = { "playlistId": mixId }
@@ -369,8 +426,11 @@ namespace InnertubeService
} }
end if end if
json = response.Json() if raw
return Innertube.ParseMixPageResponseData(json) return response.Json()
end if
return Innertube.ParseMixPageResponseData(response.Json())
end function end function
function ResolveUrl(url as string, options = invalid as object) as object function ResolveUrl(url as string, options = invalid as object) as object
@@ -399,14 +459,14 @@ namespace InnertubeService
function AuthGetCode(cancellation = invalid as object) as object function AuthGetCode(cancellation = invalid as object) as object
result = Innertube.GetClientIdentity(cancellation) result = Innertube.GetClientIdentity(cancellation)
if CancellationUtils.IsCancelled(cancellation) if CancellationUtils.IsCancelled(cancellation) or result.error <> invalid
return invalid return result
end if end if
result2 = Innertube.GetDeviceAndUserCode(result.clientId, cancellation) result2 = Innertube.GetDeviceAndUserCode(result.clientId, cancellation)
if CancellationUtils.IsCancelled(cancellation) if CancellationUtils.IsCancelled(cancellation) or result2.error <> invalid
return invalid return result2
end if end if
result.Append(result2) result.Append(result2)
@@ -452,4 +512,7 @@ namespace InnertubeService
return Innertube.RevokeAccessToken(accessToken["accessToken"], cancellation) return Innertube.RevokeAccessToken(accessToken["accessToken"], cancellation)
end function end function
function AuthListAccounts(accessToken as string, cancellation = invalid as object) as object
return Innertube.ListAccounts(accessToken, cancellation)
end function
end namespace end namespace
@@ -12,7 +12,7 @@ namespace Innertube
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"context": Innertube.CreateContext(Innertube.ClientType.Web, deviceInfo, ctt) "context": Innertube.CreateContext(Innertube.ClientType.Web, deviceInfo, ctt, "")
} }
payload.Append(payloadArgs) payload.Append(payloadArgs)
@@ -1,3 +1,7 @@
' Throw an error if an unknown node is encountered.
' Only used in debug mode.
#const THROW_ON_UNKNOWN_NODES = true
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/ObjectUtils.bs" import "pkg:/source/utils/ObjectUtils.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
@@ -21,7 +25,12 @@ namespace Innertube
for each key in nodeData for each key in nodeData
directive = directives[key] directive = directives[key]
if directive = invalid if directive = invalid
LogWarn("Unknown node", key) LogWarn("Unknown node", key, `\n`, FormatJson(nodeData[key]))
#if THROW_ON_UNKNOWN_NODES
#if DEBUG
throw "Unknown node: " + key
#end if
#end if
continue for continue for
end if end if
@@ -37,8 +46,10 @@ namespace Innertube
"watchNextEndScreenRenderer": ParseWatchNextEndScreenRenderer "watchNextEndScreenRenderer": ParseWatchNextEndScreenRenderer
"tabRenderer": ParseTabRenderer "tabRenderer": ParseTabRenderer
"sectionListRenderer": ParseSectionListRenderer "sectionListRenderer": ParseSectionListRenderer
"richSectionRenderer": ParseRichSectionRenderer
"itemSectionRenderer": ParseItemSectionRenderer "itemSectionRenderer": ParseItemSectionRenderer
"shelfRenderer": ParseShelfRenderer "shelfRenderer": ParseShelfRenderer
"richShelfRenderer": ParseRichShelfRenderer
"reelShelfRenderer": ParseReelShelfRenderer "reelShelfRenderer": ParseReelShelfRenderer
"verticalListRenderer": ParseVerticalListRenderer "verticalListRenderer": ParseVerticalListRenderer
"horizontalListRenderer": ParseHorizontalListRenderer "horizontalListRenderer": ParseHorizontalListRenderer
@@ -78,6 +89,10 @@ namespace Innertube
"horizontalCardListRenderer": ParseNotImplemented "horizontalCardListRenderer": ParseNotImplemented
' expandableTabRenderer contains the search tab with a channel. Ignored. ' expandableTabRenderer contains the search tab with a channel. Ignored.
"expandableTabRenderer": ParseNotImplemented "expandableTabRenderer": ParseNotImplemented
' Shows a view of an official channel (like an artist) with tracks or albums.
' Shows up in search results. Safe to ignore since the channel itself will also
' be shown in the search results, so this is kind of a duplicate.
"officialCardViewModel": ParseNotImplemented
' Usually contains a "X unavailable video(s) are hidden" message. Ignored. ' Usually contains a "X unavailable video(s) are hidden" message. Ignored.
"messageRenderer": ParseNotImplemented "messageRenderer": ParseNotImplemented
"clickTrackingParams": ParseNotImplemented "clickTrackingParams": ParseNotImplemented
@@ -111,6 +126,10 @@ namespace Innertube
return nodeData["contents"] return nodeData["contents"]
end function end function
function ParseRichSectionRenderer(nodeData as object, _context as object) as object
return nodeData["content"]
end function
function ParseItemSectionRenderer(nodeData as object, _context as object) as object function ParseItemSectionRenderer(nodeData as object, _context as object) as object
return nodeData["contents"] return nodeData["contents"]
end function end function
@@ -134,6 +153,11 @@ namespace Innertube
return nodeData["content"] return nodeData["content"]
end function end function
function ParseRichShelfRenderer(nodeData as object, _context as object) as object
' TODO: handle richShelfRenderer.title
return nodeData["contents"]
end function
function ParseReelShelfRenderer(nodeData as object, _context as object) as object function ParseReelShelfRenderer(nodeData as object, _context as object) as object
' TODO: handle reelShelfRenderer.title ' TODO: handle reelShelfRenderer.title
return nodeData["items"] return nodeData["items"]
@@ -660,7 +684,12 @@ namespace Innertube
return LockupViewModelTypeAlbum(nodeData, context) return LockupViewModelTypeAlbum(nodeData, context)
end if end if
LogWarn("Unknown content type:", contentType, `\n`, nodeData) LogWarn("Unknown content type:", contentType, `\n`, FormatJson(nodeData))
#if THROW_ON_UNKNOWN_NODES
#if DEBUG
throw "Unknown content type: " + contentType
#end if
#end if
return invalid return invalid
end function end function
@@ -845,7 +874,12 @@ namespace Innertube
return TileRendererTypePlaylist(nodeData, context) return TileRendererTypePlaylist(nodeData, context)
end if end if
LogWarn("Unknown content type:", contentType, `\n`, nodeData) LogWarn("Unknown content type:", contentType, `\n`, FormatJson(nodeData))
#if THROW_ON_UNKNOWN_NODES
#if DEBUG
throw "Unknown content type: " + contentType
#end if
#end if
return invalid return invalid
end function end function
@@ -967,7 +1001,7 @@ namespace Innertube
return nodeData["items"] return nodeData["items"]
end function end function
function ParseTvSurfaceContentContinuation(nodeData as object, context as object) as object function ParseTvSurfaceContentContinuation(nodeData as object, _context as object) as object
' title = ParseText(ObjectUtils.Dig(nodeData, ["header", "tvSurfaceHeaderRenderer", "title"])) ' title = ParseText(ObjectUtils.Dig(nodeData, ["header", "tvSurfaceHeaderRenderer", "title"]))
return nodeData["content"] return nodeData["content"]
end function end function
@@ -1,4 +1,5 @@
import "pkg:/source/services/HttpClient.bs" import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/ObjectUtils.bs"
import "pkg:/source/utils/TimeUtils.bs" import "pkg:/source/utils/TimeUtils.bs"
namespace Innertube namespace Innertube
@@ -14,7 +15,9 @@ namespace Innertube
response = request.Await() response = request.Await()
if not response.IsSuccess() if not response.IsSuccess()
throw `Failed to get client id: ${response.ErrorMessage()}` return {
"error": `Failed to get client id: ${response.ErrorMessage()}`
}
end if end if
text = response.Text() text = response.Text()
@@ -23,7 +26,9 @@ namespace Innertube
match = scriptRegex.Match(text) match = scriptRegex.Match(text)
if match.Count() < 2 if match.Count() < 2
throw "Could not find base-js script" return {
"error": "Could not find base-js script"
}
end if end if
baseJsUrl = "https://www.youtube.com" + match[1] baseJsUrl = "https://www.youtube.com" + match[1]
@@ -33,7 +38,9 @@ namespace Innertube
response = request.Await() response = request.Await()
if not response.IsSuccess() if not response.IsSuccess()
throw `Failed to get base js: ${response.ErrorMessage()}` return {
"error": `Failed to get base js: ${response.ErrorMessage()}`
}
end if end if
text = response.Text() text = response.Text()
@@ -42,7 +49,9 @@ namespace Innertube
match = clientIdRegex.Match(text) match = clientIdRegex.Match(text)
if match.Count() < 3 if match.Count() < 3
throw "Could not find client id" return {
"error": "Could not find client id and secret"
}
end if end if
return { return {
@@ -66,13 +75,17 @@ namespace Innertube
response = request.Await() response = request.Await()
if not response.IsSuccess() if not response.IsSuccess()
throw `Failed to get device code: ${response.ErrorMessage()}` return {
"error": `Failed to get device code: ${response.ErrorMessage()}`
}
end if end if
responseData = ToCamelCase(response.Json()) responseData = ToCamelCase(response.Json())
if responseData.DoesExist("errorCode") if responseData.DoesExist("errorCode")
throw "Failed to get device code: " + ToString(responseData) return {
"error": "Failed to get device code: " + ToString(responseData)
}
end if end if
if responseData.DoesExist("expiresIn") if responseData.DoesExist("expiresIn")
@@ -130,11 +143,13 @@ namespace Innertube
end if end if
continue while continue while
else if responseData.error = "expired_token" else if responseData.error = "expired_token"
throw "Failed to get access token: " + ToString(responseData) return responseData
else if responseData.error = "access_denied" else if responseData.error = "access_denied"
throw "Failed to get access token: " + ToString(responseData) return responseData
else else
throw "Failed to get access token: " + ToString(responseData) return {
"error": "Failed to get access token: " + ToString(responseData)
}
end if end if
end while end while
@@ -171,12 +186,70 @@ namespace Innertube
request.Cancellation(cancellation) request.Cancellation(cancellation)
response = request.Await() response = request.Await()
success = response.IsSuccess() success = response.IsSuccess()
if success if not success
LogError(`Failed to revoke token: ${response.ErrorMessage()}`) LogError(`Failed to revoke token: ${response.ErrorMessage()}`)
end if end if
return success return success
end function end function
function ListAccounts(accessToken as string, cancellation = invalid as dynamic) as object
deviceInfo = CreateObject("roDeviceInfo")
payload = {
"context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo, "", "")
"accountReadMask": {
"returnOwner": true
"returnBrandAccounts": true
"returnPersonaAccounts": true
"returnFamilyChildAccounts": true
}
}
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/account/accounts_list", payload)
headers = {
"Authorization": `Bearer ${accessToken}`
}
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.Tv))
request.Headers(headers)
request.Cancellation(cancellation)
response = request.Await()
if not response.IsSuccess()
return {
"error": `Failed to list accounts: ${response.ErrorMessage()}`
}
end if
accounts = ObjectUtils.Dig(response.Json(), ["contents", 0, "accountSectionListRenderer", "contents", 0, "accountItemSectionRenderer", "contents"])
if not IsArray(accounts)
return {
"error": "Could not parse accounts"
}
end if
parsedAccounts = []
for each account in accounts
accountItem = account["accountItem"]
if not IsAssociativeArray(accountItem)
continue for
end if
parsedAccount = {
"accountName": ParseText(accountItem["accountName"])
"accountPhoto": ObjectUtils.Dig(accountItem, ["accountPhoto", "thumbnails", 0, "url"])
"isSelected": ValidBool(accountItem["isSelected"])
"isDisabled": ValidBool(accountItem["isDisabled"])
"hasChannel": ValidBool(accountItem["hasChannel"])
"accountByline": ParseText(accountItem["accountByline"])
"channelHandle": ParseText(accountItem["channelHandle"])
}
parsedAccounts.Push(parsedAccount)
end for
return parsedAccounts
end function
function ToCamelCase(obj as object) as object function ToCamelCase(obj as object) as object
if not IsAssociativeArray(obj) if not IsAssociativeArray(obj)
return obj return obj
@@ -58,6 +58,9 @@ namespace Innertube
end if end if
author = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "title"]) author = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "title"])
if author = invalid
author = ObjectUtils.Dig(responseData, ["header", "pageHeaderRenderer", "pageTitle"])
end if
authorId = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "externalId"]) authorId = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "externalId"])
thumbnails = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "avatar", "thumbnails"]) thumbnails = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "avatar", "thumbnails"])
@@ -103,6 +106,7 @@ namespace Innertube
tabsNames = [] tabsNames = []
tabsParams = {} tabsParams = {}
tabsTitles = {}
tabs = ObjectUtils.Dig(responseData, ["contents", "twoColumnBrowseResultsRenderer", "tabs"]) tabs = ObjectUtils.Dig(responseData, ["contents", "twoColumnBrowseResultsRenderer", "tabs"])
if tabs <> invalid if tabs <> invalid
@@ -123,13 +127,17 @@ namespace Innertube
continue for continue for
end if end if
tabParams = ObjectUtils.Dig(tabRenderer, ["endpoint", "browseEndpoint", "params"]) tabsNames.Push(tabName)
if tabParams = invalid
continue for tabTitle = tabRenderer["title"]
if IsString(tabTitle)
tabsTitles[tabName] = tabTitle
end if end if
tabsNames.Push(tabName) tabParams = ObjectUtils.Dig(tabRenderer, ["endpoint", "browseEndpoint", "params"])
tabsParams[tabName] = tabParams if IsString(tabParams)
tabsParams[tabName] = tabParams
end if
end for end for
end if end if
@@ -151,6 +159,7 @@ namespace Innertube
"authorSubTitle": authorSubTitle "authorSubTitle": authorSubTitle
"tabs": tabsNames "tabs": tabsNames
"tabsParams": tabsParams "tabsParams": tabsParams
"tabsTitles": tabsTitles
"items": items "items": items
} }
@@ -6,12 +6,12 @@ import "pkg:/source/utils/Types.bs"
namespace Innertube namespace Innertube
function CreatePlayerRequest(videoId as string, ctt as string) as object function CreatePlayerRequest(videoId as string, ctt as string, visitorData as string) as object
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"videoId": videoId "videoId": videoId
"context": Innertube.CreateContext(Innertube.ClientType.IOS, deviceInfo, ctt) "context": Innertube.CreateContext(Innertube.ClientType.IOS, deviceInfo, ctt, visitorData)
"playbackContext": { "playbackContext": {
"contentPlaybackContext": { "contentPlaybackContext": {
"vis": 0 "vis": 0
@@ -6,7 +6,7 @@ namespace Innertube
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"context": CreateContext(ClientType.Web, deviceInfo, "") "context": CreateContext(ClientType.Web, deviceInfo, "", "")
"url": url "url": url
} }
@@ -6,11 +6,11 @@ import "pkg:/source/utils/Types.bs"
namespace Innertube namespace Innertube
function Search(query as string, searchFilters as object, continuation = "" as string, cancellation = invalid as object) as object function Search(query as string, searchFilters as object, continuation = "" as string, cancellation = invalid as object, raw = false as boolean) as object
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
context: Innertube.CreateContext(Innertube.ClientType.WEB, deviceInfo, "") context: Innertube.CreateContext(Innertube.ClientType.WEB, deviceInfo, "", "")
} }
if continuation <> "" if continuation <> ""
@@ -43,6 +43,10 @@ namespace Innertube
} }
end if end if
if raw
return response.Json()
end if
feeds = ParseResponseDataForFeeds(response.Json()) feeds = ParseResponseDataForFeeds(response.Json())
result = { result = {
@@ -0,0 +1,91 @@
import "pkg:/components/Services/Innertube/Constants.bs"
import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/ObjectUtils.bs"
import "pkg:/source/utils/RegistryUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/TimeUtils.bs"
namespace Innertube
const SESSION_DATA_VERSION = 1
const INNERTUBE_VISITOR_DATA_LIFESPAN = 1000 * 60 * 60 * 24
function GetSessionData() as object
sessionData = ReadSessionDataFromRegistry()
if sessionData <> invalid
return sessionData
end if
sessionData = RequestSessionData()
if sessionData = invalid
return invalid
end if
RegistryUtils.Write(RegistryUtils.INNERTUBE_SESSION_DATA, FormatJson(sessionData))
return sessionData
end function
function RequestSessionData() as object
request = HttpClient.Get("https://www.youtube.com/sw.js_data")
request.Headers({
"Accept-Language": "en-US,en;q=0.9"
"User-Agent": INNERTUBE_WEB_USER_AGENT
"Accept": "*/*"
"Referer": "https://www.youtube.com/sw.js"
})
response = request.Await()
if not response.IsSuccess()
LogError("Failed to fetch session data", response.ErrorMessage())
return invalid
end if
text = ValidString(response.Text())
if not text.StartsWith(")]}'")
LogError("Invalid session data response", text)
return invalid
end if
text = text.Replace(")]}'", "")
json = ParseJson(text)
if json = invalid
LogError("Failed to parse session data", text)
return invalid
end if
visitorData = ObjectUtils.Dig(json, [0, 2, 0, 0, 13])
if StringUtils.IsNullOrEmpty(visitorData)
LogError("Visitor data not found", text)
return invalid
end if
return {
"__version": SESSION_DATA_VERSION
"timestamp": TimeUtils.Now().AsSeconds()
"visitorData": visitorData
}
end function
function ReadSessionDataFromRegistry() as object
sessionData = RegistryUtils.Read(RegistryUtils.INNERTUBE_SESSION_DATA)
if StringUtils.IsNullOrEmpty(sessionData)
return invalid
end if
sessionData = ParseJson(sessionData)
if sessionData = invalid
RegistryUtils.Delete(RegistryUtils.INNERTUBE_SESSION_DATA)
return invalid
end if
timestamp = sessionData.timestamp
nowSeconds = TimeUtils.Now().AsSeconds()
if nowSeconds - timestamp > INNERTUBE_VISITOR_DATA_LIFESPAN
RegistryUtils.Delete(RegistryUtils.INNERTUBE_SESSION_DATA)
return invalid
end if
return sessionData
end function
end namespace
@@ -14,7 +14,6 @@ namespace Invidious
const INSTANCES_API = "https://api.invidious.io/instances.json?sort_by=type,users" const INSTANCES_API = "https://api.invidious.io/instances.json?sort_by=type,users"
const DEFAULT_INSTANCE = "http://127.0.0.1:8888/playlet-invidious-backend" const DEFAULT_INSTANCE = "http://127.0.0.1:8888/playlet-invidious-backend"
const DEFAULT_INSTANCE_NAME = "Playlet built-in backend"
const INSTANCE_EXAMPLE = "https://invidious.example.com" const INSTANCE_EXAMPLE = "https://invidious.example.com"
const TOKEN_CALLBACK = "/invidious/token_callback" const TOKEN_CALLBACK = "/invidious/token_callback"
@@ -445,6 +444,7 @@ namespace Invidious
' Courses are not yet implemented in Invidious. ' Courses are not yet implemented in Invidious.
' In this case, Invidious returns 200, but the response is empty. ' In this case, Invidious returns 200, but the response is empty.
' https://github.com/iv-org/invidious/issues/5088 ' https://github.com/iv-org/invidious/issues/5088
' https://github.com/iv-org/invidious/issues/5144
if json = invalid if json = invalid
json = { json = {
playlists: [] playlists: []
@@ -134,6 +134,7 @@ namespace InvidiousContent
node.banner = GetChannelBanner(item.authorBanners) node.banner = GetChannelBanner(item.authorBanners)
' Important: tabsParams should be set first, because settings that tabs triggers the ChannelView to load feeds ' Important: tabsParams should be set first, because settings that tabs triggers the ChannelView to load feeds
SetIfExists(node, "tabsParams", item, "tabsParams") SetIfExists(node, "tabsParams", item, "tabsParams")
SetIfExists(node, "tabsTitles", item, "tabsTitles")
SetIfExists(node, "tabs", item, "tabs") SetIfExists(node, "tabs", item, "tabs")
return node return node
@@ -50,6 +50,7 @@ function LoadProfilesFromRegistry()
profileNode.type = profile.type profileNode.type = profile.type
profileNode.username = profile.username profileNode.username = profile.username
profileNode.serverUrl = profile.serverUrl profileNode.serverUrl = profile.serverUrl
profileNode.thumbnail = profile.thumbnail
profileNode.accessToken = profile.accessToken profileNode.accessToken = profile.accessToken
profileNode.refreshToken = profile.refreshToken profileNode.refreshToken = profile.refreshToken
@@ -161,6 +162,7 @@ function GetProfilesDto(includeAccessToken as boolean) as object
"type": profileNode.type "type": profileNode.type
"username": profileNode.username "username": profileNode.username
"serverUrl": profileNode.serverUrl "serverUrl": profileNode.serverUrl
"thumbnail": profileNode.thumbnail
"color": color "color": color
} }
@@ -203,8 +205,17 @@ function LoginWithProfile(newProfile as object)
end for end for
if not isNewProfile if not isNewProfile
' Refresh token of existing profile existingProfile.username = newProfile.username
existingProfile.thumbnail = newProfile.thumbnail
existingProfile.accessToken = newProfile.accessToken existingProfile.accessToken = newProfile.accessToken
existingProfile.refreshToken = newProfile.refreshToken
existingProfile.scope = newProfile.scope
existingProfile.tokenType = newProfile.tokenType
existingProfile.expiresIn = newProfile.expiresIn
existingProfile.expiresTimestamp = newProfile.expiresTimestamp
existingProfile.clientId = newProfile.clientId
existingProfile.clientSecret = newProfile.clientSecret
newProfile = existingProfile newProfile = existingProfile
end if end if
@@ -54,7 +54,13 @@ namespace SearchHistoryUtils
if history = invalid if history = invalid
return [] return []
end if end if
return ParseJson(history)
history = ParseJson(history)
if not IsArray(history)
return []
end if
return history
end function end function
function Clear() function Clear()
@@ -5,6 +5,7 @@ import "pkg:/components/Services/Invidious/InvidiousService.bs"
function VideoContentTask(input as object) as object function VideoContentTask(input as object) as object
contentNode = input.content contentNode = input.content
invidiousNode = input.invidious invidiousNode = input.invidious
innertubeNode = input.innertube
preferencesNode = input.preferences preferencesNode = input.preferences
loungeServiceNode = input.loungeService loungeServiceNode = input.loungeService
playletServerPort = input.playletServerPort playletServerPort = input.playletServerPort
@@ -22,8 +23,9 @@ function VideoContentTask(input as object) as object
backend = preferencesNode["playback.backend"] backend = preferencesNode["playback.backend"]
if backend = "playlet" if backend = "playlet"
metadata = InnertubeService.GetVideoMetadata(contentNode.videoId, { metadata = InnertubeService.GetVideoMetadata(contentNode.videoId, {
cancellation: m.top.cancellation "cancellation": m.top.cancellation
ctt: loungeServiceNode.ctt "ctt": loungeServiceNode.ctt
"visitorData": innertubeNode.visitorData
}) })
else else
metadata = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation }) metadata = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
@@ -90,6 +92,8 @@ function CreateStreamUrls(metadata as object, service as Invidious.InvidiousServ
metadata.hlsUrl = AddInstanceToUrlIfNeeded(metadata.hlsUrl, instance) metadata.hlsUrl = AddInstanceToUrlIfNeeded(metadata.hlsUrl, instance)
AddHlsUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort) AddHlsUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
else else
' Not that we're using dashUrl, but why not, it useful when testing it
metadata.dashUrl = AddInstanceToUrlIfNeeded(metadata.dashUrl, instance)
AddDashUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort) AddDashUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
end if end if
@@ -151,6 +151,7 @@ function StartVideoContentTask(videoContentNode as object)
m.videoContentTask = AsyncTask.Start(Tasks.VideoContentTask, { m.videoContentTask = AsyncTask.Start(Tasks.VideoContentTask, {
content: videoContentNode content: videoContentNode
invidious: m.top.invidious invidious: m.top.invidious
innertube: m.top.innertube
preferences: m.top.preferences preferences: m.top.preferences
loungeService: m.top.loungeService loungeService: m.top.loungeService
playletServerPort: m.top.webServer.port playletServerPort: m.top.webServer.port
@@ -5,6 +5,7 @@
<field id="notifications" type="node" bind="../../Notifications" /> <field id="notifications" type="node" bind="../../Notifications" />
<field id="videoQueue" type="node" bind="../../VideoQueue" /> <field id="videoQueue" type="node" bind="../../VideoQueue" />
<field id="preferences" type="node" bind="../../Preferences" /> <field id="preferences" type="node" bind="../../Preferences" />
<field id="innertube" type="node" bind="../../Innertube" />
<field id="invidious" type="node" bind="../../Invidious" /> <field id="invidious" type="node" bind="../../Invidious" />
<field id="webServer" type="node" bind="../../WebServer" /> <field id="webServer" type="node" bind="../../WebServer" />
<field id="loungeService" type="node" bind="../../LoungeService" /> <field id="loungeService" type="node" bind="../../LoungeService" />
@@ -22,6 +22,7 @@
<field id="player" type="node" /> <field id="player" type="node" />
<field id="nowPlaying" type="node" /> <field id="nowPlaying" type="node" />
<field id="innertube" type="node" />
<field id="invidious" type="node" /> <field id="invidious" type="node" />
<field id="notifications" type="node" /> <field id="notifications" type="node" />
<field id="preferences" type="node" /> <field id="preferences" type="node" />
@@ -57,7 +57,11 @@ function OnContentSet() as void
end if end if
AdjustFocus(videoCount) AdjustFocus(videoCount)
LoadVideoDetailsIfNeeded() ' TODO:P1 LoadVideoDetailsIfNeeded is disabled for now.
' Trying to fetch video info (especially one by one) can lead to rate limiting.
' That would result in all videos being blocked. So for now, this is just a
' nice to have, and should not be used.
' LoadVideoDetailsIfNeeded()
end function end function
function OnKeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
@@ -143,6 +147,7 @@ function LoadVideoDetailsIfNeeded() as void
m.loadDetailsTask = AsyncTask.Start(Tasks.VideoQueueViewContentTask, { m.loadDetailsTask = AsyncTask.Start(Tasks.VideoQueueViewContentTask, {
videoNodes: m.videosDetailsToLoad videoNodes: m.videosDetailsToLoad
innertube: m.top.innertube
invidious: m.top.invidious invidious: m.top.invidious
preferences: m.top.preferences preferences: m.top.preferences
index: indexInLoadingArray index: indexInLoadingArray
@@ -4,6 +4,7 @@
<field id="jumpToItem" type="integer" alias="queueList.jumpToItem" /> <field id="jumpToItem" type="integer" alias="queueList.jumpToItem" />
<field id="videoQueue" type="node" /> <field id="videoQueue" type="node" />
<field id="appController" type="node" /> <field id="appController" type="node" />
<field id="innertube" type="node" />
<field id="invidious" type="node" /> <field id="invidious" type="node" />
<field id="preferences" type="node" /> <field id="preferences" type="node" />
<function name="Show" /> <function name="Show" />
@@ -7,6 +7,7 @@ import "pkg:/source/utils/MathUtils.bs"
@asynctask @asynctask
function VideoQueueViewContentTask(input as object) as object function VideoQueueViewContentTask(input as object) as object
videoNodes = input.videoNodes videoNodes = input.videoNodes
innertubeNode = input.innertube
invidiousNode = input.invidious invidiousNode = input.invidious
preferencesNode = input.preferences preferencesNode = input.preferences
service = new Invidious.InvidiousService(invidiousNode) service = new Invidious.InvidiousService(invidiousNode)
@@ -22,6 +23,7 @@ function VideoQueueViewContentTask(input as object) as object
cancellation: cancellation cancellation: cancellation
tryCount: 1 tryCount: 1
fetchNext: false fetchNext: false
visitorData: innertubeNode.visitorData
} }
' TODO:P1: Use InnertubeService.GetVideoInfoBatched instead of loading each video individually ' TODO:P1: Use InnertubeService.GetVideoInfoBatched instead of loading each video individually
@@ -6,6 +6,7 @@ namespace VideoQueueViewUtils
videoQueueView = CreateObject("roSGNode", "VideoQueueView") videoQueueView = CreateObject("roSGNode", "VideoQueueView")
videoQueueView.videoQueue = videoQueue videoQueueView.videoQueue = videoQueue
videoQueueView.appController = appController videoQueueView.appController = appController
videoQueueView.innertube = videoQueue.innertube
videoQueueView.invidious = videoQueue.invidious videoQueueView.invidious = videoQueue.invidious
videoQueueView.preferences = videoQueue.preferences videoQueueView.preferences = videoQueue.preferences
appController@.PushScreen(videoQueueView) appController@.PushScreen(videoQueueView)
@@ -5,8 +5,10 @@ namespace Http
class PlayletInvidiousBackendRouter extends HttpRouter class PlayletInvidiousBackendRouter extends HttpRouter
function new() function new(server as object)
super() super()
m.innertube = server.task.innertube
end function end function
@get("/playlet-invidious-backend/authorize_token") @get("/playlet-invidious-backend/authorize_token")
@@ -20,6 +22,33 @@ namespace Http
return true return true
end function end function
@post("/playlet-invidious-backend/api/v1/auth/tokens/unregister")
function UnregisterToken(context as object) as boolean
request = context.request
response = context.response
accessToken = request.body
if StringUtils.IsNullOrEmpty(accessToken)
response.Json({
"error": "Missing 'accessToken' body parameter"
})
response.http_code = 400
return true
end if
if not InnertubeService.AuthRevokeAccessToken({ "accessToken": accessToken })
response.Json({
"error": "Failed to unregister token"
})
response.http_code = 500
return true
end if
response.Default(204, "OK")
return true
end function
@get("/playlet-invidious-backend/api/v1/auth/feed") @get("/playlet-invidious-backend/api/v1/auth/feed")
function GetAuthFeed(context as object) as boolean function GetAuthFeed(context as object) as boolean
request = context.request request = context.request
@@ -185,7 +214,19 @@ namespace Http
request = context.request request = context.request
response = context.response response = context.response
result = InnertubeService.GetTrending({ type: request.query.type }) raw = request.query.raw <> invalid
options = {
raw: raw
type: request.query.type
}
result = InnertubeService.GetTrending(options)
if raw
response.Json(result)
return true
end if
if result.error <> invalid if result.error <> invalid
response.Json(result) response.Json(result)
response.http_code = 500 response.http_code = 500
@@ -239,6 +280,11 @@ namespace Http
query = request.query.q query = request.query.q
continuation = request.query.continuation continuation = request.query.continuation
raw = request.query.raw <> invalid
options = {
raw: raw
}
searchFilters = {} searchFilters = {}
sort = request.query.sort sort = request.query.sort
@@ -262,7 +308,6 @@ namespace Http
searchFilters.features = features.Split(",") searchFilters.features = features.Split(",")
end if end if
options = {}
if searchFilters.Count() > 0 if searchFilters.Count() > 0
options.searchFilters = searchFilters options.searchFilters = searchFilters
end if end if
@@ -277,6 +322,11 @@ namespace Http
return true return true
end if end if
if raw
response.Json(result)
return true
end if
if not IsArray(result.feeds) or result.feeds.Count() = 0 if not IsArray(result.feeds) or result.feeds.Count() = 0
response.Json({ response.Json({
"error": "Failed to search" "error": "Failed to search"
@@ -299,6 +349,8 @@ namespace Http
response = context.response response = context.response
url = request.query.url url = request.query.url
raw = request.query.raw <> invalid
if StringUtils.IsNullOrEmpty(url) if StringUtils.IsNullOrEmpty(url)
response.Json({ response.Json({
"error": "Missing 'url' query parameter" "error": "Missing 'url' query parameter"
@@ -307,7 +359,7 @@ namespace Http
return true return true
end if end if
json = InnertubeService.ResolveUrl(url, response) json = InnertubeService.ResolveUrl(url)
if json = invalid if json = invalid
response.Json({ response.Json({
"error": "Failed to resolve URL" "error": "Failed to resolve URL"
@@ -316,6 +368,11 @@ namespace Http
return true return true
end if end if
if raw
response.Json(json)
return true
end if
endpoint = json["endpoint"] endpoint = json["endpoint"]
pageType = ValidString(ObjectUtils.Dig(endpoint, ["commandMetadata", "webCommandMetadata", "webPageType"])) pageType = ValidString(ObjectUtils.Dig(endpoint, ["commandMetadata", "webCommandMetadata", "webPageType"]))
if pageType = "WEB_PAGE_TYPE_UNKNOWN" or pageType = "" if pageType = "WEB_PAGE_TYPE_UNKNOWN" or pageType = ""
@@ -392,8 +449,17 @@ namespace Http
route = request.route route = request.route
videoId = route.Mid("/playlet-invidious-backend/api/v1/videos/".Len()) videoId = route.Mid("/playlet-invidious-backend/api/v1/videos/".Len())
if videoId.InStr("?") > 0
videoId = videoId.Left(videoId.InStr("?"))
end if
raw = request.query.raw <> invalid
metadata = InnertubeService.GetVideoMetadata(videoId) options = {
"raw": raw
"visitorData": m.innertube.visitorData
}
metadata = InnertubeService.GetVideoMetadata(videoId, options)
response.Json(metadata) response.Json(metadata)
if metadata.error <> invalid if metadata.error <> invalid
@@ -409,9 +475,16 @@ namespace Http
route = request.route route = request.route
playlistId = route.Mid("/playlet-invidious-backend/api/v1/playlists/".Len()) playlistId = route.Mid("/playlet-invidious-backend/api/v1/playlists/".Len())
if playlistId.InStr("?") > 0
playlistId = playlistId.Left(playlistId.InStr("?"))
end if
continuation = request.query.continuation continuation = request.query.continuation
raw = request.query.raw <> invalid
options = {
raw: raw
}
options = {}
if playlistId.StartsWith("RD") if playlistId.StartsWith("RD")
if not StringUtils.IsNullOrEmpty(continuation) if not StringUtils.IsNullOrEmpty(continuation)
options.videoId = continuation options.videoId = continuation
@@ -431,6 +504,11 @@ namespace Http
playlist = InnertubeService.GetPlaylist(playlistId, options) playlist = InnertubeService.GetPlaylist(playlistId, options)
end if end if
if raw
response.Json(playlist)
return true
end if
if playlist.error <> invalid if playlist.error <> invalid
response.Json(playlist) response.Json(playlist)
response.http_code = 500 response.http_code = 500
@@ -456,10 +534,17 @@ namespace Http
route = request.route route = request.route
channelAndTab = route.Mid("/playlet-invidious-backend/api/v1/channels/".Len()) channelAndTab = route.Mid("/playlet-invidious-backend/api/v1/channels/".Len())
if channelAndTab.InStr("?") > 0
channelAndTab = channelAndTab.Left(channelAndTab.InStr("?"))
end if
channelAndTab = channelAndTab.Split("/") channelAndTab = channelAndTab.Split("/")
options = {}
continuation = request.query.continuation continuation = request.query.continuation
raw = request.query.raw <> invalid
options = {
raw: raw
}
if not StringUtils.IsNullOrEmpty(continuation) if not StringUtils.IsNullOrEmpty(continuation)
options.continuation = continuation options.continuation = continuation
@@ -468,6 +553,11 @@ namespace Http
if channelAndTab.Count() = 1 if channelAndTab.Count() = 1
channelId = channelAndTab[0] channelId = channelAndTab[0]
channel = InnertubeService.GetChannel(channelId, options) channel = InnertubeService.GetChannel(channelId, options)
if raw
response.Json(channel)
return true
end if
if channel.error <> invalid if channel.error <> invalid
response.Json(channel) response.Json(channel)
response.http_code = 500 response.http_code = 500
@@ -490,6 +580,11 @@ namespace Http
end if end if
channel = InnertubeService.GetChannel(channelId, options) channel = InnertubeService.GetChannel(channelId, options)
if raw
response.Json(channel)
return true
end if
if channel.error <> invalid if channel.error <> invalid
response.Json(channel) response.Json(channel)
response.http_code = 500 response.http_code = 500
@@ -532,6 +627,8 @@ namespace Http
response = context.response response = context.response
videoId = request.query.v videoId = request.query.v
t = request.query.t
if StringUtils.IsNullOrEmpty(videoId) if StringUtils.IsNullOrEmpty(videoId)
response.Json({ response.Json({
"error": "Missing 'v' query parameter" "error": "Missing 'v' query parameter"
@@ -540,7 +637,11 @@ namespace Http
return true return true
end if end if
response.Redirect(`https://redirect.invidious.io/watch?v=${videoId}`) url = `https://redirect.invidious.io/watch?v=${videoId}`
if not StringUtils.IsNullOrEmpty(t)
url = `${url}&t=${t}`
end if
response.Redirect(url)
return true return true
end function end function
@@ -56,7 +56,7 @@ function SetupRoutes(server as object)
server.UseRouter(new Http.DialRouter(server)) server.UseRouter(new Http.DialRouter(server))
server.UseRouter(new Http.CacheRouter()) server.UseRouter(new Http.CacheRouter())
server.UseRouter(new Http.RegistryRouter(server)) server.UseRouter(new Http.RegistryRouter(server))
server.UseRouter(new Http.PlayletInvidiousBackendRouter()) server.UseRouter(new Http.PlayletInvidiousBackendRouter(server))
etags = new Http.EtagUtils() etags = new Http.EtagUtils()
server.UseRouter(new Http.HttpStaticFilesRouter("/", "libpkg:/www", etags, { staticFiles: true, staticCompressed: true })) server.UseRouter(new Http.HttpStaticFilesRouter("/", "libpkg:/www", etags, { staticFiles: true, staticCompressed: true }))
@@ -2,6 +2,7 @@
<interface> <interface>
<field id="appController" type="node" /> <field id="appController" type="node" />
<field id="preferences" type="node" /> <field id="preferences" type="node" />
<field id="innertube" type="node" />
<field id="invidious" type="node" /> <field id="invidious" type="node" />
<field id="profilesService" type="node" /> <field id="profilesService" type="node" />
<field id="applicationInfo" type="node" /> <field id="applicationInfo" type="node" />
@@ -166,7 +166,6 @@ channel_releases:
paginationType: Continuation paginationType: Continuation
tryCount: 3 tryCount: 3
# This is implemented only by Playlet backend.
channel_courses: channel_courses:
title: Channel courses title: Channel courses
url: /api/v1/channels/{ucid}/courses url: /api/v1/channels/{ucid}/courses
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="512pt" height="512pt" version="1.0" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
<g transform="matrix(1.256 0 0 1.256 -65.668 -67.101)">
<path d="m247.17 455.95c-19.792-0.78921-38.719-4.2564-57.154-10.47-60.968-20.55-108.68-68.579-127-127.86-7.8955-25.538-10.062-53.943-6.2586-82.067 3.7105-27.439 13.603-53.515 29.342-77.344 12.069-18.273 29.138-36.277 47.228-49.816 36.891-27.61 85.944-42.49 132.38-40.157 25.88 1.3001 49.939 6.765 73.106 16.606 8.1948 3.481 20.024 9.6845 27.696 14.525 14.15 8.9272 22.367 15.498 34.482 27.573 13.254 13.211 22.128 24.276 30.398 37.906 7.2081 11.879 14.099 27.15 18.229 40.397 1.5996 5.1305 4.442 16.456 5.6852 22.653 2.3908 11.917 2.6998 15.722 2.7049 33.312 6e-3 18.515-0.46256 24.413-2.9166 36.758-9.3274 46.92-35.58 88.167-74.872 117.64-22.814 17.112-50.027 29.535-78.547 35.858-16.714 3.7059-35.421 5.2453-54.498 4.4846zm-35.1-78.786c-5.3e-4 -0.52647-0.0741-2.0564-0.16311-3.3999l-0.16178-2.4427-4.7018-0.26271c-4.0477-0.22614-4.7968-0.33363-5.3847-0.77253-2.0235-1.5108-1.4679-6.0695 2.2494-18.457 0.8637-2.8781 3.3371-11.321 5.4966-18.762 2.1594-7.4409 5.2002-17.836 6.7573-23.101 1.5571-5.2648 4.1948-14.282 5.8615-20.038 1.6667-5.7562 3.6145-12.4 4.3284-14.764 0.71391-2.3641 3.2583-11.037 5.6542-19.272 4.9475-17.007 8.1626-27.723 8.9438-29.811 0.51852-1.3858 0.54785-1.4139 0.99761-0.95317 0.25486 0.26106 3.8462 7.3667 7.9807 15.79 4.1345 8.4236 13.089 26.573 19.898 40.331 17.188 34.73 37.849 76.578 43.261 87.622l4.5356 9.257 11.359-0.0895c6.2475-0.0492 11.615-0.19623 11.929-0.32672 0.5614-0.23385 0.54167-0.2959-1.3723-4.3176-1.068-2.2442-8.1436-16.601-15.724-31.904-48.687-98.293-61.22-123.86-67.889-138.48-4.7022-10.309-6.9031-14.807-7.7139-15.762-0.82931-0.97742-1.6319-1.0638-2.3704-0.25525-1.1993 1.313-4.1046 10.063-9.3869 28.27-2.0569 7.0899-6.5372 22.425-9.9562 34.077-6.6396 22.629-8.5182 29.037-14.33 48.883-2.0354 6.9495-4.7977 16.369-6.1385 20.931-1.3408 4.5628-4.033 13.81-5.9826 20.549-4.304 14.877-6.136 20.889-7.3886 24.25-2.1371 5.7334-2.5723 6.3292-4.9216 6.7384-0.88855 0.15472-2.4102 0.28196-3.3815 0.28275-2.1993 3e-3 -3.5494 0.36339-4.0558 1.0863-0.42176 0.60215-0.56421 4.8802-0.18251 5.4812 0.20573 0.32388 2.4672 0.37414 23.34 0.51873l8.6151 0.0597-7e-4 -0.95723zm36.751-205.59c4.3282-0.92335 8.4607-4.943 9.4374-9.1796 0.36569-1.5862 0.32543-4.9758-0.077-6.4799-0.85108-3.1813-3.2688-6.291-6.039-7.7675-3.8111-2.0313-9.456-2.0295-13.272 5e-3 -5.9828 3.1888-8.1556 11.089-4.7878 17.408 2.6995 5.0648 8.3611 7.3754 14.738 6.015z" fill="#f0f0f0" stroke-width=".025526"/>
</g>
<g transform="matrix(.087787 0 0 -.087787 -10.105 528.87)">
<path d="m2787 4669c-124-65-123-255 3-319 86-44 196-16 247 62 58 87 26 211-67 258-51 26-132 26-183-1z" fill="#00b6f0" stroke="#00b6f0" stroke-width="4.25"/>
<path d="m2882 4108c-12-16-63-166-102-303-30-104-101-350-165-565-20-69-58-199-85-290-26-91-64-221-85-290-20-69-58-199-85-290-26-91-64-221-85-290-20-69-57-195-81-280-59-207-93-299-115-310-10-6-35-10-56-10-73 0-84-8-81-54l3-41 228-3 228-2-3 47-3 48-73 3c-66 3-74 5-84 27-13 28 0 104 37 225 13 41 47 156 75 255s66 230 85 290c18 61 56 191 85 290 28 99 66 230 85 290 18 61 56 191 85 290 85 297 123 419 131 429 5 5 17-11 28-35 10-24 192-393 403-819s447-902 523-1058l139-282h168c92 0 168 4 168 8s-75 158-166 342c-588 1183-969 1958-1033 2100-29 63-69 151-89 195-44 95-58 110-80 83z" fill="#575757"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

@@ -0,0 +1,11 @@
{
inputHash: 'f38944bd940b191cb7e9b1fed6e14aeb',
outputs: [
{
outputFilePath: 'images/invidious-logo.png',
outputHash: '0b593b648652e09fcf97fac09bbbf9f2',
width: 256,
height: 256,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 300 300">
<rect width="300" height="300" fill="red" ry="150" />
<path fill="#fff" d="M149.93750587 79.22267364s-63.21885.000059-79.08593926 4.12304707c-8.49578714 2.37380204-15.49140825 9.36950015-17.86523429 17.99023729-4.12295306 15.86710025-4.12304706 48.72656078-4.12304706 48.72656078s.000094 32.98420052 4.12304706 48.60156077c2.37382604 8.62062014 9.24450615 15.49138025 17.86523429 17.86524029 15.99203025 4.24788007 79.08593926 4.24804007 79.08593926 4.24804007s63.34418101-.00005 79.21094127-4.12304007c8.62079014-2.37381004 15.49133025-9.11966015 17.74023028-17.86524029 4.24793007-15.74232025 4.24805007-48.60156077 4.24805007-48.60156077s.12484-32.98446053-4.24805007-48.85156078c-2.24890003-8.62073714-9.11944014-15.49133425-17.74023028-17.74023729-15.86676026-4.37284707-79.21094127-4.37304707-79.21094127-4.37304707zm-20.11523032 40.48046465 52.59961084 30.35938049-52.59961084 30.23438048v-60.59376097z" />
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

@@ -0,0 +1,11 @@
{
inputHash: 'b9448ffdbf4982eed1f4e85867a846d1',
outputs: [
{
outputFilePath: 'images/youtube-logo.png',
outputHash: '853532c887464153c4e0f924932d85fe',
width: 256,
height: 256,
},
],
}
+13 -1
View File
@@ -1266,7 +1266,19 @@
</message> </message>
<message> <message>
<source>Buffering</source> <source>Buffering</source>
<translation type="unfinished">Puffert</translation> <translation>Pufferung</translation>
</message>
<message>
<source>Do not show again</source>
<translation>Nicht wieder anzeigen</translation>
</message>
<message>
<source>Courses</source>
<translation>Kurse</translation>
</message>
<message>
<source>Playlet built-in backend</source>
<translation>Playlet eingebautes Backend</translation>
</message> </message>
</context> </context>
</TS> </TS>
@@ -124,6 +124,10 @@
<source>Podcasts</source> <source>Podcasts</source>
<translation>Podcasts</translation> <translation>Podcasts</translation>
</message> </message>
<message>
<source>Courses</source>
<translation>Courses</translation>
</message>
<message> <message>
<source>Edit</source> <source>Edit</source>
<translation>Edit</translation> <translation>Edit</translation>
@@ -752,6 +756,10 @@
<source>Instance</source> <source>Instance</source>
<translation>Instance</translation> <translation>Instance</translation>
</message> </message>
<message>
<source>Playlet built-in backend</source>
<translation>Playlet built-in backend</translation>
</message>
<message> <message>
<source>Invidious instance to use. Example: https://example.com</source> <source>Invidious instance to use. Example: https://example.com</source>
<translation>Invidious instance to use. Example: https://example.com</translation> <translation>Invidious instance to use. Example: https://example.com</translation>
+73 -1
View File
@@ -266,7 +266,7 @@
</message> </message>
<message> <message>
<source>Show notifications when a segment is skipped</source> <source>Show notifications when a segment is skipped</source>
<translation>Monstrar notificaciones cuando un segmento es saltado</translation> <translation>Mostrar notificaciones cuando un segmento es saltado</translation>
</message> </message>
<message> <message>
<source>This year</source> <source>This year</source>
@@ -1208,5 +1208,77 @@
<source>The instance can fetch with CORS from %1</source> <source>The instance can fetch with CORS from %1</source>
<translation>La instancia puede obtener con CORS desde %1</translation> <translation>La instancia puede obtener con CORS desde %1</translation>
</message> </message>
<message>
<source>Courses</source>
<translation>Cursos</translation>
</message>
<message>
<source>Playlet built-in backend</source>
<translation>Backend de Playlet</translation>
</message>
<message>
<source>Filler</source>
<translation>Relleno</translation>
</message>
<message>
<source>Preview/Recap</source>
<translation>Avance/Resumen</translation>
</message>
<message>
<source>Preview/Recap/Hook</source>
<translation>Avance/Resumen/Gancho</translation>
</message>
<message>
<source>Sponsor</source>
<translation>Mensaje patrocinado</translation>
</message>
<message>
<source>Intermission</source>
<translation>Pausa</translation>
</message>
<message>
<source>Endcards/Credits</source>
<translation>Tarjeta final/Créditos</translation>
</message>
<message>
<source>Filler Tangent/Jokes</source>
<translation>Digresión/Chistes</translation>
</message>
<message>
<source>Intermission/Intro Animation</source>
<translation>Animación de Intermedio/Intro</translation>
</message>
<message>
<source>Non-Music</source>
<translation>Sin música</translation>
</message>
<message>
<source>Interaction Reminder (Subscribe)</source>
<translation>Recordatorio de interacción (Suscribete)</translation>
</message>
<message>
<source>Unpaid/Self Promotion</source>
<translation>Promoción propia/No pagada</translation>
</message>
<message>
<source>Music: Non-Music Section</source>
<translation>Música: Parte no musical</translation>
</message>
<message>
<source>Buffering</source>
<translation>Cargando</translation>
</message>
<message>
<source>Interaction Reminder</source>
<translation>Recordatorio de interacción</translation>
</message>
<message>
<source>Highlight</source>
<translation>Momento destacado</translation>
</message>
<message>
<source>Do not show again</source>
<translation>No mostrar de nuevo</translation>
</message>
</context> </context>
</TS> </TS>
@@ -1268,5 +1268,17 @@
<source>Add to %1 bookmark</source> <source>Add to %1 bookmark</source>
<translation>Adicionar %1 ao marcadores</translation> <translation>Adicionar %1 ao marcadores</translation>
</message> </message>
<message>
<source>Courses</source>
<translation>Cursos</translation>
</message>
<message>
<source>Playlet built-in backend</source>
<translation>Back-end integrado do playlet</translation>
</message>
<message>
<source>Do not show again</source>
<translation>Não mostrar novamente</translation>
</message>
</context> </context>
</TS> </TS>
+2 -2
View File
@@ -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=36 minor_version=36
build_version=00000 build_version=00005
ui_resolutions=hd ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p uri_resolution_autosub=$$RES$$,480p,720p,1080p
@@ -13,4 +13,4 @@ hidden=1
git_commit_sha=unknown git_commit_sha=unknown
bs_const=DEBUG=false bs_const=DEBUG=false;YT_OAUTH_SUPPORT=false
@@ -5,7 +5,6 @@
' Only use this for debugging purposes. ' Only use this for debugging purposes.
#const NETWORK_THROTTLE = false #const NETWORK_THROTTLE = false
import "pkg:/source/utils/CancellationUtils.bs"
import "pkg:/source/utils/CancellationUtils.bs" import "pkg:/source/utils/CancellationUtils.bs"
import "pkg:/source/utils/CryptoUtils.bs" import "pkg:/source/utils/CryptoUtils.bs"
import "pkg:/source/utils/ErrorUtils.bs" import "pkg:/source/utils/ErrorUtils.bs"
@@ -653,11 +652,12 @@ namespace HttpClient
return invalid return invalid
end if end if
m._json = ParseJson(text) m._json = ParseJson(text)
' TODO:P2 remove workaround after a fix has landed ' TODO:P2 remove workaround (fix landed, but remove after March 2025 as a precaution)
if m._json = invalid and m.IsSuccess() and not m._json_workaround_tried = true if m._json = invalid and m.IsSuccess() and not m._json_workaround_tried = true
' A bug was introduced in Roku OS 14.1 that causes ParseJson to return invalid parsing some unicode characters. ' A bug was introduced in Roku OS 14.1 that causes ParseJson to return invalid parsing some unicode characters.
' So we filter out \uXXXX characters and try to parse again. ' So we filter out \uXXXX characters and try to parse again.
' These characters are mostly emojis, and can't render anyway. ' These characters are mostly emojis, and can't render anyway.
' Update: a fix has landed in 14.1 (tested on 14.1.4.7709)
m._json_workaround_tried = true m._json_workaround_tried = true
filter = /\\u[0-9a-fA-F]{4}/ filter = /\\u[0-9a-fA-F]{4}/
text = filter.ReplaceAll(text, "") text = filter.ReplaceAll(text, "")
@@ -841,6 +841,11 @@ namespace HttpClientCache
return return
end if end if
body = ValidString(response.Text())
if body = ""
return
end if
date = CreateObject("roDateTime") date = CreateObject("roDateTime")
timestamp = date.AsSeconds() timestamp = date.AsSeconds()
@@ -856,7 +861,6 @@ namespace HttpClientCache
' {body} ' the body as is, string size matching metadata.body ' {body} ' the body as is, string size matching metadata.body
jsonHeaders = FormatJson(response.Headers()) jsonHeaders = FormatJson(response.Headers())
body = ValidString(response.Text())
cacheMetadata = { cacheMetadata = {
timestamp: timestamp timestamp: timestamp
+2
View File
@@ -50,6 +50,7 @@ namespace Locale
Live = "Live" Live = "Live"
Releases = "Releases" Releases = "Releases"
Podcasts = "Podcasts" Podcasts = "Podcasts"
Courses = "Courses"
end enum end enum
@locale @locale
@@ -248,6 +249,7 @@ namespace Locale
' Invidious = "Invidious" ' Invidious = "Invidious"
InvidiousPreferences = "Invidious preferences" InvidiousPreferences = "Invidious preferences"
Instance = "Instance" Instance = "Instance"
PlayletBuiltinBackend = "Playlet built-in backend"
InstanceDescriptionTV = "Invidious instance to use. Example: https://example.com" InstanceDescriptionTV = "Invidious instance to use. Example: https://example.com"
ProxyVideos = "Proxy videos" ProxyVideos = "Proxy videos"
ProxyVideosDescription = "Proxy videos through the Invidious server. This is useful if videos are geoblocked." ProxyVideosDescription = "Proxy videos through the Invidious server. This is useful if videos are geoblocked."
@@ -10,6 +10,7 @@ namespace RegistryUtils
const BOOKMARKS = "bookmarks" const BOOKMARKS = "bookmarks"
const MESSAGES = "messages" const MESSAGES = "messages"
const INNERTUBE_SESSION_DATA = "innertube_session_data"
const LAST_LOUNGE_DATA = "last_lounge_data" const LAST_LOUNGE_DATA = "last_lounge_data"
' "invidious_instances" is deprecated, but we keep for migration purposes ' "invidious_instances" is deprecated, but we keep for migration purposes
+1073 -257
View File
File diff suppressed because it is too large. Load diff
+10 -10
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-web", "name": "playlet-web",
"version": "0.36.0", "version": "0.36.5",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
@@ -12,20 +12,20 @@
"@sveltejs/vite-plugin-svelte": "^5.0.3", "@sveltejs/vite-plugin-svelte": "^5.0.3",
"@tailwindcss/typography": "^0.5.16", "@tailwindcss/typography": "^0.5.16",
"@tsconfig/svelte": "^5.0.4", "@tsconfig/svelte": "^5.0.4",
"@vitejs/plugin-legacy": "^6.0.0", "@vitejs/plugin-legacy": "^6.1.0",
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.21",
"daisyui": "^4.12.23", "daisyui": "^4.12.23",
"dotenv": "^16.4.7", "dotenv": "^16.5.0",
"ip": "^2.0.1", "ip": "^2.0.1",
"postcss": "^8.4.49", "postcss": "^8.5.3",
"svelte": "^5.17.3", "svelte": "^5.28.1",
"svelte-check": "^4.1.3", "svelte-check": "^4.1.6",
"svelte-preprocess": "^6.0.3", "svelte-preprocess": "^6.0.3",
"tailwindcss": "^3.4.17", "tailwindcss": "^3.4.17",
"terser": "^5.37.0", "terser": "^5.39.0",
"tslib": "^2.8.1", "tslib": "^2.8.1",
"typescript": "^5.7.3", "typescript": "^5.8.3",
"vite": "^6.0.7", "vite": "^6.3.2",
"vite-plugin-compression": "^0.5.1", "vite-plugin-compression": "^0.5.1",
"vite-tsconfig-paths": "^5.1.4" "vite-tsconfig-paths": "^5.1.4"
} }
+12 -2
View File
@@ -2,6 +2,9 @@
import { playletStateStore, translate } from "lib/Stores"; import { playletStateStore, translate } from "lib/Stores";
import { PlayletApi } from "./Api/PlayletApi"; import { PlayletApi } from "./Api/PlayletApi";
import { get } from "svelte/store"; import { get } from "svelte/store";
import { getHost } from "./Api/Host";
const host = () => `http://${getHost()}`;
export function show() { export function show() {
modal.showModal(); modal.showModal();
@@ -23,12 +26,19 @@
let authUrl; let authUrl;
let currentInstance; let currentInstance;
let currentInstanceName;
let accordionState = null; let accordionState = null;
playletStateStore.subscribe((value) => { playletStateStore.subscribe((value) => {
authUrl = value?.invidious?.auth_url; authUrl = value?.invidious?.auth_url;
currentInstance = value?.invidious?.current_instance; currentInstance = value?.invidious?.current_instance || "";
if (currentInstance === `${host()}/playlet-invidious-backend`) {
const trFn = get(translate);
currentInstanceName = trFn("Playlet built-in backend");
} else {
currentInstanceName = currentInstance;
}
profiles = value?.profiles?.profiles ?? []; profiles = value?.profiles?.profiles ?? [];
currentProfile = profiles.find( currentProfile = profiles.find(
(p) => p.id === value?.profiles?.currentProfile (p) => p.id === value?.profiles?.currentProfile
@@ -126,7 +136,7 @@
<button class="btn btn-primary" on:click={login}> <button class="btn btn-primary" on:click={login}>
<div class=""> <div class="">
<div class="text-m">{$translate("Login to Invidious")}</div> <div class="text-m">{$translate("Login to Invidious")}</div>
<div class="text-xs font-light">{currentInstance}</div> <div class="text-xs font-light">{currentInstanceName}</div>
</div> </div>
</button> </button>
<button class="btn m-6">{$translate("Close")}</button> <button class="btn m-6">{$translate("Close")}</button>
@@ -5,6 +5,7 @@
export let key: string; export let key: string;
export let icon; export let icon;
export let small: boolean = false; export let small: boolean = false;
export let singlePressEvent: boolean = false;
let button; let button;
@@ -37,11 +38,18 @@
let isDown = false; let isDown = false;
function pressKeyDown() { function pressKeyDown() {
isDown = true; isDown = true;
ExternalControlProtocol.pressKeyDown(key); if (singlePressEvent) {
ExternalControlProtocol.pressKey(key);
} else {
ExternalControlProtocol.pressKeyDown(key);
}
} }
function pressKeyUp() { function pressKeyUp() {
isDown = false; isDown = false;
if (singlePressEvent) {
return;
}
ExternalControlProtocol.pressKeyUp(key); ExternalControlProtocol.pressKeyUp(key);
} }
@@ -153,9 +153,24 @@ And set it to "Enabled".`;
<RemoteButton key={BUTTONS.fwd} icon={FastForwardIcon} small /> <RemoteButton key={BUTTONS.fwd} icon={FastForwardIcon} small />
</div> </div>
<div class="flex space-x-2 m-1"> <div class="flex space-x-2 m-1">
<RemoteButton key={BUTTONS.volumeMute} icon={VolumeMuteIcon} small /> <RemoteButton
<RemoteButton key={BUTTONS.volumeDown} icon={VolumeDownIcon} small /> key={BUTTONS.volumeMute}
<RemoteButton key={BUTTONS.volumeUp} icon={VolumeUpIcon} small /> icon={VolumeMuteIcon}
small
singlePressEvent
/>
<RemoteButton
key={BUTTONS.volumeDown}
icon={VolumeDownIcon}
small
singlePressEvent
/>
<RemoteButton
key={BUTTONS.volumeUp}
icon={VolumeUpIcon}
small
singlePressEvent
/>
</div> </div>
<button <button
on:click={showRemoteNotWorkingDialog} on:click={showRemoteNotWorkingDialog}
+1 -1
View File
@@ -1,4 +1,4 @@
import sveltePreprocess from 'svelte-preprocess' import { sveltePreprocess } from 'svelte-preprocess'
export default { export default {
// Consult https://github.com/sveltejs/svelte-preprocess // Consult https://github.com/sveltejs/svelte-preprocess
-124
View File
@@ -1,124 +0,0 @@
// This plugin converts svg files to png/jpeg files
import {
CompilerPlugin, FileObj, ProgramBuilder,
} from 'brighterscript';
import { readFileSync, writeFileSync } from 'fs';
import { existsSync } from 'fs-extra';
import { globSync } from 'glob';
import md5 from 'crypto-js/md5';
import { join as joinPath } from 'path';
import json5 from 'json5';
const shell = require('shelljs');
const META_EXT = '.meta.json5';
export class ImageGenPlugin implements CompilerPlugin {
public name = 'ImageGenPlugin';
beforePrepublish(builder: ProgramBuilder, files: FileObj[]) {
// Force generate flag
// @ts-ignore
const forceGenerateImages = !!builder.options.forceGenerateImages;
// Debug flag
// @ts-ignore
const debug = !!builder.options.debug;
if (debug && !forceGenerateImages) {
// Since the plugin does a lot of scanning of files, it is fine not to run it in debug mode
// The change will be picked up on release
return;
}
const rootDir = builder.options.rootDir!;
const svgFiles = globSync(`**/*.svg`, { cwd: rootDir });
svgFiles.forEach((svgFile) => {
// Web app can use svg files, no need to convert
if (svgFile.includes('www')) {
return;
}
const metafile = joinPath(rootDir, `${svgFile}${META_EXT}`);
if (!existsSync(metafile)) {
this.createDefaultMetaFile(svgFile, metafile);
}
const meta = json5.parse(readFileSync(metafile, 'utf8'));
this.generateImages(svgFile, meta, metafile, rootDir, files, forceGenerateImages);
});
}
createDefaultMetaFile(svgFile: string, metafile: string) {
const meta = {
inputHash: '',
outputs: [{
outputFilePath: svgFile.replace('.svg', '.png'),
outputHash: '',
width: 64,
height: 64,
}]
}
writeFileSync(metafile, json5.stringify(meta, null, 2));
}
generateImages(svgFile: string, meta: any, metafile: string, rootDir: string, files: FileObj[], forceGenerateImages: boolean) {
let metaChanged = false;
const inputHash = this.checkFileHash(joinPath(rootDir, svgFile), meta.inputHash);
if (!inputHash.valid) {
meta.inputHash = inputHash.hash;
metaChanged = true;
}
for (var i in meta.outputs) {
const output = meta.outputs[i];
const outputFilePath = joinPath(rootDir, output.outputFilePath);
let outputHash = this.checkFileHash(outputFilePath, output.outputHash);
if (inputHash.valid && outputHash.valid && !forceGenerateImages) {
continue;
}
this.generateImage(svgFile, output, rootDir);
outputHash = this.checkFileHash(outputFilePath, output.outputHash);
files.push({ src: outputFilePath, dest: output.outputFilePath })
output.outputHash = outputHash.hash;
metaChanged = true;
}
if (metaChanged) {
writeFileSync(metafile, json5.stringify(meta, null, 2));
}
}
generateImage(svgFile: string, output: any, rootDir: string) {
shell.exec(`node ../../tools/convert-image.js --input "${svgFile}" --options '${JSON.stringify(output)}'`, {
cwd: rootDir
})
}
checkFileHash(file: string, hash: string) {
if (!existsSync(file)) {
return {
valid: false,
hash: ''
}
}
const outputHash = md5(readFileSync(file, 'binary')).toString();
return {
valid: outputHash === hash,
hash: outputHash
}
}
}
export default () => {
return new ImageGenPlugin();
};
Loaded 100 of 106 files, more files were not shown because too many files have changed in this diff. Show more