Compare commits

..
25 Commits
Author SHA1 Message Date
Brahim Hadriche 891a5f8405 Release v0.40.0 (#636) 2025-06-01 16:56:02 -04:00
Brahim Hadriche 7ab98024c1 [skip ci] tweak sponsorblock notification timing 2025-06-01 16:43:51 -04:00
Brahim Hadriche c2b6b75f94 navbar tweak 2025-06-01 16:01:57 -04:00
Weblate (bot)andEttore Atalan 2e09239123 Translated using Weblate (German) (#635)
Currently translated at 97.9% (331 of 338 strings)

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

Co-authored-by: Ettore Atalan <atalanttore@googlemail.com>
2025-06-01 15:38:08 -04:00
Brahim Hadricheandgithub-action linter fcae05a0da SponsorBlock categories (#634)
* SponsorBlock categories

* perf

* remove todo

* tweak

* UI is working

* Lint fix

* changelog

* Bug fix

* Restore timer

* Locale

* Comment

* tweaks

* web app

* remove unsued svelte ignore

* lint web app

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2025-06-01 15:30:58 -04:00
Brahim Hadriche 0bc5ab6117 [skip ci][perf] do not listen on tasks that have no callbacks 2025-06-01 08:04:09 -04:00
Brahim Hadriche cfd6bc8ec8 [skip ci] rename stat titles to match dashboard 2025-06-01 07:59:45 -04:00
Brahim Hadriche 47896ae9dc UI adjustment 2025-05-31 15:11:36 -04:00
Brahim Hadricheandgithub-action linter 9e3da6b67d Refactor for activeIdentityToken (#631)
* Refactor for activeIdentityToken

* Account selector stuff

* Small refactor

* Tweak

* That's a wrap

* comment

* Lint fix

* Localize

* Lint fix

* Close view on error

* parse error when gathering tracking urls

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2025-05-31 14:40:33 -04:00
Brahim Hadriche 4c94db2c03 [skip ci] support previous/next buttons in the browser to switch between tabs 2025-05-31 10:43:38 -04:00
Brahim Hadriche 8ff4847977 update dependencies (#625) 2025-05-31 10:22:24 -04:00
Brahim Hadriche 65a4a855a1 changelog 2025-05-30 16:44:21 -04:00
Weblate (bot)andLacey Anaya 40e7014e55 Translated using Weblate (German) (#632)
Currently translated at 100.0% (328 of 328 strings)

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

Co-authored-by: Lacey Anaya <yecakeh263@anawalls.com>
2025-05-30 16:43:58 -04:00
Brahim Hadriche d5f74d41c0 [skip ci][tech debt] Fix localization plugin and missing items (#633)
* Fix localization plugin and missing items

* changelog fix

* Testing validation for config files
2025-05-30 16:39:00 -04:00
Brahim Hadriche 91081e09d5 [skip ci] small optimization 2025-05-30 16:24:07 -04:00
Brahim Hadriche e7fbe5c189 [skip ci] small tweak 2025-05-30 12:39:41 -04:00
Brahim Hadriche 0151f4c81c [skip ci] log innertube alerts 2025-05-23 18:32:04 -04:00
Brahim Hadriche e28c92c3d4 Show videos watch progress in playlist view 2025-05-23 18:11:46 -04:00
Brahim Hadriche 4676b45567 Release v0.39.1 (#624) 2025-05-23 17:50:25 -04:00
Brahim Hadriche 438050fcca [skip ci] Fix regression with watch progress introduced in previous release 2025-05-23 17:47:40 -04:00
Brahim Hadriche 70e2608e59 Release v0.39.0 (#622) 2025-05-23 12:35:18 -04:00
Brahim Hadriche d2d875f124 Fix a couple of regressions 2025-05-23 12:29:53 -04:00
Brahim Hadriche 6a1069337d Ignore statementBannerRenderer 2025-05-23 10:58:10 -04:00
Brahim Hadriche eb67d9e4c0 Disable shorts (#620)
* Disable shorts

* Rename setting

* changelog
2025-05-22 22:13:44 -04:00
Brahim Hadriche 6d9117a2a0 [skip ci] Avoid loading old preferences every time if not needed 2025-05-22 18:36:10 -04:00
114 changed files with 2363 additions and 1107 deletions

No files matched your search

+33 -1
View File
@@ -5,6 +5,38 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.40.0] - 2025-06-01
### Added
- German translations
- Support for multi-accounts, such as brand accounts
- Support for manual skip in SponsorBlock
- Customize SponsorBlock categories from the settings
### Fixed
- Show videos watch progress in playlist view
- Missing localization in certain views
## [0.39.1] - 2025-05-23
### Fixed
- Regression with watch progress introduced in previous release
## [0.39.0] - 2025-05-23
### Added
- New settings category: `Content Feed`
- New setting: `Disable Shorts`
### Fixed
- A regression with thumbnails not showing from previous release
- Inability to login to Invidious when selected backend is Playlet (local)
## [0.38.2] - 2025-05-22 ## [0.38.2] - 2025-05-22
### Added ### Added
@@ -736,7 +768,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed ### Removed
- Xmas theme logo - can't publish it before end of year... ([link](https://blog.roku.com/developer/channel-store-blackouts-2023)) - Xmas theme logo - can't publish it before end of year... ([channel-store-blackouts-2023](https://blog.roku.com/developer/channel-store-blackouts-2023))
## [0.17.3] - 2023-12-13 ## [0.17.3] - 2023-12-13
+37 -28
View File
@@ -1,18 +1,18 @@
{ {
"name": "playlet", "name": "playlet",
"version": "0.38.2", "version": "0.40.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet", "name": "playlet",
"version": "0.38.2", "version": "0.40.0",
"hasInstallScript": true, "hasInstallScript": true,
"devDependencies": { "devDependencies": {
"@rokucommunity/bslint": "^0.8.31", "@rokucommunity/bslint": "^0.8.31",
"@types/crypto-js": "^4.2.2", "@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/node": "^22.15.18", "@types/node": "^22.15.29",
"@types/xml2js": "^0.4.14", "@types/xml2js": "^0.4.14",
"argparse": "^2.0.1", "argparse": "^2.0.1",
"brighterscript": "0.68.5", "brighterscript": "0.68.5",
@@ -26,7 +26,7 @@
"imap": "^0.8.19", "imap": "^0.8.19",
"ip": "^2.0.1", "ip": "^2.0.1",
"json5": "^2.2.3", "json5": "^2.2.3",
"mailparser": "^3.7.2", "mailparser": "^3.7.3",
"protocol-buffers-schema": "^3.6.0", "protocol-buffers-schema": "^3.6.0",
"roku-deploy": "^3.12.5", "roku-deploy": "^3.12.5",
"roku-test-automation": "^2.0.13", "roku-test-automation": "^2.0.13",
@@ -43,7 +43,7 @@
"node": "20" "node": "20"
}, },
"optionalDependencies": { "optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "^4.40.2" "@rollup/rollup-linux-x64-gnu": "^4.41.1"
} }
}, },
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
@@ -597,9 +597,9 @@
} }
}, },
"node_modules/@rollup/rollup-linux-x64-gnu": { "node_modules/@rollup/rollup-linux-x64-gnu": {
"version": "4.40.2", "version": "4.41.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.40.2.tgz", "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.41.1.tgz",
"integrity": "sha512-lG7Xa+BmBNwpjmVUbmyKxdQJ3Q6whHjMjzQplOs5Z+Gj7mxPtWakGHqzMqNER68G67kmCX9qX57aRsW5V0VOng==", "integrity": "sha512-cWBOvayNvA+SyeQMp79BHPK8ws6sHSsYnK5zDcsC3Hsxr1dgTABKjMnMslPq1DvZIp6uO7kIWhiGwaTdR4Og9A==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -760,9 +760,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.15.18", "version": "22.15.29",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.18.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.29.tgz",
"integrity": "sha512-v1DKRfUdyW+jJhZNEI1PYy29S2YRxMV5AOO/x/SjKmW0acCIOqmbj6Haf9eHAhsPmrhlHSxEhv/1WszcLWV4cg==", "integrity": "sha512-LNdjOkUDlU1RZb8e1kOIUpN1qQUlzGkEtbVNo53vbrwDg5om6oduhm4SiUaPW5ASTXhAiP0jInWG8Qx9fVlOeQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -2821,6 +2821,7 @@
"resolved": "https://registry.npmjs.org/encoding-japanese/-/encoding-japanese-2.2.0.tgz", "resolved": "https://registry.npmjs.org/encoding-japanese/-/encoding-japanese-2.2.0.tgz",
"integrity": "sha512-EuJWwlHPZ1LbADuKTClvHtwbaFn4rOD+dRAbWysqEOXRc2Uui0hJInNJrsdH0c+OhJA4nrCBdSkW4DD5YxAo6A==", "integrity": "sha512-EuJWwlHPZ1LbADuKTClvHtwbaFn4rOD+dRAbWysqEOXRc2Uui0hJInNJrsdH0c+OhJA4nrCBdSkW4DD5YxAo6A==",
"dev": true, "dev": true,
"license": "MIT",
"engines": { "engines": {
"node": ">=8.10.0" "node": ">=8.10.0"
} }
@@ -3918,6 +3919,7 @@
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0" "safer-buffer": ">= 2.1.2 < 3.0.0"
}, },
@@ -4315,13 +4317,15 @@
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/libbase64/-/libbase64-1.3.0.tgz", "resolved": "https://registry.npmjs.org/libbase64/-/libbase64-1.3.0.tgz",
"integrity": "sha512-GgOXd0Eo6phYgh0DJtjQ2tO8dc0IVINtZJeARPeiIJqge+HdsWSuaDTe8ztQ7j/cONByDZ3zeB325AHiv5O0dg==", "integrity": "sha512-GgOXd0Eo6phYgh0DJtjQ2tO8dc0IVINtZJeARPeiIJqge+HdsWSuaDTe8ztQ7j/cONByDZ3zeB325AHiv5O0dg==",
"dev": true "dev": true,
"license": "MIT"
}, },
"node_modules/libmime": { "node_modules/libmime": {
"version": "5.3.6", "version": "5.3.6",
"resolved": "https://registry.npmjs.org/libmime/-/libmime-5.3.6.tgz", "resolved": "https://registry.npmjs.org/libmime/-/libmime-5.3.6.tgz",
"integrity": "sha512-j9mBC7eiqi6fgBPAGvKCXJKJSIASanYF4EeA4iBzSG0HxQxmXnR3KbyWqTn4CwsKSebqCv2f5XZfAO6sKzgvwA==", "integrity": "sha512-j9mBC7eiqi6fgBPAGvKCXJKJSIASanYF4EeA4iBzSG0HxQxmXnR3KbyWqTn4CwsKSebqCv2f5XZfAO6sKzgvwA==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"encoding-japanese": "2.2.0", "encoding-japanese": "2.2.0",
"iconv-lite": "0.6.3", "iconv-lite": "0.6.3",
@@ -4333,7 +4337,8 @@
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/libqp/-/libqp-2.1.1.tgz", "resolved": "https://registry.npmjs.org/libqp/-/libqp-2.1.1.tgz",
"integrity": "sha512-0Wd+GPz1O134cP62YU2GTOPNA7Qgl09XwCqM5zpBv87ERCXdfDtyKXvV7c9U22yWJh44QZqBocFnXN11K96qow==", "integrity": "sha512-0Wd+GPz1O134cP62YU2GTOPNA7Qgl09XwCqM5zpBv87ERCXdfDtyKXvV7c9U22yWJh44QZqBocFnXN11K96qow==",
"dev": true "dev": true,
"license": "MIT"
}, },
"node_modules/lie": { "node_modules/lie": {
"version": "3.3.0", "version": "3.3.0",
@@ -4425,10 +4430,11 @@
} }
}, },
"node_modules/mailparser": { "node_modules/mailparser": {
"version": "3.7.2", "version": "3.7.3",
"resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.7.2.tgz", "resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.7.3.tgz",
"integrity": "sha512-iI0p2TCcIodR1qGiRoDBBwboSSff50vQAWytM5JRggLfABa4hHYCf3YVujtuzV454xrOP352VsAPIzviqMTo4Q==", "integrity": "sha512-0RM14cZF0gO1y2Q/82hhWranispZOUSYHwvQ21h12x90NwD6+D5q59S5nOLqCtCdYitHN58LJXWEHa4RWm7BYA==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"encoding-japanese": "2.2.0", "encoding-japanese": "2.2.0",
"he": "1.2.0", "he": "1.2.0",
@@ -4436,17 +4442,18 @@
"iconv-lite": "0.6.3", "iconv-lite": "0.6.3",
"libmime": "5.3.6", "libmime": "5.3.6",
"linkify-it": "5.0.0", "linkify-it": "5.0.0",
"mailsplit": "5.4.2", "mailsplit": "5.4.3",
"nodemailer": "6.9.16", "nodemailer": "7.0.3",
"punycode.js": "2.3.1", "punycode.js": "2.3.1",
"tlds": "1.255.0" "tlds": "1.259.0"
} }
}, },
"node_modules/mailsplit": { "node_modules/mailsplit": {
"version": "5.4.2", "version": "5.4.3",
"resolved": "https://registry.npmjs.org/mailsplit/-/mailsplit-5.4.2.tgz", "resolved": "https://registry.npmjs.org/mailsplit/-/mailsplit-5.4.3.tgz",
"integrity": "sha512-4cczG/3Iu3pyl8JgQ76dKkisurZTmxMrA4dj/e8d2jKYcFTZ7MxOzg1gTioTDMPuFXwTrVuN/gxhkrO7wLg7qA==", "integrity": "sha512-PFV0BBh4Tv7Omui5FtXXVtN4ExAxIi8Yvmb9JgBz+J6Hnnrv/YYXLlKKudLhXwd3/qWEATOslRsnzVCWDeCnmQ==",
"dev": true, "dev": true,
"license": "(MIT OR EUPL-1.1+)",
"dependencies": { "dependencies": {
"libbase64": "1.3.0", "libbase64": "1.3.0",
"libmime": "5.3.6", "libmime": "5.3.6",
@@ -4778,10 +4785,11 @@
} }
}, },
"node_modules/nodemailer": { "node_modules/nodemailer": {
"version": "6.9.16", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.16.tgz", "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.3.tgz",
"integrity": "sha512-psAuZdTIRN08HKVd/E8ObdV6NO7NTBY3KsC30F7M4H1OnmLCUNaS56FpYxyb26zWLSyYF9Ozch9KYHhHegsiOQ==", "integrity": "sha512-Ajq6Sz1x7cIK3pN6KesGTah+1gnwMnx5gKl3piQlQQE/PwyJ4Mbc8is2psWYxK3RJTVeqsDaCv8ZzXLCDHMTZw==",
"dev": true, "dev": true,
"license": "MIT-0",
"engines": { "engines": {
"node": ">=6.0.0" "node": ">=6.0.0"
} }
@@ -7324,10 +7332,11 @@
"dev": true "dev": true
}, },
"node_modules/tlds": { "node_modules/tlds": {
"version": "1.255.0", "version": "1.259.0",
"resolved": "https://registry.npmjs.org/tlds/-/tlds-1.255.0.tgz", "resolved": "https://registry.npmjs.org/tlds/-/tlds-1.259.0.tgz",
"integrity": "sha512-tcwMRIioTcF/FcxLev8MJWxCp+GUALRhFEqbDoZrnowmKSGqPrl5pqS+Sut2m8BgJ6S4FExCSSpGffZ0Tks6Aw==", "integrity": "sha512-AldGGlDP0PNgwppe2quAvuBl18UcjuNtOnDuUkqhd6ipPqrYYBt3aTxK1QTsBVknk97lS2JcafWMghjGWFtunw==",
"dev": true, "dev": true,
"license": "MIT",
"bin": { "bin": {
"tlds": "bin.js" "tlds": "bin.js"
} }
+6 -7
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet", "name": "playlet",
"version": "0.38.2", "version": "0.40.0",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"devDependencies": { "devDependencies": {
"@rokucommunity/bslint": "^0.8.31", "@rokucommunity/bslint": "^0.8.31",
"@types/crypto-js": "^4.2.2", "@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/node": "^22.15.18", "@types/node": "^22.15.29",
"@types/xml2js": "^0.4.14", "@types/xml2js": "^0.4.14",
"argparse": "^2.0.1", "argparse": "^2.0.1",
"brighterscript": "0.68.5", "brighterscript": "0.68.5",
@@ -20,7 +20,7 @@
"imap": "^0.8.19", "imap": "^0.8.19",
"ip": "^2.0.1", "ip": "^2.0.1",
"json5": "^2.2.3", "json5": "^2.2.3",
"mailparser": "^3.7.2", "mailparser": "^3.7.3",
"protocol-buffers-schema": "^3.6.0", "protocol-buffers-schema": "^3.6.0",
"roku-deploy": "^3.12.5", "roku-deploy": "^3.12.5",
"roku-test-automation": "^2.0.13", "roku-test-automation": "^2.0.13",
@@ -47,8 +47,8 @@
"build:lib:dev": "cd playlet-lib && npm run build:dev", "build:lib:dev": "cd playlet-lib && npm run build:dev",
"build:lib:prod": "cd playlet-lib && npm run build:prod", "build:lib:prod": "cd playlet-lib && npm run build:prod",
"build:web": "cd playlet-web && npm run build", "build:web": "cd playlet-web && npm run build",
"lint": "cd playlet-lib && npm run lint && cd ../playlet-app && npm run lint", "lint": "cd playlet-lib && npm run lint && cd ../playlet-app && npm run lint && cd ../playlet-web && npm run lint",
"lint:fix": "cd playlet-lib && npm run lint:fix && cd ../playlet-app && npm run lint:fix", "lint:fix": "cd playlet-lib && npm run lint:fix && cd ../playlet-app && npm run lint:fix && cd ../playlet-web && npm run lint",
"format": "cd playlet-lib && npm run format && cd ../playlet-app && npm run format", "format": "cd playlet-lib && npm run format && cd ../playlet-app && npm run format",
"format:fix": "cd playlet-lib && npm run format:fix && cd ../playlet-app && npm run format:fix", "format:fix": "cd playlet-lib && npm run format:fix && cd ../playlet-app && npm run format:fix",
"test": "npm run test:lib && npm run test:app", "test": "npm run test:lib && npm run test:app",
@@ -62,7 +62,6 @@
"manifest-git-hash": "node tools/update-manifest-git-hash.js", "manifest-git-hash": "node tools/update-manifest-git-hash.js",
"sign-released-package": "node tools/sign-released-package.js", "sign-released-package": "node tools/sign-released-package.js",
"screenshot": "node tools/screenshot.js", "screenshot": "node tools/screenshot.js",
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
"convert-images": "node tools/convert-images.js", "convert-images": "node tools/convert-images.js",
"update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip", "update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip",
"postinstall": "cd playlet-lib && npm install && cd ../playlet-app && npm install && cd ../playlet-web && npm install", "postinstall": "cd playlet-lib && npm install && cd ../playlet-app && npm install && cd ../playlet-web && npm install",
@@ -75,6 +74,6 @@
"shutdown": "node tools/shutdown.js" "shutdown": "node tools/shutdown.js"
}, },
"optionalDependencies": { "optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "^4.40.2" "@rollup/rollup-linux-x64-gnu": "^4.41.1"
} }
} }
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.38.2", "version": "0.40.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-app", "name": "playlet-app",
"version": "0.38.2" "version": "0.40.0"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.38.2", "version": "0.40.0",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"scripts": { "scripts": {
"prebuild": "rm -rf ../build/playlet-app", "prebuild": "rm -rf ../build/playlet-app",
+2 -2
View File
@@ -2,8 +2,8 @@ title=Playlet
# Do not update version manually, it is auto updated from package.json # Do not update version manually, it is auto updated from package.json
major_version=0 major_version=0
minor_version=38 minor_version=40
build_version=00002 build_version=00000
ui_resolutions=hd ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p uri_resolution_autosub=$$RES$$,480p,720p,1080p
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.38.2", "version": "0.40.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.38.2" "version": "0.40.0"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.38.2", "version": "0.40.0",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"scripts": { "scripts": {
"prebuild": "rm -rf ../build/playlet-lib", "prebuild": "rm -rf ../build/playlet-lib",
@@ -101,9 +101,16 @@ function CreateChannelFeeds(authorId as string, author as string, tabs as object
return invalid return invalid
end if end if
disableShorts = m.preferences["content_feed.disable_shorts"]
feeds = [] feeds = []
for i = 0 to tabs.count() - 1 for i = 0 to tabs.count() - 1
tabName = tabs[i] tabName = tabs[i]
if tabName = "shorts" and disableShorts
LogInfo(`Skipping "Shorts" tab based on user settings`)
continue for
end if
if m.tabs.DoesExist(tabName) if m.tabs.DoesExist(tabName)
if tabsParams <> invalid and tabsParams.DoesExist(tabName) if tabsParams <> invalid and tabsParams.DoesExist(tabName)
params = tabsParams[tabName] params = tabsParams[tabName]
@@ -5,6 +5,7 @@
<field id="isSubscribed" type="boolean" onChange="OnSubscriptionChanged" /> <field id="isSubscribed" type="boolean" onChange="OnSubscriptionChanged" />
<field id="appController" type="node" bind="/AppController" /> <field id="appController" type="node" bind="/AppController" />
<field id="invidious" type="node" bind="/Invidious" /> <field id="invidious" type="node" bind="/Invidious" />
<field id="preferences" type="node" bind="/Preferences" />
<field id="bookmarksService" type="node" bind="/BookmarksService" /> <field id="bookmarksService" type="node" bind="/BookmarksService" />
<function name="ShowSortDialog" /> <function name="ShowSortDialog" />
</interface> </interface>
@@ -17,6 +17,7 @@ function FetchSubscriptionStatusTask(input as object) as object
subscriptionStatus = InnertubeService.GetSubscriptionStatusForChannel(ucid, { subscriptionStatus = InnertubeService.GetSubscriptionStatusForChannel(ucid, {
cancellation: m.top.cancellation cancellation: m.top.cancellation
accessToken: authToken.token accessToken: authToken.token
onBehalfOfUser: authToken.activeIdentifyToken
}) })
if subscriptionStatus.error <> invalid if subscriptionStatus.error <> invalid
@@ -8,6 +8,7 @@
<field id="accessToken" type="string" /> <field id="accessToken" type="string" />
<!-- Innertube fields --> <!-- Innertube fields -->
<field id="activeIdentifyToken" type="string" />
<field id="thumbnail" type="uri" /> <field id="thumbnail" type="uri" />
<field id="refreshToken" type="string" /> <field id="refreshToken" type="string" />
<field id="scope" type="string" /> <field id="scope" type="string" />
@@ -22,7 +22,7 @@
showDivider="false"> showDivider="false">
<Label <Label
id="scanLabel" id="scanLabel"
text="Scan the QR Code" text="Scan the QR code"
horizAlign="center" horizAlign="center"
wrap="true" width="400"> wrap="true" width="400">
<Font role="font" uri="font:SystemFontFile" size="24" /> <Font role="font" uri="font:SystemFontFile" size="24" />
@@ -0,0 +1,27 @@
import "pkg:/source/utils/StringUtils.bs"
namespace YouTubeLoginAccountItemUtils
function CreateProfileContentNode(accountItem 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 = accountItem.channelHandle
if StringUtils.IsNullOrEmpty(username)
username = accountItem.accountByline
end if
profile.username = username
profile.activeIdentifyToken = accountItem.activeIdentifyToken
profile.thumbnail = accountItem.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
end namespace
@@ -1,6 +1,10 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Screens/ProfileScreen/YouTubeAccountSelectionView/YouTubeAccountSelectionViewUtils.bs"
import "pkg:/source/AsyncTask/AsyncTask.bs" import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs" import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -19,15 +23,56 @@ function Init()
m.top.observeFieldScoped("buttonSelected", FuncName(Close)) m.top.observeFieldScoped("buttonSelected", FuncName(Close))
m.top.observeFieldScoped("wasClosed", FuncName(OnWasClosed)) m.top.observeFieldScoped("wasClosed", FuncName(OnWasClosed))
scanLabel = m.top.findNode("scanLabel") scanLabel = m.top.findNode("scanLabel")
' TODO:P2 localize all dialog items
scanLabel.text = Tr(Locale.Dialogs.ScanTheQrCode) scanLabel.text = Tr(Locale.Dialogs.ScanTheQrCode)
linkInstructionLabel = m.top.findNode("linkInstructionLabel")
linkInstructionLabel.text = Tr(Locale.Dialogs.OpenLinkAndEnterFollowingCode).replace("%1", `'https://yt.be/activate'`)
end function end function
function OnNodeReady() function OnNodeReady()
m.task = AsyncTask.Start(Tasks.YouTubeLoginTask, { m.task = AsyncTask.Start(Tasks.YouTubeLoginTask, {
dialog: m.top dialog: m.top
profilesService: m.top.profilesService profilesService: m.top.profilesService
}) }, OnYouTubeLoginTaskResult)
end function
function OnYouTubeLoginTaskResult(output as object) as void
m.task = invalid
if output.cancelled
Close()
return
end if
if not output.success or not output.result.success
' output.error for unhandled exception
error = output.error
if error = invalid
' output.result.error for network errors
error = output.result.error
end if
error = ErrorUtils.Format(error)
LogError(error)
DialogUtils.ShowDialogEx({
message: error
title: Tr(Locale.Generic.Error)
large: true
})
return
end if
accounts = output.result.accounts
accessToken = output.result.accessToken
' if accounts is invalid, we're going to assume a profile is already created.
if accounts = invalid or accessToken = invalid
Close()
return
end if
' The accountSelectionView will take over the creation of the profile.
accountSelectionView = YouTubeAccountSelectionViewUtils.Open(m.top.appController)
accountSelectionView.accessToken = accessToken
accountSelectionView.accounts = accounts
Close()
end function end function
function OnCodeSet(event as object) function OnCodeSet(event as object)
@@ -1,6 +1,7 @@
<component name="YouTubeLoginDialog" extends="StandardDialog" initialFocus="buttonArea" includes="AutoBind"> <component name="YouTubeLoginDialog" extends="StandardDialog" initialFocus="buttonArea" includes="AutoBind">
<interface> <interface>
<field id="profilesService" type="node" bind="/ProfilesService" /> <field id="profilesService" type="node" bind="/ProfilesService" />
<field id="appController" type="node" bind="/AppController" />
<field id="code" type="string" alias="codeLabel.text" /> <field id="code" type="string" alias="codeLabel.text" />
<field id="url" type="string" onChange="OnUrlSet" /> <field id="url" type="string" onChange="OnUrlSet" />
<field id="alwaysOnTop" type="boolean" /> <field id="alwaysOnTop" type="boolean" />
@@ -10,7 +11,8 @@
<StdDlgTitleArea primaryTitle="Login to YouTube" /> <StdDlgTitleArea primaryTitle="Login to YouTube" />
<StdDlgContentArea> <StdDlgContentArea>
<StdDlgTextItem text="Open the link 'https://yt.be/activate' and enter the following code:" /> <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<StdDlgTextItem id="linkInstructionLabel" text="Open the link 'https://yt.be/activate' and enter the following code:" />
<StdDlgTextItem id="codeLabel" text="Loading..." /> <StdDlgTextItem id="codeLabel" text="Loading..." />
</StdDlgContentArea> </StdDlgContentArea>
<StdDlgButtonArea id="buttonArea"> <StdDlgButtonArea id="buttonArea">
@@ -24,7 +26,7 @@
showDivider="false"> showDivider="false">
<Label <Label
id="scanLabel" id="scanLabel"
text="Scan the QR Code" text="Scan the QR code"
horizAlign="center" horizAlign="center"
wrap="true" width="400"> wrap="true" width="400">
<Font role="font" uri="font:SystemFontFile" size="24" /> <Font role="font" uri="font:SystemFontFile" size="24" />
@@ -37,11 +39,11 @@
loadHeight="300" loadHeight="300"
padding="10" padding="10"
translation="[50, 50]" /> translation="[50, 50]" />
<Label <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<Label text="https://yt.be/activate"
horizAlign="center" horizAlign="center"
width="400" width="400"
translation="[0, 380]" translation="[0, 380]">
text="https://yt.be/activate">
<Font role="font" uri="font:MediumSystemFontFile" size="18" /> <Font role="font" uri="font:MediumSystemFontFile" size="18" />
</Label> </Label>
</StdDlgSideCardArea> </StdDlgSideCardArea>
@@ -1,4 +1,5 @@
import "pkg:/components/Dialog/DialogUtils.bs" import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Dialog/YouTubeLoginAccountItemUtils.bs"
import "pkg:/components/Services/Innertube/InnertubeService.bs" import "pkg:/components/Services/Innertube/InnertubeService.bs"
import "pkg:/source/utils/CancellationUtils.bs" import "pkg:/source/utils/CancellationUtils.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
@@ -17,13 +18,10 @@ function YouTubeLoginTask(input as object) as object
end if end if
if authCode.error <> invalid if authCode.error <> invalid
LogError(authCode.error) return {
DialogUtils.ShowDialogEx({ success: false
title: "Error" error: authCode.error
message: authCode.error }
large: true
})
return invalid
end if end if
url = InnertubeService.AuthGetActivationUrl(authCode) url = InnertubeService.AuthGetActivationUrl(authCode)
@@ -40,13 +38,10 @@ function YouTubeLoginTask(input as object) as object
end if end if
if accessToken.error <> invalid if accessToken.error <> invalid
LogError(accessToken.error) return {
DialogUtils.ShowDialogEx({ success: false
title: "Error" error: accessToken.error
message: accessToken.error }
large: true
})
return invalid
end if end if
accounts = InnertubeService.AuthListAccounts(accessToken.accessToken, cancellation) accounts = InnertubeService.AuthListAccounts(accessToken.accessToken, cancellation)
@@ -56,63 +51,33 @@ function YouTubeLoginTask(input as object) as object
end if end if
if IsAssociativeArray(accounts) and accounts.error <> invalid if IsAssociativeArray(accounts) and accounts.error <> invalid
LogError(accounts.error) return {
DialogUtils.ShowDialogEx({ success: false
title: "Error" error: accounts.error
message: accounts.error }
large: true
})
return invalid
end if end if
if not IsArray(accounts) or accounts.Count() = 0 if not IsArray(accounts) or accounts.Count() = 0
LogError("No accounts found") return {
DialogUtils.ShowDialogEx({ success: false
title: "Error" error: Tr(Locale.Dialogs.NoValidAccountsFound)
message: "No accounts found" }
large: true
})
return invalid
end if end if
selectedAccount = invalid ' If there is only one account, we can skip the selection screen
for each account in accounts ' and just create a profile
if ValidBool(account.isSelected) if accounts.Count() = 1
selectedAccount = account profile = YouTubeLoginAccountItemUtils.CreateProfileContentNode(accounts[0], accessToken)
exit for profilesNode@.LoginWithProfile(profile)
end if
end for
if selectedAccount = invalid return {
selectedAccount = accounts[0] success: true
}
end if end if
profile = CreateProfileContentNode(selectedAccount, accessToken) return {
profilesNode@.LoginWithProfile(profile) success: true
accounts: accounts
dialogNode.close = true accessToken: accessToken
}
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 end function
+1 -2
View File
@@ -42,8 +42,7 @@
<AppVersionLabel <AppVersionLabel
fontUri="font:BoldSystemFontFile" fontUri="font:BoldSystemFontFile"
fontSize="16" fontSize="16"
translation="[0, 48]" translation="[0, 48]" />
/>
</Poster> </Poster>
<MarkupList <MarkupList
@@ -1,3 +1,4 @@
import "pkg:/source/utils/MathUtils.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/TimeUtils.bs" import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -5,6 +6,7 @@ import "pkg:/source/utils/Types.bs"
function Init() function Init()
m.durationRect = m.top.FindNode("durationRect") m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel") m.durationLabel = m.top.FindNode("durationLabel")
m.progressRect = m.top.FindNode("progressRect")
end function end function
function OnContentSet() as void function OnContentSet() as void
@@ -35,6 +37,8 @@ function OnContentSet() as void
m.top.thumbnailUri = content.thumbnail m.top.thumbnailUri = content.thumbnail
m.top.percentDurationWatched = content.percentDurationWatched
SetDurationText(content.lengthText) SetDurationText(content.lengthText)
end function end function
@@ -60,3 +64,12 @@ function SetDurationText(text as string) as void
rect.width = size.width + 16 rect.width = size.width + 16
rect.translation = [rectParent.width - rect.width, rect.translation[1]] rect.translation = [rectParent.width - rect.width, rect.translation[1]]
end function end function
function OnPercentDurationWatched() as void
if m.progressRect = invalid
return
end if
percent = MathUtils.Clamp(m.top.percentDurationWatched, 0, 100) / 100.0
m.progressRect.scale = [percent, 1]
end function
@@ -6,6 +6,7 @@
<field id="thumbnailUri" type="uri" alias="thumbnailPoster.uri" /> <field id="thumbnailUri" type="uri" alias="thumbnailPoster.uri" />
<field id="duration" type="string" alias="durationLabel.text" /> <field id="duration" type="string" alias="durationLabel.text" />
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" /> <field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
<field id="percentDurationWatched" type="float" onChange="OnPercentDurationWatched" />
</interface> </interface>
<children> <children>
<Poster <Poster
@@ -29,6 +30,14 @@
font="font:SmallestSystemFont" font="font:SmallestSystemFont"
translation="[8, 0]" /> translation="[8, 0]" />
</Rectangle> </Rectangle>
<Rectangle
id="progressRect"
width="190"
height="5"
color="#FF0000"
translation="[0, 102]"
scale="[0, 1]">
</Rectangle>
</Poster> </Poster>
@@ -43,8 +43,7 @@
showRowLabel="[true]" showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus" rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true" variableWidthItems="true"
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" />
/>
</Group> </Group>
</children> </children>
</component> </component>
@@ -36,7 +36,9 @@
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png"> focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png">
<ContentNode role="content"> <ContentNode role="content">
<ContentNode> <ContentNode>
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<BackendTypeContentNode id="BackendTypeYouTube" title="YouTube" backendLogoUri="pkg:/images/youtube-logo.png" /> <BackendTypeContentNode id="BackendTypeYouTube" title="YouTube" backendLogoUri="pkg:/images/youtube-logo.png" />
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<BackendTypeContentNode id="BackendTypeInvidious" title="Invidious" backendLogoUri="pkg:/images/invidious-logo.png" /> <BackendTypeContentNode id="BackendTypeInvidious" title="Invidious" backendLogoUri="pkg:/images/invidious-logo.png" />
</ContentNode> </ContentNode>
</ContentNode> </ContentNode>
@@ -65,8 +65,7 @@
id="backendTypePoster" id="backendTypePoster"
width="60" width="60"
height="60" height="60"
translation="[110,110]" translation="[110,110]" />
/>
</CirclePoster> </CirclePoster>
<Poster <Poster
id="CrownPoster" id="CrownPoster"
@@ -81,13 +81,12 @@ function LoginWithInvidious() as void
end function end function
function ShowLoginWithYouTubeDialog() as void function ShowLoginWithYouTubeDialog() as void
' TODO:P2 localize
dialog = DialogUtils.ShowDialogEx({ dialog = DialogUtils.ShowDialogEx({
title: "Disclaimer" title: Tr(Locale.Dialogs.Disclaimer)
message: [ 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." Tr(Locale.Dialogs.YouTubeLoginDisclaimer1)
"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." Tr(Locale.Dialogs.YouTubeLoginDisclaimer2)
"Use responsibly, especially if your YouTube account is tied to business or monetization." Tr(Locale.Dialogs.YouTubeLoginDisclaimer3)
] ]
large: true large: true
buttons: [ buttons: [
@@ -52,8 +52,7 @@
id="backendTypePoster" id="backendTypePoster"
width="60" width="60"
height="60" height="60"
translation="[110,110]" translation="[110,110]" />
/>
</CirclePoster> </CirclePoster>
<Poster <Poster
id="CrownPoster" id="CrownPoster"
@@ -0,0 +1,17 @@
import "pkg:/source/utils/Types.bs"
function OnContentSet() as void
content = m.top.itemContent
if content = invalid
return
end if
accountItem = content.accountItem
if not IsAssociativeArray(accountItem)
return
end if
m.top.accountPhoto = accountItem.accountPhoto
m.top.text1 = accountItem.accountName
m.top.text2 = accountItem.channelHandle
end function
@@ -0,0 +1,31 @@
<component name="YouTubeAccountListItem" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="accountPhoto" type="uri" alias="accountPhoto.uri" />
<field id="text1" type="string" alias="text1Label.text" />
<field id="text2" type="string" alias="text2Label.text" />
</interface>
<children>
<LayoutGroup layoutDirection="horiz" translation="[0, 2]" itemSpacings="[10]">
<Poster
width="64"
height="64"
blendColor="#DDDDDDFF"
uri="pkg:/images/white-circle.png">
<CirclePoster
id="accountPhoto"
width="60"
height="60"
translation="[2,2]"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg" />
</Poster>
<LayoutGroup layoutDirection="vert" translation="[8, 0]" itemSpacings="[10]">
<Label id="text1Label" font="font:SmallestBoldSystemFont" />
<Label id="text2Label" font="font:SmallestSystemFont" />
</LayoutGroup>
</LayoutGroup>
</children>
</component>
@@ -0,0 +1,100 @@
import "pkg:/components/Dialog/YouTubeLoginAccountItemUtils.bs"
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.accountList = m.top.FindNode("accountList")
m.accountList.ObserveField("itemSelected", FuncName(OnAccountSelected))
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
NodeSetFocus(m.accountList, 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 OnAccountsChanged() as void
accounts = m.top.accounts
if not IsArray(accounts) or accounts.Count() = 0
m.accountList.content = invalid
LogError(Tr(Locale.Dialogs.NoValidAccountsFound))
Close()
return
end if
content = CreateObject("roSGNode", "ContentNode")
accountNodes = []
for each accountItem in accounts
if not IsAssociativeArray(accountItem)
continue for
end if
accountNode = CreateObject("roSGNode", "ContentNode")
accountNode.addField("accountItem", "assocarray", false)
accountNode.accountItem = accountItem
accountNodes.Push(accountNode)
end for
if accountNodes.Count() = 0
m.accountList.content = invalid
LogError(Tr(Locale.Dialogs.NoValidAccountsFound))
Close()
return
end if
content.appendChildren(accountNodes)
m.accountList.content = content
end function
function OnAccountSelected(event as object) as void
itemSelected = m.accountList.itemSelected
itemNode = m.accountList.content.GetChild(itemSelected)
if itemNode = invalid
LogError("Invalid item selected:", itemSelected)
Close()
return
end if
accountItem = itemNode.accountItem
if not IsAssociativeArray(accountItem)
LogError("Invalid account item selected:", accountItem)
Close()
return
end if
accessToken = m.top.accessToken
if accessToken = invalid or not IsAssociativeArray(accessToken)
LogError("No valid access token available for YouTube login.")
Close()
return
end if
profileNode = YouTubeLoginAccountItemUtils.CreateProfileContentNode(accountItem, accessToken)
m.top.profilesService@.LoginWithProfile(profileNode)
Close()
end function
@@ -0,0 +1,41 @@
<component name="YouTubeAccountSelectionView" extends="Group" includes="AutoBind,Focus">
<interface>
<field id="accessToken" type="assocarray" />
<field id="accounts" type="array" onChange="OnAccountsChanged" />
<field id="appController" type="node" bind="/AppController" />
<field id="profilesService" type="node" bind="/ProfilesService" />
</interface>
<children>
<Rectangle
width="1280"
height="720"
color="#000000"
opacity="0.5">
</Rectangle>
<Rectangle
width="720"
height="520"
translation="[280,100]"
color="#242424">
<Label
width="720"
horizAlign="center"
translation="[0,45]"
text="Who's watching?">
<Font role="font" uri="font:SystemFontFile" size="24" />
</Label>
<MarkupGrid
id="accountList"
itemComponentName="YouTubeAccountListItem"
itemSize="[640,70]"
itemSpacing="[0,20]"
numColumns="1"
numRows="4"
vertFocusAnimationStyle="floatingFocus"
translation="[40,120]"
focusBitmapUri="pkg:/images/focus-glow-padding-27.9.png" />
</Rectangle>
</children>
</component>
@@ -0,0 +1,11 @@
namespace YouTubeAccountSelectionViewUtils
function Open(appController as object) as object
youTubeAccountSelectionView = CreateObject("roSGNode", "YouTubeAccountSelectionView")
appController@.PushScreen(youTubeAccountSelectionView)
youTubeAccountSelectionView@.BindNode()
return youTubeAccountSelectionView
end function
end namespace
@@ -16,8 +16,7 @@
vertAlign="center" vertAlign="center"
text="Could not get IP address: are we connected to the internet?" text="Could not get IP address: are we connected to the internet?"
wrap="true" wrap="true"
translation="[145,0]" translation="[145,0]" />
/>
</Group> </Group>
<Group id="yesInternet" visible="false"> <Group id="yesInternet" visible="false">
<LayoutGroup <LayoutGroup
@@ -83,9 +82,9 @@
vertAlignment="center" vertAlignment="center"
translation="[0,245]"> translation="[0,245]">
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]"> <LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
<Label <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
font="font:SmallSystemFont" <Label text="1."
text="1." /> font="font:SmallSystemFont" />
<Label <Label
font="font:SmallSystemFont" font="font:SmallSystemFont"
width="380" width="380"
@@ -93,9 +92,9 @@
text="On your phone, connect to the same Wi-Fi network as this device." /> text="On your phone, connect to the same Wi-Fi network as this device." />
</LayoutGroup> </LayoutGroup>
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]"> <LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
<Label <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
font="font:SmallSystemFont" <Label text="2."
text="2." /> font="font:SmallSystemFont" />
<Label <Label
font="font:SmallSystemFont" font="font:SmallSystemFont"
width="380" width="380"
@@ -103,14 +102,14 @@
text="Open the YouTube app on your phone." /> text="Open the YouTube app on your phone." />
</LayoutGroup> </LayoutGroup>
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]"> <LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
<Label <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
font="font:SmallSystemFont" <Label text="3."
text="3." /> font="font:SmallSystemFont" />
<MultiStyleLabel <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<MultiStyleLabel text="Tap the cast icon and select this device."
id="WifiInstructionWithDeviceNameLabel" id="WifiInstructionWithDeviceNameLabel"
width="380" width="380"
wrap="true" wrap="true" />
text="Tap the cast icon and select this device." />
</LayoutGroup> </LayoutGroup>
<Label <Label
text="Roku connected to:" text="Roku connected to:"
@@ -131,9 +130,9 @@
vertAlignment="center" vertAlignment="center"
translation="[0,245]"> translation="[0,245]">
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]"> <LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
<Label <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
font="font:SmallSystemFont" <Label text="1."
text="1." /> font="font:SmallSystemFont" />
<Label <Label
font="font:SmallSystemFont" font="font:SmallSystemFont"
width="380" width="380"
@@ -141,9 +140,9 @@
text="On your phone, open the YouTube app." /> text="On your phone, open the YouTube app." />
</LayoutGroup> </LayoutGroup>
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]"> <LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
<Label <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
font="font:SmallSystemFont" <Label text="2."
text="2." /> font="font:SmallSystemFont" />
<Label <Label
font="font:SmallSystemFont" font="font:SmallSystemFont"
width="380" width="380"
@@ -151,9 +150,9 @@
text="Tap the cast icon." /> text="Tap the cast icon." />
</LayoutGroup> </LayoutGroup>
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]"> <LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
<Label <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
font="font:SmallSystemFont" <Label text="3."
text="3." /> font="font:SmallSystemFont" />
<Label <Label
font="font:SmallSystemFont" font="font:SmallSystemFont"
width="380" width="380"
@@ -18,16 +18,14 @@
<DynamicMiniKeyboard <DynamicMiniKeyboard
id="keyboard" id="keyboard"
translation="[695,110]" translation="[695,110]" />
/>
<ButtonGroup <ButtonGroup
id="suggestions" id="suggestions"
focusable="false" focusable="false"
minWidth="400" minWidth="400"
maxWidth="480" maxWidth="480"
buttonHeight="50" buttonHeight="50"
translation="[125,100]" translation="[125,100]" />
/>
<VideoRowList <VideoRowList
itemComponentName="RowCell" itemComponentName="RowCell"
id="rowList" id="rowList"
@@ -43,8 +41,7 @@
showRowLabel="[true]" showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus" rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true" variableWidthItems="true"
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" />
/>
<Animation <Animation
id="scrollAnimation" id="scrollAnimation"
duration="0.3"> duration="0.3">
@@ -24,8 +24,6 @@ end function
function PrepareTests() as object function PrepareTests() as object
content = CreateObject("roSGNode", "ContentNode") content = CreateObject("roSGNode", "ContentNode")
' TODO:P2 test if video data is reachable (head?)
' TODO:P2 test if video data is reachable in proxy mode (local=true)
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.ValidUrl), IsValidUrl)) content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.ValidUrl), IsValidUrl))
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.InstanceReachable), IsReachable)) content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.InstanceReachable), IsReachable))
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoDetails), CanFetchVideoDetails)) content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoDetails), CanFetchVideoDetails))
@@ -10,7 +10,7 @@
translation="[380,96]" /> translation="[380,96]" />
<Label <Label
id="failedLabel" id="failedLabel"
text="Failed to load Invidious public instances." text="Failed to load Invidious public instances"
horizAlign="center" horizAlign="center"
translation="[0,60]" translation="[0,60]"
width="960" /> width="960" />
@@ -16,29 +16,29 @@
<Font role="font" uri="font:SystemFontFile" size="18" /> <Font role="font" uri="font:SystemFontFile" size="18" />
</Label> </Label>
<LayoutGroup layoutDirection="horiz"> <LayoutGroup layoutDirection="horiz">
<Button <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<Button text="-"
id="MinusButton" id="MinusButton"
iconUri="" iconUri=""
focusedIconUri="" focusedIconUri=""
minWidth="64" minWidth="64"
maxWidth="64" maxWidth="64"
showFocusFootprint="true" showFocusFootprint="true" />
text="-" /> <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<Button <Button text="0"
id="NumberButton" id="NumberButton"
iconUri="" iconUri=""
focusedIconUri="" focusedIconUri=""
minWidth="150" minWidth="150"
showFocusFootprint="true" showFocusFootprint="true" />
text="0" /> <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<Button <Button text="+"
id="PlusButton" id="PlusButton"
iconUri="" iconUri=""
focusedIconUri="" focusedIconUri=""
minWidth="64" minWidth="64"
maxWidth="64" maxWidth="64"
showFocusFootprint="true" showFocusFootprint="true" />
text="+" />
</LayoutGroup> </LayoutGroup>
</children> </children>
</component> </component>
@@ -23,11 +23,17 @@
<ContentNode role="content"> <ContentNode role="content">
<ContentNode id="auto" title="Auto" /> <ContentNode id="auto" title="Auto" />
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<ContentNode id="1080p" title="1080p" /> <ContentNode id="1080p" title="1080p" />
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<ContentNode id="720p" title="720p" /> <ContentNode id="720p" title="720p" />
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<ContentNode id="480p" title="480p" /> <ContentNode id="480p" title="480p" />
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<ContentNode id="360p" title="360p" /> <ContentNode id="360p" title="360p" />
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<ContentNode id="240p" title="240p" /> <ContentNode id="240p" title="240p" />
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
<ContentNode id="144p" title="144p" /> <ContentNode id="144p" title="144p" />
</ContentNode> </ContentNode>
</CheckList> </CheckList>
@@ -0,0 +1,79 @@
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.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"
function Init()
m.top.focusable = true
m.top.itemSpacings = [8]
m.button = m.top.findNode("button")
m.button.observeField("buttonSelected", FuncName(OpenSponsorBlockCategories))
AdjustButtonLabel(m.button)
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
NodeSetFocus(m.button, true)
end function
function AdjustButtonLabel(button as object) as void
children = button.getChildren(-1, 0)
for each child in children
if child.isSubtype("Label") and child.hasField("horizAlign")
child.observeField("horizAlign", FuncName(OnButtonLabelHorizAlignChanged))
child.horizAlign = "left"
return
end if
end for
end function
function OnButtonLabelHorizAlignChanged(event as object)
label = event.getRoSGNode()
if label.horizAlign <> "left"
label.horizAlign = "left"
end if
end function
function BindPreference(preferences as object, key as string)
if m.preferences <> invalid and m.key <> invalid
m.preferences.unobserveFieldScoped(m.key)
end if
m.preferences = preferences
m.key = key
if preferences <> invalid and key <> invalid
preferences.observeFieldScoped(key, FuncName(OnPreferenceChange))
OnPreferenceChange()
end if
end function
function OpenSponsorBlockCategories()
categoriesPrefs = CreateObject("roSGNode", "SponsorBlockCategoriesPreferences")
m.appController@.PushScreen(categoriesPrefs)
categoriesPrefs@.BindNode()
categoriesPrefs.value = m.top.value
categoriesPrefs.observeField("save", FuncName(OnSaveCategoriesPreferences))
end function
function OnSaveCategoriesPreferences(event as object)
categoriesPrefs = event.GetRoSGNode()
m.top.value = categoriesPrefs.value
end function
function OnPreferenceChange()
m.top.value = m.preferences[m.key]
end function
function OnValueChange() as void
if m.preferences = invalid or m.key = invalid
return
end if
m.preferences[m.key] = m.top.value
end function
@@ -0,0 +1,21 @@
<component name="SponsorBlockCategoriesControl" extends="LayoutGroup" includes="AutoBind,Focus">
<interface>
<field id="displayText" type="string" alias="Button.text" />
<field id="description" type="string" alias="DescriptionLabel.text" />
<field id="value" type="assocarray" onChange="OnValueChange" />
<field id="appController" type="node" bind="/AppController" />
<function name="BindPreference" />
</interface>
<children>
<Button
id="button"
minWidth="300"
showFocusFootprint="true" />
<Label id="DescriptionLabel"
width="450"
color="0xb4b4b4ff"
wrap="true">
<Font role="font" uri="font:SystemFontFile" size="18" />
</Label>
</children>
</component>
@@ -0,0 +1,181 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs"
import "pkg:/components/VideoPlayer/SponsorBlockSegmentAction.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.categoryList = m.top.findNode("categoryList")
m.categoryList.ObserveField("itemSelected", FuncName(OnCategorySelected))
m.service = new SponsorBlock.SponsorBlockService()
optionTitles = {}
optionTitles[SponsorBlock.SegmentAction.Disable] = Tr(Locale.SponsorBlock.Disable)
optionTitles[SponsorBlock.SegmentAction.AutoSkip] = Tr(Locale.SponsorBlock.AutoSkip)
optionTitles[SponsorBlock.SegmentAction.ManualSkip] = Tr(Locale.SponsorBlock.ManualSkip)
optionTitles[SponsorBlock.SegmentAction.ShowInSeekbar] = Tr(Locale.SponsorBlock.ShowInSeekbar)
m.optionTitles = optionTitles
SetupCategoriesUi()
m.closeButton = m.top.findNode("closeButton")
m.saveButton = m.top.findNode("saveButton")
SetButtonPositions()
SetNavigation(m.saveButton, RemoteKeys.Right, m.closeButton)
SetNavigation(m.closeButton, RemoteKeys.Left, m.saveButton)
SetNavigation(m.saveButton, RemoteKeys.Up, m.categoryList)
SetNavigation(m.closeButton, RemoteKeys.Up, m.categoryList)
SetNavigation(m.categoryList, RemoteKeys.Down, m.saveButton)
m.saveButton.observeField("buttonSelected", FuncName(OnSaveButtonSelected))
m.closeButton.observeField("buttonSelected", FuncName(Close))
end function
function SetupCategoriesUi() as void
categories = m.service.GetCategories()
if categories.Count() = 0
return
end if
content = CreateObject("roSGNode", "ContentNode")
categoryContentNodes = []
for each category in categories
categoryNode = CreateObject("roSGNode", "SponsorBlockCategoryContent")
categoryNode.category = category
categoryNode.categoryTitle = Tr(m.service.SegmentTitle(category))
categoryNode.selectedOption = SponsorBlock.SegmentAction.Disable
categoryNode.options = m.service.GetOptionsForCategory(category)
categoryNode.optionTitles = m.optionTitles
categoryNode.color = m.service.SegmentColor(category)
categoryContentNodes.push(categoryNode)
end for
content.appendChildren(categoryContentNodes)
m.categoryList.content = content
end function
function SetButtonPositions()
saveButtonWidth = m.saveButton.width
closeButtonWidth = m.closeButton.width
buttonsWith = closeButtonWidth + saveButtonWidth + 20
m.saveButton.translation = [720 / 2 - buttonsWith / 2, m.saveButton.translation[1]]
m.closeButton.translation = [720 / 2 + buttonsWith / 2 - closeButtonWidth, m.closeButton.translation[1]]
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
NodeSetFocus(m.categoryList, true)
end function
function OnKeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled
return true
end if
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 OnValueChange() as void
content = m.categoryList.content
if content = invalid
return
end if
value = m.top.value
if not IsAssociativeArray(value)
return
end if
categoryContentNodes = content.getChildren(-1, 0)
categoryNodeMap = {}
for each categoryContentNode in categoryContentNodes
categoryNodeMap[categoryContentNode.category] = categoryContentNode
end for
for each category in value
if not categoryNodeMap.DoesExist(category)
continue for
end if
categoryNode = categoryNodeMap[category]
if categoryNode = invalid
continue for
end if
categoryNode.selectedOption = value[category].option
end for
end function
function OnSaveButtonSelected()
m.top.save = true
Close()
end function
function Close()
m.appController@.PopScreen()
end function
function OnCategorySelected(event as object) as void
itemSelected = m.categoryList.itemSelected
itemNode = m.categoryList.content.GetChild(itemSelected)
if itemNode = invalid
LogError("Invalid item selected:", itemSelected)
return
end if
options = itemNode.options
optionTitles = itemNode.optionTitles
optionTitlesArray = []
for each option in options
optionTitlesArray.push(optionTitles[option])
end for
dialog = DialogUtils.ShowDialogEx({
title: itemNode.categoryTitle
message: Tr(Locale.Settings.SelectOptionFor).Replace("%1", itemNode.categoryTitle)
buttons: optionTitlesArray
})
if dialog = invalid
return
end if
dialog.addFields({
"categoryContentNode": itemNode
"options": options
})
dialog.observeField("buttonSelected", FuncName(OnCategoryDialogResult), ["buttonSelected"])
end function
function OnCategoryDialogResult(event as object) as void
dialog = event.getRoSGNode()
options = dialog.options
buttonIndex = event.GetData()
if not IsInt(buttonIndex) or buttonIndex < 0 or buttonIndex >= options.Count()
return
end if
selectedOption = options[buttonIndex]
category = dialog.categoryContentNode.category
value = m.top.value
value[category].option = selectedOption
m.top.value = value
LogInfo("SponsorBlock category", category, "set to", selectedOption)
end function
@@ -0,0 +1,52 @@
<component name="SponsorBlockCategoriesPreferences" extends="Group" includes="AutoBind,Focus">
<interface>
<field id="value" type="assocarray" onChange="OnValueChange" />
<field id="save" type="boolean" alwaysNotify="true" />
<field id="appController" type="node" bind="/AppController" />
</interface>
<children>
<Rectangle
width="1280"
height="720"
color="#000000"
opacity="0.5">
</Rectangle>
<Rectangle
width="720"
height="600"
translation="[300,60]"
color="#242424">
<Label
width="720"
horizAlign="center"
translation="[0,38]"
text="Categories">
<Font role="font" uri="font:SystemFontFile" size="24" />
</Label>
<MarkupGrid
id="categoryList"
itemComponentName="SponsorBlockCategoryListItem"
itemSize="[640,32]"
itemSpacing="[0,10]"
numColumns="1"
numRows="10"
vertFocusAnimationStyle="floatingFocus"
translation="[40,100]"
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" />
<ButtonEx
id="saveButton"
iconVisible="false"
text="Save"
padding="[30,30]"
translation="[340,500]" />
<ButtonEx
id="closeButton"
iconVisible="false"
text="Close"
padding="[30,30]"
translation="[496,500]" />
</Rectangle>
</children>
</component>
@@ -0,0 +1,10 @@
<component name="SponsorBlockCategoryContent" extends="ContentNode">
<interface>
<field id="category" type="string" />
<field id="categoryTitle" type="string" />
<field id="selectedOption" type="string" />
<field id="options" type="stringarray" />
<field id="optionTitles" type="assocarray" />
<field id="color" type="color" />
</interface>
</component>
@@ -0,0 +1,11 @@
function OnContentSet() as void
content = m.top.itemContent
if content = invalid
return
end if
m.top.categoryTitle = content.categoryTitle
optionTitles = content.optionTitles
m.top.optionTitle = optionTitles[content.selectedOption]
m.top.color = content.color
end function
@@ -0,0 +1,30 @@
<component name="SponsorBlockCategoryListItem" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="categoryTitle" type="string" alias="categoryLabel.text" />
<field id="optionTitle" type="string" alias="optionLabel.text" />
<field id="color" type="color" alias="colorRect.color" />
</interface>
<children>
<Rectangle id="colorRect"
width="52"
height="28"
translation="[10, 2]" />
<Label id="categoryLabel"
font="font:SmallestSystemFont"
width="320"
height="32"
vertAlign="center"
horizAlign="left"
translation="[80, 0]" />
<Label id="optionLabel"
width="320"
height="32"
font="font:SmallestSystemFont"
vertAlign="center"
horizAlign="right"
translation="[310, 0]" />
</children>
</component>
@@ -1,14 +1,18 @@
import "pkg:/components/Services/Innertube/Context.bs" import "pkg:/components/Services/Innertube/Context.bs"
import "pkg:/source/services/HttpClient.bs" import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/OptionUtils.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
namespace Innertube namespace Innertube
function CreateBrowseRequest(browseId as string, clienType as Innertube.ClientType, params = "" as string, continuation = "" as string) as object function CreateBrowseRequest(browseId as string, clienType as Innertube.ClientType, options = invalid as object) as object
params = OptionUtils.GetOrDefault(options, "params", "")
continuation = OptionUtils.GetOrDefault(options, "continuation", "")
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"context": Innertube.CreateContext(clienType, deviceInfo, "", "") "context": Innertube.CreateContext(clienType, deviceInfo, options)
} }
if not StringUtils.IsNullOrEmpty(continuation) if not StringUtils.IsNullOrEmpty(continuation)
@@ -21,12 +25,7 @@ namespace Innertube
end if end if
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/browse?prettyPrint=false&alt=json", payload) request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/browse?prettyPrint=false&alt=json", payload)
headers = { request.Headers(Innertube.CreateHeaders(clienType))
"accept": "*/*"
"accept-language": "*"
}
headers.Append(Innertube.CreateHeaders(clienType))
request.Headers(headers)
return request return request
end function end function
@@ -1,4 +1,5 @@
import "pkg:/components/Services/Innertube/Constants.bs" import "pkg:/components/Services/Innertube/Constants.bs"
import "pkg:/source/utils/OptionUtils.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
namespace Innertube namespace Innertube
@@ -12,18 +13,24 @@ namespace Innertube
function CreateHeaders(clienType as Innertube.ClientType) as object function CreateHeaders(clienType as Innertube.ClientType) as object
if clienType = ClientType.Web if clienType = ClientType.Web
return { return {
"accept": "*/*"
"accept-language": "*"
"user-agent": INNERTUBE_WEB_USER_AGENT "user-agent": INNERTUBE_WEB_USER_AGENT
"x-youtube-client-name": INNERTUBE_WEB_CLIENT_NAME "x-youtube-client-name": INNERTUBE_WEB_CLIENT_NAME
"x-youtube-client-version": INNERTUBE_WEB_CLIENT_VERSION "x-youtube-client-version": INNERTUBE_WEB_CLIENT_VERSION
} }
else if clienType = ClientType.IOS else if clienType = ClientType.IOS
return { return {
"accept": "*/*"
"accept-language": "*"
"user-agent": INNERTUBE_IOS_USER_AGENT "user-agent": INNERTUBE_IOS_USER_AGENT
"x-youtube-client-name": INNERTUBE_IOS_CLIENT_NAME "x-youtube-client-name": INNERTUBE_IOS_CLIENT_NAME
"x-youtube-client-version": INNERTUBE_IOS_CLIENT_VERSION "x-youtube-client-version": INNERTUBE_IOS_CLIENT_VERSION
} }
else if clienType = ClientType.Tv else if clienType = ClientType.Tv
return { return {
"accept": "*/*"
"accept-language": "*"
"user-agent": INNERTUBE_TV_USER_AGENT "user-agent": INNERTUBE_TV_USER_AGENT
"x-youtube-client-name": INNERTUBE_TV_CLIENT_NAME "x-youtube-client-name": INNERTUBE_TV_CLIENT_NAME
"x-youtube-client-version": INNERTUBE_TV_CLIENT_VERSION "x-youtube-client-version": INNERTUBE_TV_CLIENT_VERSION
@@ -33,7 +40,7 @@ namespace Innertube
end if end if
end function end function
function CreateContext(clienType as Innertube.ClientType, deviceInfo as object, ctt as string, visitorData as string) as object function CreateContext(clienType as Innertube.ClientType, deviceInfo as object, options = invalid as object) as object
client = invalid client = invalid
if clienType = ClientType.Web if clienType = ClientType.Web
client = CreateContextClientWeb(deviceInfo) client = CreateContextClientWeb(deviceInfo)
@@ -45,6 +52,10 @@ namespace Innertube
throw "Invalid client type" throw "Invalid client type"
end if end if
credentialTransferToken = OptionUtils.Get(options, "credentialTransferToken")
visitorData = OptionUtils.Get(options, "visitorData")
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
context = { context = {
"client": client "client": client
"user": { "user": {
@@ -57,9 +68,9 @@ namespace Innertube
} }
} }
if not StringUtils.IsNullOrEmpty(ctt) if not StringUtils.IsNullOrEmpty(credentialTransferToken)
context["user"]["credentialTransferTokens"] = [{ context["user"]["credentialTransferTokens"] = [{
"token": ctt "token": credentialTransferToken
"scope": "VIDEO" "scope": "VIDEO"
}] }]
end if end if
@@ -68,6 +79,10 @@ namespace Innertube
context["client"]["visitorData"] = visitorData context["client"]["visitorData"] = visitorData
end if end if
if not StringUtils.IsNullOrEmpty(onBehalfOfUser)
context["user"]["onBehalfOfUser"] = onBehalfOfUser
end if
return context return context
end function end function
@@ -11,36 +11,17 @@ import "pkg:/components/Services/Innertube/SubscriptionEndpoint.bs"
import "pkg:/source/services/HttpClient.bs" import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/CancellationUtils.bs" import "pkg:/source/utils/CancellationUtils.bs"
import "pkg:/source/utils/ObjectUtils.bs" import "pkg:/source/utils/ObjectUtils.bs"
import "pkg:/source/utils/OptionUtils.bs"
import "pkg:/source/utils/TimeUtils.bs" import "pkg:/source/utils/TimeUtils.bs"
namespace InnertubeService namespace InnertubeService
function GetVideoMetadata(videoId as string, options = invalid as object) as object function GetVideoMetadata(videoId as string, options = invalid as object) as object
cancellation = invalid cancellation = OptionUtils.Get(options, "cancellation")
fetchNext = true fetchNext = OptionUtils.GetOrDefault(options, "fetchNext", true)
ctt = "" raw = OptionUtils.GetOrDefault(options, "raw", false)
visitorData = ""
raw = false
if options <> invalid playerRequest = Innertube.CreatePlayerRequest(videoId, Innertube.ClientType.IOS, options)
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
if options.DoesExist("fetchNext")
fetchNext = options.fetchNext
end if
if options.DoesExist("ctt")
ctt = options.ctt
end if
if options.DoesExist("raw")
raw = options.raw
end if
if options.DoesExist("visitorData")
visitorData = options.visitorData
end if
end if
playerRequest = Innertube.CreatePlayerRequest(videoId, ctt, visitorData, Innertube.ClientType.IOS)
playerRequest.Cancellation(cancellation) playerRequest.Cancellation(cancellation)
if raw if raw
playerRequest.LogCurlCommand() playerRequest.LogCurlCommand()
@@ -51,7 +32,7 @@ namespace InnertubeService
nextRequest = invalid nextRequest = invalid
nextResponse = invalid nextResponse = invalid
if fetchNext if fetchNext
nextRequest = Innertube.CreateNextRequest({ "videoId": videoId }, ctt) nextRequest = Innertube.CreateNextRequest({ "videoId": videoId }, options)
nextRequest.Cancellation(cancellation) nextRequest.Cancellation(cancellation)
if raw if raw
nextRequest.LogCurlCommand() nextRequest.LogCurlCommand()
@@ -111,20 +92,11 @@ namespace InnertubeService
} }
end if end if
cancellation = invalid cancellation = OptionUtils.Get(options, "cancellation")
retry = true retry = OptionUtils.GetOrDefault(options, "retry", true)
if options <> invalid
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
if options.DoesExist("retry")
retry = options.retry
end if
end if
params = Innertube.GetEncodedNextParams(videoIds) params = Innertube.GetEncodedNextParams(videoIds)
request = Innertube.CreateNextRequest({ "params": params }, "") request = Innertube.CreateNextRequest({ "params": params })
request.Cancellation(cancellation) request.Cancellation(cancellation)
response = request.Await() response = request.Await()
@@ -182,58 +154,28 @@ namespace InnertubeService
end function end function
function Search(query as string, options = invalid as object) as object function Search(query as string, options = invalid as object) as object
searchFilters = invalid return Innertube.Search(query, options)
continuation = ""
cancellation = invalid
raw = false
if options <> invalid
if options.DoesExist("searchFilters")
searchFilters = options.searchFilters
end if
if options.DoesExist("continuation")
continuation = options.continuation
end if
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
if options.DoesExist("raw")
raw = options.raw
end if
end if
return Innertube.Search(query, searchFilters, continuation, cancellation, raw)
end function end function
function GetTrending(options = invalid as object) as object function GetTrending(options = invalid as object) as object
cancellation = invalid cancellation = OptionUtils.Get(options, "cancellation")
trendingType = LCase(OptionUtils.GetOrDefault(options, "type", ""))
disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
raw = OptionUtils.GetOrDefault(options, "raw", false)
params = "" params = ""
raw = false if trendingType = "music"
' {"44:proto": {"3:string": "ytma_charts"}}
if options <> invalid params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
if options.DoesExist("cancellation") else if trendingType = "gaming"
cancellation = options.cancellation ' {"44:proto": {"3:string": "gaming_corpus_most_popular"}}
end if params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
if options.DoesExist("type") else if trendingType = "movies"
trendingType = LCase(ValidString(options.type)) ' {"44:proto": {"3:string": "trailers"}}
params = "4gIKGgh0cmFpbGVycw%3D%3D"
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
if options.DoesExist("raw")
raw = options.raw
end if
end if end if
request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, params) request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, { params: params })
request.Cancellation(cancellation) request.Cancellation(cancellation)
if raw if raw
@@ -252,7 +194,10 @@ namespace InnertubeService
return response.Json() return response.Json()
end if end if
feeds = Innertube.ParseResponseDataForFeeds(response.Json(), { skipCreatorOnTheRise: true }) feeds = Innertube.ParseResponseDataForFeeds(response.Json(), {
disableCreatorOnTheRise: true
disableShorts: disableShorts
})
result = { result = {
feeds: feeds feeds: feeds
@@ -283,23 +228,12 @@ namespace InnertubeService
end function end function
function GetBrowseAuthenticatedPage(browserId as string, options = invalid as object) as object function GetBrowseAuthenticatedPage(browserId as string, options = invalid as object) as object
cancellation = invalid cancellation = OptionUtils.Get(options, "cancellation")
accessToken = invalid accessToken = OptionUtils.Get(options, "accessToken")
continuation = "" disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
if options <> invalid request = Innertube.CreateBrowseRequest(browserId, Innertube.ClientType.Tv, options)
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
if options.DoesExist("accessToken")
accessToken = options.accessToken
end if
if options.DoesExist("continuation")
continuation = options.continuation
end if
end if
request = Innertube.CreateBrowseRequest(browserId, Innertube.ClientType.Tv, "", continuation)
if accessToken <> invalid if accessToken <> invalid
request.Header("Authorization", "Bearer " + accessToken) request.Header("Authorization", "Bearer " + accessToken)
end if end if
@@ -312,7 +246,7 @@ namespace InnertubeService
} }
end if end if
feeds = Innertube.ParseResponseDataForFeeds(response.Json()) feeds = Innertube.ParseResponseDataForFeeds(response.Json(), { disableShorts: disableShorts })
result = { result = {
feeds: feeds feeds: feeds
@@ -334,7 +268,7 @@ namespace InnertubeService
cancellation = options.cancellation cancellation = options.cancellation
end if end if
playerRequest = Innertube.CreatePlayerRequest(videoId, "", "", Innertube.ClientType.Tv) playerRequest = Innertube.CreatePlayerRequest(videoId, Innertube.ClientType.Tv, options)
playerRequest.Cancellation(cancellation) playerRequest.Cancellation(cancellation)
playerRequest.Header("Authorization", "Bearer " + accessToken) playerRequest.Header("Authorization", "Bearer " + accessToken)
@@ -347,6 +281,13 @@ namespace InnertubeService
json = playerResponse.Json() json = playerResponse.Json()
error = Innertube.ParsePlayerResponseForError(json)
if error <> ""
return {
error: error
}
end if
videostatsPlaybackUrl = ObjectUtils.Dig(json, ["playbackTracking", "videostatsPlaybackUrl", "baseUrl"]) videostatsPlaybackUrl = ObjectUtils.Dig(json, ["playbackTracking", "videostatsPlaybackUrl", "baseUrl"])
videostatsWatchtimeUrl = ObjectUtils.Dig(json, ["playbackTracking", "videostatsWatchtimeUrl", "baseUrl"]) videostatsWatchtimeUrl = ObjectUtils.Dig(json, ["playbackTracking", "videostatsWatchtimeUrl", "baseUrl"])
@@ -357,12 +298,9 @@ namespace InnertubeService
end function end function
function AuthMarkVideoWatched(videostatsPlaybackUrl as string, options as object) as boolean function AuthMarkVideoWatched(videostatsPlaybackUrl as string, options as object) as boolean
cancellation = invalid cancellation = OptionUtils.Get(options, "cancellation")
accessToken = options.accessToken accessToken = OptionUtils.Get(options, "accessToken")
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
videostatsPlaybackUrl = videostatsPlaybackUrl.replace("https://s.", "https://www.") videostatsPlaybackUrl = videostatsPlaybackUrl.replace("https://s.", "https://www.")
queryParams = UrlUtils.ParseQueryComponents(videostatsPlaybackUrl) queryParams = UrlUtils.ParseQueryComponents(videostatsPlaybackUrl)
@@ -380,6 +318,9 @@ namespace InnertubeService
request.NoCache() request.NoCache()
request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Tv)) request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Tv))
request.Header("Authorization", "Bearer " + accessToken) request.Header("Authorization", "Bearer " + accessToken)
if not StringUtils.IsNullOrEmpty(onBehalfOfUser)
request.Header("X-Goog-Pageid", onBehalfOfUser)
end if
response = request.Await() response = request.Await()
if not response.IsSuccess() if not response.IsSuccess()
@@ -392,14 +333,9 @@ namespace InnertubeService
end function end function
function AuthMarkVideoWatchTime(time as float, videostatsWatchtimeUrl as string, options = invalid as object) as boolean function AuthMarkVideoWatchTime(time as float, videostatsWatchtimeUrl as string, options = invalid as object) as boolean
cancellation = invalid cancellation = OptionUtils.Get(options, "cancellation")
accessToken = options.accessToken accessToken = OptionUtils.Get(options, "accessToken")
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
if options <> invalid
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
end if
timeStr = time.ToStr("%.3f") timeStr = time.ToStr("%.3f")
@@ -421,6 +357,9 @@ namespace InnertubeService
request.NoCache() request.NoCache()
request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Tv)) request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Tv))
request.Header("Authorization", "Bearer " + accessToken) request.Header("Authorization", "Bearer " + accessToken)
if not StringUtils.IsNullOrEmpty(onBehalfOfUser)
request.Header("X-Goog-Pageid", onBehalfOfUser)
end if
response = request.Await() response = request.Await()
if not response.IsSuccess() if not response.IsSuccess()
@@ -446,27 +385,10 @@ namespace InnertubeService
end function end function
function GetChannel(channelId as string, options = invalid as object) as object function GetChannel(channelId as string, options = invalid as object) as object
continuation = "" cancellation = OptionUtils.Get(options, "cancellation")
params = "" raw = OptionUtils.GetOrDefault(options, "raw", false)
cancellation = invalid
raw = false
if options <> invalid request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Web, options)
if options.DoesExist("continuation")
continuation = options.continuation
end if
if options.DoesExist("params")
params = options.params
end if
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
if options.DoesExist("raw")
raw = options.raw
end if
end if
request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Web, params, continuation)
request.Cancellation(cancellation) request.Cancellation(cancellation)
if raw if raw
request.LogCurlCommand() request.LogCurlCommand()
@@ -498,16 +420,10 @@ namespace InnertubeService
end function end function
function GetSubscriptionStatusForChannel(channelId as string, options = invalid as object) as object function GetSubscriptionStatusForChannel(channelId as string, options = invalid as object) as object
cancellation = invalid cancellation = OptionUtils.Get(options, "cancellation")
accessToken = options.accessToken accessToken = OptionUtils.Get(options, "accessToken")
if options <> invalid request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Tv, options)
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
end if
request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Tv, "", "")
request.Cancellation(cancellation) request.Cancellation(cancellation)
if accessToken <> invalid if accessToken <> invalid
request.Header("Authorization", "Bearer " + accessToken) request.Header("Authorization", "Bearer " + accessToken)
@@ -564,16 +480,10 @@ namespace InnertubeService
end function end function
function SubscribeToChannel(channelId as string, options = invalid as object) as object function SubscribeToChannel(channelId as string, options = invalid as object) as object
cancellation = invalid cancellation = OptionUtils.Get(options, "cancellation")
accessToken = options.accessToken accessToken = OptionUtils.Get(options, "accessToken")
if options <> invalid request = Innertube.CreateSubscribeRequest(channelId, options)
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
end if
request = Innertube.CreateSubscribeRequest(channelId, "")
request.Cancellation(cancellation) request.Cancellation(cancellation)
if accessToken <> invalid if accessToken <> invalid
request.Header("Authorization", "Bearer " + accessToken) request.Header("Authorization", "Bearer " + accessToken)
@@ -587,16 +497,10 @@ namespace InnertubeService
end function end function
function UnsubscribeFromChannel(channelId as string, options = invalid as object) as object function UnsubscribeFromChannel(channelId as string, options = invalid as object) as object
cancellation = invalid cancellation = OptionUtils.Get(options, "cancellation")
accessToken = options.accessToken accessToken = OptionUtils.Get(options, "accessToken")
if options <> invalid request = Innertube.CreateUnsubscribeRequest(channelId, options)
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
end if
request = Innertube.CreateUnsubscribeRequest(channelId, "")
request.Cancellation(cancellation) request.Cancellation(cancellation)
if accessToken <> invalid if accessToken <> invalid
request.Header("Authorization", "Bearer " + accessToken) request.Header("Authorization", "Bearer " + accessToken)
@@ -610,25 +514,9 @@ namespace InnertubeService
end function end function
function GetPlaylist(playlistId as string, options = invalid as object) as object function GetPlaylist(playlistId as string, options = invalid as object) as object
continuation = "" cancellation = OptionUtils.Get(options, "cancellation")
cancellation = invalid raw = OptionUtils.GetOrDefault(options, "raw", false)
raw = false accessToken = OptionUtils.Get(options, "accessToken")
accessToken = invalid
if options <> invalid
if options.DoesExist("continuation")
continuation = options.continuation
end if
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
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") if not playlistId.StartsWith("VL")
playlistId = "VL" + playlistId playlistId = "VL" + playlistId
@@ -639,7 +527,7 @@ namespace InnertubeService
client = Innertube.ClientType.Tv client = Innertube.ClientType.Tv
end if end if
request = Innertube.CreateBrowseRequest(playlistId, client, "", continuation) request = Innertube.CreateBrowseRequest(playlistId, client, options)
request.Cancellation(cancellation) request.Cancellation(cancellation)
if accessToken <> invalid if accessToken <> invalid
request.Header("Authorization", "Bearer " + accessToken) request.Header("Authorization", "Bearer " + accessToken)
@@ -675,27 +563,15 @@ namespace InnertubeService
end function end function
function GetMix(mixId as string, options = invalid as object) as object function GetMix(mixId as string, options = invalid as object) as object
videoId = "" videoId = OptionUtils.Get(options, "videoId")
cancellation = invalid cancellation = OptionUtils.Get(options, "cancellation")
raw = false raw = OptionUtils.GetOrDefault(options, "raw", false)
if options <> invalid
if options.DoesExist("videoId")
videoId = options.videoId
end if
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
if options.DoesExist("raw")
raw = options.raw
end if
end if
args = { "playlistId": mixId } args = { "playlistId": mixId }
if videoId <> "" if not StringUtils.IsNullOrEmpty(videoId)
args["videoId"] = videoId args["videoId"] = videoId
end if end if
request = Innertube.CreateNextRequest(args, "") request = Innertube.CreateNextRequest(args)
request.Cancellation(cancellation) request.Cancellation(cancellation)
if raw if raw
request.LogCurlCommand() request.LogCurlCommand()
@@ -724,13 +600,7 @@ namespace InnertubeService
end function end function
function ResolveUrl(url as string, options = invalid as object) as object function ResolveUrl(url as string, options = invalid as object) as object
cancellation = invalid cancellation = OptionUtils.Get(options, "cancellation")
if options <> invalid
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
end if
request = Innertube.CreateResolveUrlRequest(url) request = Innertube.CreateResolveUrlRequest(url)
request.Cancellation(cancellation) request.Cancellation(cancellation)
@@ -8,21 +8,18 @@ import "pkg:/source/utils/Types.bs"
namespace Innertube namespace Innertube
function CreateNextRequest(payloadArgs as object, ctt as string) as object function CreateNextRequest(payloadArgs as object, options = invalid as object) as object
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
context = Innertube.CreateContext(Innertube.ClientType.Web, deviceInfo, options)
payload = { payload = {
"context": Innertube.CreateContext(Innertube.ClientType.Web, deviceInfo, ctt, "") "context": context
} }
payload.Append(payloadArgs) payload.Append(payloadArgs)
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/next?prettyPrint=false&alt=json", payload) request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/next?prettyPrint=false&alt=json", payload)
headers = { request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Web))
"accept": "*/*"
"accept-language": "*"
}
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.Web))
request.Headers(headers)
return request return request
end function end function
@@ -112,6 +112,7 @@ namespace Innertube
"searchBarRenderer": ParseNotImplemented "searchBarRenderer": ParseNotImplemented
"clickTrackingParams": ParseNotImplemented "clickTrackingParams": ParseNotImplemented
"promoShelfRenderer": ParseNotImplemented "promoShelfRenderer": ParseNotImplemented
"statementBannerRenderer": ParseNotImplemented
"adSlotRenderer": ParseNotImplemented "adSlotRenderer": ParseNotImplemented
"adsControlFlowOpportunityReceivedCommand": ParseNotImplemented "adsControlFlowOpportunityReceivedCommand": ParseNotImplemented
} }
@@ -156,13 +157,13 @@ namespace Innertube
end function end function
function ParseShelfRenderer(nodeData as object, context as object) as object function ParseShelfRenderer(nodeData as object, context as object) as object
if context.skipCreatorOnTheRise = true if context.disableCreatorOnTheRise = true
badges = nodeData["badges"] badges = nodeData["badges"]
if IsArray(badges) if IsArray(badges)
for each badge in badges for each badge in badges
if ValidString(ObjectUtils.Dig(badge, ["metadataBadgeRenderer", "style"])) = "BADGE_STYLE_TYPE_FEATURED" if ValidString(ObjectUtils.Dig(badge, ["metadataBadgeRenderer", "style"])) = "BADGE_STYLE_TYPE_FEATURED"
label = ParseText(ObjectUtils.Dig(badge, ["metadataBadgeRenderer", "label"])) label = ParseText(ObjectUtils.Dig(badge, ["metadataBadgeRenderer", "label"]))
LogInfo(`Skipping 'Create on the Rise' shelf (${label})`) LogInfo(`Skipping 'Creator on the Rise' shelf (${label})`)
return invalid return invalid
end if end if
end for end for
@@ -179,7 +180,11 @@ namespace Innertube
return nodeData["contents"] return nodeData["contents"]
end function end function
function ParseReelShelfRenderer(nodeData as object, _context as object) as object function ParseReelShelfRenderer(nodeData as object, context as object) as object
if context.disableShorts = true
LogInfo("Skipping ReelShelfRenderer based on user settings")
return invalid
end if
' TODO: handle reelShelfRenderer.title ' TODO: handle reelShelfRenderer.title
return nodeData["items"] return nodeData["items"]
end function end function
@@ -276,20 +281,31 @@ namespace Innertube
end if end if
end if end if
liveNow = ValidString(ObjectUtils.Dig(nodeData, ["badges", 0, "metadataBadgeRenderer", "icon", "iconType"])) = "LIVE" isUpcoming = false
if not liveNow liveNow = false
thumbnailOverlays = nodeData["thumbnailOverlays"]
if IsArray(thumbnailOverlays) thumbnailOverlays = nodeData["thumbnailOverlays"]
for each overlay in thumbnailOverlays if IsArray(thumbnailOverlays)
if ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "LIVE" for each overlay in thumbnailOverlays
liveNow = true parsedTimeStatusRenderer = ParseThumbnailOverlayTimeStatusRenderer(overlay)
exit for if parsedTimeStatusRenderer <> invalid
if parsedTimeStatusRenderer.isShort
if context.disableShorts = true
LogInfo("Skipping Short based on user settings")
return invalid
end if
end if end if
end for
end if liveNow = liveNow or parsedTimeStatusRenderer.isLive
isUpcoming = isUpcoming or parsedTimeStatusRenderer.isUpcoming
end if
end for
end if
if ValidString(ObjectUtils.Dig(nodeData, ["badges", 0, "metadataBadgeRenderer", "icon", "iconType"])) = "LIVE"
liveNow = true
end if end if
isUpcoming = false
premiereTimestamp = ObjectUtils.Dig(nodeData, ["upcomingEventData", "startTime"]) premiereTimestamp = ObjectUtils.Dig(nodeData, ["upcomingEventData", "startTime"])
if IsString(premiereTimestamp) if IsString(premiereTimestamp)
premiereTimestamp = premiereTimestamp.ToInt() premiereTimestamp = premiereTimestamp.ToInt()
@@ -362,9 +378,12 @@ namespace Innertube
thumbnailOverlays = nodeData["thumbnailOverlays"] thumbnailOverlays = nodeData["thumbnailOverlays"]
if IsArray(thumbnailOverlays) if IsArray(thumbnailOverlays)
for each overlay in thumbnailOverlays for each overlay in thumbnailOverlays
lengthText = ParseText(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "text"])) parsedTimeStatusRenderer = ParseThumbnailOverlayTimeStatusRenderer(overlay)
if lengthText <> "" if parsedTimeStatusRenderer <> invalid
exit for lengthText = parsedTimeStatusRenderer.text
if lengthText <> ""
exit for
end if
end if end if
end for end for
end if end if
@@ -518,8 +537,18 @@ namespace Innertube
thumbnailOverlays = nodeData["thumbnailOverlays"] thumbnailOverlays = nodeData["thumbnailOverlays"]
if IsArray(thumbnailOverlays) if IsArray(thumbnailOverlays)
for each overlay in thumbnailOverlays for each overlay in thumbnailOverlays
liveNow = liveNow or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "LIVE") parsedTimeStatusRenderer = ParseThumbnailOverlayTimeStatusRenderer(overlay)
isUpcoming = isUpcoming or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "UPCOMING") if parsedTimeStatusRenderer <> invalid
if parsedTimeStatusRenderer.isShort
if context.disableShorts = true
LogInfo("Skipping Short based on user settings")
return invalid
end if
end if
liveNow = liveNow or parsedTimeStatusRenderer.isLive
isUpcoming = isUpcoming or parsedTimeStatusRenderer.isUpcoming
end if
end for end for
end if end if
@@ -869,6 +898,11 @@ namespace Innertube
end function end function
function ParseShortsLockupViewModel(nodeData as object, context as object) as object function ParseShortsLockupViewModel(nodeData as object, context as object) as object
if context.disableShorts = true
LogInfo("Skipping Short based on user settings")
return invalid
end if
videoId = ObjectUtils.Dig(nodeData, ["onTap", "innertubeCommand", "reelWatchEndpoint", "videoId"]) videoId = ObjectUtils.Dig(nodeData, ["onTap", "innertubeCommand", "reelWatchEndpoint", "videoId"])
if not IsString(videoId) if not IsString(videoId)
LogWarn("Invalid video ID", nodeData) LogWarn("Invalid video ID", nodeData)
@@ -978,17 +1012,30 @@ namespace Innertube
thumbnailOverlays = ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnailOverlays"]) thumbnailOverlays = ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnailOverlays"])
if IsArray(thumbnailOverlays) if IsArray(thumbnailOverlays)
for each overlay in thumbnailOverlays for each overlay in thumbnailOverlays
maybeLengthText = ParseText(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "text"])) parsedTimeStatusRenderer = ParseThumbnailOverlayTimeStatusRenderer(overlay)
if maybeLengthText <> "" if parsedTimeStatusRenderer <> invalid
lengthText = maybeLengthText if parsedTimeStatusRenderer.isShort
if context.disableShorts = true
LogInfo("Skipping Short based on user settings")
return invalid
end if
end if
maybeLengthText = parsedTimeStatusRenderer.text
if maybeLengthText <> ""
lengthText = maybeLengthText
end if
liveNow = liveNow or parsedTimeStatusRenderer.isLive
isUpcoming = isUpcoming or parsedTimeStatusRenderer.isUpcoming
end if end if
maybePercentDurationWatched = ObjectUtils.Dig(overlay, ["thumbnailOverlayResumePlaybackRenderer", "percentDurationWatched"]) maybePercentDurationWatched = ObjectUtils.Dig(overlay, ["thumbnailOverlayResumePlaybackRenderer", "percentDurationWatched"])
if maybePercentDurationWatched <> invalid if maybePercentDurationWatched <> invalid
percentDurationWatched = maybePercentDurationWatched percentDurationWatched = maybePercentDurationWatched
end if end if
liveNow = liveNow or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "LIVE")
isUpcoming = isUpcoming or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "UPCOMING")
end for end for
if liveNow or isUpcoming if liveNow or isUpcoming
lengthText = "" lengthText = ""
end if end if
@@ -1022,6 +1069,11 @@ namespace Innertube
end function end function
function TileRendererTypeShorts(nodeData as object, context as object) as object function TileRendererTypeShorts(nodeData as object, context as object) as object
if context.disableShorts = true
LogInfo("Skipping Short based on user settings")
return invalid
end if
videoId = nodeData["contentId"] videoId = nodeData["contentId"]
if not IsString(videoId) if not IsString(videoId)
LogWarn("Invalid video ID", nodeData) LogWarn("Invalid video ID", nodeData)
@@ -1204,6 +1256,34 @@ namespace Innertube
return ParseText(data["text"]) return ParseText(data["text"])
end function end function
function ParseThumbnailOverlayTimeStatusRenderer(data as object) as object
if data = invalid
return invalid
end if
if not IsAssociativeArray(data) or not data.DoesExist("thumbnailOverlayTimeStatusRenderer")
return invalid
end if
renderer = data["thumbnailOverlayTimeStatusRenderer"]
if not IsAssociativeArray(renderer)
return invalid
end if
text = ParseText(renderer["text"])
overlayStyle = ValidString(renderer["style"])
isLive = overlayStyle = "LIVE"
isUpcoming = overlayStyle = "UPCOMING"
isShort = overlayStyle = "SHORTS"
return {
"text": text
"isLive": isLive
"isUpcoming": isUpcoming
"isShort": isShort
}
end function
function StartNewFeed(title as string, context as object) as void function StartNewFeed(title as string, context as object) as void
if context.currentFeed <> invalid if context.currentFeed <> invalid
if context.currentFeed.items.Count() = 0 and context.currentFeed.title = "" if context.currentFeed.items.Count() = 0 and context.currentFeed.title = ""
@@ -196,7 +196,7 @@ namespace Innertube
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo, "", "") "context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo)
"accountReadMask": { "accountReadMask": {
"returnOwner": true "returnOwner": true
"returnBrandAccounts": true "returnBrandAccounts": true
@@ -243,6 +243,7 @@ namespace Innertube
"hasChannel": ValidBool(accountItem["hasChannel"]) "hasChannel": ValidBool(accountItem["hasChannel"])
"accountByline": ParseText(accountItem["accountByline"]) "accountByline": ParseText(accountItem["accountByline"])
"channelHandle": ParseText(accountItem["channelHandle"]) "channelHandle": ParseText(accountItem["channelHandle"])
"activeIdentifyToken": ParseAccountItemIdentityToken(accountItem)
} }
parsedAccounts.Push(parsedAccount) parsedAccounts.Push(parsedAccount)
end for end for
@@ -250,6 +251,48 @@ namespace Innertube
return parsedAccounts return parsedAccounts
end function end function
function ParseAccountItemIdentityToken(accountItem as object) as string
' Although selected (default) account would have a token, we usually don't
' need it, since we don't need to pass the "onBehalfOfUser" argument
' when using selected account.
if ValidBool(accountItem.isSelected)
return ""
end if
supportedTokens = ObjectUtils.Dig(accountItem, ["serviceEndpoint", "selectActiveIdentityEndpoint", "supportedTokens"])
if not IsArray(supportedTokens) or supportedTokens.Count() = 0
return ""
end if
for each supportedToken in supportedTokens
if not IsAssociativeArray(supportedToken)
continue for
end if
' TODO:P2 should we stick with pageId, and ignore the rest?
pageId = ObjectUtils.Dig(supportedToken, ["pageIdToken", "pageId"])
if not StringUtils.IsNullOrEmpty(pageId)
return pageId
end if
obfuscatedGaiaId = ObjectUtils.Dig(supportedToken, ["accountStateToken", "obfuscatedGaiaId"])
if not StringUtils.IsNullOrEmpty(obfuscatedGaiaId)
return obfuscatedGaiaId
end if
datasyncIdToken = ObjectUtils.Dig(supportedToken, ["datasyncIdToken", "datasyncIdToken"])
if not StringUtils.IsNullOrEmpty(datasyncIdToken)
' "datasyncIdToken": "123456789012345678901||123456789012345678901"
match = /(\d+)\|\|(\d+)/.match(datasyncIdToken)
if match.Count() = 3
return match[1]
end if
end if
end for
return ""
end function
function ToCamelCase(obj as object) as object function ToCamelCase(obj as object) as object
if not IsAssociativeArray(obj) if not IsAssociativeArray(obj)
return obj return obj
@@ -10,9 +10,7 @@ namespace Innertube
return [] return []
end if end if
if context = invalid context = ValidAssociativeArray(context)
context = {}
end if
if not ValidBool(context.noContainers) if not ValidBool(context.noContainers)
containers = GetContainers(responseData) containers = GetContainers(responseData)
@@ -333,16 +331,37 @@ namespace Innertube
end function end function
function ParseResponseDataForError(responseData as object) as string function ParseResponseDataForError(responseData as object) as string
error = ""
if responseData = invalid if responseData = invalid
return "" return error
end if end if
alert = ObjectUtils.Dig(responseData, ["alerts", 0, "alertRenderer"]) alerts = responseData["alerts"]
if IsAssociativeArray(alert) and alert.type = "ERROR" if not IsArray(alerts) or alerts.Count() = 0
return ParseText(alert.text) return error
end if end if
return "" for each alert in alerts
if not IsAssociativeArray(alert)
continue for
end if
alertRenderer = alert["alertRenderer"]
if alertRenderer = invalid
alertRenderer = alert["alertWithButtonRenderer"]
end if
if not IsAssociativeArray(alertRenderer)
continue for
end if
alertText = ParseText(alertRenderer.text)
LogWarn("Innertube Alert:", `[${alertRenderer.type}]`, alertText)
if alertRenderer.type = "ERROR"
error += alertText
end if
end for
return error
end function end function
function ParseResponseForCacheControl(response as object) as dynamic function ParseResponseForCacheControl(response as object) as dynamic
@@ -6,12 +6,16 @@ import "pkg:/source/utils/Types.bs"
namespace Innertube namespace Innertube
function CreatePlayerRequest(videoId as string, ctt as string, visitorData as string, client as Innertube.ClientType) as object function CreatePlayerRequest(videoId as string, client as Innertube.ClientType, options = invalid as object) as object
visitorData = OptionUtils.Get(options, "visitorData")
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
context = Innertube.CreateContext(client, deviceInfo, options)
payload = { payload = {
"videoId": videoId "videoId": videoId
"context": Innertube.CreateContext(client, deviceInfo, ctt, visitorData) "context": context
"playbackContext": { "playbackContext": {
"contentPlaybackContext": { "contentPlaybackContext": {
"vis": 0 "vis": 0
@@ -32,48 +36,19 @@ namespace Innertube
} }
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/player?prettyPrint=false&alt=json", payload) request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/player?prettyPrint=false&alt=json", payload)
headers = { request.Headers(Innertube.CreateHeaders(client))
"accept": "*/*" if not StringUtils.IsNullOrEmpty(visitorData)
"accept-language": "*" request.Header("x-goog-visitor-id", visitorData)
} end if
headers.Append(Innertube.CreateHeaders(client))
request.Headers(headers)
return request return request
end function end function
function ParseInnertubePlayerResponse(payload as object) as object function ParseInnertubePlayerResponse(payload as object) as object
if not IsAssociativeArray(payload) error = ParsePlayerResponseForError(payload)
if error <> ""
return { return {
error: "Invalid payload" error: error
}
end if
playabilityStatus = payload["playabilityStatus"]
if not IsAssociativeArray(playabilityStatus)
return {
error: "Invalid playability status"
}
end if
if playabilityStatus["status"] <> "OK"
errorMessage = ""
if IsString(playabilityStatus["reason"])
errorMessage = playabilityStatus["reason"]
end if
subreason = ParseText(ObjectUtils.Dig(playabilityStatus, ["errorScreen", "playerErrorMessageRenderer", "subreason"]))
if subreason <> ""
errorMessage += `\n` + subreason
end if
if errorMessage = ""
errorMessage = "Video not available"
end if
return {
error: errorMessage
} }
end if end if
@@ -114,6 +89,38 @@ namespace Innertube
return videoInfo return videoInfo
end function end function
function ParsePlayerResponseForError(payload as object) as string
if not IsAssociativeArray(payload)
return "Invalid payload"
end if
playabilityStatus = payload["playabilityStatus"]
if not IsAssociativeArray(playabilityStatus)
return "Invalid playability status"
end if
if playabilityStatus["status"] = "OK"
return ""
end if
errorMessage = ""
if IsString(playabilityStatus["reason"])
errorMessage = playabilityStatus["reason"]
end if
subreason = ParseText(ObjectUtils.Dig(playabilityStatus, ["errorScreen", "playerErrorMessageRenderer", "subreason"]))
if subreason <> ""
errorMessage += `\n` + subreason
end if
if errorMessage = ""
errorMessage = "Video not available"
end if
return errorMessage
end function
function ParseStoryboards(payload as object, lengthSeconds as integer) as object function ParseStoryboards(payload as object, lengthSeconds as integer) as object
storyboard = ObjectUtils.Dig(payload, ["storyboards", "playerLiveStoryboardSpecRenderer", "spec"]) storyboard = ObjectUtils.Dig(payload, ["storyboards", "playerLiveStoryboardSpecRenderer", "spec"])
if IsString(storyboard) if IsString(storyboard)
@@ -6,17 +6,12 @@ namespace Innertube
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"context": CreateContext(ClientType.Web, deviceInfo, "", "") "context": CreateContext(ClientType.Web, deviceInfo)
"url": url "url": url
} }
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/navigation/resolve_url?prettyPrint=false&alt=json", payload) request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/navigation/resolve_url?prettyPrint=false&alt=json", payload)
headers = { request.Headers(Innertube.CreateHeaders(ClientType.Web))
"accept": "*/*"
"accept-language": "*"
}
headers.Append(CreateHeaders(ClientType.Web))
request.Headers(headers)
return request return request
end function end function
@@ -2,18 +2,25 @@ import "pkg:/components/Services/Innertube/Context.bs"
import "pkg:/components/Services/Innertube/Parser.bs" import "pkg:/components/Services/Innertube/Parser.bs"
import "pkg:/components/Services/Innertube/SearchFilters.bs" import "pkg:/components/Services/Innertube/SearchFilters.bs"
import "pkg:/source/services/HttpClient.bs" import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/OptionUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
namespace Innertube namespace Innertube
function Search(query as string, searchFilters as object, continuation = "" as string, cancellation = invalid as object, raw = false as boolean) as object function Search(query as string, options = invalid as object) as object
searchFilters = OptionUtils.Get(options, "searchFilters")
continuation = OptionUtils.Get(options, "continuation")
cancellation = OptionUtils.Get(options, "cancellation")
disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
raw = OptionUtils.GetOrDefault(options, "raw", false)
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
context: Innertube.CreateContext(Innertube.ClientType.WEB, deviceInfo, "", "") context: Innertube.CreateContext(Innertube.ClientType.WEB, deviceInfo)
} }
if continuation <> "" if not StringUtils.IsNullOrEmpty(continuation)
payload["continuation"] = continuation payload["continuation"] = continuation
else else
payload["query"] = query payload["query"] = query
@@ -26,13 +33,7 @@ namespace Innertube
end if end if
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/search?prettyPrint=false&alt=json", payload) request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/search?prettyPrint=false&alt=json", payload)
request.Headers({ request.Headers(Innertube.CreateHeaders(ClientType.Web))
"accept": "*/*"
"accept-language": "*"
"user-agent": INNERTUBE_WEB_USER_AGENT
"x-youtube-client-name": INNERTUBE_WEB_CLIENT_NAME
"x-youtube-client-version": INNERTUBE_WEB_CLIENT_VERSION
})
request.Cancellation(cancellation) request.Cancellation(cancellation)
if raw if raw
@@ -51,7 +52,7 @@ namespace Innertube
return response.Json() return response.Json()
end if end if
feeds = ParseResponseDataForFeeds(response.Json()) feeds = ParseResponseDataForFeeds(response.Json(), { disableShorts: disableShorts })
result = { result = {
feeds: feeds feeds: feeds
@@ -3,11 +3,11 @@ import "pkg:/source/utils/Types.bs"
namespace Innertube namespace Innertube
function CreateSubscribeRequest(channelIds as dynamic, params as string) as object function CreateSubscribeRequest(channelIds as dynamic, options = invalid as object) as object
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo, "", "") "context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo, options)
} }
if IsString(channelIds) if IsString(channelIds)
@@ -15,26 +15,17 @@ namespace Innertube
end if end if
payload["channelIds"] = channelIds 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) request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/subscription/subscribe?prettyPrint=false&alt=json", payload)
headers = { request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Tv))
"accept": "*/*"
"accept-language": "*"
}
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.Tv))
request.Headers(headers)
return request return request
end function end function
function CreateUnsubscribeRequest(channelIds as dynamic, params as string) as object function CreateUnsubscribeRequest(channelIds as dynamic, options = invalid as object) as object
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo, "", "") "context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo, options)
} }
if IsString(channelIds) if IsString(channelIds)
@@ -42,17 +33,8 @@ namespace Innertube
end if end if
payload["channelIds"] = channelIds 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) request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/subscription/unsubscribe?prettyPrint=false&alt=json", payload)
headers = { request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Tv))
"accept": "*/*"
"accept-language": "*"
}
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.Tv))
request.Headers(headers)
return request return request
end function end function
@@ -7,10 +7,14 @@ function Init()
m.service = new Invidious.InvidiousService(m.top) m.service = new Invidious.InvidiousService(m.top)
end function end function
function GetCurrentInstance(_unused as dynamic) as string function GetInstance(_unused as dynamic) as string
return m.service.GetInstance() return m.service.GetInstance()
end function end function
function GetInvidiousInstance(_unused as dynamic) as string
return m.service.GetInvidiousInstance()
end function
function GetAuthorizeTokenLink(_unused as dynamic) as dynamic function GetAuthorizeTokenLink(_unused as dynamic) as dynamic
return m.service.GetAuthorizeTokenLink() return m.service.GetAuthorizeTokenLink()
end function end function
@@ -8,7 +8,8 @@
<field id="authToken" type="assocarray" /> <field id="authToken" type="assocarray" />
<field id="apiDefinitions" type="assocarray" /> <field id="apiDefinitions" type="assocarray" />
<function name="GetCurrentInstance" /> <function name="GetInstance" />
<function name="GetInvidiousInstance" />
<function name="GetAuthorizeTokenLink" /> <function name="GetAuthorizeTokenLink" />
</interface> </interface>
</component> </component>
@@ -8,6 +8,7 @@ import "pkg:/source/utils/CryptoUtils.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/MessagePortUtils.bs" import "pkg:/source/utils/MessagePortUtils.bs"
import "pkg:/source/utils/OptionUtils.bs" import "pkg:/source/utils/OptionUtils.bs"
import "pkg:/source/utils/OptionUtils.bs"
import "pkg:/source/utils/RegistryUtils.bs" import "pkg:/source/utils/RegistryUtils.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/TimeUtils.bs" import "pkg:/source/utils/TimeUtils.bs"
@@ -15,7 +16,7 @@ import "pkg:/source/utils/TimeUtils.bs"
namespace Invidious namespace Invidious
const INSTANCES_API = "https://api.invidious.io/instances.json?sort_by=type,users" const INSTANCES_API = "https://api.invidious.io/instances.json?sort_by=type,users"
const DEFAULT_INSTANCE = "http://127.0.0.1:8888/playlet-invidious-backend" const PLAYLET_BUILT_IN_INSTANCE = "http://127.0.0.1:8888/playlet-invidious-backend"
const INSTANCE_EXAMPLE = "https://invidious.example.com" const INSTANCE_EXAMPLE = "https://invidious.example.com"
const TOKEN_CALLBACK = "/invidious/token_callback" const TOKEN_CALLBACK = "/invidious/token_callback"
@@ -73,13 +74,25 @@ namespace Invidious
backend = m.preferences["backend.selected"] backend = m.preferences["backend.selected"]
if backend = "invidious" if backend = "invidious"
instance = m.preferences["invidious.instance"] instance = m.GetInvidiousInstance()
if not StringUtils.IsNullOrEmpty(instance) if not StringUtils.IsNullOrEmpty(instance)
return instance return instance
end if end if
end if end if
instance = DEFAULT_INSTANCE return m.GetPlayletBuiltinInstance()
end function
function GetInvidiousInstance() as string
if m.preferences = invalid
m.preferences = m.invidiousNode.preferences
end if
return m.preferences["invidious.instance"]
end function
function GetPlayletBuiltinInstance() as string
instance = PLAYLET_BUILT_IN_INSTANCE
address = m.invidiousNode.webServer@.GetServerAddress() address = m.invidiousNode.webServer@.GetServerAddress()
instance = instance.Replace("http://127.0.0.1:8888", address) instance = instance.Replace("http://127.0.0.1:8888", address)
return instance return instance
@@ -128,21 +141,9 @@ namespace Invidious
' have the exact expiration time, we'll use 5 hours. Invidious currently ' have the exact expiration time, we'll use 5 hours. Invidious currently
' Does a fresh fetch if the cache is older than 10 minutes. ' Does a fresh fetch if the cache is older than 10 minutes.
' https://github.com/iv-org/invidious/blob/069e91d2a609b1df94bdfbb693335969b2a281d8/src/invidious/videos.cr#L349 ' https://github.com/iv-org/invidious/blob/069e91d2a609b1df94bdfbb693335969b2a281d8/src/invidious/videos.cr#L349
cacheSeconds = 18000 ' 5 hours cacheSeconds = OptionUtils.GetOrDefault(options, "cacheSeconds", 18000) ' 5 hours
cancellation = invalid cancellation = OptionUtils.Get(options, "cancellation")
tryCount = 2 tryCount = OptionUtils.GetOrDefault(options, "tryCount", 2)
if options <> invalid
if options.DoesExist("cacheSeconds")
cacheSeconds = options.cacheSeconds
end if
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
if options.DoesExist("tryCount")
tryCount = options.tryCount
end if
end if
instance = m.GetInstance() instance = m.GetInstance()
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}` url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
@@ -185,6 +186,9 @@ namespace Invidious
url = `${authToken.instance}${Invidious.AUTH_PLAYLISTS}/${playlistId}` url = `${authToken.instance}${Invidious.AUTH_PLAYLISTS}/${playlistId}`
request = HttpClient.Get(url) request = HttpClient.Get(url)
request.Headers(m.GetAuthenticationHeaders(authToken.token)) request.Headers(m.GetAuthenticationHeaders(authToken.token))
if not StringUtils.IsNullOrEmpty(authToken.activeIdentifyToken)
request.QueryParam("activeIdentifyToken", authToken.activeIdentifyToken)
end if
else else
instance = m.GetInstance() instance = m.GetInstance()
url = `${instance}${Invidious.PLAYLISTS_ENDPOINT}/${playlistId}` url = `${instance}${Invidious.PLAYLISTS_ENDPOINT}/${playlistId}`
@@ -307,6 +311,9 @@ namespace Invidious
request.Url(authToken.instance + endpoint.url) request.Url(authToken.instance + endpoint.url)
request.Headers(m.GetAuthenticationHeaders(authToken.token)) request.Headers(m.GetAuthenticationHeaders(authToken.token))
if not StringUtils.IsNullOrEmpty(authToken.activeIdentifyToken)
request.QueryParam("activeIdentifyToken", authToken.activeIdentifyToken)
end if
end if end if
if endpoint.queryParams <> invalid if endpoint.queryParams <> invalid
@@ -732,7 +739,11 @@ namespace Invidious
end function end function
function GetAuthorizeTokenLink() as dynamic function GetAuthorizeTokenLink() as dynamic
instance = m.GetInstance() instance = m.GetInvidiousInstance()
if StringUtils.IsNullOrEmpty(instance)
instance = m.GetPlayletBuiltinInstance()
end if
' Make sure the host is not on https, because https cannot redirect to http, which is our local server ' Make sure the host is not on https, because https cannot redirect to http, which is our local server
invidiousHost = instance.Replace("https://", "http://") invidiousHost = instance.Replace("https://", "http://")
@@ -770,6 +781,9 @@ namespace Invidious
url = `${authToken.instance}${Invidious.AUTH_SUBSCRIPTIONS}/${channelId}` url = `${authToken.instance}${Invidious.AUTH_SUBSCRIPTIONS}/${channelId}`
request = HttpClient.Post(url, "") request = HttpClient.Post(url, "")
if not StringUtils.IsNullOrEmpty(authToken.activeIdentifyToken)
request.QueryParam("activeIdentifyToken", authToken.activeIdentifyToken)
end if
request.Headers(m.GetAuthenticationHeaders(authToken.token)) request.Headers(m.GetAuthenticationHeaders(authToken.token))
request.Cancellation(cancellation) request.Cancellation(cancellation)
@@ -784,6 +798,9 @@ namespace Invidious
url = `${authToken.instance}${Invidious.AUTH_SUBSCRIPTIONS}/${channelId}` url = `${authToken.instance}${Invidious.AUTH_SUBSCRIPTIONS}/${channelId}`
request = HttpClient.Delete(url) request = HttpClient.Delete(url)
if not StringUtils.IsNullOrEmpty(authToken.activeIdentifyToken)
request.QueryParam("activeIdentifyToken", authToken.activeIdentifyToken)
end if
request.Headers(m.GetAuthenticationHeaders(authToken.token)) request.Headers(m.GetAuthenticationHeaders(authToken.token))
request.Cancellation(cancellation) request.Cancellation(cancellation)
@@ -170,15 +170,16 @@ namespace InvidiousContent
end if end if
end function end function
function VideoSetThumbnail(node as object, videoItem as object, instance as dynamic, quality = "medium" as string) as boolean function VideoSetThumbnail(node as object, videoItem as object, instance as dynamic, quality = "medium" as string) as void
videoThumbnails = videoItem.videoThumbnails videoThumbnails = videoItem.videoThumbnails
hasValidInstance = not StringUtils.IsNullOrEmpty(instance) and instance.InStr(":8888/playlet-invidious-backend") = -1
if videoThumbnails = invalid or videoThumbnails.Count() = 0 if videoThumbnails = invalid or videoThumbnails.Count() = 0
if StringUtils.IsNullOrEmpty(instance) if hasValidInstance
node.thumbnail = `https://i.ytimg.com/vi/${videoItem.videoId}/mqdefault.jpg`
else
node.thumbnail = `${instance}/vi/${videoItem.videoId}/mqdefault.jpg` node.thumbnail = `${instance}/vi/${videoItem.videoId}/mqdefault.jpg`
else
node.thumbnail = `https://i.ytimg.com/vi/${videoItem.videoId}/mqdefault.jpg`
end if end if
return false return
end if end if
url = invalid url = invalid
for each thumbnail in videoThumbnails for each thumbnail in videoThumbnails
@@ -191,13 +192,13 @@ namespace InvidiousContent
url = videoThumbnails[0].url url = videoThumbnails[0].url
end if end if
if url.startsWith("/") if url.startsWith("/")
if StringUtils.IsNullOrEmpty(instance) if hasValidInstance
return false url = instance + url
else
url = `https://i.ytimg.com/vi/${videoItem.videoId}/mqdefault.jpg`
end if end if
url = instance + url
end if end if
node.thumbnail = url node.thumbnail = url
return true
end function end function
function VideoIsLive(videoItem as object) as boolean function VideoIsLive(videoItem as object) as boolean
@@ -288,16 +289,16 @@ namespace InvidiousContent
end if end if
thumbnail = "" thumbnail = ""
hasValidInstance = not StringUtils.IsNullOrEmpty(instance) and instance.InStr(":8888/playlet-invidious-backend") = -1
if IsString(playlistItem.playlistThumbnail) if IsString(playlistItem.playlistThumbnail)
thumbnailUrl = playlistItem.playlistThumbnail thumbnailUrl = playlistItem.playlistThumbnail
if thumbnailUrl.startsWith("/") and not StringUtils.IsNullOrEmpty(playlistItem.instance) if thumbnailUrl.startsWith("/") and hasValidInstance
thumbnailUrl = playlistItem.instance + thumbnailUrl thumbnailUrl = playlistItem.instance + thumbnailUrl
end if end if
thumbnail = thumbnailUrl thumbnail = thumbnailUrl
else if playlistItem.videos <> invalid and playlistItem.videos.Count() > 0 and playlistItem.videos[0].index = 0 else if playlistItem.videos <> invalid and playlistItem.videos.Count() > 0 and playlistItem.videos[0].index = 0
if VideoSetThumbnail(node, playlistItem.videos[0], instance, quality) VideoSetThumbnail(node, playlistItem.videos[0], instance, quality)
return return
end if
else if node.getChildCount() > 0 else if node.getChildCount() > 0
thumbnail = node.getChild(0).thumbnail thumbnail = node.getChild(0).thumbnail
end if end if
@@ -427,8 +427,8 @@ class LoungeApi
' Right now we just store only the last ctt, which works ok if we're casting one video at a time. ' Right now we just store only the last ctt, which works ok if we're casting one video at a time.
' But if the age restrcited video is added to the queue, we don't capture a token and playing the video would fail. ' But if the age restrcited video is added to the queue, we don't capture a token and playing the video would fail.
' These tokens need to be managed better, based on the video they belong to. ' These tokens need to be managed better, based on the video they belong to.
if not StringUtils.IsNullOrEmpty(commandArgs.ctt) if not StringUtils.IsNullOrEmpty(commandArgs[FIELD_CTT])
m.loungeServiceNode.ctt = commandArgs.ctt m.loungeServiceNode.credentialTransferToken = commandArgs[FIELD_CTT]
end if end if
LoungeVideoQueue.SetPlaylist(m.videoQueueNode, m.invService, commandArgs) LoungeVideoQueue.SetPlaylist(m.videoQueueNode, m.invService, commandArgs)
end function end function
@@ -5,7 +5,7 @@
<field id="deviceName" type="string" /> <field id="deviceName" type="string" />
<field id="screenId" type="string" /> <field id="screenId" type="string" />
<field id="loungeToken" type="string" /> <field id="loungeToken" type="string" />
<field id="ctt" type="string" /> <field id="credentialTransferToken" type="string" />
<field id="join" type="boolean" alwaysNotify="true" /> <field id="join" type="boolean" alwaysNotify="true" />
<field id="outgoingMessages" type="array" alwaysNotify="true" /> <field id="outgoingMessages" type="array" alwaysNotify="true" />
@@ -1,4 +1,5 @@
import "pkg:/source/utils/RegistryUtils.bs" import "pkg:/source/utils/RegistryUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -8,6 +9,7 @@ function Init()
"number": "integer" "number": "integer"
"radio": "string" "radio": "string"
"array": "array" "array": "array"
"assocarray": "assocarray"
} }
m.disableSavingToRegistry = false m.disableSavingToRegistry = false
@@ -93,23 +95,21 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
isDirty = false isDirty = false
' v0 -> v1 ' v0 -> v1
instances = RegistryUtils.Read(RegistryUtils.INVIDIOUS_INSTANCES) if ValidInt(userPrefs.__version) = 0
if instances <> invalid instances = RegistryUtils.Read(RegistryUtils.INVIDIOUS_INSTANCES)
currentInstance = userPrefs["invidious.instance"] if not StringUtils.IsNullOrEmpty(instances)
if currentInstance = invalid or currentInstance = "" currentInstance = userPrefs["invidious.instance"]
instances = ParseJson(instances) if StringUtils.IsNullOrEmpty(currentInstance)
if instances.Count() > 0 instances = ParseJson(instances)
instance = instances[0] if IsArray(instances) and instances.Count() > 0
if instance <> invalid and instance <> "" instance = instances[0]
userPrefs["invidious.instance"] = instance if not StringUtils.IsNullOrEmpty(instance)
isDirty = true userPrefs["invidious.instance"] = instance
end if
end if end if
end if end if
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES)
end if end if
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES)
end if
if ValidInt(userPrefs.__version) = 0
userPrefs.__version = 1 userPrefs.__version = 1
isDirty = true isDirty = true
end if end if
@@ -53,6 +53,7 @@ function LoadProfilesFromRegistry()
profileNode.thumbnail = profile.thumbnail profileNode.thumbnail = profile.thumbnail
profileNode.accessToken = profile.accessToken profileNode.accessToken = profile.accessToken
profileNode.activeIdentifyToken = profile.activeIdentifyToken
profileNode.refreshToken = profile.refreshToken profileNode.refreshToken = profile.refreshToken
profileNode.scope = profile.scope profileNode.scope = profile.scope
profileNode.tokenType = profile.tokenType profileNode.tokenType = profile.tokenType
@@ -103,7 +104,7 @@ function MigrateExistingProfiles(userProfiles as object) as boolean
return false return false
end if end if
id = CreateProfileId(authToken.username, authToken.instance) id = CreateProfileId(authToken.username, "", authToken.instance)
for each profile in userProfiles.profiles for each profile in userProfiles.profiles
if profile.id = id if profile.id = id
return false return false
@@ -161,6 +162,7 @@ function GetProfilesDto(includeAccessToken as boolean) as object
"id": profileNode.id "id": profileNode.id
"type": profileNode.type "type": profileNode.type
"username": profileNode.username "username": profileNode.username
"activeIdentifyToken": profileNode.activeIdentifyToken
"serverUrl": profileNode.serverUrl "serverUrl": profileNode.serverUrl
"thumbnail": profileNode.thumbnail "thumbnail": profileNode.thumbnail
"color": color "color": color
@@ -191,7 +193,7 @@ end function
function LoginWithProfile(newProfile as object) function LoginWithProfile(newProfile as object)
isNewProfile = true isNewProfile = true
if StringUtils.IsNullOrEmpty(newProfile.id) if StringUtils.IsNullOrEmpty(newProfile.id)
newProfile.id = CreateProfileId(newProfile.username, newProfile.serverUrl) newProfile.id = CreateProfileId(newProfile.username, newProfile.activeIdentifyToken, newProfile.serverUrl)
end if end if
existingProfile = invalid existingProfile = invalid
@@ -206,6 +208,7 @@ function LoginWithProfile(newProfile as object)
if not isNewProfile if not isNewProfile
existingProfile.username = newProfile.username existingProfile.username = newProfile.username
existingProfile.activeIdentifyToken = newProfile.activeIdentifyToken
existingProfile.thumbnail = newProfile.thumbnail existingProfile.thumbnail = newProfile.thumbnail
existingProfile.accessToken = newProfile.accessToken existingProfile.accessToken = newProfile.accessToken
existingProfile.refreshToken = newProfile.refreshToken existingProfile.refreshToken = newProfile.refreshToken
@@ -333,6 +336,7 @@ function SetCurrentProfile(newActiveProfile as object) as void
token: newActiveProfile.accessToken token: newActiveProfile.accessToken
instance: newActiveProfile.serverUrl instance: newActiveProfile.serverUrl
username: newActiveProfile.username username: newActiveProfile.username
activeIdentifyToken: newActiveProfile.activeIdentifyToken
profileNode: newActiveProfile profileNode: newActiveProfile
} }
LogInfo("Current profile set to", newActiveProfile.username, "@", newActiveProfile.serverUrl) LogInfo("Current profile set to", newActiveProfile.username, "@", newActiveProfile.serverUrl)
@@ -353,6 +357,6 @@ function RefreshActiveProfileState(activeProfile as object) as void
end for end for
end function end function
function CreateProfileId(username as string, serverUrl as string) as string function CreateProfileId(username as string, activeIdentifyToken as string, serverUrl as string) as string
return "v1:" + CryptoUtils.GetMd5(username + serverUrl) return "v1:" + CryptoUtils.GetMd5(username + activeIdentifyToken + serverUrl)
end function end function
@@ -1,4 +1,5 @@
import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs" import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs"
import "pkg:/components/VideoPlayer/SponsorBlockSegmentAction.bs"
function Init() function Init()
m.categoryLabel = m.top.findNode("categoryLabel") m.categoryLabel = m.top.findNode("categoryLabel")
@@ -13,16 +14,7 @@ function Init()
m.service = SponsorBlock.SponsorBlockService() m.service = SponsorBlock.SponsorBlockService()
end function end function
function OnActionSet() function OnDoShow() as void
action = m.top.action
category = m.top.segment.category
categoryTitle = Tr(ValidString(m.service.SegmentShortTitle(category)))
if action = "AutoSkip"
m.categoryLabel.text = Tr(Locale.SponsorBlock.Skipped) + `\n` + categoryTitle
else
m.categoryLabel.text = categoryTitle
end if
AnimateIn() AnimateIn()
end function end function
@@ -1,7 +1,9 @@
<component name="SponsorBlockNotification" extends="Group"> <component name="SponsorBlockNotification" extends="Group">
<interface> <interface>
<field id="segment" type="assocarray" /> <field id="segmentId" type="string" />
<field id="action" type="string" onChange="OnActionSet" alwaysNotify="true" /> <field id="categoryText" type="string" alias="categoryLabel.text" />
<field id="actionText" type="string" alias="actionLabel.text" />
<field id="doShow" type="boolean" onChange="OnDoShow" alwaysNotify="true" />
</interface> </interface>
<children> <children>
<Poster <Poster
@@ -16,18 +18,26 @@
height="50" height="50"
translation="[10,10]"> translation="[10,10]">
</Poster> </Poster>
<Label <LayoutGroup vertAlignment="center" translation="[70,35]">
id="categoryLabel" <Label
text="..." id="categoryLabel"
font="font:SmallestBoldSystemFont" font="font:TinyBoldSystemFont"
lineSpacing="5" horizAlign="center"
horizAlign="center" width="170"
vertAlign="center" lineSpacing="0"
wrap="true" maxLines="2"
width="170" wrap="true">
height="70" </Label>
translation="[70,0]"> <Label
</Label> id="actionLabel"
font="font:TinySystemFont"
horizAlign="center"
width="170"
lineSpacing="0"
maxLines="2"
wrap="true">
</Label>
</LayoutGroup>
</Poster> </Poster>
<Animation <Animation
id="translationAnimation" id="translationAnimation"
@@ -1,27 +1,43 @@
namespace SponsorBlock namespace SponsorBlock
const NOTIFICATION_NODE_ID = "SponsorBlockNotification" const NOTIFICATION_NODE_ID = "SponsorBlockNotification"
function GetCurrentNotification(notifications as object) as object
childCount = notifications.getChildCount()
for i = 0 to childCount - 1
child = notifications.getChild(i)
if child.id = NOTIFICATION_NODE_ID
return child
end if
end for
return invalid
end function
function ShowNotifcation(notifications as object, segment as object, action as dynamic) as void function ShowNotifcation(notifications as object, segment as object, action as dynamic) as void
' TODO:P2 avoid finding the node over and over ' TODO:P2 avoid finding the node over and over
' The video player can probably own a single notification, and destroy it when the video is closed ' The video player can probably own a single notification, and destroy it when the video is closed
notification = notifications.findNode(NOTIFICATION_NODE_ID) notification = GetCurrentNotification(notifications)
if notification = invalid if notification = invalid
notification = notifications.createChild("SponsorBlockNotification") notification = notifications.createChild("SponsorBlockNotification")
notification.id = NOTIFICATION_NODE_ID notification.id = NOTIFICATION_NODE_ID
end if end if
notification.segment = segment
notification.action = action notification.segmentId = segment.UUID
notification.categoryText = segment.shortTitle
notification.actionText = segment.actionText
notification.doShow = true
end function end function
function RemoveNotifcation(notifications as object) as void function RemoveNotifcation(notifications as object) as void
notification = notifications.findNode(NOTIFICATION_NODE_ID) notification = GetCurrentNotification(notifications)
if notification <> invalid if notification <> invalid
notifications.RemoveChild(notification) notifications.RemoveChild(notification)
end if end if
end function end function
function SetVisible(notifications as object, visible as boolean) function SetVisible(notifications as object, visible as boolean)
notification = notifications.findNode(NOTIFICATION_NODE_ID) notification = GetCurrentNotification(notifications)
if notification <> invalid if notification <> invalid
notification.visible = visible notification.visible = visible
end if end if
@@ -5,5 +5,5 @@ function SponsorBlockSegmentViewedTask(input as object)
segmentId = input.segmentId segmentId = input.segmentId
service = new SponsorBlock.SponsorBlockService() service = new SponsorBlock.SponsorBlockService()
service.PostSegmentViewed(segmentId) service.PostSegmentViewed(segmentId, m.top.cancellation)
end function end function
@@ -12,6 +12,26 @@ namespace SponsorBlock
m.sponsorBlockConfig = ParseJson(ReadAsciiFile("libpkg:/config/sponsorblock_config.json5")) m.sponsorBlockConfig = ParseJson(ReadAsciiFile("libpkg:/config/sponsorblock_config.json5"))
end function end function
function GetCategories() as object
if m.sponsorBlockConfig = invalid
return []
end if
return ValidArray(m.sponsorBlockConfig.categoryList)
end function
function GetOptionsForCategory(category as string) as object
if m.sponsorBlockConfig = invalid
return []
end if
if not m.sponsorBlockConfig.categories.doesexist(category)
return []
end if
return ValidArray(m.sponsorBlockConfig.categories[category].options)
end function
function SegmentColor(category as string) as integer function SegmentColor(category as string) as integer
if m.sponsorBlockConfig = invalid if m.sponsorBlockConfig = invalid
return 0 return 0
@@ -54,8 +74,10 @@ namespace SponsorBlock
return invalid return invalid
end if end if
categories = ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "poi_highlight", "filler", "exclusive_access"] ' categories = ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "poi_highlight", "filler", "exclusive_access"]
actionTypes = ["skip", "mute", "chapter", "full", "poi"] categories = ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "poi_highlight", "filler"]
' actionTypes = ["skip", "mute", "chapter", "full", "poi"]
actionTypes = ["skip", "mute", "poi"]
categoriesJson = FormatJson(categories).EncodeUriComponent() categoriesJson = FormatJson(categories).EncodeUriComponent()
actionTypesJson = FormatJson(actionTypes).EncodeUriComponent() actionTypesJson = FormatJson(actionTypes).EncodeUriComponent()
@@ -64,6 +86,11 @@ namespace SponsorBlock
hashPrefix = CryptoUtils.GetSha256(videoId).Left(4) hashPrefix = CryptoUtils.GetSha256(videoId).Left(4)
url = `${m.sponsorBlockConfig.serverAddress}${SponsorBlock.SKIP_SEGMENT_ENDPOINT}/${hashPrefix}?categories=${categoriesJson}&actionTypes=${actionTypesJson}` url = `${m.sponsorBlockConfig.serverAddress}${SponsorBlock.SKIP_SEGMENT_ENDPOINT}/${hashPrefix}?categories=${categoriesJson}&actionTypes=${actionTypesJson}`
response = HttpClient.Get(url).Await() response = HttpClient.Get(url).Await()
if not response.IsSuccess()
LogError("SponsorBlockService: GetSkipSegmentsForVideo failed", response.ErrorMessage())
return invalid
end if
json = response.Json() json = response.Json()
if json = invalid if json = invalid
return invalid return invalid
@@ -78,13 +105,13 @@ namespace SponsorBlock
return invalid return invalid
end function end function
function PostSegmentViewed(segmentId as string) as void function PostSegmentViewed(segmentId as string, cancellation = invalid as object) as void
if m.sponsorBlockConfig = invalid or StringUtils.IsNullOrEmpty(m.sponsorBlockConfig.serverAddress) if m.sponsorBlockConfig = invalid or StringUtils.IsNullOrEmpty(m.sponsorBlockConfig.serverAddress)
return return
end if end if
url = `${m.sponsorBlockConfig.serverAddress}${SponsorBlock.VIEWED_SEGMENT_ENDPOINT}?UUID=${segmentId}` url = `${m.sponsorBlockConfig.serverAddress}${SponsorBlock.VIEWED_SEGMENT_ENDPOINT}?UUID=${segmentId}`
HttpClient.Post(url, "").Await() HttpClient.Post(url, "").Cancellation(cancellation).Await()
end function end function
function GenerateProgressBarBackground(segments as object, lengthSeconds as integer, path as string) function GenerateProgressBarBackground(segments as object, lengthSeconds as integer, path as string)
@@ -103,8 +130,8 @@ namespace SponsorBlock
continue for continue for
end if end if
pixelStart = (segment.segment[0] / videoDuration) * width pixelStart = (segment.start / videoDuration) * width
pixelEnd = (segment.segment[1] / videoDuration) * width pixelEnd = (segment.end / videoDuration) * width
color = m.SegmentColor(segment.category) color = m.SegmentColor(segment.category)
' highlight's duration is zero, so it is not visble on the bar. ' highlight's duration is zero, so it is not visble on the bar.
' Add a few pixels to see it ' Add a few pixels to see it
@@ -1,22 +1,135 @@
import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs" import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs"
import "pkg:/components/VideoPlayer/SponsorBlockSegmentAction.bs"
import "pkg:/source/utils/Types.bs"
@asynctask @asynctask
function SponsorBlockTask(input as object) as object function SponsorBlockTask(input as object) as object
videoId = input.metadata.videoId videoId = input.metadata.videoId
lengthSeconds = input.metadata.lengthSeconds lengthSeconds = input.metadata.lengthSeconds
showNotifications = input.showNotifications
categories = input.categories
service = new SponsorBlock.SponsorBlockService() service = new SponsorBlock.SponsorBlockService()
skipSegments = service.GetSkipSegmentsForVideo(videoId) skipSegments = service.GetSkipSegmentsForVideo(videoId)
barPath = invalid
skipSegments = ProcessSkipSegments(skipSegments, showNotifications, categories, service)
barPath = invalid
if skipSegments <> invalid if skipSegments <> invalid
barPath = `tmp:/sponsorblock_bar.png` barPath = `tmp:/sponsorblock_bar.png`
service.GenerateProgressBarBackground(skipSegments, lengthSeconds, barPath) service.GenerateProgressBarBackground(skipSegments, lengthSeconds, barPath)
end if end if
' Usually segment.start and segment.end are equal for poi_highlight
' We pad the duration for poi_highlight segments so that the chapter label
' can be visible when seeking in trickplay.
' Padding poi_highlight is done after generating the progress bar, so that the
' highlight is not too long in the bar.
skipSegments = PadHightlightSegment(skipSegments, lengthSeconds)
' Sort the segments by start time, so we can binary search them later.
if skipSegments <> invalid
skipSegments.SortBy("start")
end if
return { return {
videoId: videoId videoId: videoId
skipSegments: skipSegments skipSegments: skipSegments
barPath: barPath barPath: barPath
} }
end function end function
function ProcessSkipSegments(skipSegments as object, showNotifications as boolean, categories as object, service as SponsorBlock.SponsorBlockService) as object
if skipSegments = invalid
return invalid
end if
processedSegments = []
for each segment in skipSegments
' When a submission reaches the score of -2 or lower, it gets removed and will not appear anymore for users
' https://wiki.sponsor.ajay.app/w/FAQ#How_does_voting_work_and_what_do_certain_amounts_of_votes_mean?
if ValidInt(segment.votes) < -1
continue for
end if
option = GetOptionForSegment(segment, categories)
if option = SponsorBlock.SegmentAction.Disable
continue for
end if
segment.option = option
segment.showNotification = showNotifications and ShouldShowNotification(segment, categories)
if segment.showNotification
if option = SponsorBlock.SegmentAction.AutoSkip
segment.actionText = Tr(Locale.SponsorBlock.Skipped)
else if option = SponsorBlock.SegmentAction.ManualSkip
segment.actionText = Tr(Locale.SponsorBlock.PressOkToSkip)
else
segment.actionText = ""
end if
end if
segmentRange = segment["segment"]
segmentStart = segmentRange[0]
segmentEnd = segmentRange[1]
segment.Delete("segment")
segment.start = segmentStart
segment.end = segmentEnd
segment.title = Tr(ValidString(service.SegmentTitle(segment.category)))
segment.shortTitle = Tr(ValidString(service.SegmentShortTitle(segment.category)))
processedSegments.push(segment)
end for
return processedSegments
end function
function GetOptionForSegment(segment as object, categories as object) as string
category = categories[segment.category]
if not IsAssociativeArray(category)
return false
end if
option = category.option
if StringUtils.IsNullOrEmpty(option)
option = SponsorBlock.SegmentAction.Disable
end if
return option
end function
function ShouldShowNotification(segment as object, categories as object) as boolean
option = GetOptionForSegment(segment, categories)
return option = SponsorBlock.SegmentAction.AutoSkip or option = SponsorBlock.SegmentAction.ManualSkip
end function
function PadHightlightSegment(segments as object, lengthSeconds as integer) as object
for each segment in segments
if not segment.category = "poi_highlight"
continue for
end if
segmentPaddedDuration = 5
if lengthSeconds > 0
if lengthSeconds < 120
segmentPaddedDuration = 1
else if lengthSeconds < 300
segmentPaddedDuration = 2
else if lengthSeconds < 900
segmentPaddedDuration = 5
else
segmentPaddedDuration = 10
end if
end if
segmentDuration = Abs(segment.end - segment.start)
padding = Abs(segmentPaddedDuration - segmentDuration) / 2
segment.start = segment.start - padding
segment.end = segment.end + padding
end for
return segments
end function
@@ -23,6 +23,7 @@ function MarkVideoWatchedTask(input as object) as object
playbackTrackingUrls = InnertubeService.AuthGetPlaybackTrackingUrls(videoId, { playbackTrackingUrls = InnertubeService.AuthGetPlaybackTrackingUrls(videoId, {
accessToken: authToken.token accessToken: authToken.token
onBehalfOfUser: authToken.activeIdentifyToken
cancellation: cancellation cancellation: cancellation
}) })
@@ -38,6 +39,7 @@ function MarkVideoWatchedTask(input as object) as object
markedAsWatched = InnertubeService.AuthMarkVideoWatched(playbackTrackingUrls.videostatsPlaybackUrl, { markedAsWatched = InnertubeService.AuthMarkVideoWatched(playbackTrackingUrls.videostatsPlaybackUrl, {
accessToken: authToken.token accessToken: authToken.token
onBehalfOfUser: authToken.activeIdentifyToken
cancellation: cancellation cancellation: cancellation
}) })
if not markedAsWatched if not markedAsWatched
@@ -67,6 +69,7 @@ function MarkVideoWatchedTask(input as object) as object
watchTime = message.getData() watchTime = message.getData()
InnertubeService.AuthMarkVideoWatchTime(watchTime, playbackTrackingUrls.videostatsWatchtimeUrl, { InnertubeService.AuthMarkVideoWatchTime(watchTime, playbackTrackingUrls.videostatsWatchtimeUrl, {
accessToken: authToken.token accessToken: authToken.token
onBehalfOfUser: authToken.activeIdentifyToken
cancellation: cancellation cancellation: cancellation
}) })
end while end while
@@ -2,6 +2,7 @@ import "pkg:/components/Services/SponsorBlock/Notifications/SponsorBlockNotifica
import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs" import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs"
import "pkg:/source/AsyncTask/AsyncTask.bs" import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs" import "pkg:/source/AsyncTask/Tasks.bs"
import "SponsorBlockSegmentAction.bs"
import "VideoPlayer.bs" import "VideoPlayer.bs"
namespace SponsorBlock namespace SponsorBlock
@@ -12,18 +13,62 @@ namespace SponsorBlock
end if end if
m.sponsorBlockService = new SponsorBlock.SponsorBlockService() m.sponsorBlockService = new SponsorBlock.SponsorBlockService()
PositionChapterLabel()
m.top.trickPlayBar.observeField("visible", FuncName(OnTrickPlayBarVisible))
m.chapterLabelTimer = m.top.findNode("chapterLabelTimer")
m.chapterLabelTimer.observeField("fire", FuncName(OnChapterLabelTimer))
m._sponsorBlockLastTime = 0.0#
' TODO:P1 more precision on when notifications should be visible
' Should notifcations be visible when the video is not fullscreen?
SponsorBlock.SetVisible(m.notifications, m.container.fullscreen) SponsorBlock.SetVisible(m.notifications, m.container.fullscreen)
end function end function
function FetchSponsorBlock(metadata as object) as void
if not m.preferences["sponsorblock.enabled"]
return
end if
if m.sponsorBlockTask <> invalid
m.sponsorBlockTask.cancel = true
end if
m.sponsorBlockTask = AsyncTask.Start(Tasks.SponsorBlockTask, {
metadata: metadata
showNotifications: m.preferences["sponsorblock.show_notifications"]
categories: m.preferences["sponsorblock.categories"]
}, OnSponsorBlockTaskResults)
end function
function OnSponsorBlockTaskResults(output as object) as void
m.sponsorBlockTask = invalid
if output.cancelled or m.onCloseCalled = true
return
end if
if not output.success
error = ErrorUtils.Format(output.error)
LogError(error)
return
end if
skipSegments = output.result.skipSegments
if skipSegments = invalid or skipSegments.Count() = 0
return
end if
m.skipSegments = skipSegments
m.top.seekMode = "accurate"
barPath = output.result.barPath
if barPath <> invalid
m.top.trickPlayBar.trackImageUri = barPath
m.top.trickPlayBar.filledBarBlendColor = "#FF000080"
end if
m.top.ObserveFieldScoped("position", FuncName(OnPositionChangeSkipSponsorBlockSections))
if m.top.hasField("trickPlayPosition")
PositionChapterLabel()
m.chapterLabelTimer = m.top.findNode("chapterLabelTimer")
m.chapterLabelTimer.observeField("fire", FuncName(OnChapterLabelTimer))
m._sponsorBlockLastTimeChapterUpdated = 0.0#
m.top.trickPlayBar.observeField("visible", FuncName(OnTrickPlayBarVisible))
end if
end function
function PositionChapterLabel() function PositionChapterLabel()
m.chapterLabel = m.top.findNode("chapterLabel") m.chapterLabel = m.top.findNode("chapterLabel")
' We move the chapter label under m.top.trickPlayBar ' We move the chapter label under m.top.trickPlayBar
@@ -43,162 +88,136 @@ namespace SponsorBlock
end function end function
function OnChapterLabelTimer() as void function OnChapterLabelTimer() as void
if m.skipSegments = invalid trickPlayPosition = m.top.trickPlayPosition
if m._sponsorBlockLastTimeChapterUpdated = trickPlayPosition
return return
end if end if
' trickPlayPosition is not documented on Roku website, this is why we're checking m._sponsorBlockLastTimeChapterUpdated = trickPlayPosition
if not IsDouble(m.top.trickPlayPosition) UpdateSponsorBlockChapter(trickPlayPosition)
return
end if
if m._sponsorBlockLastTime = m.top.trickPlayPosition
return
end if
m._sponsorBlockLastTime = m.top.trickPlayPosition
UpdateSponsorBlockChapter(m._sponsorBlockLastTime)
end function end function
function UpdateSponsorBlockChapter(time as double) as void function UpdateSponsorBlockChapter(time as double) as void
segments = m.skipSegments segments = m.skipSegments
for each segment in segments segment = FindSegmentByTime(segments, time)
category = segment["category"] if segment = invalid
segmentRange = segment["segment"] m.top.chapter = ""
segmentStart = segmentRange[0] return
segmentEnd = segmentRange[1] end if
m.top.chapter = segment.title
' Usually segmentStart and segmentEnd are equal for poi_highlight
' We pad the duration for poi_highlight segments so that the chapter label
' can be visible when seeking in trickplay
if category = "poi_highlight"
segmentPaddedDuration = 5
duration = m.top.duration
if duration > 0
if duration < 120
segmentPaddedDuration = 1
else if duration < 300
segmentPaddedDuration = 2
else if duration < 900
segmentPaddedDuration = 5
else
segmentPaddedDuration = 10
end if
end if
segmentDuration = Abs(segmentEnd - segmentStart)
padding = Abs(segmentPaddedDuration - segmentDuration) / 2
segmentStart = segmentStart - padding
segmentEnd = segmentEnd + padding
end if
if (segmentStart <= time) and (segmentEnd >= time)
m.top.chapter = Tr(ValidString(m.sponsorBlockService.SegmentTitle(category)))
return
end if
end for
m.top.chapter = ""
end function end function
function FetchSponsorBlock(metadata as object) as void function FindSegmentByTime(segments as object, time as dynamic) as dynamic
if not m.preferences["sponsorblock.enabled"] ' Binary search for the segment that contains the time.
return ' This search sometimes fails if the segments overlap.
end if ' For most cases, this is acceptable, since it is not common for segments to overlap.
low = 0
if m.sponsorBlockTask <> invalid high = segments.Count() - 1
m.sponsorBlockTask.cancel = true while low <= high
end if middle = (low + high) \ 2
segment = segments[middle]
m.sponsorBlockTask = AsyncTask.Start(Tasks.SponsorBlockTask, { metadata: metadata }, OnSponsorBlockTaskResults) if time < segment.start
end function high = middle - 1
else if time > segment.end
function OnSponsorBlockTaskResults(output as object) as void low = middle + 1
m.sponsorBlockTask = invalid else
if output.cancelled or m.onCloseCalled = true return segment
return end if
end if end while
return invalid
if not output.success
error = ErrorUtils.Format(output.error)
LogError(error)
return
end if
skipSegments = output.result.skipSegments
if skipSegments = invalid
return
end if
m.skipSegments = skipSegments
m.top.seekMode = "accurate"
barPath = output.result.barPath
if barPath <> invalid
m.top.trickPlayBar.trackImageUri = barPath
m.top.trickPlayBar.filledBarBlendColor = "#FF000080"
end if
m.top.ObserveFieldScoped("position", FuncName(OnPositionChangeSkipSponsorBlockSections))
end function end function
function OnPositionChangeSkipSponsorBlockSections() as void function OnPositionChangeSkipSponsorBlockSections() as void
segments = m.skipSegments segments = m.skipSegments
if segments = invalid position = m.top.position
segment = FindSegmentByTime(segments, position)
if segment = invalid
return return
end if end if
for each segment in segments action = segment.option
segmentRange = segment["segment"]
segmentStart = segmentRange[0]
segmentEnd = segmentRange[1]
currentPosition = m.top.position
if (segmentStart < currentPosition) and ((segmentEnd - 1) > currentPosition)
action = GetActionForSegment(segment)
if m.preferences["sponsorblock.show_notifications"] = true
SponsorBlock.ShowNotifcation(m.notifications, segment, action)
end if
if action = "AutoSkip" ' If we're close to the end of the segment, we don't want to show
duration = m.top.duration ' a notification, since it is possible this is where we skipped to.
' Sometimes segmentEnd is greater than duration ' Seeking is not super accurate.
if duration > 0 and segmentEnd > duration if segment.showNotification and Abs(segment.end - position) >= 1
segmentEnd = duration SponsorBlock.ShowNotifcation(m.notifications, segment, action)
end if
' If the segment is at the end of the video, skip the video instead of seeking if action = SegmentAction.ManualSkip
if duration > 0 and Abs(segmentEnd - duration) < 2 ' We'll save the segment here, and handle it in case the user
LogInfo("Skipping section:", segment["category"], "at end of video") ' presses the OK button on the notification.
SendSkippedSectionEvent(segment.UUID) m.manualSkipSegment = segment
OnVideoFinished() return
return
else
LogInfo("Skipping section:", segment["category"])
SendSkippedSectionEvent(segment.UUID)
m.top.seek = segmentEnd
return
end if
end if
end if end if
end for end if
if action = SegmentAction.AutoSkip
SkipSegment(segment, position)
end if
end function end function
function GetActionForSegment(segment as object) as dynamic function SkipSegment(segment as object, position as dynamic) as void
category = segment["category"] segmentEnd = segment.end
if category = "sponsor"
return "AutoSkip" duration = m.top.duration
else if category = "poi_highlight" ' Sometimes segmentEnd is greater than duration
return "ManualSkip" if duration > 0 and segmentEnd > duration
else if category = "exclusive_access" segmentEnd = duration
return "ShowOverlay"
else if category = "chapter"
return "ShowOverlay"
end if end if
return ""
' If we're skipping a very short distance, it's not worth it
' since we can cause rebuffering
if Abs(segmentEnd - position) < 2
LogInfo("Skip position is within 2 seconds of segment end, not skipping")
return
end if
' If the segment is at the end of the video, skip the video instead of seeking
if duration > 0 and Abs(segmentEnd - duration) < 2
LogInfo("Skipping section:", segment.category, "at end of video")
OnVideoFinished()
else
LogInfo("Skipping section:", segment.category)
m.top.seek = segmentEnd
end if
SendSkippedSectionEvent(segment.UUID)
end function
function ManualSkipSegment() as boolean
segment = m.manualSkipSegment
if segment = invalid
return false
end if
m.manualSkipSegment = invalid
notification = SponsorBlock.GetCurrentNotification(m.notifications)
if notification = invalid
return false
end if
notificationSegmentId = notification.segmentId
if notificationSegmentId <> segment.UUID
return false
end if
position = m.top.position
if (position < segment.start) or (segment.end < position)
return false
end if
SkipSegment(segment, position)
SponsorBlock.RemoveNotifcation(m.notifications)
return true
end function end function
function SendSkippedSectionEvent(segmentId as string) function SendSkippedSectionEvent(segmentId as string)
AsyncTask.Start(Tasks.SponsorBlockSegmentViewedTask, { segmentId: segmentId }) if m.sponsorSkipEventTask <> invalid
m.sponsorSkipEventTask.cancel = true
end if
m.sponsorSkipEventTask = AsyncTask.Start(Tasks.SponsorBlockSegmentViewedTask, { segmentId: segmentId })
end function end function
end namespace end namespace
@@ -0,0 +1,16 @@
namespace SponsorBlock
enum SegmentAction
' Disable: we do not care about this segment.
Disable = "disable"
' AutoSkip: we want to skip this segment automatically.
AutoSkip = "auto_skip"
' ManualSkip: we want to skip this segment manually, by showing a notification.
' The user would have to press the skip button on the notification.
ManualSkip = "manual_skip"
' ShowInSeekbar: we want to show this segment in the seekbar, but not skip it.
' No notification will be shown
ShowInSeekbar = "show_in_seekbar"
end enum
end namespace
@@ -24,7 +24,7 @@ function VideoContentTask(input as object) as object
if backend = "playlet" if backend = "playlet"
metadata = InnertubeService.GetVideoMetadata(contentNode.videoId, { metadata = InnertubeService.GetVideoMetadata(contentNode.videoId, {
"cancellation": m.top.cancellation "cancellation": m.top.cancellation
"ctt": loungeServiceNode.ctt "credentialTransferToken": loungeServiceNode.credentialTransferToken
"visitorData": innertubeNode.visitorData "visitorData": innertubeNode.visitorData
}) })
else else
@@ -518,6 +518,10 @@ function HideUIAndStopTimer()
end function end function
function HandleOKPress() as boolean function HandleOKPress() as boolean
if SponsorBlock.ManualSkipSegment()
return false
end if
if not m.showUIEnabled if not m.showUIEnabled
return false return false
end if end if
@@ -19,7 +19,7 @@
</interface> </interface>
<children> <children>
<Label id="chapterLabel" width="350" height="25" horizAlign="center" vertAlign="center" font="font:SmallestSystemFont" /> <Label id="chapterLabel" width="350" height="25" horizAlign="center" vertAlign="center" font="font:SmallestSystemFont" />
<Timer id="chapterLabelTimer" repeat="true" duration="0.25" /> <Timer id="chapterLabelTimer" repeat="true" duration="0.5" />
<Animation id="minimizeAnimation" duration="0.3" optional="true"> <Animation id="minimizeAnimation" duration="0.3" optional="true">
<FloatFieldInterpolator id="widthInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.width" /> <FloatFieldInterpolator id="widthInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.width" />
<FloatFieldInterpolator id="heightInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.height" /> <FloatFieldInterpolator id="heightInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.height" />
@@ -20,8 +20,8 @@
<function name="PlayWithContent" /> <function name="PlayWithContent" />
</interface> </interface>
<children> <children>
<SimpleLabel <!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
text="Dev Player!" <SimpleLabel text="Dev Player!"
color="#FF0000" color="#FF0000"
fontUri="font:SmallestBoldSystemFont" fontUri="font:SmallestBoldSystemFont"
horizOrigin="right" horizOrigin="right"
@@ -152,7 +152,7 @@ namespace VideoQueueUtils
end if end if
LogInfo(`Playing next recommended video (${videoId})`) LogInfo(`Playing next recommended video (${videoId})`)
instance = invidiousNode@.GetCurrentInstance() instance = invidiousNode@.GetInstance()
node = InvidiousContent.ToVideoContentNode(invalid, recommendedVideo, instance) node = InvidiousContent.ToVideoContentNode(invalid, recommendedVideo, instance)
videoQueue.playVideo = node videoQueue.playVideo = node
return true return true
@@ -8,7 +8,9 @@ namespace Http
function new(server as object) function new(server as object)
super() super()
m.innertube = server.task.innertube task = server.task
m.innertube = task.innertube
m.preferences = task.preferences
end function end function
@get("/playlet-invidious-backend/authorize_token") @get("/playlet-invidious-backend/authorize_token")
@@ -65,7 +67,14 @@ namespace Http
options = { options = {
"accessToken": accessToken.Mid("Bearer ".Len()) "accessToken": accessToken.Mid("Bearer ".Len())
"disableShorts": m.preferences["content_feed.disable_shorts"]
} }
activeIdentifyToken = request.query.activeIdentifyToken
if not StringUtils.IsNullOrEmpty(activeIdentifyToken)
options.onBehalfOfUser = activeIdentifyToken
end if
continuation = request.query.continuation continuation = request.query.continuation
if not StringUtils.IsNullOrEmpty(continuation) if not StringUtils.IsNullOrEmpty(continuation)
options.continuation = continuation options.continuation = continuation
@@ -138,6 +147,12 @@ namespace Http
options = { options = {
"accessToken": accessToken.Mid("Bearer ".Len()) "accessToken": accessToken.Mid("Bearer ".Len())
} }
activeIdentifyToken = request.query.activeIdentifyToken
if not StringUtils.IsNullOrEmpty(activeIdentifyToken)
options.onBehalfOfUser = activeIdentifyToken
end if
continuation = request.query.continuation continuation = request.query.continuation
if not StringUtils.IsNullOrEmpty(continuation) if not StringUtils.IsNullOrEmpty(continuation)
options.continuation = continuation options.continuation = continuation
@@ -185,6 +200,11 @@ namespace Http
"accessToken": accessToken.Mid("Bearer ".Len()) "accessToken": accessToken.Mid("Bearer ".Len())
} }
activeIdentifyToken = request.query.activeIdentifyToken
if not StringUtils.IsNullOrEmpty(activeIdentifyToken)
options.onBehalfOfUser = activeIdentifyToken
end if
continuation = request.query.continuation continuation = request.query.continuation
hasContinuation = not StringUtils.IsNullOrEmpty(continuation) hasContinuation = not StringUtils.IsNullOrEmpty(continuation)
if hasContinuation if hasContinuation
@@ -247,6 +267,7 @@ namespace Http
raw = request.query.raw <> invalid raw = request.query.raw <> invalid
options = { options = {
"disableShorts": m.preferences["content_feed.disable_shorts"]
raw: raw raw: raw
type: request.query.type type: request.query.type
} }
@@ -295,8 +316,14 @@ namespace Http
options = { options = {
"accessToken": accessToken.Mid("Bearer ".Len()) "accessToken": accessToken.Mid("Bearer ".Len())
"disableShorts": m.preferences["content_feed.disable_shorts"]
} }
activeIdentifyToken = request.query.activeIdentifyToken
if not StringUtils.IsNullOrEmpty(activeIdentifyToken)
options.onBehalfOfUser = activeIdentifyToken
end if
continuation = request.query.continuation continuation = request.query.continuation
if not StringUtils.IsNullOrEmpty(continuation) if not StringUtils.IsNullOrEmpty(continuation)
options.continuation = continuation options.continuation = continuation
@@ -360,6 +387,7 @@ namespace Http
raw = request.query.raw <> invalid raw = request.query.raw <> invalid
options = { options = {
"disableShorts": m.preferences["content_feed.disable_shorts"]
raw: raw raw: raw
} }
@@ -583,6 +611,11 @@ namespace Http
accessToken = request.headers["authorization"] accessToken = request.headers["authorization"]
if not StringUtils.IsNullOrEmpty(accessToken) and accessToken.StartsWith("Bearer ") if not StringUtils.IsNullOrEmpty(accessToken) and accessToken.StartsWith("Bearer ")
options["accessToken"] = accessToken.Mid("Bearer ".Len()) options["accessToken"] = accessToken.Mid("Bearer ".Len())
activeIdentifyToken = request.query.activeIdentifyToken
if not StringUtils.IsNullOrEmpty(activeIdentifyToken)
options.onBehalfOfUser = activeIdentifyToken
end if
end if end if
if playlistId.StartsWith("RD") if playlistId.StartsWith("RD")
@@ -775,6 +808,11 @@ namespace Http
"accessToken": accessToken.Mid("Bearer ".Len()) "accessToken": accessToken.Mid("Bearer ".Len())
} }
activeIdentifyToken = request.query.activeIdentifyToken
if not StringUtils.IsNullOrEmpty(activeIdentifyToken)
options.onBehalfOfUser = activeIdentifyToken
end if
result = InnertubeService.SubscribeToChannel(channelId, options) result = InnertubeService.SubscribeToChannel(channelId, options)
if result.success <> true if result.success <> true
@@ -830,6 +868,11 @@ namespace Http
"accessToken": accessToken.Mid("Bearer ".Len()) "accessToken": accessToken.Mid("Bearer ".Len())
} }
activeIdentifyToken = request.query.activeIdentifyToken
if not StringUtils.IsNullOrEmpty(activeIdentifyToken)
options.onBehalfOfUser = activeIdentifyToken
end if
result = InnertubeService.UnsubscribeFromChannel(channelId, options) result = InnertubeService.UnsubscribeFromChannel(channelId, options)
if result.success <> true if result.success <> true
@@ -65,7 +65,8 @@ namespace Http
if keysDict["invidious"] = true if keysDict["invidious"] = true
state["invidious"] = { state["invidious"] = {
current_instance: m.invidiousNode@.GetCurrentInstance() instance: m.invidiousNode@.GetInstance()
invidious_instance: m.invidiousNode@.GetInvidiousInstance()
auth_url: m.invidiousNode@.GetAuthorizeTokenLink() auth_url: m.invidiousNode@.GetAuthorizeTokenLink()
} }
end if end if
+60
View File
@@ -53,6 +53,20 @@
}, },
], ],
}, },
{
displayText: "Content Feed",
key: "content_feed",
description: "Feed preferences",
children: [
{
displayText: "Disable Shorts",
key: "content_feed.disable_shorts",
description: "Disable short videos.",
type: "boolean",
defaultValue: false,
},
],
},
{ {
displayText: "Invidious", displayText: "Invidious",
key: "invidious", key: "invidious",
@@ -114,6 +128,52 @@
type: "boolean", type: "boolean",
defaultValue: true, defaultValue: true,
}, },
{
displayText: "Categories",
key: "sponsorblock.categories",
description: "Configure which segments to skip",
type: "assocarray",
visibility: "tv",
rokuComponent: "SponsorBlockCategoriesControl",
defaultValue: {
// TODO:P1 support for exclusive_access and chapter
// TODO:P1 support for manual skip for poi_highlight
sponsor: {
option: "auto_skip",
},
selfpromo: {
option: "manual_skip",
},
interaction: {
option: "manual_skip",
},
poi_highlight: {
option: "show_in_seekbar",
},
intro: {
option: "manual_skip",
},
outro: {
option: "manual_skip",
},
preview: {
option: "manual_skip",
},
filler: {
option: "manual_skip",
},
music_offtopic: {
option: "manual_skip",
},
},
},
{
displayText: "Categories",
key: "sponsorblock.categories",
description: "Configure which segments to skip",
visibility: "web",
svelteComponent: "SponsorBlockCategoriesControl",
},
], ],
}, },
{ {
@@ -1,116 +1,70 @@
{ {
serverAddress: 'https://sponsor.ajay.app', serverAddress: "https://sponsor.ajay.app",
categoryList: [ categoryList: [
'sponsor', "sponsor",
'selfpromo', "selfpromo",
'exclusive_access', "interaction",
'interaction', "poi_highlight",
'poi_highlight', "intro",
'intro', "outro",
'outro', "preview",
'preview', "filler",
'filler', "music_offtopic",
'chapter',
'music_offtopic',
], ],
categories: { categories: {
sponsor: { sponsor: {
title: 'Sponsor', title: "Sponsor",
short_title: 'Sponsor', short_title: "Sponsor",
categorySupport: [ options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
'skip', color: "#00D400B3",
'mute',
'full',
],
color: '#00D400B3',
}, },
selfpromo: { selfpromo: {
title: 'Unpaid/Self Promotion', title: "Unpaid/Self Promotion",
short_title: 'Unpaid/Self Promotion', short_title: "Unpaid/Self Promotion",
categorySupport: [ options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
'skip', color: "#FFFF00B3",
'mute',
'full',
],
color: '#FFFF00B3',
},
exclusive_access: {
title: 'Exclusive Access',
short_title: 'Exclusive Access',
categorySupport: [
'full',
],
color: '#008A5CB3',
}, },
interaction: { interaction: {
title: 'Interaction Reminder (Subscribe)', title: "Interaction Reminder (Subscribe)",
short_title: 'Interaction Reminder', short_title: "Interaction Reminder",
categorySupport: [ options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
'skip', color: "#CC00FFB3",
'mute',
],
color: '#CC00FFB3',
}, },
poi_highlight: { poi_highlight: {
title: 'Highlight', title: "Highlight",
short_title: 'Highlight', short_title: "Highlight",
categorySupport: [ options: ["show_in_seekbar", "disable"],
'poi', color: "#FF1684B3",
],
color: '#FF1684B3',
}, },
intro: { intro: {
title: 'Intermission/Intro Animation', title: "Intermission/Intro Animation",
short_title: 'Intermission', short_title: "Intermission",
categorySupport: [ options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
'skip', color: "#00FFFFB3",
'mute',
],
color: '#00FFFFB3',
}, },
outro: { outro: {
title: 'Endcards/Credits', title: "Endcards/Credits",
short_title: 'Endcards/Credits', short_title: "Endcards/Credits",
categorySupport: [ options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
'skip', color: "#0202EDB3",
'mute',
],
color: '#0202EDB3',
}, },
preview: { preview: {
title: 'Preview/Recap/Hook', title: "Preview/Recap/Hook",
// Note: short title renamed from "Preview/Recap/Hook" to "Preview/Recap" to fit in the UI short_title: "Preview/Recap",
short_title: 'Preview/Recap', options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
categorySupport: [ color: "#008FD6B3",
'skip',
'mute',
],
color: '#008FD6B3',
}, },
filler: { filler: {
title: 'Filler Tangent/Jokes', title: "Filler Tangent/Jokes",
short_title: 'Filler', short_title: "Filler",
categorySupport: [ options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
'skip', color: "#7300FFE6",
'mute',
],
color: '#7300FFE6',
},
chapter: {
title: 'Chapter',
short_title: 'Chapter',
categorySupport: [
'chapter',
],
color: '#FFFFFFC8',
}, },
music_offtopic: { music_offtopic: {
title: 'Music: Non-Music Section', title: "Music: Non-Music Section",
short_title: 'Non-Music', short_title: "Non-Music",
categorySupport: [ options: ["auto_skip", "manual_skip", "show_in_seekbar", "disable"],
'skip', color: "#FF9900B3",
],
color: '#FF9900B3',
}, },
}, },
} }
@@ -1284,5 +1284,49 @@
<source>Recommended</source> <source>Recommended</source>
<translation>Empfohlen</translation> <translation>Empfohlen</translation>
</message> </message>
<message>
<source>Disable short videos.</source>
<translation>Kurze Videos ausblenden.</translation>
</message>
<message>
<source>Disable Shorts</source>
<translation>Shorts ausblenden</translation>
</message>
<message>
<source>Backend</source>
<translation>Backend</translation>
</message>
<message>
<source>Backend preferences</source>
<translation>Backend-Einstellungen</translation>
</message>
<message>
<source>Selected backend</source>
<translation>Ausgewähltes Backend</translation>
</message>
<message>
<source>The backend used for browsing and playing videos.</source>
<translation>Das für das Durchstöbern und Anschauen von Videos genutzte Backend.</translation>
</message>
<message>
<source>Content Feed</source>
<translation>Inhalts-Feed</translation>
</message>
<message>
<source>Feed preferences</source>
<translation>Feed-Einstellungen</translation>
</message>
<message>
<source>Disclaimer</source>
<translation>Haftungsausschluss</translation>
</message>
<message>
<source>Error</source>
<translation>Fehler</translation>
</message>
<message>
<source>Login to YouTube</source>
<translation>Bei YouTube anmelden</translation>
</message>
</context> </context>
</TS> </TS>
@@ -264,6 +264,42 @@
<source>Failed to get session data. Please restart Playlet to use the cast function.</source> <source>Failed to get session data. Please restart Playlet to use the cast function.</source>
<translation>Failed to get session data. Please restart Playlet to use the cast function.</translation> <translation>Failed to get session data. Please restart Playlet to use the cast function.</translation>
</message> </message>
<message>
<source>Select a service to login</source>
<translation>Select a service to login</translation>
</message>
<message>
<source>Login to YouTube</source>
<translation>Login to YouTube</translation>
</message>
<message>
<source>Open the link %1 and enter the following code:</source>
<translation>Open the link %1 and enter the following code:</translation>
</message>
<message>
<source>Disclaimer</source>
<translation>Disclaimer</translation>
</message>
<message>
<source>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.</source>
<translation>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.</translation>
</message>
<message>
<source>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.</source>
<translation>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.</translation>
</message>
<message>
<source>Use responsibly, especially if your YouTube account is tied to business or monetization.</source>
<translation>Use responsibly, especially if your YouTube account is tied to business or monetization.</translation>
</message>
<message>
<source>Who&#39;s watching?</source>
<translation>Who&#39;s watching?</translation>
</message>
<message>
<source>No valid accounts found for YouTube login.</source>
<translation>No valid accounts found for YouTube login.</translation>
</message>
<message> <message>
<source>Invidious custom instance</source> <source>Invidious custom instance</source>
<translation>Invidious custom instance</translation> <translation>Invidious custom instance</translation>
@@ -320,6 +356,10 @@
<source>Success</source> <source>Success</source>
<translation>Success</translation> <translation>Success</translation>
</message> </message>
<message>
<source>Error</source>
<translation>Error</translation>
</message>
<message> <message>
<source>Refresh</source> <source>Refresh</source>
<translation>Refresh</translation> <translation>Refresh</translation>
@@ -768,6 +808,22 @@
<source>The backend used for browsing and playing videos.</source> <source>The backend used for browsing and playing videos.</source>
<translation>The backend used for browsing and playing videos.</translation> <translation>The backend used for browsing and playing videos.</translation>
</message> </message>
<message>
<source>Content Feed</source>
<translation>Content Feed</translation>
</message>
<message>
<source>Feed preferences</source>
<translation>Feed preferences</translation>
</message>
<message>
<source>Disable Shorts</source>
<translation>Disable Shorts</translation>
</message>
<message>
<source>Disable short videos.</source>
<translation>Disable short videos.</translation>
</message>
<message> <message>
<source>Invidious preferences</source> <source>Invidious preferences</source>
<translation>Invidious preferences</translation> <translation>Invidious preferences</translation>
@@ -828,6 +884,18 @@
<source>Show notifications when a segment is skipped</source> <source>Show notifications when a segment is skipped</source>
<translation>Show notifications when a segment is skipped</translation> <translation>Show notifications when a segment is skipped</translation>
</message> </message>
<message>
<source>Categories</source>
<translation>Categories</translation>
</message>
<message>
<source>Configure which segments to skip</source>
<translation>Configure which segments to skip</translation>
</message>
<message>
<source>Select option for %1</source>
<translation>Select option for %1</translation>
</message>
<message> <message>
<source>Search History</source> <source>Search History</source>
<translation>Search History</translation> <translation>Search History</translation>
@@ -948,6 +1016,26 @@
<source>Skipped</source> <source>Skipped</source>
<translation>Skipped</translation> <translation>Skipped</translation>
</message> </message>
<message>
<source>Press OK to skip</source>
<translation>Press OK to skip</translation>
</message>
<message>
<source>Disable</source>
<translation>Disable</translation>
</message>
<message>
<source>Auto Skip</source>
<translation>Auto Skip</translation>
</message>
<message>
<source>Manual Skip</source>
<translation>Manual Skip</translation>
</message>
<message>
<source>Show in Seekbar</source>
<translation>Show in Seekbar</translation>
</message>
<message> <message>
<source>Sponsor</source> <source>Sponsor</source>
<translation>Sponsor</translation> <translation>Sponsor</translation>
+2 -2
View File
@@ -2,8 +2,8 @@ title=PlayletLib
# Do not update version manually, it is auto updated from package.json # Do not update version manually, it is auto updated from package.json
major_version=0 major_version=0
minor_version=38 minor_version=40
build_version=00002 build_version=00000
ui_resolutions=hd ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p uri_resolution_autosub=$$RES$$,480p,720p,1080p
@@ -14,9 +14,10 @@ namespace AsyncTask
task.id = id task.id = id
task.input = input task.input = input
m[`asynctask_${id}`] = task if callback <> invalid
m[`asynctask_${id}_callback`] = callback m[`asynctask_${id}_callback`] = callback
task.ObserveFieldScoped("state", FuncName(internal_OnTaskState)) task.ObserveFieldScoped("state", FuncName(internal_OnTaskState))
end if
return task return task
end function end function
@@ -39,9 +40,6 @@ namespace AsyncTask
end if end if
end if end if
task.input = invalid
task.output = invalid
m.delete(`asynctask_${id}`)
m.delete(`asynctask_${id}_callback`) m.delete(`asynctask_${id}_callback`)
end function end function
+25
View File
@@ -86,6 +86,16 @@ namespace Locale
LoungeFailedToGetLoungeToken = "Failed to get lounge token. Please restart Playlet to use the cast function." LoungeFailedToGetLoungeToken = "Failed to get lounge token. Please restart Playlet to use the cast function."
LoungeInvalidResponse = "Invalid response: %1" LoungeInvalidResponse = "Invalid response: %1"
LoungeFailedToGetSessionData = "Failed to get session data. Please restart Playlet to use the cast function." LoungeFailedToGetSessionData = "Failed to get session data. Please restart Playlet to use the cast function."
' YouTube login
SelectServiceToLogin = "Select a service to login"
LoginToYouTube = "Login to YouTube"
OpenLinkAndEnterFollowingCode = "Open the link %1 and enter the following code:"
Disclaimer = "Disclaimer"
YouTubeLoginDisclaimer1 = "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."
YouTubeLoginDisclaimer2 = "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."
YouTubeLoginDisclaimer3 = "Use responsibly, especially if your YouTube account is tied to business or monetization."
WhosWatching = "Who's watching?"
NoValidAccountsFound = "No valid accounts found for YouTube login."
end enum end enum
@locale @locale
@@ -106,6 +116,7 @@ namespace Locale
Yes = "Yes" Yes = "Yes"
No = "No" No = "No"
Success = "Success" Success = "Success"
Error = "Error"
end enum end enum
@locale @locale
@@ -250,6 +261,11 @@ namespace Locale
SelectedBackend = "Selected backend" SelectedBackend = "Selected backend"
SelectedBackendDescription = "The backend used for browsing and playing videos." SelectedBackendDescription = "The backend used for browsing and playing videos."
ContentFeed = "Content Feed"
ContentPreferences = "Feed preferences"
DisableShorts = "Disable Shorts"
DisableShortsDescription = "Disable short videos."
' "Invidious" is used as node id, so we can't use it before refactoring node ids. ' "Invidious" is used as node id, so we can't use it before refactoring node ids.
' Either way, Invidious doesn't translate, so it's fine to skip it here ' Either way, Invidious doesn't translate, so it's fine to skip it here
' Invidious = "Invidious" ' Invidious = "Invidious"
@@ -269,6 +285,9 @@ namespace Locale
EnabledDescription = "Enable SponsorBlock" EnabledDescription = "Enable SponsorBlock"
ShowNotifications = "Show notifications" ShowNotifications = "Show notifications"
ShowNotificationsDescription = "Show notifications when a segment is skipped" ShowNotificationsDescription = "Show notifications when a segment is skipped"
Categories = "Categories"
CategoriesDescription = "Configure which segments to skip"
SelectOptionFor = "Select option for %1"
SearchHistory = "Search History" SearchHistory = "Search History"
SearchHistoryPreferences = "Search history preferences" SearchHistoryPreferences = "Search history preferences"
@@ -317,6 +336,12 @@ namespace Locale
@locale @locale
enum SponsorBlock enum SponsorBlock
Skipped = "Skipped" Skipped = "Skipped"
PressOkToSkip = "Press OK to skip"
Disable = "Disable"
AutoSkip = "Auto Skip"
ManualSkip = "Manual Skip"
ShowInSeekbar = "Show in Seekbar"
SponsorTitle = "Sponsor" SponsorTitle = "Sponsor"
SelfPromoTitle = "Unpaid/Self Promotion" SelfPromoTitle = "Unpaid/Self Promotion"
+11 -12
View File
@@ -1,24 +1,23 @@
namespace OptionUtils namespace OptionUtils
function Get(opts as object, key as string, passthroughFunction = invalid as dynamic) as dynamic function Get(opts as object, key as string) as dynamic
if opts = invalid if opts = invalid
if passthroughFunction = invalid return invalid
return invalid end if
end if
return passthroughFunction(invalid) return opts[key]
end function
function GetOrDefault(opts as object, key as string, defaultValue as dynamic) as dynamic
if opts = invalid or not opts.DoesExist(key)
return defaultValue
end if end if
value = opts[key] value = opts[key]
if value = invalid if value = invalid
if passthroughFunction = invalid return defaultValue
return invalid
end if
return passthroughFunction(invalid)
end if end if
if passthroughFunction <> invalid
return passthroughFunction(value)
end if
return value return value
end function end function
+19 -18
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-web", "name": "playlet-web",
"version": "0.38.2", "version": "0.40.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-web", "name": "playlet-web",
"version": "0.38.2", "version": "0.40.0",
"devDependencies": { "devDependencies": {
"@sveltejs/vite-plugin-svelte": "^5.0.3", "@sveltejs/vite-plugin-svelte": "^5.0.3",
"@tailwindcss/typography": "^0.5.16", "@tailwindcss/typography": "^0.5.16",
@@ -16,12 +16,12 @@
"daisyui": "^4.12.23", "daisyui": "^4.12.23",
"dotenv": "^16.5.0", "dotenv": "^16.5.0",
"ip": "^2.0.1", "ip": "^2.0.1",
"postcss": "^8.5.3", "postcss": "^8.5.4",
"svelte": "^5.30.1", "svelte": "^5.33.10",
"svelte-check": "^4.2.1", "svelte-check": "^4.2.1",
"svelte-preprocess": "^6.0.3", "svelte-preprocess": "^6.0.3",
"tailwindcss": "^3.4.17", "tailwindcss": "^3.4.17",
"terser": "^5.39.2", "terser": "^5.40.0",
"tslib": "^2.8.1", "tslib": "^2.8.1",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"vite": "^6.3.5", "vite": "^6.3.5",
@@ -3627,9 +3627,9 @@
} }
}, },
"node_modules/nanoid": { "node_modules/nanoid": {
"version": "3.3.8", "version": "3.3.11",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz",
"integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
@@ -3637,6 +3637,7 @@
"url": "https://github.com/sponsors/ai" "url": "https://github.com/sponsors/ai"
} }
], ],
"license": "MIT",
"bin": { "bin": {
"nanoid": "bin/nanoid.cjs" "nanoid": "bin/nanoid.cjs"
}, },
@@ -3766,9 +3767,9 @@
} }
}, },
"node_modules/postcss": { "node_modules/postcss": {
"version": "8.5.3", "version": "8.5.4",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.4.tgz",
"integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==", "integrity": "sha512-QSa9EBe+uwlGTFmHsPKokv3B/oEMQZxfqW0QqNCyhpa6mB1afzulwn8hihglqAb2pOw+BJgNlmXQ8la2VeHB7w==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
@@ -3786,7 +3787,7 @@
], ],
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"nanoid": "^3.3.8", "nanoid": "^3.3.11",
"picocolors": "^1.1.1", "picocolors": "^1.1.1",
"source-map-js": "^1.2.1" "source-map-js": "^1.2.1"
}, },
@@ -4371,9 +4372,9 @@
} }
}, },
"node_modules/svelte": { "node_modules/svelte": {
"version": "5.30.1", "version": "5.33.10",
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.30.1.tgz", "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.33.10.tgz",
"integrity": "sha512-QIYtKnJGkubWXtNkrUBKVCvyo9gjcccdbnvXfwsGNhvbeNNdQjRDTa/BiQcJ2kWXbXPQbWKyT7CUu53KIj1rfw==", "integrity": "sha512-/yArPQIBoQS2p86LKnvJywOXkVHeEXnFgrDPSxkEfIAEkykopYuy2bF6UUqHG4IbZlJD6OurLxJT8Kn7kTk9WA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -4592,9 +4593,9 @@
} }
}, },
"node_modules/terser": { "node_modules/terser": {
"version": "5.39.2", "version": "5.40.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.39.2.tgz", "resolved": "https://registry.npmjs.org/terser/-/terser-5.40.0.tgz",
"integrity": "sha512-yEPUmWve+VA78bI71BW70Dh0TuV4HHd+I5SHOAfS1+QBOmvmCiiffgjR8ryyEd3KIfvPGFqoADt8LdQ6XpXIvg==", "integrity": "sha512-cfeKl/jjwSR5ar7d0FGmave9hFGJT8obyo0z+CrQOylLDbk7X81nPU6vq9VORa5jU30SkDnT2FXjLbR8HLP+xA==",
"dev": true, "dev": true,
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"dependencies": { "dependencies": {
+5 -5
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-web", "name": "playlet-web",
"version": "0.38.2", "version": "0.40.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json" "lint": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings"
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/vite-plugin-svelte": "^5.0.3", "@sveltejs/vite-plugin-svelte": "^5.0.3",
@@ -17,12 +17,12 @@
"daisyui": "^4.12.23", "daisyui": "^4.12.23",
"dotenv": "^16.5.0", "dotenv": "^16.5.0",
"ip": "^2.0.1", "ip": "^2.0.1",
"postcss": "^8.5.3", "postcss": "^8.5.4",
"svelte": "^5.30.1", "svelte": "^5.33.10",
"svelte-check": "^4.2.1", "svelte-check": "^4.2.1",
"svelte-preprocess": "^6.0.3", "svelte-preprocess": "^6.0.3",
"tailwindcss": "^3.4.17", "tailwindcss": "^3.4.17",
"terser": "^5.39.2", "terser": "^5.40.0",
"tslib": "^2.8.1", "tslib": "^2.8.1",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"vite": "^6.3.5", "vite": "^6.3.5",
+6 -1
View File
@@ -11,6 +11,7 @@
playletStateStore, playletStateStore,
preferencesModelStore, preferencesModelStore,
searchHistoryStore, searchHistoryStore,
sponsorBlockConfigStore,
userPreferencesStore, userPreferencesStore,
} from "lib/Stores"; } from "lib/Stores";
import BottomNavigation from "lib/BottomNavigation.svelte"; import BottomNavigation from "lib/BottomNavigation.svelte";
@@ -24,7 +25,7 @@
import RemoteControlScreen from "lib/Screens/RemoteControlScreen.svelte"; import RemoteControlScreen from "lib/Screens/RemoteControlScreen.svelte";
import { fetchLocale } from "lib/Api/Locale"; import { fetchLocale } from "lib/Api/Locale";
onMount(async () => { onMount(() => {
PlayletApi.getState().then((value) => { PlayletApi.getState().then((value) => {
playletStateStore.set(value); playletStateStore.set(value);
fetchLocale(value.device?.current_locale); fetchLocale(value.device?.current_locale);
@@ -38,6 +39,10 @@
homeLayoutFileStore.set(value); homeLayoutFileStore.set(value);
}); });
PlayletApi.getSponsorBlockConfigFile().then((value) => {
sponsorBlockConfigStore.set(value);
});
PlayletApi.getInvidiousVideoApiFile().then((apiDefinitions) => { PlayletApi.getInvidiousVideoApiFile().then((apiDefinitions) => {
invidiousVideoApiStore.set(apiDefinitions); invidiousVideoApiStore.set(apiDefinitions);
}); });
+2 -2
View File
@@ -1,7 +1,7 @@
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
width="82" width="65"
height="32" height="25"
viewBox="0 0 98.161 37.571" viewBox="0 0 98.161 37.571"
> >
<g transform="translate(-22.26 -34.716)"> <g transform="translate(-22.26 -34.716)">

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

+2 -2
View File
@@ -1,7 +1,7 @@
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
width="82" width="65"
height="32" height="25"
viewBox="0 0 98.161 37.571" viewBox="0 0 98.161 37.571"
> >
<g transform="translate(-22.26 -34.716)"> <g transform="translate(-22.26 -34.716)">

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

+5
View File
@@ -34,6 +34,11 @@ export class PlayletApi {
return await response.json(); return await response.json();
} }
static async getSponsorBlockConfigFile() {
const response = await fetch(`${PlayletApi.host()}/config/sponsorblock_config.json5`);
return await response.json();
}
static async getInvidiousVideoApiFile() { static async getInvidiousVideoApiFile() {
const response = await fetch(`${PlayletApi.host()}/config/invidious_video_api.yaml`); const response = await fetch(`${PlayletApi.host()}/config/invidious_video_api.yaml`);
return await response.json(); return await response.json();
@@ -31,6 +31,12 @@
} else { } else {
setScreenNameInUrl("home"); setScreenNameInUrl("home");
} }
window.addEventListener("hashchange", OnWindowHashChange);
return () => {
window.removeEventListener("hashchange", OnWindowHashChange);
};
}); });
function getScreenNameInUrl(): AppState["screen"] | undefined { function getScreenNameInUrl(): AppState["screen"] | undefined {
@@ -47,6 +53,16 @@
function setScreenNameInUrl(screen: AppState["screen"]) { function setScreenNameInUrl(screen: AppState["screen"]) {
window.location.hash = screen; window.location.hash = screen;
} }
function OnWindowHashChange() {
const screen = getScreenNameInUrl();
if (screen && screen !== $appStateStore.screen) {
appStateStore.update((state) => {
state.screen = screen;
return state;
});
}
}
</script> </script>
<!-- https://github.com/saadeghi/daisyui/issues/1732#issuecomment-1747818200 --> <!-- https://github.com/saadeghi/daisyui/issues/1732#issuecomment-1747818200 -->
+7 -7
View File
@@ -24,19 +24,19 @@
let invidiousApi = new InvidiousApi(); let invidiousApi = new InvidiousApi();
playletStateStore.subscribe((value) => { playletStateStore.subscribe((value) => {
invidiousApi.instance = value?.invidious?.current_instance; invidiousApi.instance = value?.invidious?.instance;
}); });
onMount(async () => { onMount(() => {
document.body.addEventListener("drop", onDrop); document.body.addEventListener("drop", onDrop);
document.body.addEventListener("dragover", onDragOver); document.body.addEventListener("dragover", onDragOver);
document.body.addEventListener("paste", onPaste); document.body.addEventListener("paste", onPaste);
});
onDestroy(() => { return () => {
document.body.removeEventListener("drop", onDrop); document.body.removeEventListener("drop", onDrop);
document.body.removeEventListener("dragover", onDragOver); document.body.removeEventListener("dragover", onDragOver);
document.body.removeEventListener("paste", onPaste); document.body.removeEventListener("paste", onPaste);
};
}); });
async function onPaste(event) { async function onPaste(event) {
+13 -10
View File
@@ -54,22 +54,25 @@
<div class="navbar bg-base-100 sticky top-0 z-40"> <div class="navbar bg-base-100 sticky top-0 z-40">
<div class="flex-1"> <div class="flex-1">
<button on:click={() => ExternalControlProtocol.launchApp(appId)}> <div class="flex flex-col justify-center items-center">
{#if $appThemeStore === "dark"} <button on:click={() => ExternalControlProtocol.launchApp(appId)}>
<PlayletLogoDark /> {#if $appThemeStore === "dark"}
{:else} <PlayletLogoDark />
<PlayletLogoLight /> {:else}
{/if} <PlayletLogoLight />
</button> {/if}
<h4 class="label brightness-75">{version}</h4> </button>
<div class="text-xs brightness-75">{version}</div>
</div>
</div> </div>
<div class="flex-none"> <div class="flex-none">
<ThemeSelect /> <ThemeSelect />
{#if currentProfile && currentProfile.username} {#if currentProfile && currentProfile.username}
<div class="badge badge-outline"> <div class="badge badge-outline">
<span> <span>
{currentProfile.username.length > 5 <!-- TODO:P2 use text-ellipsis -->
? `${currentProfile.username.slice(0, 5)}…` {currentProfile.username.length > 10
? `${currentProfile.username.slice(0, 10)}…`
: currentProfile.username} : currentProfile.username}
</span> </span>
</div> </div>
+2 -1
View File
@@ -32,7 +32,8 @@
playletStateStore.subscribe((value) => { playletStateStore.subscribe((value) => {
authUrl = value?.invidious?.auth_url; authUrl = value?.invidious?.auth_url;
currentInstance = value?.invidious?.current_instance || ""; currentInstance =
value?.invidious?.invidious_instance || value?.invidious?.instance || "";
if (currentInstance === `${host()}/playlet-invidious-backend`) { if (currentInstance === `${host()}/playlet-invidious-backend`) {
const trFn = get(translate); const trFn = get(translate);
currentInstanceName = trFn("Playlet built-in backend"); currentInstanceName = trFn("Playlet built-in backend");
@@ -20,19 +20,18 @@
button.addEventListener("mouseup", pressKeyUp); button.addEventListener("mouseup", pressKeyUp);
button.addEventListener("mouseleave", onMouseLeave); button.addEventListener("mouseleave", onMouseLeave);
} }
});
onDestroy(() => { return () => {
const isTouchDevice = "ontouchstart" in document.documentElement; if (isTouchDevice) {
if (isTouchDevice) { button.removeEventListener("touchstart", pressKeyDown);
button.removeEventListener("touchstart", pressKeyDown); button.removeEventListener("touchend", pressKeyUp);
button.removeEventListener("touchend", pressKeyUp); button.removeEventListener("touchcancel", onMouseLeave);
button.removeEventListener("touchcancel", onMouseLeave); } else {
} else { button.removeEventListener("mousedown", pressKeyDown);
button.removeEventListener("mousedown", pressKeyDown); button.removeEventListener("mouseup", pressKeyUp);
button.removeEventListener("mouseup", pressKeyUp); button.removeEventListener("mouseleave", onMouseLeave);
button.removeEventListener("mouseleave", onMouseLeave); }
} };
}); });
let isDown = false; let isDown = false;
@@ -60,11 +60,11 @@
onMount(() => { onMount(() => {
screen.addEventListener("keydown", onKeyDown); screen.addEventListener("keydown", onKeyDown);
screen.addEventListener("keyup", onKeyUp); screen.addEventListener("keyup", onKeyUp);
});
onDestroy(() => { return () => {
screen.removeEventListener("keydown", onKeyDown); screen.removeEventListener("keydown", onKeyDown);
screen.removeEventListener("keyup", onKeyUp); screen.removeEventListener("keyup", onKeyUp);
};
}); });
function onKeyDown(event) { function onKeyDown(event) {
@@ -31,7 +31,7 @@
let searchFiltersLabel; let searchFiltersLabel;
playletStateStore.subscribe((value) => { playletStateStore.subscribe((value) => {
invidiousApi.instance = value?.invidious?.current_instance; invidiousApi.instance = value?.invidious?.instance;
let userCountryCode = value?.device?.user_country_code; let userCountryCode = value?.device?.user_country_code;
if (!userCountryCode || userCountryCode === "OT") { if (!userCountryCode || userCountryCode === "OT") {
userCountryCode = "US"; userCountryCode = "US";
@@ -12,7 +12,6 @@
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"]; const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
export let displayText: string = ""; export let displayText: string = "";
// svelte-ignore unused-export-let
export let key: string = ""; export let key: string = "";
export let description: string = ""; export let description: string = "";
export let level: number = 0; export let level: number = 0;
@@ -92,7 +91,7 @@
<div class={textSizes[level]}>{$translate(displayText)}</div> <div class={textSizes[level]}>{$translate(displayText)}</div>
<div class="text-xs text-gray-500">{@html $translate(description)}</div> <div class="text-xs text-gray-500">{@html $translate(description)}</div>
<button class="btn m-1" on:click={openHomeScreenEditor} <button class="btn m-1" on:click={openHomeScreenEditor}
>{$translate("Edit home screen")}</button >{$translate(displayText)}</button
> >
</div> </div>
Loaded 100 of 114 files, more files were not shown because too many files have changed in this diff. Show more