Compare commits

..
51 Commits
Author SHA1 Message Date
Brahim Hadriche 910d57795a Release v0.21.2 (#324) 2024-03-10 11:14:57 -04:00
Brahim Hadriche ef733d8d88 Fix deep linking 2024-03-10 11:06:16 -04:00
Brahim Hadriche 6ad42f3fcd update metadata 2024-03-09 23:11:28 -05:00
Brahim Hadriche 1ba5184d95 Release v0.21.1 (#323) 2024-03-09 22:59:04 -05:00
Brahim Hadriche 26ed985ecc Bug fixes 2024-03-09 22:55:07 -05:00
Brahim Hadriche 6b47440cb5 Add launch arg to clear 2024-03-09 19:09:11 -05:00
Brahim Hadriche ee3312763d Add a loading indicator to QR codes 2024-03-09 18:34:32 -05:00
Brahim Hadriche 7bb73e0fb6 Dev video player (#321) 2024-03-09 08:44:32 -05:00
f71ad7b873 [chore] update dependencies (#320)
* update dependencies

* no message

---------

Co-authored-by: iBicha <iBicha@users.noreply.github.com>
Co-authored-by: Brahim Hadriche <brahim.hadriche@gmail.com>
2024-03-08 23:30:09 -05:00
Brahim Hadriche 0f6329997d tweak optional chaining rule 2024-03-08 23:14:32 -05:00
Brahim Hadriche 58918f68fb Add a /watch endpoint for easier casting 2024-03-08 13:19:40 -05:00
Brahim Hadriche 8a63bc848d Disallow optional chaining operator 2024-03-08 12:06:41 -05:00
Brahim Hadriche 9315fa6cf7 Added subscriber count in the channel page 2024-03-07 23:12:35 -05:00
Brahim Hadriche 15841cf5bf Release v0.21.0 (#318) 2024-03-07 22:30:36 -05:00
Brahim Hadriche 9c7de8f41f Add user agent to player 2024-03-06 08:26:33 -05:00
Brahim Hadriche 405e1aa703 Revert "use region param in videos api endpoint" (#317)
This reverts commit 79d9e0f069.
2024-03-06 08:26:08 -05:00
Brahim Hadriche 79d9e0f069 use region param in videos api endpoint 2024-03-05 18:14:42 -05:00
Brahim Hadriche d8bfd8859e remove todo 2024-03-04 23:44:36 -05:00
Brahim Hadriche 1c8d075e87 Fix empty invidious instance in preferences 2024-03-04 13:03:59 -05:00
13bb21c1f7 [chore] update dependencies (#314)
* update dependencies

* revert rooibos

---------

Co-authored-by: iBicha <iBicha@users.noreply.github.com>
Co-authored-by: Brahim Hadriche <brahim.hadriche@gmail.com>
2024-03-04 12:40:43 -05:00
Brahim Hadricheandgithub-action linter 394dd23999 Multiple profiles (#312)
* Navbar user profile

* profiles stuff

* fix profile

* Lint fix

* Some ui experiments

* More ui work

* progress

* Lint fix

* migration, web api, wip

* profile view and web app

* web app and apis

* Invidious and profiles

* Lint fix

* bug fix

* Remove ActionContentNode

* Profile icon button, profile color

* Lint fix

* reset server url

* href that doesn't work

* remove activate button on active profile

* TODO

* Fin.

* Final touches

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2024-03-04 09:04:34 -05:00
Brahim Hadriche 8e03ca0ea6 Fix empty search results bug 2024-02-27 20:45:32 -05:00
Brahim Hadriche aebdc579a9 Small cleanup 2024-02-27 20:04:12 -05:00
Brahim Hadriche 87e7d91169 Format fix 2024-02-27 17:20:15 -05:00
Brahim Hadriche c334736325 play next video on fail 2024-02-27 17:14:15 -05:00
Brahim Hadriche bb0a0725d6 Release 0.20.2 (#311) 2024-02-26 18:57:52 -05:00
Brahim Hadriche f2ffb42876 refactor url encoded form requests 2024-02-26 18:44:57 -05:00
Brahim Hadriche edbfc86e56 changelog 2024-02-26 09:47:18 -05:00
Brahim Hadriche b25eaafc82 Fix for sponsorblock highlight label 2024-02-26 09:46:20 -05:00
Brahim Hadriche ef9c653ad7 Device connected notification only show once every half hour per device to avoid spam 2024-02-25 22:16:01 -05:00
Andrey LazarevichandBrahim Hadriche e9f015bb19 OK button as Play/Pause (#307)
* OK button as Play/Pause

First OK press now shows Video UI.
It's achievable via hidden Roku Video node property `showUI`, which allows you to override how trickplay should be displayed by specifying parts of the UI to be rendered (like 'titleAndTime', 'trickplayBar', e.t.c). A timer is started every time custom UI is shown to prevent UI from staying forever.

Second OK press while UI is visible pauses the video (pause poster animation is not added yet).

However, since we shouldn't break default OK button actions, we must track whether user is seeking in video UI and if they do, fallback to Video internal OK handler.

Also, auto-formatted VideoPlayer.xml

* fix comment typo

* move HideUI function slightly higher

* Addressed the feedback:

* Add a workaround to leave Live video behavior intact (no pause, ok simply switches UI back and forth)
* Hide UI when minimizing to avoid a bug where title and time element could stay forver
* More aggressive `isSeeking` detection, so every left/right/ff/rw button press would cause us to fall back to default OK button handler

* More accurate liveNow handling

* Changelog

---------

Co-authored-by: Brahim Hadriche <brahim.hadriche@gmail.com>
2024-02-25 20:05:11 -05:00
Brahim Hadriche 544671f246 remove old todo 2024-02-25 19:55:13 -05:00
Brahim Hadriche f45ba30979 Colored logs for debugging (#308)
* Colored logs for debugging

* disable colors
2024-02-25 19:06:27 -05:00
Brahim Hadriche 4953e4481f Rename files for consistency 2024-02-24 19:08:43 -05:00
Brahim Hadriche c7b0815768 New focus 9 patch textures 2024-02-24 19:03:12 -05:00
Brahim Hadriche 4ab7f74a4e More adjustments to context menu 2024-02-24 16:58:18 -05:00
Brahim Hadriche 96916f6c37 Formatting 2024-02-24 11:44:03 -05:00
Brahim Hadriche eafad684b6 Small improvement 2024-02-24 11:40:52 -05:00
Brahim Hadriche 14d3e38aeb Tweaks to remote screen UI 2024-02-23 22:21:44 -05:00
afe281c094 [chore] update dependencies (#306)
* update dependencies

* Update package.json

* lock file

---------

Co-authored-by: iBicha <iBicha@users.noreply.github.com>
Co-authored-by: Brahim Hadriche <brahim.hadriche@gmail.com>
2024-02-23 20:04:14 -05:00
Brahim Hadriche 436078bdf8 Release 0.20.1 (#305) 2024-02-23 18:24:00 -05:00
Brahim Hadriche 20120538e4 Small perf optm 2024-02-23 17:04:33 -05:00
Brahim Hadriche eec4101d29 Fix for repeated 2024-02-23 12:44:55 -05:00
Brahim Hadriche b135ba2a0a Log connect and disconnect events 2024-02-22 23:40:40 -05:00
Brahim Hadriche 9c9f24cb39 rollback rooibos 2024-02-22 19:37:17 -05:00
Brahim Hadriche 6aeb4bc8b9 Changelog 2024-02-22 19:16:55 -05:00
Brahim Hadriche 4beb7fbf3c humor 2024-02-22 19:16:23 -05:00
Brahim Hadriche 4f3512023f Move devices array to lounge api class 2024-02-22 18:58:47 -05:00
Brahim Hadriche f38115171b Error handling for registry script 2024-02-22 17:11:51 -05:00
Brahim Hadriche 7456917cec fix rale tracker warnings 2024-02-22 13:30:51 -05:00
Brahim Hadriche 4482d3333f Update info and screenshots 2024-02-21 19:52:40 -05:00
140 changed files with 3148 additions and 809 deletions

No files matched your search

+52 -1
View File
@@ -2,9 +2,60 @@
All notable changes to this project will be documented in this file. 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.0.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.21.2] - 2024-03-10
### Fixed
- Deeplinking required for certification
## [0.21.1] - 2024-03-09
### Added
- Subscriber count in the channel page
### Fixed
- A bug where videos that did not premiere yet would error with a playback error
- A bug where a playback error dialog is dismissed too fast before playing the next video
## [0.21.0] - 2024-03-07
### Added
- Support for multiple profiles. You can now use multiple Invidious accounts.
- When a video error dialog shows, a timer with 10 seconds starts to play the next video
### Fixed
- A bug where the loading screen does not disappear if search results are empty.
- Empty invidious instance in preferences when default instance is being used
## [0.20.2] - 2024-02-26
### Added
- Small improvement in the context menu of the Playlist view
- Videos can be paused and resumed using the `Ok` remote button
### Fixed
- `Device connected` notification only show once every 30 minutes per device to avoid spam
- SponsorBlock category "highlight" was not visible in chapter label
### Changed
- UI focus images are now with rounded corners, and with a slight glow
## [0.20.1] - 2024-02-23
### Fixed
- `Device connected` notification showing repeatedly
## [0.20.0] - 2024-02-21 ## [0.20.0] - 2024-02-21
### Added ### Added
+6 -6
View File
@@ -42,16 +42,16 @@ More under [Screenshots](./docs/screenshots/README.md)
- 🕵️ No Tracking - 🕵️ No Tracking
- 🛡️ Privacy driven (uses Invidious backend) - 🛡️ Privacy driven (uses Invidious backend)
- ⚔️ SponsorBlock integration (skips undesirable sections in videos) - ⚔️ SponsorBlock integration (skips undesirable sections in videos)
- 📱 Browse, search, and cast from phone using the web app - 📱 Browse, search, and cast from phone using the YouTube app or the browser
- 🔮 Picture-in-picture mode - 🔮 Picture-in-picture mode
- ⚡ Fast! [Check out how we compare with the official YouTube app](https://youtu.be/qmSvA-QQW20) - ⚡ Fast! [Check out how we compare with the official YouTube app](https://youtu.be/qmSvA-QQW20)
### Cast from phone ### Cast from phone
1. Open "Web app" tab in Playlet - Open "Remote" tab in Playlet
1. Scan QR Code with Phone - Scan QR Code with Phone, and use the browser; OR
1. Browse or search videos - Use the YouTube app to connect using the same Wi-Fi; OR
1. Click the video and choose the "Play on TV" option - Use the `Link with TV code` to connect
### Picture-in-picture ### Picture-in-picture
@@ -63,7 +63,7 @@ More under [Screenshots](./docs/screenshots/README.md)
1. Open settings in Playlet 1. Open settings in Playlet
1. Select Invidious -> Instance 1. Select Invidious -> Instance
1. Set a custom instance, or choose a public one hosted by volunteers (from https://api.invidious.io/) 1. Set a custom instance, or choose a public one hosted by volunteers (from [api.invidious.io](https://api.invidious.io/))
1. Optionally, Select `Test instance` to make sure it works 1. Optionally, Select `Test instance` to make sure it works
1. Hit save 1. Hit save
+6
View File
@@ -40,6 +40,12 @@
"regex": "\\b(?!_unused)unused\\b", "regex": "\\b(?!_unused)unused\\b",
"regexFlags": "ig", "regexFlags": "ig",
"message": "unused args should start with _ (e.g. _unused)" "message": "unused args should start with _ (e.g. _unused)"
},
{
"code": "NO_OPTIONAL_CHAINING",
"regex": "\\?[\\.|\\[|\\(|@]",
"regexFlags": "ig",
"message": "No optional chaning (var1?.property). Do a type check instead."
} }
], ],
"files": [ "files": [
+8 -2
View File
@@ -294,14 +294,20 @@ This is mostly useful to QA the `canary` release (see [Canary release](https://e
#### In case of a softlock #### In case of a softlock
If the dev menu is used to load a custom Playlet lib url, but the lib does not have a functionality to revert back: If the dev menu is used to load a custom Playlet lib url, but you couldn't revert back:
```bash ```bash
curl -d '' "http://$ROKU_DEV_TARGET:8060/launch/dev?clearPlayletLibUrls=true" curl -d '' "http://$ROKU_DEV_TARGET:8060/launch/693751?clearPlayletLibUrls=true"
``` ```
This will remove the custom lib, and revert to using default (latest release from Github). This will remove the custom lib, and revert to using default (latest release from Github).
If you need to clear all the data from the registry, use
```bash
curl -d '' "http://$ROKU_DEV_TARGET:8060/launch/693751?clearRegistry=true"
```
## CI/CD ## CI/CD
On pull requests, a Github action will run `lint:fix` and `format:fix` and push changes to the PR branch, to keep things tidy. On pull requests, a Github action will run `lint:fix` and `format:fix` and push changes to the PR branch, to keep things tidy.
+76 -13
View File
@@ -2,7 +2,7 @@ openapi: 3.0.0
info: info:
title: Playlet Web API title: Playlet Web API
version: 0.20.0 version: 0.21.2
description: description:
Playlet Web API is a RESTful API for controlling the Playlet app on Playlet Web API is a RESTful API for controlling the Playlet app on
Roku devices. The API is intended to be used by the Playlet web app, but can Roku devices. The API is intended to be used by the Playlet web app, but can
@@ -322,14 +322,63 @@ paths:
schema: schema:
type: string type: string
format: uri format: uri
/invidious/logout: /api/profiles:
get: get:
summary: Logout from Invidious summary: Get profiles
description: Logout from Invidious, and invalidate the token if any. description: Get the logged profiles, and the currently active profile.
operationId: invidiousLogout operationId: getProfiles
responses: responses:
"204": "200":
description: No Content description: OK
content:
application/json:
schema:
type: object
properties:
currentProfile:
type: string
profiles:
type: array
items:
$ref: "#/components/schemas/ProfileObject"
delete:
summary: Logout from a profile
description: Logout from a profile. This will remove the profile from the list of logged profiles.
operationId: logoutProfile
parameters:
- name: id
in: query
description: The ID of the profile to logout
required: true
schema:
type: string
responses:
"200":
description: OK
"400":
description: Bad Request
"404":
description: Not Found
/api/profiles/activate:
post:
summary: Activate a profile
description: Activate a profile. This will set the profile as the active profile.
operationId: activateProfile
requestBody:
content:
application/json:
schema:
type: object
properties:
id:
type: string
responses:
"200":
description: OK
"400":
description: Bad Request
"404":
description: Not Found
# Roku External Control Protocol (ECP) # Roku External Control Protocol (ECP)
/input/{appId}: /input/{appId}:
@@ -530,14 +579,17 @@ components:
type: string type: string
auth_url: auth_url:
type: string type: string
logged_in:
type: boolean
logged_in_instance:
type: string
logged_in_username:
type: string
preferences: preferences:
$ref: "#/components/schemas/PreferencesObject" $ref: "#/components/schemas/PreferencesObject"
profiles:
type: object
properties:
currentProfile:
type: string
profiles:
type: array
items:
$ref: "#/components/schemas/ProfileObject"
PreferencesObject: PreferencesObject:
type: object type: object
properties: properties:
@@ -560,6 +612,17 @@ components:
type: boolean type: boolean
sponsorblock.show_notifications: sponsorblock.show_notifications:
type: boolean type: boolean
ProfileObject:
type: object
properties:
id:
type: string
type:
type: string
username:
type: string
serverUrl:
type: string
# TODO:P1 add the rest of properties # TODO:P1 add the rest of properties
VideoQueueObject: VideoQueueObject:
type: object type: object
+3 -3
View File
@@ -18,9 +18,9 @@
| --------------------------- | ------------------------------------------------ | --------------------------------------------- | | --------------------------- | ------------------------------------------------ | --------------------------------------------- |
| ![Settings](./settings.jpg) | ![Invidious instances](./invidious-settings.jpg) | ![Invidious testing](./invidious-testing.jpg) | | ![Settings](./settings.jpg) | ![Invidious instances](./invidious-settings.jpg) | ![Invidious testing](./invidious-testing.jpg) |
| Link to web app | App info | | Remote | App info |
| ----------------------------------- | --------------------------- | | ----------------------- | --------------------------- |
| ![Link to web app](./webapp-qr.jpg) | ![App info](./app-info.jpg) | | ![Remote](./remote.jpg) | ![App info](./app-info.jpg) |
## Playlet web app ## Playlet web app
Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

+232 -108
View File
@@ -1,41 +1,41 @@
{ {
"name": "playlet", "name": "playlet",
"version": "0.20.0", "version": "0.21.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet", "name": "playlet",
"version": "0.20.0", "version": "0.21.2",
"hasInstallScript": true, "hasInstallScript": true,
"devDependencies": { "devDependencies": {
"@rokucommunity/bslint": "^0.8.17", "@rokucommunity/bslint": "^0.8.19",
"@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": "^20.11.19", "@types/node": "^20.11.25",
"@types/xml2js": "^0.4.14", "@types/xml2js": "^0.4.14",
"argparse": "^2.0.1", "argparse": "^2.0.1",
"brighterscript": "0.65.22", "brighterscript": "0.65.25",
"brighterscript-formatter": "^1.6.40", "brighterscript-formatter": "^1.7.0",
"convert-svg-to-png": "^0.6.4", "convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0", "cross-fetch": "^4.0.0",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"dotenv": "^16.4.4", "dotenv": "^16.4.5",
"express": "^4.18.2", "express": "^4.18.3",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"glob": "^10.3.10", "glob": "^10.3.10",
"imap": "^0.8.19", "imap": "^0.8.19",
"ip": "^1.1.8", "ip": "^2.0.1",
"json5": "^2.2.3", "json5": "^2.2.3",
"mailparser": "^3.6.7", "mailparser": "^3.6.9",
"roku-deploy": "^3.11.2", "roku-deploy": "^3.12.0",
"rooibos-roku": "^5.11.0", "rooibos-roku": "5.10.0",
"semver": "^7.6.0", "semver": "^7.6.0",
"shelljs": "^0.8.5", "shelljs": "^0.8.5",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.3.3", "typescript": "^5.4.2",
"xml2js": "^0.6.2", "xml2js": "^0.6.2",
"yaml": "^2.3.4" "yaml": "^2.4.1"
}, },
"engines": { "engines": {
"node": "18" "node": "18"
@@ -276,9 +276,9 @@
"dev": true "dev": true
}, },
"node_modules/@rokucommunity/bslint": { "node_modules/@rokucommunity/bslint": {
"version": "0.8.17", "version": "0.8.19",
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.17.tgz", "resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.19.tgz",
"integrity": "sha512-e0ksPVYnN+QkhzuV97yPTf1NxSkBQZNMJRhlCFnMJf6gfps+VdY1HwYn3IlqDz3XJxfYcRSDa3v3fQ5dQynVEA==", "integrity": "sha512-2vQasjH5nZdgJJzxAOwYzA8gtjvvO5MtxfqjK10shE1G8XmLpqguT5qHzLz+HxvdRbFZ7OSOOyBAqQHgZRpO1Q==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
@@ -370,9 +370,9 @@
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "20.11.19", "version": "20.11.25",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.25.tgz",
"integrity": "sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==", "integrity": "sha512-TBHyJxk2b7HceLVGFcpAUjsa5zIdsPWlR6XHfyGzd0SFu+/NFgQgMAl96MSDZgQDvJAvV6BKsFOrt6zIL09JDw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"undici-types": "~5.26.4" "undici-types": "~5.26.4"
@@ -676,13 +676,13 @@
"dev": true "dev": true
}, },
"node_modules/body-parser": { "node_modules/body-parser": {
"version": "1.20.1", "version": "1.20.2",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
"integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"bytes": "3.1.2", "bytes": "3.1.2",
"content-type": "~1.0.4", "content-type": "~1.0.5",
"debug": "2.6.9", "debug": "2.6.9",
"depd": "2.0.0", "depd": "2.0.0",
"destroy": "1.2.0", "destroy": "1.2.0",
@@ -690,7 +690,7 @@
"iconv-lite": "0.4.24", "iconv-lite": "0.4.24",
"on-finished": "2.4.1", "on-finished": "2.4.1",
"qs": "6.11.0", "qs": "6.11.0",
"raw-body": "2.5.1", "raw-body": "2.5.2",
"type-is": "~1.6.18", "type-is": "~1.6.18",
"unpipe": "1.0.0" "unpipe": "1.0.0"
}, },
@@ -728,9 +728,9 @@
} }
}, },
"node_modules/brighterscript": { "node_modules/brighterscript": {
"version": "0.65.22", "version": "0.65.25",
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.22.tgz", "resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.25.tgz",
"integrity": "sha512-rDSdO33xRnFGB9nr54awTUucpd4oZpZmDMvVUSAb6jmFU1jz+SYhwV9ezc8U5m3Kswap7uV+BmS1O69QZ9MuSw==", "integrity": "sha512-sezfScxcXZfzEJ702HCMjfPsIH/x3mfLAFDObGU+xAC2E8m/zxrPOHKlD9Qpmdvd7/j4TgsujhiRQ1tnk8BzGA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@rokucommunity/bslib": "^0.1.1", "@rokucommunity/bslib": "^0.1.1",
@@ -755,7 +755,7 @@
"parse-ms": "^2.1.0", "parse-ms": "^2.1.0",
"readline": "^1.3.0", "readline": "^1.3.0",
"require-relative": "^0.8.7", "require-relative": "^0.8.7",
"roku-deploy": "^3.11.2", "roku-deploy": "^3.12.0",
"serialize-error": "^7.0.1", "serialize-error": "^7.0.1",
"source-map": "^0.7.4", "source-map": "^0.7.4",
"vscode-languageserver": "7.0.0", "vscode-languageserver": "7.0.0",
@@ -770,12 +770,12 @@
} }
}, },
"node_modules/brighterscript-formatter": { "node_modules/brighterscript-formatter": {
"version": "1.6.40", "version": "1.7.0",
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.6.40.tgz", "resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.7.0.tgz",
"integrity": "sha512-cxvGGluNfxy6p3khtcMt/3AschwqEnERjLRIEt3XVU0R0l2QgwXelDp8ViqgnQ2hQYa8LnfnOiV1u7OCqbiZPA==", "integrity": "sha512-LKnUeAgNX3eKqK0J1Z55YteRlR/+DFuCbMf6/5DHdlCI7VVkOf+EWErruSfuol6+T2eImM0LY79CLT854VTE5g==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"brighterscript": "^0.65.19", "brighterscript": "^0.65.25",
"glob-all": "^3.3.0", "glob-all": "^3.3.0",
"jsonc-parser": "^3.0.0", "jsonc-parser": "^3.0.0",
"source-map": "^0.7.3", "source-map": "^0.7.3",
@@ -1086,13 +1086,19 @@
} }
}, },
"node_modules/call-bind": { "node_modules/call-bind": {
"version": "1.0.2", "version": "1.0.7",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"function-bind": "^1.1.1", "es-define-property": "^1.0.0",
"get-intrinsic": "^1.0.2" "es-errors": "^1.3.0",
"function-bind": "^1.1.2",
"get-intrinsic": "^1.2.4",
"set-function-length": "^1.2.1"
},
"engines": {
"node": ">= 0.4"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
@@ -1607,6 +1613,23 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/define-data-property": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
"integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
"dev": true,
"dependencies": {
"es-define-property": "^1.0.0",
"es-errors": "^1.3.0",
"gopd": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/delayed-stream": { "node_modules/delayed-stream": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
@@ -1706,9 +1729,9 @@
} }
}, },
"node_modules/dotenv": { "node_modules/dotenv": {
"version": "16.4.4", "version": "16.4.5",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.4.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
"integrity": "sha512-XvPXc8XAQThSjAbY6cQ/9PcBXmFoWuw1sQ3b8HqUCR6ziGXjkTi//kB9SWa2UwqlgdAIuRqAa/9hVljzPehbYg==", "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
@@ -1809,6 +1832,27 @@
"url": "https://github.com/fb55/entities?sponsor=1" "url": "https://github.com/fb55/entities?sponsor=1"
} }
}, },
"node_modules/es-define-property": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
"integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
"dev": true,
"dependencies": {
"get-intrinsic": "^1.2.4"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"dev": true,
"engines": {
"node": ">= 0.4"
}
},
"node_modules/escalade": { "node_modules/escalade": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
@@ -1849,14 +1893,14 @@
"dev": true "dev": true
}, },
"node_modules/express": { "node_modules/express": {
"version": "4.18.2", "version": "4.18.3",
"resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", "resolved": "https://registry.npmjs.org/express/-/express-4.18.3.tgz",
"integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", "integrity": "sha512-6VyCijWQ+9O7WuVMTRBTl+cjNNIzD5cY5mQ1WM8r/LEkI2u8EYpOotESNwzNlyCn3g+dmjKYI6BmNneSr/FSRw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"accepts": "~1.3.8", "accepts": "~1.3.8",
"array-flatten": "1.1.1", "array-flatten": "1.1.1",
"body-parser": "1.20.1", "body-parser": "1.20.2",
"content-disposition": "0.5.4", "content-disposition": "0.5.4",
"content-type": "~1.0.4", "content-type": "~1.0.4",
"cookie": "0.5.0", "cookie": "0.5.0",
@@ -1977,9 +2021,9 @@
"dev": true "dev": true
}, },
"node_modules/fastq": { "node_modules/fastq": {
"version": "1.16.0", "version": "1.17.1",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.16.0.tgz", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz",
"integrity": "sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==", "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"reusify": "^1.0.4" "reusify": "^1.0.4"
@@ -2142,10 +2186,13 @@
} }
}, },
"node_modules/function-bind": { "node_modules/function-bind": {
"version": "1.1.1", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"dev": true "dev": true,
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
}, },
"node_modules/get-caller-file": { "node_modules/get-caller-file": {
"version": "2.0.5", "version": "2.0.5",
@@ -2157,15 +2204,19 @@
} }
}, },
"node_modules/get-intrinsic": { "node_modules/get-intrinsic": {
"version": "1.2.1", "version": "1.2.4",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
"integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==", "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"function-bind": "^1.1.1", "es-errors": "^1.3.0",
"has": "^1.0.3", "function-bind": "^1.1.2",
"has-proto": "^1.0.1", "has-proto": "^1.0.1",
"has-symbols": "^1.0.3" "has-symbols": "^1.0.3",
"hasown": "^2.0.0"
},
"engines": {
"node": ">= 0.4"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
@@ -2307,6 +2358,18 @@
"node": ">=16 || 14 >=14.17" "node": ">=16 || 14 >=14.17"
} }
}, },
"node_modules/gopd": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
"integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
"dev": true,
"dependencies": {
"get-intrinsic": "^1.1.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/graceful-fs": { "node_modules/graceful-fs": {
"version": "4.2.11", "version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
@@ -2357,10 +2420,22 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/has-property-descriptors": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
"integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
"dev": true,
"dependencies": {
"es-define-property": "^1.0.0"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-proto": { "node_modules/has-proto": {
"version": "1.0.1", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">= 0.4" "node": ">= 0.4"
@@ -2381,6 +2456,18 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/hasown": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz",
"integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==",
"dev": true,
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/he": { "node_modules/he": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
@@ -2592,9 +2679,9 @@
} }
}, },
"node_modules/ip": { "node_modules/ip": {
"version": "1.1.8", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz",
"integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==", "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==",
"dev": true "dev": true
}, },
"node_modules/ipaddr.js": { "node_modules/ipaddr.js": {
@@ -2808,15 +2895,15 @@
"dev": true "dev": true
}, },
"node_modules/libmime": { "node_modules/libmime": {
"version": "5.2.1", "version": "5.3.4",
"resolved": "https://registry.npmjs.org/libmime/-/libmime-5.2.1.tgz", "resolved": "https://registry.npmjs.org/libmime/-/libmime-5.3.4.tgz",
"integrity": "sha512-A0z9O4+5q+ZTj7QwNe/Juy1KARNb4WaviO4mYeFC4b8dBT2EEqK2pkM+GC8MVnkOjqhl5nYQxRgnPYRRTNmuSQ==", "integrity": "sha512-TsqPdercr6DHrnoQx1F0nS2Y4yPT+fWuOjEP2rqzvV77hMYWomTe/rpm0u9JORQ/FavEXybAGcBJsQbLr9+hjA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"encoding-japanese": "2.0.0", "encoding-japanese": "2.0.0",
"iconv-lite": "0.6.3", "iconv-lite": "0.6.3",
"libbase64": "1.2.1", "libbase64": "1.3.0",
"libqp": "2.0.1" "libqp": "2.1.0"
} }
}, },
"node_modules/libmime/node_modules/iconv-lite": { "node_modules/libmime/node_modules/iconv-lite": {
@@ -2831,6 +2918,18 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/libmime/node_modules/libbase64": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/libbase64/-/libbase64-1.3.0.tgz",
"integrity": "sha512-GgOXd0Eo6phYgh0DJtjQ2tO8dc0IVINtZJeARPeiIJqge+HdsWSuaDTe8ztQ7j/cONByDZ3zeB325AHiv5O0dg==",
"dev": true
},
"node_modules/libmime/node_modules/libqp": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/libqp/-/libqp-2.1.0.tgz",
"integrity": "sha512-O6O6/fsG5jiUVbvdgT7YX3xY3uIadR6wEZ7+vy9u7PKHAlSEB6blvC1o5pHBjgsi95Uo0aiBBdkyFecj6jtb7A==",
"dev": true
},
"node_modules/libqp": { "node_modules/libqp": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/libqp/-/libqp-2.0.1.tgz", "resolved": "https://registry.npmjs.org/libqp/-/libqp-2.0.1.tgz",
@@ -2916,20 +3015,21 @@
} }
}, },
"node_modules/mailparser": { "node_modules/mailparser": {
"version": "3.6.7", "version": "3.6.9",
"resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.6.7.tgz", "resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.6.9.tgz",
"integrity": "sha512-/3x8HW70DNehw+3vdOPKdlLuxOHoWcGB5jfx5vJ5XUbY9/2jUJbrrhda5Si8Dj/3w08U0y5uGAkqs5+SPTPKoA==", "integrity": "sha512-1fIDZlgN1NnuzmTSEUxkaViquXYkw5NbQehVc+kz55QRy98QgLdTtRSKv289Jy4NrCiDchRx6zAijB4HrPsvkA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"encoding-japanese": "2.0.0", "encoding-japanese": "2.0.0",
"he": "1.2.0", "he": "1.2.0",
"html-to-text": "9.0.5", "html-to-text": "9.0.5",
"iconv-lite": "0.6.3", "iconv-lite": "0.6.3",
"libmime": "5.2.1", "libmime": "5.3.4",
"linkify-it": "5.0.0", "linkify-it": "5.0.0",
"mailsplit": "5.4.0", "mailsplit": "5.4.0",
"nodemailer": "6.9.9", "nodemailer": "6.9.11",
"tlds": "1.248.0" "punycode": "2.3.1",
"tlds": "1.250.0"
} }
}, },
"node_modules/mailparser/node_modules/iconv-lite": { "node_modules/mailparser/node_modules/iconv-lite": {
@@ -3083,9 +3183,9 @@
"dev": true "dev": true
}, },
"node_modules/moment": { "node_modules/moment": {
"version": "2.29.4", "version": "2.30.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz",
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": "*" "node": "*"
@@ -3127,9 +3227,9 @@
} }
}, },
"node_modules/nodemailer": { "node_modules/nodemailer": {
"version": "6.9.9", "version": "6.9.11",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.9.tgz", "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.11.tgz",
"integrity": "sha512-dexTll8zqQoVJEZPwQAKzxxtFn0qTnjdQTchoU6Re9BUUGBJiOy3YMn/0ShTW6J5M0dfQ1NeDeRTTl4oIWgQMA==", "integrity": "sha512-UiAkgiERuG94kl/3bKfE8o10epvDnl0vokNEtZDPTq9BWzIl6EFT9336SbIT4oaTBD8NmmUTLsQyXHV82eXSWg==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=6.0.0" "node": ">=6.0.0"
@@ -3166,9 +3266,9 @@
} }
}, },
"node_modules/object-inspect": { "node_modules/object-inspect": {
"version": "1.12.3", "version": "1.13.1",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz",
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==",
"dev": true, "dev": true,
"funding": { "funding": {
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
@@ -3689,9 +3789,9 @@
} }
}, },
"node_modules/raw-body": { "node_modules/raw-body": {
"version": "2.5.1", "version": "2.5.2",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
"integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"bytes": "3.1.2", "bytes": "3.1.2",
@@ -3850,9 +3950,9 @@
} }
}, },
"node_modules/roku-deploy": { "node_modules/roku-deploy": {
"version": "3.11.2", "version": "3.12.0",
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.11.2.tgz", "resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.12.0.tgz",
"integrity": "sha512-3JDlnbTxv6Xk5GVolQoA3+d34MLZXXwZWMySprHwazZoWLP3LvulYHP92YvFOJAo/aI4IZp/TFA8kR82IrmHKA==", "integrity": "sha512-YiCZeQ+sEmFW9ZfXtMNH+/CBSHQ5deNZYWONM+s6gCEQsrz7kCMFPj5YEdgfqW+d2b8G1ve9GELHcSt2FsfM8g==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"chalk": "^2.4.2", "chalk": "^2.4.2",
@@ -3921,9 +4021,9 @@
} }
}, },
"node_modules/rooibos-roku": { "node_modules/rooibos-roku": {
"version": "5.11.0", "version": "5.10.0",
"resolved": "https://registry.npmjs.org/rooibos-roku/-/rooibos-roku-5.11.0.tgz", "resolved": "https://registry.npmjs.org/rooibos-roku/-/rooibos-roku-5.10.0.tgz",
"integrity": "sha512-qxTYwsyp6Ihb6B8tmFm+24DE/s2gMCxagvdABElGWgqL834M+kZtmwrQXvSrMkM+0gkmQfIDuw1M4v484gycYQ==", "integrity": "sha512-Idiv3nWQOEr5V8z8oHcIovjcoBffgqRtTQ5B6K+x/cGAouKxyVJp0fsZ80xQvUul9IwHQ0XIPUYbNWCR3RQ3sA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"source-map": "^0.7.3", "source-map": "^0.7.3",
@@ -4117,6 +4217,23 @@
"integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
"dev": true "dev": true
}, },
"node_modules/set-function-length": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz",
"integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==",
"dev": true,
"dependencies": {
"define-data-property": "^1.1.2",
"es-errors": "^1.3.0",
"function-bind": "^1.1.2",
"get-intrinsic": "^1.2.3",
"gopd": "^1.0.1",
"has-property-descriptors": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/setimmediate": { "node_modules/setimmediate": {
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
@@ -4188,14 +4305,18 @@
} }
}, },
"node_modules/side-channel": { "node_modules/side-channel": {
"version": "1.0.4", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"call-bind": "^1.0.0", "call-bind": "^1.0.7",
"get-intrinsic": "^1.0.2", "es-errors": "^1.3.0",
"object-inspect": "^1.9.0" "get-intrinsic": "^1.2.4",
"object-inspect": "^1.13.1"
},
"engines": {
"node": ">= 0.4"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
@@ -4404,9 +4525,9 @@
"dev": true "dev": true
}, },
"node_modules/tlds": { "node_modules/tlds": {
"version": "1.248.0", "version": "1.250.0",
"resolved": "https://registry.npmjs.org/tlds/-/tlds-1.248.0.tgz", "resolved": "https://registry.npmjs.org/tlds/-/tlds-1.250.0.tgz",
"integrity": "sha512-noj0KdpWTBhwsKxMOXk0rN9otg4kTgLm4WohERRHbJ9IY+kSDKr3RmjitaQ3JFzny+DyvBOQKlFZhp0G0qNSfg==", "integrity": "sha512-rWsBfFCWKrjM/o2Q1TTUeYQv6tHSd/umUutDjVs6taTuEgRDIreVYIBgWRWW4ot7jp6n0UVUuxhTLWBtUmPu/w==",
"dev": true, "dev": true,
"bin": { "bin": {
"tlds": "bin.js" "tlds": "bin.js"
@@ -4526,9 +4647,9 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "5.3.3", "version": "5.4.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz",
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==",
"dev": true, "dev": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
@@ -4926,10 +5047,13 @@
"dev": true "dev": true
}, },
"node_modules/yaml": { "node_modules/yaml": {
"version": "2.3.4", "version": "2.4.1",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.1.tgz",
"integrity": "sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==", "integrity": "sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg==",
"dev": true, "dev": true,
"bin": {
"yaml": "bin.mjs"
},
"engines": { "engines": {
"node": ">= 14" "node": ">= 14"
} }
+13 -13
View File
@@ -1,35 +1,35 @@
{ {
"name": "playlet", "name": "playlet",
"version": "0.20.0", "version": "0.21.2",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"devDependencies": { "devDependencies": {
"@rokucommunity/bslint": "^0.8.17", "@rokucommunity/bslint": "^0.8.19",
"@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": "^20.11.19", "@types/node": "^20.11.25",
"@types/xml2js": "^0.4.14", "@types/xml2js": "^0.4.14",
"argparse": "^2.0.1", "argparse": "^2.0.1",
"brighterscript": "0.65.22", "brighterscript": "0.65.25",
"brighterscript-formatter": "^1.6.40", "brighterscript-formatter": "^1.7.0",
"convert-svg-to-png": "^0.6.4", "convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0", "cross-fetch": "^4.0.0",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"dotenv": "^16.4.4", "dotenv": "^16.4.5",
"express": "^4.18.2", "express": "^4.18.3",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"glob": "^10.3.10", "glob": "^10.3.10",
"imap": "^0.8.19", "imap": "^0.8.19",
"ip": "^1.1.8", "ip": "^2.0.1",
"json5": "^2.2.3", "json5": "^2.2.3",
"mailparser": "^3.6.7", "mailparser": "^3.6.9",
"roku-deploy": "^3.11.2", "roku-deploy": "^3.12.0",
"rooibos-roku": "^5.11.0", "rooibos-roku": "5.10.0",
"semver": "^7.6.0", "semver": "^7.6.0",
"shelljs": "^0.8.5", "shelljs": "^0.8.5",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.3.3", "typescript": "^5.4.2",
"xml2js": "^0.6.2", "xml2js": "^0.6.2",
"yaml": "^2.3.4" "yaml": "^2.4.1"
}, },
"engines": { "engines": {
"node": "18" "node": "18"
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.20.0", "version": "0.21.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-app", "name": "playlet-app",
"version": "0.20.0" "version": "0.21.2"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.20.0", "version": "0.21.2",
"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",
@@ -20,6 +20,11 @@ function GetLoadingMessage() as string
"Don't forget to like and subscribe...", "Don't forget to like and subscribe...",
"Shoveling coal into the server...", "Shoveling coal into the server...",
"Counting down from infinity...", "Counting down from infinity...",
"Unfortunately, the internet is closed today...",
"Unfortunately, we have no ads to show you...",
"Looking for the remote...",
"Finding that song that goes 'La la lala la'...",
"Waiting for the spinny thing to finish...",
] ]
end if end if
index = GetRandom(0, messages.count() - 1) index = GetRandom(0, messages.count() - 1)
+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=20 minor_version=21
build_version=00000 build_version=00002
ui_resolutions=hd ui_resolutions=hd
+1
View File
@@ -22,6 +22,7 @@ function Main(args as object) as void
Logger.Init() Logger.Init()
Registry.ClearPlayletLibUrlsIfNeeded(args) Registry.ClearPlayletLibUrlsIfNeeded(args)
Registry.ClearRegistryIfNeeded(args)
scene = screen.CreateScene("BootstrapScene") scene = screen.CreateScene("BootstrapScene")
screen.show() screen.show()
+17
View File
@@ -14,6 +14,15 @@ namespace Registry
sec.Flush() sec.Flush()
end function end function
function DeleteAll()
reg = CreateObject("roRegistry")
sectionNames = reg.GetSectionList()
for each sectionName in sectionNames
reg.Delete(sectionName)
end for
reg.Flush()
end function
function GetPlayletLibUrlsFromRegistry() as object function GetPlayletLibUrlsFromRegistry() as object
urlsJson = ReadKey("playlet_lib_urls", "Playlet") urlsJson = ReadKey("playlet_lib_urls", "Playlet")
if urlsJson = invalid if urlsJson = invalid
@@ -31,4 +40,12 @@ namespace Registry
Logger.Log("Cleared key playlet_lib_urls from registry") Logger.Log("Cleared key playlet_lib_urls from registry")
end function end function
function ClearRegistryIfNeeded(launchArgs as object) as void
if launchArgs = invalid or launchArgs.clearRegistry = invalid
return
end if
DeleteAll()
Logger.Log("Cleared all data from registry")
end function
end namespace end namespace
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.20.0", "version": "0.21.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.20.0" "version": "0.21.2"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.20.0", "version": "0.21.2",
"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",
@@ -16,6 +16,7 @@ function Init()
m.banner = m.top.findNode("banner") m.banner = m.top.findNode("banner")
m.thumbnail = m.top.findNode("thumbnail") m.thumbnail = m.top.findNode("thumbnail")
m.authorLabel = m.top.findNode("authorLabel") m.authorLabel = m.top.findNode("authorLabel")
m.subCountLabel = m.top.findNode("subCountLabel")
m.subscribeButton = m.top.findNode("subscribeButton") m.subscribeButton = m.top.findNode("subscribeButton")
m.rowList = m.top.FindNode("rowList") m.rowList = m.top.FindNode("rowList")
m.rowList.focusable = true m.rowList.focusable = true
@@ -60,6 +61,7 @@ function OnContentSet() as void
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation. ' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.authorLabel.text = content._author m.authorLabel.text = content._author
m.subCountLabel.text = content.subCountText
m.banner.uri = content.banner m.banner.uri = content.banner
if StringUtils.IsNullOrEmpty(content.thumbnail) if StringUtils.IsNullOrEmpty(content.thumbnail)
m.thumbnail.uri = "" m.thumbnail.uri = ""
@@ -36,6 +36,10 @@
id="authorLabel" id="authorLabel"
translation="[115,40]" translation="[115,40]"
font="font:MediumBoldSystemFont" /> font="font:MediumBoldSystemFont" />
<Label
id="subCountLabel"
translation="[115,70]"
font="font:SmallestSystemFont" />
</Poster> </Poster>
<Button <Button
@@ -61,7 +65,7 @@
showRowLabel="[true]" showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus" rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true" variableWidthItems="true"
focusBitmapUri="pkg:/images/focus_grid.9.png" /> focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" />
<Animation <Animation
id="scrollAnimation" id="scrollAnimation"
@@ -1,6 +0,0 @@
<component name="ActionContentNode" extends="ContentNode">
<interface>
<field id="type" type="string" value="action" />
<field id="action" type="string" />
</interface>
</component>
@@ -0,0 +1,12 @@
<component name="ProfileContentNode" extends="ContentNode">
<interface>
<field id="type" type="string" value="invidious" />
<field id="isSelected" type="boolean" alwaysNotify="true" />
<field id="username" type="string" />
<field id="serverUrl" type="string" />
<field id="accessToken" type="string" />
<field id="color" type="color" />
</interface>
</component>
@@ -71,8 +71,6 @@ import "pkg:/source/utils/Types.bs"
' - "Remove group from Bookmarks" ' - "Remove group from Bookmarks"
' - "Reload bookmarks" - DONE ' - "Reload bookmarks" - DONE
' '
' TODO:P1 Playlist item seletected from the bookmarks need to play as a playlist, not as a single video
' TODO:P1 Context menu might need to be scrollable (both horizontally and vertically)
' TODO:P1 Context menu might need sections. Example: ' TODO:P1 Context menu might need sections. Example:
' In a Channel view, while selecting a playlist: ' In a Channel view, while selecting a playlist:
' - Channel ' - Channel
@@ -22,4 +22,31 @@ namespace DialogUtils
m.top.getScene().dialog = dialog m.top.getScene().dialog = dialog
return dialog return dialog
end function end function
function ShowTimedDialogButtons(message as dynamic, title as string, buttons as object, defaultButton as integer, timeoutSeconds as integer, large = false as boolean) as object
dialog = CreateObject("roSGNode", "TimedDialog")
if GetInterface(message, "ifArray") = invalid
message = message.Tokenize(`\n`).ToArray()
end if
dialog.message = message
dialog.title = title
dialog.actualButtons = buttons
if large
if m._deviceDisplayWidth = invalid
deviceInfo = CreateObject("roDeviceInfo")
displaySize = deviceInfo.GetDisplaySize()
m._deviceDisplayWidth = displaySize.w
end if
dialog.width = m._deviceDisplayWidth - 100
end if
dialog.defaultButtonIndex = defaultButton
dialog.defaultActionTimeoutSeconds = timeoutSeconds
dialog.startCountdown = true
m.top.getScene().dialog = dialog
return dialog
end function
end namespace end namespace
@@ -1,6 +1,4 @@
import "DialogPalette.bs" import "DialogPalette.bs"
import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -33,14 +31,10 @@ function OnUrlSet()
url = m.top.url url = m.top.url
m.urlLabel.text = url m.urlLabel.text = url
AsyncTask.Start(Tasks.GenerateQrCodeTask, { m.qrCode.text = url
poster: m.qrCode
text: url
size: m.qrCode.loadWidth
padding: 10
})
end function end function
function OnAuthTokenChange() function OnAuthTokenChange()
m.invidious.unobserveFieldScoped("authToken")
Close() Close()
end function end function
@@ -25,12 +25,13 @@
wrap="true" width="400"> wrap="true" width="400">
<Font role="font" uri="font:SystemFontFile" size="24" /> <Font role="font" uri="font:SystemFontFile" size="24" />
</Label> </Label>
<Poster <QrCodePoster
id="QrCodePoster" id="QrCodePoster"
width="300" width="300"
height="300" height="300"
loadWidth="300" loadWidth="300"
loadHeight="300" loadHeight="300"
padding="10"
translation="[50, 50]" /> translation="[50, 50]" />
<Label <Label
id="urlLabel" id="urlLabel"
@@ -0,0 +1,98 @@
import "DialogPalette.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/Types.bs"
function Init()
SetPalette(m.top)
m.top.observeField("buttonSelected", FuncName(OnButtonSelected))
m.top.observeField("wasClosed", FuncName(OnDialogClosed))
end function
function OnStartCountdown()
actualButtons = m.top.actualButtons
defaultButtonIndex = m.top.defaultButtonIndex
defaultActionTimeoutSeconds = m.top.defaultActionTimeoutSeconds
buttons = []
for i = 0 to actualButtons.Count() - 1
if i = defaultButtonIndex
buttons.push(`${actualButtons[i]} (${defaultActionTimeoutSeconds})`)
else
buttons.push(actualButtons[i])
end if
end for
m.top.buttons = buttons
CancelTimer()
m.timer = CreateObject("roSGNode", "Timer")
m.timer.repeat = true
m.timer.observeFieldScoped("fire", FuncName(TimerUpdateButtons))
m.currentCountDown = defaultActionTimeoutSeconds
m.timer.control = "start"
end function
function TimerUpdateButtons() as void
m.currentCountDown -= 1
if m.currentCountDown <= 0
m.top.actualButtonSelected = m.top.defaultButtonIndex
m.top.close = true
return
end if
FindButtonComponents()
if m.buttonComponents = invalid
return
end if
defaultButtonIndex = m.top.defaultButtonIndex
m.buttonComponents[defaultButtonIndex].text = `${m.top.actualButtons[defaultButtonIndex]} (${m.currentCountDown})`
end function
function OnButtonSelected()
m.top.actualButtonSelected = m.top.buttonSelected
m.top.close = true
end function
function OnDialogClosed()
CancelTimer()
end function
function onKeyEvent(key as string, press as boolean) as boolean
if m.timer = invalid
return false
end if
CancelTimer()
FindButtonComponents()
if m.buttonComponents = invalid
return false
end if
defaultButtonIndex = m.top.defaultButtonIndex
m.buttonComponents[defaultButtonIndex].text = m.top.actualButtons[defaultButtonIndex]
return false
end function
function CancelTimer()
if m.timer <> invalid
m.timer.control = "stop"
m.timer.unobserveFieldScoped("fire")
m.timer = invalid
end if
end function
function FindButtonComponents() as void
if m.buttonComponents <> invalid
return
end if
areas = m.top.getChildren(-1, 0)
for each area in areas
if area.subtype() = "StdDlgButtonArea"
m.buttonComponents = area.getChildren(-1, 0)
return
end if
end for
LogWarn("No buttons found in dialog")
end function
@@ -0,0 +1,10 @@
<component name="TimedDialog" extends="StandardMessageDialog">
<interface>
<field id="actualButtons" type="stringarray" />
<field id="defaultButtonIndex" type="integer" value="-1" />
<field id="defaultActionTimeoutSeconds" type="integer" value="10" />
<!-- Use actualButtonSelected because buttonSelected is read only and defaults to 0 -->
<field id="actualButtonSelected" type="integer" value="-1" />
<field id="startCountdown" type="boolean" alwaysNotify="true" onChange="OnStartCountdown" />
</interface>
</component>
+2 -4
View File
@@ -29,10 +29,8 @@ function ProcessArguments(args as object) as void
return return
end if end if
if not StringUtils.IsNullOrEmpty(args.contentId) and args.mediaType = "video" if not StringUtils.IsNullOrEmpty(args.contentId) and StringUtils.IsNullOrEmpty(args.videoId)
if StringUtils.IsNullOrEmpty(args.videoId) args.videoId = args.contentId
args.videoId = args.contentId
end if
end if end if
if args.timestamp <> invalid if args.timestamp <> invalid
@@ -22,8 +22,9 @@
<AppController id="AppController"> <AppController id="AppController">
<Group id="Stack"> <Group id="Stack">
<AppRoot id="AppRoot"> <AppRoot id="AppRoot">
<NavBar id="NavBar" focusIndex="1"> <NavBar id="NavBar" focusIndex="2">
<ContentNode role="items"> <ContentNode role="items">
<NavBarItem screen="ProfileScreen" text="Profile" icon="pkg:/images/icons/user.png" padding="10" componentName="ProfileIconButton" />
<NavBarItem screen="SearchScreen" text="Search" icon="pkg:/images/icons/search.png" /> <NavBarItem screen="SearchScreen" text="Search" icon="pkg:/images/icons/search.png" />
<NavBarItem screen="HomeScreen" text="Home" icon="pkg:/images/icons/home.png" /> <NavBarItem screen="HomeScreen" text="Home" icon="pkg:/images/icons/home.png" />
<NavBarItem screen="BookmarksScreen" text="Bookmarks" icon="pkg:/images/icons/star.png" /> <NavBarItem screen="BookmarksScreen" text="Bookmarks" icon="pkg:/images/icons/star.png" />
@@ -41,6 +42,7 @@
<Preferences id="Preferences" /> <Preferences id="Preferences" />
<Bookmarks id="Bookmarks" /> <Bookmarks id="Bookmarks" />
<SearchHistory id="SearchHistory" /> <SearchHistory id="SearchHistory" />
<Profiles id="Profiles" />
<Invidious id="Invidious" /> <Invidious id="Invidious" />
<PlayletWebServer id="WebServer" port="8888" /> <PlayletWebServer id="WebServer" port="8888" />
<DialServer id="DialServer" /> <DialServer id="DialServer" />
+14 -2
View File
@@ -8,8 +8,15 @@
videoQueue="bind:./VideoQueue"> videoQueue="bind:./VideoQueue">
<Group id="Stack"> <Group id="Stack">
<AppRoot id="AppRoot"> <AppRoot id="AppRoot">
<NavBar id="NavBar" focusIndex="1" appController="bind:/AppController"> <NavBar id="NavBar" focusIndex="2" appController="bind:/AppController">
<ContentNode role="items"> <ContentNode role="items">
<NavBarItem
screen="ProfileScreen"
text="Profile"
icon="pkg:/images/icons/user.png"
padding="10"
componentName="ProfileIconButton">
</NavBarItem>
<NavBarItem <NavBarItem
screen="SearchScreen" screen="SearchScreen"
text="Search" text="Search"
@@ -63,10 +70,14 @@
<SearchHistory id="SearchHistory" <SearchHistory id="SearchHistory"
preferences="bind:../Preferences" /> preferences="bind:../Preferences" />
<Profiles id="Profiles"
invidious="bind:../Invidious" />
<Invidious id="Invidious" <Invidious id="Invidious"
webServer="bind:../WebServer" webServer="bind:../WebServer"
applicationInfo="bind:../ApplicationInfo" applicationInfo="bind:../ApplicationInfo"
preferences="bind:../Preferences" /> preferences="bind:../Preferences"
profiles="bind:../Profiles" />
<!-- Tasks --> <!-- Tasks -->
<PlayletWebServer id="WebServer" <PlayletWebServer id="WebServer"
@@ -74,6 +85,7 @@
appController="bind:/AppController" appController="bind:/AppController"
applicationInfo="bind:../ApplicationInfo" applicationInfo="bind:../ApplicationInfo"
invidious="bind:../Invidious" invidious="bind:../Invidious"
profiles="bind:../Profiles"
preferences="bind:../Preferences" preferences="bind:../Preferences"
videoQueue="bind:../VideoQueue" videoQueue="bind:../VideoQueue"
bookmarks="bind:../Bookmarks" bookmarks="bind:../Bookmarks"
@@ -24,15 +24,20 @@ function InitializeBindings()
"SearchHistory": { "SearchHistory": {
"preferences": "../Preferences" "preferences": "../Preferences"
}, },
"Profiles": {
"invidious": "../Invidious"
},
"Invidious": { "Invidious": {
"webServer": "../WebServer", "webServer": "../WebServer",
"applicationInfo": "../ApplicationInfo", "applicationInfo": "../ApplicationInfo",
"preferences": "../Preferences" "preferences": "../Preferences",
"profiles": "../Profiles"
}, },
"WebServer": { "WebServer": {
"appController": "/AppController", "appController": "/AppController",
"applicationInfo": "../ApplicationInfo", "applicationInfo": "../ApplicationInfo",
"invidious": "../Invidious", "invidious": "../Invidious",
"profiles": "../Profiles",
"preferences": "../Preferences", "preferences": "../Preferences",
"videoQueue": "../VideoQueue", "videoQueue": "../VideoQueue",
"bookmarks": "../Bookmarks", "bookmarks": "../Bookmarks",
@@ -1,7 +1,8 @@
import "pkg:/source/utils/MathUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
' Based on https://github.com/jellyfin/jellyfin-roku/blob/unstable/components/IconButton.brs ' Based on https://github.com/jellyfin/jellyfin-roku/blob/unstable/components/IconButton.brs
function init() function Init()
m.buttonBackground = m.top.findNode("buttonBackground") m.buttonBackground = m.top.findNode("buttonBackground")
m.buttonIcon = m.top.findNode("buttonIcon") m.buttonIcon = m.top.findNode("buttonIcon")
m.buttonText = m.top.findNode("buttonText") m.buttonText = m.top.findNode("buttonText")
@@ -40,17 +41,12 @@ function setIconSize()
height = m.top.height height = m.top.height
width = m.top.width width = m.top.width
if height > 0 and width > 0 if height > 0 and width > 0
' TODO: Use smallest number between them iconSize = MathUtils.Min(height, width) - m.top.padding
m.buttonIcon.height = m.top.height m.buttonIcon.height = iconSize
m.buttonIcon.width = iconSize
if m.top.padding > 0 m.buttonIcon.translation = [((width - iconSize) / 2), ((height - iconSize) / 2)]
m.buttonIcon.height = m.buttonIcon.height - m.top.padding m.buttonText.translation = [-5, height + 2]
end if
m.buttonIcon.width = m.buttonIcon.height
m.buttonIcon.translation = [((width - m.buttonIcon.width) / 2), ((height - m.buttonIcon.height) / 2)]
m.buttonText.translation = [-5, height]
m.buttonText.width = width + 10 m.buttonText.width = width + 10
end if end if
end function end function
+2 -2
View File
@@ -29,15 +29,15 @@ function PopulateButtons() as void
buttons = [] buttons = []
for each item in navBarItems for each item in navBarItems
button = CreateObject("roSGNode", "IconButton") button = CreateObject("roSGNode", item.componentName)
button.background = "#242424FF" button.background = "#242424FF"
button.focusBackground = "#FF1C30FF" button.focusBackground = "#FF1C30FF"
button.padding = 20
button.height = 50 button.height = 50
button.width = 90 button.width = 90
button.icon = item.icon button.icon = item.icon
button.text = item.text button.text = item.text
button.padding = item.padding
buttons.push(button) buttons.push(button)
end for end for
@@ -3,5 +3,7 @@
<field id="screen" type="string" /> <field id="screen" type="string" />
<field id="icon" type="string" /> <field id="icon" type="string" />
<field id="text" type="string" /> <field id="text" type="string" />
<field id="padding" type="integer" value="20" />
<field id="componentName" type="string" value="IconButton" />
</interface> </interface>
</component> </component>
@@ -0,0 +1,111 @@
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/MathUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
' TODO:P1 this file is a copy paste of IconButton. It should be refactored.
function Init()
m.buttonBackground = m.top.findNode("buttonBackground")
m.buttonIcon = m.top.findNode("buttonIcon")
m.buttonText = m.top.findNode("buttonText")
m.circlePoster = m.top.findNode("circlePoster")
m.circlePosterInner = m.top.findNode("circlePosterInner")
m.letterLabel = m.top.findNode("LetterLabel")
m.top.observeField("background", FuncName(onBackgroundChanged))
m.top.observeField("icon", FuncName(onIconChanged))
m.top.observeField("text", FuncName(onTextChanged))
m.top.observeField("height", FuncName(onHeightChanged))
m.top.observeField("width", FuncName(onWidthChanged))
m.top.observeField("padding", FuncName(onPaddingChanged))
profiles = m.top.getScene().findNode("Profiles")
if profiles <> invalid
m.profiles = profiles
profiles.observeField("currentProfile", FuncName(OnCurrentProfile))
OnCurrentProfile()
end if
end function
function OnFocusChange()
if m.top.focus
m.buttonBackground.blendColor = m.top.focusBackground
else
m.buttonBackground.blendColor = m.top.background
end if
m.buttonBackground.visible = m.top.focus
m.buttonText.visible = m.top.focus
end function
function onBackgroundChanged()
m.buttonBackground.blendColor = m.top.background
end function
function onIconChanged()
m.buttonIcon.uri = m.top.icon
end function
function onTextChanged()
m.buttonText.text = m.top.text
end function
function setIconSize()
height = m.top.height
width = m.top.width
if height > 0 and width > 0
iconSize = MathUtils.Min(height, width) - m.top.padding
m.buttonIcon.height = iconSize
m.buttonIcon.width = iconSize
iconTranslation = [((width - iconSize) / 2), ((height - iconSize) / 2)]
m.buttonIcon.translation = iconTranslation
m.buttonText.translation = [-5, height + 2]
m.buttonText.width = width + 10
m.circlePoster.width = iconSize
m.circlePoster.height = iconSize
m.circlePoster.translation = iconTranslation
m.circlePosterInner.width = iconSize - 4
m.circlePosterInner.height = iconSize - 4
m.letterLabel.width = iconSize - 4
m.letterLabel.height = iconSize - 4
end if
end function
function onHeightChanged()
m.buttonBackground.height = m.top.height
setIconSize()
end function
function onWidthChanged()
m.buttonBackground.width = m.top.width - 10
m.buttonBackground.translation = [5, 0]
setIconSize()
end function
function onPaddingChanged()
setIconSize()
end function
function OnCurrentProfile() as void
currentProfile = m.profiles.currentProfile
if currentProfile = invalid
m.circlePoster.visible = false
m.buttonIcon.visible = true
return
end if
username = currentProfile.username
if not StringUtils.IsNullOrEmpty(username)
m.LetterLabel.text = UCase(username.Left(1))
else
m.LetterLabel.text = ""
end if
m.circlePosterInner.blendColor = currentProfile.color
m.circlePoster.visible = true
m.buttonIcon.visible = false
end function
@@ -0,0 +1,40 @@
<component name="ProfileIconButton" extends="Group" includes="Focus">
<interface>
<field id="background" type="color" value="" />
<field id="focusBackground" type="color" value="" />
<field id="text" type="string" value="" />
<field id="padding" type="integer" value="-1" />
<field id="height" type="integer" value="" />
<field id="width" type="integer" value="" />
<field id="icon" type="string" value="" />
</interface>
<children>
<Poster id="buttonBackground" uri="pkg:/images/white.9.png" visible="false" />
<Poster id="buttonIcon" />
<Poster
id="circlePoster"
width="40"
height="40"
uri="pkg:/images/white-circle.png">
<Poster
id="circlePosterInner"
width="36"
height="36"
blendColor="#9696c8"
uri="pkg:/images/white-circle.png"
translation="[2,2]">
<Label
id="LetterLabel"
width="40"
height="40"
vertAlign="center"
horizAlign="center">
<Font role="font" uri="font:SystemFontFile" size="24" />
</Label>
</Poster>
</Poster>
<Label id="buttonText" color="#aaaaaa" font="font:SmallestSystemFont" vertAlign="center" horizAlign="center" visible="false" />
</children>
</component>
@@ -1,6 +1,5 @@
import "pkg:/components/ChannelView/ChannelUtils.bs" import "pkg:/components/ChannelView/ChannelUtils.bs"
import "pkg:/components/ContextMenu/ContextMenuUtils.bs" import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Navigation/LongPress.bs" import "pkg:/components/Navigation/LongPress.bs"
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs" import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
import "pkg:/components/VideoFeed/FeedLoadState.bs" import "pkg:/components/VideoFeed/FeedLoadState.bs"
@@ -143,9 +142,6 @@ function OnItemLongPressed(index as integer) as void
LogInfo("Long press: playlist:", playlistId, "video:", videoId) LogInfo("Long press: playlist:", playlistId, "video:", videoId)
' TODO:P1 handle case of opening the channel
' - Owner of a video
' - Owner of a playlist
contextMenuProviders = [m.top] contextMenuProviders = [m.top]
ContextMenuUtils.Open(contextMenuProviders, m.appController, video) ContextMenuUtils.Open(contextMenuProviders, m.appController, video)
end function end function
@@ -173,8 +169,20 @@ function GetContextMenuOptionsForItem(video as object) as object
ContextMenuUtils.CreateOption("Queue video", m.videoQueue, "FuncAddToQueueVideo", [video]), ContextMenuUtils.CreateOption("Queue video", m.videoQueue, "FuncAddToQueueVideo", [video]),
] ]
if not StringUtils.IsNullOrEmpty(playlist.authorId) playlistAuthorId = playlist.authorId
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [playlist])) videoAuthorId = video.authorId
if not StringUtils.IsNullOrEmpty(playlistAuthorId) or not StringUtils.IsNullOrEmpty(videoAuthorId)
if playlistAuthorId = videoAuthorId
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [playlist]))
else
if not StringUtils.IsNullOrEmpty(playlistAuthorId)
options.push(ContextMenuUtils.CreateOption("Open playlist channel", m.top, "OpenPlaylistChannel", [playlist]))
end if
if not StringUtils.IsNullOrEmpty(videoAuthorId)
options.push(ContextMenuUtils.CreateOption("Open video channel", m.top, "OpenVideoChannel", [video]))
end if
end if
end if end if
options.append(m.bookmarks@.GetMenuForPlaylist(playlist)) options.append(m.bookmarks@.GetMenuForPlaylist(playlist))
@@ -193,6 +201,16 @@ function OpenPlaylistChannel(playlist as object) as void
ChannelUtils.Open(channel) ChannelUtils.Open(channel)
end function end function
function OpenVideoChannel(video as object) as void
authorId = video.authorId
if StringUtils.IsNullOrEmpty(authorId)
LogWarn("Invalid authorId:", authorId)
return
end if
channel = InvidiousContent.ToChannelContentNode(invalid, { authorId: authorId }, invalid)
ChannelUtils.Open(channel)
end function
'TODO:P1 a playlist could have been opened from the bookmarks, which can be as old as 3 days 'TODO:P1 a playlist could have been opened from the bookmarks, which can be as old as 3 days
' We should make a request in this case, and let the cache handle freshness. ' We should make a request in this case, and let the cache handle freshness.
function LoadPlaylistIfNeeded() as void function LoadPlaylistIfNeeded() as void
@@ -6,6 +6,7 @@
<field id="videoQueue" type="node" bind="/VideoQueue" /> <field id="videoQueue" type="node" bind="/VideoQueue" />
<field id="bookmarks" type="node" bind="/Bookmarks" /> <field id="bookmarks" type="node" bind="/Bookmarks" />
<function name="OpenPlaylistChannel" /> <function name="OpenPlaylistChannel" />
<function name="OpenVideoChannel" />
</interface> </interface>
<children> <children>
<Rectangle <Rectangle
@@ -56,8 +57,8 @@
numColumns="1" numColumns="1"
numRows="5" numRows="5"
vertFocusAnimationStyle="floatingFocus" vertFocusAnimationStyle="floatingFocus"
translation="[620,90]" /> translation="[620,90]"
focusBitmapUri="pkg:/images/focus-glow-padding-27.9.png" />
</Poster> </Poster>
</children> </children>
</component> </component>
@@ -0,0 +1,160 @@
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/source/utils/DisposableObserve.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.activateButton = m.top.findNode("activateButton")
m.logoutButton = m.top.findNode("logoutButton")
m.closeButton = m.top.findNode("closeButton")
m.buttonGroup = m.top.findNode("buttonGroup")
DisposableObserveField(m.activateButton, "buttonSelected", FuncName(Activate))
DisposableObserveField(m.logoutButton, "buttonSelected", FuncName(Logout))
DisposableObserveField(m.closeButton, "buttonSelected", FuncName(Close))
end function
function OnNodeReady()
SetNavigation(m.activateButton, "down", m.logoutButton)
SetNavigation(m.logoutButton, "down", m.closeButton)
SetNavigation(m.closeButton, "up", m.logoutButton)
SetNavigation(m.logoutButton, "up", m.activateButton)
DisposableObserveFieldScoped(m.profiles, "currentProfile", FuncName(OnCunrrentProfileChanged))
DisposableObserveFieldScoped(m.profiles, "onProfileLogout", FuncName(OnProfileLogout))
end function
function OnContentSet() as void
content = m.top.content
if content = invalid
return
end if
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
m.top.circlePosterInnerBlendColor = content.color
username = content.username
m.top.username = username
if not StringUtils.IsNullOrEmpty(username)
m.top.letter = UCase(username.Left(1))
else
m.top.letter = ""
end if
m.top.serverUrl = content.serverUrl
m.top.crownVisible = content.isSelected
UpdateActivateButton()
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
if m.activateButton.focusable
NodeSetFocus(m.activateButton, true)
else
NodeSetFocus(m.logoutButton, true)
end if
end function
function OnkeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled
return true
end if
if key = "options"
' A pass-through to the app controller, so it can toggle picture-in-picture
return false
end if
if key = "back" and press
Close()
return true
end if
return true
end function
function Activate() as void
content = m.top.content
if content = invalid
return
end if
profile = m.profiles.content.getChild(0).findNode(content.id)
if profile = invalid
return
end if
m.top.content = invalid
m.profiles@.SetCurrentProfile(profile)
Close()
end function
function Logout() as void
content = m.top.content
if content = invalid
return
end if
m.top.content = invalid
m.profiles@.LogoutWithProfile(content)
Close()
end function
function Close()
m.top.appController@.PopScreen()
m.top.dispose = true
end function
function OnDispose()
DisposeObservers()
m.top.content = invalid
end function
function OnCunrrentProfileChanged() as void
content = m.top.content
if content = invalid
return
end if
m.top.crownVisible = content.isSelected
UpdateActivateButton()
end function
function OnProfileLogout() as void
content = m.top.content
if content = invalid
return
end if
profile = m.profiles.content.getChild(0).findNode(content.id)
if profile = invalid
Close()
end if
end function
function UpdateActivateButton() as void
content = m.top.content
if content = invalid
return
end if
isSelected = content.isSelected
if isSelected
if m.activateButton.hasFocus()
NodeSetFocus(m.logoutButton, true)
end if
parent = m.activateButton.getParent()
if parent <> invalid
m.buttonGroup.removeChild(m.activateButton)
end if
m.activateButton.focusable = false
else
parent = m.activateButton.getParent()
if parent = invalid
m.buttonGroup.insertChild(m.activateButton, 0)
end if
m.activateButton.focusable = true
end if
end function
@@ -0,0 +1,97 @@
<component name="ProfileView" extends="Group" includes="AutoBind,Focus,Disposable">
<interface>
<field id="content" type="node" onChange="OnContentSet" />
<field id="letter" type="string" alias="LetterLabel.text" />
<field id="username" type="string" alias="UsernameLabel.text" />
<field id="serverUrl" type="string" alias="ServerLabel.text" />
<field id="circlePosterInnerUri" type="uri" alias="circlePosterInner.uri" />
<field id="circlePosterInnerBlendColor" type="uri" alias="circlePosterInner.blendColor" />
<field id="crownVisible" type="boolean" alias="CrownPoster.visible" />
<field id="appController" type="node" bind="/AppController" />
<field id="profiles" type="node" bind="/Profiles" />
</interface>
<children>
<Rectangle
width="1280"
height="720"
color="#000000"
opacity="0.5">
</Rectangle>
<Rectangle
width="720"
height="420"
translation="[280,150]"
color="#242424">
<Group translation="[100,90]">
<Poster
id="circlePoster"
width="160"
height="160"
translation="[20,20]"
uri="pkg:/images/white-circle.png">
<Poster
id="circlePosterInner"
width="152"
height="152"
blendColor="#9696c8"
uri="pkg:/images/white-circle.png"
translation="[4,4]">
<Label
id="LetterLabel"
width="152"
height="152"
vertAlign="center"
horizAlign="center">
<Font role="font" uri="font:SystemFontFile" size="120" />
</Label>
</Poster>
<Poster
id="CrownPoster"
width="60"
height="60"
translation="[50,-60]"
uri="pkg:/images/icons/crown.png"
visible="false">
</Poster>
</Poster>
<Label
id="UsernameLabel"
width="200"
horizAlign="center"
translation="[0,210]">
<Font role="font" uri="font:BoldSystemFontFile" size="26" />
</Label>
<Label
id="ServerLabel"
width="400"
horizAlign="center"
translation="[-100,250]">
<Font role="font" uri="font:SystemFontFile" size="18" />
</Label>
</Group>
<LayoutGroup
id="buttonGroup"
translation="[420,94]"
itemSpacings="[20,20]">
<Button
id="activateButton"
text="Activate"
minWidth="200"
showFocusFootprint="true" />
<Button
id="logoutButton"
text="Logout"
minWidth="200"
showFocusFootprint="true" />
<Button
id="closeButton"
text="Close"
minWidth="200"
showFocusFootprint="true" />
</LayoutGroup>
</Rectangle>
</children>
</component>
@@ -0,0 +1,11 @@
namespace ProfileViewUtils
function Open(profile as object, appController as object)
profileView = CreateObject("roSGNode", "ProfileView")
appController@.PushScreen(profileView)
profileView@.BindNode()
profileView.content = profile
end function
end namespace
@@ -2,7 +2,7 @@ import "pkg:/source/QrCode/QrImage.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
@asynctask @asynctask
function GenerateQrCodeTask(input as object) function GenerateQrCodeTask(input as object) as object
poster = input.poster poster = input.poster
mode = input.mode mode = input.mode
text = input.text text = input.text
@@ -24,7 +24,13 @@ function GenerateQrCodeTask(input as object)
qr = new QrCode.QRImage() qr = new QrCode.QRImage()
imagePath = qr.Generate(text, size, padding, mode) imagePath = qr.Generate(text, size, padding, mode)
if m.top.cancel
return invalid
end if
if not StringUtils.IsNullOrEmpty(imagePath) if not StringUtils.IsNullOrEmpty(imagePath)
poster.uri = imagePath poster.uri = imagePath
end if end if
return invalid
end function end function
@@ -0,0 +1,65 @@
import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.busySpinner = m.top.findNode("busySpinner")
m.busySpinnerPoster = m.busySpinner.poster
m.busySpinnerPoster.uri = "pkg:/images/spinner.png"
m.top.observeField("width", FuncName(OnSizeChange))
m.top.observeField("height", FuncName(OnSizeChange))
OnSizeChange()
end function
function OnSizeChange()
width = m.top.width
height = m.top.height
m.busySpinnerPoster.width = width / 2
m.busySpinnerPoster.height = height / 2
m.busySpinner.translation = [width / 4, height / 4]
end function
function OnTextChange() as void
if m.qrCodeGenTask <> invalid
m.qrCodeGenTask.cancel = true
end if
text = m.top.text
width = m.top.loadWidth
if width = 0
width = m.top.width
end if
m.top.uri = ""
if StringUtils.IsNullOrEmpty(text)
m.busySpinner.control = "stop"
m.busySpinner.visible = false
return
end if
m.busySpinnerPoster.rotation = 0
m.busySpinner.visible = true
m.busySpinner.control = "start"
m.qrCodeGenTask = AsyncTask.Start(Tasks.GenerateQrCodeTask, {
poster: m.top
text: text
size: width
padding: m.top.padding
}, OnGenerateQrCodeTaskResult)
end function
function OnGenerateQrCodeTaskResult(output as object) as void
if output.cancelled
return
end if
m.busySpinner.control = "stop"
m.busySpinner.visible = false
end function
@@ -0,0 +1,12 @@
<component name="QrCodePoster" extends="Poster">
<interface>
<field id="text" type="string" onChange="OnTextChange" />
<field id="padding" type="integer" />
</interface>
<children>
<BusySpinner
id="busySpinner"
spinInterval="1"
visible="false" />
</children>
</component>
@@ -31,7 +31,7 @@
showRowLabel="[true]" showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus" rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true" variableWidthItems="true"
focusBitmapUri="pkg:/images/focus_grid.9.png" focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png"
/> />
</Group> </Group>
</children> </children>
@@ -20,7 +20,7 @@
showRowLabel="[true]" showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus" rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true" variableWidthItems="true"
focusBitmapUri="pkg:/images/focus_grid.9.png" focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png"
/> />
</children> </children>
</component> </component>
@@ -0,0 +1,2 @@
<component name="ProfileRowList" extends="RowList">
</component>
@@ -0,0 +1,68 @@
import "pkg:/source/utils/StringUtils.bs"
function Init()
m.normalFont = m.top.findNode("normalFont")
m.boldFont = m.top.findNode("boldFont")
end function
function OnContentSet() as void
content = m.top.itemContent
if content = invalid
return
end if
if content.type = "login"
m.top.circlePosterInnerUri = "pkg:/images/icons/user-200.png"
' bs:disable-next-line LINT3023
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
m.top.letter = ""
m.top.username = "Login"
m.top.serverUrl = ""
m.top.crownVisible = false
return
end if
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
m.top.circlePosterInnerBlendColor = content.color
username = content.username
m.top.username = username
if not StringUtils.IsNullOrEmpty(username)
m.top.letter = UCase(username.Left(1))
else
m.top.letter = ""
end if
m.top.serverUrl = content.serverUrl
m.top.crownVisible = content.isSelected
end function
function OnRowListHasFocus()
if not m.top.rowListHasFocus
m.top.animate = false
end if
end function
function OnItemHasFocus()
m.top.animate = (m.top.itemHasFocus or m.top.focusPercent > 0.5) and m.top.rowListHasFocus
end function
function OnFocusPercent()
if m.top.focusPercent > 0.5 and m.top.rowListHasFocus
m.top.animate = true
else
m.top.animate = false
end if
end function
function OnAnimate()
animate = m.top.animate
m.top.shadowVisible = animate
m.top.serverLabelVisible = animate
m.top.circlePosterTranslation = [20, 20]
if animate
m.top.UsernameLabelFont = m.boldFont
m.top.animationControl = "start"
else
m.top.UsernameLabelFont = m.normalFont
m.top.animationControl = "stop"
end if
end function
@@ -0,0 +1,106 @@
<component name="ProfileRowListCell" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="letter" type="string" alias="LetterLabel.text" />
<field id="username" type="string" alias="UsernameLabel.text" />
<field id="serverUrl" type="string" alias="ServerLabel.text" />
<field id="circlePosterInnerUri" type="uri" alias="circlePosterInner.uri" />
<field id="circlePosterInnerBlendColor" type="uri" alias="circlePosterInner.blendColor" />
<field id="UsernameLabelFont" type="boolean" alias="UsernameLabel.font" />
<field id="rowListHasFocus" type="boolean" onChange="OnRowListHasFocus" />
<field id="itemHasFocus" type="boolean" onChange="OnItemHasFocus" />
<field id="focusPercent" type="float" onChange="OnFocusPercent" />
<field id="circlePosterTranslation" type="vector2d" alias="circlePoster.translation" />
<field id="animate" type="boolean" onChange="OnAnimate" />
<field id="animationControl" type="string" alias="floatAnimation.control" />
<field id="shadowVisible" type="boolean" alias="shadowPoster.visible" />
<field id="crownVisible" type="boolean" alias="CrownPoster.visible" />
<field id="serverLabelVisible" type="boolean" alias="ServerLabel.visible" />
</interface>
<children>
<Font id="normalFont" uri="font:SystemFontFile" size="24" />
<Font id="boldFont" uri="font:BoldSystemFontFile" size="26" />
<Group translation="[20,50]">
<Group
id="shadowScaler"
translation="[100,20]">
<Group translation="[-100,-20]">
<Poster
id="shadowPoster"
uri="pkg:/images/white-circle.png"
blendColor="#000000"
width="200"
height="40"
translation="[0,200]"
visible="false">
</Poster>
</Group>
</Group>
<Poster
id="circlePoster"
width="160"
height="160"
translation="[20,20]"
uri="pkg:/images/white-circle.png">
<Poster
id="circlePosterInner"
width="152"
height="152"
blendColor="#9696c8"
uri="pkg:/images/white-circle.png"
translation="[4,4]">
<Label
id="LetterLabel"
width="152"
height="152"
vertAlign="center"
horizAlign="center">
<Font role="font" uri="font:SystemFontFile" size="120" />
</Label>
</Poster>
<Poster
id="CrownPoster"
width="60"
height="60"
translation="[50,-60]"
uri="pkg:/images/icons/crown.png"
visible="false">
</Poster>
</Poster>
<Label
id="UsernameLabel"
width="200"
horizAlign="center"
translation="[0,250]">
</Label>
<Label
id="ServerLabel"
width="400"
horizAlign="center"
translation="[-100,310]"
visible="false">
<Font role="font" uri="font:SystemFontFile" size="18" />
</Label>
</Group>
<Animation
id="floatAnimation"
repeat="true"
duration="4"
easeFunction="inOutQuad">
<Vector2DFieldInterpolator
key="[ 0.0, 0.5, 0.55, 1.0 ]"
keyValue="[ [20,40], [20,10], [20,10], [20,40]]"
fieldToInterp="circlePoster.translation" />
<Vector2DFieldInterpolator
key="[ 0.0, 0.5, 0.55, 1.0 ]"
keyValue="[ [0.7,1], [1.05,1],[1.05,1] , [0.7,1] ]"
fieldToInterp="shadowScaler.scale" />
<FloatFieldInterpolator
key="[ 0.0, 0.5, 0.55, 1.0 ]"
keyValue="[0.3, 0.05 ,0.05, 0.3 ]"
fieldToInterp="shadowPoster.opacity" />
</Animation>
</children>
</component>
@@ -0,0 +1,63 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/ProfileView/ProfileViewUtils.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.top.focusable = true
m.profileRowList = m.top.FindNode("ProfileRowList")
end function
function OnNodeReady()
SetNavigation(invalid, "back", m.navBar)
SetNavigation(invalid, "left", m.navBar)
m.profileRowList.content = m.profiles.content
m.profileRowList.observeFieldScoped("rowItemSelected", FuncName(OnRowItemSelected))
m.profiles.observeFieldScoped("currentProfile", FuncName(OnCurrentProfileChanged))
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
NodeSetFocus(m.profileRowList, true)
end function
function OnkeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled
return true
end if
return false
end function
function OnRowItemSelected() as void
index = m.profileRowList.rowItemSelected[1]
row = m.profileRowList.content.GetChild(0)
selectedProfile = row.GetChild(index)
if selectedProfile.type = "login"
dialog = CreateObject("roSGNode", "LoginDialog")
dialog@.BindNode()
m.top.getScene().dialog = dialog
return
end if
ProfileViewUtils.Open(selectedProfile, m.appController)
end function
function OnCurrentProfileChanged() as void
currentProfile = m.profiles.currentProfile
if currentProfile = invalid
return
end if
row = m.profileRowList.content.GetChild(0)
allProfiles = row.getChildren(-1, 0)
for i = 0 to allProfiles.Count() - 1
if currentProfile.id = allProfiles[i].id
m.profileRowList.jumpToRowItem = [0, i]
return
end if
end for
end function
@@ -0,0 +1,21 @@
<component name="ProfileScreen" extends="Group" includes="AutoBind,Focus">
<interface>
<field id="navBar" type="node" bind="/NavBar" />
<field id="profiles" type="node" bind="/Profiles" />
<field id="appController" type="node" bind="/AppController" />
</interface>
<children>
<ProfileRowList
id="ProfileRowList"
translation="[0,160]"
numRows="2"
rowitemSize="[[240,340]]"
rowItemSpacing="[[0,0]]"
itemSize="[1280,500]"
focusXOffset="[200]"
itemComponentName="ProfileRowListCell"
rowFocusAnimationStyle="floatingfocus"
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" />
</children>
</component>
@@ -1,8 +1,6 @@
import "pkg:/components/Dialog/DialogUtils.bs" import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Navigation/Navigation.bs" import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/source/AsyncTask/AsyncTask.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/AsyncTask/Tasks.bs"
import "pkg:/source/utils/ErrorUtils.bs" import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
@@ -18,7 +16,10 @@ function Init()
m.linkWithWifiPanel = m.top.findNode("LinkWithWiFiPanel") m.linkWithWifiPanel = m.top.findNode("LinkWithWiFiPanel")
m.linkWithTvPanel = m.top.findNode("LinkWithTvPanel") m.linkWithTvPanel = m.top.findNode("LinkWithTvPanel")
m.webAppUrlLabel = m.top.findNode("WebAppUrlLabel")
m.webAppQrCodePoster = m.top.findNode("WebAppQrCodePoster")
m.wifiNameLabel = m.top.findNode("WifiNameLabel") m.wifiNameLabel = m.top.findNode("WifiNameLabel")
m.wifiInstructionWithDeviceNameLabel = m.top.findNode("WifiInstructionWithDeviceNameLabel")
m.linkCodeLabel = m.top.findNode("LinkCodeLabel") m.linkCodeLabel = m.top.findNode("LinkCodeLabel")
end function end function
@@ -64,16 +65,8 @@ end function
function OnUrlSet() function OnUrlSet()
url = m.top.url url = m.top.url
urlLabel = m.top.findNode("urlLabel") m.webAppUrlLabel.text = url
urlLabel.text = url m.webAppQrCodePoster.text = url
qrCodePoster = m.top.findNode("QrCodePoster")
AsyncTask.Start(Tasks.GenerateQrCodeTask, {
poster: qrCodePoster
text: url
size: qrCodePoster.loadWidth
padding: 20
})
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnkeyEvent(key as string, press as boolean) as boolean
@@ -128,6 +121,8 @@ function OnLinkWithWifiPanelVisibleChanged() as void
else else
m.wifiNameLabel.text = "N/A" m.wifiNameLabel.text = "N/A"
end if end if
m.wifiInstructionWithDeviceNameLabel.text = `Tap the cast icon and select "${m.loungeService.deviceName}"`
end function end function
function OnLinkWithTvPanelVisibleChanged() function OnLinkWithTvPanelVisibleChanged()
@@ -147,6 +142,7 @@ function GeneratePairingCode()
m.linkCodeTask.cancel = true m.linkCodeTask.cancel = true
end if end if
m.linkCodeLabel.text = "Loading..."
m.linkCodeTask = AsyncTask.Start(Tasks.LoungeGenerateManualPairingCodeTask, { m.linkCodeTask = AsyncTask.Start(Tasks.LoungeGenerateManualPairingCodeTask, {
loungeService: m.loungeService loungeService: m.loungeService
loungeToken: m.loungeService.loungeToken loungeToken: m.loungeService.loungeToken
@@ -47,15 +47,16 @@
font="font:SmallBoldSystemFont" font="font:SmallBoldSystemFont"
horizAlign="center" horizAlign="center"
text="Scan the QR code" /> text="Scan the QR code" />
<Poster <QrCodePoster
id="QrCodePoster" id="WebAppQrCodePoster"
height="400" height="400"
width="400" width="400"
loadHeight="400" loadHeight="400"
loadWidth="400" loadWidth="400"
padding="20"
translation="[0,40]" /> translation="[0,40]" />
<Label <Label
id="UrlLabel" id="WebAppUrlLabel"
height="30" height="30"
width="400" width="400"
font="font:SmallBoldSystemFont" font="font:SmallBoldSystemFont"
@@ -91,6 +92,7 @@
font="font:SmallSystemFont" font="font:SmallSystemFont"
text="3." /> text="3." />
<Label <Label
id="WifiInstructionWithDeviceNameLabel"
font="font:SmallSystemFont" font="font:SmallSystemFont"
width="380" width="380"
wrap="true" wrap="true"
@@ -1,3 +1,4 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Navigation/Navigation.bs" import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/Services/SearchHistory/SearchHistoryUtils.bs" import "pkg:/components/Services/SearchHistory/SearchHistoryUtils.bs"
import "pkg:/source/AsyncTask/AsyncTask.bs" import "pkg:/source/AsyncTask/AsyncTask.bs"
@@ -203,8 +204,6 @@ end function
function Search(text as string) function Search(text as string)
m.rowlist.UnobserveFieldScoped("someContentReady") m.rowlist.UnobserveFieldScoped("someContentReady")
' TODO:P1 someContentReady only fires if there are search results.
' The case where search results are empty is not handled.
m.rowlist.ObserveFieldScoped("someContentReady", FuncName(OnSearchContentReady)) m.rowlist.ObserveFieldScoped("someContentReady", FuncName(OnSearchContentReady))
ShowLoadingScreen() ShowLoadingScreen()
@@ -238,10 +237,16 @@ function Search(text as string)
end function end function
function OnSearchContentReady() as void function OnSearchContentReady() as void
m.rowlist.UnobserveFieldScoped("someContentReady")
if not m.rowlist.someContentReady if not m.rowlist.someContentReady
DialogUtils.ShowDialog("We didn't find any results for your search. Please try again with a different query or different filters.", "No results found")
m.rowlist.feeds = invalid
m.rowlist.focusable = false
HideLoadingScreen()
return return
end if end if
m.rowlist.UnobserveFieldScoped("someContentReady")
m.rowlist.focusable = true m.rowlist.focusable = true
m.currentNavigtionNode = m.rowList m.currentNavigtionNode = m.rowList
NodeSetFocus(m.rowlist, true) NodeSetFocus(m.rowlist, true)
@@ -253,6 +258,7 @@ function OnSearchContentReady() as void
end function end function
function OnSearchError() function OnSearchError()
' Note: we don't display an error dialog, VideoRowListRowContentTask will do that.
m.rowlist.feeds = invalid m.rowlist.feeds = invalid
m.rowlist.focusable = false m.rowlist.focusable = false
HideLoadingScreen() HideLoadingScreen()
@@ -46,7 +46,7 @@
showRowLabel="[true]" showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus" rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true" variableWidthItems="true"
focusBitmapUri="pkg:/images/focus_grid.9.png" focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png"
/> />
<Animation <Animation
id="scrollAnimation" id="scrollAnimation"
@@ -1,5 +1,7 @@
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs" import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
@@ -7,6 +9,7 @@ function Init()
m.top.itemSpacings = [8] m.top.itemSpacings = [8]
m.button = m.top.findNode("button") m.button = m.top.findNode("button")
m.button.text = Invidious.DEFAULT_INSTANCE
AdjustButtonLabel(m.button) AdjustButtonLabel(m.button)
m.button.observeField("buttonSelected", FuncName(OpenInvidiousInstanceSettings)) m.button.observeField("buttonSelected", FuncName(OpenInvidiousInstanceSettings))
@@ -74,5 +77,12 @@ function OnValueChange() as void
return return
end if end if
m.preferences[m.key] = m.top.value value = m.top.value
m.preferences[m.key] = value
if StringUtils.IsNullOrEmpty(value)
m.button.text = Invidious.DEFAULT_INSTANCE
else
m.button.text = value
end if
end function end function
@@ -2,7 +2,7 @@
<interface> <interface>
<field id="displayText" type="string" alias="DisplayTextLabel.text" /> <field id="displayText" type="string" alias="DisplayTextLabel.text" />
<field id="description" type="string" alias="DescriptionLabel.text" /> <field id="description" type="string" alias="DescriptionLabel.text" />
<field id="value" type="string" alias="Button.text" onChange="OnValueChange" /> <field id="value" type="string" onChange="OnValueChange" />
<field id="appController" type="node" bind="/AppController" /> <field id="appController" type="node" bind="/AppController" />
<function name="BindPreference" /> <function name="BindPreference" />
</interface> </interface>
@@ -9,6 +9,7 @@
<children> <children>
<BusySpinner <BusySpinner
id="busySpinner" id="busySpinner"
spinInterval="2"
translation="[5,0]" /> translation="[5,0]" />
<Label <Label
id="nameLabel" id="nameLabel"
@@ -5,6 +5,7 @@
<children> <children>
<BusySpinner <BusySpinner
id="busySpinner" id="busySpinner"
spinInterval="1"
translation="[380,96]" /> translation="[380,96]" />
<Label <Label
id="failedLabel" id="failedLabel"
@@ -30,12 +31,13 @@
<MarkupGrid <MarkupGrid
id="instances" id="instances"
itemComponentName="InvidiousPublicInstancesListItem" itemComponentName="InvidiousPublicInstancesListItem"
itemSize="[860,16]" itemSize="[810,16]"
itemSpacing="[0,20]" itemSpacing="[0,20]"
numColumns="1" numColumns="1"
numRows="7" numRows="7"
vertFocusAnimationStyle="floatingFocus" vertFocusAnimationStyle="floatingFocus"
translation="[0,46]" /> translation="[0,46]"
focusBitmapUri="pkg:/images/white-border.9.png" />
</children> </children>
</component> </component>
@@ -42,7 +42,7 @@
<Label <Label
id="healthLabel" id="healthLabel"
font="font:SmallestSystemFont" font="font:SmallestSystemFont"
width="100" width="60"
translation="[750,0]" /> translation="[750,0]" />
</children> </children>
</component> </component>
@@ -11,7 +11,7 @@ function Init()
m.top.iconUri = "" m.top.iconUri = ""
m.top.focusedIconUri = "" m.top.focusedIconUri = ""
m.top.focusBitmapUri = "pkg:/images/white.9.png" m.top.focusBitmapUri = "pkg:/images/white.9.png"
m.top.focusFootprintBitmapUri = "pkg:/images/white_border.9.png" m.top.focusFootprintBitmapUri = "pkg:/images/white-border.9.png"
m.top.showFocusFootprint = true m.top.showFocusFootprint = true
m.top.observeField("focusedChild", FuncName(OnFocusedChildChange)) m.top.observeField("focusedChild", FuncName(OnFocusedChildChange))
end function end function
@@ -14,6 +14,7 @@ function GetLatestPlayletLibVersionFromGithubReleases() as string
if response.StatusCode() = 200 if response.StatusCode() = 200
headers = response.Headers() headers = response.Headers()
if headers.location <> invalid if headers.location <> invalid
' bs:disable-next-line NO_OPTIONAL_CHAINING
regex = /\/v?(\d+\.\d+\.\d+)/ regex = /\/v?(\d+\.\d+\.\d+)/
match = regex.match(headers.location) match = regex.match(headers.location)
if match.Count() = 2 if match.Count() = 2
@@ -5,7 +5,6 @@ import "pkg:/source/AsyncTask/Tasks.bs"
function Init() function Init()
m.top.apiDefinitions = ParseJson(ReadAsciiFile("libpkg:/config/invidious_video_api.yaml")) m.top.apiDefinitions = ParseJson(ReadAsciiFile("libpkg:/config/invidious_video_api.yaml"))
m.service = new Invidious.InvidiousService(m.top) m.service = new Invidious.InvidiousService(m.top)
m.top.authToken = m.service.GetAuthToken()
end function end function
function GetCurrentInstance(_unused as dynamic) as string function GetCurrentInstance(_unused as dynamic) as string
@@ -16,10 +15,6 @@ function GetAuthorizeTokenLink(_unused as dynamic) as dynamic
return m.service.GetAuthorizeTokenLink() return m.service.GetAuthorizeTokenLink()
end function end function
function SetAuthToken(token as string, instance as string, username as dynamic)
m.service.SetAuthToken(token, instance, username)
end function
function OnAuthTokenChange() as void function OnAuthTokenChange() as void
m.top.refreshSubscribtions = true m.top.refreshSubscribtions = true
end function end function
@@ -3,6 +3,7 @@
<field id="applicationInfo" type="node" /> <field id="applicationInfo" type="node" />
<field id="preferences" type="node" /> <field id="preferences" type="node" />
<field id="webServer" type="node" /> <field id="webServer" type="node" />
<field id="profiles" type="node" />
<field id="authToken" type="assocarray" onChange="OnAuthTokenChange" /> <field id="authToken" type="assocarray" onChange="OnAuthTokenChange" />
<field id="apiDefinitions" type="assocarray" /> <field id="apiDefinitions" type="assocarray" />
@@ -11,6 +12,5 @@
<function name="GetCurrentInstance" /> <function name="GetCurrentInstance" />
<function name="GetAuthorizeTokenLink" /> <function name="GetAuthorizeTokenLink" />
<function name="SetAuthToken" />
</interface> </interface>
</component> </component>
@@ -37,15 +37,15 @@ namespace Invidious
const ERROR_NOT_AUTHENTICATED = "Not authenticated" const ERROR_NOT_AUTHENTICATED = "Not authenticated"
class InvidiousService class InvidiousService
public node as object public invidiousNode as object
function new(node as object) function new(invidiousNode as object)
m.node = node m.invidiousNode = invidiousNode
end function end function
function GetUserRegion() as string function GetUserRegion() as string
if m._userRegion = invalid if m._userRegion = invalid
m._userRegion = m.node.applicationInfo@.GetUserCountryCode() m._userRegion = m.invidiousNode.applicationInfo@.GetUserCountryCode()
end if end if
return m._userRegion return m._userRegion
end function end function
@@ -57,7 +57,10 @@ namespace Invidious
end function end function
function GetInstance() as string function GetInstance() as string
instance = m.node.preferences["invidious.instance"] if m.preferences = invalid
m.preferences = m.invidiousNode.preferences
end if
instance = m.preferences["invidious.instance"]
if not StringUtils.IsNullOrEmpty(instance) if not StringUtils.IsNullOrEmpty(instance)
return instance return instance
end if end if
@@ -70,7 +73,7 @@ namespace Invidious
return return
end if end if
authToken = m.node.authToken authToken = m.invidiousNode.authToken
if authToken = invalid if authToken = invalid
return return
end if end if
@@ -146,7 +149,7 @@ namespace Invidious
end function end function
function GetPlaylist(playlistId as string, index = 0 as integer, cancellation = invalid as object) as object function GetPlaylist(playlistId as string, index = 0 as integer, cancellation = invalid as object) as object
authToken = m.node.authToken authToken = m.invidiousNode.authToken
if authToken = invalid if authToken = invalid
instance = m.GetInstance() instance = m.GetInstance()
url = `${instance}${Invidious.PLAYLISTS_ENDPOINT}/${playlistId}` url = `${instance}${Invidious.PLAYLISTS_ENDPOINT}/${playlistId}`
@@ -191,7 +194,7 @@ namespace Invidious
feedSource = feedSources[feedSourcesIndex] feedSource = feedSources[feedSourcesIndex]
if m.endpoints = invalid if m.endpoints = invalid
m.endpoints = m.node.apiDefinitions m.endpoints = m.invidiousNode.apiDefinitions
end if end if
endpoint = m.endpoints[feedSource.endpoint] endpoint = m.endpoints[feedSource.endpoint]
@@ -228,7 +231,7 @@ namespace Invidious
function MakeRequest(feedSource as object, additionalQueryParams = invalid as object, cancellation = invalid as object) as object function MakeRequest(feedSource as object, additionalQueryParams = invalid as object, cancellation = invalid as object) as object
if m.endpoints = invalid if m.endpoints = invalid
m.endpoints = m.node.apiDefinitions m.endpoints = m.invidiousNode.apiDefinitions
end if end if
endpoint = m.endpoints[feedSource.endpoint] endpoint = m.endpoints[feedSource.endpoint]
@@ -243,8 +246,10 @@ namespace Invidious
request = HttpClient.Get(instance + endpoint.url) request = HttpClient.Get(instance + endpoint.url)
authToken = invalid
if endpoint.authenticated = true if endpoint.authenticated = true
authToken = m.node.authToken authToken = m.invidiousNode.authToken
if authToken = invalid if authToken = invalid
return { return {
success: false success: false
@@ -261,7 +266,7 @@ namespace Invidious
if queryParam.default <> invalid if queryParam.default <> invalid
if IsString(queryParam.type) and queryParam.type = "#ISO3166" if IsString(queryParam.type) and queryParam.type = "#ISO3166"
if queryParam.default = "GetUserCountryCode" if queryParam.default = "GetUserCountryCode"
request.QueryParam(queryParamKey, m.node.applicationInfo@.GetUserCountryCode()) request.QueryParam(queryParamKey, m.GetUserRegion())
else else
request.QueryParam(queryParamKey, queryParam.default) request.QueryParam(queryParamKey, queryParam.default)
end if end if
@@ -302,23 +307,18 @@ namespace Invidious
response = request.Await() response = request.Await()
if m.responseHandlers = invalid responseHandler = invalid
m.responseHandlers = { if IsString(endpoint.responseHandler) and m.DoesExist(endpoint.responseHandler)
DefaultHandler: m.DefaultHandler responseHandler = endpoint.responseHandler
AuthFeedHandler: m.AuthFeedHandler else
PlaylistHandler: m.PlaylistHandler responseHandler = "DefaultHandler"
VideoInfoHandler: m.VideoInfoHandler
PlaylistInfoHandler: m.PlaylistInfoHandler
ChannelInfoHandler: m.ChannelInfoHandler
ChannelVideosHandler: m.ChannelVideosHandler
ChannelPlaylistsHandler: m.ChannelPlaylistsHandler
WatchHistoryHandler: m.WatchHistoryHandler
}
end if end if
responseHandler = endpoint.responseHandler <> invalid ? m.responseHandlers[endpoint.responseHandler] : m.responseHandlers["DefaultHandler"] result = m[responseHandler]({
feedSource: feedSource
result = responseHandler(m, feedSource, response) response: response
authToken: authToken
})
if response.IsSuccess() and result <> invalid if response.IsSuccess() and result <> invalid
return { return {
@@ -333,7 +333,9 @@ namespace Invidious
end if end if
end function end function
function DefaultHandler(m as object, feedSource as object, response as object) as object function DefaultHandler(context as object) as object
response = context.response
if response.StatusCode() = 200 if response.StatusCode() = 200
json = response.Json() json = response.Json()
return { return {
@@ -343,7 +345,9 @@ namespace Invidious
return invalid return invalid
end function end function
function PlaylistHandler(m as object, feedSource as object, response as object) as object function PlaylistHandler(context as object) as object
response = context.response
if response.StatusCode() = 200 if response.StatusCode() = 200
json = response.Json() json = response.Json()
return { return {
@@ -353,7 +357,9 @@ namespace Invidious
return invalid return invalid
end function end function
function ChannelVideosHandler(m as object, feedSource as object, response as object) as object function ChannelVideosHandler(context as object) as object
response = context.response
if response.StatusCode() = 200 if response.StatusCode() = 200
json = response.Json() json = response.Json()
return { return {
@@ -364,7 +370,9 @@ namespace Invidious
return invalid return invalid
end function end function
function ChannelPlaylistsHandler(m as object, feedSource as object, response as object) as object function ChannelPlaylistsHandler(context as object) as object
response = context.response
if response.StatusCode() = 200 if response.StatusCode() = 200
json = response.Json() json = response.Json()
return { return {
@@ -375,7 +383,10 @@ namespace Invidious
return invalid return invalid
end function end function
function VideoInfoHandler(m as object, feedSource as object, response as object) as object function VideoInfoHandler(context as object) as object
response = context.response
feedSource = context.feedSource
statusCode = response.StatusCode() statusCode = response.StatusCode()
if statusCode >= 500 if statusCode >= 500
' In some cases, such as a video became private, or a live stream ended, ' In some cases, such as a video became private, or a live stream ended,
@@ -383,8 +394,7 @@ namespace Invidious
' with just a video id, which will allow us to show a valid thumbnail if possible. ' with just a video id, which will allow us to show a valid thumbnail if possible.
' This is to makes it possible to load a bookmarked video and delete it even if ' This is to makes it possible to load a bookmarked video and delete it even if
' it is no longer valid. ' it is no longer valid.
' TODO:P2 access to private property response.OverrideStatusCode(200)
response._statusCode = 200
return { return {
items: [{ items: [{
"videoId": feedSource.pathParams.id "videoId": feedSource.pathParams.id
@@ -404,7 +414,9 @@ namespace Invidious
return invalid return invalid
end function end function
function PlaylistInfoHandler(m as object, feedSource as object, response as object) as object function PlaylistInfoHandler(context as object) as object
response = context.response
if response.StatusCode() = 200 if response.StatusCode() = 200
json = response.Json() json = response.Json()
json.type = "playlist" json.type = "playlist"
@@ -415,7 +427,9 @@ namespace Invidious
return invalid return invalid
end function end function
function ChannelInfoHandler(m as object, feedSource as object, response as object) as object function ChannelInfoHandler(context as object) as object
response = context.response
if response.StatusCode() = 200 if response.StatusCode() = 200
json = response.Json() json = response.Json()
json.type = "channel" json.type = "channel"
@@ -426,8 +440,11 @@ namespace Invidious
return invalid return invalid
end function end function
function AuthFeedHandler(m as object, feedSource as object, response as object) as object function AuthFeedHandler(context as object) as object
m.DeleteExpiredToken(response) response = context.response
authToken = context.authToken
m.DeleteExpiredToken(response, authToken)
if response.StatusCode() <> 200 if response.StatusCode() <> 200
return invalid return invalid
@@ -453,8 +470,11 @@ namespace Invidious
} }
end function end function
function WatchHistoryHandler(m as object, feedSource as object, response as object) as object function WatchHistoryHandler(context as object) as object
m.DeleteExpiredToken(response) response = context.response
authToken = context.authToken
m.DeleteExpiredToken(response, authToken)
if response.StatusCode() <> 200 if response.StatusCode() <> 200
return invalid return invalid
@@ -478,53 +498,19 @@ namespace Invidious
} }
end function end function
function DeleteExpiredToken(response as object) function DeleteExpiredToken(response as object, authToken as object) as void
if response.StatusCode() = 403 if response.StatusCode() <> 403
LogWarn(`Invidious instance responded with 403: ${response.Text()}`) return
LogWarn("Deleting Invidious token...")
m.DeleteAuthToken()
end if end if
end function
function GetAuthToken() as object LogWarn(`Invidious instance responded with 403: ${response.Text()}`)
tokenPayload = RegistryUtils.Read(RegistryUtils.INVIDIOUS_TOKEN) if not IsAssociativeArray(authToken) or not IsString(authToken.token)
if tokenPayload = invalid LogWarn("No valid token to delete")
return invalid return
end if end if
authToken = ParseJson(tokenPayload)
if authToken = invalid or authToken.instance = invalid or authToken.token = invalid
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
return invalid
end if
if not m.VerifyTokenScope(authToken.token)
' Right now we're probably in a UI thread, and we can't unregister the token
' Without a Task
AsyncTask.Start(Tasks.InvidiousUnregisterTokenTask, {
invidious: m.node
authToken: authToken
})
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
message = `It looks like you are logged in to Invidious, but your access token does not have the required permissions.
For that reason, we have logged you out. Please log in again.
This can happen when Playlet is updated with new features.
We apologize for the inconvenience.`
DialogUtils.ShowDialog(message, "User logged out")
return invalid
end if
return authToken
end function
function SetAuthToken(token as string, instance as string, username as dynamic) LogInfo("Deleting Invidious token...")
obj = { m.invidiousNode.profiles@.LogoutWithAccessToken(authToken.token)
token: token
instance: instance
username: username
}
json = FormatJson(obj)
RegistryUtils.Write(RegistryUtils.INVIDIOUS_TOKEN, json)
m.node.authToken = obj
end function end function
function VerifyTokenScope(token as string) as boolean function VerifyTokenScope(token as string) as boolean
@@ -548,30 +534,14 @@ We apologize for the inconvenience.`
return validScopes return validScopes
end function end function
function DeleteAuthToken() function UnregisterToken(authToken as object) as object
m.node.authToken = invalid
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
end function
function Logout() as boolean
authToken = m.node.authToken
if authToken = invalid
return false
end if
m.UnregisterToken(authToken)
m.DeleteAuthToken()
return true
end function
function UnregisterToken(authToken as object) as void
url = `${authToken.instance}${Invidious.AUTH_TOKENS_UNREGISTER}` url = `${authToken.instance}${Invidious.AUTH_TOKENS_UNREGISTER}`
request = HttpClient.Post(url, authToken.token) request = HttpClient.Post(url, authToken.token)
request.Headers(m.GetAuthenticationHeaders(authToken.token)) request.Headers(m.GetAuthenticationHeaders(authToken.token))
request.Header("Content-Type", "application/json") request.Header("Content-Type", "application/json")
request.Await() return request.Await()
end function end function
function GetAuthorizeTokenLink() as dynamic function GetAuthorizeTokenLink() as dynamic
@@ -579,7 +549,7 @@ We apologize for the inconvenience.`
' 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://")
address = m.node.webServer@.GetServerAddress() address = m.invidiousNode.webServer@.GetServerAddress()
if address = invalid if address = invalid
return invalid return invalid
end if end if
@@ -592,7 +562,7 @@ We apologize for the inconvenience.`
end function end function
function GetSubscriptions(cancellation = invalid as object) as object function GetSubscriptions(cancellation = invalid as object) as object
authToken = m.node.authToken authToken = m.invidiousNode.authToken
if authToken = invalid if authToken = invalid
return invalid return invalid
end if end if
@@ -606,7 +576,7 @@ We apologize for the inconvenience.`
end function end function
function Subscribe(channelId as string, cancellation = invalid as object) as object function Subscribe(channelId as string, cancellation = invalid as object) as object
authToken = m.node.authToken authToken = m.invidiousNode.authToken
if authToken = invalid if authToken = invalid
return invalid return invalid
end if end if
@@ -620,7 +590,7 @@ We apologize for the inconvenience.`
end function end function
function Unsubscribe(channelId as string, cancellation = invalid as object) as object function Unsubscribe(channelId as string, cancellation = invalid as object) as object
authToken = m.node.authToken authToken = m.invidiousNode.authToken
if authToken = invalid if authToken = invalid
return invalid return invalid
end if end if
@@ -251,12 +251,34 @@ namespace InvidiousContent
function GetVideoCountText(item as object) as string function GetVideoCountText(item as object) as string
videoCount = ValidInt(item.videoCount) videoCount = ValidInt(item.videoCount)
return videoCount = 1 ? "1 video" : `${videoCount} videos` if videoCount = 1
return "1 video"
end if
return `${videoCount} videos`
end function end function
function GetChannelSubCountText(channel as object) as string function GetChannelSubCountText(channel as object) as string
subCount = ValidInt(channel.subCount) subCount = ValidInt(channel.subCount)
return subCount = 1 ? "1 subscriber" : `${subCount} subscribers` if subCount = 1
return "1 subscriber"
end if
if subCount < 1000
return `${subCount} subscribers`
end if
subCount = subCount / 1000
if subCount < 1000
return `${FormatFloat(subCount)}K subscribers`
end if
subCount = subCount / 1000
if subCount < 1000
return `${FormatFloat(subCount)}M subscribers`
end if
subCount = subCount / 1000
return `${FormatFloat(subCount)}B subscribers`
end function end function
function PlaylistGetViewCountText(playlistItem as object) as string function PlaylistGetViewCountText(playlistItem as object) as string
@@ -1,12 +0,0 @@
import "InvidiousService.bs"
@asynctask
function InvidiousUnregisterTokenTask(input as object) as object
invidiousNode = input.invidious
authToken = input.authToken
service = new Invidious.InvidiousService(invidiousNode)
service.UnregisterToken(authToken)
return invalid
end function
@@ -13,6 +13,11 @@ import "pkg:/source/utils/UrlUtils.bs"
const COMMAND_HANDLER_PREFIX = "_Handle_" const COMMAND_HANDLER_PREFIX = "_Handle_"
' Apparently devices can be connected and disconnected very frequently.
' We don't want to spam the user with notifications, so we'll only show a notification
' if the last notification was more than 30 minutes ago.
const CONNECT_NOTIFICATION_MIN_INTERVAL_SECONDS = 1800
class LoungeApi class LoungeApi
public loungeServiceNode public loungeServiceNode
@@ -27,6 +32,7 @@ class LoungeApi
public loungeToken public loungeToken
public sessionId public sessionId
public gSessionId public gSessionId
public devices
private ofs private ofs
private lastProcessedCommandIndex = -1 private lastProcessedCommandIndex = -1
@@ -46,6 +52,7 @@ class LoungeApi
m.ofs = 0 m.ofs = 0
m.poller = invalid m.poller = invalid
m.outgoingMessagesRequests = {} m.outgoingMessagesRequests = {}
m.devices = {}
commandHandlers = {} commandHandlers = {}
commandHandlers[COMMAND_TYPE_NOOP] = m.HandleIgnoreCommand commandHandlers[COMMAND_TYPE_NOOP] = m.HandleIgnoreCommand
@@ -55,13 +62,13 @@ class LoungeApi
commandHandlers[COMMAND_TYPE_DPAD_COMMAND] = m.HandleIgnoreCommand commandHandlers[COMMAND_TYPE_DPAD_COMMAND] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_VOICE_COMMAND] = m.HandleIgnoreCommand commandHandlers[COMMAND_TYPE_VOICE_COMMAND] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_ON_USER_ACTIVITY] = m.HandleIgnoreCommand commandHandlers[COMMAND_TYPE_ON_USER_ACTIVITY] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_REMOTE_DISCONNECTED] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_GET_NOW_PLAYING] = m.HandleGetPlayingNow commandHandlers[COMMAND_TYPE_GET_NOW_PLAYING] = m.HandleGetPlayingNow
commandHandlers[COMMAND_TYPE_SESSION_ID] = m.HandleSessionId commandHandlers[COMMAND_TYPE_SESSION_ID] = m.HandleSessionId
commandHandlers[COMMAND_TYPE_G_SESSION_ID] = m.HandleGSessionId commandHandlers[COMMAND_TYPE_G_SESSION_ID] = m.HandleGSessionId
commandHandlers[COMMAND_TYPE_LOUNGE_STATUS] = m.HandleLoungeStatus commandHandlers[COMMAND_TYPE_LOUNGE_STATUS] = m.HandleLoungeStatus
commandHandlers[COMMAND_TYPE_REMOTE_CONNECTED] = m.HandleRemoteConnected commandHandlers[COMMAND_TYPE_REMOTE_CONNECTED] = m.HandleRemoteConnected
commandHandlers[COMMAND_TYPE_REMOTE_DISCONNECTED] = m.HandleRemoteDisconnected
commandHandlers[COMMAND_TYPE_SET_VOLUME] = m.HandleSetVolume commandHandlers[COMMAND_TYPE_SET_VOLUME] = m.HandleSetVolume
commandHandlers[COMMAND_TYPE_SET_PLAYLIST] = m.HandleSetPlaylist commandHandlers[COMMAND_TYPE_SET_PLAYLIST] = m.HandleSetPlaylist
commandHandlers[COMMAND_TYPE_UPDATE_PLAYLIST] = m.HandleUpdatePlaylist commandHandlers[COMMAND_TYPE_UPDATE_PLAYLIST] = m.HandleUpdatePlaylist
@@ -92,6 +99,7 @@ class LoungeApi
end if end if
request = HttpClient.Get("https://www.youtube.com/api/lounge/pairing/generate_screen_id") request = HttpClient.Get("https://www.youtube.com/api/lounge/pairing/generate_screen_id")
response = request.Await() response = request.Await()
if not response.IsSuccess() if not response.IsSuccess()
error = `Failed to get screen id. Please restart playlet to use the cast function.\n${response.ErrorMessage()}` error = `Failed to get screen id. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
@@ -99,6 +107,7 @@ class LoungeApi
DialogUtils.ShowDialog(error, "Lounge service setup error") DialogUtils.ShowDialog(error, "Lounge service setup error")
return invalid return invalid
end if end if
id = response.Text() id = response.Text()
if not IsString(id) if not IsString(id)
error = `Failed to get screen id. Please restart playlet to use the cast function.\nNot a valid screen id: ${id}` error = `Failed to get screen id. Please restart playlet to use the cast function.\nNot a valid screen id: ${id}`
@@ -106,6 +115,7 @@ class LoungeApi
DialogUtils.ShowDialog(error, "Lounge service setup error") DialogUtils.ShowDialog(error, "Lounge service setup error")
return invalid return invalid
end if end if
m.screenId = id m.screenId = id
return id return id
end function end function
@@ -115,9 +125,11 @@ class LoungeApi
return m.loungeToken return m.loungeToken
end if end if
form = UrlUtils.GetUrlEncodedForm({ "screen_ids": m.screenId }) request = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/get_lounge_token_batch", "")
request = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/get_lounge_token_batch", form) request.UrlEncodedForm({
request.Header("Content-Type", "application/x-www-form-urlencoded") "screen_ids": m.screenId
})
response = request.Await() response = request.Await()
if not response.IsSuccess() if not response.IsSuccess()
error = `Failed to get lounge token. Please restart playlet to use the cast function.\n${response.ErrorMessage()}` error = `Failed to get lounge token. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
@@ -141,7 +153,6 @@ class LoungeApi
end function end function
function GetSessionData() as boolean function GetSessionData() as boolean
baseUrl = "https://www.youtube.com/api/lounge/bc/bind"
queryParams = { queryParams = {
"device": "LOUNGE_SCREEN" "device": "LOUNGE_SCREEN"
"theme": "cl" "theme": "cl"
@@ -159,10 +170,11 @@ class LoungeApi
queryParams["loungeIdToken"] = m.loungeToken queryParams["loungeIdToken"] = m.loungeToken
queryParams["zx"] = m.Zx() queryParams["zx"] = m.Zx()
url = UrlUtils.BuildUrl(baseUrl, invalid, queryParams) request = HttpClient.Post("https://www.youtube.com/api/lounge/bc/bind", "")
request.QueryParams(queryParams)
request = HttpClient.Post(url, "count=0") request.UrlEncodedForm({
request.Header("Content-Type", "application/x-www-form-urlencoded") "count": 0
})
response = request.Await() response = request.Await()
if not response.IsSuccess() if not response.IsSuccess()
@@ -336,35 +348,38 @@ class LoungeApi
return return
end if end if
devicesDict = {}
for each device in devices for each device in devices
devicesDict[device.id] = device if m.devices.DoesExist(device.id)
device.lastConnectNotificationTime = m.devices[device.id].lastConnectNotificationTime
end if
m.devices[device.id] = device
end for end for
m.loungeServiceNode.devices = devicesDict
end function end function
function HandleRemoteConnected(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void function HandleRemoteConnected(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
LogInfo(commandType) LogInfo(commandType, FormatJson(commandArgs))
newDevice = commandArgs newDevice = commandArgs
id = newDevice.id id = newDevice.id
if StringUtils.IsNullOrEmpty(id) if StringUtils.IsNullOrEmpty(id)
return return
end if end if
devices = m.loungeServiceNode.devices if m.devices.DoesExist(id)
if devices = invalid device = m.devices[id]
devices = {}
end if
if devices.DoesExist(id)
device = devices[id]
device.Append(newDevice) device.Append(newDevice)
newDevice = device newDevice = device
end if end if
devices[id] = newDevice m.devices[id] = newDevice
m.loungeServiceNode.devices = devices
nowSeconds = TimeUtils.Now().AsSeconds()
lastConnectNotificationInterval = nowSeconds - ValidInt(newDevice.lastConnectNotificationTime)
if lastConnectNotificationInterval < CONNECT_NOTIFICATION_MIN_INTERVAL_SECONDS
LogInfo("Skipping connect notification. Last connect notification interval:", lastConnectNotificationInterval, "seconds")
return
end if
newDevice.lastConnectNotificationTime = nowSeconds
userName = newDevice.user userName = newDevice.user
deviceName = newDevice.name deviceName = newDevice.name
@@ -373,24 +388,6 @@ class LoungeApi
LoungeDeviceConnected.ShowNotifcation(m.notificationsNode, deviceName, userName, userAvatarUri) LoungeDeviceConnected.ShowNotifcation(m.notificationsNode, deviceName, userName, userAvatarUri)
end function end function
function HandleRemoteDisconnected(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
LogInfo(commandType)
device = commandArgs
id = device.id
if StringUtils.IsNullOrEmpty(id)
return
end if
devices = m.loungeServiceNode.devices
if devices = invalid
devices = {}
end if
if devices.Delete(id)
m.loungeServiceNode.devices = devices
end if
' TODO:P1 disconnect notification
end function
function HandleSetVolume(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void function HandleSetVolume(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
player = m.videoQueueNode.player player = m.videoQueueNode.player
if player = invalid if player = invalid
@@ -443,7 +440,6 @@ class LoungeApi
return return
end if end if
baseUrl = "https://www.youtube.com/api/lounge/bc/bind"
queryParams = { queryParams = {
"device": "LOUNGE_SCREEN" "device": "LOUNGE_SCREEN"
"theme": "cl" "theme": "cl"
@@ -470,8 +466,6 @@ class LoungeApi
queryParams["AID"] = messages[0].commandId queryParams["AID"] = messages[0].commandId
end if end if
url = UrlUtils.BuildUrl(baseUrl, invalid, queryParams)
postData = [ postData = [
{ key: "count", value: messages.Count() } { key: "count", value: messages.Count() }
{ key: "ofs", value: loungeData.ofs } { key: "ofs", value: loungeData.ofs }
@@ -495,9 +489,10 @@ class LoungeApi
LogDebug("Sending messages:", postData) LogDebug("Sending messages:", postData)
body = UrlUtils.GetUrlEncodedForm(postData) request = HttpClient.Post("https://www.youtube.com/api/lounge/bc/bind", "")
request = HttpClient.Post(url, body) request.QueryParams(queryParams)
request.Header("Content-Type", "application/x-www-form-urlencoded") request.UrlEncodedForm(postData)
request.Send() request.Send()
' we do not need to wait for requests to finish, we check on them later ' we do not need to wait for requests to finish, we check on them later
@@ -23,15 +23,15 @@ function LoungeGenerateManualPairingCodeTask(input as object) as object
input.loungeToken = loungeService.loungeToken input.loungeToken = loungeService.loungeToken
end if end if
bodyParams = { form = {
"lounge_token": input.loungeToken "lounge_token": input.loungeToken
"screen_id": input.screenId "screen_id": input.screenId
"screen_name": input.screenName "screen_name": input.screenName
"device_id": input.deviceId "device_id": input.deviceId
} }
for each key in bodyParams for each key in form
if StringUtils.IsNullOrEmpty(bodyParams[key]) if StringUtils.IsNullOrEmpty(form[key])
return { return {
"success": false "success": false
"error": key + " is empty" "error": key + " is empty"
@@ -39,14 +39,11 @@ function LoungeGenerateManualPairingCodeTask(input as object) as object
end if end if
end for end for
bodyParams["access_type"] = "permanent" form["access_type"] = "permanent"
bodyParams["app"] = "Playlet" form["app"] = "Playlet"
baseUrl = "https://www.youtube.com/api/lounge/pairing/get_pairing_code?ctx=pair" request = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/get_pairing_code?ctx=pair", "")
request.UrlEncodedForm(form)
body = UrlUtils.GetUrlEncodedForm(bodyParams)
request = HttpClient.Post(baseUrl, body)
request.Header("Content-Type", "application/x-www-form-urlencoded")
response = request.Await() response = request.Await()
if not response.IsSuccess() if not response.IsSuccess()
@@ -1,7 +1,5 @@
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs" import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Services/LoungeService/LoungeApi.bs" import "pkg:/components/Services/LoungeService/LoungeApi.bs"
' TODO:P0
' 1. Add a section about the lounge in the privacy policy
function Init() function Init()
m.top.functionName = "LoungeServiceLoop" m.top.functionName = "LoungeServiceLoop"
@@ -6,8 +6,6 @@
<field id="screenId" type="string" /> <field id="screenId" type="string" />
<field id="loungeToken" type="string" /> <field id="loungeToken" type="string" />
<field id="devices" type="assocarray" />
<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" />
@@ -0,0 +1,331 @@
import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/ArrayUtils.bs"
import "pkg:/source/utils/ColorUtils.bs"
import "pkg:/source/utils/CryptoUtils.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RegistryUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
' TODO:P1 add the ability to change color of profiles
function Init()
m.disableSavingToRegistry = false
content = m.top.findNode("ProfilesContent")
m.top.content = content
m.profilesContent = content.getChild(0)
end function
function OnNodeReady()
LoadProfilesFromRegistry()
end function
function LoadProfilesFromRegistry()
LogInfo("Loading profiles from registry...")
' Step 1: Load user profiles from registry
userProfiles = RegistryUtils.Read(RegistryUtils.USER_PROFILES)
if userProfiles = invalid
userProfiles = {
profiles: []
currentProfile: invalid
}
else
userProfiles = ParseJson(userProfiles)
end if
' Step 2: Migrate existing profiles to new format (if needed)
isDirty = MigrateExistingProfiles(userProfiles)
' Step 3: Save user preferences (if needed)
if isDirty
SaveUserProfilesToRegistry()
end if
' Step 4: Load user profiles into content nodes
profileNodes = []
for each profile in userProfiles.profiles
profileNode = CreateObject("roSGNode", "ProfileContentNode")
profileNode.id = profile.id
profileNode.type = profile.type
profileNode.username = profile.username
profileNode.serverUrl = profile.serverUrl
profileNode.accessToken = profile.accessToken
profileNode.color = profile.color
profileNodes.Push(profileNode)
end for
m.profilesContent.insertChildren(profileNodes, 0)
if not StringUtils.IsNullOrEmpty(userProfiles.currentProfile)
for each profileNode in profileNodes
if profileNode.id = userProfiles.currentProfile
' Setting current profile will also save the profiles to registry
' but we just saved the profiles
m.disableSavingToRegistry = true
SetCurrentProfile(profileNode)
m.disableSavingToRegistry = false
exit for
end if
end for
end if
if profileNodes.Count() > 0
AsyncTask.Start(Tasks.ProfilesVerifyTokensTask, {
profiles: m.top
invidious: m.invidious
profileNodes: profileNodes
})
end if
end function
function MigrateExistingProfiles(userProfiles as object) as boolean
tokenPayload = RegistryUtils.Read(RegistryUtils.INVIDIOUS_TOKEN)
if tokenPayload = invalid
return false
end if
authToken = ParseJson(tokenPayload)
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
if authToken = invalid or authToken.instance = invalid or authToken.token = invalid or authToken.username = invalid
return false
end if
id = CreateProfileId(authToken.username, authToken.instance)
for each profile in userProfiles.profiles
if profile.id = id
return false
end if
end for
profile = {
"id": id
"type": "invidious"
"username": authToken.username
"serverUrl": authToken.instance
"accessToken": authToken.token
"color": ColorUtils.RandomSoftColorHex()
}
userProfiles.profiles.Unshift(profile)
if StringUtils.IsNullOrEmpty(userProfiles["currentProfile"])
userProfiles["currentProfile"] = profile.id
end if
return true
end function
function SaveUserProfilesToRegistry() as void
if m.disableSavingToRegistry
return
end if
userProfiles = GetProfilesDto(true)
userProfiles.__version = m.top.__version
RegistryUtils.Write(RegistryUtils.USER_PROFILES, FormatJson(userProfiles))
end function
function GetProfilesDto(includeAccessToken as boolean) as object
userProfiles = {
"profiles": []
"currentProfile": invalid
}
profileNodes = m.profilesContent.getChildren(-1, 0)
for each profileNode in profileNodes
if profileNode.type = "login"
continue for
end if
color = profileNode.color
if IsInt(color)
' Use hex color for web app
color = ColorUtils.IntToHex(color)
end if
profile = {
"id": profileNode.id
"type": profileNode.type
"username": profileNode.username
"serverUrl": profileNode.serverUrl
"color": color
}
if includeAccessToken
profile["accessToken"] = profileNode.accessToken
end if
userProfiles.profiles.Push(profile)
end for
currentProfile = m.top.currentProfile
if currentProfile <> invalid
userProfiles["currentProfile"] = currentProfile.id
end if
return userProfiles
end function
function LoginWithProfile(newProfile as object)
isNewProfile = true
if StringUtils.IsNullOrEmpty(newProfile.id)
newProfile.id = CreateProfileId(newProfile.username, newProfile.serverUrl)
end if
existingProfile = invalid
profiles = m.profilesContent.getChildren(-1, 0)
for each profile in profiles
if profile.id = newProfile.id
existingProfile = profile
isNewProfile = false
exit for
end if
end for
if not isNewProfile
' Refresh token of existing profile
existingProfile.accessToken = newProfile.accessToken
newProfile = existingProfile
end if
if isNewProfile
newProfile.color = ColorUtils.RandomSoftColorHex()
m.profilesContent.insertChild(newProfile, 0)
end if
SetCurrentProfile(newProfile)
end function
function LogoutWithProfile(profile as object) as void
if profile = invalid
return
end if
profile = m.profilesContent.findNode(profile.id)
if profile = invalid
return
end if
m.profilesContent.removeChild(profile)
currentProfile = m.top.currentProfile
if currentProfile <> invalid and currentProfile.id = profile.id
SetCurrentProfile(invalid)
else
RefreshActiveProfileState(currentProfile)
end if
m.top.onProfileLogout = true
AsyncTask.Start(Tasks.ProfilesInvidiousUnregisterTokenTask, {
profiles: m.top
invidious: m.invidious
profileNodes: [profile]
})
end function
function LogoutWithProfiles(profiles as object) as void
if profiles = invalid or profiles.Count() = 0
return
end if
currentProfile = m.top.currentProfile
logoutFromCurrentProfile = false
onProfileLogout = false
for each profile in profiles
profileNode = m.profilesContent.findNode(profile.id)
if profileNode = invalid
continue for
end if
m.profilesContent.removeChild(profileNode)
onProfileLogout = true
if currentProfile <> invalid and currentProfile.id = profile.id
logoutFromCurrentProfile = true
end if
end for
if logoutFromCurrentProfile
SetCurrentProfile(invalid)
else
RefreshActiveProfileState(currentProfile)
end if
if onProfileLogout
m.top.onProfileLogout = true
end if
AsyncTask.Start(Tasks.ProfilesInvidiousUnregisterTokenTask, {
profiles: m.top
invidious: m.invidious
profileNodes: profiles
})
end function
function LogoutWithAccessToken(accessToken as dynamic) as void
if StringUtils.IsNullOrEmpty(accessToken)
return
end if
' We are not going to invalidate the token on the server
' because we are likely dealing with an invalid token
' in the first place. All we need to do is remove the
' profile from the list of profiles.
allProfiles = m.profilesContent.getChildren(-1, 0)
for each profile in allProfiles
if profile.accessToken = accessToken
m.profilesContent.removeChild(profile)
currentProfile = m.top.currentProfile
if currentProfile <> invalid and currentProfile.id = profile.id
SetCurrentProfile(invalid)
else
RefreshActiveProfileState(currentProfile)
end if
m.top.onProfileLogout = true
exit for
end if
end for
end function
function SetCurrentProfile(newActiveProfile as object) as void
if newActiveProfile = invalid
RefreshActiveProfileState(invalid)
m.top.currentProfile = invalid
m.invidious.authToken = invalid
LogInfo("Current profile set to <invalid>")
SaveUserProfilesToRegistry()
return
end if
RefreshActiveProfileState(newActiveProfile)
m.top.currentProfile = newActiveProfile
m.invidious.authToken = {
token: newActiveProfile.accessToken
instance: newActiveProfile.serverUrl
username: newActiveProfile.username
}
LogInfo("Current profile set to", newActiveProfile.username, "@", newActiveProfile.serverUrl)
SaveUserProfilesToRegistry()
end function
function RefreshActiveProfileState(activeProfile as object) as void
allProfiles = m.profilesContent.getChildren(-1, 0)
if activeProfile = invalid
for each profile in allProfiles
profile.isSelected = false
end for
return
end if
for each profile in allProfiles
profile.isSelected = profile.id = activeProfile.id
end for
end function
function CreateProfileId(username as string, serverUrl as string) as string
return "v1:" + CryptoUtils.GetMd5(username + serverUrl)
end function
@@ -0,0 +1,31 @@
<component name="Profiles" extends="Node" includes="AutoBind">
<interface>
<!--
The version of the profiles. This is used to determine if the
profiles saved need to be migrated. If the version is less than the
current version, a migration is needed.
-->
<field id="__version" type="integer" value="1" />
<field id="currentProfile" type="node" />
<field id="onProfileLogout" type="boolean" alwaysNotify="true" />
<field id="content" type="node" />
<field id="invidious" type="node" />
<function name="GetProfilesDto" />
<function name="LoginWithProfile" />
<function name="LogoutWithProfile" />
<function name="LogoutWithProfiles" />
<function name="LogoutWithAccessToken" />
<function name="SetCurrentProfile" />
</interface>
<children>
<!-- Note: two content nodes because we're rendering profiles in a RowList on the ProfilesScreen -->
<ContentNode id="ProfilesContent">
<ContentNode>
<ProfileContentNode type="login">
</ProfileContentNode>
</ContentNode>
</ContentNode>
</children>
</component>
@@ -0,0 +1,22 @@
import "pkg:/components/Services/Invidious/InvidiousService.bs"
@asynctask
function ProfilesInvidiousUnregisterTokenTask(input as object) as object
profileContentNodes = input.profileNodes
invidiousNode = input.invidious
service = new Invidious.InvidiousService(invidiousNode)
for each profileNode in profileContentNodes
authToken = {
instance: profileNode.serverUrl
token: profileNode.accessToken
}
response = service.UnregisterToken(authToken)
if not response.IsSuccess()
LogWarn(`Failed to unregister token: ${response.ErrorMessage()}`)
end if
end for
return invalid
end function
@@ -0,0 +1,38 @@
import "pkg:/components/Services/Invidious/InvidiousService.bs"
@asynctask
function ProfilesVerifyTokensTask(input as object) as object
profilesNode = input.profiles
invidiousNode = input.invidious
profileContentNodes = input.profileNodes
service = new Invidious.InvidiousService(invidiousNode)
invalidProfiles = []
for each profileNode in profileContentNodes
if not service.VerifyTokenScope(profileNode.accessToken)
invalidProfiles.push(profileNode)
end if
end for
if invalidProfiles.Count() = 0
return invalid
end if
profilesNode@.LogoutWithProfiles(invalidProfiles)
profileNames = []
for each profileNode in invalidProfiles
profileNames.push(profileNode.username)
end for
profileNames = profileNames.join(", ")
message = `It looks like you are logged in to Invidious, but do not have the required permissions.
For that reason, we have logged you out from the following profiles: ${profileNames}
Please log in again.
This can happen when Playlet is updated with new features.
We apologize for the inconvenience.`
DialogUtils.ShowDialog(message, "User logged out")
return invalid
end function
@@ -1,13 +0,0 @@
function Init()
m.label = m.top.findNode("label")
end function
function OnContentSet() as void
content = m.top.itemContent
if content = invalid
return
end if
m.label.text = content.title
end function
@@ -1,17 +0,0 @@
<component name="ActionRowCell" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="type" type="string" value="action" />
</interface>
<children>
<Label
id="label"
width="310"
height="196"
horizAlign="center"
vertAlign="center"
translation="[20,0]"
wrap="true"
font="font:LargeBoldSystemFont" />
</children>
</component>
@@ -8,7 +8,6 @@ function OnContentSet() as void
"playlist": "playlistRowCellVisible" "playlist": "playlistRowCellVisible"
"channel": "channelRowCellVisible" "channel": "channelRowCellVisible"
"loading": "loadingRowCellVisible" "loading": "loadingRowCellVisible"
"action": "actionRowCellVisible"
} }
contentProperties = { contentProperties = {
@@ -16,7 +15,6 @@ function OnContentSet() as void
"playlist": "playlistRowCellItemContent" "playlist": "playlistRowCellItemContent"
"channel": "channelRowCellItemContent" "channel": "channelRowCellItemContent"
"loading": "loadingRowCellItemContent" "loading": "loadingRowCellItemContent"
"action": "actionRowCellItemContent"
} }
if content = invalid if content = invalid
@@ -8,13 +8,11 @@
<field id="playlistRowCellVisible" type="boolean" alias="PlaylistRowCell.visible" /> <field id="playlistRowCellVisible" type="boolean" alias="PlaylistRowCell.visible" />
<field id="channelRowCellVisible" type="boolean" alias="ChannelRowCell.visible" /> <field id="channelRowCellVisible" type="boolean" alias="ChannelRowCell.visible" />
<field id="loadingRowCellVisible" type="boolean" alias="LoadingRowCell.visible" /> <field id="loadingRowCellVisible" type="boolean" alias="LoadingRowCell.visible" />
<field id="actionRowCellVisible" type="boolean" alias="ActionRowCell.visible" />
<field id="videoRowCellItemContent" type="node" alias="VideoRowCell.itemContent" /> <field id="videoRowCellItemContent" type="node" alias="VideoRowCell.itemContent" />
<field id="playlistRowCellItemContent" type="node" alias="PlaylistRowCell.itemContent" /> <field id="playlistRowCellItemContent" type="node" alias="PlaylistRowCell.itemContent" />
<field id="channelRowCellItemContent" type="node" alias="ChannelRowCell.itemContent" /> <field id="channelRowCellItemContent" type="node" alias="ChannelRowCell.itemContent" />
<field id="loadingRowCellItemContent" type="node" alias="LoadingRowCell.itemContent" /> <field id="loadingRowCellItemContent" type="node" alias="LoadingRowCell.itemContent" />
<field id="actionRowCellItemContent" type="node" alias="ActionRowCell.itemContent" />
<field id="loadingRowCellIndex" type="integer" alias="LoadingRowCell.index" /> <field id="loadingRowCellIndex" type="integer" alias="LoadingRowCell.index" />
</interface> </interface>
@@ -23,6 +21,5 @@
<PlaylistRowCell id="PlaylistRowCell" /> <PlaylistRowCell id="PlaylistRowCell" />
<ChannelRowCell id="ChannelRowCell" /> <ChannelRowCell id="ChannelRowCell" />
<LoadingRowCell id="LoadingRowCell" /> <LoadingRowCell id="LoadingRowCell" />
<ActionRowCell id="ActionRowCell" />
</children> </children>
</component> </component>
@@ -12,9 +12,7 @@ import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
' TODO:P1 add the option to remove a row if it does not have any content ' TODO:P1 add the option to remove a row if it does not have any content
' E.g. NBC News does not return any related chnanels ' E.g. Subscriptions, Watch History and Playlists can be empty
' The "Continue Watching" feed source might return nothing. In this case,
' it should be removed.
function Init() function Init()
m.pendingLoadTasks = {} m.pendingLoadTasks = {}
end function end function
@@ -108,12 +106,8 @@ function OnRowItemSelected(index as object) as void
authorId = rowItem.authorId authorId = rowItem.authorId
LogInfo("Open channel: " + authorId) LogInfo("Open channel: " + authorId)
OpenChannel(rowItem) OpenChannel(rowItem)
else if rowItem.type = "action" else
if rowItem.action = "LoginDialog" LogWarn("Unknown row item type:", rowItem.type)
dialog = CreateObject("roSGNode", "LoginDialog")
dialog@.BindNode()
m.top.getScene().dialog = dialog
end if
end if end if
end function end function
@@ -154,17 +148,22 @@ function GetContextMenuOptionsForItem(rowItem as object) as object
options.push(ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayVideo", [rowItem])) options.push(ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayVideo", [rowItem]))
options.push(ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueueVideo", [rowItem])) options.push(ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueueVideo", [rowItem]))
item = ContextMenuUtils.CreateOption("Open channel", m.top, "OpenVideoChannel", [rowItem]) authorId = rowItem.authorId
options.push(item) if not StringUtils.IsNullOrEmpty(authorId)
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenVideoChannel", [rowItem]))
end if
else if rowItem.type = "playlist" else if rowItem.type = "playlist"
options.push(ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayPlaylist", [rowItem, 0])) options.push(ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayPlaylist", [rowItem, 0]))
options.push(ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueuePlaylist", [rowItem])) options.push(ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueuePlaylist", [rowItem]))
item = ContextMenuUtils.CreateOption("Open", m.top, "OpenPlaylist", [rowItem]) options.push(ContextMenuUtils.CreateOption("Open playlist", m.top, "OpenPlaylist", [rowItem]))
options.push(item)
authorId = rowItem.authorId
if not StringUtils.IsNullOrEmpty(authorId)
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [rowItem]))
end if
else if rowItem.type = "channel" else if rowItem.type = "channel"
item = ContextMenuUtils.CreateOption("Open", m.top, "OpenChannel", [rowItem]) options.push(ContextMenuUtils.CreateOption("Open", m.top, "OpenChannel", [rowItem]))
options.push(item)
else else
LogWarn("Unknown long pressed item type:", rowItem.type) LogWarn("Unknown long pressed item type:", rowItem.type)
return [] return []
@@ -191,6 +190,16 @@ function OpenVideoChannel(video as object) as void
ChannelUtils.Open(channel) ChannelUtils.Open(channel)
end function end function
function OpenPlaylistChannel(playlist as object) as void
authorId = playlist.authorId
if StringUtils.IsNullOrEmpty(authorId)
LogWarn("Invalid authorId:", authorId)
return
end if
channel = InvidiousContent.ToChannelContentNode(invalid, { authorId: authorId }, invalid)
ChannelUtils.Open(channel)
end function
function Refresh(unsued as dynamic) function Refresh(unsued as dynamic)
InitContent() InitContent()
end function end function
@@ -203,7 +212,6 @@ end function
function InitContent() as void function InitContent() as void
CancelCurrentTasks() CancelCurrentTasks()
m.top.someContentReady = false
if m.top.feeds = invalid if m.top.feeds = invalid
m.top.content = invalid m.top.content = invalid
@@ -6,11 +6,18 @@
<field id="bookmarks" type="node" bind="/Bookmarks" /> <field id="bookmarks" type="node" bind="/Bookmarks" />
<field id="screen" type="node" /> <field id="screen" type="node" />
<field id="feeds" type="array" onChange="OnFeedsChange" /> <field id="feeds" type="array" onChange="OnFeedsChange" />
<field id="someContentReady" type="bool" /> <!--
someContentReady is a field specifically for the search screen.
It is set to true when there are some search results
and set to false when there are no search results.
It a signal to make sure to hide the loading indicator.
-->
<field id="someContentReady" type="bool" alwaysNotify="true" />
<field id="onError" type="string" alwaysNotify="true" /> <field id="onError" type="string" alwaysNotify="true" />
<function name="OpenPlaylist" /> <function name="OpenPlaylist" />
<function name="OpenChannel" /> <function name="OpenChannel" />
<function name="OpenVideoChannel" /> <function name="OpenVideoChannel" />
<function name="OpenPlaylistChannel" />
<function name="Refresh" /> <function name="Refresh" />
</interface> </interface>
</component> </component>
@@ -2,6 +2,7 @@ import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs" import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs" import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
' TODO:P1 handle case where all feedSources are empty
@asynctask @asynctask
function VideoRowListRowContentTask(input as object) as object function VideoRowListRowContentTask(input as object) as object
try try
@@ -14,6 +15,8 @@ function VideoRowListRowContentTask(input as object) as object
totalfetchedItems = 0 totalfetchedItems = 0
someContentReadySet = false
while true while true
if m.top.cancel if m.top.cancel
feedContentNode.loadState = FeedLoadState.None feedContentNode.loadState = FeedLoadState.None
@@ -25,6 +28,10 @@ function VideoRowListRowContentTask(input as object) as object
if feedSourcesIndex >= feedSources.Count() if feedSourcesIndex >= feedSources.Count()
feedContentNode.loadState = FeedLoadState.Loaded feedContentNode.loadState = FeedLoadState.Loaded
if not someContentReadySet
rowList.someContentReady = false
end if
return { return {
success: true success: true
} }
@@ -36,6 +43,9 @@ function VideoRowListRowContentTask(input as object) as object
feedSourcesIndex += 1 feedSourcesIndex += 1
if feedSourcesIndex >= feedSources.Count() if feedSourcesIndex >= feedSources.Count()
feedContentNode.loadState = FeedLoadState.Loaded feedContentNode.loadState = FeedLoadState.Loaded
if not someContentReadySet
rowList.someContentReady = false
end if
return { return {
success: true success: true
} }
@@ -50,17 +60,13 @@ function VideoRowListRowContentTask(input as object) as object
if not response.success if not response.success
if response.error = Invidious.ERROR_NOT_AUTHENTICATED if response.error = Invidious.ERROR_NOT_AUTHENTICATED
RemovePlaceHolderItems(feedContentNode) if feedSources.Count() = 1
actionNode = CreateObject("roSGNode", "ActionContentNode") parent = feedContentNode.getParent()
actionNode.title = `Login to view ${feedSource.title}` parent.removeChild(feedContentNode)
actionNode.action = "LoginDialog" return {
success: true
feedSource.state.loadState = FeedLoadState.Loaded }
feedSources[feedSourcesIndex] = feedSource end if
feedContentNode.feedSources = feedSources
feedContentNode.appendChild(actionNode)
feedContentNode.loadState = FeedLoadState.Loaded
continue while continue while
end if end if
@@ -130,7 +136,8 @@ function VideoRowListRowContentTask(input as object) as object
feedContentNode.loadState = FeedLoadState.LoadedPage feedContentNode.loadState = FeedLoadState.LoadedPage
end if end if
if itemNodes.Count() > 0 if itemNodes.Count() > 0 and not someContentReadySet
someContentReadySet = true
rowList.someContentReady = true rowList.someContentReady = true
end if end if
@@ -63,12 +63,38 @@ namespace SponsorBlock
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 for each segment in segments
category = segment["category"]
segmentRange = segment["segment"] segmentRange = segment["segment"]
segmentStart = segmentRange[0] segmentStart = segmentRange[0]
segmentEnd = segmentRange[1] segmentEnd = segmentRange[1]
' 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) if (segmentStart <= time) and (segmentEnd >= time)
m.top.chapter = m.sponsorBlockService.SegmentTitle(segment["category"]) m.top.chapter = m.sponsorBlockService.SegmentTitle(category)
return return
end if end if
end for end for
@@ -34,6 +34,17 @@ function VideoContentTask(input as object) as object
contentNode.title = metadata.title contentNode.title = metadata.title
contentNode.secondaryTitle = metadata.author contentNode.secondaryTitle = metadata.author
contentNode.live = metadata.liveNow
if IsString(metadata.error)
' Adding metadata allows us to play next recommended video after displaying the error
contentNode.addFields({ metadata: metadata })
return {
success: false
error: metadata.error
}
end if
streamUrls = CreateStreamUrls(metadata, service, preferencesNode, playletServerPort) streamUrls = CreateStreamUrls(metadata, service, preferencesNode, playletServerPort)
contentNode.url = streamUrls[0] contentNode.url = streamUrls[0]
@@ -156,10 +167,6 @@ function AddInstanceToUrlIfNeeded(streamUrls as object, instance as string)
end for end for
end function end function
' TODO:P2
' Captions are rate limited https://github.com/iv-org/invidious/issues/2567
' It's possible to loop through a list of backup instances hoping to find working subtitles.
' Caveat: searching for a working caption could cause a delay in the video player start.
function SetCaptions(metadata as object, service as object, contentNode as object) as void function SetCaptions(metadata as object, service as object, contentNode as object) as void
if metadata.captions.Count() = 0 if metadata.captions.Count() = 0
return return
@@ -16,6 +16,8 @@ function Init()
m.fullScreenHintLabel = m.top.findNode("fullScreenHintLabel") m.fullScreenHintLabel = m.top.findNode("fullScreenHintLabel")
m.fullScreenHintTimer = m.top.findNode("fullScreenHintTimer") m.fullScreenHintTimer = m.top.findNode("fullScreenHintTimer")
m.fullScreenHintTimer.ObserveField("fire", FuncName(OnFullScreenHintTimer)) m.fullScreenHintTimer.ObserveField("fire", FuncName(OnFullScreenHintTimer))
m.trickplayUITimer = m.top.findNode("trickplayUITimer")
m.trickplayUITimer.ObserveField("fire", FuncName(OnTrickplayUITimer))
' videoPlayingSuccess indicates if we started playing a video successfully ' videoPlayingSuccess indicates if we started playing a video successfully
' We use it to detect if we should try another link for a video, or if another error ' We use it to detect if we should try another link for a video, or if another error
@@ -23,9 +25,18 @@ function Init()
m.videoPlayingSuccess = false m.videoPlayingSuccess = false
' ignoreNextFinishedState indicates if we should ignore the next finished state ' ignoreNextFinishedState indicates if we should ignore the next finished state
' This is used to prevent the video from playing the next video when we are ' This is used to prevent the video from playing the next video when we are
' still trying to find a working stream url ' still trying to find a working stream url.
' This is also used to prevent playing the next video when we're still displaying
' an error dialog.
m.ignoreNextFinishedState = false m.ignoreNextFinishedState = false
' Indicates that we're currently paused and seeking position
m.isSeekingPosition = false
' Checks if current RokuOS version has showUI field in Video node
m.showUIEnabled = m.top.hasField("showUI")
LogInfo(`Custom OK handler is ${m.showUIEnabled ? "enabled" : "disabled"}`)
' asyncStopSemantics available since Roku OS 12.5 ' asyncStopSemantics available since Roku OS 12.5
' It is set to true because stopping synchronously causes timeout and crash ' It is set to true because stopping synchronously causes timeout and crash
' Usually we would need to wait for the video state to move to "stopping" then to "stopped" ' Usually we would need to wait for the video state to move to "stopping" then to "stopped"
@@ -35,6 +46,9 @@ function Init()
if m.top.hasField("asyncStopSemantics") if m.top.hasField("asyncStopSemantics")
m.top.asyncStopSemantics = true m.top.asyncStopSemantics = true
end if end if
httpAgent = m.top.getHttpAgent()
httpAgent.AddHeader("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0")
end function end function
function OnNodeReady() function OnNodeReady()
@@ -50,6 +64,7 @@ function OnNodeReady()
m.fullScreenHint.translation = [0, minRect.height - m.fullScreenHint.height] m.fullScreenHint.translation = [0, minRect.height - m.fullScreenHint.height]
' TODO:P2 show a loading spinner if video is loading minimized ' TODO:P2 show a loading spinner if video is loading minimized
' Probably only worth doing after the video player is redone
m.top.enableUI = m.container.fullscreen m.top.enableUI = m.container.fullscreen
m.top.showFullScreenHint = not m.container.fullscreen m.top.showFullScreenHint = not m.container.fullscreen
@@ -114,9 +129,10 @@ function OnVideoContentTaskResults(output as object) as void
LogError(error) LogError(error)
videoId = output.task.input.content.videoId videoId = output.task.input.content.videoId
message = `Failed to load video information for ${videoId}\n${error}` message = `Failed to load video information for ${videoId}\n${error}`
DialogUtils.ShowDialog(message, "Video load fail", true)
' TODO:P1 play next video in the queue after showing the error dialog dialog = DialogUtils.ShowTimedDialogButtons(message, "Video load fail", ["Play next video", "Cancel"], 0, 10, true)
m.videoQueue.closePlayer = true dialog.observeFieldScoped("wasClosed", FuncName(OnVideoContentTaskErrorDialogResponse))
Lounge.SendOnStateChange() Lounge.SendOnStateChange()
return return
end if end if
@@ -129,6 +145,18 @@ function OnVideoContentTaskResults(output as object) as void
end if end if
end function end function
function OnVideoContentTaskErrorDialogResponse(event as object)
dialog = event.getRoSGNode()
dialog.unobserveFieldScoped("wasClosed")
shouldPlayNext = dialog.actualButtonSelected = 0
if not shouldPlayNext or not VideoQueueUtils.PlayNext(m.videoQueue, m.invidious, m.preferences)
m.videoQueue.closePlayer = true
end if
Lounge.SendOnStateChange()
end function
function MarkVideoWatched(videoId as string) function MarkVideoWatched(videoId as string)
if m.top.invidious.authToken <> invalid if m.top.invidious.authToken <> invalid
AsyncTask.Start(Tasks.MarkVideoWatchedTask, { AsyncTask.Start(Tasks.MarkVideoWatchedTask, {
@@ -169,6 +197,12 @@ function OnVideoPlayerStateChange() as void
state = m.top.state state = m.top.state
content = m.top.content content = m.top.content
' Reset isSeekingPosition when started to play the video
if state = "playing"
m.isSeekingPosition = false
end if
' If we successfully played the video, then any error that comes later is not due to a 403 (FORBIDDEN). ' If we successfully played the video, then any error that comes later is not due to a 403 (FORBIDDEN).
' This is to reduce false positives, as we do not want retry another link if the first link is working fine. ' This is to reduce false positives, as we do not want retry another link if the first link is working fine.
if state = "playing" and not m.videoPlayingSuccess if state = "playing" and not m.videoPlayingSuccess
@@ -231,9 +265,10 @@ function OnVideoPlayerStateChange() as void
title = `Error playing video ${content.videoId}` title = `Error playing video ${content.videoId}`
LogError(title, messageLines) LogError(title, messageLines)
DialogUtils.ShowDialog(messageLines, title, true)
' TODO:P1 play next video in the queue after showing the error dialog dialog = DialogUtils.ShowTimedDialogButtons(messageLines, title, ["Play next video", "Cancel"], 0, 10, true)
m.videoQueue.closePlayer = true dialog.observeFieldScoped("wasClosed", FuncName(OnVideoContentTaskErrorDialogResponse))
m.ignoreNextFinishedState = true
end if end if
end function end function
@@ -243,6 +278,69 @@ function OnVideoFinished() as void
end if end if
end function end function
function IsLiveVideo() as boolean
if m.top.content <> invalid
return m.top.content.live
end if
return false
end function
function ShowUIAndStartTimer()
if m.showUIEnabled
m.top.showUI = { "show": true, "trickPlaybar": true, "titleAndTime": true, "trickplayBackgroundOverlay": true, "focusTrickplayBar": false }
m.trickplayUITimer.control = "start"
end if
end function
function HideUIAndStopTimer()
if m.showUIEnabled
m.top.showUI = { "show": false, "focusTrickplayBar": false }
m.trickplayUITimer.control = "stop"
end if
end function
function HandleOKPress() as boolean
if not m.showUIEnabled
return false
end if
handled = false
state = m.top.state
uiVisible = m.top.trickPlaybar.visible
isLive = IsLiveVideo()
LogInfo(`Handling OK button: state = ${state}, uiVisible = ${uiVisible} isLive = ${isLive}`)
if state = "playing"
if not uiVisible
' Video is playing and UI is not visible, show it
ShowUIAndStartTimer()
else if not isLive
' Trickplay bar is visible and video is currently played, pause it and retain the UI
m.trickplayUITimer.control = "stop"
m.top.control = "pause"
ShowUIAndStartTimer()
else
HideUIAndStopTimer()
end if
handled = true
else if state = "paused"
' Exit early if we're in seeking mode to avoid messing up internal Video node state
if m.isSeekingPosition
return false
end if
if not uiVisible
' Video is paused and UI is not visible, show it
ShowUIAndStartTimer()
else
' Video is currently paused with visible UI, resume it and hide UI
HideUIAndStopTimer()
m.top.control = "resume"
end if
handled = true
end if
return handled
end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnkeyEvent(key as string, press as boolean) as boolean
if press = false if press = false
return false return false
@@ -260,6 +358,19 @@ function OnkeyEvent(key as string, press as boolean) as boolean
m.videoQueue.closePlayer = true m.videoQueue.closePlayer = true
return true return true
end if end if
if key = "OK"
return HandleOKPress()
end if
if key = "left" or key = "right" or key = "rewind" or key = "fastforward"
' We're paused and one of the buttons is pressed: left, right ff, rw.
' That means we're seeking position. Check that in HandleOKPress and exit early
m.isSeekingPosition = true
end if
' Always stop UI timer when pressing any button to avoid UI being hidden twice
m.trickplayUITimer.control = "stop"
return false return false
end function end function
@@ -281,6 +392,8 @@ function SetupAnimation()
end function end function
function OnFullScreenChange() function OnFullScreenChange()
HideUIAndStopTimer()
m.widthInterpolator.reverse = m.container.fullscreen m.widthInterpolator.reverse = m.container.fullscreen
m.heightInterpolator.reverse = m.container.fullscreen m.heightInterpolator.reverse = m.container.fullscreen
m.translationInterpolator.reverse = m.container.fullscreen m.translationInterpolator.reverse = m.container.fullscreen
@@ -312,6 +425,10 @@ function OnShowFullScreenHint() as void
m.fullScreenHintTimer.control = "start" m.fullScreenHintTimer.control = "start"
end function end function
function OnTrickplayUITimer()
HideUIAndStopTimer()
end function
function OnFullScreenHintTimer() function OnFullScreenHintTimer()
showFullScreenHint = m.top.showFullScreenHint showFullScreenHint = m.top.showFullScreenHint
m.fullScreenHint.visible = showFullScreenHint m.fullScreenHint.visible = showFullScreenHint
@@ -16,53 +16,17 @@
<function name="Close" /> <function name="Close" />
</interface> </interface>
<children> <children>
<Label <Label id="chapterLabel" width="350" height="25" horizAlign="center" vertAlign="center" font="font:SmallestSystemFont" />
id="chapterLabel" <Timer id="chapterLabelTimer" repeat="true" duration="0.25" />
width="350" <Animation id="minimizeAnimation" duration="0.3" optional="true">
height="25" <FloatFieldInterpolator id="widthInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.width" />
horizAlign="center" <FloatFieldInterpolator id="heightInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.height" />
vertAlign="center" <Vector2DFieldInterpolator id="translationInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.translation" />
font="font:SmallestSystemFont"
/>
<Timer
id="chapterLabelTimer"
repeat="true"
duration="0.25"
/>
<Animation id="minimizeAnimation"
duration="0.3"
optional="true">
<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" />
<Vector2DFieldInterpolator
id="translationInterpolator"
key="[0.0, 0.5, 1.0]"
fieldToInterp="VideoPlayer.translation" />
</Animation> </Animation>
<Rectangle <Rectangle id="fullScreenHint" height="26" color="0x000000" opacity="0.8" visible="false">
id="fullScreenHint" <Label id="fullScreenHintLabel" text="Press Options (*) for full screen" height="26" color="0xFFFFFF" horizAlign="center" vertAlign="center" font="font:SmallestSystemFont" />
height="26" <Timer id="fullScreenHintTimer" duration="5" />
color="0x000000" <Timer id="trickplayUITimer" duration="5" />
opacity="0.8"
visible="false">
<Label
id="fullScreenHintLabel"
text="Press Options (*) for full screen"
height="26"
color="0xFFFFFF"
horizAlign="center"
vertAlign="center"
font="font:SmallestSystemFont"
/>
<Timer
id="fullScreenHintTimer"
duration="5" />
</Rectangle> </Rectangle>
</children> </children>
</component> </component>
@@ -0,0 +1,46 @@
import "pkg:/components/Services/Invidious/InvidiousService.bs"
@asynctask
function VideoContentTaskDev(input as object) as object
contentNode = input.content
invidiousNode = input.invidious
if StringUtils.IsNullOrEmpty(contentNode.videoId)
throw "Can't load video information: videoId is missing"
end if
service = new Invidious.InvidiousService(invidiousNode)
response = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
if m.top.cancel
return invalid
end if
metadata = response.Json()
if not response.IsSuccess() or metadata = invalid
return {
success: false
error: response.ErrorMessage()
}
end if
contentNode.title = metadata.title
contentNode.secondaryTitle = metadata.author
contentNode.live = metadata.liveNow
streamUrls = [`http://127.0.0.1:8888/api/dash?v=${metadata.videoId}`]
contentNode.url = streamUrls[0]
contentNode.addFields({
metadata: metadata
' StreamUrls is taken
playletStreamUrls: streamUrls
playletStreamUrlIndex: 0
})
return {
success: true
}
end function
@@ -0,0 +1,95 @@
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.top.enableUI = false
m.top.enableTrickPlay = false
httpAgent = m.top.getHttpAgent()
httpAgent.AddHeader("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0")
end function
function PlayWithContent(contentNode as object)
videoContentNode = CreateObject("roSGNode", "ContentNode")
if not StringUtils.IsNullOrEmpty(contentNode.videoId)
videoContentNode.AddFields({ videoId: contentNode.videoId })
end if
if not StringUtils.IsNullOrEmpty(contentNode.title)
videoContentNode.title = contentNode.title
end if
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
if not StringUtils.IsNullOrEmpty(contentNode._author)
videoContentNode.secondaryTitle = contentNode._author
end if
StartVideoContentTask(videoContentNode)
end function
function StartVideoContentTask(videoContentNode as object)
if m.videoContentTask <> invalid
m.videoContentTask.cancel = true
end if
m.top.content = videoContentNode
m.videoContentTask = AsyncTask.Start(Tasks.VideoContentTaskDev, {
content: videoContentNode
invidious: m.top.invidious
}, OnVideoContentTaskResults)
end function
function OnVideoContentTaskResults(output as object) as void
m.videoContentTask = invalid
if output.cancelled
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)
Close(invalid)
return
end if
m.top.control = "play"
end function
function Close(_unused as dynamic)
if m.videoContentTask <> invalid
m.videoContentTask.cancel = true
m.videoContentTask = invalid
end if
parent = m.top.getParent()
if parent <> invalid
parent.RemoveChild(m.top)
end if
m.top.control = "stop"
m.top.content = invalid
end function
function OnkeyEvent(key as string, press as boolean) as boolean
if press = false
return false
end if
if key = "back"
m.videoQueue.closePlayer = true
return true
end if
return false
end function
@@ -0,0 +1,23 @@
<!--
VideoPlayerDev is the player that will eventually be used in the Playlet app.
It extends the Video component, and will be fully managing the UI, progress,
buffering, and any state of the video playback.
This would allow us to be flexible with the UI beyond the customizations
of the stock Roku Video component.
-->
<component name="VideoPlayerDev" extends="Video" includes="AutoBind">
<interface>
<field id="videoQueue" type="node" bind="../../VideoQueue" />
<field id="invidious" type="node" bind="../../Invidious" />
<function name="PlayWithContent" />
<function name="Close" />
</interface>
<children>
<SimpleLabel
text="Dev Player!"
color="#FF0000"
fontUri="font:SmallestBoldSystemFont"
horizOrigin="right"
translation="[1280,0]" />
</children>
</component>
@@ -355,8 +355,15 @@ function OnHasNext()
end function end function
function CreateVideoPlayer() as object function CreateVideoPlayer() as object
useDevPlayer = m.top.preferences["dev.dev_video_player"]
if useDevPlayer
playerComponent = "VideoPlayerDev"
else
playerComponent = "VideoPlayer"
end if
container = m.top.videoContainer container = m.top.videoContainer
videoPlayer = container.createChild("VideoPlayer") videoPlayer = container.createChild(playerComponent)
videoPlayer.id = "VideoPlayer" videoPlayer.id = "VideoPlayer"
videoPlayer@.BindNode() videoPlayer@.BindNode()
@@ -44,7 +44,8 @@
numColumns="1" numColumns="1"
numRows="6" numRows="6"
vertFocusAnimationStyle="floatingFocus" vertFocusAnimationStyle="floatingFocus"
translation="[20,90]" /> translation="[20,90]"
focusBitmapUri="pkg:/images/focus-glow-padding-27.9.png" />
</Rectangle> </Rectangle>
<Animation id="showAnimation" <Animation id="showAnimation"
@@ -56,12 +56,14 @@ function SetHighlight() as void
contentIndex = content.queueIndex contentIndex = content.queueIndex
index = m.top.index index = m.top.index
if contentIndex = index highlighted = contentIndex = index
if highlighted
' bs:disable-next-line LINT3023 ' bs:disable-next-line LINT3023
m.top.thumbnailBlendColor = "#FFFFFFFF" m.top.thumbnailBlendColor = "#FFFFFFFF"
m.top.highlightUri = "pkg:/images/focus_grid.9.png"
else else
m.top.thumbnailBlendColor = "#606060FF" m.top.thumbnailBlendColor = "#606060FF"
m.top.highlightUri = ""
end if end if
m.top.highlightVisible = highlighted
end function end function
@@ -5,7 +5,7 @@
<field id="title" type="string" alias="titleLabel.text" /> <field id="title" type="string" alias="titleLabel.text" />
<field id="thumbnailUri" type="uri" alias="thumbnailPoster.uri" /> <field id="thumbnailUri" type="uri" alias="thumbnailPoster.uri" />
<field id="thumbnailBlendColor" type="color" alias="thumbnailPoster.blendColor" /> <field id="thumbnailBlendColor" type="color" alias="thumbnailPoster.blendColor" />
<field id="highlightUri" type="uri" alias="highlightPoster.uri" /> <field id="highlightVisible" type="boolean" alias="highlightPoster.visible" />
<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" />
</interface> </interface>
@@ -36,9 +36,9 @@
<Poster <Poster
id="highlightPoster" id="highlightPoster"
blendColor="0xFF1C30" blendColor="0xFF1C30"
uri="pkg:/images/queue-highlight.9.png"
width="164" width="164"
height="94" /> height="94" />
<Label <Label
id="titleLabel" id="titleLabel"
width="260" width="260"
@@ -77,18 +77,15 @@ namespace Http
end if end if
end if end if
registerUrl = "https://www.youtube.com/api/lounge/pairing/register_pairing_code" req = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/register_pairing_code", "")
registerBody = { req.UrlEncodedForm({
"app": "Playlet" "app": "Playlet"
"pairing_code": pairingCode "pairing_code": pairingCode
"screen_id": m.loungeService.screenId "screen_id": m.loungeService.screenId
"screen_name": m.deviceName "screen_name": m.deviceName
"device_id": m.deviceId "device_id": m.deviceId
} })
body = UrlUtils.GetUrlEncodedForm(registerBody)
req = HttpClient.Post(registerUrl, body)
req.Header("Content-Type", "application/x-www-form-urlencoded")
res = req.Await() res = req.Await()
if not res.IsSuccess() if not res.IsSuccess()
@@ -8,7 +8,9 @@ namespace Http
function new(server as object) function new(server as object)
super() super()
m.invidiousNode = server.task.invidious task = server.task
m.profilesNode = task.profiles
m.invidiousNode = task.invidious
m.invidiousService = new Invidious.InvidiousService(m.invidiousNode) m.invidiousService = new Invidious.InvidiousService(m.invidiousNode)
end function end function
@@ -21,16 +23,6 @@ namespace Http
return true return true
end function end function
@get("/invidious/logout")
function Logout(context as object) as boolean
response = context.response
m.invidiousService.Logout()
response.Default(204, "OK")
return true
end function
@get("/invidious/token_callback") @get("/invidious/token_callback")
function OnTokenReceived(context as object) as boolean function OnTokenReceived(context as object) as boolean
request = context.request request = context.request
@@ -42,7 +34,12 @@ namespace Http
username = request.query["username"].DecodeUriComponent().DecodeUriComponent() username = request.query["username"].DecodeUriComponent().DecodeUriComponent()
referer = request.query["ref"].DecodeUriComponent() referer = request.query["ref"].DecodeUriComponent()
m.invidiousNode@.SetAuthToken(token, referer, username) profile = CreateObject("roSGNode", "ProfileContentNode")
profile.username = username
profile.accessToken = token
profile.serverUrl = referer
m.profilesNode@.LoginWithProfile(profile)
end if end if
response.Redirect("/") response.Redirect("/")
return true return true
@@ -0,0 +1,73 @@
namespace Http
class ProfilesRouter extends HttpRouter
function new(server as object)
super()
m.profilesNode = server.task.profiles
m.profilesContent = m.profilesNode.content.getChild(0)
end function
@get("/api/profiles")
function GetProfiles(context as object) as boolean
response = context.response
profiles = m.profilesNode@.GetProfilesDto(false)
response.Json(profiles)
return true
end function
@post("/api/profiles/activate")
function ActivateProfile(context as object) as boolean
request = context.request
response = context.response
payload = request.Json()
if payload = invalid
response.Default(400, `Invalid JSON payload`)
return true
end if
id = payload.id
if StringUtils.IsNullOrEmpty(id)
response.Default(400, "Missing profile id")
return true
end if
profile = m.profilesContent.findNode(id)
if profile = invalid
response.Default(404, `Profile id "${id}" not found`)
return true
end if
m.profilesNode@.SetCurrentProfile(profile)
response.Default(200, "Profile updated")
return true
end function
@delete("/api/profiles")
function Logout(context as object) as boolean
request = context.request
response = context.response
id = request.query.id
if StringUtils.IsNullOrEmpty(id)
response.Default(400, "Missing profile id")
return true
end if
profile = m.profilesContent.findNode(id)
if profile = invalid
response.Default(404, `Profile id "${id}" not found`)
return true
end if
m.profilesNode@.LogoutWithProfile(profile)
response.Default(200, "Profile logged out")
return true
end function
end class
end namespace
@@ -11,6 +11,7 @@ namespace Http
m.applicationInfoNode = task.applicationInfo m.applicationInfoNode = task.applicationInfo
m.invidiousNode = task.invidious m.invidiousNode = task.invidious
m.preferencesNode = task.preferences m.preferencesNode = task.preferences
m.profilesNode = task.profiles
end function end function
@get("/api/state") @get("/api/state")
@@ -18,7 +19,7 @@ namespace Http
request = context.request request = context.request
response = context.response response = context.response
keys = ["app", "device", "invidious", "preferences"] keys = ["app", "device", "invidious", "preferences", "profiles"]
if request.query.DoesExist("key") if request.query.DoesExist("key")
keys = request.query["key"] keys = request.query["key"]
@@ -27,9 +28,14 @@ namespace Http
end if end if
end if end if
keysDict = {}
for each key in keys
keysDict[key] = true
end for
state = {} state = {}
if ArrayUtils.IndexOfString(keys, "app") <> -1 if keysDict["app"] = true
appInfo = m.applicationInfoNode@.GetAppInfo() appInfo = m.applicationInfoNode@.GetAppInfo()
if appInfo.lib_version_latest = "N/A" if appInfo.lib_version_latest = "N/A"
@@ -46,25 +52,25 @@ namespace Http
state["app"] = appInfo state["app"] = appInfo
end if end if
if ArrayUtils.IndexOfString(keys, "device") <> -1 if keysDict["device"] = true
state["device"] = m.applicationInfoNode@.GetDeviceInfo() state["device"] = m.applicationInfoNode@.GetDeviceInfo()
end if end if
if ArrayUtils.IndexOfString(keys, "invidious") <> -1 if keysDict["invidious"] = true
authToken = m.invidiousNode.authToken
state["invidious"] = { state["invidious"] = {
current_instance: m.invidiousNode@.GetCurrentInstance() current_instance: m.invidiousNode@.GetCurrentInstance()
auth_url: m.invidiousNode@.GetAuthorizeTokenLink() auth_url: m.invidiousNode@.GetAuthorizeTokenLink()
logged_in: authToken <> invalid
logged_in_instance: authToken <> invalid ? authToken.instance : invalid
logged_in_username: authToken <> invalid ? authToken.username : invalid
} }
end if end if
if ArrayUtils.IndexOfString(keys, "preferences") <> -1 if keysDict["preferences"] = true
state["preferences"] = m.preferencesNode@.GetUserPreferences() state["preferences"] = m.preferencesNode@.GetUserPreferences()
end if end if
if keysDict["profiles"] = true
state["profiles"] = m.profilesNode@.GetProfilesDto(false)
end if
response.Json(state) response.Json(state)
return true return true
end function end function
@@ -99,6 +99,69 @@ namespace Http
return true return true
end function end function
' A shortcut to play a video using a /watch endpoint
@get("/watch")
function PlayWatch(context as object) as boolean
request = context.request
response = context.response
videoId = request.query.v
playlistId = request.query.list
playlistIndex = request.query.index
hasValidVideo = not StringUtils.IsNullOrEmpty(videoId)
hasValidPlaylist = not StringUtils.IsNullOrEmpty(playlistId) and not StringUtils.IsNullOrEmpty(playlistIndex)
if not hasValidVideo and not hasValidPlaylist
response.Default(400, `Missing video id ("v") or playlist id and index ("list" and "index") in query`)
return true
end if
instance = m.invidiousService.GetInstance()
if hasValidPlaylist
payload = {
"type": "playlist"
"playlistId": playlistId
}
contentNode = InvidiousContent.ToRowCellContentNode(payload, instance)
playlistIndex = MathUtils.Max(0, ValidInt(playlistIndex.toInt()) - 1)
' TODO:P1 handle playlist with timestamp
' TODO:P1 videoId should take precedence over index
m.videoQueueNode.playPlaylist = {
playlistNode: contentNode
playlistIndex: playlistIndex
}
response.Default(200, "Now playing playlist - " + playlistId)
return true
else if hasValidVideo
timestamp = request.query.t
if IsString(timestamp)
if timestamp.endsWith("s")
timestamp = timestamp.left(timestamp.Len() - 1)
end if
timestamp = timestamp.toInt()
end if
timestamp = ValidInt(timestamp)
payload = {
"type": "video"
"videoId": videoId
"timestamp": timestamp
}
contentNode = InvidiousContent.ToRowCellContentNode(payload, instance)
m.videoQueueNode.playVideo = contentNode
response.Default(200, "Now playing video - " + videoId)
return true
end if
return false
end function
@delete("/api/queue") @delete("/api/queue")
function ClearQueue(context as object) as boolean function ClearQueue(context as object) as boolean
response = context.response response = context.response
Loaded 100 of 140 files, more files were not shown because too many files have changed in this diff. Show more