Compare commits

...
101 Commits
Author SHA1 Message Date
Brahim Hadriche cbb34d45fc Release v0.37.0 (#605)
* Release v0.37.0

* web app adjustments
2025-05-16 18:19:52 -04:00
Brahim Hadriche beeb21283d [skip ci] error formatting tweak 2025-05-16 11:59:02 -04:00
Brahim Hadriche 89ec969c40 YouTube account support enabled 2025-05-15 22:44:41 -04:00
Brahim Hadriche 0e226cfc42 CORS change 2025-05-15 22:22:52 -04:00
Brahim Hadriche 5762de656c Ignore videoSurveyShelfRenderer 2025-05-15 22:18:01 -04:00
Brahim Hadriche a721cd3f0a [skip ci] YouTube account disclaimer 2025-05-15 22:11:24 -04:00
Brahim Hadriche 8c0692dc10 Fix formatting 2025-05-15 21:56:38 -04:00
Brahim Hadriche 21c7aee907 [skip ci] Update Privacy 2025-05-15 21:55:01 -04:00
Brahim Hadriche 227a5157a5 Parse metadata lines on tv feeds 2025-05-15 21:50:40 -04:00
Brahim Hadriche 4fc44becd2 OAuth: mark video watched (#604)
* OAuth: mark video watched

* remove comment

* Tweaks
2025-05-15 18:29:18 -04:00
Brahim Hadricheandgithub-action linter 918b763384 OAuth: subscribe/unsubscribe (#603)
* OAuth: subscribe/unsubscribe

* Lint fix

* Cancel fetch status when subscribe button is clicked

* tweak

* error handling

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2025-05-14 20:11:18 -04:00
Brahim Hadriche e821464451 OAuth: recommended feed 2025-05-13 18:08:34 -04:00
Brahim Hadriche fb030cee97 OAuth: Fix auth playlist duplication issue 2025-05-13 13:56:32 -04:00
Brahim Hadriche 6e13e3009a [skip ci] Make username label wider 2025-05-12 22:18:15 -04:00
Brahim Hadriche b38f105e02 Private playlists, continuation 2025-05-12 19:58:07 -04:00
Brahim Hadriche 9b58bf47ad Do not print auth token to logs 2025-05-11 20:05:10 -04:00
Brahim Hadriche af12ac43be [skip ci] Display YouTube profile in web app 2025-05-11 19:47:38 -04:00
Brahim Hadriche 32f0477f36 OAuth fix lock from web app in case Invidious instance is not Playlet backend 2025-05-11 19:47:16 -04:00
Brahim Hadriche dcadb1ec17 Add Canadian english locale file 2025-05-11 15:58:10 -04:00
Brahim Hadriche 02c9358eb1 [skip ci] ignore adsControlFlowOpportunityReceivedCommand 2025-05-11 15:47:46 -04:00
Brahim Hadriche dea178f78e [skip ci] ignore adSlotRenderer 2025-05-11 15:42:25 -04:00
Brahim Hadriche 1268f63bbc Fix isue with web app fetching translation for locale en_CA 2025-05-11 12:41:37 -04:00
Brahim Hadriche cd10f237f4 [skip ci] Handle singleColumnBrowseResultsRenderer 2025-05-10 22:39:01 -04:00
Brahim Hadriche 64c23ade48 update dependencies (#600) 2025-05-10 21:12:01 -04:00
Brahim Hadricheandgithub-action linter 1dcd88a9a4 OAuth refresh token (#601)
* OAuth refresh token

* Lint fix

* tweak refresh logic

* error handling cancelled request

* Ignore endScreenPlaylistRenderer

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2025-05-10 21:04:07 -04:00
Brahim Hadriche b040b2997c Rotate visitor data every day 2025-05-08 21:48:52 -04:00
Brahim Hadriche 21a10705f1 Handle unauthorized case in backend 2025-05-06 17:05:01 -04:00
Brahim Hadriche 1120d40085 [skip ci] skip genericPromoRenderer 2025-05-05 21:56:16 -04:00
Brahim Hadriche 2b633888f4 [skip ci] TODO for adding "mark as watched" 2025-05-05 20:06:47 -04:00
Brahim Hadriche af4a6ee726 placeholder 2025-05-05 20:05:26 -04:00
Brahim Hadricheandgithub-action linter f3f9327c1c Process local http request (#599)
* Local http?

* option utils

* Fix for hanging web app

* Lint fix

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2025-05-05 17:21:12 -04:00
Brahim Hadriche fae875845a Remove workaround no longer needed 2025-05-04 10:47:19 -04:00
Brahim Hadriche 17aca0b8bf Release v0.36.7 (#597) 2025-05-03 22:40:45 -04:00
Brahim Hadriche 49390ab0ae Fixed Playlet backend error caused by Roku 14.5 update on Canada devices 2025-05-03 22:34:57 -04:00
Brahim Hadriche bb2ca5515b [skip ci] tweak 2025-05-03 12:02:18 -04:00
Brahim Hadriche e15b6ec958 [skip ci] small tweak 2025-05-03 11:40:06 -04:00
Brahim Hadriche 6a80fe6c74 Parse gridShelfViewModel 2025-05-03 11:37:37 -04:00
Brahim Hadriche 0d61d1e337 Release v0.36.6 (#596) 2025-05-03 10:42:26 -04:00
Brahim Hadriche 33c6e174ee [chore] update dependencies (#595)
* update dependencies

* Bottom nav ui fix

* Bottom nav ui fix2

* changelog

* Backend logging
2025-05-03 10:34:40 -04:00
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
122 changed files with 4564 additions and 1321 deletions

No files matched your search

+72 -1
View File
@@ -5,6 +5,77 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.37.0] - 2025-05-16
### Added
- YouTube account support. The following features are now available:
- The ability to login to one or multiple accounts
- Both YouTube accounts and Invidious accounts are supported side-by-side
- Subscritions
- User playlists
- Watch History
- Watched videos on Playlet are added to the watch history
- Subscribe/Unsubscribe
- Recommended videos for logged in YouTube user are available in the home screen
- This feed can be enabled/disabled from the settings
- When an Invidious user is logged in, this becomes "popular" since Invidious does not support recommendations
### Fixed
- A bug where Session data did not refresh after 24 hours
### Changed
- [advanced users]: the Playlet web server's CORS headers are no longer set to `*`, for security reasons.
## [0.36.7] - 2025-05-04
### Fixed
- Playlet backend error caused by Roku 14.5 update on Canada devices
## [0.36.6] - 2025-05-03
### Fixed
- Small UI bug in web app nav bar
- Backend logging to improve debugging
## [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
@@ -13,7 +84,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
### 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.
+5
View File
@@ -32,6 +32,11 @@ Playlet makes requests directly to Innertube instead of Invidious.
Similar to Invidious requests, only the bare minimum and necessary information
is sent, which is used to enable the viewing of content.
Additionally, when a YouTube account is used in Playlet, Innertube traffic can
become associated with the account, which further reduces user privacy. This
is necessary to use features associated with YouTube accounts, such as
subscriptions, playlists, and watch history.
## SponsorBlock
Playlet may request information from a [SponsorBlock](https://github.com/ajayyy/SponsorBlock)
+3 -2
View File
@@ -15,7 +15,7 @@
<a href="/LICENSE">
<img alt="AGPL-3.0 license" src="https://img.shields.io/github/license/iBicha/playlet.svg"/>
</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"/>
</a>
<a href="https://github.com/iBicha/playlet/wiki">
@@ -40,7 +40,7 @@ More under [Screenshots](./docs/screenshots/README.md)
## 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)
@@ -49,6 +49,7 @@ Can't install from the store? See [How to install Playlet as a sideloaded/dev ap
- 🔥 No Ads (Not now, not ever)
- 🕵️ No Tracking
- 🛡️ Privacy driven (uses [Invidious](https://invidious.io/) backend)
- 🙋 User accounts (YouTube and Invidious accounts)
- ⚔️ [SponsorBlock](https://sponsor.ajay.app/) integration (skips undesirable sections in videos)
- 📱 Browse, search, and cast from phone using the YouTube app or the browser
- 🔮 Picture-in-picture mode
-1
View File
@@ -91,7 +91,6 @@
"../tools/bs-plugins/json-yaml-plugin.ts",
"../tools/bs-plugins/validation-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/web-server-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/validation-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/web-server-plugin.ts",
"../tools/bs-plugins/locale-validation-plugin.ts",
+1 -1
View File
@@ -2,7 +2,7 @@ openapi: 3.0.0
info:
title: Playlet Web API
version: 0.36.1
version: 0.37.0
description:
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
-16
View File
@@ -1,7 +1,6 @@
# Playlet Brighterscript Plugins
- [Json5/Yaml support](#json5yaml-support)
- [Convert images](#convert-images)
- [Manifest editing](#manifest-editing)
- [Validation](#validation)
- [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.
## 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
**[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 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({
RokuDevice: {
devices: [{
@@ -16,7 +21,7 @@ export function setupEnvironment() {
},
ECP: {
default: {
launchChannelId: 'dev'
launchChannelId: appId,
}
},
OnDeviceComponent: {
+36 -8
View File
@@ -1,14 +1,14 @@
// 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 { setupEnvironment } from './common';
import { AppId, setupEnvironment } from './common';
import { Key } from 'roku-test-automation/client/dist/ECP';
setupEnvironment();
async function playVideoDev() {
setupEnvironment(AppId.DEV);
(async () => {
await ecp.sendInput({ params: { contentId: "jNQXAC9IVRw" } });
await ecp.sendLaunchChannel({ params: { contentId: "jNQXAC9IVRw" } });
await ecp.sleep(5000);
await odc.onFieldChangeOnce({
base: "scene",
@@ -18,7 +18,35 @@ setupEnvironment();
console.log("Video started playing");
await ecp.sendKeypress(Key.Back);
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();
})();
+716 -465
View File
File diff suppressed because it is too large. Load diff
+21 -17
View File
@@ -1,36 +1,37 @@
{
"name": "playlet",
"version": "0.36.1",
"version": "0.37.0",
"description": "Unofficial YouTube client for Roku",
"devDependencies": {
"@rokucommunity/bslint": "^0.8.28",
"@rokucommunity/bslint": "^0.8.30",
"@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4",
"@types/node": "^22.10.7",
"@types/node": "^22.15.17",
"@types/xml2js": "^0.4.14",
"argparse": "^2.0.1",
"brighterscript": "0.68.3",
"brighterscript-formatter": "^1.7.8",
"brighterscript": "0.68.5",
"brighterscript-formatter": "^1.7.13",
"cheerio": "1.0.0-rc.11",
"convert-svg-to-png": "^0.6.4",
"crypto-js": "^4.2.0",
"dotenv": "^16.4.7",
"dotenv": "^16.5.0",
"fs-extra": "^11.3.0",
"glob": "^11.0.1",
"glob": "^11.0.2",
"imap": "^0.8.19",
"ip": "^2.0.1",
"json5": "^2.2.3",
"mailparser": "^3.7.2",
"protocol-buffers-schema": "^3.6.0",
"roku-deploy": "^3.12.3",
"roku-test-automation": "^2.0.10",
"rooibos-roku": "5.14.0",
"roku-deploy": "^3.12.5",
"roku-test-automation": "^2.0.13",
"rooibos-roku": "5.15.7",
"rounded-rect-9patch": "^1.1.2",
"semver": "^7.6.3",
"shelljs": "^0.8.5",
"semver": "^7.7.1",
"shelljs": "^0.10.0",
"ts-node": "^10.9.2",
"typescript": "5.7.3",
"typescript": "5.8.3",
"xml2js": "^0.6.2",
"yaml": "^2.7.0"
"yaml": "^2.7.1"
},
"engines": {
"node": "20"
@@ -62,15 +63,18 @@
"sign-released-package": "node tools/sign-released-package.js",
"screenshot": "node tools/screenshot.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",
"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:read": "node tools/registry.js --output registry.json",
"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": {
"@rollup/rollup-linux-x64-gnu": "^4.30.1"
"@rollup/rollup-linux-x64-gnu": "^4.40.2"
}
}
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-app",
"version": "0.36.1",
"version": "0.37.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-app",
"version": "0.36.1"
"version": "0.37.0"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-app",
"version": "0.36.1",
"version": "0.37.0",
"description": "Unofficial YouTube client for Roku",
"scripts": {
"prebuild": "rm -rf ../build/playlet-app",
+2 -2
View File
@@ -2,8 +2,8 @@ title=Playlet
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=36
build_version=00001
minor_version=37
build_version=00000
ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-lib",
"version": "0.36.1",
"version": "0.37.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-lib",
"version": "0.36.1"
"version": "0.37.0"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-lib",
"version": "0.36.1",
"version": "0.37.0",
"description": "Unofficial YouTube client for Roku",
"scripts": {
"prebuild": "rm -rf ../build/playlet-lib",
@@ -159,18 +159,25 @@ function OnDispose()
m.subscribeTask.cancel = true
m.subscribeTask = invalid
end if
if m.fetchSubscriptionStatusTask <> invalid
m.fetchSubscriptionStatusTask.cancel = true
m.fetchSubscriptionStatusTask = invalid
end if
end function
function OnSubscribeButtonSelected()
if m.subscribeTask <> invalid
m.subscribeTask.cancel = true
end if
if m.fetchSubscriptionStatusTask <> invalid
m.fetchSubscriptionStatusTask.cancel = true
end if
isSubbed = IsSubscribed()
m.subscribeTask = AsyncTask.Start(Tasks.SubscribeTask, {
channelView: m.top
invidious: m.invidious
ucid: m.authorId
subscribe: not isSubbed
subscribe: not m.top.isSubscribed
})
end function
@@ -350,25 +357,10 @@ function IsLoggedIn() as boolean
return m.invidious.authToken <> invalid
end function
function IsSubscribed() as boolean
authorId = m.top.authorId
if StringUtils.IsNullOrEmpty(authorId)
return false
end if
subscriptions = m.invidious.subscriptions
if subscriptions = invalid
return false
end if
if not subscriptions.DoesExist(authorId)
return false
end if
return subscriptions[authorId]
end function
function OnAuthorIdChange()
SetSubscribeButtonVisibility()
OnSubscriptionChanged()
FetchSubscriptionStatus()
end function
function SetSubscribeButtonVisibility()
@@ -380,9 +372,34 @@ function SetSubscribeButtonVisibility()
end if
end function
function FetchSubscriptionStatus() as void
if not IsLoggedIn()
return
end if
authorId = m.top.authorId
if StringUtils.IsNullOrEmpty(authorId)
return
end if
if m.fetchSubscriptionStatusTask <> invalid
return
end if
m.fetchSubscriptionStatusTask = AsyncTask.Start(Tasks.FetchSubscriptionStatusTask, {
channelView: m.top
ucid: authorId
authToken: m.invidious.authToken
invidious: m.invidious
})
end function
function OnFetchSubscriptionStatusResult(result as object) as void
m.fetchSubscriptionStatusTask = invalid
end function
function OnSubscriptionChanged()
isSubbed = IsSubscribed()
if isSubbed
if m.top.isSubscribed
m.subscribeButton.text = Tr(Locale.Buttons.Unsubscribe)
else
m.subscribeButton.text = Tr(Locale.Buttons.Subscribe)
@@ -2,6 +2,7 @@
<interface>
<field id="content" type="node" onChange="OnContentSet" />
<field id="authorId" type="string" onChange="OnAuthorIdChange" />
<field id="isSubscribed" type="boolean" onChange="OnSubscriptionChanged" />
<field id="appController" type="node" bind="/AppController" />
<field id="invidious" type="node" bind="/Invidious" />
<field id="bookmarksService" type="node" bind="/BookmarksService" />
@@ -0,0 +1,48 @@
import "pkg:/components/Services/Innertube/InnertubeService.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs"
@asynctask
function FetchSubscriptionStatusTask(input as object) as object
channelView = input.channelView
ucid = input.ucid
invidiousNode = input.invidious
authToken = input.authToken
if m.top.cancel
return invalid
end if
isInnertubeProfile = authToken.profileNode.type = "youtube"
if isInnertubeProfile
subscriptionStatus = InnertubeService.GetSubscriptionStatusForChannel(ucid, {
cancellation: m.top.cancellation
accessToken: authToken.token
})
if subscriptionStatus.error <> invalid
LogError("Failed to fetch subscription status:", subscriptionStatus.error)
return invalid
end if
channelView.isSubscribed = subscriptionStatus.isSubscribed
else
service = new Invidious.InvidiousService(invidiousNode)
subscriptionsRequest = service.GetSubscriptions(m.top.cancellation)
if not subscriptionsRequest.IsSuccess()
error = subscriptionsRequest.ErrorMessage()
LogError("Failed to fetch subscriptions:", error)
return invalid
end if
subscriptions = subscriptionsRequest.Json()
isSubscribed = false
for each subscription in subscriptions
if subscription.authorId = ucid
isSubscribed = true
exit for
end if
end for
channelView.isSubscribed = isSubscribed
end if
return invalid
end function
@@ -2,6 +2,7 @@ import "pkg:/components/Services/Invidious/InvidiousService.bs"
@asynctask
function SubscribeTask(input as object) as object
channelView = input.channelView
invidiousNode = input.invidious
ucid = input.ucid
subscribe = input.subscribe
@@ -13,23 +14,17 @@ function SubscribeTask(input as object) as object
service = new Invidious.InvidiousService(invidiousNode)
if subscribe
response = service.Subscribe(ucid)
response = service.Subscribe(ucid, m.top.cancellation)
else
response = service.Unsubscribe(ucid)
response = service.Unsubscribe(ucid, m.top.cancellation)
end if
if not response.IsSuccess()
error = response.ErrorMessage()
LogError("Failed to subscribe/unsubscribe to channel:", error)
return {
success: false
error: error
}
return invalid
end if
invidiousNode.refreshSubscribtions = true
return {
success: true
}
channelView.isSubscribed = subscribe
return invalid
end function
@@ -9,6 +9,7 @@
<field id="loadingBitmapUri" type="uri" alias="Poster.loadingBitmapUri" />
<field id="failedBitmapUri" type="uri" alias="Poster.failedBitmapUri" />
<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="maskSize" type="vector2d" alias="MaskGroup.maskSize" />
@@ -0,0 +1,5 @@
<component name="BackendTypeContentNode" extends="ContentNode">
<interface>
<field id="backendLogoUri" type="uri" />
</interface>
</component>
@@ -43,5 +43,6 @@
<field id="statsText" type="string" />
<!-- videoId is Mix continuation (playlistId starts with "RD") -->
<field id="videoId" type="string" />
<field id="lines" type="stringarray" />
</interface>
</component>
@@ -54,24 +54,18 @@ function PlaylistContentTask(input as object) as object
}
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)
childCount = contentNode.getChildCount()
videoCount = ValidInt(metadata.videoCount)
hasContinuation = not StringUtils.IsNullOrEmpty(metadata.continuation)
if (hadContinuation and not hasContinuation) or (metadata.videos.Count() = 0 or childCount >= videoCount)
noMoreContinuation = hadContinuation and not hasContinuation
noVideosReturned = metadata.videos.Count() = 0
reachedVideoCount = videoCount <> -1 and childCount >= videoCount
if noMoreContinuation or noVideosReturned or reachedVideoCount
contentNode.loadState = FeedLoadState.Loaded
return {
success: true
@@ -0,0 +1,56 @@
import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/TimeUtils.bs"
function HasValidAccessToken(_unused as dynamic) as boolean
serverType = m.top.type
accessToken = m.top.accessToken
if StringUtils.IsNullOrEmpty(accessToken)
return false
end if
if serverType = "invidious"
return true
end if
nowSeconds = TimeUtils.Now().AsSeconds()
expiresTimestamp = m.top.expiresTimestamp
' We should refresh the token if it's about to expire in 30 minutes
' Although the current token might be valid, we can let current request
' wait for the new token
shouldRefreshToken = expiresTimestamp < nowSeconds + 60 * 30
if shouldRefreshToken
RefreshAccessToken()
end if
return not shouldRefreshToken
end function
function RefreshAccessToken() as void
if m.refreshTokenTask <> invalid
return
end if
if m.profilesService = invalid
m.profilesService = m.top.getScene().findNode("ProfilesService")
end if
LogInfo("Refreshing access token for profile:", m.top.username)
m.refreshTokenTask = AsyncTask.Start(Tasks.ProfileRefreshTokenTask, {
profile: m.top
profilesService: m.profilesService
accessTokenObject: {
clientId: m.top.clientId
clientSecret: m.top.clientSecret
refreshToken: m.top.refreshToken
}
}, OnProfileRefreshTokenTaskResult)
end function
function OnProfileRefreshTokenTaskResult(output as object) as void
m.refreshTokenTask = invalid
end function
@@ -8,6 +8,7 @@
<field id="accessToken" type="string" />
<!-- Innertube fields -->
<field id="thumbnail" type="uri" />
<field id="refreshToken" type="string" />
<field id="scope" type="string" />
<field id="tokenType" type="string" />
@@ -17,5 +18,7 @@
<field id="clientSecret" type="string" />
<field id="color" type="color" />
<function name="HasValidAccessToken" />
</interface>
</component>
@@ -0,0 +1,25 @@
import "pkg:/components/Services/Innertube/InnertubeService.bs"
import "pkg:/source/utils/ErrorUtils.bs"
@asynctask
function ProfileRefreshTokenTask(input as object) as object
profileNode = input.profile
accessTokenObject = input.accessTokenObject
profilesService = input.profilesService
try
if InnertubeService.AuthRefreshAccessToken(accessTokenObject)
profileNode.expiresIn = accessTokenObject.expiresIn
profileNode.expiresTimestamp = accessTokenObject.expiresTimestamp
profileNode.accessToken = accessTokenObject.accessToken
profilesService@.SaveUserProfilesToRegistry()
else
LogError("Failed to refresh access token")
profileNode.accessToken = invalid
end if
catch error
LogError("Failed to refresh access token:", ErrorUtils.Format(error))
profileNode.accessToken = invalid
end try
return invalid
end function
@@ -22,5 +22,6 @@
<field id="title" type="string" />
<field id="videoId" type="string" />
<field id="viewCountText" type="string" />
<field id="lines" type="stringarray" />
</interface>
</component>
@@ -1,4 +1,4 @@
<component name="LoginDialog" extends="StandardDialog" initialFocus="buttonArea" includes="AutoBind">
<component name="InvidiousLoginDialog" extends="StandardDialog" initialFocus="buttonArea" includes="AutoBind">
<interface>
<field id="webServer" type="node" bind="/WebServer" />
<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
+20 -9
View File
@@ -54,18 +54,29 @@ function StartWebServer()
m.dialServer@.StartServer()
end function
function ShowAnnouncement()
DialogUtils.ShowDialogOnce({
messageId: "1736288537"
title: "Announcement - Playlet backend"
function ShowAnnouncement() as void
dialog = DialogUtils.ShowDialogOnce({
messageId: "1747362859"
title: "Announcement - YouTube account support"
message: [
"An experimental built-in backend has been added to Playlet."
"This allows you to access YouTube content without the need for an Invidious instance."
"To use it, go to the Settings > Invidious > Instance and set the field to empty (Edit, and delete the url)."
"Please note that it's missing some features and may not work as expected."
"Thank you for using Playlet!"
"YouTube account support is now available in Playlet!"
`Subscriptions, playlists, watch history and "Recommended" are now available in the app.`
"If you encounter any issues, please report them on GitHub."
"https://github.com/iBicha/playlet/issues"
"Thank you."
]
alwaysOnTop: true
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
@@ -51,19 +51,28 @@ function StartWebServer()
m.dialServer.callfunc("StartServer", invalid)
end function
function ShowAnnouncement()
DialogUtils_ShowDialogOnce({
messageId: "1736288537"
title: "Announcement - Playlet backend"
function ShowAnnouncement() as void
dialog = DialogUtils_ShowDialogOnce({
messageId: "1747362859"
title: "Announcement - YouTube account support"
message: [
"An experimental built-in backend has been added to Playlet."
"This allows you to access YouTube content without the need for an Invidious instance."
"To use it, go to the Settings > Invidious > Instance and set the field to empty (Edit, and delete the url)."
"Please note that it's missing some features and may not work as expected."
"Thank you for using Playlet!"
"YouTube account support is now available in Playlet!"
"Subscriptions, playlists, watch history and " + chr(34) + "Recommended" + chr(34) + " are now available in the app."
"If you encounter any issues, please report them on GitHub."
"https://github.com/iBicha/playlet/issues"
"Thank you."
]
alwaysOnTop: true
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
'//# sourceMappingURL=./MainScene.brs.map
@@ -23,13 +23,28 @@ function OnCurrentProfile() as void
return
end if
username = currentProfile.username
if not StringUtils.IsNullOrEmpty(username)
m.letterLabel.text = UCase(username.Left(1))
else
thumbnail = currentProfile.thumbnail
if not StringUtils.IsNullOrEmpty(thumbnail)
m.circlePosterInner.uri = thumbnail
' bs:disable-next-line LINT3023
m.circlePosterInner.blendColor = "#FFFFFFFF"
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
m.circlePosterInner.blendColor = currentProfile.color
m.circlePoster.visible = true
m.buttonIcon.visible = false
@@ -12,7 +12,7 @@
height="40"
blendColor="#DDDDDDFF"
uri="pkg:/images/white-circle.png">
<Poster
<CirclePoster
id="circlePosterInner"
width="36"
height="36"
@@ -27,7 +27,7 @@
horizAlign="center">
<Font role="font" uri="font:SystemFontFile" size="24" />
</Label>
</Poster>
</CirclePoster>
</Poster>
</children>
</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"
m.top.circlePosterInnerUri = "pkg:/images/icons/user-200.png"
m.top.backendTypePosterUri = ""
' bs:disable-next-line LINT3023
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
m.top.letter = ""
@@ -23,17 +24,43 @@ function OnContentSet() as void
return
end if
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
m.top.circlePosterInnerBlendColor = content.color
username = content.username
m.top.username = username
if not StringUtils.IsNullOrEmpty(username)
m.top.letter = UCase(username.Left(1))
else
thumbnail = content.thumbnail
if not StringUtils.IsNullOrEmpty(thumbnail)
m.top.circlePosterInnerUri = thumbnail
' bs:disable-next-line LINT3023
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
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
m.top.serverUrl = content.serverUrl
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
function OnRowListHasFocus()
@@ -6,6 +6,7 @@
<field id="serverUrl" type="string" alias="ServerLabel.text" />
<field id="circlePosterInnerUri" type="uri" alias="circlePosterInner.uri" />
<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="rowListHasFocus" type="boolean" onChange="OnRowListHasFocus" />
<field id="itemHasFocus" type="boolean" onChange="OnItemHasFocus" />
@@ -45,7 +46,7 @@
translation="[20,20]"
blendColor="#DDDDDDFF"
uri="pkg:/images/white-circle.png">
<Poster
<CirclePoster
id="circlePosterInner"
width="152"
height="152"
@@ -60,7 +61,13 @@
horizAlign="center">
<Font role="font" uri="font:SystemFontFile" size="120" />
</Label>
</Poster>
<Poster
id="backendTypePoster"
width="60"
height="60"
translation="[110,110]"
/>
</CirclePoster>
<Poster
id="CrownPoster"
width="60"
@@ -72,9 +79,9 @@
</Poster>
<Label
id="UsernameLabel"
width="200"
width="300"
horizAlign="center"
translation="[0,250]">
translation="[-50,250]">
</Label>
<Label
id="ServerLabel"
@@ -1,7 +1,9 @@
import "pkg:/components/Dialog/DialogUtils.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/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs"
@@ -38,26 +40,79 @@ function OnRowItemSelected() as void
row = m.profileRowList.content.GetChild(0)
selectedProfile = row.GetChild(index)
if selectedProfile.type = "login"
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", "LoginDialog")
dialog@.BindNode()
m.top.getScene().dialog = dialog
backendTypeSelectionView = BackendTypeSelectionViewUtils.Open(m.appController)
backendTypeSelectionView.observeFieldScoped("selectedBackendType", FuncName(OnBackEndSelected))
return
end if
ProfileViewUtils.Open(selectedProfile, m.appController)
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 is a third-party app and is not affiliated with, endorsed by, or sponsored by YouTube or Google. All trademarks and registered trademarks mentioned are the property of their respective owners and are used only for identification purposes."
"By using Playlet and signing in with your YouTube account, you acknowledge that you do so at your own risk. The developers of Playlet are not liable for any harm, including but not limited to data loss, account suspension or ban, hacking, or loss of content."
"Use responsibly, especially if your YouTube account is tied to business or monetization."
]
large: true
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
currentProfile = m.profilesService.currentProfile
if currentProfile = invalid
@@ -7,7 +7,7 @@
</interface>
<children>
<ProfileRowList
<RowList
id="ProfileRowList"
translation="[0,160]"
numRows="2"
@@ -32,17 +32,44 @@ function OnContentSet() as void
return
end if
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
m.top.circlePosterInnerBlendColor = content.color
username = content.username
m.top.username = username
if not StringUtils.IsNullOrEmpty(username)
m.top.letter = UCase(username.Left(1))
else
thumbnail = content.thumbnail
if not StringUtils.IsNullOrEmpty(thumbnail)
m.top.circlePosterInnerUri = thumbnail
' bs:disable-next-line LINT3023
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
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
m.top.serverUrl = content.serverUrl
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()
end function
@@ -5,6 +5,7 @@
<field id="username" type="string" alias="UsernameLabel.text" />
<field id="serverUrl" type="string" alias="ServerLabel.text" />
<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="crownVisible" type="boolean" alias="CrownPoster.visible" />
@@ -32,7 +33,7 @@
translation="[20,20]"
blendColor="#DDDDDDFF"
uri="pkg:/images/white-circle.png">
<Poster
<CirclePoster
id="circlePosterInner"
width="152"
height="152"
@@ -47,7 +48,13 @@
horizAlign="center">
<Font role="font" uri="font:SystemFontFile" size="120" />
</Label>
</Poster>
<Poster
id="backendTypePoster"
width="60"
height="60"
translation="[110,110]"
/>
</CirclePoster>
<Poster
id="CrownPoster"
width="60"
@@ -59,9 +66,9 @@
</Poster>
<Label
id="UsernameLabel"
width="200"
width="400"
horizAlign="center"
translation="[0,210]">
translation="[-100,210]">
<Font role="font" uri="font:MediumSystemFontFile" size="26" />
</Label>
<Label
@@ -19,7 +19,7 @@
<CheckList
id="checkList"
vertFocusAnimationStyle="floatingFocus"
translation="[164,70]">
translation="[164,40]">
<ContentNode role="content" />
</CheckList>
@@ -1,6 +1,7 @@
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
@@ -9,7 +10,7 @@ function Init()
m.top.itemSpacings = [8]
m.button = m.top.findNode("button")
m.button.text = Invidious.DEFAULT_INSTANCE_NAME
m.button.text = Tr(Locale.Settings.PlayletBuiltinBackend)
AdjustButtonLabel(m.button)
m.button.observeField("buttonSelected", FuncName(OpenInvidiousInstanceSettings))
@@ -81,7 +82,7 @@ function OnValueChange() as void
m.preferences[m.key] = value
if StringUtils.IsNullOrEmpty(value)
m.button.text = Invidious.DEFAULT_INSTANCE_NAME
m.button.text = Tr(Locale.Settings.PlayletBuiltinBackend)
else
m.button.text = value
end if
@@ -1,20 +1,21 @@
const INNERTUBE_IOS_CLIENT_NAME = "5"
const INNERTUBE_IOS_CLIENT_VERSION = "19.49.7"
const INNERTUBE_IOS_OS_VERSION = "15.6"
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_DEVICE_MODEL = "iPhone16,2"
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_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_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_MODEL = "24LF4820-BU"
const INNERTUBE_TV_OS_NAME = "webOS"
const INNERTUBE_TV_OS_VERSION = "2015"
const INNERTUBE_TV_BROWSER_NAME = "LG Browser"
const INNERTUBE_TV_BROWSER_VERSION = "7.00.00"
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)"
@@ -123,7 +123,7 @@ namespace Innertube
"timeZone": deviceInfo.GetTimeZone()
"originalUrl": "https://www.youtube.com"
"deviceMake": "Apple"
"deviceModel": "iPhone10,6"
"deviceModel": INNERTUBE_IOS_DEVICE_MODEL
"utcOffsetMinutes": -240
"memoryTotalKbytes": "8000000"
}
@@ -162,7 +162,12 @@ namespace Innertube
end function
function GetCurrentLocale(deviceInfo as object) as string
return deviceInfo.GetCurrentLocale()
currentLocale = deviceInfo.GetCurrentLocale()
' en_CA is not a valid locale for Innertube
if currentLocale = "en_CA"
currentLocale = "en_US"
end if
return currentLocale
end function
function GetContentRegion(deviceInfo as object) as string
@@ -7,6 +7,7 @@ import "pkg:/components/Services/Innertube/PlayerEndpoint.bs"
import "pkg:/components/Services/Innertube/ResolveUrlEndpoint.bs"
import "pkg:/components/Services/Innertube/SearchEndpoint.bs"
import "pkg:/components/Services/Innertube/SearchFilters.bs"
import "pkg:/components/Services/Innertube/SubscriptionEndpoint.bs"
import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/CancellationUtils.bs"
import "pkg:/source/utils/ObjectUtils.bs"
@@ -39,8 +40,12 @@ namespace InnertubeService
end if
end if
playerRequest = Innertube.CreatePlayerRequest(videoId, ctt, visitorData)
playerRequest = Innertube.CreatePlayerRequest(videoId, ctt, visitorData, Innertube.ClientType.IOS)
playerRequest.Cancellation(cancellation)
if raw
playerRequest.LogCurlCommand()
playerRequest.NoCache()
end if
playerRequest.Send()
nextRequest = invalid
@@ -48,6 +53,10 @@ namespace InnertubeService
if fetchNext
nextRequest = Innertube.CreateNextRequest({ "videoId": videoId }, ctt)
nextRequest.Cancellation(cancellation)
if raw
nextRequest.LogCurlCommand()
nextRequest.NoCache()
end if
nextRequest.Send()
end if
@@ -209,10 +218,13 @@ namespace InnertubeService
trendingType = LCase(ValidString(options.type))
if trendingType = "music"
' {"44:proto": {"3:string": "ytma_charts"}}
params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
else if trendingType = "gaming"
' {"44:proto": {"3:string": "gaming_corpus_most_popular"}}
params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
else if trendingType = "movies"
' {"44:proto": {"3:string": "trailers"}}
params = "4gIKGgh0cmFpbGVycw%3D%3D"
end if
end if
@@ -224,9 +236,16 @@ namespace InnertubeService
request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, params)
request.Cancellation(cancellation)
if raw
request.LogCurlCommand()
request.NoCache()
end if
response = request.Await()
if not response.IsSuccess()
return invalid
return {
error: response.ErrorMessage()
}
end if
if raw
@@ -288,13 +307,82 @@ namespace InnertubeService
response = request.Await()
if not response.IsSuccess()
return invalid
return {
error: response.ErrorMessage()
}
end if
json = response.Json()
return Innertube.ParseResponseDataForFeeds(json)
end function
function AuthMarkVideoWatched(videoId as string, options as object) as boolean
cancellation = invalid
accessToken = options.accessToken
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
playerRequest = Innertube.CreatePlayerRequest(videoId, "", "", Innertube.ClientType.Tv)
playerRequest.Cancellation(cancellation)
playerRequest.Header("Authorization", "Bearer " + accessToken)
playerResponse = playerRequest.Await()
if not playerResponse.IsSuccess()
LogError("Error marking video as watched:", playerResponse.ErrorMessage())
return false
end if
if CancellationUtils.IsCancelled(cancellation)
return false
end if
json = playerResponse.Json()
videostatsPlaybackUrl = ObjectUtils.Dig(json, ["playbackTracking", "videostatsPlaybackUrl", "baseUrl"])
if StringUtils.IsNullOrEmpty(videostatsPlaybackUrl)
LogError("No videostatsPlaybackUrl found in response")
return false
end if
videostatsPlaybackUrl = videostatsPlaybackUrl.replace("https://s.youtube.com", "https://www.youtube.com")
queryParams = UrlUtils.ParseQueryComponents(videostatsPlaybackUrl)
queryParams["c"] = "TVHTML5"
queryParams["cbrver"] = INNERTUBE_TV_CLIENT_VERSION
queryParams["cver"] = INNERTUBE_TV_CLIENT_VERSION
queryParams["cpn"] = InnertubeService.CreateClientPlaybackNonce()
queryParams["fmt"] = "251"
queryParams["rtn"] = "0"
queryParams["rt"] = "0"
queryParams["ver"] = "2"
videostatsPlaybackUrl = UrlUtils.SetQueryParams(videostatsPlaybackUrl, queryParams)
trackingRequest = HttpClient.Get(videostatsPlaybackUrl)
trackingRequest.Header("Authorization", "Bearer " + accessToken)
trackingResponse = trackingRequest.Await()
if not trackingResponse.IsSuccess()
LogError("Error marking video as watched:", trackingResponse.ErrorMessage())
return false
end if
LogDebug("Marked video as watched:", videoId)
return true
end function
function CreateClientPlaybackNonce() as string
length = 16
result = []
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
alphabetLen = alphabet.len()
for i = 1 to length
result.push(alphabet.mid(Rnd(alphabetLen - 1), 1))
end for
return result.join("")
end function
function GetChannel(channelId as string, options = invalid as object) as object
continuation = ""
params = ""
@@ -318,6 +406,10 @@ namespace InnertubeService
request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Web, params, continuation)
request.Cancellation(cancellation)
if raw
request.LogCurlCommand()
request.NoCache()
end if
response = request.Await()
if not response.IsSuccess()
@@ -343,10 +435,123 @@ namespace InnertubeService
return result
end function
function GetSubscriptionStatusForChannel(channelId as string, options = invalid as object) as object
cancellation = invalid
accessToken = options.accessToken
if options <> invalid
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
end if
request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Tv, "", "")
request.Cancellation(cancellation)
if accessToken <> invalid
request.Header("Authorization", "Bearer " + accessToken)
end if
response = request.Await()
if not response.IsSuccess()
return {
error: response.ErrorMessage()
}
end if
responseData = response.Json()
error = Innertube.ParseResponseDataForError(responseData)
if error <> ""
return {
error: error
}
end if
channelHeaderButtons = ObjectUtils.Dig(responseData, ["contents", "tvBrowseRenderer", "content", "tvSurfaceContentRenderer", "header", "channelHeaderRenderer", "buttons"])
if not IsArray(channelHeaderButtons)
return {
error: "Node 'contents.tvBrowseRenderer.content.tvSurfaceContentRenderer.header.channelHeaderRenderer.buttons' not found"
}
end if
subscribeButtonRenderer = invalid
for each button in channelHeaderButtons
if not IsAssociativeArray(button) or not button.DoesExist("subscribeButtonRenderer")
continue for
end if
subscribeButtonRenderer = button.subscribeButtonRenderer
exit for
end for
if subscribeButtonRenderer = invalid
return {
error: "no 'subscribeButtonRenderer' found under 'buttons'"
}
end if
if not IsBool(subscribeButtonRenderer["subscribed"])
return {
error: "no 'subscribed' status found under 'subscribeButtonRenderer'"
}
end if
return {
success: true
isSubscribed: subscribeButtonRenderer["subscribed"]
}
end function
function SubscribeToChannel(channelId as string, options = invalid as object) as object
cancellation = invalid
accessToken = options.accessToken
if options <> invalid
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
end if
request = Innertube.CreateSubscribeRequest(channelId, "")
request.Cancellation(cancellation)
if accessToken <> invalid
request.Header("Authorization", "Bearer " + accessToken)
end if
response = request.Await()
return {
success: response.IsSuccess()
error: response.ErrorMessage()
}
end function
function UnsubscribeFromChannel(channelId as string, options = invalid as object) as object
cancellation = invalid
accessToken = options.accessToken
if options <> invalid
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
end if
request = Innertube.CreateUnsubscribeRequest(channelId, "")
request.Cancellation(cancellation)
if accessToken <> invalid
request.Header("Authorization", "Bearer " + accessToken)
end if
response = request.Await()
return {
success: response.IsSuccess()
error: response.ErrorMessage()
}
end function
function GetPlaylist(playlistId as string, options = invalid as object) as object
continuation = ""
cancellation = invalid
raw = false
accessToken = invalid
if options <> invalid
if options.DoesExist("continuation")
@@ -358,14 +563,29 @@ namespace InnertubeService
if options.DoesExist("raw")
raw = options.raw
end if
if options.DoesExist("accessToken")
accessToken = options.accessToken
end if
end if
if not playlistId.StartsWith("VL")
playlistId = "VL" + playlistId
end if
request = Innertube.CreateBrowseRequest(playlistId, Innertube.ClientType.Web, "", continuation)
client = Innertube.ClientType.Web
if accessToken <> invalid
client = Innertube.ClientType.Tv
end if
request = Innertube.CreateBrowseRequest(playlistId, client, "", continuation)
request.Cancellation(cancellation)
if accessToken <> invalid
request.Header("Authorization", "Bearer " + accessToken)
end if
if raw
request.LogCurlCommand()
request.NoCache()
end if
response = request.Await()
if not response.IsSuccess()
@@ -380,6 +600,10 @@ namespace InnertubeService
result = Innertube.ParsePlaylistPageResponseData(response.Json())
if result.playlistId = invalid and result.error = invalid
result["playlistId"] = playlistId
end if
cacheControl = Innertube.ParseResponseForCacheControl(response)
if cacheControl <> invalid
result["cache-control"] = cacheControl
@@ -411,6 +635,10 @@ namespace InnertubeService
end if
request = Innertube.CreateNextRequest(args, "")
request.Cancellation(cancellation)
if raw
request.LogCurlCommand()
request.NoCache()
end if
response = request.Await()
if not response.IsSuccess()
@@ -452,14 +680,14 @@ namespace InnertubeService
function AuthGetCode(cancellation = invalid as object) as object
result = Innertube.GetClientIdentity(cancellation)
if CancellationUtils.IsCancelled(cancellation)
return invalid
if CancellationUtils.IsCancelled(cancellation) or result.error <> invalid
return result
end if
result2 = Innertube.GetDeviceAndUserCode(result.clientId, cancellation)
if CancellationUtils.IsCancelled(cancellation)
return invalid
if CancellationUtils.IsCancelled(cancellation) or result2.error <> invalid
return result2
end if
result.Append(result2)
@@ -474,24 +702,19 @@ namespace InnertubeService
return Innertube.PollForAccessToken(code, code, cancellation)
end function
function AuthRefreshAccessTokenIfNeeded(accessToken as object, cancellation = invalid as object) as boolean
function AuthRefreshAccessToken(accessToken as object, cancellation = invalid as object) as boolean
if not IsAssociativeArray(accessToken)
return false
end if
nowSeconds = TimeUtils.Now().AsSeconds()
expiresTimestamp = accessToken["expires_timestamp"]
refreshed = Innertube.RefreshAccessToken(accessToken, cancellation)
if expiresTimestamp = invalid or expiresTimestamp < nowSeconds
refreshed = Innertube.RefreshAccessToken(accessToken, cancellation)
if IsAssociativeArray(refreshed) and refreshed.DoesExist("accessToken")
accessToken.Append(refreshed)
if accessToken.DoesExist("expiresIn")
accessToken["expiresTimestamp"] = TimeUtils.Now().AsSeconds() + accessToken["expiresIn"]
end if
return true
if IsAssociativeArray(refreshed) and refreshed.DoesExist("accessToken")
accessToken.Append(refreshed)
if accessToken.DoesExist("expiresIn")
accessToken["expiresTimestamp"] = TimeUtils.Now().AsSeconds() + accessToken["expiresIn"]
end if
return true
end if
return false
@@ -505,4 +728,7 @@ namespace InnertubeService
return Innertube.RevokeAccessToken(accessToken["accessToken"], cancellation)
end function
function AuthListAccounts(accessToken as string, cancellation = invalid as object) as object
return Innertube.ListAccounts(accessToken, cancellation)
end function
end namespace
@@ -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/ObjectUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
@@ -21,7 +25,12 @@ namespace Innertube
for each key in nodeData
directive = directives[key]
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
end if
@@ -33,6 +42,7 @@ namespace Innertube
function GetParsingDirectives() as object
return {
"twoColumnSearchResultsRenderer": ParseTwoColumnSearchResultsRenderer
"singleColumnBrowseResultsRenderer": ParseSingleColumnBrowseResultsRenderer
"twoColumnBrowseResultsRenderer": ParseTwoColumnBrowseResultsRenderer
"watchNextEndScreenRenderer": ParseWatchNextEndScreenRenderer
"tabRenderer": ParseTabRenderer
@@ -44,9 +54,11 @@ namespace Innertube
"reelShelfRenderer": ParseReelShelfRenderer
"verticalListRenderer": ParseVerticalListRenderer
"horizontalListRenderer": ParseHorizontalListRenderer
"horizontalListContinuation": ParseHorizontalListContinuation
"expandedShelfContentsRenderer": ParseExpandedShelfContentsRenderer
"channelFeaturedContentRenderer": ParseChannelFeaturedContentRenderer
"playlistVideoListRenderer": ParsePlaylistVideoListRenderer
"playlistVideoListContinuation": ParsePlaylistVideoListContinuation
"videoRenderer": ParseVideoRenderer
"gridVideoRenderer": ParseGridVideoRenderer
"channelVideoPlayerRenderer": ParseChannelVideoPlayerRenderer
@@ -57,12 +69,14 @@ namespace Innertube
"gridChannelRenderer": ParseGridChannelRenderer
"playlistRenderer": ParsePlaylistRenderer
"gridPlaylistRenderer": ParseGridPlaylistRenderer
"gridShelfViewModel": ParseGridShelfViewModel
"lockupViewModel": ParseLockupViewModel
"shortsLockupViewModel": ParseShortsLockupViewModel
"tvBrowseRenderer": ParseTvBrowseRenderer
"tvSurfaceContentRenderer": ParseTvSurfaceContentRenderer
"tvSecondaryNavRenderer": ParseTvSecondaryNavRenderer
"tvSecondaryNavSectionRenderer": ParseTvSecondaryNavSectionRenderer
"twoColumnRenderer": ParseTwoColumnRenderer
"tileRenderer": ParseTileRenderer
"gridRenderer": ParseGridRenderer
"richGridRenderer": ParseRichGridRenderer
@@ -72,6 +86,8 @@ namespace Innertube
"gridContinuation": ParseGridContinuation
"tvSurfaceContentContinuation": ParseTvSurfaceContentContinuation
' Ignored nodes:
' A playlist at the end of a video. We don't need that for now.
"endScreenPlaylistRenderer": ParseNotImplemented
' Posts not yet supported
"postRenderer": ParseNotImplemented
' a "View all posts" button
@@ -80,10 +96,22 @@ namespace Innertube
"horizontalCardListRenderer": ParseNotImplemented
' expandableTabRenderer contains the search tab with a channel. Ignored.
"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.
"messageRenderer": ParseNotImplemented
' Messages like "Videos you watch will be saved here"
"genericPromoRenderer": ParseNotImplemented
' "Sign in to see the latest videos tailored to your interests"
"feedNudgeRenderer": ParseNotImplemented
"videoSurveyShelfRenderer": ParseNotImplemented
"searchBarRenderer": ParseNotImplemented
"clickTrackingParams": ParseNotImplemented
"promoShelfRenderer": ParseNotImplemented
"adSlotRenderer": ParseNotImplemented
"adsControlFlowOpportunityReceivedCommand": ParseNotImplemented
}
end function
@@ -91,6 +119,10 @@ namespace Innertube
return nodeData["primaryContents"]
end function
function ParseSingleColumnBrowseResultsRenderer(nodeData as object, _context as object) as object
return nodeData["tabs"]
end function
function ParseTwoColumnBrowseResultsRenderer(nodeData as object, _context as object) as object
return nodeData["tabs"]
end function
@@ -140,7 +172,7 @@ namespace Innertube
return nodeData["content"]
end function
function ParseRichShelfRenderer(nodeData as object, context as object) as object
function ParseRichShelfRenderer(nodeData as object, _context as object) as object
' TODO: handle richShelfRenderer.title
return nodeData["contents"]
end function
@@ -154,8 +186,25 @@ namespace Innertube
return nodeData["items"]
end function
function ParseHorizontalListRenderer(nodeData as object, _context as object) as object
' TODO: handle continuations
function ParseHorizontalListRenderer(nodeData as object, context as object) as object
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
if IsString(continuation)
if not StringUtils.IsNullOrEmpty(context.currentFeed.continuation)
StartNewFeed("", context)
end if
context.currentFeed.continuation = continuation
end if
return nodeData["items"]
end function
function ParseHorizontalListContinuation(nodeData as object, context as object) as object
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
if IsString(continuation)
if not StringUtils.IsNullOrEmpty(context.currentFeed.continuation)
StartNewFeed("", context)
end if
context.currentFeed.continuation = continuation
end if
return nodeData["items"]
end function
@@ -167,7 +216,19 @@ namespace Innertube
return nodeData["items"]
end function
function ParsePlaylistVideoListRenderer(nodeData as object, _context as object) as object
function ParsePlaylistVideoListRenderer(nodeData as object, context as object) as object
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
if IsString(continuation)
context.currentFeed.continuation = continuation
end if
return nodeData["contents"]
end function
function ParsePlaylistVideoListContinuation(nodeData as object, context as object) as object
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
if IsString(continuation)
context.currentFeed.continuation = continuation
end if
return nodeData["contents"]
end function
@@ -661,6 +722,10 @@ namespace Innertube
return invalid
end function
function ParseGridShelfViewModel(nodeData as object, _context as object) as object
return nodeData["contents"]
end function
function ParseLockupViewModel(nodeData as object, context as object) as object
contentType = ValidString(nodeData["contentType"])
if contentType = "LOCKUP_CONTENT_TYPE_PLAYLIST"
@@ -671,7 +736,12 @@ namespace Innertube
return LockupViewModelTypeAlbum(nodeData, context)
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
end function
@@ -848,6 +918,13 @@ namespace Innertube
return nodeData["tabs"]
end function
function ParseTwoColumnRenderer(nodeData as object, context as object) as object
' twoColumnRenderer is used for Playlists on TV.
' The right column has the videos (and continuation)
' The left column has the playlist info (title, description, etc) which was already parsed
return nodeData["rightColumn"]
end function
function ParseTileRenderer(nodeData as object, context as object) as object
contentType = ValidString(nodeData["contentType"])
if contentType = "TILE_CONTENT_TYPE_VIDEO"
@@ -856,7 +933,12 @@ namespace Innertube
return TileRendererTypePlaylist(nodeData, context)
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
end function
@@ -894,6 +976,17 @@ namespace Innertube
end if
end if
renderedLines = []
lines = ObjectUtils.Dig(nodeData, ["metadata", "tileMetadataRenderer", "lines"])
if IsArray(lines)
for each line in lines
if not IsAssociativeArray(line)
continue for
end if
renderedLines.Push(ParseLineRenderer(line["lineRenderer"]))
end for
end if
video = {
"type": "video"
"videoId": videoId
@@ -902,6 +995,7 @@ namespace Innertube
"lengthText": lengthText
"liveNow": liveNow
"isUpcoming": isUpcoming
"lines": renderedLines
}
PushFeedItem(video, context)
@@ -926,12 +1020,24 @@ namespace Innertube
end for
end if
renderedLines = []
lines = ObjectUtils.Dig(nodeData, ["metadata", "tileMetadataRenderer", "lines"])
if IsArray(lines)
for each line in lines
if not IsAssociativeArray(line)
continue for
end if
renderedLines.Push(ParseLineRenderer(line["lineRenderer"]))
end for
end if
playlist = {
"type": "playlist"
"playlistId": playlistId
"title": ParseText(ObjectUtils.Dig(nodeData, ["metadata", "tileMetadataRenderer", "title"]))
"playlistThumbnail": ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnail", "thumbnails", 0, "url"])
"videoCountText": videoCountText
"lines": renderedLines
}
PushFeedItem(playlist, context)
@@ -978,7 +1084,7 @@ namespace Innertube
return nodeData["items"]
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"]))
return nodeData["content"]
end function
@@ -1003,6 +1109,44 @@ namespace Innertube
return ""
end function
function ParseLineRenderer(data as object) as string
if data = invalid
return ""
end if
if IsString(data)
return data
end if
if not IsAssociativeArray(data) or not data.DoesExist("items")
return ""
end if
items = data["items"]
if not IsArray(items)
return ""
end if
texts = []
for each item in items
if IsString(item)
texts.Push(item)
else if IsAssociativeArray(item) and item.DoesExist("lineItemRenderer")
texts.Push(ParseLineItemRenderer(item["lineItemRenderer"]))
end if
end for
return texts.Join(" ")
end function
function ParseLineItemRenderer(data as object) as string
if data = invalid
return ""
end if
if IsString(data)
return data
end if
if not IsAssociativeArray(data) or not data.DoesExist("text")
return ""
end if
return ParseText(data["text"])
end function
function StartNewFeed(title as string, context as object) as void
if context.currentFeed <> invalid
if context.currentFeed.items.Count() = 0 and context.currentFeed.title = ""
@@ -1,4 +1,5 @@
import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/ObjectUtils.bs"
import "pkg:/source/utils/TimeUtils.bs"
namespace Innertube
@@ -14,7 +15,9 @@ namespace Innertube
response = request.Await()
if not response.IsSuccess()
throw `Failed to get client id: ${response.ErrorMessage()}`
return {
"error": `Failed to get client id: ${response.ErrorMessage()}`
}
end if
text = response.Text()
@@ -23,7 +26,9 @@ namespace Innertube
match = scriptRegex.Match(text)
if match.Count() < 2
throw "Could not find base-js script"
return {
"error": "Could not find base-js script"
}
end if
baseJsUrl = "https://www.youtube.com" + match[1]
@@ -33,7 +38,9 @@ namespace Innertube
response = request.Await()
if not response.IsSuccess()
throw `Failed to get base js: ${response.ErrorMessage()}`
return {
"error": `Failed to get base js: ${response.ErrorMessage()}`
}
end if
text = response.Text()
@@ -42,7 +49,9 @@ namespace Innertube
match = clientIdRegex.Match(text)
if match.Count() < 3
throw "Could not find client id"
return {
"error": "Could not find client id and secret"
}
end if
return {
@@ -66,13 +75,17 @@ namespace Innertube
response = request.Await()
if not response.IsSuccess()
throw `Failed to get device code: ${response.ErrorMessage()}`
return {
"error": `Failed to get device code: ${response.ErrorMessage()}`
}
end if
responseData = ToCamelCase(response.Json())
if responseData.DoesExist("errorCode")
throw "Failed to get device code: " + ToString(responseData)
return {
"error": "Failed to get device code: " + ToString(responseData)
}
end if
if responseData.DoesExist("expiresIn")
@@ -130,11 +143,13 @@ namespace Innertube
end if
continue while
else if responseData.error = "expired_token"
throw "Failed to get access token: " + ToString(responseData)
return responseData
else if responseData.error = "access_denied"
throw "Failed to get access token: " + ToString(responseData)
return responseData
else
throw "Failed to get access token: " + ToString(responseData)
return {
"error": "Failed to get access token: " + ToString(responseData)
}
end if
end while
@@ -171,12 +186,70 @@ namespace Innertube
request.Cancellation(cancellation)
response = request.Await()
success = response.IsSuccess()
if success
if not success
LogError(`Failed to revoke token: ${response.ErrorMessage()}`)
end if
return success
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
if not IsAssociativeArray(obj)
return obj
@@ -184,44 +184,85 @@ namespace Innertube
}
end if
playlistId = invalid
title = invalid
author = invalid
authorId = invalid
description = invalid
videoCount = -1
thumbnail = invalid
statsText = invalid
playlistSidebarRendererItems = ObjectUtils.Dig(responseData, ["sidebar", "playlistSidebarRenderer", "items"])
if playlistSidebarRendererItems <> invalid
primaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [0, "playlistSidebarPrimaryInfoRenderer"])
secondaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [1, "playlistSidebarSecondaryInfoRenderer"])
primaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [0, "playlistSidebarPrimaryInfoRenderer"])
secondaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [1, "playlistSidebarSecondaryInfoRenderer"])
playlistId = ObjectUtils.Dig(primaryInfo, ["navigationEndpoint", "watchEndpoint", "playlistId"])
title = ParseText(ObjectUtils.Dig(primaryInfo, ["title"]))
description = ParseText(ObjectUtils.Dig(primaryInfo, ["description"]))
videoCount = ParseText(ObjectUtils.Dig(primaryInfo, ["stats", 0, "runs", 0, "text"])).ToInt()
thumbnail = ObjectUtils.Dig(primaryInfo, ["thumbnailRenderer", "playlistVideoThumbnailRenderer", "thumbnail", "thumbnails", 0, "url"])
playlistId = ObjectUtils.Dig(primaryInfo, ["navigationEndpoint", "watchEndpoint", "playlistId"])
title = ParseText(ObjectUtils.Dig(primaryInfo, ["title"]))
description = ParseText(ObjectUtils.Dig(primaryInfo, ["description"]))
videoCount = ParseText(ObjectUtils.Dig(primaryInfo, ["stats", 0, "runs", 0, "text"])).ToInt()
thumbnail = ObjectUtils.Dig(primaryInfo, ["thumbnailRenderer", "playlistVideoThumbnailRenderer", "thumbnail", "thumbnails", 0, "url"])
author = ParseText(ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "title"]))
authorId = ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "navigationEndpoint", "browseEndpoint", "browseId"])
stats = ObjectUtils.Dig(primaryInfo, ["stats"])
if IsArray(stats)
statsTexts = []
for each stat in stats
statText = ParseText(stat)
if statText <> ""
statsTexts.Push(statText)
end if
end for
statsText = statsTexts.Join(" • ")
end if
end if
author = ParseText(ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "title"]))
authorId = ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "navigationEndpoint", "browseEndpoint", "browseId"])
statsText = ""
stats = ObjectUtils.Dig(primaryInfo, ["stats"])
if IsArray(stats)
statsTexts = []
for each stat in stats
statText = ParseText(stat)
if statText <> ""
statsTexts.Push(statText)
twoColumnRenderer = ObjectUtils.Dig(responseData, ["contents", "tvBrowseRenderer", "content", "tvSurfaceContentRenderer", "content", "twoColumnRenderer"])
if twoColumnRenderer <> invalid
entityMetadataRenderer = ObjectUtils.Dig(twoColumnRenderer, ["leftColumn", "entityMetadataRenderer"])
if entityMetadataRenderer <> invalid
if title = invalid
title = ParseText(entityMetadataRenderer["title"])
end if
end for
statsText = statsTexts.Join(" • ")
if statsText = invalid
statsText = ParseLineRenderer(ObjectUtils.Dig(entityMetadataRenderer, ["bylines", 0, "lineRenderer"]))
end if
if description = invalid
description = ParseText(entityMetadataRenderer["description"])
end if
if playlistId = invalid
playlistId = ObjectUtils.Dig(twoColumnRenderer, ["rightColumn", "playlistVideoListRenderer", "playlistId"])
end if
end if
end if
playlist = {
"playlistId": playlistId
"title": title
"author": author
"authorId": authorId
"description": description
"videoCount": videoCount
"thumbnail": thumbnail
"videos": []
"statsText": statsText
}
if playlistId <> invalid
playlist["playlistId"] = playlistId
end if
if title <> invalid
playlist["title"] = title
end if
if author <> invalid
playlist["author"] = author
end if
if authorId <> invalid
playlist["authorId"] = authorId
end if
if description <> invalid
playlist["description"] = description
end if
if thumbnail <> invalid
playlist["thumbnail"] = thumbnail
end if
if statsText <> invalid
playlist["statsText"] = statsText
end if
feeds = ParseResponseDataForFeeds(responseData)
if feeds.Count() > 0
@@ -231,6 +272,10 @@ namespace Innertube
end if
end if
if playlist["thumbnail"] = invalid and playlist["videos"].Count() > 0
playlist["thumbnail"] = ObjectUtils.Dig(playlist, ["videos", 0, "thumbnails", 0, "url"])
end if
return playlist
end function
@@ -6,12 +6,12 @@ import "pkg:/source/utils/Types.bs"
namespace Innertube
function CreatePlayerRequest(videoId as string, ctt as string, visitorData as string) as object
function CreatePlayerRequest(videoId as string, ctt as string, visitorData as string, client as Innertube.ClientType) as object
deviceInfo = CreateObject("roDeviceInfo")
payload = {
"videoId": videoId
"context": Innertube.CreateContext(Innertube.ClientType.IOS, deviceInfo, ctt, visitorData)
"context": Innertube.CreateContext(client, deviceInfo, ctt, visitorData)
"playbackContext": {
"contentPlaybackContext": {
"vis": 0
@@ -36,7 +36,7 @@ namespace Innertube
"accept": "*/*"
"accept-language": "*"
}
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.IOS))
headers.Append(Innertube.CreateHeaders(client))
request.Headers(headers)
return request
@@ -92,6 +92,7 @@ namespace Innertube
end if
lengthSeconds = videoDetails["lengthSeconds"].ToInt()
videoInfo = {
"type": "video"
"title": videoDetails["title"]
@@ -35,6 +35,10 @@ namespace Innertube
})
request.Cancellation(cancellation)
if raw
request.NoCache()
request.LogCurlCommand()
end if
response = request.Await()
if not response.IsSuccess()
@@ -9,7 +9,7 @@ import "pkg:/source/utils/TimeUtils.bs"
namespace Innertube
const SESSION_DATA_VERSION = 1
const INNERTUBE_VISITOR_DATA_LIFESPAN = 1000 * 60 * 60 * 24
const INNERTUBE_VISITOR_DATA_LIFESPAN_SECONDS = 60 * 60 * 24
function GetSessionData() as object
sessionData = ReadSessionDataFromRegistry()
@@ -81,7 +81,7 @@ namespace Innertube
timestamp = sessionData.timestamp
nowSeconds = TimeUtils.Now().AsSeconds()
if nowSeconds - timestamp > INNERTUBE_VISITOR_DATA_LIFESPAN
if nowSeconds - timestamp > INNERTUBE_VISITOR_DATA_LIFESPAN_SECONDS
RegistryUtils.Delete(RegistryUtils.INNERTUBE_SESSION_DATA)
return invalid
end if
@@ -0,0 +1,60 @@
import "pkg:/components/Services/Innertube/Context.bs"
import "pkg:/source/utils/Types.bs"
namespace Innertube
function CreateSubscribeRequest(channelIds as dynamic, params as string) as object
deviceInfo = CreateObject("roDeviceInfo")
payload = {
"context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo, "", "")
}
if IsString(channelIds)
channelIds = [channelIds]
end if
payload["channelIds"] = channelIds
if not StringUtils.IsNullOrEmpty(params)
payload["params"] = params
end if
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/subscription/subscribe?prettyPrint=false&alt=json", payload)
headers = {
"accept": "*/*"
"accept-language": "*"
}
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.Tv))
request.Headers(headers)
return request
end function
function CreateUnsubscribeRequest(channelIds as dynamic, params as string) as object
deviceInfo = CreateObject("roDeviceInfo")
payload = {
"context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo, "", "")
}
if IsString(channelIds)
channelIds = [channelIds]
end if
payload["channelIds"] = channelIds
if not StringUtils.IsNullOrEmpty(params)
payload["params"] = params
end if
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/subscription/unsubscribe?prettyPrint=false&alt=json", payload)
headers = {
"accept": "*/*"
"accept-language": "*"
}
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.Tv))
request.Headers(headers)
return request
end function
end namespace
@@ -14,18 +14,3 @@ end function
function GetAuthorizeTokenLink(_unused as dynamic) as dynamic
return m.service.GetAuthorizeTokenLink()
end function
function OnAuthTokenChange() as void
m.top.refreshSubscribtions = true
end function
function GetSubscriptions() as void
if m.subscriptionsTask <> invalid
m.subscriptionsTask.cancel = true
end if
if m.top.authToken = invalid
m.top.subscriptions = invalid
return
end if
m.subscriptionsTask = AsyncTask.Start(Tasks.InvidiousSubscriptionsTask, { invidious: m.top })
end function
@@ -5,10 +5,8 @@
<field id="webServer" type="node" />
<field id="profilesService" type="node" />
<field id="authToken" type="assocarray" onChange="OnAuthTokenChange" />
<field id="authToken" type="assocarray" />
<field id="apiDefinitions" type="assocarray" />
<field id="refreshSubscribtions" type="boolean" alwaysNotify="true" onChange="GetSubscriptions" />
<field id="subscriptions" type="assocarray" />
<function name="GetCurrentInstance" />
<function name="GetAuthorizeTokenLink" />
@@ -6,6 +6,8 @@ import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/CryptoUtils.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/MessagePortUtils.bs"
import "pkg:/source/utils/OptionUtils.bs"
import "pkg:/source/utils/RegistryUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/TimeUtils.bs"
@@ -14,7 +16,6 @@ namespace Invidious
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_NAME = "Playlet built-in backend"
const INSTANCE_EXAMPLE = "https://invidious.example.com"
const TOKEN_CALLBACK = "/invidious/token_callback"
@@ -70,6 +71,7 @@ namespace Invidious
m.preferences = m.invidiousNode.preferences
end if
instance = m.preferences["invidious.instance"]
if not StringUtils.IsNullOrEmpty(instance)
return instance
end if
@@ -178,9 +180,7 @@ namespace Invidious
function GetPlaylist(playlistId as string, index = 0 as integer, continuation = "" as string, cancellation = invalid as object) as object
authToken = m.invidiousNode.authToken
' There's no need to use auth, unless the playlist is from Invidious
' (starts with "IV") because it can be a private playlist from logged user.
if playlistId.StartsWith("IV") and authToken <> invalid
if authToken <> invalid
url = `${authToken.instance}${Invidious.AUTH_PLAYLISTS}/${playlistId}`
request = HttpClient.Get(url)
request.Headers(m.GetAuthenticationHeaders(authToken.token))
@@ -259,7 +259,11 @@ namespace Invidious
return feedSource
end function
function MakeRequest(feedSource as object, additionalQueryParams = invalid as object, cancellation = invalid as object) as object
function MakeRequest(feedSource as object, options = invalid as dynamic) as object
additionalQueryParams = OptionUtils.Get(options, "additionalQueryParams")
cancellation = OptionUtils.Get(options, "cancellation")
httpServer = OptionUtils.Get(options, "httpServer")
if m.endpoints = invalid
m.endpoints = m.invidiousNode.apiDefinitions
end if
@@ -286,6 +290,20 @@ namespace Invidious
error: ERROR_NOT_AUTHENTICATED
}
end if
profileNode = authToken.profileNode
' This is not the right place for a token refresh,
' but it needs a refactor to be done properly.
if not profileNode@.HasValidAccessToken()
messagePort = CreateObject("roMessagePort")
MessagePortUtils.ObserveFieldScopedExSafe(profileNode, "accessToken", messagePort)
msg = wait(10000, messagePort)
profileNode.unobserveFieldScoped("accessToken")
if msg <> invalid
authToken.token = profileNode.accessToken
m.invidiousNode.authToken = authToken
end if
end if
request.Url(authToken.instance + endpoint.url)
request.Headers(m.GetAuthenticationHeaders(authToken.token))
end if
@@ -335,7 +353,7 @@ namespace Invidious
request.Cancellation(cancellation)
response = request.Await()
response = m.SendRequest(request, httpServer)
responseHandler = invalid
if IsString(endpoint.responseHandler) and m.DoesExist(endpoint.responseHandler)
@@ -359,10 +377,39 @@ namespace Invidious
return {
success: false
error: response.ErrorMessage()
cancelled: response.IsCancelled()
}
end if
end function
function SendRequest(request as HttpClient.HttpRequest, httpServer as dynamic) as dynamic
if httpServer = invalid
return request.Await()
end if
url = request.BuildUrl()
isUrlToLocalServer = url.StartsWith("http://127.0.0.1:8888") or url.StartsWith(m.invidiousNode.webServer@.GetServerAddress())
if not isUrlToLocalServer
return request.Await()
end if
parsedUrl = UrlUtils.ParseUrl(url)
method = request.GetMethod()
uri = parsedUrl.path
headers = request.GetHeaders()
body = ValidString(request.GetBody())
responseObj = httpServer.ProcessRequestLocal(method, uri, headers, body)
response = new HttpClient.HttpResponse(request, invalid)
response.OverrideStatusCode(responseObj.http_code)
response.OverrideHeaders(responseObj.headers)
body = ""
if responseObj.body <> invalid
body = responseObj.body.ToAsciiString()
end if
response.OverrideText(body)
return response
end function
function DefaultHandler(context as object) as object
response = context.response
@@ -1,42 +0,0 @@
import "InvidiousService.bs"
import "pkg:/source/utils/Logging.bs"
@asynctask
function InvidiousSubscriptionsTask(input as object) as object
invidiousNode = input.invidious
service = new Invidious.InvidiousService(invidiousNode)
response = service.GetSubscriptions(m.top.cancellation)
if m.top.cancel
return invalid
end if
subscriptions = response.Json()
if not response.IsSuccess() or subscriptions = invalid
error = response.ErrorMessage()
LogError("Error getting subscriptions:", error)
return {
success: false
error: response.ErrorMessage()
}
end if
if m.top.cancel
return invalid
end if
subscriptionsDict = {}
for each subscription in subscriptions
subscriptionsDict[subscription.authorId] = true
end for
invidiousNode.subscriptions = subscriptionsDict
return {
success: true
}
end function
@@ -51,6 +51,7 @@ namespace InvidiousContent
SetIfExists(node, "videoId", item, "videoId")
node.viewCountText = VideoGetViewCountText(item)
SetIfExists(node, "index", item, "index")
SetIfExists(node, "lines", item, "lines")
return node
end function
@@ -77,6 +78,7 @@ namespace InvidiousContent
SetIfExists(node, "updated", item, "updated")
node.updatedText = PlaylistGetUpdatedText(item)
SetIfExists(node, "statsText", item, "statsText")
SetIfExists(node, "lines", item, "lines")
if item.videos <> invalid
childCount = node.getChildCount()
@@ -307,6 +309,10 @@ namespace InvidiousContent
node.videoCountText = videoCountText
return
end if
' If we already have this information, we should not override it.
if not StringUtils.IsNullOrEmpty(node.videoCountText)
return
end if
videoCount = ValidInt(item.videoCount)
if videoCount = -1
return
@@ -49,7 +49,7 @@ class LongPoller
LogInfo(`Sending long polling GET ${url}`, "ID:", socket.GetID())
#if DEBUG
? `════════ curl command ════════\n${m.ToCurlCommand()}\n══════════════════════════════`
? `======== curl command ========\n${m.ToCurlCommand()}\n==============================`
#end if
message = `GET ${urlObject.path} HTTP/1.1\r\n`
@@ -122,6 +122,27 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
isDirty = true
end if
if userPrefs.__version = 2
if IsArray(userPrefs["misc.home_screen_layout"])
homeScreenLayout = userPrefs["misc.home_screen_layout"]
hasRecommended = false
for each item in homeScreenLayout
if item.id = "recommended"
hasRecommended = true
exit for
end if
end for
if not hasRecommended
homeScreenLayout.Unshift({
id: "recommended"
enabled: true
})
end if
end if
userPrefs.__version = 3
isDirty = true
end if
' TODO:P2 handle case where saved preferences version is higher than current version (e.g. user downgraded)
return isDirty
end function
@@ -39,7 +39,7 @@ function LoadProfilesFromRegistry()
' Step 3: Save user preferences (if needed)
if isDirty
SaveUserProfilesToRegistry()
SaveUserProfilesToRegistry(invalid)
end if
' Step 4: Load user profiles into content nodes
@@ -50,6 +50,7 @@ function LoadProfilesFromRegistry()
profileNode.type = profile.type
profileNode.username = profile.username
profileNode.serverUrl = profile.serverUrl
profileNode.thumbnail = profile.thumbnail
profileNode.accessToken = profile.accessToken
profileNode.refreshToken = profile.refreshToken
@@ -126,7 +127,7 @@ function MigrateExistingProfiles(userProfiles as object) as boolean
return true
end function
function SaveUserProfilesToRegistry() as void
function SaveUserProfilesToRegistry(_unused as dynamic) as void
if m.disableSavingToRegistry
return
end if
@@ -161,6 +162,7 @@ function GetProfilesDto(includeAccessToken as boolean) as object
"type": profileNode.type
"username": profileNode.username
"serverUrl": profileNode.serverUrl
"thumbnail": profileNode.thumbnail
"color": color
}
@@ -203,8 +205,17 @@ function LoginWithProfile(newProfile as object)
end for
if not isNewProfile
' Refresh token of existing profile
existingProfile.username = newProfile.username
existingProfile.thumbnail = newProfile.thumbnail
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
end if
@@ -311,7 +322,7 @@ function SetCurrentProfile(newActiveProfile as object) as void
m.top.currentProfile = invalid
m.invidious.authToken = invalid
LogInfo("Current profile set to <invalid>")
SaveUserProfilesToRegistry()
SaveUserProfilesToRegistry(invalid)
return
end if
@@ -322,9 +333,10 @@ function SetCurrentProfile(newActiveProfile as object) as void
token: newActiveProfile.accessToken
instance: newActiveProfile.serverUrl
username: newActiveProfile.username
profileNode: newActiveProfile
}
LogInfo("Current profile set to", newActiveProfile.username, "@", newActiveProfile.serverUrl)
SaveUserProfilesToRegistry()
SaveUserProfilesToRegistry(invalid)
end function
function RefreshActiveProfileState(activeProfile as object) as void
@@ -18,6 +18,7 @@
<function name="LogoutWithProfiles" />
<function name="LogoutWithAccessToken" />
<function name="SetCurrentProfile" />
<function name="SaveUserProfilesToRegistry" />
</interface>
<children>
<!-- Note: two content nodes because we're rendering profiles in a RowList on the ProfilesScreen -->
@@ -54,7 +54,13 @@ namespace SearchHistoryUtils
if history = invalid
return []
end if
return ParseJson(history)
history = ParseJson(history)
if not IsArray(history)
return []
end if
return history
end function
function Clear()
@@ -1,3 +1,4 @@
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
@@ -13,9 +14,24 @@ function OnContentSet() as void
end if
m.top.title = content.title
lines = content.lines
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.top.author = content._author
m.top.updated = content.updatedText
author = content._author
if StringUtils.IsNullOrEmpty(author)
if IsArray(lines) and lines.Count() > 0
author = lines[0]
end if
end if
m.top.author = author
updatedText = content.updatedText
if StringUtils.IsNullOrEmpty(updatedText)
if IsArray(lines) and lines.Count() > 1
updatedText = lines[1]
end if
end if
m.top.updated = updatedText
m.top.thumbnailUri = content.thumbnail
@@ -18,11 +18,20 @@ function OnContentSet() as void
end if
m.top.title = content.title
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.top.author = content._author
lines = content.lines
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
author = content._author
if StringUtils.IsNullOrEmpty(author)
if IsArray(lines) and lines.Count() > 0
author = lines[0]
end if
end if
m.top.author = author
viewCountDate = ""
if content.isUpcoming = true
m.top.viewCountDate = content.premiereTimestampText
viewCountDate = content.premiereTimestampText
else
publishedText = content.publishedText
viewCountText = content.viewCountText
@@ -33,8 +42,14 @@ function OnContentSet() as void
end if
label += viewCountText
m.top.viewCountDate = label
viewCountDate = label
end if
if StringUtils.IsNullOrEmpty(viewCountDate)
if IsArray(lines) and lines.Count() > 1
viewCountDate = lines[1]
end if
end if
m.top.viewCountDate = viewCountDate
m.top.thumbnailUri = content.thumbnail
@@ -57,7 +57,10 @@ function VideoRowListRowContentTask(input as object) as object
feedSource = service.MarkFeedPagination(feedContentNode)
hadContinuation = not StringUtils.IsNullOrEmpty(feedSource.state.continuation)
response = service.MakeRequest(feedSource, feedSource.state.queryParams, m.top.cancellation)
response = service.MakeRequest(feedSource, {
additionalQueryParams: feedSource.state.queryParams
cancellation: m.top.cancellation
})
if not response.success
if response.error = Invidious.ERROR_NOT_AUTHENTICATED
@@ -93,7 +96,8 @@ function VideoRowListRowContentTask(input as object) as object
feedContentNode.title += " (Failed to load)"
end if
HandleFeedLoadErrorDialog(response.error, rowList)
isCancelled = response.cancelled = true
HandleFeedLoadErrorDialog(response.error, isCancelled, rowList)
continue while
end if
@@ -107,12 +111,23 @@ function VideoRowListRowContentTask(input as object) as object
end for
RemovePlaceHolderItems(feedContentNode)
feedContentNode.appendChildren(itemNodes)
addedItemCount = 0
' For some reason, Innertube's "FEplaylist_aggregation" (which maps to "inv_auth_playlists"
' aka Authenticated user playlists) returns continuation for the next page, but returns
' items from the first page. So we deduplicate to avoid loading this feed infnitely,
' with the same items repeating.
if feedSource.id = "inv_auth_playlists"
addedItemCount = DeduplicateAppendAuthPlaylists(feedContentNode, itemNodes)
else
feedContentNode.appendChildren(itemNodes)
addedItemCount = itemNodes.Count()
end if
hasContinuation = not StringUtils.IsNullOrEmpty(response.result.continuation)
feedSource.state.continuation = ValidString(response.result.continuation)
if response.result.items.Count() > 0
if addedItemCount > 0
pageType = feedSource.state.paginationType
if response.result.isLastPage = true or (hadContinuation and not hasContinuation)
feedSource.state.loadState = FeedLoadState.Loaded
@@ -136,19 +151,19 @@ function VideoRowListRowContentTask(input as object) as object
feedContentNode.loadState = FeedLoadState.LoadedPage
end if
if itemNodes.Count() > 0 and not someContentReadySet
if addedItemCount > 0 and not someContentReadySet
someContentReadySet = true
rowList.someContentReady = true
end if
totalfetchedItems += response.result.items.Count()
totalfetchedItems += addedItemCount
if totalfetchedItems > 3
exit while
end if
end while
catch error
HandleFeedLoadErrorDialog(error, rowList)
HandleFeedLoadErrorDialog(error, false, rowList)
return {
success: false
error: error
@@ -183,13 +198,57 @@ function RemovePlaceHolderItems(contentNode as object)
end if
end function
function HandleFeedLoadErrorDialog(error as object, rowList as object) as void
function DeduplicateAppendAuthPlaylists(feedContentNode as object, itemNodes as object) as integer
if itemNodes.Count() = 0
return 0
end if
currentChildCount = feedContentNode.getChildCount()
if currentChildCount = 0
feedContentNode.appendChildren(itemNodes)
return itemNodes.Count()
end if
currentChildren = feedContentNode.getChildren(-1, 0)
currentChildrenMap = {}
for i = 0 to currentChildCount - 1
playlistId = currentChildren[i].playlistId
if StringUtils.IsNullOrEmpty(playlistId)
continue for
end if
currentChildrenMap[playlistId] = true
end for
nodesToAdd = []
for i = 0 to itemNodes.Count() - 1
itemNode = itemNodes[i]
playlistId = itemNode.playlistId
if StringUtils.IsNullOrEmpty(playlistId)
continue for
end if
if currentChildrenMap[playlistId] = true
continue for
end if
currentChildrenMap[playlistId] = true
nodesToAdd.Push(itemNode)
end for
if nodesToAdd.Count() = 0
return 0
end if
feedContentNode.appendChildren(nodesToAdd)
return nodesToAdd.Count()
end function
function HandleFeedLoadErrorDialog(error as object, isCancelled as boolean, rowList as object) as void
error = ErrorUtils.Format(error)
LogError(error)
rowList.onError = error
if rowList.hasField("dispose") and rowList.dispose
return
end if
if isCancelled
return
end if
DialogUtils.ShowDialogEx({
message: error
title: "Failed to load feed"
@@ -92,6 +92,8 @@ function CreateStreamUrls(metadata as object, service as Invidious.InvidiousServ
metadata.hlsUrl = AddInstanceToUrlIfNeeded(metadata.hlsUrl, instance)
AddHlsUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
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)
end if
@@ -9,6 +9,7 @@ namespace Http
function new(server as object)
super()
m.server = server
task = server.task
m.profilesNode = task.profilesService
m.invidiousNode = task.invidious
@@ -72,12 +73,15 @@ namespace Http
return true
end if
additionalQueryParams = invalid
options = {
httpServer: m.server
}
if feedSource.state <> invalid and feedSource.state.queryParams <> invalid
additionalQueryParams = feedSource.state.queryParams
options.additionalQueryParams = feedSource.state.queryParams
end if
invResponse = m.invidiousService.MakeRequest(feedSource, additionalQueryParams)
invResponse = m.invidiousService.MakeRequest(feedSource, options)
if not invResponse.success
response.Default(500, `Failed to make request: ${invResponse.error}`)
return true
@@ -16,12 +16,39 @@ namespace Http
response = context.response
response.Json({
"error": "Playlet built-in Invidious backend is not a real Invidious instance, and does not support accounts."
"error": "Playlet built-in Invidious backend is not a real Invidious instance, and does not support accounts. Please use the login with YouTube option instead."
})
response.http_code = 400
return true
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")
function GetAuthFeed(context as object) as boolean
request = context.request
@@ -53,6 +80,15 @@ namespace Http
return true
end if
if IsAssociativeArray(feeds)
if feeds.error <> invalid
response.Json(feeds)
response.http_code = 500
return true
end if
return true
end if
result = {
"videos": []
}
@@ -117,6 +153,15 @@ namespace Http
return true
end if
if IsAssociativeArray(feeds)
if feeds.error <> invalid
response.Json(feeds)
response.http_code = 500
return true
end if
return true
end if
if feeds.Count() > 0
response.Json(feeds[0])
return true
@@ -159,6 +204,15 @@ namespace Http
return true
end if
if IsAssociativeArray(feeds)
if feeds.error <> invalid
response.Json(feeds)
response.http_code = 500
return true
end if
return true
end if
if feeds.Count() > 0
response.Json(feeds[0])
return true
@@ -170,6 +224,49 @@ namespace Http
return true
end function
function AuthMarkVideoWatched(context as object) as boolean
request = context.request
response = context.response
route = request.route
accessToken = request.headers["authorization"]
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
response.Json({
"error": "Missing or invalid 'Authorization' header"
})
response.http_code = 403
return true
end if
videoId = route.Mid("/playlet-invidious-backend/api/v1/auth/history/".Len())
if videoId.InStr("?") > 0
videoId = videoId.Left(videoId.InStr("?"))
end if
if StringUtils.IsNullOrEmpty(videoId)
response.Json({
"error": "Missing 'videoId' path parameter"
})
response.http_code = 400
return true
end if
options = {
"accessToken": accessToken.Mid("Bearer ".Len())
}
if not InnertubeService.AuthMarkVideoWatched(videoId, options)
response.Json({
"error": "Failed to mark video as watched"
})
response.http_code = 500
return true
end if
response.Default(204, "OK")
return true
end function
@get("/playlet-invidious-backend/api/v1/stats")
function GetStats(context as object) as boolean
response = context.response
@@ -187,6 +284,11 @@ namespace Http
request = context.request
response = context.response
isRecommended = request.query.recommended = "true"
if isRecommended
return m.GetAuthRecommended(context)
end if
raw = request.query.raw <> invalid
options = {
@@ -222,6 +324,61 @@ namespace Http
return true
end function
function GetAuthRecommended(context as object) as boolean
request = context.request
response = context.response
accessToken = request.headers["authorization"]
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
response.Json({
"error": "Missing or invalid 'Authorization' header"
})
response.http_code = 403
return true
end if
options = {
"accessToken": accessToken.Mid("Bearer ".Len())
}
continuation = request.query.continuation
if not StringUtils.IsNullOrEmpty(continuation)
options.continuation = continuation
end if
feeds = InnertubeService.GetHome(options)
if feeds = invalid
response.Json({
"error": "Failed to get auth home feed"
})
response.http_code = 500
return true
end if
if IsAssociativeArray(feeds)
if feeds.error <> invalid
response.Json(feeds)
response.http_code = 500
return true
end if
return true
end if
result = {
"items": []
}
if feeds.Count() > 0
result["items"] = ValidArray(feeds[0].items)
if feeds[0].DoesExist("continuation")
result["continuation"] = feeds[0].continuation
end if
end if
response.Json(result)
return true
end function
@get("/playlet-invidious-backend/api/v1/search/suggestions")
function GetSearchSuggestions(context as object) as boolean
request = context.request
@@ -289,17 +446,18 @@ namespace Http
end if
result = InnertubeService.Search(query, options)
if result.error <> invalid
response.Json(result)
response.http_code = 500
return true
end if
if raw
response.Json(result)
return true
end if
if result.error <> invalid
response.Json(result)
response.http_code = 500
return true
end if
if not IsArray(result.feeds) or result.feeds.Count() = 0
response.Json({
"error": "Failed to search"
@@ -407,6 +565,8 @@ namespace Http
return m.GetVideo(context)
else if route.StartsWith("/playlet-invidious-backend/api/v1/playlists/")
return m.GetPlaylist(context)
else if route.StartsWith("/playlet-invidious-backend/api/v1/auth/playlists/")
return m.GetAuthPlaylist(context)
else if route.StartsWith("/playlet-invidious-backend/api/v1/channels/")
return m.GetChannel(context)
else if route.StartsWith("/playlet-invidious-backend/channel")
@@ -416,6 +576,20 @@ namespace Http
return false
end function
@post("*")
function PostAll(context as object) as boolean
request = context.request
route = request.route
if route.StartsWith("/playlet-invidious-backend/api/v1/auth/history/")
return m.AuthMarkVideoWatched(context)
else if route.StartsWith("/playlet-invidious-backend/api/v1/auth/subscriptions/")
return m.SubscribeToChannel(context)
end if
return false
end function
function GetVideo(context as object) as boolean
request = context.request
response = context.response
@@ -447,9 +621,12 @@ namespace Http
response = context.response
route = request.route
playlistId = route.Mid("/playlet-invidious-backend/api/v1/playlists/".Len())
if playlistId.InStr("?") > 0
playlistId = playlistId.Left(playlistId.InStr("?"))
playlistId = context.playlistId
if StringUtils.IsNullOrEmpty(playlistId)
playlistId = route.Mid("/playlet-invidious-backend/api/v1/playlists/".Len())
if playlistId.InStr("?") > 0
playlistId = playlistId.Left(playlistId.InStr("?"))
end if
end if
continuation = request.query.continuation
raw = request.query.raw <> invalid
@@ -458,6 +635,11 @@ namespace Http
raw: raw
}
accessToken = request.headers["authorization"]
if not StringUtils.IsNullOrEmpty(accessToken) and accessToken.StartsWith("Bearer ")
options["accessToken"] = accessToken.Mid("Bearer ".Len())
end if
if playlistId.StartsWith("RD")
if not StringUtils.IsNullOrEmpty(continuation)
options.videoId = continuation
@@ -501,6 +683,29 @@ namespace Http
return true
end function
function GetAuthPlaylist(context as object) as boolean
request = context.request
response = context.response
route = request.route
accessToken = request.headers["authorization"]
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
response.Json({
"error": "Missing or invalid 'Authorization' header"
})
response.http_code = 403
return true
end if
playlistId = route.Mid("/playlet-invidious-backend/api/v1/auth/playlists/".Len())
if playlistId.InStr("?") > 0
playlistId = playlistId.Left(playlistId.InStr("?"))
end if
context.playlistId = playlistId
return m.GetPlaylist(context)
end function
function GetChannel(context as object) as boolean
request = context.request
response = context.response
@@ -594,6 +799,104 @@ namespace Http
return false
end function
function SubscribeToChannel(context as object) as boolean
request = context.request
response = context.response
route = request.route
accessToken = request.headers["authorization"]
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
response.Json({
"error": "Missing or invalid 'Authorization' header"
})
response.http_code = 403
return true
end if
channelId = route.Mid("/playlet-invidious-backend/api/v1/auth/subscriptions/".Len())
if channelId.InStr("?") > 0
channelId = channelId.Left(channelId.InStr("?"))
end if
if StringUtils.IsNullOrEmpty(channelId)
response.Json({
"error": "Missing 'channelId' path parameter"
})
response.http_code = 400
return true
end if
options = {
"accessToken": accessToken.Mid("Bearer ".Len())
}
result = InnertubeService.SubscribeToChannel(channelId, options)
if result.success <> true
response.Json(result)
response.http_code = 500
return true
end if
response.Default(204, "OK")
return true
end function
@delete("*")
function DeleteAll(context as object) as boolean
request = context.request
route = request.route
if route.StartsWith("/playlet-invidious-backend/api/v1/auth/subscriptions/")
return m.UnsubscribeFromChannel(context)
end if
return false
end function
function UnsubscribeFromChannel(context as object) as boolean
request = context.request
response = context.response
route = request.route
accessToken = request.headers["authorization"]
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
response.Json({
"error": "Missing or invalid 'Authorization' header"
})
response.http_code = 403
return true
end if
channelId = route.Mid("/playlet-invidious-backend/api/v1/auth/subscriptions/".Len())
if channelId.InStr("?") > 0
channelId = channelId.Left(channelId.InStr("?"))
end if
if StringUtils.IsNullOrEmpty(channelId)
response.Json({
"error": "Missing 'channelId' path parameter"
})
response.http_code = 400
return true
end if
options = {
"accessToken": accessToken.Mid("Bearer ".Len())
}
result = InnertubeService.UnsubscribeFromChannel(channelId, options)
if result.success <> true
response.Json(result)
response.http_code = 500
return true
end if
response.Default(204, "OK")
return true
end function
@get("/playlet-invidious-backend/watch")
function RedirectWatch(context as object) as boolean
request = context.request
@@ -55,7 +55,12 @@ namespace Http
end if
if keysDict["device"] = true
state["device"] = m.applicationInfoNode@.GetDeviceInfo()
deviceInfo = m.applicationInfoNode@.GetDeviceInfo()
' We do not currently have translations for en_CA
if deviceInfo.current_locale = "en_CA"
deviceInfo.current_locale = "en_US"
end if
state["device"] = deviceInfo
end if
if keysDict["invidious"] = true
@@ -36,7 +36,10 @@ function GetServerAddress(_unused as dynamic) as dynamic
end function
function SetupRoutes(server as object)
server.UseRouter(new Http.CorsMiddleware())
#if DEBUG
'CORS is mostly for developing the web app
server.UseRouter(new Http.CorsMiddleware())
#end if
if server.settings.WebSocketsEnabled
server.UseRouter(new Http.WebSocketMiddleware())
end if
@@ -34,6 +34,15 @@ namespace Http
m.headers = CreateObject("roAssociativeArray")
end function
function FromParsedData(method as string, uri as string, headers as object, body as string)
m.method = method
m.uri = uri
m.ProcessOperation()
m.headers = headers
m.body = body
m.state = Http.HttpRequestState.DONE
end function
function Add(incoming as string, maybeUnicode as boolean)
if IsString(m.buffer)
m.buffer = m.buffer + incoming
@@ -20,7 +20,7 @@ namespace Http
m.routes = []
end function
private function OnRequest(request as object, response as HttpResponse, connection as HttpConnection) as boolean
function OnRequest(request as object, response as HttpResponse, connection as HttpConnection) as boolean
for each route in m.routes
if m.RouteMatchesRequest(route, request)
try
@@ -195,6 +195,22 @@ namespace Http
stats = stats + " Bytes" + Stri(m.total_in) + " in," + Stri(m.total_out) + " out"
return stats
end function
function ProcessRequestLocal(method as string, uri as string, headers as object, body as string) as object
LogInfo(`Processing request locally ${method} ${uri}`)
request = new HttpRequest()
request.FromParsedData(method, uri, headers, body)
response = new HttpResponse(request, m, m.settings)
response.Process({})
return {
http_code: response.http_code
headers: response.headers
body: response.body_buffer
}
end function
end class
end namespace
@@ -6,6 +6,14 @@
apiType: Invidious
endpoint: auth_feed
- title: Recommended
id: recommended
feedSources:
- id: inv_auth_recommended
title: Recommended
apiType: Invidious
endpoint: auth_recommended
- title: Trending
id: trending
feedSources:
@@ -166,8 +166,6 @@ channel_releases:
paginationType: Continuation
tryCount: 3
# This is implemented only by Playlet backend.
# https://github.com/iv-org/invidious/issues/5144
channel_courses:
title: Channel courses
url: /api/v1/channels/{ucid}/courses
@@ -189,3 +187,16 @@ watch_history:
authenticated: true
paginationType: Pages
responseHandler: WatchHistoryHandler
# Recommended is not a thing for Invidious, but we can use
# /api/v1/popular?recommended=true and handle it in Playlet
# backend. Invidious will just ignore the query param.
auth_recommended:
title: Recommended
url: /api/v1/popular
authenticated: true
paginationType: Continuation
queryParams:
recommended:
type: boolean
default: true
+4
View File
@@ -152,6 +152,10 @@
id: "subscriptions",
enabled: true,
},
{
id: "recommended",
enabled: true,
},
{
id: "trending",
enabled: true,
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>
<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>
</context>
</TS>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="en_CA" sourcelanguage="en_US">
<defaultcodec>UTF-8</defaultcodec>
<context>
<name>default</name>
</context>
</TS>
@@ -76,6 +76,10 @@
<source>Subscriptions</source>
<translation>Subscriptions</translation>
</message>
<message>
<source>Recommended</source>
<translation>Recommended</translation>
</message>
<message>
<source>Playlists</source>
<translation>Playlists</translation>
@@ -124,6 +128,10 @@
<source>Podcasts</source>
<translation>Podcasts</translation>
</message>
<message>
<source>Courses</source>
<translation>Courses</translation>
</message>
<message>
<source>Edit</source>
<translation>Edit</translation>
@@ -752,6 +760,10 @@
<source>Instance</source>
<translation>Instance</translation>
</message>
<message>
<source>Playlet built-in backend</source>
<translation>Playlet built-in backend</translation>
</message>
<message>
<source>Invidious instance to use. Example: https://example.com</source>
<translation>Invidious instance to use. Example: https://example.com</translation>
+73 -1
View File
@@ -266,7 +266,7 @@
</message>
<message>
<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>
<source>This year</source>
@@ -1208,5 +1208,77 @@
<source>The instance can fetch with CORS from %1</source>
<translation>La instancia puede obtener con CORS desde %1</translation>
</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>
</TS>
@@ -1268,5 +1268,17 @@
<source>Add to %1 bookmark</source>
<translation>Adicionar %1 ao marcadores</translation>
</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>
</TS>
+2 -2
View File
@@ -2,8 +2,8 @@ title=PlayletLib
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=36
build_version=00001
minor_version=37
build_version=00000
ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p
+43 -16
View File
@@ -5,7 +5,6 @@
' Only use this for debugging purposes.
#const NETWORK_THROTTLE = false
import "pkg:/source/utils/CancellationUtils.bs"
import "pkg:/source/utils/CancellationUtils.bs"
import "pkg:/source/utils/CryptoUtils.bs"
import "pkg:/source/utils/ErrorUtils.bs"
@@ -150,6 +149,10 @@ namespace HttpClient
return m
end function
function GetMethod() as string
return m._method
end function
function Url(url as string) as HttpRequest
m._url = url
return m
@@ -222,11 +225,22 @@ namespace HttpClient
return m
end function
function GetHeaders() as object
if m._headers = invalid
m._headers = {}
end if
return m._headers
end function
function Body(body as dynamic) as HttpRequest
m._body = ValidString(body)
return m
end function
function GetBody() as dynamic
return m._body
end function
function Json(body as object) as HttpRequest
m.Body(FormatJson(body))
m.Header("Content-Type", "application/json")
@@ -280,6 +294,11 @@ namespace HttpClient
return m
end function
function LogCurlCommand() as HttpRequest
m._logCurlCommand = true
return m
end function
function ToCurlCommand() as string
command = `curl "${m.BuildUrl()}"`
if m._method = "HEAD"
@@ -302,7 +321,15 @@ namespace HttpClient
if m._headers <> invalid
for each key in m._headers
command += ` \\\n -H '${key}: ${m._headers[key]}'`
#if DEBUG
command += ` \\\n -H '${key}: ${m._headers[key]}'`
#else
if LCase(key) = "authorization"
command += ` \\\n -H '${key}: <REDACTED>'`
else
command += ` \\\n -H '${key}: ${m._headers[key]}'`
end if
#end if
end for
end if
@@ -351,9 +378,13 @@ namespace HttpClient
LogInfo("Sending", m._method, m.urlTransfer.GetURL(), "ID:", m.urlTransfer.GetIdentity())
#if DEBUG
? `════════ curl command ════════\n${m.ToCurlCommand()}\n══════════════════════════════`
m._logCurlCommand = true
#end if
if m._logCurlCommand = true
LogInfo(`======== curl command ========\n${m.ToCurlCommand()}\n==============================`)
end if
if m._method = "POST"
body = m._body
if body = invalid
@@ -604,6 +635,10 @@ namespace HttpClient
m._json = json
end function
function OverrideHeaders(headers as object)
m._headers = headers
end function
function OverrideErrorMessage(errorMessage as string)
m._errorMessage = errorMessage
end function
@@ -653,18 +688,6 @@ namespace HttpClient
return invalid
end if
m._json = ParseJson(text)
' 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
' 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.
' 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
filter = /\\u[0-9a-fA-F]{4}/
text = filter.ReplaceAll(text, "")
m._json = ParseJson(text)
LogWarn("Failed to parse JSON. Workaround applied. Success:", m._json <> invalid)
end if
return m._json
end function
@@ -842,6 +865,11 @@ namespace HttpClientCache
return
end if
body = ValidString(response.Text())
if body = ""
return
end if
date = CreateObject("roDateTime")
timestamp = date.AsSeconds()
@@ -857,7 +885,6 @@ namespace HttpClientCache
' {body} ' the body as is, string size matching metadata.body
jsonHeaders = FormatJson(response.Headers())
body = ValidString(response.Text())
cacheMetadata = {
timestamp: timestamp
+8 -1
View File
@@ -14,8 +14,15 @@ namespace ErrorUtils
result = `${error.message} (0x${StrI(error.number, 16)}). backtrace:`
for i = error.backtrace.count() - 1 to 0 step -1
backtrace = error.backtrace[i]
result += `\n ${backtrace.function} @${backtrace.filename}:${backtrace.line_number}\n`
result += `\n ${backtrace.function} @${backtrace.filename}:${backtrace.line_number}`
end for
#if DEBUG
' make paths start with pkg:/ so that they can be source mapped
' to the original source files
result = result.replace("playletlib:/", "pkg:/")
#end if
return result
end if
Loaded 100 of 122 files, more files were not shown because too many files have changed in this diff. Show more