Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
910d57795a | ||
|
|
ef733d8d88 | ||
|
|
6ad42f3fcd | ||
|
|
1ba5184d95 | ||
|
|
26ed985ecc | ||
|
|
6b47440cb5 | ||
|
|
ee3312763d | ||
|
|
7bb73e0fb6 | ||
|
|
f71ad7b873 | ||
|
|
0f6329997d | ||
|
|
58918f68fb | ||
|
|
8a63bc848d | ||
|
|
9315fa6cf7 | ||
|
|
15841cf5bf | ||
|
|
9c7de8f41f | ||
|
|
405e1aa703 | ||
|
|
79d9e0f069 | ||
|
|
d8bfd8859e | ||
|
|
1c8d075e87 | ||
|
|
13bb21c1f7 | ||
|
|
394dd23999 | ||
|
|
8e03ca0ea6 | ||
|
|
aebdc579a9 | ||
|
|
87e7d91169 | ||
|
|
c334736325 | ||
|
|
bb0a0725d6 | ||
|
|
f2ffb42876 | ||
|
|
edbfc86e56 | ||
|
|
b25eaafc82 | ||
|
|
ef9c653ad7 | ||
|
|
e9f015bb19 | ||
|
|
544671f246 | ||
|
|
f45ba30979 | ||
|
|
4953e4481f | ||
|
|
c7b0815768 | ||
|
|
4ab7f74a4e | ||
|
|
96916f6c37 | ||
|
|
eafad684b6 | ||
|
|
14d3e38aeb | ||
|
|
afe281c094 | ||
|
|
436078bdf8 | ||
|
|
20120538e4 | ||
|
|
eec4101d29 | ||
|
|
b135ba2a0a | ||
|
|
9c9f24cb39 | ||
|
|
6aeb4bc8b9 | ||
|
|
4beb7fbf3c | ||
|
|
4f3512023f | ||
|
|
f38115171b | ||
|
|
7456917cec | ||
|
|
4482d3333f | ||
|
|
1112070f63 | ||
|
|
37dde57c67 | ||
|
|
b52cd6f01b | ||
|
|
aa5be75e06 | ||
|
|
188463c6a7 | ||
|
|
793842f4dd | ||
|
|
7ca98e7ef2 | ||
|
|
77204c4449 | ||
|
|
190548245a | ||
|
|
71f9820ed6 | ||
|
|
87e50e713f | ||
|
|
2d55569614 | ||
|
|
83a59a5e9c | ||
|
|
7d1ba07286 | ||
|
|
ec9178d687 | ||
|
|
84c6d822e2 | ||
|
|
7503c2dbd6 | ||
|
|
ca3cad4058 | ||
|
|
c7f14dfc38 | ||
|
|
ac3d1cea17 |
No files matched your search
+84
-1
@@ -2,9 +2,92 @@
|
||||
|
||||
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).
|
||||
|
||||
## [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
|
||||
|
||||
### Added
|
||||
|
||||
- Support for casting from the YouTube app (also known as Lounge API, or LeanBack)
|
||||
- Connect to Playlet from the YouTube mobile app or from certain browsers (such as Chrome)
|
||||
- Connect to Playlet from local network, or through the TV code.
|
||||
- On the cast dialog in your YouTube mobile app, you might see two listings for the same device. E.g. `Roku TV` and `Playlet on Roku TV`. Use the `Playlet on` one to cast to Playlet, and the other one to cast to the regular YouTube TV app.
|
||||
- The functionality is still experiemntal, and has some limitations. To name a few:
|
||||
- The queue does not perfectly sync between the mobile app and Playlet, espeically if it gets modified by the web app or in Playlet.
|
||||
- Many functions (such as d-pad controls or setting the volume) are not working due to OS limitations
|
||||
- Many functions (such as changing the subtitle settings) are not currently implemented
|
||||
- **ATTENTION**: This feature is not very privacy friendly. When connected to a lounge, all network traffic (videos played, queued, etc) go through YouTube servers. For this reason, certain measures are taken:
|
||||
- While Playlet broadcasts its casting capabilities to the local network, it does not connect to a lounge for the first time until:
|
||||
- A device connects to Playlet (using DIAL/Connect using Wi-Fi)
|
||||
- A `Link with TV code` is generated, by visiting the `Remote` -> `Link with TV code` tab.
|
||||
- Playlet disconnects from previous lounge sessions on start, and joins a new one instead of one continous session. In other words, restarting Playlet will disconnect your second device. This is a feature, not a bug.
|
||||
- Playlet does not expose device details, and uses a randomly generated id on each start, instead of consistent device id.
|
||||
|
||||
### Changed
|
||||
|
||||
- The queue no longer contains playlists. When a playlist is added to the queue, the entire playlist is loaded.
|
||||
- It can take a few seconds to load large playlist before it can be added to the queue
|
||||
- This is done to be more compatible more the lounge, which does not contain "Playlists in the queue" concept.
|
||||
- The `Web App` tab is now called `Remote`. It can be used to open the web app, or connect using Lounge (cast from YouTube)
|
||||
- Removed `fields` from Invidious requests, as per [https://github.com/iv-org/invidious/pull/4276](https://github.com/iv-org/invidious/pull/4276)
|
||||
- The `POST /api/queue/` no longer returns the current queue. Instead it returns a 204.
|
||||
|
||||
### Fixed
|
||||
|
||||
- [Perf] improved some caching of videos in the queue
|
||||
|
||||
## [0.19.2] - 2024-02-11
|
||||
|
||||
### Fixed
|
||||
|
||||
+24
-11
@@ -1,39 +1,52 @@
|
||||
# PRIVACY POLICY
|
||||
|
||||
## Playlet
|
||||
|
||||
Playlet, the Roku app, does not collect any user information whatsoever.
|
||||
In fact, it does not have any servers capable of collecting any form of data.
|
||||
|
||||
Playlet does not show advertising, whether personalized or non personalized.
|
||||
|
||||
## Invidious
|
||||
|
||||
Playlet may request information from one or more [Invidious](https://invidious.io/)
|
||||
servers, depending on user configuration. With these requests, absolutely no
|
||||
user data is collected, and only the bare minimum and necessary information
|
||||
servers, depending on user configuration. With these requests, absolutely no
|
||||
user data is collected, and only the bare minimum and necessary information
|
||||
is sent, which is used to enable the viewing of content.
|
||||
|
||||
Please note that some of the [Invidious](https://invidious.io/) servers used
|
||||
could be public instances hosted by volenteers. These instances are available
|
||||
[here](https://api.invidious.io/).
|
||||
[here](https://api.invidious.io/).
|
||||
|
||||
While invidious does no data collection by default, and it is in fact built to
|
||||
be privacy driven, but in theory, from a playlet request it is possible to
|
||||
know the IP address of a user, the identifiers of watched video, and search
|
||||
be privacy driven, but in theory, from a playlet request it is possible to
|
||||
know the IP address of a user, the identifiers of watched video, and search
|
||||
keywords. In case the user has privacy concerns, they can host their own
|
||||
Invidious instance and use it from Playlet.
|
||||
|
||||
## SponsorBlock
|
||||
|
||||
Playlet may request information from a [SponsorBlock](https://github.com/ajayyy/SponsorBlock)
|
||||
server, in order to get sponsor sections for requested videos to watch.
|
||||
With these requests, absolutely no
|
||||
user data is collected, and only the bare minimum and necessary information
|
||||
With these requests, absolutely no
|
||||
user data is collected, and only the bare minimum and necessary information
|
||||
is sent, which is used to enable the viewing of content.
|
||||
|
||||
Playlet uses hashing when requesting video metadata, which obfuscates
|
||||
Playlet uses hashing when requesting video metadata, which obfuscates
|
||||
the video id requested. This is a SponsorBlock privacy feature that protects
|
||||
user privacy.
|
||||
|
||||
Additionally, Playlet may send a "skipped" event to SponsorBlock, to indicate
|
||||
that a section of a video has been skipped. This event does not have any
|
||||
tracking information attached to it, and it is anonymous. It is merely to
|
||||
indicate to contributers how much their contributions are being used in the wild.
|
||||
that a section of a video has been skipped. This event does not have any
|
||||
tracking information attached to it, and it is anonymous. It is merely to
|
||||
indicate to contributers how much their contributions are being used in the wild.
|
||||
|
||||
## LeanBack
|
||||
|
||||
LeanBack, also known as Lounge API, also known as "cast from phone". Is a feature that Playlet implmements as a convenience to allow users to use a separate device to browse and cast videos.
|
||||
When this feature is used, all traffic related to the videos being watched, added to the queue, and the video player state is routed through YouTube servers.
|
||||
|
||||
Playlet tries to preserve user privacy, to the best of its ability, by implementing several techniques, such as randomizing device id, using a fresh session on each start, and only providing necessary fields for the feature to function.
|
||||
Additionally, Playlet does not join a session/lounge, until a device is attempting to connect using DIAL (**DI**scovery **A**nd **L**aunch spec), or when a `Link with TV code` is generated, by visiting the appropriate settings page.
|
||||
|
||||
If you have privacy concerns and do not wish to use this functionality, simply do not connect from a local network using the YouTube app or the browser, and do not visit the `Link with TV code` tab.
|
||||
@@ -42,16 +42,16 @@ More under [Screenshots](./docs/screenshots/README.md)
|
||||
- 🕵️ No Tracking
|
||||
- 🛡️ Privacy driven (uses Invidious backend)
|
||||
- ⚔️ 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
|
||||
- ⚡ Fast! [Check out how we compare with the official YouTube app](https://youtu.be/qmSvA-QQW20)
|
||||
|
||||
### Cast from phone
|
||||
|
||||
1. Open "Web app" tab in Playlet
|
||||
1. Scan QR Code with Phone
|
||||
1. Browse or search videos
|
||||
1. Click the video and choose the "Play on TV" option
|
||||
- Open "Remote" tab in Playlet
|
||||
- Scan QR Code with Phone, and use the browser; OR
|
||||
- Use the YouTube app to connect using the same Wi-Fi; OR
|
||||
- Use the `Link with TV code` to connect
|
||||
|
||||
### Picture-in-picture
|
||||
|
||||
@@ -63,7 +63,7 @@ More under [Screenshots](./docs/screenshots/README.md)
|
||||
|
||||
1. Open settings in Playlet
|
||||
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. Hit save
|
||||
|
||||
|
||||
@@ -40,6 +40,12 @@
|
||||
"regex": "\\b(?!_unused)unused\\b",
|
||||
"regexFlags": "ig",
|
||||
"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": [
|
||||
|
||||
+8
-2
@@ -294,14 +294,20 @@ This is mostly useful to QA the `canary` release (see [Canary release](https://e
|
||||
|
||||
#### 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
|
||||
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).
|
||||
|
||||
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
|
||||
|
||||
On pull requests, a Github action will run `lint:fix` and `format:fix` and push changes to the PR branch, to keep things tidy.
|
||||
|
||||
+95
-45
@@ -2,7 +2,7 @@ openapi: 3.0.0
|
||||
|
||||
info:
|
||||
title: Playlet Web API
|
||||
version: 0.19.2
|
||||
version: 0.21.2
|
||||
description:
|
||||
Playlet Web API is a RESTful API for controlling the Playlet app on
|
||||
Roku devices. The API is intended to be used by the Playlet web app, but can
|
||||
@@ -140,9 +140,9 @@ paths:
|
||||
description: No Content
|
||||
/api/queue:
|
||||
get:
|
||||
summary: Get play queue
|
||||
summary: Get video queue
|
||||
description: Get the current videos in the queue.
|
||||
operationId: getPlayQueue
|
||||
operationId: getVideoQueue
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
@@ -151,56 +151,43 @@ paths:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
index:
|
||||
type: integer
|
||||
playlistIndex:
|
||||
type: integer
|
||||
items:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PlayQueueObject"
|
||||
$ref: "#/components/schemas/VideoQueueObject"
|
||||
index:
|
||||
type: integer
|
||||
nowPlaying:
|
||||
$ref: "#/components/schemas/VideoQueueObject"
|
||||
post:
|
||||
summary: Add to play queue
|
||||
summary: Add to video queue
|
||||
description: Add a video or a playlist to the queue.
|
||||
operationId: addToPlayQueue
|
||||
operationId: addToVideoQueue
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PlayQueueObject"
|
||||
$ref: "#/components/schemas/VideoQueueObject"
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
index:
|
||||
type: integer
|
||||
playlistIndex:
|
||||
type: integer
|
||||
items:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PlayQueueObject"
|
||||
"204":
|
||||
description: No Content
|
||||
delete:
|
||||
summary: Clear play queue
|
||||
description: Clear the play queue.
|
||||
operationId: clearPlayQueue
|
||||
summary: Clear video queue
|
||||
description: Clear the video queue.
|
||||
operationId: clearVideoQueue
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
/api/queue/play:
|
||||
post:
|
||||
summary: Play video or playlist
|
||||
summary: Play video
|
||||
description: Play a video or playlist. This adds the video or playlist to the current position in the queue and plays it.
|
||||
operationId: playPlayQueue
|
||||
operationId: playVideoQueue
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PlayQueueObject"
|
||||
$ref: "#/components/schemas/VideoQueueObject"
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
@@ -335,14 +322,63 @@ paths:
|
||||
schema:
|
||||
type: string
|
||||
format: uri
|
||||
/invidious/logout:
|
||||
/api/profiles:
|
||||
get:
|
||||
summary: Logout from Invidious
|
||||
description: Logout from Invidious, and invalidate the token if any.
|
||||
operationId: invidiousLogout
|
||||
summary: Get profiles
|
||||
description: Get the logged profiles, and the currently active profile.
|
||||
operationId: getProfiles
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
"200":
|
||||
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)
|
||||
/input/{appId}:
|
||||
@@ -543,14 +579,17 @@ components:
|
||||
type: string
|
||||
auth_url:
|
||||
type: string
|
||||
logged_in:
|
||||
type: boolean
|
||||
logged_in_instance:
|
||||
type: string
|
||||
logged_in_username:
|
||||
type: string
|
||||
preferences:
|
||||
$ref: "#/components/schemas/PreferencesObject"
|
||||
profiles:
|
||||
type: object
|
||||
properties:
|
||||
currentProfile:
|
||||
type: string
|
||||
profiles:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ProfileObject"
|
||||
PreferencesObject:
|
||||
type: object
|
||||
properties:
|
||||
@@ -573,8 +612,19 @@ components:
|
||||
type: boolean
|
||||
sponsorblock.show_notifications:
|
||||
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
|
||||
PlayQueueObject:
|
||||
VideoQueueObject:
|
||||
type: object
|
||||
properties:
|
||||
videoId:
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
| --------------------------- | ------------------------------------------------ | --------------------------------------------- |
|
||||
|  |  |  |
|
||||
|
||||
| Link to web app | App info |
|
||||
| ----------------------------------- | --------------------------- |
|
||||
|  |  |
|
||||
| Remote | App info |
|
||||
| ----------------------- | --------------------------- |
|
||||
|  |  |
|
||||
|
||||
## 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 |
Generated
+233
-109
@@ -1,41 +1,41 @@
|
||||
{
|
||||
"name": "playlet",
|
||||
"version": "0.19.2",
|
||||
"version": "0.21.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playlet",
|
||||
"version": "0.19.2",
|
||||
"version": "0.21.2",
|
||||
"hasInstallScript": true,
|
||||
"devDependencies": {
|
||||
"@rokucommunity/bslint": "^0.8.17",
|
||||
"@rokucommunity/bslint": "^0.8.19",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/node": "^20.11.17",
|
||||
"@types/node": "^20.11.25",
|
||||
"@types/xml2js": "^0.4.14",
|
||||
"argparse": "^2.0.1",
|
||||
"brighterscript": "0.65.22",
|
||||
"brighterscript-formatter": "^1.6.40",
|
||||
"brighterscript": "0.65.25",
|
||||
"brighterscript-formatter": "^1.7.0",
|
||||
"convert-svg-to-png": "^0.6.4",
|
||||
"cross-fetch": "^4.0.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dotenv": "^16.4.1",
|
||||
"express": "^4.18.2",
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.18.3",
|
||||
"fs-extra": "^11.2.0",
|
||||
"glob": "^10.3.10",
|
||||
"imap": "^0.8.19",
|
||||
"ip": "^1.1.8",
|
||||
"ip": "^2.0.1",
|
||||
"json5": "^2.2.3",
|
||||
"mailparser": "^3.6.7",
|
||||
"roku-deploy": "^3.11.2",
|
||||
"rooibos-roku": "^5.11.0",
|
||||
"mailparser": "^3.6.9",
|
||||
"roku-deploy": "^3.12.0",
|
||||
"rooibos-roku": "5.10.0",
|
||||
"semver": "^7.6.0",
|
||||
"shelljs": "^0.8.5",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.3.3",
|
||||
"typescript": "^5.4.2",
|
||||
"xml2js": "^0.6.2",
|
||||
"yaml": "^2.3.4"
|
||||
"yaml": "^2.4.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18"
|
||||
@@ -276,9 +276,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@rokucommunity/bslint": {
|
||||
"version": "0.8.17",
|
||||
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.17.tgz",
|
||||
"integrity": "sha512-e0ksPVYnN+QkhzuV97yPTf1NxSkBQZNMJRhlCFnMJf6gfps+VdY1HwYn3IlqDz3XJxfYcRSDa3v3fQ5dQynVEA==",
|
||||
"version": "0.8.19",
|
||||
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.19.tgz",
|
||||
"integrity": "sha512-2vQasjH5nZdgJJzxAOwYzA8gtjvvO5MtxfqjK10shE1G8XmLpqguT5qHzLz+HxvdRbFZ7OSOOyBAqQHgZRpO1Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"fs-extra": "^10.0.0",
|
||||
@@ -370,9 +370,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.11.17",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.17.tgz",
|
||||
"integrity": "sha512-QmgQZGWu1Yw9TDyAP9ZzpFJKynYNeOvwMJmaxABfieQoVoiVOS6MN1WSpqpRcbeA5+RW82kraAVxCCJg+780Qw==",
|
||||
"version": "20.11.25",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.25.tgz",
|
||||
"integrity": "sha512-TBHyJxk2b7HceLVGFcpAUjsa5zIdsPWlR6XHfyGzd0SFu+/NFgQgMAl96MSDZgQDvJAvV6BKsFOrt6zIL09JDw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
@@ -676,13 +676,13 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/body-parser": {
|
||||
"version": "1.20.1",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
|
||||
"integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
|
||||
"version": "1.20.2",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
|
||||
"integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"content-type": "~1.0.4",
|
||||
"content-type": "~1.0.5",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "1.2.0",
|
||||
@@ -690,7 +690,7 @@
|
||||
"iconv-lite": "0.4.24",
|
||||
"on-finished": "2.4.1",
|
||||
"qs": "6.11.0",
|
||||
"raw-body": "2.5.1",
|
||||
"raw-body": "2.5.2",
|
||||
"type-is": "~1.6.18",
|
||||
"unpipe": "1.0.0"
|
||||
},
|
||||
@@ -728,9 +728,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/brighterscript": {
|
||||
"version": "0.65.22",
|
||||
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.22.tgz",
|
||||
"integrity": "sha512-rDSdO33xRnFGB9nr54awTUucpd4oZpZmDMvVUSAb6jmFU1jz+SYhwV9ezc8U5m3Kswap7uV+BmS1O69QZ9MuSw==",
|
||||
"version": "0.65.25",
|
||||
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.25.tgz",
|
||||
"integrity": "sha512-sezfScxcXZfzEJ702HCMjfPsIH/x3mfLAFDObGU+xAC2E8m/zxrPOHKlD9Qpmdvd7/j4TgsujhiRQ1tnk8BzGA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@rokucommunity/bslib": "^0.1.1",
|
||||
@@ -755,7 +755,7 @@
|
||||
"parse-ms": "^2.1.0",
|
||||
"readline": "^1.3.0",
|
||||
"require-relative": "^0.8.7",
|
||||
"roku-deploy": "^3.11.2",
|
||||
"roku-deploy": "^3.12.0",
|
||||
"serialize-error": "^7.0.1",
|
||||
"source-map": "^0.7.4",
|
||||
"vscode-languageserver": "7.0.0",
|
||||
@@ -770,12 +770,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/brighterscript-formatter": {
|
||||
"version": "1.6.40",
|
||||
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.6.40.tgz",
|
||||
"integrity": "sha512-cxvGGluNfxy6p3khtcMt/3AschwqEnERjLRIEt3XVU0R0l2QgwXelDp8ViqgnQ2hQYa8LnfnOiV1u7OCqbiZPA==",
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.7.0.tgz",
|
||||
"integrity": "sha512-LKnUeAgNX3eKqK0J1Z55YteRlR/+DFuCbMf6/5DHdlCI7VVkOf+EWErruSfuol6+T2eImM0LY79CLT854VTE5g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"brighterscript": "^0.65.19",
|
||||
"brighterscript": "^0.65.25",
|
||||
"glob-all": "^3.3.0",
|
||||
"jsonc-parser": "^3.0.0",
|
||||
"source-map": "^0.7.3",
|
||||
@@ -1086,13 +1086,19 @@
|
||||
}
|
||||
},
|
||||
"node_modules/call-bind": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
|
||||
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
|
||||
"integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.1",
|
||||
"get-intrinsic": "^1.0.2"
|
||||
"es-define-property": "^1.0.0",
|
||||
"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": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
@@ -1607,6 +1613,23 @@
|
||||
"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": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
@@ -1706,15 +1729,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.4.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.1.tgz",
|
||||
"integrity": "sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ==",
|
||||
"version": "16.4.5",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
|
||||
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/motdotla/dotenv?sponsor=1"
|
||||
"url": "https://dotenvx.com"
|
||||
}
|
||||
},
|
||||
"node_modules/eastasianwidth": {
|
||||
@@ -1809,6 +1832,27 @@
|
||||
"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": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
|
||||
@@ -1849,14 +1893,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/express": {
|
||||
"version": "4.18.2",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz",
|
||||
"integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==",
|
||||
"version": "4.18.3",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.18.3.tgz",
|
||||
"integrity": "sha512-6VyCijWQ+9O7WuVMTRBTl+cjNNIzD5cY5mQ1WM8r/LEkI2u8EYpOotESNwzNlyCn3g+dmjKYI6BmNneSr/FSRw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "1.20.1",
|
||||
"body-parser": "1.20.2",
|
||||
"content-disposition": "0.5.4",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "0.5.0",
|
||||
@@ -1977,9 +2021,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/fastq": {
|
||||
"version": "1.16.0",
|
||||
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.16.0.tgz",
|
||||
"integrity": "sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==",
|
||||
"version": "1.17.1",
|
||||
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz",
|
||||
"integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"reusify": "^1.0.4"
|
||||
@@ -2142,10 +2186,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
|
||||
"dev": true
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"dev": true,
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-caller-file": {
|
||||
"version": "2.0.5",
|
||||
@@ -2157,15 +2204,19 @@
|
||||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz",
|
||||
"integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==",
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
|
||||
"integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.1",
|
||||
"has": "^1.0.3",
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2",
|
||||
"has-proto": "^1.0.1",
|
||||
"has-symbols": "^1.0.3"
|
||||
"has-symbols": "^1.0.3",
|
||||
"hasown": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
@@ -2307,6 +2358,18 @@
|
||||
"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": {
|
||||
"version": "4.2.11",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
||||
@@ -2357,10 +2420,22 @@
|
||||
"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": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==",
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
|
||||
"integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -2381,6 +2456,18 @@
|
||||
"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": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
||||
@@ -2592,9 +2679,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ip": {
|
||||
"version": "1.1.8",
|
||||
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz",
|
||||
"integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==",
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz",
|
||||
"integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/ipaddr.js": {
|
||||
@@ -2808,15 +2895,15 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/libmime": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/libmime/-/libmime-5.2.1.tgz",
|
||||
"integrity": "sha512-A0z9O4+5q+ZTj7QwNe/Juy1KARNb4WaviO4mYeFC4b8dBT2EEqK2pkM+GC8MVnkOjqhl5nYQxRgnPYRRTNmuSQ==",
|
||||
"version": "5.3.4",
|
||||
"resolved": "https://registry.npmjs.org/libmime/-/libmime-5.3.4.tgz",
|
||||
"integrity": "sha512-TsqPdercr6DHrnoQx1F0nS2Y4yPT+fWuOjEP2rqzvV77hMYWomTe/rpm0u9JORQ/FavEXybAGcBJsQbLr9+hjA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"encoding-japanese": "2.0.0",
|
||||
"iconv-lite": "0.6.3",
|
||||
"libbase64": "1.2.1",
|
||||
"libqp": "2.0.1"
|
||||
"libbase64": "1.3.0",
|
||||
"libqp": "2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/libmime/node_modules/iconv-lite": {
|
||||
@@ -2831,6 +2918,18 @@
|
||||
"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": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/libqp/-/libqp-2.0.1.tgz",
|
||||
@@ -2916,20 +3015,21 @@
|
||||
}
|
||||
},
|
||||
"node_modules/mailparser": {
|
||||
"version": "3.6.7",
|
||||
"resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.6.7.tgz",
|
||||
"integrity": "sha512-/3x8HW70DNehw+3vdOPKdlLuxOHoWcGB5jfx5vJ5XUbY9/2jUJbrrhda5Si8Dj/3w08U0y5uGAkqs5+SPTPKoA==",
|
||||
"version": "3.6.9",
|
||||
"resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.6.9.tgz",
|
||||
"integrity": "sha512-1fIDZlgN1NnuzmTSEUxkaViquXYkw5NbQehVc+kz55QRy98QgLdTtRSKv289Jy4NrCiDchRx6zAijB4HrPsvkA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"encoding-japanese": "2.0.0",
|
||||
"he": "1.2.0",
|
||||
"html-to-text": "9.0.5",
|
||||
"iconv-lite": "0.6.3",
|
||||
"libmime": "5.2.1",
|
||||
"libmime": "5.3.4",
|
||||
"linkify-it": "5.0.0",
|
||||
"mailsplit": "5.4.0",
|
||||
"nodemailer": "6.9.9",
|
||||
"tlds": "1.248.0"
|
||||
"nodemailer": "6.9.11",
|
||||
"punycode": "2.3.1",
|
||||
"tlds": "1.250.0"
|
||||
}
|
||||
},
|
||||
"node_modules/mailparser/node_modules/iconv-lite": {
|
||||
@@ -3083,9 +3183,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/moment": {
|
||||
"version": "2.29.4",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
|
||||
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
|
||||
"version": "2.30.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz",
|
||||
"integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "*"
|
||||
@@ -3127,9 +3227,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/nodemailer": {
|
||||
"version": "6.9.9",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.9.tgz",
|
||||
"integrity": "sha512-dexTll8zqQoVJEZPwQAKzxxtFn0qTnjdQTchoU6Re9BUUGBJiOy3YMn/0ShTW6J5M0dfQ1NeDeRTTl4oIWgQMA==",
|
||||
"version": "6.9.11",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.11.tgz",
|
||||
"integrity": "sha512-UiAkgiERuG94kl/3bKfE8o10epvDnl0vokNEtZDPTq9BWzIl6EFT9336SbIT4oaTBD8NmmUTLsQyXHV82eXSWg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
@@ -3166,9 +3266,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/object-inspect": {
|
||||
"version": "1.12.3",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz",
|
||||
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==",
|
||||
"version": "1.13.1",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz",
|
||||
"integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==",
|
||||
"dev": true,
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
@@ -3689,9 +3789,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/raw-body": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
|
||||
"integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
|
||||
"version": "2.5.2",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
|
||||
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
@@ -3850,9 +3950,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/roku-deploy": {
|
||||
"version": "3.11.2",
|
||||
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.11.2.tgz",
|
||||
"integrity": "sha512-3JDlnbTxv6Xk5GVolQoA3+d34MLZXXwZWMySprHwazZoWLP3LvulYHP92YvFOJAo/aI4IZp/TFA8kR82IrmHKA==",
|
||||
"version": "3.12.0",
|
||||
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.12.0.tgz",
|
||||
"integrity": "sha512-YiCZeQ+sEmFW9ZfXtMNH+/CBSHQ5deNZYWONM+s6gCEQsrz7kCMFPj5YEdgfqW+d2b8G1ve9GELHcSt2FsfM8g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"chalk": "^2.4.2",
|
||||
@@ -3921,9 +4021,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/rooibos-roku": {
|
||||
"version": "5.11.0",
|
||||
"resolved": "https://registry.npmjs.org/rooibos-roku/-/rooibos-roku-5.11.0.tgz",
|
||||
"integrity": "sha512-qxTYwsyp6Ihb6B8tmFm+24DE/s2gMCxagvdABElGWgqL834M+kZtmwrQXvSrMkM+0gkmQfIDuw1M4v484gycYQ==",
|
||||
"version": "5.10.0",
|
||||
"resolved": "https://registry.npmjs.org/rooibos-roku/-/rooibos-roku-5.10.0.tgz",
|
||||
"integrity": "sha512-Idiv3nWQOEr5V8z8oHcIovjcoBffgqRtTQ5B6K+x/cGAouKxyVJp0fsZ80xQvUul9IwHQ0XIPUYbNWCR3RQ3sA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"source-map": "^0.7.3",
|
||||
@@ -4117,6 +4217,23 @@
|
||||
"integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
|
||||
"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": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
|
||||
@@ -4188,14 +4305,18 @@
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
|
||||
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
|
||||
"integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.0",
|
||||
"get-intrinsic": "^1.0.2",
|
||||
"object-inspect": "^1.9.0"
|
||||
"call-bind": "^1.0.7",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.4",
|
||||
"object-inspect": "^1.13.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
@@ -4404,9 +4525,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/tlds": {
|
||||
"version": "1.248.0",
|
||||
"resolved": "https://registry.npmjs.org/tlds/-/tlds-1.248.0.tgz",
|
||||
"integrity": "sha512-noj0KdpWTBhwsKxMOXk0rN9otg4kTgLm4WohERRHbJ9IY+kSDKr3RmjitaQ3JFzny+DyvBOQKlFZhp0G0qNSfg==",
|
||||
"version": "1.250.0",
|
||||
"resolved": "https://registry.npmjs.org/tlds/-/tlds-1.250.0.tgz",
|
||||
"integrity": "sha512-rWsBfFCWKrjM/o2Q1TTUeYQv6tHSd/umUutDjVs6taTuEgRDIreVYIBgWRWW4ot7jp6n0UVUuxhTLWBtUmPu/w==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tlds": "bin.js"
|
||||
@@ -4526,9 +4647,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.3.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
|
||||
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
|
||||
"version": "5.4.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz",
|
||||
"integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
@@ -4926,10 +5047,13 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/yaml": {
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz",
|
||||
"integrity": "sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==",
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.1.tgz",
|
||||
"integrity": "sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"yaml": "bin.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
|
||||
+13
-13
@@ -1,35 +1,35 @@
|
||||
{
|
||||
"name": "playlet",
|
||||
"version": "0.19.2",
|
||||
"version": "0.21.2",
|
||||
"description": "Unofficial YouTube client for Roku",
|
||||
"devDependencies": {
|
||||
"@rokucommunity/bslint": "^0.8.17",
|
||||
"@rokucommunity/bslint": "^0.8.19",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/node": "^20.11.17",
|
||||
"@types/node": "^20.11.25",
|
||||
"@types/xml2js": "^0.4.14",
|
||||
"argparse": "^2.0.1",
|
||||
"brighterscript": "0.65.22",
|
||||
"brighterscript-formatter": "^1.6.40",
|
||||
"brighterscript": "0.65.25",
|
||||
"brighterscript-formatter": "^1.7.0",
|
||||
"convert-svg-to-png": "^0.6.4",
|
||||
"cross-fetch": "^4.0.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dotenv": "^16.4.1",
|
||||
"express": "^4.18.2",
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.18.3",
|
||||
"fs-extra": "^11.2.0",
|
||||
"glob": "^10.3.10",
|
||||
"imap": "^0.8.19",
|
||||
"ip": "^1.1.8",
|
||||
"ip": "^2.0.1",
|
||||
"json5": "^2.2.3",
|
||||
"mailparser": "^3.6.7",
|
||||
"roku-deploy": "^3.11.2",
|
||||
"rooibos-roku": "^5.11.0",
|
||||
"mailparser": "^3.6.9",
|
||||
"roku-deploy": "^3.12.0",
|
||||
"rooibos-roku": "5.10.0",
|
||||
"semver": "^7.6.0",
|
||||
"shelljs": "^0.8.5",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.3.3",
|
||||
"typescript": "^5.4.2",
|
||||
"xml2js": "^0.6.2",
|
||||
"yaml": "^2.3.4"
|
||||
"yaml": "^2.4.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18"
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "playlet-app",
|
||||
"version": "0.19.2",
|
||||
"version": "0.21.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playlet-app",
|
||||
"version": "0.19.2"
|
||||
"version": "0.21.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playlet-app",
|
||||
"version": "0.19.2",
|
||||
"version": "0.21.2",
|
||||
"description": "Unofficial YouTube client for Roku",
|
||||
"scripts": {
|
||||
"prebuild": "rm -rf build/playlet-app",
|
||||
|
||||
@@ -23,7 +23,12 @@ end function
|
||||
function GetPlayletLibUrls() as object
|
||||
#if DEBUG
|
||||
debug = { type: "debug", link: Manifest.ReadValue("playlet_lib_debug_url") }
|
||||
return [debug]
|
||||
embedded = { type: "embedded", link: Manifest.ReadValue("playlet_lib_embedded_url") }
|
||||
#if DEBUG_FALLBACK_TO_EMBEDDED
|
||||
return [debug, embedded]
|
||||
#else
|
||||
return [debug]
|
||||
#end if
|
||||
#else
|
||||
savedUrls = Registry.GetPlayletLibUrlsFromRegistry()
|
||||
if savedUrls <> invalid
|
||||
|
||||
@@ -20,6 +20,11 @@ function GetLoadingMessage() as string
|
||||
"Don't forget to like and subscribe...",
|
||||
"Shoveling coal into the server...",
|
||||
"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
|
||||
index = GetRandom(0, messages.count() - 1)
|
||||
|
||||
@@ -2,7 +2,7 @@ title=Playlet
|
||||
|
||||
# Do not update version manually, it is auto updated from package.json
|
||||
major_version=0
|
||||
minor_version=19
|
||||
minor_version=21
|
||||
build_version=00002
|
||||
|
||||
ui_resolutions=hd
|
||||
@@ -33,4 +33,4 @@ playlet_lib_debug_url=http://DEBUG_HOST_IP_ADDRESS:8086/playlet-lib.zip
|
||||
|
||||
git_commit_sha=unknown
|
||||
|
||||
bs_const=DEBUG=false
|
||||
bs_const=DEBUG=false;DEBUG_FALLBACK_TO_EMBEDDED=true
|
||||
@@ -22,6 +22,7 @@ function Main(args as object) as void
|
||||
Logger.Init()
|
||||
|
||||
Registry.ClearPlayletLibUrlsIfNeeded(args)
|
||||
Registry.ClearRegistryIfNeeded(args)
|
||||
|
||||
scene = screen.CreateScene("BootstrapScene")
|
||||
screen.show()
|
||||
@@ -33,9 +34,9 @@ function Main(args as object) as void
|
||||
' These vars are needed to pass certification.
|
||||
' The actual work is done in Playlet Lib
|
||||
' bs:disable-next-line LINT1005
|
||||
contentId = args.contentId
|
||||
_contentId = args.contentId
|
||||
' bs:disable-next-line LINT1005
|
||||
mediaType = args.mediaType
|
||||
_mediaType = args.mediaType
|
||||
|
||||
' Do not signal app launch complete here, we're doing it over at Playlet Lib
|
||||
' This is needed to pass cetification
|
||||
|
||||
@@ -14,6 +14,15 @@ namespace Registry
|
||||
sec.Flush()
|
||||
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
|
||||
urlsJson = ReadKey("playlet_lib_urls", "Playlet")
|
||||
if urlsJson = invalid
|
||||
@@ -31,4 +40,12 @@ namespace Registry
|
||||
Logger.Log("Cleared key playlet_lib_urls from registry")
|
||||
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
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "playlet-lib",
|
||||
"version": "0.19.2",
|
||||
"version": "0.21.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playlet-lib",
|
||||
"version": "0.19.2"
|
||||
"version": "0.21.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playlet-lib",
|
||||
"version": "0.19.2",
|
||||
"version": "0.21.2",
|
||||
"description": "Unofficial YouTube client for Roku",
|
||||
"scripts": {
|
||||
"prebuild": "rm -rf build/playlet-lib",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Navigation/LongPress.bs"
|
||||
import "pkg:/components/PlayQueue/PlayQueueViewUtils.bs"
|
||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
||||
import "pkg:/components/VideoQueue/VideoQueueUtils.bs"
|
||||
import "pkg:/components/VideoQueue/VideoQueueViewUtils.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
@@ -86,13 +86,13 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
||||
end if
|
||||
|
||||
if key = OPTIONS_LONG_PRESS_KEY and press
|
||||
LogInfo("Opening PlayQueueView")
|
||||
PlayQueueViewUtils.Open(m.top.playQueue, m.top)
|
||||
LogInfo("Opening VideoQueueView")
|
||||
VideoQueueViewUtils.Open(m.top.videoQueue, m.top)
|
||||
return true
|
||||
end if
|
||||
|
||||
if key = "options" and not press
|
||||
if VideoUtils.ToggleVideoPictureInPicture()
|
||||
if VideoQueueUtils.ToggleVideoPictureInPicture(m.top.videoQueue)
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
@@ -102,26 +102,26 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
||||
end if
|
||||
|
||||
if key = "play"
|
||||
if VideoUtils.TogglePause()
|
||||
if VideoQueueUtils.TogglePause(m.top.videoQueue)
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
if key = "pause"
|
||||
if VideoUtils.PauseVideo()
|
||||
if VideoQueueUtils.Pause(m.top.videoQueue)
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
if key = "playonly"
|
||||
if VideoUtils.ResumeVideo()
|
||||
if VideoQueueUtils.Play(m.top.videoQueue)
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
if key = "back"
|
||||
if VideoUtils.IsVideoPlayerOpen() and not VideoUtils.IsVideoPlayerFullScreen()
|
||||
if VideoUtils.ToggleVideoPictureInPicture()
|
||||
if VideoQueueUtils.IsVideoPlayerOpen(m.top.videoQueue) and not VideoQueueUtils.IsVideoPlayerFullScreen(m.top.videoQueue)
|
||||
if VideoQueueUtils.ToggleVideoPictureInPicture(m.top.videoQueue)
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<interface>
|
||||
<field id="root" type="node" />
|
||||
<field id="stack" type="node" />
|
||||
<field id="playQueue" type="node" />
|
||||
<field id="videoQueue" type="node" />
|
||||
<function name="PushScreen" />
|
||||
<function name="PopScreen" />
|
||||
<function name="FocusTopScreen" />
|
||||
|
||||
@@ -16,6 +16,7 @@ function Init()
|
||||
m.banner = m.top.findNode("banner")
|
||||
m.thumbnail = m.top.findNode("thumbnail")
|
||||
m.authorLabel = m.top.findNode("authorLabel")
|
||||
m.subCountLabel = m.top.findNode("subCountLabel")
|
||||
m.subscribeButton = m.top.findNode("subscribeButton")
|
||||
m.rowList = m.top.FindNode("rowList")
|
||||
m.rowList.focusable = true
|
||||
@@ -60,6 +61,7 @@ function OnContentSet() as void
|
||||
|
||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||
m.authorLabel.text = content._author
|
||||
m.subCountLabel.text = content.subCountText
|
||||
m.banner.uri = content.banner
|
||||
if StringUtils.IsNullOrEmpty(content.thumbnail)
|
||||
m.thumbnail.uri = ""
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
id="authorLabel"
|
||||
translation="[115,40]"
|
||||
font="font:MediumBoldSystemFont" />
|
||||
<Label
|
||||
id="subCountLabel"
|
||||
translation="[115,70]"
|
||||
font="font:SmallestSystemFont" />
|
||||
</Poster>
|
||||
|
||||
<Button
|
||||
@@ -61,7 +65,7 @@
|
||||
showRowLabel="[true]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
variableWidthItems="true"
|
||||
focusBitmapUri="pkg:/images/focus_grid.9.png" />
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" />
|
||||
|
||||
<Animation
|
||||
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>
|
||||
@@ -5,9 +5,6 @@ import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/source/utils/ErrorUtils.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
|
||||
function Init()
|
||||
end function
|
||||
|
||||
function LoadChannel(invidiousNode as object) as void
|
||||
if m.contentTask <> invalid
|
||||
m.contentTask.cancel = true
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/VideoFeed/FeedLoadState.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"
|
||||
|
||||
function LoadPlaylistPage(invidiousNode as object) as void
|
||||
LoadPlaylist(invidiousNode, true)
|
||||
end function
|
||||
|
||||
function LoadPlaylistAll(invidiousNode as object) as void
|
||||
LoadPlaylist(invidiousNode, false)
|
||||
end function
|
||||
|
||||
function LoadPlaylist(invidiousNode as object, singlePage as boolean) as void
|
||||
if m.contentTask <> invalid
|
||||
m.contentTask.cancel = true
|
||||
end if
|
||||
|
||||
loadState = m.top.loadState
|
||||
if loadState = FeedLoadState.Loading or loadState = FeedLoadState.Loaded
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.loadState = FeedLoadState.Loading
|
||||
m.contentTask = AsyncTask.Start(Tasks.PlaylistContentTask, {
|
||||
content: m.top
|
||||
invidious: invidiousNode
|
||||
singlePage: singlePage
|
||||
}, OnPlaylistContentTaskResult)
|
||||
end function
|
||||
|
||||
function OnPlaylistContentTaskResult(output as object) as void
|
||||
m.contentTask = 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)
|
||||
playlistId = output.task.input.content.playlistId
|
||||
message = `Failed to load playlist ${playlistId}\n${error}`
|
||||
DialogUtils.ShowDialog(message, "Playlist load fail", true)
|
||||
return
|
||||
end if
|
||||
end function
|
||||
@@ -1,5 +1,8 @@
|
||||
<component name="PlaylistContentNode" extends="ContentNode">
|
||||
<interface>
|
||||
<function name="LoadPlaylistPage" />
|
||||
<function name="LoadPlaylistAll" />
|
||||
|
||||
<field id="type" type="string" value="playlist" />
|
||||
<field id="loadState" type="string" />
|
||||
<!-- index in a feed -->
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
||||
|
||||
@asynctask
|
||||
function PlaylistContentTask(input as object) as object
|
||||
contentNode = input.content
|
||||
invidiousNode = input.invidious
|
||||
singlePage = input.singlePage
|
||||
|
||||
if m.top.cancel
|
||||
contentNode.loadState = FeedLoadState.None
|
||||
return invalid
|
||||
end if
|
||||
|
||||
service = new Invidious.InvidiousService(invidiousNode)
|
||||
instance = service.GetInstance()
|
||||
|
||||
while true
|
||||
index = contentNode.getChildCount()
|
||||
response = service.GetPlaylist(contentNode.playlistId, index, m.top.cancellation)
|
||||
|
||||
if m.top.cancel
|
||||
contentNode.loadState = FeedLoadState.None
|
||||
return invalid
|
||||
end if
|
||||
|
||||
metadata = response.Json()
|
||||
|
||||
if not response.IsSuccess() or metadata = invalid
|
||||
contentNode.loadState = FeedLoadState.Error
|
||||
return {
|
||||
success: false
|
||||
error: response.ErrorMessage()
|
||||
}
|
||||
end if
|
||||
|
||||
InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance)
|
||||
childCount = contentNode.getChildCount()
|
||||
|
||||
if metadata.videos.Count() = 0 or childCount >= metadata.videoCount
|
||||
contentNode.loadState = FeedLoadState.Loaded
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
else
|
||||
contentNode.loadState = FeedLoadState.LoadedPage
|
||||
if singlePage
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
end if
|
||||
end if
|
||||
end while
|
||||
|
||||
return invalid
|
||||
end function
|
||||
@@ -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>
|
||||
@@ -5,8 +5,11 @@
|
||||
<field id="index" type="integer" value="-1" />
|
||||
<!-- index in a feed -->
|
||||
<field id="feedSourcesIndex" type="integer" value="-1" />
|
||||
<!-- index in the queue -->
|
||||
<field id="queueIndex" type="integer" value="-1" />
|
||||
|
||||
<field id="author" type="string" />
|
||||
<!-- NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation -->
|
||||
<field id="_author" type="string" />
|
||||
<field id="authorId" type="string" />
|
||||
<field id="isUpcoming" type="boolean" />
|
||||
<field id="lengthSeconds" type="integer" />
|
||||
|
||||
@@ -71,8 +71,6 @@ import "pkg:/source/utils/Types.bs"
|
||||
' - "Remove group from Bookmarks"
|
||||
' - "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:
|
||||
' In a Channel view, while selecting a playlist:
|
||||
' - Channel
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace ContextMenuUtils
|
||||
if item.type = "video"
|
||||
LogInfo("Opening context menu for video:", item.videoId)
|
||||
title = item.title
|
||||
subtitle = item.author
|
||||
subtitle = item._author
|
||||
thumbnail = item.thumbnail
|
||||
else if item.type = "playlist"
|
||||
LogInfo("Opening context menu for playlist:", item.playlistId)
|
||||
|
||||
@@ -22,4 +22,31 @@ namespace DialogUtils
|
||||
m.top.getScene().dialog = dialog
|
||||
return dialog
|
||||
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
|
||||
@@ -1,6 +1,4 @@
|
||||
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/Types.bs"
|
||||
|
||||
@@ -33,14 +31,10 @@ function OnUrlSet()
|
||||
url = m.top.url
|
||||
|
||||
m.urlLabel.text = url
|
||||
AsyncTask.Start(Tasks.GenerateQrCodeTask, {
|
||||
poster: m.qrCode
|
||||
text: url
|
||||
size: m.qrCode.loadWidth
|
||||
padding: 10
|
||||
})
|
||||
m.qrCode.text = url
|
||||
end function
|
||||
|
||||
function OnAuthTokenChange()
|
||||
m.invidious.unobserveFieldScoped("authToken")
|
||||
Close()
|
||||
end function
|
||||
@@ -25,12 +25,13 @@
|
||||
wrap="true" width="400">
|
||||
<Font role="font" uri="font:SystemFontFile" size="24" />
|
||||
</Label>
|
||||
<Poster
|
||||
<QrCodePoster
|
||||
id="QrCodePoster"
|
||||
width="300"
|
||||
height="300"
|
||||
loadWidth="300"
|
||||
loadHeight="300"
|
||||
padding="10"
|
||||
translation="[50, 50]" />
|
||||
<Label
|
||||
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>
|
||||
@@ -1,10 +1,9 @@
|
||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function InitEcpArgs()
|
||||
m.playQueue = m.top.findNode("PlayQueue")
|
||||
m.videoQueue = m.top.findNode("VideoQueue")
|
||||
LaunchArgumentsReceived()
|
||||
|
||||
m.scene.ObserveField("inputArgs", FuncName(InputArgumentsReceived))
|
||||
@@ -30,10 +29,8 @@ function ProcessArguments(args as object) as void
|
||||
return
|
||||
end if
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(args.contentId) and args.mediaType = "video"
|
||||
if StringUtils.IsNullOrEmpty(args.videoId)
|
||||
args.videoId = args.contentId
|
||||
end if
|
||||
if not StringUtils.IsNullOrEmpty(args.contentId) and StringUtils.IsNullOrEmpty(args.videoId)
|
||||
args.videoId = args.contentId
|
||||
end if
|
||||
|
||||
if args.timestamp <> invalid
|
||||
@@ -46,6 +43,6 @@ function ProcessArguments(args as object) as void
|
||||
if args.timestamp <> invalid
|
||||
node.timestamp = args.timestamp
|
||||
end if
|
||||
m.playQueue@.Play(node, -1)
|
||||
m.videoQueue.playVideo = node
|
||||
end if
|
||||
end function
|
||||
@@ -21,6 +21,12 @@ function MainSceneContainerChanged()
|
||||
end function
|
||||
|
||||
function StartWebServer()
|
||||
m.loungeService = m.top.findNode("LoungeService")
|
||||
m.loungeService@.StartService()
|
||||
|
||||
m.webServer = m.top.findNode("WebServer")
|
||||
m.webServer@.StartServer()
|
||||
|
||||
m.dialServer = m.top.findNode("DialServer")
|
||||
m.dialServer@.StartServer()
|
||||
end function
|
||||
@@ -22,7 +22,11 @@ function MainSceneContainerChanged()
|
||||
end function
|
||||
|
||||
function StartWebServer()
|
||||
m.loungeService = m.top.findNode("LoungeService")
|
||||
m.loungeService.callfunc("StartService", invalid)
|
||||
m.webServer = m.top.findNode("WebServer")
|
||||
m.webServer.callfunc("StartServer", invalid)
|
||||
m.dialServer = m.top.findNode("DialServer")
|
||||
m.dialServer.callfunc("StartServer", invalid)
|
||||
end function
|
||||
'//# sourceMappingURL=./MainScene.brs.map
|
||||
@@ -16,22 +16,20 @@
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/Types.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/StringUtils.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/Logging.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/VideoPlayer/VideoUtils.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/FocusManagement.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/Dialog/DialogUtils.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
||||
<children>
|
||||
<Logger id="Logger" />
|
||||
<AppController id="AppController">
|
||||
<Group id="Stack">
|
||||
<AppRoot id="AppRoot">
|
||||
<NavBar id="NavBar" focusIndex="1">
|
||||
<NavBar id="NavBar" focusIndex="2">
|
||||
<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="HomeScreen" text="Home" icon="pkg:/images/icons/home.png" />
|
||||
<NavBarItem screen="BookmarksScreen" text="Bookmarks" icon="pkg:/images/icons/star.png" />
|
||||
<NavBarItem screen="SettingsScreen" text="Settings" icon="pkg:/images/icons/settings.png" />
|
||||
<NavBarItem screen="WebAppScreen" text="Web App" icon="pkg:/images/icons/phone.png" />
|
||||
<NavBarItem screen="RemoteScreen" text="Remote" icon="pkg:/images/icons/phone.png" />
|
||||
<NavBarItem screen="AppInfoScreen" text="Info" icon="pkg:/images/icons/info.png" />
|
||||
</ContentNode>
|
||||
</NavBar>
|
||||
@@ -39,13 +37,16 @@
|
||||
</Group>
|
||||
<VideoContainer id="VideoContainer" />
|
||||
<Group id="Notifications" />
|
||||
<PlayQueue id="PlayQueue" />
|
||||
<VideoQueue id="VideoQueue" />
|
||||
<ApplicationInfo id="ApplicationInfo" />
|
||||
<Preferences id="Preferences" />
|
||||
<Bookmarks id="Bookmarks" />
|
||||
<SearchHistory id="SearchHistory" />
|
||||
<Profiles id="Profiles" />
|
||||
<Invidious id="Invidious" />
|
||||
<PlayletWebServer id="WebServer" port="8888" />
|
||||
<DialServer id="DialServer" />
|
||||
<LoungeService id="LoungeService" />
|
||||
</AppController>
|
||||
</children>
|
||||
</component>
|
||||
|
||||
@@ -5,11 +5,18 @@
|
||||
<AppController id="AppController"
|
||||
root="bind:./AppRoot"
|
||||
stack="bind:./Stack"
|
||||
playQueue="bind:./PlayQueue">
|
||||
videoQueue="bind:./VideoQueue">
|
||||
<Group id="Stack">
|
||||
<AppRoot id="AppRoot">
|
||||
<NavBar id="NavBar" focusIndex="1" appController="bind:/AppController">
|
||||
<NavBar id="NavBar" focusIndex="2" appController="bind:/AppController">
|
||||
<ContentNode role="items">
|
||||
<NavBarItem
|
||||
screen="ProfileScreen"
|
||||
text="Profile"
|
||||
icon="pkg:/images/icons/user.png"
|
||||
padding="10"
|
||||
componentName="ProfileIconButton">
|
||||
</NavBarItem>
|
||||
<NavBarItem
|
||||
screen="SearchScreen"
|
||||
text="Search"
|
||||
@@ -31,8 +38,8 @@
|
||||
icon="pkg:/images/icons/settings.png">
|
||||
</NavBarItem>
|
||||
<NavBarItem
|
||||
screen="WebAppScreen"
|
||||
text="Web App"
|
||||
screen="RemoteScreen"
|
||||
text="Remote"
|
||||
icon="pkg:/images/icons/phone.png">
|
||||
</NavBarItem>
|
||||
<NavBarItem
|
||||
@@ -49,30 +56,47 @@
|
||||
<Group id="Notifications" />
|
||||
|
||||
<!-- No render nodes -->
|
||||
<PlayQueue id="PlayQueue"
|
||||
<VideoQueue id="VideoQueue"
|
||||
appController="bind:/AppController"
|
||||
videoContainer="bind:../VideoContainer"
|
||||
invidious="bind:../Invidious"
|
||||
notifications="bind:../Notifications"
|
||||
preferences="bind:../Preferences" />
|
||||
preferences="bind:../Preferences"
|
||||
loungeService="bind:../LoungeService" />
|
||||
|
||||
<ApplicationInfo id="ApplicationInfo" />
|
||||
<Preferences id="Preferences" />
|
||||
<Bookmarks id="Bookmarks" />
|
||||
<SearchHistory id="SearchHistory"
|
||||
preferences="bind:../Preferences" />
|
||||
|
||||
<Profiles id="Profiles"
|
||||
invidious="bind:../Invidious" />
|
||||
|
||||
<Invidious id="Invidious"
|
||||
webServer="bind:../WebServer"
|
||||
applicationInfo="bind:../ApplicationInfo"
|
||||
preferences="bind:../Preferences" />
|
||||
preferences="bind:../Preferences"
|
||||
profiles="bind:../Profiles" />
|
||||
|
||||
<PlayletWebServer
|
||||
id="WebServer"
|
||||
<!-- Tasks -->
|
||||
<PlayletWebServer id="WebServer"
|
||||
port="8888"
|
||||
appController="bind:/AppController"
|
||||
applicationInfo="bind:../ApplicationInfo"
|
||||
invidious="bind:../Invidious"
|
||||
profiles="bind:../Profiles"
|
||||
preferences="bind:../Preferences"
|
||||
playQueue="bind:../PlayQueue"
|
||||
bookmarks="bind:../Bookmarks" />
|
||||
videoQueue="bind:../VideoQueue"
|
||||
bookmarks="bind:../Bookmarks"
|
||||
loungeService="bind:../LoungeService" />
|
||||
<DialServer id="DialServer"
|
||||
webServer="bind:../WebServer"
|
||||
loungeService="bind:../LoungeService" />
|
||||
<LoungeService id="LoungeService"
|
||||
videoQueue="bind:../VideoQueue"
|
||||
notifications="bind:../Notifications"
|
||||
invidious="bind:../Invidious" />
|
||||
</AppController>
|
||||
</children>
|
||||
</component>
|
||||
@@ -8,31 +8,49 @@ function InitializeBindings()
|
||||
"AppController": {
|
||||
"root": "./AppRoot",
|
||||
"stack": "./Stack",
|
||||
"playQueue": "./PlayQueue"
|
||||
"videoQueue": "./VideoQueue"
|
||||
},
|
||||
"NavBar": {
|
||||
"appController": "/AppController"
|
||||
},
|
||||
"PlayQueue": {
|
||||
"VideoQueue": {
|
||||
"appController": "/AppController",
|
||||
"videoContainer": "../VideoContainer",
|
||||
"invidious": "../Invidious",
|
||||
"notifications": "../Notifications",
|
||||
"preferences": "../Preferences"
|
||||
"preferences": "../Preferences",
|
||||
"loungeService": "../LoungeService"
|
||||
},
|
||||
"SearchHistory": {
|
||||
"preferences": "../Preferences"
|
||||
},
|
||||
"Profiles": {
|
||||
"invidious": "../Invidious"
|
||||
},
|
||||
"Invidious": {
|
||||
"webServer": "../WebServer",
|
||||
"applicationInfo": "../ApplicationInfo",
|
||||
"preferences": "../Preferences"
|
||||
"preferences": "../Preferences",
|
||||
"profiles": "../Profiles"
|
||||
},
|
||||
"WebServer": {
|
||||
"appController": "/AppController",
|
||||
"applicationInfo": "../ApplicationInfo",
|
||||
"invidious": "../Invidious",
|
||||
"profiles": "../Profiles",
|
||||
"preferences": "../Preferences",
|
||||
"playQueue": "../PlayQueue",
|
||||
"bookmarks": "../Bookmarks"
|
||||
"videoQueue": "../VideoQueue",
|
||||
"bookmarks": "../Bookmarks",
|
||||
"loungeService": "../LoungeService"
|
||||
},
|
||||
"DialServer": {
|
||||
"webServer": "../WebServer",
|
||||
"loungeService": "../LoungeService"
|
||||
},
|
||||
"LoungeService": {
|
||||
"videoQueue": "../VideoQueue",
|
||||
"notifications": "../Notifications",
|
||||
"invidious": "../Invidious"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import "pkg:/source/utils/MathUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
' Based on https://github.com/jellyfin/jellyfin-roku/blob/unstable/components/IconButton.brs
|
||||
function init()
|
||||
function Init()
|
||||
m.buttonBackground = m.top.findNode("buttonBackground")
|
||||
m.buttonIcon = m.top.findNode("buttonIcon")
|
||||
m.buttonText = m.top.findNode("buttonText")
|
||||
@@ -40,17 +41,12 @@ function setIconSize()
|
||||
height = m.top.height
|
||||
width = m.top.width
|
||||
if height > 0 and width > 0
|
||||
' TODO: Use smallest number between them
|
||||
m.buttonIcon.height = m.top.height
|
||||
iconSize = MathUtils.Min(height, width) - m.top.padding
|
||||
m.buttonIcon.height = iconSize
|
||||
m.buttonIcon.width = iconSize
|
||||
|
||||
if m.top.padding > 0
|
||||
m.buttonIcon.height = m.buttonIcon.height - m.top.padding
|
||||
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.buttonIcon.translation = [((width - iconSize) / 2), ((height - iconSize) / 2)]
|
||||
m.buttonText.translation = [-5, height + 2]
|
||||
m.buttonText.width = width + 10
|
||||
end if
|
||||
end function
|
||||
|
||||
@@ -29,15 +29,15 @@ function PopulateButtons() as void
|
||||
|
||||
buttons = []
|
||||
for each item in navBarItems
|
||||
button = CreateObject("roSGNode", "IconButton")
|
||||
button = CreateObject("roSGNode", item.componentName)
|
||||
button.background = "#242424FF"
|
||||
button.focusBackground = "#FF1C30FF"
|
||||
button.padding = 20
|
||||
button.height = 50
|
||||
button.width = 90
|
||||
|
||||
button.icon = item.icon
|
||||
button.text = item.text
|
||||
button.padding = item.padding
|
||||
|
||||
buttons.push(button)
|
||||
end for
|
||||
|
||||
@@ -3,5 +3,7 @@
|
||||
<field id="screen" type="string" />
|
||||
<field id="icon" type="string" />
|
||||
<field id="text" type="string" />
|
||||
<field id="padding" type="integer" value="20" />
|
||||
<field id="componentName" type="string" value="IconButton" />
|
||||
</interface>
|
||||
</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,5 +0,0 @@
|
||||
<component name="ContentNodeReference" extends="ContentNode">
|
||||
<interface>
|
||||
<field id="refNode" type="node" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -1,41 +0,0 @@
|
||||
' NodeByRef: these functions provides the ability to "wrap" a node in
|
||||
' another node, so it can be passed by reference. This is useful for
|
||||
' when a node is required to be a child of multiple nodes at once,
|
||||
' which is not possible.
|
||||
' Instead, the node is wrapped, passed around, and unwrapped when needed.
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
namespace NodeByRef
|
||||
|
||||
function Wrap(node as object) as object
|
||||
if node = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if node.refNode <> invalid
|
||||
return node
|
||||
end if
|
||||
|
||||
ref = CreateObject("roSGNode", "ContentNodeReference")
|
||||
ref.refNode = node
|
||||
if not StringUtils.IsNullOrEmpty(node.id)
|
||||
ref.id = node.id + "-ref"
|
||||
end if
|
||||
return ref
|
||||
end function
|
||||
|
||||
function Unwrap(node as object) as object
|
||||
if node = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
loopGuard = 0
|
||||
while node.refNode <> invalid and loopGuard < 10
|
||||
node = node.refNode
|
||||
loopGuard += 1
|
||||
end while
|
||||
|
||||
return node
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -1,241 +0,0 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/NodeByRef/NodeByRef.bs"
|
||||
import "pkg:/components/PlayQueue/Notifications/PlayQueueNotificationUtils.bs"
|
||||
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/source/utils/ArrayUtils.bs"
|
||||
import "pkg:/source/utils/ErrorUtils.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/RingBuffer.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
' TODO:P1 prevent adding duplicates of the same video/playlist
|
||||
function Init()
|
||||
m.pendingLoadTasks = {}
|
||||
m.content = m.top.findNode("Content")
|
||||
m.top.content = m.content
|
||||
m.content.addField("index", "integer", false)
|
||||
m.content.index = m.top.index
|
||||
' TODO:P2 use actual queue nodes instead of internal buffer
|
||||
m.watchedVideos = new RingBuffer(100)
|
||||
end function
|
||||
|
||||
function Play(node as object, playlistIndex as integer)
|
||||
m.top.index += 1
|
||||
m.top.playlistIndex = playlistIndex
|
||||
|
||||
node = WrapWithIndexField(node)
|
||||
if m.top.index >= m.content.getChildCount()
|
||||
m.content.appendChild(node)
|
||||
m.top.index = m.content.getChildCount() - 1
|
||||
else
|
||||
m.content.insertChild(node, m.top.index)
|
||||
end if
|
||||
|
||||
PlayItemAtCurrentIndex()
|
||||
end function
|
||||
|
||||
function AddToQueue(node as object)
|
||||
node = WrapWithIndexField(node)
|
||||
m.content.appendChild(node)
|
||||
queueNotifications = m.top.preferences["misc.queue_notifications"]
|
||||
if queueNotifications
|
||||
hintVisible = VideoUtils.GetVideoPlayer() = invalid or not VideoUtils.IsVideoPlayerFullScreen()
|
||||
PlayQueue.ShowNotifcation(m.top.notifications, node, hintVisible)
|
||||
end if
|
||||
end function
|
||||
|
||||
function WrapWithIndexField(node as object) as object
|
||||
node = NodeByRef.Wrap(node)
|
||||
if not node.hasField("index")
|
||||
node.addField("index", "integer", false)
|
||||
end if
|
||||
node.index = m.top.index
|
||||
return node
|
||||
end function
|
||||
|
||||
' TODO:P0 better model of the queue (Now playing, etc)
|
||||
function GetQueue(_unused as dynamic) as object
|
||||
queueNodes = m.content.getChildren(-1, 0)
|
||||
items = []
|
||||
for each node in queueNodes
|
||||
node = NodeByRef.Unwrap(node)
|
||||
if node = invalid
|
||||
continue for
|
||||
end if
|
||||
|
||||
nodeType = node.type
|
||||
if nodeType = "video"
|
||||
items.push({
|
||||
type: nodeType
|
||||
videoId: node.videoId
|
||||
title: node.title
|
||||
author: node.author
|
||||
thumbnail: node.thumbnail
|
||||
})
|
||||
else if node.type = "playlist"
|
||||
items.push({
|
||||
type: nodeType
|
||||
playlistId: node.playlistId
|
||||
title: node.title
|
||||
thumbnail: node.thumbnail
|
||||
videoCountText: node.videoCountText
|
||||
})
|
||||
end if
|
||||
end for
|
||||
|
||||
return {
|
||||
index: m.top.index
|
||||
playlistIndex: m.top.playlistIndex
|
||||
items: items
|
||||
}
|
||||
end function
|
||||
|
||||
function Clear(_unused as dynamic)
|
||||
m.content.removeChildrenIndex(m.content.getChildCount(), 0)
|
||||
m.top.index = -1
|
||||
m.top.playlistIndex = -1
|
||||
end function
|
||||
|
||||
function PlayNextItem(_unused as dynamic) as boolean
|
||||
childCount = m.content.getChildCount()
|
||||
if childCount = 0
|
||||
return false
|
||||
end if
|
||||
|
||||
index = m.top.index
|
||||
if index <> -1
|
||||
if index >= childCount
|
||||
return false
|
||||
end if
|
||||
node = m.content.getChild(index)
|
||||
node = NodeByRef.Unwrap(node)
|
||||
if node.type = "playlist"
|
||||
m.top.playlistIndex += 1
|
||||
if PlayPlaylistAtCurrentIndex(node)
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
m.top.index += 1
|
||||
m.top.playlistIndex = -1
|
||||
if m.top.index >= childCount
|
||||
return false
|
||||
end if
|
||||
|
||||
return PlayItemAtCurrentIndex()
|
||||
end function
|
||||
|
||||
function PlayItemAtIndex(index as integer) as boolean
|
||||
m.top.index = index
|
||||
m.top.playlistIndex = -1
|
||||
return PlayItemAtCurrentIndex()
|
||||
end function
|
||||
|
||||
function PlayItemAtCurrentIndex() as boolean
|
||||
node = m.content.getChild(m.top.index)
|
||||
node = NodeByRef.Unwrap(node)
|
||||
if node = invalid
|
||||
return false
|
||||
end if
|
||||
if node.type = "video"
|
||||
PlayVideo(node)
|
||||
return true
|
||||
else if node.type = "playlist"
|
||||
if m.top.playlistIndex = -1
|
||||
m.top.playlistIndex = 0
|
||||
end if
|
||||
return PlayPlaylistAtCurrentIndex(node)
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
function PlayPlaylistAtCurrentIndex(playlist as object) as boolean
|
||||
playlist = NodeByRef.Unwrap(playlist)
|
||||
if playlist.videoCount < 0
|
||||
LoadPlaylist(playlist)
|
||||
return true
|
||||
end if
|
||||
playlistIndex = m.top.playlistIndex
|
||||
if playlistIndex < 0 or playlistIndex >= playlist.videoCount
|
||||
return false
|
||||
end if
|
||||
|
||||
if playlistIndex < playlist.getChildCount()
|
||||
child = playlist.getChild(playlistIndex)
|
||||
PlayVideo(child)
|
||||
return true
|
||||
end if
|
||||
|
||||
LoadPlaylist(playlist)
|
||||
return true
|
||||
end function
|
||||
|
||||
function PlayVideo(node as object)
|
||||
videoId = node.videoId
|
||||
if not m.watchedVideos.Contains(videoId)
|
||||
m.watchedVideos.Push(videoId)
|
||||
end if
|
||||
VideoUtils.PlayVideo(node)
|
||||
end function
|
||||
|
||||
function LoadPlaylist(playlist as object) as void
|
||||
if playlist.loadState = FeedLoadState.Loading
|
||||
return
|
||||
end if
|
||||
|
||||
playlist.loadState = FeedLoadState.Loading
|
||||
|
||||
task = AsyncTask.Start(Tasks.PlaylistContentTask, {
|
||||
content: playlist
|
||||
invidious: m.top.invidious
|
||||
}, OnPlaylistContentTaskResult)
|
||||
m.pendingLoadTasks[task.id] = task
|
||||
end function
|
||||
|
||||
function OnPlaylistContentTaskResult(output as object) as void
|
||||
m.pendingLoadTasks.Delete(output.task.id)
|
||||
|
||||
if output.cancelled
|
||||
return
|
||||
end if
|
||||
|
||||
playlist = output.task.input.content
|
||||
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)
|
||||
playlistId = playlist.playlistId
|
||||
message = `Failed to load playlist ${playlistId}\n${error}`
|
||||
' TODO:P1 play next upon closing the dialog
|
||||
DialogUtils.ShowDialog(message, "Playlist load fail", true)
|
||||
return
|
||||
end if
|
||||
|
||||
PlayPlaylistAtCurrentIndex(playlist)
|
||||
end function
|
||||
|
||||
function OnIndexChange()
|
||||
index = m.top.index
|
||||
m.content.index = index
|
||||
children = m.top.content.getChildren(-1, 0)
|
||||
for each child in children
|
||||
child.index = index
|
||||
end for
|
||||
end function
|
||||
|
||||
function watchedVideosContain(videoId as string) as boolean
|
||||
return m.watchedVideos.Contains(videoId)
|
||||
end function
|
||||
|
||||
function watchedVideosClear(_unused as dynamic)
|
||||
m.watchedVideos = new RingBuffer(100)
|
||||
end function
|
||||
@@ -1,21 +0,0 @@
|
||||
<component name="PlayQueue" extends="Node">
|
||||
<interface>
|
||||
<field id="content" type="node" />
|
||||
<field id="index" type="integer" value="-1" onChange="OnIndexChange" />
|
||||
<field id="playlistIndex" type="integer" value="-1" />
|
||||
<field id="invidious" type="node" />
|
||||
<field id="notifications" type="node" />
|
||||
<field id="preferences" type="node" />
|
||||
<function name="Play" />
|
||||
<function name="AddToQueue" />
|
||||
<function name="GetQueue" />
|
||||
<function name="Clear" />
|
||||
<function name="PlayNextItem" />
|
||||
<function name="PlayItemAtIndex" />
|
||||
<function name="watchedVideosContain" />
|
||||
<function name="watchedVideosClear" />
|
||||
</interface>
|
||||
<children>
|
||||
<ContentNode id="Content" />
|
||||
</children>
|
||||
</component>
|
||||
@@ -1,83 +0,0 @@
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.queueList = m.top.findNode("queueList")
|
||||
m.queueLabel = m.top.findNode("queueLabel")
|
||||
m.clearButton = m.top.findNode("clearButton")
|
||||
m.showAnimation = m.top.findNode("showAnimation")
|
||||
|
||||
m.clearButton.ObserveField("buttonSelected", FuncName(OnClearButtonSelected))
|
||||
m.queueList.ObserveField("itemSelected", FuncName(OnItemSelected))
|
||||
|
||||
SetNavigation(m.queueList, "up", m.clearButton)
|
||||
SetNavigation(m.clearButton, "down", m.queueList)
|
||||
end function
|
||||
|
||||
function Show(unsued as dynamic)
|
||||
m.showAnimation.control = "start"
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
NodeSetFocus(m.queueList, true)
|
||||
end function
|
||||
|
||||
function OnContentSet() as void
|
||||
content = m.top.content
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
if not content.isSameNode(m.queueList.content)
|
||||
m.queueList.content = content
|
||||
end if
|
||||
|
||||
index = content.index
|
||||
if IsInt(index) and index <> -1
|
||||
m.queueLabel.text = `Queue (${index + 1}/${content.getChildCount()})`
|
||||
else
|
||||
m.queueLabel.text = `Queue (${content.getChildCount()})`
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
if NavigationKeyHandler(key, press).handled
|
||||
return true
|
||||
end if
|
||||
|
||||
if press = false
|
||||
return false
|
||||
end if
|
||||
|
||||
if key = "back"
|
||||
Close()
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
function Close()
|
||||
m.top.appController@.PopScreen()
|
||||
end function
|
||||
|
||||
function OnClearButtonSelected()
|
||||
m.top.playQueue@.Clear()
|
||||
end function
|
||||
|
||||
function OnItemSelected() as void
|
||||
content = m.queueList.content
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
index = m.queueList.itemSelected
|
||||
if index < 0 or index >= content.getChildCount()
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.playQueue@.PlayItemAtIndex(index)
|
||||
end function
|
||||
@@ -1,23 +0,0 @@
|
||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||
|
||||
namespace PlayQueueViewUtils
|
||||
|
||||
function Open(playQueue as object, appController as object) as object
|
||||
playQueueView = CreateObject("roSGNode", "PlayQueueView")
|
||||
playQueueView.appController = appController
|
||||
playQueueView.playQueue = playQueue
|
||||
appController@.PushScreen(playQueueView)
|
||||
|
||||
content = playQueue.content
|
||||
index = playQueue.index
|
||||
|
||||
playQueueView.content = content
|
||||
if index > -1 and index < content.GetChildCount()
|
||||
playQueueView.jumpToItem = index
|
||||
end if
|
||||
|
||||
playQueueView@.Show()
|
||||
return playQueueView
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -1,48 +0,0 @@
|
||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||
|
||||
' TODO:P1 this should only be called from PlaylistContentNode.bs
|
||||
@asynctask
|
||||
function PlaylistContentTask(input as object) as object
|
||||
contentNode = input.content
|
||||
invidiousNode = input.invidious
|
||||
|
||||
if m.top.cancel
|
||||
contentNode.loadState = FeedLoadState.None
|
||||
return invalid
|
||||
end if
|
||||
|
||||
service = new Invidious.InvidiousService(invidiousNode)
|
||||
|
||||
index = contentNode.getChildCount()
|
||||
response = service.GetPlaylist(contentNode.playlistId, index, m.top.cancellation)
|
||||
|
||||
if m.top.cancel
|
||||
contentNode.loadState = FeedLoadState.None
|
||||
return invalid
|
||||
end if
|
||||
|
||||
metadata = response.Json()
|
||||
|
||||
if not response.IsSuccess() or metadata = invalid
|
||||
contentNode.loadState = FeedLoadState.Error
|
||||
return {
|
||||
success: false
|
||||
error: response.ErrorMessage()
|
||||
}
|
||||
end if
|
||||
|
||||
instance = service.GetInstance()
|
||||
InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance)
|
||||
|
||||
childCount = contentNode.getChildCount()
|
||||
if metadata.videos.Count() > 0 or childCount < metadata.videoCount
|
||||
contentNode.loadState = FeedLoadState.LoadedPage
|
||||
else
|
||||
contentNode.loadState = FeedLoadState.Loaded
|
||||
end if
|
||||
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
end function
|
||||
@@ -1,10 +1,8 @@
|
||||
import "pkg:/components/ChannelView/ChannelUtils.bs"
|
||||
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Navigation/LongPress.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/source/utils/ErrorUtils.bs"
|
||||
@@ -117,7 +115,10 @@ function OnItemSelected(index as integer) as void
|
||||
videoId = video.videoId
|
||||
if not StringUtils.IsNullOrEmpty(videoId)
|
||||
LogInfo("Play playlist:", playlistId, "video:", videoId)
|
||||
m.playQueue@.Play(playlist, index)
|
||||
m.videoQueue.playPlaylist = {
|
||||
playlistNode: playlist
|
||||
playlistIndex: index
|
||||
}
|
||||
end if
|
||||
end function
|
||||
|
||||
@@ -141,9 +142,6 @@ function OnItemLongPressed(index as integer) as void
|
||||
|
||||
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]
|
||||
ContextMenuUtils.Open(contextMenuProviders, m.appController, video)
|
||||
end function
|
||||
@@ -165,14 +163,26 @@ function GetContextMenuOptionsForItem(video as object) as object
|
||||
end if
|
||||
|
||||
options = [
|
||||
ContextMenuUtils.CreateOption("Play", m.playQueue, "Play", [playlist, index]),
|
||||
ContextMenuUtils.CreateOption("Queue", m.playQueue, "AddToQueue", [playlist])
|
||||
ContextMenuUtils.CreateOption("Play video", m.playQueue, "Play", [video, -1]),
|
||||
ContextMenuUtils.CreateOption("Queue video", m.playQueue, "AddToQueue", [video]),
|
||||
ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayPlaylist", [playlist, index]),
|
||||
ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueuePlaylist", [playlist])
|
||||
ContextMenuUtils.CreateOption("Play video", m.videoQueue, "FuncPlayVideo", [video]),
|
||||
ContextMenuUtils.CreateOption("Queue video", m.videoQueue, "FuncAddToQueueVideo", [video]),
|
||||
]
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(playlist.authorId)
|
||||
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [playlist]))
|
||||
playlistAuthorId = playlist.authorId
|
||||
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
|
||||
|
||||
options.append(m.bookmarks@.GetMenuForPlaylist(playlist))
|
||||
@@ -191,6 +201,16 @@ function OpenPlaylistChannel(playlist as object) as void
|
||||
ChannelUtils.Open(channel)
|
||||
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
|
||||
' We should make a request in this case, and let the cache handle freshness.
|
||||
function LoadPlaylistIfNeeded() as void
|
||||
@@ -214,42 +234,5 @@ function LoadPlaylistIfNeeded() as void
|
||||
return
|
||||
end if
|
||||
|
||||
LoadPlaylist()
|
||||
end function
|
||||
|
||||
function LoadPlaylist() as void
|
||||
if m.playlistLoadTask <> invalid
|
||||
m.playlistLoadTask.cancel = true
|
||||
end if
|
||||
|
||||
m.top.content.loadState = FeedLoadState.Loading
|
||||
m.playlistLoadTask = AsyncTask.Start(Tasks.PlaylistContentTask, {
|
||||
content: m.top.content
|
||||
invidious: m.top.invidious
|
||||
}, OnPlaylistContentTaskResult)
|
||||
end function
|
||||
|
||||
function OnPlaylistContentTaskResult(output as object) as void
|
||||
m.playlistLoadTask = 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)
|
||||
playlistId = output.task.input.content.playlistId
|
||||
message = `Failed to load playlist ${playlistId}\n${error}`
|
||||
DialogUtils.ShowDialog(message, "Playlist load fail", true)
|
||||
return
|
||||
end if
|
||||
|
||||
LoadPlaylistIfNeeded()
|
||||
m.top.content@.LoadPlaylistPage(m.top.invidious)
|
||||
end function
|
||||
@@ -3,9 +3,10 @@
|
||||
<field id="content" type="node" onChange="OnContentSet" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
<field id="invidious" type="node" bind="/Invidious" />
|
||||
<field id="playQueue" type="node" bind="/PlayQueue" />
|
||||
<field id="videoQueue" type="node" bind="/VideoQueue" />
|
||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
||||
<function name="OpenPlaylistChannel" />
|
||||
<function name="OpenVideoChannel" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
@@ -56,8 +57,8 @@
|
||||
numColumns="1"
|
||||
numRows="5"
|
||||
vertFocusAnimationStyle="floatingFocus"
|
||||
translation="[620,90]" />
|
||||
|
||||
translation="[620,90]"
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-27.9.png" />
|
||||
</Poster>
|
||||
</children>
|
||||
</component>
|
||||
@@ -14,7 +14,8 @@ function OnContentSet() as void
|
||||
end if
|
||||
|
||||
m.top.title = content.title
|
||||
m.top.author = content.author
|
||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||
m.top.author = content._author
|
||||
m.top.thumbnailUri = content.thumbnail
|
||||
|
||||
if ValidInt(content.lengthSeconds) <> 0
|
||||
|
||||
@@ -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
|
||||
+7
-1
@@ -2,7 +2,7 @@ import "pkg:/source/QrCode/QrImage.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
@asynctask
|
||||
function GenerateQrCodeTask(input as object)
|
||||
function GenerateQrCodeTask(input as object) as object
|
||||
poster = input.poster
|
||||
mode = input.mode
|
||||
text = input.text
|
||||
@@ -24,7 +24,13 @@ function GenerateQrCodeTask(input as object)
|
||||
qr = new QrCode.QRImage()
|
||||
imagePath = qr.Generate(text, size, padding, mode)
|
||||
|
||||
if m.top.cancel
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(imagePath)
|
||||
poster.uri = imagePath
|
||||
end if
|
||||
|
||||
return invalid
|
||||
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]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
variableWidthItems="true"
|
||||
focusBitmapUri="pkg:/images/focus_grid.9.png"
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png"
|
||||
/>
|
||||
</Group>
|
||||
</children>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
showRowLabel="[true]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
variableWidthItems="true"
|
||||
focusBitmapUri="pkg:/images/focus_grid.9.png"
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png"
|
||||
/>
|
||||
</children>
|
||||
</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
|
||||
+106
@@ -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>
|
||||
@@ -0,0 +1,192 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/source/utils/ErrorUtils.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
function Init()
|
||||
m.webAppButton = m.top.findNode("WebAppButton")
|
||||
m.linkWithWifiButton = m.top.findNode("LinkWithWiFiButton")
|
||||
m.linkWithTvButton = m.top.findNode("LinkWithTvButton")
|
||||
|
||||
m.webAppPanel = m.top.findNode("WebAppPanel")
|
||||
m.linkWithWifiPanel = m.top.findNode("LinkWithWiFiPanel")
|
||||
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.wifiInstructionWithDeviceNameLabel = m.top.findNode("WifiInstructionWithDeviceNameLabel")
|
||||
m.linkCodeLabel = m.top.findNode("LinkCodeLabel")
|
||||
end function
|
||||
|
||||
function OnNodeReady()
|
||||
SetNavigation(m.webAppButton, "down", m.linkWithWifiButton)
|
||||
SetNavigation(m.linkWithWifiButton, "down", m.linkWithTvButton)
|
||||
SetNavigation(m.linkWithTvButton, "up", m.linkWithWifiButton)
|
||||
SetNavigation(m.linkWithWifiButton, "up", m.webAppButton)
|
||||
|
||||
SetNavigation(invalid, "back", m.navBar)
|
||||
SetNavigation(invalid, "left", m.navBar)
|
||||
|
||||
address = m.webserver@.GetServerAddress()
|
||||
isValidAddress = not StringUtils.IsNullOrEmpty(address)
|
||||
if isValidAddress
|
||||
m.top.url = address
|
||||
end if
|
||||
m.top.findNode("noInternet").visible = not isValidAddress
|
||||
m.top.findNode("yesInternet").visible = isValidAddress
|
||||
m.top.focusable = isValidAddress
|
||||
|
||||
m.top.observeField("visible", FuncName(OnVisibleChanged))
|
||||
|
||||
m.linkWithWifiPanel.observeField("visible", FuncName(OnLinkWithWifiPanelVisibleChanged))
|
||||
m.linkWithWifiPanel.visible = false
|
||||
m.linkWithTvPanel.observeField("visible", FuncName(OnLinkWithTvPanelVisibleChanged))
|
||||
m.linkWithTvPanel.visible = false
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
|
||||
if m.currentNavigtionNode = invalid
|
||||
m.currentNavigtionNode = m.webAppButton
|
||||
end if
|
||||
|
||||
NodeSetFocus(m.currentNavigtionNode, true)
|
||||
ShowTab(m.currentNavigtionNode)
|
||||
end function
|
||||
|
||||
function OnUrlSet()
|
||||
url = m.top.url
|
||||
|
||||
m.webAppUrlLabel.text = url
|
||||
m.webAppQrCodePoster.text = url
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
navigation = NavigationKeyHandler(key, press)
|
||||
if navigation.handled
|
||||
ShowTab(navigation.node)
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
function ShowTab(button as object)
|
||||
if button.isSameNode(m.webAppButton)
|
||||
m.webAppPanel.visible = true
|
||||
m.linkWithWifiPanel.visible = false
|
||||
m.linkWithTvPanel.visible = false
|
||||
m.currentNavigtionNode = button
|
||||
else if button.isSameNode(m.linkWithWifiButton)
|
||||
m.linkWithWifiPanel.visible = true
|
||||
m.webAppPanel.visible = false
|
||||
m.linkWithTvPanel.visible = false
|
||||
m.currentNavigtionNode = button
|
||||
else if button.isSameNode(m.linkWithTvButton)
|
||||
m.linkWithTvPanel.visible = true
|
||||
m.webAppPanel.visible = false
|
||||
m.linkWithWifiPanel.visible = false
|
||||
m.currentNavigtionNode = button
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnVisibleChanged()
|
||||
if not m.top.visible
|
||||
m.currentNavigtionNode = invalid
|
||||
m.webAppPanel.visible = true
|
||||
m.linkWithWifiPanel.visible = false
|
||||
m.linkWithTvPanel.visible = false
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnLinkWithWifiPanelVisibleChanged() as void
|
||||
if not m.linkWithWifiPanel.visible
|
||||
return
|
||||
end if
|
||||
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
connectionInfo = deviceInfo.GetConnectionInfo()
|
||||
|
||||
if connectionInfo.type = "WiFiConnection"
|
||||
m.wifiNameLabel.text = connectionInfo.ssid
|
||||
else if connectionInfo.type = "WiredConnection"
|
||||
m.wifiNameLabel.text = "Wired connection"
|
||||
else
|
||||
m.wifiNameLabel.text = "N/A"
|
||||
end if
|
||||
|
||||
m.wifiInstructionWithDeviceNameLabel.text = `Tap the cast icon and select "${m.loungeService.deviceName}"`
|
||||
end function
|
||||
|
||||
function OnLinkWithTvPanelVisibleChanged()
|
||||
if m.linkWithTvPanel.visible
|
||||
GeneratePairingCode()
|
||||
else
|
||||
if m.linkCodeTask <> invalid
|
||||
m.linkCodeTask.cancel = true
|
||||
m.linkCodeTask = invalid
|
||||
end if
|
||||
m.linkCodeLabel.text = ""
|
||||
end if
|
||||
end function
|
||||
|
||||
function GeneratePairingCode()
|
||||
if m.linkCodeTask <> invalid
|
||||
m.linkCodeTask.cancel = true
|
||||
end if
|
||||
|
||||
m.linkCodeLabel.text = "Loading..."
|
||||
m.linkCodeTask = AsyncTask.Start(Tasks.LoungeGenerateManualPairingCodeTask, {
|
||||
loungeService: m.loungeService
|
||||
loungeToken: m.loungeService.loungeToken
|
||||
screenId: m.loungeService.screenId
|
||||
' Use deviceName as screenName
|
||||
screenName: m.loungeService.deviceName
|
||||
deviceId: m.loungeService.deviceId
|
||||
}, OnLoungeGenerateManualPairingCodeTaskResult)
|
||||
end function
|
||||
|
||||
function OnLoungeGenerateManualPairingCodeTaskResult(output as object) as void
|
||||
m.linkCodeTask = 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)
|
||||
|
||||
message = `Failed to generate manual pairing code\n${error}`
|
||||
DialogUtils.ShowDialog(message, "Get TV code fail", true)
|
||||
return
|
||||
end if
|
||||
|
||||
manualLinkCode = output.result.code
|
||||
if StringUtils.IsNullOrEmpty(manualLinkCode)
|
||||
m.linkCodeLabel.text = ""
|
||||
return
|
||||
end if
|
||||
|
||||
' insert a space every 3 characters.
|
||||
parts = []
|
||||
for i = 0 to manualLinkCode.Len() - 1 step 3
|
||||
parts.Push(manualLinkCode.Mid(i, 3))
|
||||
end for
|
||||
linkCode = parts.Join(" ")
|
||||
|
||||
m.linkCodeLabel.text = linkCode
|
||||
end function
|
||||
@@ -0,0 +1,161 @@
|
||||
<component name="RemoteScreen" extends="Group" includes="AutoBind,Focus">
|
||||
<interface>
|
||||
<field id="navBar" type="node" bind="/NavBar" />
|
||||
<field id="webServer" type="node" bind="/WebServer" />
|
||||
<field id="loungeService" type="node" bind="/LoungeService" />
|
||||
<field id="url" type="string" onChange="OnUrlSet" />
|
||||
<field id="qrCodeUrl" type="string" onChange="OnUrlSet" />
|
||||
</interface>
|
||||
<children>
|
||||
<Group id="noInternet" visible="false">
|
||||
<Label
|
||||
height="720"
|
||||
width="1280"
|
||||
font="font:MediumBoldSystemFont"
|
||||
horizAlign="center"
|
||||
vertAlign="center"
|
||||
text="Could not get IP address: are we connected to the internet?"
|
||||
/>
|
||||
</Group>
|
||||
<Group id="yesInternet" visible="false">
|
||||
<SettingCategory
|
||||
id="WebAppButton"
|
||||
displayText="Playlet Web App"
|
||||
description="Use Playlet Remote in the browser"
|
||||
minimumWidth="350"
|
||||
translation="[150,178]" />
|
||||
|
||||
<SettingCategory
|
||||
id="LinkWithWiFiButton"
|
||||
displayText="Link with Wi-Fi"
|
||||
description="Cast from the YouTube app to Playlet"
|
||||
minimumWidth="350"
|
||||
translation="[150,314]" />
|
||||
|
||||
<SettingCategory
|
||||
id="LinkWithTvButton"
|
||||
displayText="Link with TV code"
|
||||
description="Cast from the YouTube app to Playlet"
|
||||
minimumWidth="350"
|
||||
translation="[150,450]" />
|
||||
|
||||
<Group id="WebAppPanel"
|
||||
translation="[700,115]">
|
||||
<Label
|
||||
height="30"
|
||||
width="400"
|
||||
font="font:SmallBoldSystemFont"
|
||||
horizAlign="center"
|
||||
text="Scan the QR code" />
|
||||
<QrCodePoster
|
||||
id="WebAppQrCodePoster"
|
||||
height="400"
|
||||
width="400"
|
||||
loadHeight="400"
|
||||
loadWidth="400"
|
||||
padding="20"
|
||||
translation="[0,40]" />
|
||||
<Label
|
||||
id="WebAppUrlLabel"
|
||||
height="30"
|
||||
width="400"
|
||||
font="font:SmallBoldSystemFont"
|
||||
horizAlign="center"
|
||||
translation="[0,460]" />
|
||||
</Group>
|
||||
|
||||
<Group id="LinkWithWiFiPanel"
|
||||
translation="[700,220]">
|
||||
<LayoutGroup itemSpacings="[12]">
|
||||
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
text="1." />
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
width="380"
|
||||
wrap="true"
|
||||
text="On your phone, connect to the same Wi-Fi network as this device." />
|
||||
</LayoutGroup>
|
||||
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
text="2." />
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
width="380"
|
||||
wrap="true"
|
||||
text="Open the YouTube app on your phone." />
|
||||
</LayoutGroup>
|
||||
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
text="3." />
|
||||
<Label
|
||||
id="WifiInstructionWithDeviceNameLabel"
|
||||
font="font:SmallSystemFont"
|
||||
width="380"
|
||||
wrap="true"
|
||||
text="Tap the cast icon and select this device." />
|
||||
</LayoutGroup>
|
||||
</LayoutGroup>
|
||||
<Label
|
||||
text="Roku connected to:"
|
||||
translation="[0,220]">
|
||||
<Font role="font" uri="font:SystemFontFile" size="20" />
|
||||
</Label>
|
||||
<Label
|
||||
id="WifiNameLabel"
|
||||
color="#4287f5"
|
||||
translation="[0,250]">
|
||||
<Font role="font" uri="font:BoldSystemFontFile" size="28" />
|
||||
</Label>
|
||||
</Group>
|
||||
|
||||
<Group id="LinkWithTvPanel"
|
||||
translation="[700,220]">
|
||||
<LayoutGroup itemSpacings="[12]">
|
||||
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
text="1." />
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
width="380"
|
||||
wrap="true"
|
||||
text="On your phone, open the YouTube app." />
|
||||
</LayoutGroup>
|
||||
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
text="2." />
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
width="380"
|
||||
wrap="true"
|
||||
text="Tap the Chromecast icon." />
|
||||
</LayoutGroup>
|
||||
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
text="3." />
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
width="380"
|
||||
wrap="true"
|
||||
text="Tap "Link with TV code" and enter the code below." />
|
||||
</LayoutGroup>
|
||||
</LayoutGroup>
|
||||
<Label
|
||||
id="LinkCodeLabel"
|
||||
font="font:LargeBoldSystemFont"
|
||||
color="#4287f5"
|
||||
translation="[-30,180]"
|
||||
width="460"
|
||||
horizAlign="center">
|
||||
<Font role="font" uri="font:BoldSystemFontFile" size="48" />
|
||||
</Label>
|
||||
</Group>
|
||||
</Group>
|
||||
</children>
|
||||
</component>
|
||||
@@ -1,3 +1,4 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/components/Services/SearchHistory/SearchHistoryUtils.bs"
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
@@ -203,8 +204,6 @@ end function
|
||||
|
||||
function Search(text as string)
|
||||
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))
|
||||
ShowLoadingScreen()
|
||||
|
||||
@@ -238,10 +237,16 @@ function Search(text as string)
|
||||
end function
|
||||
|
||||
function OnSearchContentReady() as void
|
||||
m.rowlist.UnobserveFieldScoped("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
|
||||
end if
|
||||
m.rowlist.UnobserveFieldScoped("someContentReady")
|
||||
|
||||
m.rowlist.focusable = true
|
||||
m.currentNavigtionNode = m.rowList
|
||||
NodeSetFocus(m.rowlist, true)
|
||||
@@ -253,6 +258,7 @@ function OnSearchContentReady() as void
|
||||
end function
|
||||
|
||||
function OnSearchError()
|
||||
' Note: we don't display an error dialog, VideoRowListRowContentTask will do that.
|
||||
m.rowlist.feeds = invalid
|
||||
m.rowlist.focusable = false
|
||||
HideLoadingScreen()
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
<Group id="container">
|
||||
<Button
|
||||
id="filtersButton"
|
||||
translation="[160,40]"
|
||||
minWidth="240"
|
||||
height="48"
|
||||
translation="[160,35]"
|
||||
minWidth="0"
|
||||
height="58"
|
||||
showFocusFootprint="true"
|
||||
iconUri="pkg:/images/icons/filters-white.png"
|
||||
focusedIconUri="pkg:/images/icons/filters-black.png"
|
||||
@@ -46,7 +46,7 @@
|
||||
showRowLabel="[true]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
variableWidthItems="true"
|
||||
focusBitmapUri="pkg:/images/focus_grid.9.png"
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png"
|
||||
/>
|
||||
<Animation
|
||||
id="scrollAnimation"
|
||||
|
||||
+1
-2
@@ -131,8 +131,7 @@ function MoveItem(offset as integer) as void
|
||||
|
||||
itemCount = content.getChildCount()
|
||||
index = m.checkList.itemFocused
|
||||
newIndex = MathUtils.Max(0, MathUtils.Min(index + offset, itemCount - 1))
|
||||
|
||||
newIndex = MathUtils.Clamp(index + offset, 0, itemCount - 1)
|
||||
if index = newIndex
|
||||
return
|
||||
end if
|
||||
|
||||
+11
-1
@@ -1,5 +1,7 @@
|
||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
@@ -7,6 +9,7 @@ function Init()
|
||||
m.top.itemSpacings = [8]
|
||||
|
||||
m.button = m.top.findNode("button")
|
||||
m.button.text = Invidious.DEFAULT_INSTANCE
|
||||
AdjustButtonLabel(m.button)
|
||||
|
||||
m.button.observeField("buttonSelected", FuncName(OpenInvidiousInstanceSettings))
|
||||
@@ -74,5 +77,12 @@ function OnValueChange() as void
|
||||
return
|
||||
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
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<interface>
|
||||
<field id="displayText" type="string" alias="DisplayTextLabel.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" />
|
||||
<function name="BindPreference" />
|
||||
</interface>
|
||||
|
||||
+1
@@ -9,6 +9,7 @@
|
||||
<children>
|
||||
<BusySpinner
|
||||
id="busySpinner"
|
||||
spinInterval="2"
|
||||
translation="[5,0]" />
|
||||
<Label
|
||||
id="nameLabel"
|
||||
|
||||
+4
-2
@@ -5,6 +5,7 @@
|
||||
<children>
|
||||
<BusySpinner
|
||||
id="busySpinner"
|
||||
spinInterval="1"
|
||||
translation="[380,96]" />
|
||||
<Label
|
||||
id="failedLabel"
|
||||
@@ -30,12 +31,13 @@
|
||||
<MarkupGrid
|
||||
id="instances"
|
||||
itemComponentName="InvidiousPublicInstancesListItem"
|
||||
itemSize="[860,16]"
|
||||
itemSize="[810,16]"
|
||||
itemSpacing="[0,20]"
|
||||
numColumns="1"
|
||||
numRows="7"
|
||||
vertFocusAnimationStyle="floatingFocus"
|
||||
translation="[0,46]" />
|
||||
translation="[0,46]"
|
||||
focusBitmapUri="pkg:/images/white-border.9.png" />
|
||||
|
||||
</children>
|
||||
</component>
|
||||
+1
-1
@@ -42,7 +42,7 @@
|
||||
<Label
|
||||
id="healthLabel"
|
||||
font="font:SmallestSystemFont"
|
||||
width="100"
|
||||
width="60"
|
||||
translation="[750,0]" />
|
||||
</children>
|
||||
</component>
|
||||
@@ -35,7 +35,7 @@ function BindPreference(preferences as object, key as string)
|
||||
end function
|
||||
|
||||
function OnPreferenceChange()
|
||||
m.top.value = MathUtils.Max(MathUtils.Min(m.preferences[m.key], m.top.max), m.top.min)
|
||||
m.top.value = MathUtils.Clamp(m.preferences[m.key], m.top.min, m.top.max)
|
||||
end function
|
||||
|
||||
function OnValueChange() as void
|
||||
|
||||
@@ -10,7 +10,9 @@ function Init()
|
||||
|
||||
m.top.iconUri = ""
|
||||
m.top.focusedIconUri = ""
|
||||
m.top.focusFootprintBitmapUri = "pkg:/images/white.9.png"
|
||||
m.top.focusBitmapUri = "pkg:/images/white.9.png"
|
||||
m.top.focusFootprintBitmapUri = "pkg:/images/white-border.9.png"
|
||||
m.top.showFocusFootprint = true
|
||||
m.top.observeField("focusedChild", FuncName(OnFocusedChildChange))
|
||||
end function
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
function Init()
|
||||
end function
|
||||
|
||||
function OnNodeReady()
|
||||
address = m.webserver@.GetServerAddress()
|
||||
isValidAddress = not StringUtils.IsNullOrEmpty(address)
|
||||
if isValidAddress
|
||||
m.top.url = address
|
||||
end if
|
||||
m.top.findNode("noInternet").visible = not isValidAddress
|
||||
m.top.findNode("yesInternet").visible = isValidAddress
|
||||
end function
|
||||
|
||||
function OnUrlSet()
|
||||
url = m.top.url
|
||||
|
||||
urlLabel = m.top.findNode("urlLabel")
|
||||
urlLabel.text = url
|
||||
|
||||
qrCodePoster = m.top.findNode("QrCodePoster")
|
||||
AsyncTask.Start(Tasks.GenerateQrCodeTask, {
|
||||
poster: qrCodePoster
|
||||
text: url
|
||||
size: qrCodePoster.loadWidth
|
||||
padding: 20
|
||||
})
|
||||
end function
|
||||
@@ -1,45 +0,0 @@
|
||||
<component name="WebAppScreen" extends="Group" includes="AutoBind">
|
||||
<interface>
|
||||
<field id="webServer" type="node" bind="/WebServer" />
|
||||
<field id="url" type="string" onChange="OnUrlSet" />
|
||||
<field id="qrCodeUrl" type="string" onChange="OnUrlSet" />
|
||||
</interface>
|
||||
<children>
|
||||
<Group id="noInternet" visible="false">
|
||||
<Label
|
||||
height="720"
|
||||
width="1280"
|
||||
font="font:MediumBoldSystemFont"
|
||||
horizAlign="center"
|
||||
vertAlign="center"
|
||||
text="Could not get IP address: are we connected to the internet?"
|
||||
/>
|
||||
</Group>
|
||||
<Group id="yesInternet" visible="false">
|
||||
<Label
|
||||
height="60"
|
||||
width="1280"
|
||||
font="font:MediumBoldSystemFont"
|
||||
horizAlign="center"
|
||||
translation="[0,92]"
|
||||
text="Scan the QR code with your phone camera, or open the URL in a web browser:"
|
||||
/>
|
||||
<Poster
|
||||
id="QrCodePoster"
|
||||
height="400"
|
||||
width="400"
|
||||
loadHeight="400"
|
||||
loadWidth="400"
|
||||
translation="[440, 160]" />
|
||||
|
||||
<Label
|
||||
id="UrlLabel"
|
||||
height="50"
|
||||
width="1280"
|
||||
font="font:MediumBoldSystemFont"
|
||||
horizAlign="center"
|
||||
translation="[0,600]"
|
||||
/>
|
||||
</Group>
|
||||
</children>
|
||||
</component>
|
||||
@@ -14,6 +14,7 @@ function GetLatestPlayletLibVersionFromGithubReleases() as string
|
||||
if response.StatusCode() = 200
|
||||
headers = response.Headers()
|
||||
if headers.location <> invalid
|
||||
' bs:disable-next-line NO_OPTIONAL_CHAINING
|
||||
regex = /\/v?(\d+\.\d+\.\d+)/
|
||||
match = regex.match(headers.location)
|
||||
if match.Count() = 2
|
||||
|
||||
@@ -5,7 +5,6 @@ import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
function Init()
|
||||
m.top.apiDefinitions = ParseJson(ReadAsciiFile("libpkg:/config/invidious_video_api.yaml"))
|
||||
m.service = new Invidious.InvidiousService(m.top)
|
||||
m.top.authToken = m.service.GetAuthToken()
|
||||
end function
|
||||
|
||||
function GetCurrentInstance(_unused as dynamic) as string
|
||||
@@ -16,10 +15,6 @@ function GetAuthorizeTokenLink(_unused as dynamic) as dynamic
|
||||
return m.service.GetAuthorizeTokenLink()
|
||||
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
|
||||
m.top.refreshSubscribtions = true
|
||||
end function
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<field id="applicationInfo" type="node" />
|
||||
<field id="preferences" type="node" />
|
||||
<field id="webServer" type="node" />
|
||||
<field id="profiles" type="node" />
|
||||
|
||||
<field id="authToken" type="assocarray" onChange="OnAuthTokenChange" />
|
||||
<field id="apiDefinitions" type="assocarray" />
|
||||
@@ -11,6 +12,5 @@
|
||||
|
||||
<function name="GetCurrentInstance" />
|
||||
<function name="GetAuthorizeTokenLink" />
|
||||
<function name="SetAuthToken" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -37,30 +37,17 @@ namespace Invidious
|
||||
const ERROR_NOT_AUTHENTICATED = "Not authenticated"
|
||||
|
||||
class InvidiousService
|
||||
public node as object
|
||||
public invidiousNode as object
|
||||
|
||||
function new(node as object)
|
||||
m.node = node
|
||||
|
||||
m.endpoints = node.apiDefinitions
|
||||
|
||||
m.responseHandlers = {
|
||||
DefaultHandler: m.DefaultHandler
|
||||
AuthFeedHandler: m.AuthFeedHandler
|
||||
PlaylistHandler: m.PlaylistHandler
|
||||
VideoInfoHandler: m.VideoInfoHandler
|
||||
PlaylistInfoHandler: m.PlaylistInfoHandler
|
||||
ChannelInfoHandler: m.ChannelInfoHandler
|
||||
ChannelVideosHandler: m.ChannelVideosHandler
|
||||
ChannelPlaylistsHandler: m.ChannelPlaylistsHandler
|
||||
WatchHistoryHandler: m.WatchHistoryHandler
|
||||
}
|
||||
function new(invidiousNode as object)
|
||||
m.invidiousNode = invidiousNode
|
||||
end function
|
||||
|
||||
function DefaultQueryParams() as object
|
||||
return {
|
||||
region: m.node.applicationInfo@.GetUserCountryCode()
|
||||
}
|
||||
function GetUserRegion() as string
|
||||
if m._userRegion = invalid
|
||||
m._userRegion = m.invidiousNode.applicationInfo@.GetUserCountryCode()
|
||||
end if
|
||||
return m._userRegion
|
||||
end function
|
||||
|
||||
function GetAuthenticationHeaders(token as string) as object
|
||||
@@ -70,7 +57,10 @@ namespace Invidious
|
||||
end function
|
||||
|
||||
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)
|
||||
return instance
|
||||
end if
|
||||
@@ -83,7 +73,7 @@ namespace Invidious
|
||||
return
|
||||
end if
|
||||
|
||||
authToken = m.node.authToken
|
||||
authToken = m.invidiousNode.authToken
|
||||
if authToken = invalid
|
||||
return
|
||||
end if
|
||||
@@ -99,7 +89,7 @@ namespace Invidious
|
||||
url = `${instance}${Invidious.SEARCH_SUGGEST_ENDPOINT}`
|
||||
|
||||
request = HttpClient.Get(url)
|
||||
request.QueryParams(m.DefaultQueryParams())
|
||||
request.QueryParam("region", m.GetUserRegion())
|
||||
request.QueryParam("q", q)
|
||||
request.CacheSeconds(60 * 60 * 24)
|
||||
|
||||
@@ -109,39 +99,57 @@ namespace Invidious
|
||||
return response.Json()
|
||||
end function
|
||||
|
||||
function GetVideoMetadata(videoId as string, cancellation = invalid as object) as object
|
||||
instance = m.GetInstance()
|
||||
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
|
||||
|
||||
request = HttpClient.Get(url)
|
||||
request.QueryParams(m.DefaultQueryParams())
|
||||
function GetVideoMetadata(videoId as string, options = invalid as object) as object
|
||||
' 5 hours cache. Videos should expire in 6 hours, but since we don't
|
||||
' have the exact expiration time, we'll use 5 hours. Invidious currently
|
||||
' Does a fresh fetch if the cache is older than 10 minutes.
|
||||
' https://github.com/iv-org/invidious/blob/069e91d2a609b1df94bdfbb693335969b2a281d8/src/invidious/videos.cr#L349
|
||||
request.CacheSeconds(60 * 60 * 5)
|
||||
cacheSeconds = 18000 ' 5 hours
|
||||
cancellation = invalid
|
||||
tryCount = 2
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("cacheSeconds")
|
||||
cacheSeconds = options.cacheSeconds
|
||||
end if
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
if options.DoesExist("tryCount")
|
||||
tryCount = options.tryCount
|
||||
end if
|
||||
end if
|
||||
|
||||
instance = m.GetInstance()
|
||||
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
|
||||
|
||||
request = HttpClient.Get(url)
|
||||
|
||||
request.CacheSeconds(cacheSeconds)
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
request.TryCount(2)
|
||||
request.RetryCallback(function(context as object) as boolean
|
||||
response = context.response
|
||||
' In some cases, video info requests return "HTTP/0.9 when not allowed" errors.
|
||||
' Retrying should usually fix the issue.
|
||||
if response.StatusCode() = HttpClient.CurlErrors.CURLE_UNSUPPORTED_PROTOCOL
|
||||
errorMessage = response.ErrorMessage()
|
||||
if errorMessage.InStr("HTTP/0.9") <> -1
|
||||
return true
|
||||
if tryCount > 1
|
||||
request.TryCount(tryCount)
|
||||
request.RetryCallback(function(context as object) as boolean
|
||||
response = context.response
|
||||
' In some cases, video info requests return "HTTP/0.9 when not allowed" errors.
|
||||
' Retrying should usually fix the issue.
|
||||
if response.StatusCode() = HttpClient.CurlErrors.CURLE_UNSUPPORTED_PROTOCOL
|
||||
errorMessage = response.ErrorMessage()
|
||||
if errorMessage.InStr("HTTP/0.9") <> -1
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
return false
|
||||
end function)
|
||||
return false
|
||||
end function)
|
||||
end if
|
||||
|
||||
return request.Await()
|
||||
end function
|
||||
|
||||
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
|
||||
instance = m.GetInstance()
|
||||
url = `${instance}${Invidious.PLAYLISTS_ENDPOINT}/${playlistId}`
|
||||
@@ -152,7 +160,6 @@ namespace Invidious
|
||||
request.Headers(m.GetAuthenticationHeaders(authToken.token))
|
||||
end if
|
||||
|
||||
request.QueryParams(m.DefaultQueryParams())
|
||||
request.QueryParam("index", index)
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
@@ -164,7 +171,6 @@ namespace Invidious
|
||||
url = `${instance}${Invidious.CHANNELS_ENDPOINT}/${authorId}`
|
||||
|
||||
request = HttpClient.Get(url)
|
||||
request.QueryParams(m.DefaultQueryParams())
|
||||
request.Cancellation(cancellation)
|
||||
request.CacheSeconds(60 * 60 * 24)' 24 hours
|
||||
request.TryCount(3)
|
||||
@@ -187,6 +193,10 @@ namespace Invidious
|
||||
|
||||
feedSource = feedSources[feedSourcesIndex]
|
||||
|
||||
if m.endpoints = invalid
|
||||
m.endpoints = m.invidiousNode.apiDefinitions
|
||||
end if
|
||||
|
||||
endpoint = m.endpoints[feedSource.endpoint]
|
||||
if endpoint = invalid or StringUtils.IsNullOrEmpty(endpoint.paginationType)
|
||||
return feedSource
|
||||
@@ -220,6 +230,10 @@ namespace Invidious
|
||||
end function
|
||||
|
||||
function MakeRequest(feedSource as object, additionalQueryParams = invalid as object, cancellation = invalid as object) as object
|
||||
if m.endpoints = invalid
|
||||
m.endpoints = m.invidiousNode.apiDefinitions
|
||||
end if
|
||||
|
||||
endpoint = m.endpoints[feedSource.endpoint]
|
||||
if endpoint = invalid
|
||||
return {
|
||||
@@ -232,8 +246,10 @@ namespace Invidious
|
||||
|
||||
request = HttpClient.Get(instance + endpoint.url)
|
||||
|
||||
authToken = invalid
|
||||
|
||||
if endpoint.authenticated = true
|
||||
authToken = m.node.authToken
|
||||
authToken = m.invidiousNode.authToken
|
||||
if authToken = invalid
|
||||
return {
|
||||
success: false
|
||||
@@ -250,7 +266,7 @@ namespace Invidious
|
||||
if queryParam.default <> invalid
|
||||
if IsString(queryParam.type) and queryParam.type = "#ISO3166"
|
||||
if queryParam.default = "GetUserCountryCode"
|
||||
request.QueryParam(queryParamKey, m.node.applicationInfo@.GetUserCountryCode())
|
||||
request.QueryParam(queryParamKey, m.GetUserRegion())
|
||||
else
|
||||
request.QueryParam(queryParamKey, queryParam.default)
|
||||
end if
|
||||
@@ -291,9 +307,18 @@ namespace Invidious
|
||||
|
||||
response = request.Await()
|
||||
|
||||
responseHandler = endpoint.responseHandler <> invalid ? m.responseHandlers[endpoint.responseHandler] : m.responseHandlers["DefaultHandler"]
|
||||
responseHandler = invalid
|
||||
if IsString(endpoint.responseHandler) and m.DoesExist(endpoint.responseHandler)
|
||||
responseHandler = endpoint.responseHandler
|
||||
else
|
||||
responseHandler = "DefaultHandler"
|
||||
end if
|
||||
|
||||
result = responseHandler(m, feedSource, response)
|
||||
result = m[responseHandler]({
|
||||
feedSource: feedSource
|
||||
response: response
|
||||
authToken: authToken
|
||||
})
|
||||
|
||||
if response.IsSuccess() and result <> invalid
|
||||
return {
|
||||
@@ -308,7 +333,9 @@ namespace Invidious
|
||||
end if
|
||||
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
|
||||
json = response.Json()
|
||||
return {
|
||||
@@ -318,7 +345,9 @@ namespace Invidious
|
||||
return invalid
|
||||
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
|
||||
json = response.Json()
|
||||
return {
|
||||
@@ -328,7 +357,9 @@ namespace Invidious
|
||||
return invalid
|
||||
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
|
||||
json = response.Json()
|
||||
return {
|
||||
@@ -339,7 +370,9 @@ namespace Invidious
|
||||
return invalid
|
||||
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
|
||||
json = response.Json()
|
||||
return {
|
||||
@@ -350,7 +383,10 @@ namespace Invidious
|
||||
return invalid
|
||||
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()
|
||||
if statusCode >= 500
|
||||
' In some cases, such as a video became private, or a live stream ended,
|
||||
@@ -358,8 +394,7 @@ namespace Invidious
|
||||
' 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
|
||||
' it is no longer valid.
|
||||
' TODO:P2 access to private property
|
||||
response._statusCode = 200
|
||||
response.OverrideStatusCode(200)
|
||||
return {
|
||||
items: [{
|
||||
"videoId": feedSource.pathParams.id
|
||||
@@ -379,7 +414,9 @@ namespace Invidious
|
||||
return invalid
|
||||
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
|
||||
json = response.Json()
|
||||
json.type = "playlist"
|
||||
@@ -390,7 +427,9 @@ namespace Invidious
|
||||
return invalid
|
||||
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
|
||||
json = response.Json()
|
||||
json.type = "channel"
|
||||
@@ -401,8 +440,11 @@ namespace Invidious
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function AuthFeedHandler(m as object, feedSource as object, response as object) as object
|
||||
m.DeleteExpiredToken(response)
|
||||
function AuthFeedHandler(context as object) as object
|
||||
response = context.response
|
||||
authToken = context.authToken
|
||||
|
||||
m.DeleteExpiredToken(response, authToken)
|
||||
|
||||
if response.StatusCode() <> 200
|
||||
return invalid
|
||||
@@ -428,8 +470,11 @@ namespace Invidious
|
||||
}
|
||||
end function
|
||||
|
||||
function WatchHistoryHandler(m as object, feedSource as object, response as object) as object
|
||||
m.DeleteExpiredToken(response)
|
||||
function WatchHistoryHandler(context as object) as object
|
||||
response = context.response
|
||||
authToken = context.authToken
|
||||
|
||||
m.DeleteExpiredToken(response, authToken)
|
||||
|
||||
if response.StatusCode() <> 200
|
||||
return invalid
|
||||
@@ -453,53 +498,19 @@ namespace Invidious
|
||||
}
|
||||
end function
|
||||
|
||||
function DeleteExpiredToken(response as object)
|
||||
if response.StatusCode() = 403
|
||||
LogWarn(`Invidious instance responded with 403: ${response.Text()}`)
|
||||
LogWarn("Deleting Invidious token...")
|
||||
m.DeleteAuthToken()
|
||||
function DeleteExpiredToken(response as object, authToken as object) as void
|
||||
if response.StatusCode() <> 403
|
||||
return
|
||||
end if
|
||||
end function
|
||||
|
||||
function GetAuthToken() as object
|
||||
tokenPayload = RegistryUtils.Read(RegistryUtils.INVIDIOUS_TOKEN)
|
||||
if tokenPayload = invalid
|
||||
return invalid
|
||||
LogWarn(`Invidious instance responded with 403: ${response.Text()}`)
|
||||
if not IsAssociativeArray(authToken) or not IsString(authToken.token)
|
||||
LogWarn("No valid token to delete")
|
||||
return
|
||||
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)
|
||||
obj = {
|
||||
token: token
|
||||
instance: instance
|
||||
username: username
|
||||
}
|
||||
|
||||
json = FormatJson(obj)
|
||||
RegistryUtils.Write(RegistryUtils.INVIDIOUS_TOKEN, json)
|
||||
|
||||
m.node.authToken = obj
|
||||
LogInfo("Deleting Invidious token...")
|
||||
m.invidiousNode.profiles@.LogoutWithAccessToken(authToken.token)
|
||||
end function
|
||||
|
||||
function VerifyTokenScope(token as string) as boolean
|
||||
@@ -523,30 +534,14 @@ We apologize for the inconvenience.`
|
||||
return validScopes
|
||||
end function
|
||||
|
||||
function DeleteAuthToken()
|
||||
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
|
||||
function UnregisterToken(authToken as object) as object
|
||||
url = `${authToken.instance}${Invidious.AUTH_TOKENS_UNREGISTER}`
|
||||
|
||||
request = HttpClient.Post(url, authToken.token)
|
||||
request.Headers(m.GetAuthenticationHeaders(authToken.token))
|
||||
request.Header("Content-Type", "application/json")
|
||||
|
||||
request.Await()
|
||||
return request.Await()
|
||||
end function
|
||||
|
||||
function GetAuthorizeTokenLink() as dynamic
|
||||
@@ -554,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
|
||||
invidiousHost = instance.Replace("https://", "http://")
|
||||
|
||||
address = m.node.webServer@.GetServerAddress()
|
||||
address = m.invidiousNode.webServer@.GetServerAddress()
|
||||
if address = invalid
|
||||
return invalid
|
||||
end if
|
||||
@@ -567,7 +562,7 @@ We apologize for the inconvenience.`
|
||||
end function
|
||||
|
||||
function GetSubscriptions(cancellation = invalid as object) as object
|
||||
authToken = m.node.authToken
|
||||
authToken = m.invidiousNode.authToken
|
||||
if authToken = invalid
|
||||
return invalid
|
||||
end if
|
||||
@@ -581,7 +576,7 @@ We apologize for the inconvenience.`
|
||||
end function
|
||||
|
||||
function Subscribe(channelId as string, cancellation = invalid as object) as object
|
||||
authToken = m.node.authToken
|
||||
authToken = m.invidiousNode.authToken
|
||||
if authToken = invalid
|
||||
return invalid
|
||||
end if
|
||||
@@ -595,7 +590,7 @@ We apologize for the inconvenience.`
|
||||
end function
|
||||
|
||||
function Unsubscribe(channelId as string, cancellation = invalid as object) as object
|
||||
authToken = m.node.authToken
|
||||
authToken = m.invidiousNode.authToken
|
||||
if authToken = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/TimeUtils.bs"
|
||||
|
||||
namespace InvidiousContent
|
||||
@@ -33,7 +34,8 @@ namespace InvidiousContent
|
||||
end if
|
||||
node.type = "video"
|
||||
|
||||
SetIfExists(node, "author", item, "author")
|
||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||
SetIfExists(node, "_author", item, "author")
|
||||
SetIfExists(node, "authorId", item, "authorId")
|
||||
SetIfExists(node, "lengthSeconds", item, "lengthSeconds")
|
||||
node.lengthText = TimeUtils.GetFormattedTime(item.lengthSeconds)
|
||||
@@ -43,6 +45,7 @@ namespace InvidiousContent
|
||||
VideoSetThumbnail(node, item, instance)
|
||||
SetIfExists(node, "title", item, "title")
|
||||
SetIfExists(node, "timestamp", item, "timestamp")
|
||||
SetIfExists(node, "id", item, "videoId")
|
||||
SetIfExists(node, "videoId", item, "videoId")
|
||||
node.viewCountText = VideoGetViewCountText(item)
|
||||
SetIfExists(node, "index", item, "index")
|
||||
@@ -61,6 +64,7 @@ namespace InvidiousContent
|
||||
SetIfExists(node, "_author", item, "author")
|
||||
SetIfExists(node, "authorId", item, "authorId")
|
||||
SetIfExists(node, "description", item, "description")
|
||||
SetIfExists(node, "id", item, "playlistId")
|
||||
SetIfExists(node, "playlistId", item, "playlistId")
|
||||
SetIfExists(node, "title", item, "title")
|
||||
SetIfExists(node, "videoCount", item, "videoCount")
|
||||
@@ -105,6 +109,7 @@ namespace InvidiousContent
|
||||
|
||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||
SetIfExists(node, "_author", item, "author")
|
||||
SetIfExists(node, "id", item, "authorId")
|
||||
SetIfExists(node, "authorId", item, "authorId")
|
||||
SetIfExists(node, "channelHandle", item, "channelHandle")
|
||||
SetIfExists(node, "description", item, "description")
|
||||
@@ -246,12 +251,34 @@ namespace InvidiousContent
|
||||
|
||||
function GetVideoCountText(item as object) as string
|
||||
videoCount = ValidInt(item.videoCount)
|
||||
return videoCount = 1 ? "1 video" : `${videoCount} videos`
|
||||
if videoCount = 1
|
||||
return "1 video"
|
||||
end if
|
||||
return `${videoCount} videos`
|
||||
end function
|
||||
|
||||
function GetChannelSubCountText(channel as object) as string
|
||||
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
|
||||
|
||||
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
|
||||
@@ -0,0 +1,298 @@
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/UrlUtils.bs"
|
||||
|
||||
const LONG_POLL_BUFSIZE = 65536
|
||||
const LONG_POLL_TIMEOUT_MS = 60000
|
||||
|
||||
enum HttpResponseState
|
||||
INIT = 0
|
||||
READING_STATUS = 1
|
||||
READING_HEADERS = 2
|
||||
READING_BODY_CHUNK_SIZE = 3
|
||||
READING_BODY_CHUNK = 4
|
||||
end enum
|
||||
|
||||
class LongPoller
|
||||
' Socket stuff for long polling
|
||||
private socket
|
||||
private socket_buffer
|
||||
private socket_state = HttpResponseState.INIT
|
||||
private socket_chunk_size = 0
|
||||
private socket_timer
|
||||
|
||||
private status_code = 0
|
||||
private headers
|
||||
|
||||
function new()
|
||||
m.socket_timer = CreateObject("roTimespan")
|
||||
end function
|
||||
|
||||
function SendRequest(url as string, messagePort as object) as boolean
|
||||
m.url = url
|
||||
|
||||
urlObject = UrlUtils.ParseUrl(url)
|
||||
if urlObject.protocol <> "http"
|
||||
throw `Invalid protocol: ${urlObject.protocol}`
|
||||
end if
|
||||
|
||||
sendAddress = CreateObject("roSocketAddress")
|
||||
sendAddress.SetAddress(`${urlObject.host}:${urlObject.port}`)
|
||||
|
||||
socket = CreateObject("roStreamSocket")
|
||||
socket.setSendToAddress(sendAddress)
|
||||
if not socket.Connect()
|
||||
LogError("Failed to connect")
|
||||
return false
|
||||
end if
|
||||
|
||||
LogInfo(`Sending long polling GET ${url}`, "ID:", socket.GetID())
|
||||
|
||||
#if DEBUG
|
||||
? `════════ curl command ════════\n${m.ToCurlCommand()}\n══════════════════════════════`
|
||||
#end if
|
||||
|
||||
message = `GET ${urlObject.path} HTTP/1.1\r\n`
|
||||
message += `Host: ${urlObject.host}\r\n`
|
||||
message += `\r\n`
|
||||
|
||||
socket.SendStr(message)
|
||||
|
||||
socket.notifyReadable(true)
|
||||
socket.setMessagePort(messagePort)
|
||||
|
||||
m.socket = socket
|
||||
m.socket_timer.Mark()
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
' Returns:
|
||||
' - false if we're no longer returning data - socket is closed
|
||||
' - true if we're still waiting for data
|
||||
' - array we've received chunk(s) of data
|
||||
function Poll(socketMessages as object) as dynamic
|
||||
if m.socket = invalid
|
||||
return false
|
||||
end if
|
||||
|
||||
socket = m.socket
|
||||
if not socket.IsConnected()
|
||||
LogError("Socket is not connected")
|
||||
m.CloseSocket()
|
||||
return false
|
||||
end if
|
||||
|
||||
' Not receiving data for LONG_POLL_TIMEOUT_MS seconds might be a sign of a dead connection
|
||||
if m.socket_timer.TotalMilliseconds() > LONG_POLL_TIMEOUT_MS
|
||||
LogWarn("Timeout after", LONG_POLL_TIMEOUT_MS, "ms")
|
||||
m.CloseSocket()
|
||||
return false
|
||||
end if
|
||||
|
||||
if socketMessages.Count() = 0
|
||||
return true
|
||||
end if
|
||||
|
||||
hasDataToReceive = false
|
||||
for each socketMessage in socketMessages
|
||||
if socketMessage.GetSocketID() = socket.GetID()
|
||||
hasDataToReceive = true
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
|
||||
if not hasDataToReceive
|
||||
return true
|
||||
end if
|
||||
|
||||
data = socket.ReceiveStr(LONG_POLL_BUFSIZE)
|
||||
if not socket.eSuccess()
|
||||
LogError("Error receiving data")
|
||||
m.CloseSocket()
|
||||
return false
|
||||
end if
|
||||
|
||||
m.socket_timer.Mark()
|
||||
|
||||
if m.socket_buffer = invalid
|
||||
m.socket_buffer = ""
|
||||
end if
|
||||
|
||||
m.socket_buffer += data
|
||||
|
||||
return m.ParseData()
|
||||
end function
|
||||
|
||||
function IsOpen() as boolean
|
||||
return m.socket <> invalid and m.socket.IsConnected()
|
||||
end function
|
||||
|
||||
function CloseSocket() as void
|
||||
if m.socket = invalid
|
||||
return
|
||||
end if
|
||||
m.socket.notifyReadable(false)
|
||||
m.socket.close()
|
||||
m.socket = invalid
|
||||
m.socket_buffer = invalid
|
||||
m.socket_state = HttpResponseState.INIT
|
||||
end function
|
||||
|
||||
function ParseData() as dynamic
|
||||
if m.socket_state = HttpResponseState.INIT
|
||||
m.socket_state = HttpResponseState.READING_STATUS
|
||||
end if
|
||||
|
||||
if m.socket_state = HttpResponseState.READING_STATUS
|
||||
if not m.ParseOpration()
|
||||
return false
|
||||
end if
|
||||
end if
|
||||
|
||||
if m.socket_state = HttpResponseState.READING_HEADERS
|
||||
if not m.ParseHeaders()
|
||||
return false
|
||||
end if
|
||||
end if
|
||||
|
||||
chunks = []
|
||||
READING_BODY_CHUNK_SIZE:
|
||||
if m.socket_state = HttpResponseState.READING_BODY_CHUNK_SIZE
|
||||
if not m.ParseChunkSize()
|
||||
return chunks
|
||||
end if
|
||||
end if
|
||||
|
||||
if m.socket_state = HttpResponseState.READING_BODY_CHUNK
|
||||
chunk = m.ParseChunk()
|
||||
if IsBool(chunk)
|
||||
if not chunk
|
||||
return chunks
|
||||
end if
|
||||
else
|
||||
chunks.Push(chunk)
|
||||
goto READING_BODY_CHUNK_SIZE
|
||||
end if
|
||||
end if
|
||||
|
||||
return chunks
|
||||
end function
|
||||
|
||||
function ParseOpration() as boolean
|
||||
newLineIndex = m.socket_buffer.InStr(`\r\n`)
|
||||
if newLineIndex > 0
|
||||
operationLine = m.socket_buffer.Left(newLineIndex)
|
||||
parts = operationLine.Split(" ")
|
||||
if parts.Count() <> 3 or parts[0] <> "HTTP/1.1"
|
||||
LogError("Invalid operation line:", operationLine)
|
||||
m.CloseSocket()
|
||||
return false
|
||||
end if
|
||||
|
||||
m.status_code = Val(parts[1])
|
||||
if not m.status_code = 200
|
||||
LogError("Http status code:", m.status_code)
|
||||
LogError("Response data:", m.socket_buffer)
|
||||
m.CloseSocket()
|
||||
return false
|
||||
end if
|
||||
|
||||
m.socket_buffer = m.socket_buffer.Mid(newLineIndex + 2)
|
||||
m.socket_state = HttpResponseState.READING_HEADERS
|
||||
end if
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
function ParseHeaders() as boolean
|
||||
newLineIndex = m.socket_buffer.InStr(`\r\n\r\n`)
|
||||
if newLineIndex > 0
|
||||
headersStr = m.socket_buffer.Left(newLineIndex)
|
||||
|
||||
headers = {}
|
||||
headerLines = headersStr.Split(`\r\n`)
|
||||
for each headerLine in headerLines
|
||||
colonIndex = headerLine.InStr(":")
|
||||
key = headerLine.Left(colonIndex).Trim()
|
||||
value = headerLine.Mid(colonIndex + 1).Trim()
|
||||
headers[key] = value
|
||||
end for
|
||||
m.headers = headers
|
||||
|
||||
LogDebug("Headers:", headers)
|
||||
|
||||
if headers["Transfer-Encoding"] <> "chunked"
|
||||
LogError("Invalid transfer encoding:", headers["Transfer-Encoding"])
|
||||
m.CloseSocket()
|
||||
return false
|
||||
end if
|
||||
|
||||
m.socket_buffer = m.socket_buffer.Mid(newLineIndex + 4)
|
||||
m.socket_state = HttpResponseState.READING_BODY_CHUNK_SIZE
|
||||
end if
|
||||
return true
|
||||
end function
|
||||
|
||||
function ParseChunkSize() as boolean
|
||||
m.ConsumeNewLines()
|
||||
newLineIndex = m.socket_buffer.InStr(`\r\n`)
|
||||
if newLineIndex > 0
|
||||
chunkSize = m.socket_buffer.Left(newLineIndex)
|
||||
chunkSize = chunkSize.Trim()
|
||||
chunkSize = Val(chunkSize, 16)
|
||||
LogDebug("Chunk size:", chunkSize)
|
||||
m.socket_chunk_size = chunkSize
|
||||
if chunkSize = 0
|
||||
LogDebug("End of chunked data")
|
||||
m.CloseSocket()
|
||||
return false
|
||||
end if
|
||||
m.socket_buffer = m.socket_buffer.Mid(newLineIndex + 2)
|
||||
m.socket_state = HttpResponseState.READING_BODY_CHUNK
|
||||
end if
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
function ParseChunk() as dynamic
|
||||
if m.socket_chunk_size > 0
|
||||
if m.socket_buffer.Len() >= m.socket_chunk_size
|
||||
chunk = m.socket_buffer.Left(m.socket_chunk_size)
|
||||
m.socket_buffer = m.socket_buffer.Mid(m.socket_chunk_size)
|
||||
m.socket_chunk_size = 0
|
||||
m.socket_state = HttpResponseState.READING_BODY_CHUNK_SIZE
|
||||
return chunk
|
||||
end if
|
||||
else
|
||||
LogError("Invalid chunk size")
|
||||
m.CloseSocket()
|
||||
return false
|
||||
end if
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
function ConsumeNewLines()
|
||||
CR = `\r`
|
||||
LF = `\n`
|
||||
startIndex = 0
|
||||
while true
|
||||
char = m.socket_buffer.Mid(startIndex, 1)
|
||||
if char = CR or char = LF
|
||||
startIndex += 1
|
||||
else
|
||||
exit while
|
||||
end if
|
||||
end while
|
||||
|
||||
if startIndex > 0
|
||||
m.socket_buffer = m.socket_buffer.Mid(startIndex)
|
||||
end if
|
||||
end function
|
||||
|
||||
function ToCurlCommand() as string
|
||||
' It won't work the same since it will disconnect quickly
|
||||
return `curl "${m.url}"`
|
||||
end function
|
||||
|
||||
end class
|
||||
@@ -0,0 +1,578 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||
import "pkg:/components/Services/LoungeService/LongPoller.bs"
|
||||
import "pkg:/components/Services/LoungeService/LoungeConstants.bs"
|
||||
import "pkg:/components/Services/LoungeService/LoungeMessages.bs"
|
||||
import "pkg:/components/Services/LoungeService/LoungeVideoQueue.bs"
|
||||
import "pkg:/components/Services/LoungeService/Notifications/DeviceConnectedNotificationUtils.bs"
|
||||
import "pkg:/source/services/HttpClient.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/RegistryUtils.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/UrlUtils.bs"
|
||||
|
||||
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
|
||||
|
||||
public loungeServiceNode
|
||||
public videoQueueNode
|
||||
public notificationsNode
|
||||
public invService
|
||||
|
||||
public deviceId
|
||||
public deviceName
|
||||
public screenId
|
||||
public screenName
|
||||
public loungeToken
|
||||
public sessionId
|
||||
public gSessionId
|
||||
public devices
|
||||
|
||||
private ofs
|
||||
private lastProcessedCommandIndex = -1
|
||||
private poller
|
||||
private outgoingMessagesRequests
|
||||
|
||||
function new(loungeServiceNode as object, videoQueueNode as object, notificationsNode as object, invidiousNode as object)
|
||||
m.loungeServiceNode = loungeServiceNode
|
||||
m.videoQueueNode = videoQueueNode
|
||||
m.notificationsNode = notificationsNode
|
||||
m.invService = new Invidious.InvidiousService(invidiousNode)
|
||||
m.dateTime = CreateObject("roDateTime")
|
||||
m.deviceId = loungeServiceNode.deviceId
|
||||
deviceName = loungeServiceNode.deviceName
|
||||
m.deviceName = deviceName
|
||||
m.screenName = deviceName
|
||||
m.ofs = 0
|
||||
m.poller = invalid
|
||||
m.outgoingMessagesRequests = {}
|
||||
m.devices = {}
|
||||
|
||||
commandHandlers = {}
|
||||
commandHandlers[COMMAND_TYPE_NOOP] = m.HandleIgnoreCommand
|
||||
commandHandlers[COMMAND_TYPE_GET_VOLUME] = m.HandleIgnoreCommand
|
||||
commandHandlers[COMMAND_TYPE_GET_SUBTITLES_TRACK] = m.HandleIgnoreCommand
|
||||
commandHandlers[COMMAND_TYPE_SET_SUBTITLES] = m.HandleIgnoreCommand
|
||||
commandHandlers[COMMAND_TYPE_DPAD_COMMAND] = m.HandleIgnoreCommand
|
||||
commandHandlers[COMMAND_TYPE_VOICE_COMMAND] = 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_SESSION_ID] = m.HandleSessionId
|
||||
commandHandlers[COMMAND_TYPE_G_SESSION_ID] = m.HandleGSessionId
|
||||
commandHandlers[COMMAND_TYPE_LOUNGE_STATUS] = m.HandleLoungeStatus
|
||||
commandHandlers[COMMAND_TYPE_REMOTE_CONNECTED] = m.HandleRemoteConnected
|
||||
commandHandlers[COMMAND_TYPE_SET_VOLUME] = m.HandleSetVolume
|
||||
commandHandlers[COMMAND_TYPE_SET_PLAYLIST] = m.HandleSetPlaylist
|
||||
commandHandlers[COMMAND_TYPE_UPDATE_PLAYLIST] = m.HandleUpdatePlaylist
|
||||
commandHandlers[COMMAND_TYPE_PAUSE] = m.HandlePause
|
||||
commandHandlers[COMMAND_TYPE_PLAY] = m.HandlePlay
|
||||
commandHandlers[COMMAND_TYPE_STOP_VIDEO] = m.HandleStopVideo
|
||||
commandHandlers[COMMAND_TYPE_SEEK_TO] = m.HandleSeekTo
|
||||
|
||||
for each key in commandHandlers
|
||||
m[COMMAND_HANDLER_PREFIX + key] = commandHandlers[key]
|
||||
end for
|
||||
end function
|
||||
|
||||
function Zx() as string
|
||||
' Math.floor(2147483648 * Math.random()).toString(36) + Math.abs(Math.floor(2147483648 * Math.random()) ^ Date.now()).toString(36)
|
||||
rnd1% = rnd(2147483647)
|
||||
rnd2& = rnd(2147483647)
|
||||
m.dateTime.mark()
|
||||
now& = m.dateTime.AsSeconds()
|
||||
now& = now& * 1000 + m.dateTime.GetMilliseconds()
|
||||
rnd2xor& = (rnd2& or now&) and not (rnd2& and now&)
|
||||
return StrI(rnd1%, 36) + StrI(Abs(rnd2xor&), 36)
|
||||
end function
|
||||
|
||||
function GetScreenId() as dynamic
|
||||
if not StringUtils.IsNullOrEmpty(m.screenId)
|
||||
return m.screenId
|
||||
end if
|
||||
|
||||
request = HttpClient.Get("https://www.youtube.com/api/lounge/pairing/generate_screen_id")
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
error = `Failed to get screen id. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
|
||||
LogError(error)
|
||||
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
id = response.Text()
|
||||
if not IsString(id)
|
||||
error = `Failed to get screen id. Please restart playlet to use the cast function.\nNot a valid screen id: ${id}`
|
||||
LogError(error)
|
||||
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
m.screenId = id
|
||||
return id
|
||||
end function
|
||||
|
||||
function GetToken() as dynamic
|
||||
if not StringUtils.IsNullOrEmpty(m.loungeToken)
|
||||
return m.loungeToken
|
||||
end if
|
||||
|
||||
request = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/get_lounge_token_batch", "")
|
||||
request.UrlEncodedForm({
|
||||
"screen_ids": m.screenId
|
||||
})
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
error = `Failed to get lounge token. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
|
||||
LogError(error)
|
||||
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
screens = json.screens
|
||||
if not IsArray(screens) or screens.Count() <> 1
|
||||
error = `Failed to get lounge token. Please restart playlet to use the cast function.\nInvalid response: ${json}`
|
||||
LogError(error)
|
||||
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
' payload contains more information, but we only need the token
|
||||
m.loungeToken = screens[0].loungeToken
|
||||
return m.loungeToken
|
||||
end function
|
||||
|
||||
function GetSessionData() as boolean
|
||||
queryParams = {
|
||||
"device": "LOUNGE_SCREEN"
|
||||
"theme": "cl"
|
||||
"capabilities": ""
|
||||
"mdxVersion": "2"
|
||||
"VER": "8"
|
||||
"v": "2"
|
||||
"t": "1"
|
||||
"app": "lb-v4"
|
||||
"RID": "1337"
|
||||
}
|
||||
|
||||
queryParams["name"] = m.screenName
|
||||
queryParams["id"] = m.deviceId
|
||||
queryParams["loungeIdToken"] = m.loungeToken
|
||||
queryParams["zx"] = m.Zx()
|
||||
|
||||
request = HttpClient.Post("https://www.youtube.com/api/lounge/bc/bind", "")
|
||||
request.QueryParams(queryParams)
|
||||
request.UrlEncodedForm({
|
||||
"count": 0
|
||||
})
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
error = `Failed to get session data. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
|
||||
LogError(error)
|
||||
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||
return false
|
||||
end if
|
||||
|
||||
text = response.Text()
|
||||
' First line should be a number, which is the length of the JSON payload
|
||||
text = text.Mid(text.instr(`\n`) + 1)
|
||||
|
||||
messagesToSend = []
|
||||
commands = ParseJson(text)
|
||||
m.ProcessCommands(commands, messagesToSend)
|
||||
m.SendMessages(messagesToSend)
|
||||
return true
|
||||
end function
|
||||
|
||||
function FetchCommandsRpc(messagePort as object) as void
|
||||
' Note we're not using https, not supported by LongPoller
|
||||
baseUrl = "http://www.youtube.com/api/lounge/bc/bind"
|
||||
queryParams = {
|
||||
"device": "LOUNGE_SCREEN"
|
||||
"theme": "cl"
|
||||
"capabilities": ""
|
||||
"mdxVersion": "2"
|
||||
"VER": "8"
|
||||
"v": "2"
|
||||
"t": "1"
|
||||
"app": "lb-v4"
|
||||
"RID": "rpc"
|
||||
"CI": "0"
|
||||
}
|
||||
|
||||
queryParams["name"] = m.screenName
|
||||
queryParams["id"] = m.deviceId
|
||||
queryParams["loungeIdToken"] = m.loungeToken
|
||||
queryParams["SID"] = m.sessionId
|
||||
queryParams["gsessionid"] = m.gSessionId
|
||||
queryParams["zx"] = m.Zx()
|
||||
|
||||
url = UrlUtils.BuildUrl(baseUrl, invalid, queryParams)
|
||||
|
||||
if m.poller = invalid
|
||||
m.poller = new LongPoller()
|
||||
end if
|
||||
|
||||
m.poller.SendRequest(url, messagePort)
|
||||
end function
|
||||
|
||||
function Poll(socketMessages as object, messagesToSend as object) as boolean
|
||||
chunks = m.poller.Poll(socketMessages)
|
||||
if IsArray(chunks)
|
||||
for each chunk in chunks
|
||||
m.ProcessChunk(chunk, messagesToSend)
|
||||
end for
|
||||
end if
|
||||
|
||||
return m.poller.IsOpen()
|
||||
end function
|
||||
|
||||
function ProcessChunk(chunk as string, messagesToSend as object) as void
|
||||
chunk = m.ConsumeNewLines(chunk)
|
||||
newLineIndex = chunk.InStr(`\n`)
|
||||
while newLineIndex > 0
|
||||
payloadSize = chunk.Left(newLineIndex).trim()
|
||||
payloadSize = payloadSize.ToInt()
|
||||
payload = chunk.Mid(newLineIndex + 1, payloadSize)
|
||||
commands = ParseJson(payload)
|
||||
m.ProcessCommands(commands, messagesToSend)
|
||||
chunk = chunk.Mid(newLineIndex + payloadSize + 1)
|
||||
newLineIndex = chunk.InStr(`\n`)
|
||||
end while
|
||||
end function
|
||||
|
||||
function ConsumeNewLines(chunk as string) as string
|
||||
CR = `\r`
|
||||
LF = `\n`
|
||||
startIndex = 0
|
||||
while true
|
||||
char = chunk.Mid(startIndex, 1)
|
||||
if char = CR or char = LF
|
||||
startIndex += 1
|
||||
else
|
||||
exit while
|
||||
end if
|
||||
end while
|
||||
|
||||
if startIndex > 0
|
||||
return chunk.Mid(startIndex)
|
||||
end if
|
||||
|
||||
return chunk
|
||||
end function
|
||||
|
||||
function ProcessCommands(commands as object, messagesToSend as object) as void
|
||||
if not IsArray(commands)
|
||||
return
|
||||
end if
|
||||
|
||||
for each command in commands
|
||||
if not IsArray(command) or command.Count() <> 2
|
||||
continue for
|
||||
end if
|
||||
|
||||
commandIndex = command[0]
|
||||
if commandIndex <= m.lastProcessedCommandIndex
|
||||
LogDebug("Skipping command already processed:", command)
|
||||
continue for
|
||||
end if
|
||||
m.lastProcessedCommandIndex = commandIndex
|
||||
|
||||
commandId = command[0]
|
||||
commandData = command[1]
|
||||
commandType = commandData[0]
|
||||
commandArgs = invalid
|
||||
if commandData.Count() > 1
|
||||
commandArgs = commandData[1]
|
||||
end if
|
||||
|
||||
handler = COMMAND_HANDLER_PREFIX + commandType
|
||||
if m.DoesExist(handler)
|
||||
LogInfo(commandType)
|
||||
m[handler](commandId, commandType, commandArgs, messagesToSend)
|
||||
else
|
||||
LogWarn("Unknown command type:", commandType, "command:", command)
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
|
||||
function HandleIgnoreCommand(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||
LogDebug("Ignoring command:", commandType, "args:", commandArgs)
|
||||
end function
|
||||
|
||||
function HandleSessionId(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||
m.sessionId = commandArgs
|
||||
LogInfo("sessionId:", m.sessionId)
|
||||
end function
|
||||
|
||||
function HandleGSessionId(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||
m.gSessionId = commandArgs
|
||||
LogInfo("gSessionId:", m.gSessionId)
|
||||
end function
|
||||
|
||||
function HandleGetPlayingNow(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
|
||||
player = m.videoQueueNode.player
|
||||
|
||||
message = LoungeMessages.OnHasPreviousNextChanged(m.videoQueueNode.hasPrevious, m.videoQueueNode.hasNext)
|
||||
message["commandId"] = commandId
|
||||
messagesToSend.Push(message)
|
||||
|
||||
message = LoungeMessages.NowPlaying(player)
|
||||
message["commandId"] = commandId
|
||||
messagesToSend.Push(message)
|
||||
|
||||
message = LoungeMessages.OnStateChange(player)
|
||||
message["commandId"] = commandId
|
||||
messagesToSend.Push(message)
|
||||
end function
|
||||
|
||||
function HandleLoungeStatus(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
|
||||
LogInfo(commandType, FormatJson(commandArgs))
|
||||
devices = commandArgs["devices"]
|
||||
if not IsString(devices)
|
||||
return
|
||||
end if
|
||||
devices = ParseJson(devices)
|
||||
if devices = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
for each device in devices
|
||||
if m.devices.DoesExist(device.id)
|
||||
device.lastConnectNotificationTime = m.devices[device.id].lastConnectNotificationTime
|
||||
end if
|
||||
m.devices[device.id] = device
|
||||
end for
|
||||
end function
|
||||
|
||||
function HandleRemoteConnected(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
|
||||
LogInfo(commandType, FormatJson(commandArgs))
|
||||
newDevice = commandArgs
|
||||
id = newDevice.id
|
||||
if StringUtils.IsNullOrEmpty(id)
|
||||
return
|
||||
end if
|
||||
|
||||
if m.devices.DoesExist(id)
|
||||
device = m.devices[id]
|
||||
device.Append(newDevice)
|
||||
newDevice = device
|
||||
end if
|
||||
|
||||
m.devices[id] = newDevice
|
||||
|
||||
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
|
||||
deviceName = newDevice.name
|
||||
userAvatarUri = newDevice.userAvatarUri
|
||||
|
||||
LoungeDeviceConnected.ShowNotifcation(m.notificationsNode, deviceName, userName, userAvatarUri)
|
||||
end function
|
||||
|
||||
function HandleSetVolume(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
|
||||
player = m.videoQueueNode.player
|
||||
if player = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
volume = Val(commandArgs["volume"])
|
||||
isMute = volume = 0
|
||||
LogInfo("Setting volume is not supported:", volume, "but can mute:", isMute)
|
||||
' TODO:P2 volume should be set to the lounge state.
|
||||
' Also the state needs to be separate from the player, since SponsorBlock can mute sections.
|
||||
player.mute = isMute
|
||||
end function
|
||||
|
||||
function HandleSetPlaylist(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||
LogDebug(commandType, commandArgs)
|
||||
LoungeVideoQueue.SetPlaylist(m.videoQueueNode, m.invService, commandArgs)
|
||||
end function
|
||||
|
||||
function HandleUpdatePlaylist(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||
LogDebug(commandType, commandArgs)
|
||||
LoungeVideoQueue.UpdatePlaylist(m.videoQueueNode, m.invService, commandArgs)
|
||||
end function
|
||||
|
||||
function HandlePause(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||
m.videoQueueNode.pause = true
|
||||
end function
|
||||
|
||||
function HandlePlay(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||
m.videoQueueNode.play = true
|
||||
end function
|
||||
|
||||
function HandleStopVideo(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||
m.videoQueueNode.closePlayer = true
|
||||
end function
|
||||
|
||||
function HandleSeekTo(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
|
||||
player = m.videoQueueNode.player
|
||||
if player = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
seekTo = Val(commandArgs[FIELD_NEW_TIME])
|
||||
LogInfo("Seeking to:", seekTo)
|
||||
player.seek = seekTo
|
||||
end function
|
||||
|
||||
function SendMessages(messages as object, loungeData = invalid as object) as void
|
||||
if messages.Count() = 0
|
||||
return
|
||||
end if
|
||||
|
||||
queryParams = {
|
||||
"device": "LOUNGE_SCREEN"
|
||||
"theme": "cl"
|
||||
"capabilities": ""
|
||||
"mdxVersion": "2"
|
||||
"VER": "8"
|
||||
"v": "2"
|
||||
"t": "1"
|
||||
"app": "lb-v4"
|
||||
"RID": "1337"
|
||||
}
|
||||
|
||||
if loungeData = invalid
|
||||
loungeData = m
|
||||
end if
|
||||
|
||||
queryParams["name"] = loungeData.screenName
|
||||
queryParams["id"] = loungeData.deviceId
|
||||
queryParams["loungeIdToken"] = loungeData.loungeToken
|
||||
queryParams["SID"] = loungeData.sessionId
|
||||
queryParams["gsessionid"] = loungeData.gSessionId
|
||||
queryParams["zx"] = m.Zx()
|
||||
if messages[0].commandId <> invalid
|
||||
queryParams["AID"] = messages[0].commandId
|
||||
end if
|
||||
|
||||
postData = [
|
||||
{ key: "count", value: messages.Count() }
|
||||
{ key: "ofs", value: loungeData.ofs }
|
||||
]
|
||||
|
||||
loungeData.ofs += messages.Count()
|
||||
|
||||
for i = 0 to messages.Count() - 1
|
||||
message = messages[i]
|
||||
keyPrefix = `req${i}_`
|
||||
|
||||
postData.Push({ key: `${keyPrefix}${FIELD_COMMAND_NAME}`, value: message.commandType })
|
||||
|
||||
commandArgs = message.commandArgs
|
||||
if commandArgs <> invalid
|
||||
for each key in commandArgs
|
||||
postData.Push({ key: `${keyPrefix}${key}`, value: commandArgs[key] })
|
||||
end for
|
||||
end if
|
||||
end for
|
||||
|
||||
LogDebug("Sending messages:", postData)
|
||||
|
||||
request = HttpClient.Post("https://www.youtube.com/api/lounge/bc/bind", "")
|
||||
request.QueryParams(queryParams)
|
||||
request.UrlEncodedForm(postData)
|
||||
|
||||
request.Send()
|
||||
|
||||
' we do not need to wait for requests to finish, we check on them later
|
||||
' to avoid blocking the thread.
|
||||
' This is specific to sent lounge messages, since we're not waiting for a response.
|
||||
requestId = request.urlTransfer.GetIdentity().ToStr()
|
||||
m.outgoingMessagesRequests[requestId] = request
|
||||
end function
|
||||
|
||||
function ProcessPendingOutgoingMessages()
|
||||
for each key in m.outgoingMessagesRequests
|
||||
request = m.outgoingMessagesRequests[key]
|
||||
if request.IsCompleted()
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
LogError(response.ErrorMessage())
|
||||
end if
|
||||
|
||||
m.outgoingMessagesRequests.Delete(key)
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
|
||||
function SaveCurrentLoungeData() as void
|
||||
loungeData = {
|
||||
"__version": 1
|
||||
}
|
||||
fields = ["screenName", "deviceId", "loungeToken", "sessionId", "gSessionId"]
|
||||
for each field in fields
|
||||
if StringUtils.IsNullOrEmpty(m[field])
|
||||
LogWarn("Lounge data will not be saved. missing field:", field)
|
||||
return
|
||||
end if
|
||||
|
||||
loungeData[field] = m[field]
|
||||
end for
|
||||
|
||||
loungeData = FormatJson(loungeData)
|
||||
RegistryUtils.Write(RegistryUtils.LAST_LOUNGE_DATA, loungeData)
|
||||
end function
|
||||
|
||||
function DisconnectFromLastLounge() as void
|
||||
loungeData = RegistryUtils.Read(RegistryUtils.LAST_LOUNGE_DATA)
|
||||
if loungeData = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
RegistryUtils.Delete(RegistryUtils.LAST_LOUNGE_DATA)
|
||||
|
||||
loungeData = ParseJson(loungeData)
|
||||
if not IsAssociativeArray(loungeData)
|
||||
LogWarn("Can't disconnect from lounge. Invalid data:", loungeData)
|
||||
return
|
||||
end if
|
||||
|
||||
if ValidInt(loungeData.__version) <> 1
|
||||
LogWarn("Can't disconnect from lounge. Unknown version:", loungeData.__version)
|
||||
return
|
||||
end if
|
||||
|
||||
fields = ["screenName", "deviceId", "loungeToken", "sessionId", "gSessionId"]
|
||||
for each field in fields
|
||||
if StringUtils.IsNullOrEmpty(loungeData[field])
|
||||
LogWarn("Can't disconnect from lounge. Missing field:", field)
|
||||
return
|
||||
end if
|
||||
end for
|
||||
|
||||
messages = [{
|
||||
"commandType": COMMAND_LOUNGE_SCREEN_DISCONNECTED
|
||||
}]
|
||||
|
||||
LogInfo("Disconnecting from last lounge")
|
||||
' Every time we send messages, we need to increment the ofs.
|
||||
' This is so that the server recognizes old messages and doesn't process them.
|
||||
' But we're currently disconnecting from a previous session, and since
|
||||
' we didn't keep track of the ofs, so we'll just set it to a large number.
|
||||
' This is the last message we'll be sending to this lounge.
|
||||
loungeData.ofs = 99999999
|
||||
m.SendMessages(messages, loungeData)
|
||||
end function
|
||||
|
||||
end class
|
||||
@@ -0,0 +1,73 @@
|
||||
' Outgoing commands
|
||||
const COMMAND_NOW_PLAYING = "nowPlaying"
|
||||
const COMMAND_ON_STATE_CHANGE = "onStateChange"
|
||||
const COMMAND_ON_VOLUME_CHANGED = "onVolumeChanged"
|
||||
const COMMAND_ON_PREVIOUS_NEXT_CHANGE = "onHasPreviousNextChanged"
|
||||
const COMMAND_LOUNGE_SCREEN_DISCONNECTED = "loungeScreenDisconnected"
|
||||
' Incoming commands
|
||||
const COMMAND_TYPE_SET_PLAYLIST = "setPlaylist"
|
||||
const COMMAND_TYPE_LOUNGE_STATUS = "loungeStatus"
|
||||
const COMMAND_TYPE_REMOTE_CONNECTED = "remoteConnected"
|
||||
const COMMAND_TYPE_REMOTE_DISCONNECTED = "remoteDisconnected"
|
||||
const COMMAND_TYPE_GET_NOW_PLAYING = "getNowPlaying"
|
||||
const COMMAND_TYPE_GET_VOLUME = "getVolume"
|
||||
const COMMAND_TYPE_GET_SUBTITLES_TRACK = "getSubtitlesTrack"
|
||||
const COMMAND_TYPE_UPDATE_PLAYLIST = "updatePlaylist"
|
||||
const COMMAND_TYPE_NOOP = "noop"
|
||||
const COMMAND_TYPE_PLAY = "play"
|
||||
const COMMAND_TYPE_PAUSE = "pause"
|
||||
const COMMAND_TYPE_NEXT = "next"
|
||||
const COMMAND_TYPE_PREVIOUS = "previous"
|
||||
const COMMAND_TYPE_SEEK_TO = "seekTo"
|
||||
const COMMAND_TYPE_SET_VOLUME = "setVolume"
|
||||
const COMMAND_TYPE_STOP_VIDEO = "stopVideo"
|
||||
const COMMAND_TYPE_DPAD_COMMAND = "dpadCommand"
|
||||
const COMMAND_TYPE_VOICE_COMMAND = "voiceCommand"
|
||||
const COMMAND_TYPE_SET_SUBTITLES = "setSubtitlesTrack"
|
||||
const COMMAND_TYPE_ON_USER_ACTIVITY = "onUserActivity"
|
||||
' Special commands
|
||||
const COMMAND_TYPE_SESSION_ID = "c"
|
||||
const COMMAND_TYPE_G_SESSION_ID = "S"
|
||||
' Dpad commands
|
||||
const COMMAND_KEY_UP = "UP"
|
||||
const COMMAND_KEY_DOWN = "DOWN"
|
||||
const COMMAND_KEY_LEFT = "LEFT"
|
||||
const COMMAND_KEY_RIGHT = "RIGHT"
|
||||
const COMMAND_KEY_ENTER = "ENTER"
|
||||
const COMMAND_KEY_BACK = "BACK"
|
||||
' Fields
|
||||
const FIELD_COUNT = "count"
|
||||
const FIELD_OFS = "ofs"
|
||||
const FIELD_COMMAND_NAME = "_sc"
|
||||
const FIELD_STATE = "state"
|
||||
const FIELD_VIDEO_ID = "videoId"
|
||||
const FIELD_VIDEO_IDS = "videoIds"
|
||||
const FIELD_EVENT_DETAILS = "eventDetails"
|
||||
const FIELD_LIST_ID = "listId"
|
||||
const FIELD_CURRENT_TIME = "currentTime"
|
||||
const FIELD_DURATION = "duration"
|
||||
const FIELD_VOLUME = "volume"
|
||||
const FIELD_MUTED = "muted"
|
||||
const FIELD_CPN = "cpn"
|
||||
const FIELD_CTT = "ctt"
|
||||
const FIELD_CURRENT_INDEX = "currentIndex"
|
||||
const FIELD_LOADED_TIME = "loadedTime"
|
||||
const FIELD_SEEKABLE_START_TIME = "seekableStartTime"
|
||||
const FIELD_SEEKABLE_END_TIME = "seekableEndTime"
|
||||
const FIELD_HAS_PREVIOUS = "hasPrevious"
|
||||
const FIELD_HAS_NEXT = "hasNext"
|
||||
const FIELD_NEW_TIME = "newTime"
|
||||
|
||||
enum PlayerState
|
||||
UNSTARTED = -1
|
||||
ENDED = 0
|
||||
PLAYING = 1
|
||||
PAUSED = 2
|
||||
BUFFERING = 3
|
||||
STOPPED = 4
|
||||
VIDEO_CUED = 5
|
||||
ADVERTISEMENT = 1081
|
||||
UNCONFIRMED = -8002
|
||||
ERROR = -8003
|
||||
UNKNOWN = -8001
|
||||
end enum
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
import "pkg:/components/Services/LoungeService/LoungeApi.bs"
|
||||
import "pkg:/source/services/HttpClient.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
@asynctask
|
||||
function LoungeGenerateManualPairingCodeTask(input as object) as object
|
||||
loungeService = input.loungeService
|
||||
|
||||
if StringUtils.IsNullOrEmpty(input.loungeToken)
|
||||
messagePort = CreateObject("roMessagePort")
|
||||
loungeService.observeFieldScoped("loungeToken", messagePort)
|
||||
loungeService.join = true
|
||||
message = wait(30000, messagePort)
|
||||
loungeService.unobserveFieldScoped("loungeToken")
|
||||
if message = invalid or StringUtils.IsNullOrEmpty(message.GetData())
|
||||
return {
|
||||
"success": false
|
||||
"error": "Couldn't join lounge"
|
||||
}
|
||||
end if
|
||||
|
||||
input.screenId = loungeService.screenId
|
||||
input.loungeToken = loungeService.loungeToken
|
||||
end if
|
||||
|
||||
form = {
|
||||
"lounge_token": input.loungeToken
|
||||
"screen_id": input.screenId
|
||||
"screen_name": input.screenName
|
||||
"device_id": input.deviceId
|
||||
}
|
||||
|
||||
for each key in form
|
||||
if StringUtils.IsNullOrEmpty(form[key])
|
||||
return {
|
||||
"success": false
|
||||
"error": key + " is empty"
|
||||
}
|
||||
end if
|
||||
end for
|
||||
|
||||
form["access_type"] = "permanent"
|
||||
form["app"] = "Playlet"
|
||||
|
||||
request = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/get_pairing_code?ctx=pair", "")
|
||||
request.UrlEncodedForm(form)
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
return {
|
||||
"success": false
|
||||
"error": response.ErrorMessage()
|
||||
}
|
||||
end if
|
||||
|
||||
code = response.Text()
|
||||
return {
|
||||
"success": true
|
||||
"code": code
|
||||
}
|
||||
end function
|
||||
@@ -0,0 +1,126 @@
|
||||
import "pkg:/components/Services/LoungeService/LoungeConstants.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace LoungeMessages
|
||||
|
||||
function OnHasPreviousNextChanged(hasPrevious as boolean, hasNext as boolean) as object
|
||||
message = {
|
||||
commandType: COMMAND_ON_PREVIOUS_NEXT_CHANGE
|
||||
}
|
||||
commandArgs = {}
|
||||
commandArgs[FIELD_HAS_PREVIOUS] = hasPrevious
|
||||
commandArgs[FIELD_HAS_NEXT] = hasNext
|
||||
message.commandArgs = commandArgs
|
||||
return message
|
||||
end function
|
||||
|
||||
function OnStateChange(player as object, overrides = invalid as object) as object
|
||||
message = {
|
||||
commandType: COMMAND_ON_STATE_CHANGE
|
||||
}
|
||||
|
||||
commandArgs = {}
|
||||
|
||||
if player = invalid
|
||||
commandArgs[FIELD_STATE] = PlayerState.UNSTARTED
|
||||
message.commandArgs = commandArgs
|
||||
return message
|
||||
end if
|
||||
|
||||
commandArgs[FIELD_STATE] = GetPlayerState(player)
|
||||
commandArgs[FIELD_CURRENT_TIME] = ValidDouble(player.position)
|
||||
commandArgs[FIELD_SEEKABLE_START_TIME] = 0
|
||||
|
||||
content = player.content
|
||||
if content <> invalid
|
||||
metadata = content.metadata
|
||||
if metadata <> invalid
|
||||
lengthSeconds = metadata.lengthSeconds
|
||||
if IsInt(lengthSeconds)
|
||||
commandArgs[FIELD_DURATION] = lengthSeconds
|
||||
commandArgs[FIELD_SEEKABLE_END_TIME] = lengthSeconds
|
||||
|
||||
if commandArgs[FIELD_STATE] = PlayerState.PLAYING or commandArgs[FIELD_STATE] = PlayerState.PAUSED or commandArgs[FIELD_STATE] = PlayerState.BUFFERING
|
||||
commandArgs[FIELD_LOADED_TIME] = lengthSeconds
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
if overrides <> invalid
|
||||
commandArgs.Append(overrides)
|
||||
end if
|
||||
|
||||
message.commandArgs = commandArgs
|
||||
|
||||
return message
|
||||
end function
|
||||
|
||||
function NowPlaying(player as object, overrides = invalid as object) as object
|
||||
message = {
|
||||
commandType: COMMAND_NOW_PLAYING
|
||||
}
|
||||
|
||||
if player = invalid
|
||||
return message
|
||||
end if
|
||||
|
||||
commandArgs = {}
|
||||
|
||||
commandArgs[FIELD_CURRENT_TIME] = ValidDouble(player.position)
|
||||
commandArgs[FIELD_SEEKABLE_START_TIME] = 0
|
||||
commandArgs[FIELD_CURRENT_INDEX] = 0
|
||||
|
||||
commandArgs[FIELD_STATE] = GetPlayerState(player)
|
||||
|
||||
content = player.content
|
||||
if content <> invalid
|
||||
metadata = content.metadata
|
||||
if metadata <> invalid
|
||||
lengthSeconds = metadata.lengthSeconds
|
||||
if IsInt(lengthSeconds)
|
||||
commandArgs[FIELD_DURATION] = lengthSeconds
|
||||
commandArgs[FIELD_SEEKABLE_END_TIME] = lengthSeconds
|
||||
|
||||
if commandArgs[FIELD_STATE] = PlayerState.PLAYING or commandArgs[FIELD_STATE] = PlayerState.PAUSED or commandArgs[FIELD_STATE] = PlayerState.BUFFERING
|
||||
commandArgs[FIELD_LOADED_TIME] = lengthSeconds
|
||||
end if
|
||||
end if
|
||||
videoId = metadata.videoId
|
||||
if not StringUtils.IsNullOrEmpty(videoId)
|
||||
commandArgs[FIELD_VIDEO_ID] = videoId
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
if overrides <> invalid
|
||||
commandArgs.Append(overrides)
|
||||
end if
|
||||
|
||||
message.commandArgs = commandArgs
|
||||
return message
|
||||
end function
|
||||
|
||||
function GetPlayerState(player as object) as PlayerState
|
||||
if player = invalid
|
||||
return PlayerState.UNSTARTED
|
||||
end if
|
||||
|
||||
state = player.state
|
||||
if state = "playing"
|
||||
return PlayerState.PLAYING
|
||||
else if state = "paused"
|
||||
return PlayerState.PAUSED
|
||||
else if state = "buffering"
|
||||
return PlayerState.BUFFERING
|
||||
else if state = "finished"
|
||||
return PlayerState.ENDED
|
||||
else if state = "stopped" or state = "stopping"
|
||||
return PlayerState.STOPPED
|
||||
end if
|
||||
|
||||
return PlayerState.UNSTARTED
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -0,0 +1,130 @@
|
||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||
import "pkg:/components/Services/LoungeService/LoungeApi.bs"
|
||||
|
||||
function Init()
|
||||
m.top.functionName = "LoungeServiceLoop"
|
||||
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
m.top.deviceId = deviceInfo.GetRandomUUID()
|
||||
deviceFriendlyName = deviceInfo.GetFriendlyName()
|
||||
if StringUtils.IsNullOrEmpty(deviceFriendlyName)
|
||||
deviceFriendlyName = "TV"
|
||||
end if
|
||||
m.top.deviceName = "Playlet on " + deviceFriendlyName
|
||||
end function
|
||||
|
||||
function StartService(_unused as dynamic) as boolean
|
||||
if m.top.isRunning = true
|
||||
return true
|
||||
end if
|
||||
|
||||
m.top.control = "run"
|
||||
return true
|
||||
end function
|
||||
|
||||
function StopService(_unused as dynamic) as void
|
||||
if m.top.isRunning = false
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.shouldQuit = true
|
||||
end function
|
||||
|
||||
function LoungeServiceLoop() as void
|
||||
api = new LoungeApi(m.top, m.top.videoQueue, m.top.notifications, m.top.invidious)
|
||||
' Mobile app can remain connected to devices even after restarts.
|
||||
' Since we create a new lounge every time, we signal to the last lounge
|
||||
' that we're no longer there, and we're not coming back.
|
||||
api.DisconnectFromLastLounge()
|
||||
|
||||
messagePort = CreateObject("roMessagePort")
|
||||
|
||||
' We do not join a lounge until something asks us to like
|
||||
' - A remote connects through DIAL
|
||||
' - Generating a TV link code
|
||||
m.top.observeField("join", messagePort)
|
||||
wait(0, messagePort)
|
||||
m.top.unobserveField("join")
|
||||
|
||||
|
||||
screenId = api.GetScreenId()
|
||||
if StringUtils.IsNullOrEmpty(screenId)
|
||||
m.top.isRunning = false
|
||||
return
|
||||
end if
|
||||
m.top.screenId = screenId
|
||||
|
||||
loungeToken = api.GetToken()
|
||||
if StringUtils.IsNullOrEmpty(loungeToken)
|
||||
m.top.isRunning = false
|
||||
return
|
||||
end if
|
||||
m.top.loungeToken = loungeToken
|
||||
|
||||
m.top.observeField("outgoingMessages", messagePort)
|
||||
|
||||
if not api.GetSessionData()
|
||||
m.top.unobserveField("outgoingMessages", messagePort)
|
||||
m.top.isRunning = false
|
||||
return
|
||||
end if
|
||||
|
||||
api.SaveCurrentLoungeData()
|
||||
api.FetchCommandsRpc(messagePort)
|
||||
|
||||
m.top.shouldQuit = false
|
||||
isOpen = false
|
||||
outgoingLoungeMessages = []
|
||||
portMessages = []
|
||||
socketMessages = []
|
||||
|
||||
while true
|
||||
if m.top.shouldQuit = true
|
||||
exit while
|
||||
end if
|
||||
|
||||
message = wait(60000, messagePort)
|
||||
portMessages.Clear()
|
||||
portMessages.Push(message)
|
||||
|
||||
' There's a chance messages were piling up while we were sending messages to the lounge
|
||||
' This could happen if we were sending things to the lounge and the player state
|
||||
' changed many times.
|
||||
while messagePort.PeekMessage() <> invalid
|
||||
portMessages.Push(messagePort.GetMessage())
|
||||
end while
|
||||
|
||||
' At this point:
|
||||
' - We check if we need to send messages to the lounge based on player state
|
||||
' - We check the lounge for new commands, which might need responding to
|
||||
' - Finally, we send the outgoing messages to the lounge in one go
|
||||
outgoingLoungeMessages.Clear()
|
||||
socketMessages.Clear()
|
||||
|
||||
for each portMessage in portMessages
|
||||
messageType = type(portMessage)
|
||||
if messageType = "roSocketEvent"
|
||||
socketMessages.Push(portMessage)
|
||||
else if messageType = "roSGNodeEvent"
|
||||
field = portMessage.GetField()
|
||||
if field = "outgoingMessages"
|
||||
messages = portMessage.GetData()
|
||||
outgoingLoungeMessages.Append(messages)
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
|
||||
isOpen = api.Poll(socketMessages, outgoingLoungeMessages)
|
||||
|
||||
api.SendMessages(outgoingLoungeMessages)
|
||||
api.ProcessPendingOutgoingMessages()
|
||||
|
||||
if not isOpen
|
||||
sleep(3000)
|
||||
api.FetchCommandsRpc(messagePort)
|
||||
end if
|
||||
end while
|
||||
|
||||
m.top.unobserveField("outgoingMessages", messagePort)
|
||||
m.top.isRunning = false
|
||||
end function
|
||||
@@ -0,0 +1,22 @@
|
||||
<component name="LoungeService" extends="Task" includes="AutoBind">
|
||||
<interface>
|
||||
<field id="deviceId" type="string" />
|
||||
<!-- We treat device name and screen name the same -->
|
||||
<field id="deviceName" type="string" />
|
||||
<field id="screenId" type="string" />
|
||||
<field id="loungeToken" type="string" />
|
||||
|
||||
<field id="join" type="boolean" alwaysNotify="true" />
|
||||
<field id="outgoingMessages" type="array" alwaysNotify="true" />
|
||||
|
||||
<field id="videoQueue" type="node" />
|
||||
<field id="notifications" type="node" />
|
||||
<field id="invidious" type="node" />
|
||||
|
||||
<field id="isRunning" type="boolean" />
|
||||
<function name="StartService" />
|
||||
<function name="StopService" />
|
||||
|
||||
<field id="shouldQuit" type="boolean" alwaysNotify="true" />
|
||||
</interface>
|
||||
</component>
|
||||
Loaded 100 of 192 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user