Compare commits

..
112 Commits
Author SHA1 Message Date
Brahim Hadriche 9201b8dfe0 Release v0.17.0 (#205) 2023-11-17 16:37:01 -05:00
Brahim Hadriche cf17fed02e adjust remote repeat keys 2023-11-15 21:13:01 -05:00
Brahim Hadriche f8d202be56 Fix icon, fix ok button long press 2023-11-15 21:03:45 -05:00
Brahim Hadriche af091fe8f7 remote power button 2023-11-15 20:50:10 -05:00
Brahim Hadriche d89b1c519d support long press and touch 2023-11-15 16:22:22 -05:00
Brahim Hadriche dca3e42c79 add keyboard support 2023-11-15 13:32:27 -05:00
Brahim Hadriche 2f72c6471a Adjust remote 2023-11-15 12:05:16 -05:00
Brahim Hadriche 413e73c1c0 [PoC] Web app remote control (#203)
* [PoC] Web app remote control

* Remote UI cleanup

* changelog
2023-11-15 11:49:54 -05:00
Brahim Hadriche 2a57cc99c7 Launch Playlet from web app 2023-11-14 18:49:17 -05:00
Brahim Hadriche d65f930247 Small tweak 2023-11-13 23:13:43 -05:00
Brahim Hadriche ed632a7a62 tweak job 2023-11-13 23:10:08 -05:00
Brahim Hadriche 89ea45ed54 Add update deps job 2023-11-13 23:07:11 -05:00
Brahim Hadriche d7e5732fde Release v0.16.0 (#200) 2023-11-13 22:25:12 -05:00
Brahim Hadriche 9f5a605e8f Small cleanup on content nodes 2023-11-13 22:00:25 -05:00
Brahim Hadriche 45da0880ba Focus current item on queue open 2023-11-13 15:22:21 -05:00
Brahim Hadriche 9e47d4d42e Bug fixes 2023-11-13 15:01:31 -05:00
Brahim Hadriche 3312bbc56e Small refactor 2023-11-13 09:10:52 -05:00
Brahim Hadriche e1cda5cc5c tweak 2023-11-13 09:06:41 -05:00
Brahim Hadriche af0ddf68c5 Adjust queue ui 2023-11-12 17:57:28 -05:00
Brahim Hadricheandgithub-action linter 3559a3fff6 Queue UI (#199)
* Refactor long press

* Lint fix

* Queue UI, refactor PlayQueue to use ContentNode

* Add queue notification hint

* Play at index

* Play queue with highlight

* Priority

* Comment

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-11-12 17:45:00 -05:00
Brahim Hadriche e0709452be Update README.md 2023-11-11 21:55:04 -05:00
Brahim Hadriche 9bbf8dd038 Update README.md 2023-11-11 21:53:54 -05:00
Brahim Hadriche 64d655fca9 Update README.md 2023-11-11 12:11:19 -05:00
Brahim Hadriche ecb738ab1f Small tweak to http retry logging 2023-11-10 18:23:13 -05:00
Brahim Hadriche c14fa7a1d3 [Perf] reduce some rendezvous 2023-11-10 18:14:26 -05:00
Brahim Hadriche 96f24a12a7 Release v0.15.1 (#198) 2023-11-10 17:39:25 -05:00
Brahim Hadriche 665fa44a49 Fix bug with requests not sent 2023-11-10 17:34:31 -05:00
Brahim Hadriche 3c43934081 Set default http request method 2023-11-10 15:32:43 -05:00
Brahim Hadriche e941bc2439 Http client request from object 2023-11-10 13:46:33 -05:00
Brahim Hadriche c35779b211 [shore] update dependencies 2023-11-08 18:04:05 -05:00
Brahim Hadriche 7adb90ccc2 Update README.md 2023-11-08 13:58:53 -05:00
Brahim Hadriche 59ed47108d Fix/error dialog on disposed rowlist (#196)
* Dispose tasks when disposing a view

* Do not show dialog on disposed views
2023-11-08 13:43:21 -05:00
Brahim Hadriche 2eb0cf88af Web app fix (#195) 2023-11-08 13:38:02 -05:00
Brahim Hadriche 38a1d9a950 RowCell bug fix 2023-11-08 08:18:45 -05:00
Brahim Hadriche c1bb059d66 Update download-stats.js 2023-11-07 14:54:58 -05:00
Brahim Hadriche da71382b4a Update stats.yml 2023-11-06 22:08:18 -05:00
Brahim Hadriche 4c32243e6e Add search history preference (#193) 2023-11-06 18:07:21 -05:00
Brahim Hadriche 91be37fd8a Log error message 2023-11-06 17:18:57 -05:00
Brahim Hadriche 54db808b83 move emails to trash once done 2023-11-06 14:01:13 -05:00
Brahim Hadriche 8f722276f3 Delete existing attachments 2023-11-06 13:32:48 -05:00
Brahim Hadriche 3b5d7a9520 format date 2023-11-05 22:39:11 -05:00
Brahim Hadriche 94773d5c3a small tweak 2023-11-05 22:32:42 -05:00
Brahim Hadriche 60fb566a01 Feature/wiki automate (#192)
* change paths

* path adjust

* Fix script

* order change

* Revert "order change"

This reverts commit 4237b4676f7ae277bca7f4cac7414ae1a69ba4dc.

* use imap for attachments

* fix env vars

* add comments
2023-11-05 22:29:52 -05:00
Brahim Hadriche ac9709fc4a Update stats.yml 2023-11-05 18:55:27 -05:00
Brahim Hadriche 1f1a4479da stats test (#189) 2023-11-05 18:53:37 -05:00
Brahim Hadriche 2dcfabdd60 Release v0.15.0 (#188)
* Release v0.15.0

* Changelog
2023-11-05 15:21:20 -05:00
Brahim Hadriche 8f59e3648e Implement retry mechanism (#187)
* Implement retry mechanism

* Set retry count to 3

* web app cache key

* Changelog
2023-11-05 15:11:19 -05:00
Brahim Hadricheandgithub-action linter 4233f30dec Play queue notification (#186)
* Play queue notification

* Lint fix

* change binding

* Add notification preference

* Lint fix

* changelog

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-11-04 20:23:02 -04:00
Brahim Hadriche 777db66bda Fix crash related to fetching subscriptions 2023-11-04 11:12:35 -04:00
Brahim Hadriche 771929d0d8 Channel links in web app 2023-11-01 08:50:55 -04:00
Brahim Hadricheandgithub-action linter 5179de5c74 Subscribe button (#185)
* Subscribe button

* changelog

* Lint fix

* Introduce disposable part

* Lint fix

* revert navigation change

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-10-31 22:47:03 -04:00
Brahim Hadriche e22051014f [Shore] update dependencies 2023-10-31 19:23:27 -04:00
Brahim Hadriche 3eb45653f0 add --compressed flag to curl 2023-10-31 15:44:03 -04:00
Brahim Hadriche 5287070233 adjust loading indicator 2023-10-30 08:38:51 -04:00
Brahim Hadriche d149c20e0d Remove comment 2023-10-29 19:12:29 -04:00
Brahim Hadriche 6cf735e089 Get rid of optional chaining (Roku 11 feature) 2023-10-29 11:38:36 -04:00
Brahim Hadriche af1fa0b401 Refactor casting dialog and add thumbnails (#184) 2023-10-29 00:28:21 -04:00
Brahim Hadriche f58137b326 Fix casting timestamp 2023-10-27 20:01:18 -04:00
Brahim Hadriche 200fb68ab9 link copy/paste fix 2023-10-27 17:34:24 -04:00
Brahim Hadriche bde4523c00 Support copy pasting links in web app 2023-10-27 16:32:11 -04:00
Brahim Hadriche af020b509a Update README.md 2023-10-27 14:52:16 -04:00
Brahim Hadriche 97592f9839 Maximize video if playing on channel exit 2023-10-27 13:22:06 -04:00
Brahim Hadriche 53f8535535 search pagination in web app (#183) 2023-10-27 13:10:20 -04:00
Brahim Hadriche 982dd0cd2e Release v0.14.0 (#181) 2023-10-25 21:32:05 -04:00
Brahim Hadriche 4827537f57 Fix for feed when no videos are loaded 2023-10-25 21:22:22 -04:00
Brahim Hadriche 586925c2da Comment 2023-10-25 20:55:03 -04:00
Brahim Hadriche dd79d85cca Fix "upcoming" videos 2023-10-25 20:51:36 -04:00
Brahim Hadriche 584ee9a38a dash router input validation 2023-10-25 17:06:39 -04:00
Brahim Hadriche 6051d45a80 Support drag and drop links for channels 2023-10-24 19:59:24 -04:00
Brahim Hadriche 549913ef7d Open views (#179)
* adjust todo

* Open view
2023-10-24 17:21:48 -04:00
Brahim Hadriche 8975861615 signing script update 2023-10-24 16:19:23 -04:00
Brahim Hadriche 03e08c99c6 comment 2023-10-24 14:11:29 -04:00
Brahim Hadriche 072b93728a Bookmarks web app part 2 (#178)
* Message for no bookmarks

* feed lazy loading

* cached fetch

* Versioned cache

* comment
2023-10-24 13:41:13 -04:00
Brahim Hadricheandgithub-action linter 57fa1c5c3f Bookmarks in web app (#177)
* Bookmarks api

* Lint fix

* first pass

* Lint fix

* comment

* bookmarks, loading feedSources, and pagination

* comment

* null check

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-10-23 20:39:44 -04:00
Brahim Hadriche 58ce2d6396 ChannelHandle in web app 2023-10-23 20:26:28 -04:00
Brahim Hadriche 837386b6e0 Change playlist view cell to avoid execution timeout 2023-10-23 13:14:47 -04:00
Brahim Hadriche 9baa132ca3 Refactor to reduce chance of execution timeout 2023-10-23 12:40:48 -04:00
Brahim Hadriche ed2ec9bea5 increase resolution of navbar icons 2023-10-22 19:51:01 -04:00
Brahim Hadriche 2bc4d43f51 Search filters in web app (#176) 2023-10-22 18:29:45 -04:00
Brahim Hadriche a61c0afe16 Fix for long press 2023-10-22 16:17:03 -04:00
Brahim Hadriche 6fd34c13d1 A fix for upcoming videos 2023-10-22 16:08:56 -04:00
Brahim Hadriche e1b7500d7c TODOs 2023-10-22 15:35:58 -04:00
7bfe657401 Smooth scroll to top if active screen selected in web UI (#175)
* Smooth scroll to top if active screen selected in web UI

* Use fullname repo

---------

Co-authored-by: agathanonymous <agatha@juggalol.com>
Co-authored-by: Brahim Hadriche <brahim.hadriche@gmail.com>
2023-10-21 20:13:14 -04:00
Brahim Hadriche ceeb2bf37b Show channel handle instead of video count in search (#174) 2023-10-21 16:50:07 -04:00
Brahim Hadriche 3b69140398 Fix for bookmark load order 2023-10-21 16:49:26 -04:00
Brahim Hadriche 25e573a1e1 change debug port 2023-10-20 17:01:32 -04:00
Brahim Hadriche d123393b2f Log warn 2023-10-19 21:33:55 -04:00
Brahim Hadriche 6e0ee8adf4 Canary fallback to latest to avoid issues 2023-10-19 19:33:27 -04:00
Brahim Hadriche 74742c7e28 small tweak 2023-10-19 19:22:40 -04:00
Brahim Hadricheandgithub-action linter c740d5e0a0 Bookmarks (#153)
* Empty bookmarks screen

* Bookmarks object

* Long press support

* Lint fix

* Context menu v1

* A working context menu

* Basic bookmarks in context menu

* Use a root content node for bookmarks

* context menu animation

* small tweak

* move logger around, adjust animation

* Lint fix

* Restore logger fix

* Cache channel info

* Bookmarks v1

* Added comment

* Adjust "popular" feed error handling

* Progress with bookmarks

* Add todo

* add todo

* handle roDateTime logging

* logger adjustment

* Use yaml for api and layout

* rename requestData to feedSource

* Restructure things

* Lint fix

* remove comment

* introduce feedSource id

* small cleanup

* playlist context menu

* Context menu for the channel view

* changelog

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-10-19 19:16:27 -04:00
Brahim Hadriche 620a8a6e2b banner on top 2023-10-18 09:07:11 -04:00
Brahim Hadriche 84835e26e0 dash manifest sorting 2023-10-15 12:58:42 -04:00
Brahim Hadriche 64f3683a22 Add invidious test duration in list 2023-10-14 22:54:13 -04:00
Brahim Hadriche e80fcabae5 Trickplay thumbnails (#169)
* Trickplay thumbnails

* Changelog

* Comment
2023-10-14 17:36:06 -04:00
Brahim Hadriche a12b6cca11 Removed "chapter" from SponsorBlock categories 2023-10-14 15:53:20 -04:00
Brahim Hadriche b2f5ed2275 Add comment 2023-10-14 14:59:12 -04:00
Brahim Hadricheandgithub-action linter fc161ffe4c Feature/local dash (#166)
* Generate dash locally

* Refactor xml gen

* Lint fix

* Add feature flag

* Multi language audio tracks

* Unused var

* Set video expiration to 5 hours

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-10-14 14:44:08 -04:00
Brahim Hadriche fc3629de09 Cache format (#168) 2023-10-14 12:47:09 -04:00
Brahim Hadriche 4efbdda167 Fix for channel view layout (#167)
* Fix for channel view layout

* tweak
2023-10-14 12:08:42 -04:00
Brahim Hadriche 0aad02f5e6 [Shore] update dependencies 2023-10-09 17:43:24 -04:00
Brahim Hadriche ea5ca1c45d Adjust image gen plugin 2023-10-09 11:15:53 -04:00
Brahim Hadriche 9fddd40ff3 Release v0.13.1 (#164) 2023-10-08 12:26:47 -04:00
Brahim Hadriche b489735af9 only regen images on release 2023-10-08 12:11:30 -04:00
Brahim Hadriche 508306c6f4 Refactor image conversion (#163)
* Refactor image conversion

* Docs
2023-10-07 18:21:54 -04:00
Brahim Hadriche 7818f778ea Log video player errors 2023-10-06 09:18:21 -04:00
Brahim Hadriche 6abd18ab85 Handle Popular disabled case (#162) 2023-10-04 18:52:44 -04:00
Brahim Hadriche e8fd7ee35d Fix/bugs (#161)
* Fix for execution timeout

* Multiple bug fixes
2023-10-04 18:16:57 -04:00
Brahim Hadriche deeed05383 Fix button size 2023-10-03 20:46:14 -04:00
Brahim Hadriche 518409cb3f Add todo 2023-10-03 20:41:07 -04:00
Brahim Hadriche a9d7de971b Delete renovate.json 2023-10-03 11:41:13 -04:00
Brahim Hadriche 324543684d Pause/Resume during picture in picture (#156)
* Pause/Resume during picture in picture

* changelog

* changelog
2023-10-02 15:14:24 -04:00
Brahim Hadriche a6f8cb59ee fix filter button again 2023-10-02 15:03:20 -04:00
220 changed files with 7516 additions and 1606 deletions

No files matched your search

+1
View File
@@ -17,6 +17,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Configure repo
run: |
+44
View File
@@ -0,0 +1,44 @@
name: Stats
on:
schedule:
- cron: "0 11 * * *"
workflow_dispatch:
jobs:
update_wiki_stats:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout Wiki
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}.wiki
path: ./playlet.wiki
- name: Configure repo
run: |
git config --local user.email "githubaction@githubaction.com"
git config --local user.name "github-action wiki updater"
working-directory: ./playlet.wiki
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Download attachements
run: node tools/download-stats.js
env:
EMAIL: ${{ secrets.EMAIL }}
EMAIL_APP_PASSWORD: ${{ secrets.EMAIL_APP_PASSWORD }}
- name: Update wiki
run: git add "." && git commit -m "Update stats" --no-verify && git push || true
working-directory: ./playlet.wiki
+36
View File
@@ -0,0 +1,36 @@
name: Update Dependencies
on:
schedule:
- cron: "0 0 * * 6"
workflow_dispatch: {}
jobs:
update_deps:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Update dependencies
run: npm run update-deps
- name: Install dependencies
run: npm ci
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: "update dependencies"
branch: shore/update-deps
title: "[shore] update dependencies"
body: "Weekly pull request to update dependencies."
+6 -2
View File
@@ -18,6 +18,7 @@
"files": [
"**"
],
"componentLibrariesPort": 8086,
"componentLibraries": [
{
"rootDir": "${workspaceFolder}/build/playlet-lib",
@@ -59,7 +60,7 @@
"command": "npm run dev:web",
"request": "launch",
"type": "node-terminal"
},
},
{
"name": "Playlet Web (Chrome)",
"type": "chrome",
@@ -79,7 +80,10 @@
"compounds": [
{
"name": "Playlet Web (Debug)",
"configurations": ["Playlet Web (Dev)", "Playlet Web (Chrome)"],
"configurations": [
"Playlet Web (Dev)",
"Playlet Web (Chrome)"
],
"stopAll": true
}
]
+99
View File
@@ -5,6 +5,105 @@ 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/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.17.0] - 2023-11-17
### Added
- Playlet logo in web app is clickable, and launches app if not already on
- Remote control in web app
- Clickable buttons and keyboard support
## [0.16.0] - 2023-11-13
### Added
- User interface for the Queue: Press and hold `Options (*)` to show the queue
### Fixed
- Crash when video player has no content
- Execution timeout on cirlce posters
## [0.15.1] - 2023-11-10
### Added
- An option to disable search history
### Fixed
- A rare bug that causes the app to crash when displaying video cells
- A bug where we show error dialogs that happened on screens that are already closed
- A bug where bookmarks show duplicate videos
- A bug where watch history is not always sent to Invidious
## [0.15.0] - 2023-11-05
### Added
- Pagination support in web app search (load more button)
- Video links pasted into the web app triggers the dialog to cast the video
- Ability to subscribe/unsubscribe from a channel screen
- This needs additional scope for the Invidious token. You will be logged out, and need to login again. Sorry for the inconvenience.
- A notification when videos are added to the queue (can be disabled from the settings)
### Fixed
- A bug where casting from web included timestamp even if the "Start at" check box is unchecked
- A leak where channel screens would reload data even when closed
- A crash when fetching subscriptions
- Fetching errors by adding a retry mechanism to web requests
## [0.14.0] - 2023-10-25
### Added
- Bookmarks: different items can now be bookmarked, and be found in the `Bookmarks` screen.
Things that can be bookmarked:
- A video
- A channel
- A playlist
- Subscriptions
- Trending
- Popular
- Playlists
- Search results
- Channel tabs (latest videos, live streams, playlists, shorts, podcasts, related channels)
- Context menu: press and hold `OK` to show a context menu to:
- Play/queue a video or a playlist
- Open the channel of a playlist or of a video
- Manage bookmarks
- Local DASH manifest generation
- This adds support for multi languages audio tracks
- Also adds thumbnails/preview in trick play mode
- Known issue: thumbnails might appear cropped/misaligned at the end of videos. This will be addressed in a later release.
- Search filters in web app
- Channels and Playlists can be opened on TV from web app
- Channel links can be drag and dropped into the web app
### Fixed
- Layout in channel view so that the upload time and view count of videos is visible
- A few things in the logger
- A bug where channels show "0 videos". Channel handle is shown instead.
### Changed
- Cache format so it does less parsing work
- Removed "chapter" from SponsorBlock categories
## [0.13.1] - 2023-10-08
### Added
- Support to pause/play while picture-in-picture
### Fixed
- (potentionally) a bug where many dialogs could cause an execution timeout
- Mutltiple rare crashes when component content is set before component initialization
- Error dialog for loading "Popular" when "Popular" is disabled
## [0.13.0] - 2023-10-02
### Added
+17 -6
View File
@@ -1,6 +1,4 @@
# Playlet
<!-- markdownlint-disable MD033 -->
<!-- markdownlint-disable MD033 MD041 -->
<p align="center">
<img src="docs/banner.png" style="display:block;text-align:center" alt="Playlet Logo" width="800"/>
<br/><br/>
@@ -19,6 +17,8 @@
</a>
</p>
# Playlet
Playlet is an unofficial Youtube client for Roku 📺
## Screenshots
@@ -62,14 +62,25 @@ More under [Screenshots](./docs/screenshots/README.md)
### Customize Invidious instance
1. Open settings in Playlet
1. Scan QR Code with Phone
1. Change the Invidious instance
1. You can also do this from the settings tab
1. Select Invidious -> Instance
1. Set a custom instance, or choose a public one hosted by volunteers (from https://api.invidious.io/)
1. Optionally, Select `Test instance` to make sure it works
1. Hit save
> ℹ️ **Note**: If you are logged in when you change the instance, you will remain logged in to the old instance. In this case, Playlet will use the old instance to retrieve your subscriptions and your playlists, but will use the new instance for everything else. After switching to a new instance, you can log out and log in again to use your profile on the new instance.
## Development
For everything related to Playlet app development, please see the [documentation](./docs/README.md)
## Analytics and reporting
We do not collect any usage data, anonymous or not. But Roku does, and you can find the data made available to Playlet in the [Wiki](https://github.com/iBicha/playlet/wiki).
Most software in the wild collect some data to make sure things work, and to prioritize features.
Because we don't do that, we wouldn't know if people using Playlet are facing issues, unless these issues get reported.
Playlet could run on variaty of devices, with different capabilities and screen sizes, and different Invidious instances.
That's why it's important to report any issues you encouter using Playlet, otherwise it's unlikely that they get addressed.
## Why Playlet
```none
+4 -2
View File
@@ -26,7 +26,8 @@
"source/**",
"components/**",
"images/**",
"!images/vector/**",
"!**/*.svg",
"!**/*.svg.meta.json5",
"fonts/**",
"config/**",
"lib/**",
@@ -48,7 +49,8 @@
"../tools/bs-plugins/track-transpiled-plugin.ts",
"../tools/bs-plugins/json-yaml-plugin.ts",
"../tools/bs-plugins/validation-plugin.ts",
"../tools/bs-plugins/logger-plugin.ts"
"../tools/bs-plugins/logger-plugin.ts",
"../tools/bs-plugins/image-gen-plugin.ts"
],
"retainStagingDir": true,
"require": [
+4 -2
View File
@@ -4,7 +4,8 @@
"source/**",
"components/**",
"images/**",
"!images/vector/**",
"!**/*.svg",
"!**/*.svg.meta.json5",
"fonts/**",
"config/**",
"lib/**",
@@ -24,7 +25,8 @@
"../tools/bs-plugins/track-transpiled-plugin.ts",
"../tools/bs-plugins/json-yaml-plugin.ts",
"../tools/bs-plugins/validation-plugin.ts",
"../tools/bs-plugins/logger-plugin.ts"
"../tools/bs-plugins/logger-plugin.ts",
"../tools/bs-plugins/image-gen-plugin.ts"
],
"rooibos": {
"logLevel": 2,
+5 -5
View File
@@ -143,7 +143,7 @@ That's pretty much it.
There are a few reasons we made this separation:
- Playlet relies on [Invidious](https://github.com/iv-org/invidious). Invidious tries to keep up with Youtube making changes to their platform, but sometimes, a breaking change happens that requires Playlet to react quickly. Releasing through the Roku Channel store can take days, or a week. During this time, Playlet would be not functional, and that's not acceptable.
- The ability to roll back: Sometimes an app breaking bug gets released. Allowing users to choose a seperate version is a flexible way to keep things working. Although right now rollbacks are behind a - hidden by default - developer menu, the reasoning still stands.
- The ability to roll back: Sometimes an app breaking bug gets released. Allowing users to choose a seperate version is a flexible way to keep things working. For example, it's possible to choose a different verrsion from the developer settings in the web app.
- It is simply easier to release: Releasing Playlet Lib on Github, and everyone receives the latest version immediately, is very conveninct and less of a hassle, than going through the Roku Channel store.
- I've had instances where I was trying to pass the certfication for Playlet to publish it. One of the criterias is to pass a some automated tests. But the tests were failing because their system could not connect to their Roku test devices (connection keeps timing out). My only option was to keep trying over and over until it worked.
- It might sound that Playlet Lib is just a workaround for the Roku Channel release process. But phrased differently, Roku Channel release process is not good enough of what we need for Playlet.
@@ -185,11 +185,11 @@ Since Component Libraries are simply zip files hosted at some https endpoint, Gi
### Dev library hosted by VS Code Extension
When in debug mode, Playlet lib is packaged and served locally on port 8080, and Playlet app would use it instead of the Playlet lib from Github. This is an important detail, because once you stop debugging in VS Code, the dev app on your Roku TV won't function anymore, with an error:
When in debug mode, Playlet lib is packaged and served locally on port 8086, and Playlet app would use it instead of the Playlet lib from Github. This is an important detail, because once you stop debugging in VS Code, the dev app on your Roku TV won't function anymore, with an error:
> Could not load Playlet component library from any of the following urls:
>
> - \[debug\] http://192.168.1.x:8080/playlet-lib.zip <!-- markdownlint-disable-line -->
> - \[debug\] http://192.168.1.x:8086/playlet-lib.zip <!-- markdownlint-disable-line -->
> Please restart Playlet.
> If the problem persist, contact Playlet authors.
@@ -210,13 +210,13 @@ Additionally, the web server exposes the settings under `/api/preferences`, whic
When Playlet starts, it shows a video feed on the screen. Subscription, Trending videos, and so on.
The layout is defined under [playlet-lib/src/config/default_home_layout.json5](/playlet-lib/src/config/default_home_layout.json5).
The layout is defined under [playlet-lib/src/config/default_home_layout.yaml](/playlet-lib/src/config/default_home_layout.yaml).
This could allow users to define custom layouts, so they can see what they find relevant in the home page. This can include Subscription, Trending, Popular videos, Search per keywords, or Playlists.
Additionally each feed has information on how it is fetched. For now, only Invidious can be data source, but other systems should be configured in the same way.
Invidious API definitions are defined under [playlet-lib/src/config/invidious_video_api.json5](/playlet-lib/src/config/invidious_video_api.json5), and Playlet parses these at runtime and make the right API calls to fetch the data.
Invidious API definitions are defined under [playlet-lib/src/config/invidious_video_api.yaml](/playlet-lib/src/config/invidious_video_api.yaml), and Playlet parses these at runtime and make the right API calls to fetch the data.
Finally, this layout system is what allows both the BrightScript app and the Web app to display the same homepage.
+3 -1
View File
@@ -43,6 +43,8 @@ These are mostly the steps when releasing a new version:
For releasing to the store (when needed), this is done following a Playlet lib release:
- Switch to main branch and pull changes - **match commit corresponding to the release.**
- `npm run build:release`
- `npm run build:release:ci`
- This makes sure to have a valid app in the staging folder
- `npm run sign-released-package`
- This should create the signed package under `release/playlet.pkg`
- Upload to dashboard, and schedule a release (takes a couple of days)
+48
View File
@@ -0,0 +1,48 @@
<!-- TODO:P1 document models better -->
# Models
ApiEndpoint:
- id
- url
- queryParams
- pathParams
- cacheSeconds
- paginationType
- authenticated
- responseHandler
FeedSource:
- id
- title
- apiType: string ("Invidious")
- endpoint: ApiEndpoint
- pathParams
- queryParams
- state:
- paginationtype (Runtime field)
- page (Runtime field)
- continuation (Runtime field)
- queryParams.page (Runtime field)
- queryParams.continuation (Runtime field)
Feed/FeedContentNode:
- Title
- feedSources: FeedSource[]
- feedSourceIndex (Runtime field)
RowListLayout
- Feed[]
Bookmarks
- BookmarkGroup[]
BookmarkGroup
- title
- feedSources: FeedSource[]
+25 -1
View File
@@ -2,7 +2,7 @@ openapi: 3.0.0
info:
title: Playlet Web API
version: 0.13.0
version: 0.17.0
description:
Playlet Web API is a RESTful API for controlling the Playlet app on
Roku devices. The API is intended to be used by the Playlet web app, but can
@@ -204,6 +204,29 @@ paths:
responses:
"204":
description: No Content
/api/view/open:
get:
summary: Open a channel view or a playlist view
description: Open a channel view or a playlist view. If a video is playing in full screen, it is shrinked.
operationId: openView
parameters:
- name: channelId
in: query
description: The ID of the channel to open
required: false
schema:
type: string
- name: playlistId
in: query
description: The ID of the playlist to open
required: false
schema:
type: string
responses:
"204":
description: No Content
"400":
description: Bad Request
/api/playlet-lib-urls:
get:
summary: Get Playlet lib URLs
@@ -515,6 +538,7 @@ components:
type: boolean
sponsorblock.show_notifications:
type: boolean
# TODO:P1 add the rest of properties
PlayQueueObject:
type: object
properties:
+16
View File
@@ -1,6 +1,7 @@
# Playlet Brighterscript Plugins
- [Json5/Yaml support](#json5yaml-support)
- [Convert images](#convert-images)
- [Manifest editing](#manifest-editing)
- [Validation](#validation)
- [Includes](#includes)
@@ -27,6 +28,21 @@ Brightscript can only parse json natively using [ParseJson](https://developer.ro
At the end of the build, the plugin scans for certain files (`jsonc`, `json`, `json5` and `yaml`), and converts them to plain json, while keeping the original file name. That way they are all parsable by the [ParseJson](https://developer.roku.com/en-ca/docs/references/brightscript/language/global-utility-functions.md#parsejsonjsonstring-as-string-flags---as-string-as-object) function, even though their original format is not compatible.
## Convert images
**[Source](/tools/bs-plugins/image-gen-plugin.ts)**
This plugin allows us to convert svg files to png files.
### Why
This is used to convert splash screen, app poster, as well as icons in the app. Having svg images (or vector images in general) as the source of truth is better, in case images need to be modified or resized. Since Roku can't load them, we convert them to png.
### How
Each `.svg` file found will have an associated `.svg.meta.json5` file, which will contain the hash (MD5) of the svg, conversion paramters, and the hash of the output files. This allows us to hash existing files and see if a conversion is needed.
Notice how each `.svg` file can be configured to generate multiple png files. This is especially the case to generate the app artwork (splash screen/poster) with different sizes from the same logo `.svg` file.
## Manifest editing
**[Source](/tools/bs-plugins/manifest-edit-plugin.ts)**
+372 -53
View File
@@ -1,37 +1,41 @@
{
"name": "playlet",
"version": "0.13.0",
"version": "0.17.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet",
"version": "0.13.0",
"version": "0.17.0",
"hasInstallScript": true,
"devDependencies": {
"@rokucommunity/bslint": "^0.8.10",
"@types/fs-extra": "^11.0.2",
"@types/node": "^20.7.2",
"@types/xml2js": "^0.4.12",
"@rokucommunity/bslint": "^0.8.12",
"@types/crypto-js": "^4.2.1",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.9.0",
"@types/xml2js": "^0.4.14",
"argparse": "^2.0.1",
"brighterscript": "^0.65.7",
"brighterscript-formatter": "^1.6.33",
"brighterscript": "^0.65.9",
"brighterscript-formatter": "^1.6.35",
"convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0",
"crypto-js": "^4.2.0",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"fs-extra": "^11.1.1",
"glob": "^10.3.10",
"imap": "^0.8.19",
"ip": "^1.1.8",
"json5": "^2.2.3",
"roku-deploy": "^3.10.3",
"rooibos-roku": "^5.7.0",
"mailparser": "^3.6.5",
"roku-deploy": "^3.10.4",
"rooibos-roku": "^5.8.0",
"semver": "^7.5.4",
"shelljs": "^0.8.5",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"xml2js": "^0.6.2",
"yaml": "^2.3.2"
"yaml": "^2.3.4"
},
"engines": {
"node": "18"
@@ -272,9 +276,9 @@
"dev": true
},
"node_modules/@rokucommunity/bslint": {
"version": "0.8.10",
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.10.tgz",
"integrity": "sha512-2aaWPtt5xACm7sIaKR5ctF7f3HrjKGfTVSAT6ZGdojDsXPQanHK2+XyYX20fQVdjJFVn414UCfVkUiaO0PTtog==",
"version": "0.8.12",
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.12.tgz",
"integrity": "sha512-0kU6sHpjEq51f54ajzscxzLT5Tq7SjF8FPszr7pRMSmUHHIDmTu5e1vDu8gS5UzWM+RGhXHqa3EXXt789B6sdQ==",
"dev": true,
"dependencies": {
"fs-extra": "^10.0.0",
@@ -303,6 +307,19 @@
"node": ">=12"
}
},
"node_modules/@selderee/plugin-htmlparser2": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.11.0.tgz",
"integrity": "sha512-P33hHGdldxGabLFjPPpaTxVolMrzrcegejx+0GxjrIb9Zv48D8yAIA/QTDR2dFl7Uz7urX8aX6+5bCZslr+gWQ==",
"dev": true,
"dependencies": {
"domhandler": "^5.0.3",
"selderee": "^0.11.0"
},
"funding": {
"url": "https://ko-fi.com/killymxi"
}
},
"node_modules/@tsconfig/node10": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz",
@@ -327,10 +344,16 @@
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
"dev": true
},
"node_modules/@types/crypto-js": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.2.1.tgz",
"integrity": "sha512-FSPGd9+OcSok3RsM0UZ/9fcvMOXJ1ENE/ZbLfOPlBWj7BgXtEAM8VYfTtT760GiLbQIMoVozwVuisjvsVwqYWw==",
"dev": true
},
"node_modules/@types/fs-extra": {
"version": "11.0.2",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.2.tgz",
"integrity": "sha512-c0hrgAOVYr21EX8J0jBMXGLMgJqVf/v6yxi0dLaJboW9aQPh16Id+z6w2Tx1hm+piJOLv8xPfVKZCLfjPw/IMQ==",
"version": "11.0.4",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.4.tgz",
"integrity": "sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==",
"dev": true,
"dependencies": {
"@types/jsonfile": "*",
@@ -347,15 +370,18 @@
}
},
"node_modules/@types/node": {
"version": "20.7.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.2.tgz",
"integrity": "sha512-RcdC3hOBOauLP+r/kRt27NrByYtDjsXyAuSbR87O6xpsvi763WI+5fbSIvYJrXnt9w4RuxhV6eAXfIs7aaf/FQ==",
"dev": true
"version": "20.9.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz",
"integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/@types/xml2js": {
"version": "0.4.12",
"resolved": "https://registry.npmjs.org/@types/xml2js/-/xml2js-0.4.12.tgz",
"integrity": "sha512-CZPpQKBZ8db66EP5hCjwvYrLThgZvnyZrPXK2W+UI1oOaWezGt34iOaUCX4Jah2X8+rQqjvl9VKEIT8TR1I0rA==",
"version": "0.4.14",
"resolved": "https://registry.npmjs.org/@types/xml2js/-/xml2js-0.4.14.tgz",
"integrity": "sha512-4YnrRemBShWRO2QjvUin8ESA41rH+9nQGLUGZV/1IDhi3SL9OhdpNC/MrulTWuptXKwhx/aDxE7toV0f/ypIXQ==",
"dev": true,
"dependencies": {
"@types/node": "*"
@@ -702,9 +728,9 @@
}
},
"node_modules/brighterscript": {
"version": "0.65.7",
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.7.tgz",
"integrity": "sha512-cmV0JzlYuKIKkMsbHR2FyaD2YugHeHESdMmUOtK61EsEUS895Y6yXftDVnFUwij7beLiZR6s1oRpMfiS7MJ40g==",
"version": "0.65.9",
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.9.tgz",
"integrity": "sha512-cjJmftkY+2A5HrGIbmRz2fylywEwj3+Y/EXeSx4TJsEvOW0/M61G5gHRdGyqPF/TMEGlPHGlTBAmPdOMi85+xw==",
"dev": true,
"dependencies": {
"@rokucommunity/bslib": "^0.1.1",
@@ -730,7 +756,7 @@
"parse-ms": "^2.1.0",
"readline": "^1.3.0",
"require-relative": "^0.8.7",
"roku-deploy": "^3.10.3",
"roku-deploy": "^3.10.4",
"serialize-error": "^7.0.1",
"source-map": "^0.7.4",
"vscode-languageserver": "7.0.0",
@@ -745,12 +771,12 @@
}
},
"node_modules/brighterscript-formatter": {
"version": "1.6.33",
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.6.33.tgz",
"integrity": "sha512-XmirSAOBBHsprJvLOuh8nzXNiPQJXQa2NJ581OZdQrofFdBNPGH+yFhV6XXUZ+pA6fVLSxMxXA0toF83jtKjrA==",
"version": "1.6.35",
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.6.35.tgz",
"integrity": "sha512-OtExVLvgfZ7QlBDFpNqDUZQiSbO8sNO1l0wEfkspYJzPbhbhKYL2NEEL9OSTzUJYCrO/I8ZL7bo57ZGNQlcNBQ==",
"dev": true,
"dependencies": {
"brighterscript": "^0.65.7",
"brighterscript": "^0.65.9",
"glob-all": "^3.3.0",
"jsonc-parser": "^3.0.0",
"source-map": "^0.7.3",
@@ -1507,6 +1533,12 @@
"node": ">= 8"
}
},
"node_modules/crypto-js": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==",
"dev": true
},
"node_modules/css-select": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz",
@@ -1557,9 +1589,9 @@
}
},
"node_modules/dayjs": {
"version": "1.11.8",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.8.tgz",
"integrity": "sha512-LcgxzFoWMEPO7ggRv1Y2N31hUf2R0Vj7fuy/m+Bg1K8rr+KAs1AEy4y9jd5DXe8pbHgX+srkHNS7TH6Q6ZhYeQ==",
"version": "1.11.10",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz",
"integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==",
"dev": true
},
"node_modules/debounce-promise": {
@@ -1586,6 +1618,15 @@
"node": ">=0.10.0"
}
},
"node_modules/deepmerge": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
"integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
@@ -1744,6 +1785,15 @@
"iconv-lite": "^0.6.2"
}
},
"node_modules/encoding-japanese": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encoding-japanese/-/encoding-japanese-2.0.0.tgz",
"integrity": "sha512-++P0RhebUC8MJAwJOsT93dT+5oc5oPImp1HubZpAuCZ5kTLnhuuBhKHj2jJeO/Gj93idPBWmIuQ9QWMe5rX3pQ==",
"dev": true,
"engines": {
"node": ">=8.10.0"
}
},
"node_modules/encoding/node_modules/iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
@@ -1925,9 +1975,9 @@
"dev": true
},
"node_modules/fast-glob": {
"version": "3.2.12",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz",
"integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==",
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
"integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==",
"dev": true,
"dependencies": {
"@nodelib/fs.stat": "^2.0.2",
@@ -2365,6 +2415,31 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/he": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
"dev": true,
"bin": {
"he": "bin/he"
}
},
"node_modules/html-to-text": {
"version": "9.0.5",
"resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-9.0.5.tgz",
"integrity": "sha512-qY60FjREgVZL03vJU6IfMV4GDjGBIoOyvuFdpBDIX9yTlDw0TjxVBQp+P8NvpdIXNJvfWBTNul7fsAQJq2FNpg==",
"dev": true,
"dependencies": {
"@selderee/plugin-htmlparser2": "^0.11.0",
"deepmerge": "^4.3.1",
"dom-serializer": "^2.0.0",
"htmlparser2": "^8.0.2",
"selderee": "^0.11.0"
},
"engines": {
"node": ">=14"
}
},
"node_modules/htmlparser2": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz",
@@ -2482,6 +2557,43 @@
}
]
},
"node_modules/imap": {
"version": "0.8.19",
"resolved": "https://registry.npmjs.org/imap/-/imap-0.8.19.tgz",
"integrity": "sha512-z5DxEA1uRnZG73UcPA4ES5NSCGnPuuouUx43OPX7KZx1yzq3N8/vx2mtXEShT5inxB3pRgnfG1hijfu7XN2YMw==",
"dev": true,
"dependencies": {
"readable-stream": "1.1.x",
"utf7": ">=1.0.2"
},
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/imap/node_modules/isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==",
"dev": true
},
"node_modules/imap/node_modules/readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==",
"dev": true,
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"node_modules/imap/node_modules/string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==",
"dev": true
},
"node_modules/immediate": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
@@ -2735,6 +2847,51 @@
"lcov-parse": "bin/cli.js"
}
},
"node_modules/leac": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/leac/-/leac-0.6.0.tgz",
"integrity": "sha512-y+SqErxb8h7nE/fiEX07jsbuhrpO9lL8eca7/Y1nuWV2moNlXhyd59iDGcRf6moVyDMbmTNzL40SUyrFU/yDpg==",
"dev": true,
"funding": {
"url": "https://ko-fi.com/killymxi"
}
},
"node_modules/libbase64": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/libbase64/-/libbase64-1.2.1.tgz",
"integrity": "sha512-l+nePcPbIG1fNlqMzrh68MLkX/gTxk/+vdvAb388Ssi7UuUN31MI44w4Yf33mM3Cm4xDfw48mdf3rkdHszLNew==",
"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==",
"dev": true,
"dependencies": {
"encoding-japanese": "2.0.0",
"iconv-lite": "0.6.3",
"libbase64": "1.2.1",
"libqp": "2.0.1"
}
},
"node_modules/libmime/node_modules/iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"dev": true,
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/libqp": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/libqp/-/libqp-2.0.1.tgz",
"integrity": "sha512-Ka0eC5LkF3IPNQHJmYBWljJsw0UvM6j+QdKRbWyCdTmYwvIDE6a7bCm0UkTAL/K+3KXK5qXT/ClcInU01OpdLg==",
"dev": true
},
"node_modules/lie": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz",
@@ -2744,6 +2901,15 @@
"immediate": "~3.0.5"
}
},
"node_modules/linkify-it": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-4.0.1.tgz",
"integrity": "sha512-C7bfi1UZmoj8+PQx22XyeXCuBlokoyWQL5pWSP+EI6nzRylyThouddufc2c1NDIcP9k5agmN9fLpA7VNJfIiqw==",
"dev": true,
"dependencies": {
"uc.micro": "^1.0.1"
}
},
"node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
@@ -2756,6 +2922,12 @@
"node": ">=8"
}
},
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"node_modules/lodash.omit": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.omit/-/lodash.omit-4.5.0.tgz",
@@ -2807,6 +2979,70 @@
"node": ">=12"
}
},
"node_modules/mailparser": {
"version": "3.6.5",
"resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.6.5.tgz",
"integrity": "sha512-nteTpF0Khm5JLOnt4sigmzNdUH/6mO7PZ4KEnvxf4mckyXYFFhrtAWZzbq/V5aQMH+049gA7ZjfLdh+QiX2Uqg==",
"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",
"linkify-it": "4.0.1",
"mailsplit": "5.4.0",
"nodemailer": "6.9.3",
"tlds": "1.240.0"
}
},
"node_modules/mailparser/node_modules/iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"dev": true,
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/mailsplit": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/mailsplit/-/mailsplit-5.4.0.tgz",
"integrity": "sha512-wnYxX5D5qymGIPYLwnp6h8n1+6P6vz/MJn5AzGjZ8pwICWssL+CCQjWBIToOVHASmATot4ktvlLo6CyLfOXWYA==",
"dev": true,
"dependencies": {
"libbase64": "1.2.1",
"libmime": "5.2.0",
"libqp": "2.0.1"
}
},
"node_modules/mailsplit/node_modules/iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"dev": true,
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/mailsplit/node_modules/libmime": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/libmime/-/libmime-5.2.0.tgz",
"integrity": "sha512-X2U5Wx0YmK0rXFbk67ASMeqYIkZ6E5vY7pNWRKtnNzqjvdYYG8xtPDpCnuUEnPU9vlgNev+JoSrcaKSUaNvfsw==",
"dev": true,
"dependencies": {
"encoding-japanese": "2.0.0",
"iconv-lite": "0.6.3",
"libbase64": "1.2.1",
"libqp": "2.0.1"
}
},
"node_modules/make-error": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
@@ -2963,6 +3199,15 @@
}
}
},
"node_modules/nodemailer": {
"version": "6.9.3",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.3.tgz",
"integrity": "sha512-fy9v3NgTzBngrMFkDsKEj0r02U7jm6XfC3b52eoNV+GCrGj+s8pt5OqhiJdWKuw51zCTdiNR/IUD1z33LIIGpg==",
"dev": true,
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
@@ -3142,6 +3387,19 @@
"url": "https://github.com/inikulin/parse5?sponsor=1"
}
},
"node_modules/parseley": {
"version": "0.12.1",
"resolved": "https://registry.npmjs.org/parseley/-/parseley-0.12.1.tgz",
"integrity": "sha512-e6qHKe3a9HWr0oMRVDTRhKce+bRO8VGQR3NyVwcjwrbhMmFCX9KszEV35+rn4AdilFAq9VPxP/Fe1wC9Qjd2lw==",
"dev": true,
"dependencies": {
"leac": "^0.6.0",
"peberminta": "^0.9.0"
},
"funding": {
"url": "https://ko-fi.com/killymxi"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
@@ -3224,6 +3482,15 @@
"integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==",
"dev": true
},
"node_modules/peberminta": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/peberminta/-/peberminta-0.9.0.tgz",
"integrity": "sha512-XIxfHpEuSJbITd1H3EeQwpcZbTLHc+VVr8ANI9t5sit565tsI4/xK3KWTUFE2e6QiangUkh3B0jihzmGnNrRsQ==",
"dev": true,
"funding": {
"url": "https://ko-fi.com/killymxi"
}
},
"node_modules/pend": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
@@ -3359,9 +3626,9 @@
}
},
"node_modules/punycode": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz",
"integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==",
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
"dev": true,
"engines": {
"node": ">=6"
@@ -3656,9 +3923,9 @@
}
},
"node_modules/roku-deploy": {
"version": "3.10.3",
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.10.3.tgz",
"integrity": "sha512-COJSQ638QklcM+8AN1nujFuzT04rTZLFuLSww35edm8w/y0l60oF/Iu7TQ46m75DwoGFzGFfomLEmA1ltQk9mA==",
"version": "3.10.4",
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.10.4.tgz",
"integrity": "sha512-Drl0c78HjZejaC0zovm4f/pJRCw0DbbBzR5Pe+ADKlMfOSJuF4UvNaejJzgbTcGXKkeztgOBvu5xxpOL7gqhWQ==",
"dev": true,
"dependencies": {
"chalk": "^2.4.2",
@@ -3669,6 +3936,7 @@
"is-glob": "^4.0.3",
"jsonc-parser": "^2.3.0",
"jszip": "^3.6.0",
"lodash": "^4.17.21",
"micromatch": "^4.0.4",
"moment": "^2.29.1",
"parse-ms": "^2.1.0",
@@ -3726,9 +3994,9 @@
}
},
"node_modules/rooibos-roku": {
"version": "5.7.0",
"resolved": "https://registry.npmjs.org/rooibos-roku/-/rooibos-roku-5.7.0.tgz",
"integrity": "sha512-rkEAaowZeuLbwvtBcRZ1r5ber2yeBRqjxcwya9kfYQmDJ+m2XP8pGO9j10C0eW9hx6H7ZZl+5z1oHjnjwQsmBQ==",
"version": "5.8.0",
"resolved": "https://registry.npmjs.org/rooibos-roku/-/rooibos-roku-5.8.0.tgz",
"integrity": "sha512-mPAszwOH1VdxMgSaoXQ/CgpAZ3RQ0A+d3BoxyY8axMsYS5kPO/8dL8fa7iFTGEZYA7803Ur52zlyN8GXqV5nLg==",
"dev": true,
"dependencies": {
"source-map": "^0.7.3",
@@ -3829,6 +4097,18 @@
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==",
"dev": true
},
"node_modules/selderee": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/selderee/-/selderee-0.11.0.tgz",
"integrity": "sha512-5TF+l7p4+OsnP8BCCvSyZiSPc4x4//p5uPwK8TCnVPJYRmU2aYKMpOXvw8zM5a5JvuuCGN1jmsMwuU2W02ukfA==",
"dev": true,
"dependencies": {
"parseley": "^0.12.0"
},
"funding": {
"url": "https://ko-fi.com/killymxi"
}
},
"node_modules/semver": {
"version": "7.5.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
@@ -4004,9 +4284,9 @@
}
},
"node_modules/sshpk": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz",
"integrity": "sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ==",
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.18.0.tgz",
"integrity": "sha512-2p2KJZTSqQ/I3+HX42EpYOa2l3f8Erv8MWKsy2I9uf4wA7yFIkXRffYdsx86y6z4vHtV8u7g+pPlr8/4ouAxsQ==",
"dev": true,
"dependencies": {
"asn1": "~0.2.3",
@@ -4196,6 +4476,15 @@
"integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==",
"dev": true
},
"node_modules/tlds": {
"version": "1.240.0",
"resolved": "https://registry.npmjs.org/tlds/-/tlds-1.240.0.tgz",
"integrity": "sha512-1OYJQenswGZSOdRw7Bql5Qu7uf75b+F3HFBXbqnG/ifHa0fev1XcG+3pJf3pA/KC6RtHQzfKgIf1vkMlMG7mtQ==",
"dev": true,
"bin": {
"tlds": "bin.js"
}
},
"node_modules/tmp": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz",
@@ -4322,6 +4611,12 @@
"node": ">=14.17"
}
},
"node_modules/uc.micro": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz",
"integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==",
"dev": true
},
"node_modules/unbzip2-stream": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz",
@@ -4338,6 +4633,12 @@
"integrity": "sha512-vohX7ywgBjRxDNw+f3wHclSXmO0z9HsEfmGObOuG7G0yi7kZ6OtCG8kAxtDSNklmua5KR6ev2drTFqMGqpYEbg==",
"dev": true
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
},
"node_modules/universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
@@ -4375,6 +4676,24 @@
"requires-port": "^1.0.0"
}
},
"node_modules/utf7": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/utf7/-/utf7-1.0.2.tgz",
"integrity": "sha512-qQrPtYLLLl12NF4DrM9CvfkxkYI97xOb5dsnGZHE3teFr0tWiEZ9UdgMPczv24vl708cYMpe6mGXGHrotIp3Bw==",
"dev": true,
"dependencies": {
"semver": "~5.3.0"
}
},
"node_modules/utf7/node_modules/semver": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
"integrity": "sha512-mfmm3/H9+67MCVix1h+IXTpDwL6710LyHuk7+cWC9T1mE0qz4iHhh6r4hU2wrIT9iTsAAC2XQRvfblL028cpLw==",
"dev": true,
"bin": {
"semver": "bin/semver"
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
@@ -4680,9 +4999,9 @@
"dev": true
},
"node_modules/yaml": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.2.tgz",
"integrity": "sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==",
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz",
"integrity": "sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==",
"dev": true,
"engines": {
"node": ">= 14"
+15 -11
View File
@@ -1,31 +1,35 @@
{
"name": "playlet",
"version": "0.13.0",
"version": "0.17.0",
"description": "Unofficial Youtube client for Roku",
"devDependencies": {
"@rokucommunity/bslint": "^0.8.10",
"@types/fs-extra": "^11.0.2",
"@types/node": "^20.7.2",
"@types/xml2js": "^0.4.12",
"@rokucommunity/bslint": "^0.8.12",
"@types/crypto-js": "^4.2.1",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.9.0",
"@types/xml2js": "^0.4.14",
"argparse": "^2.0.1",
"brighterscript": "^0.65.7",
"brighterscript-formatter": "^1.6.33",
"brighterscript": "^0.65.9",
"brighterscript-formatter": "^1.6.35",
"convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0",
"crypto-js": "^4.2.0",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"fs-extra": "^11.1.1",
"glob": "^10.3.10",
"imap": "^0.8.19",
"ip": "^1.1.8",
"json5": "^2.2.3",
"roku-deploy": "^3.10.3",
"rooibos-roku": "^5.7.0",
"mailparser": "^3.6.5",
"roku-deploy": "^3.10.4",
"rooibos-roku": "^5.8.0",
"semver": "^7.5.4",
"shelljs": "^0.8.5",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"xml2js": "^0.6.2",
"yaml": "^2.3.2"
"yaml": "^2.3.4"
},
"engines": {
"node": "18"
@@ -52,10 +56,10 @@
"test:build:app": "cd playlet-app && npm run test:build",
"test:lib": "cd playlet-lib && npm run test",
"test:build:lib": "cd playlet-lib && npm run test:build",
"generate-images": "node tools/generate-images.js",
"version-sync": "node tools/version-sync.js",
"manifest-git-hash": "node tools/update-manifest-git-hash.js",
"sign-package": "node tools/sign-package.js",
"sign-released-package": "node tools/sign-released-package.js",
"screenshot": "node tools/screenshot.js",
"profile-sync": "node tools/profile-sync.js",
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-app",
"version": "0.13.0",
"version": "0.17.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-app",
"version": "0.13.0"
"version": "0.17.0"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-app",
"version": "0.13.0",
"version": "0.17.0",
"description": "Unofficial Youtube client for Roku",
"scripts": {
"prebuild": "rm -rf build/playlet-app",
@@ -4,7 +4,7 @@
<field id="launchArgs" type="assocarray" />
<field id="inputArgs" type="assocarray" alwaysNotify="true" />
<field id="playletLibLoadedUrl" type="assocarray" />
<field id="systemLogEvent" type="assocarray" />
<field id="systemLogEvent" type="assocarray" alwaysNotify="true" />
</interface>
<script type="text/brightscript" uri="pkg:/source/Dialog.bs" />
<script type="text/brightscript" uri="pkg:/source/Manifest.bs" />
@@ -14,12 +14,10 @@ function PositionSpinner()
centerx = (1280 - m.busyspinner.poster.width) / 2
centery = (720 - m.busyspinner.poster.height) / 2
m.busyspinner.translation = [centerx, centery]
m.busyspinner.visible = true
end if
end function
function OnVisibleChange()
m.busyspinner.visible = m.top.visible
if m.busyspinner.visible
m.busyspinner.control = "start"
else
@@ -0,0 +1,26 @@
{
inputHash: '0536f51fa72c2e4e368ea0e901aadfc1',
outputs: [
{
outputFilePath: 'images/splash-screen_fhd.jpg',
outputHash: 'b15f3a3f1ccc459cbca12cb828b78d16',
width: 1920,
height: 1080,
background: '#242424',
},
{
outputFilePath: 'images/splash-screen_hd.jpg',
outputHash: '25e9c4220f8a42101d6333e548e33aa8',
width: 1280,
height: 720,
background: '#242424',
},
{
outputFilePath: 'images/splash-screen_sd.jpg',
outputHash: 'c54a2f7fa65f443263806962450f2c04',
width: 720,
height: 480,
background: '#242424',
},
],
}
@@ -0,0 +1,4 @@
{
inputHash: 'd61131ccc714d8df0b4514ca76883494',
outputs: [],
}
@@ -0,0 +1,26 @@
{
inputHash: '3452c6ea1c84f59aedf5530bf86a7a51',
outputs: [
{
outputFilePath: 'images/channel-poster_fhd.png',
outputHash: 'd644a0db84deed0bcc41a41d08a4ef75',
width: 540,
height: 405,
background: '#FFFFFF',
},
{
outputFilePath: 'images/channel-poster_hd.png',
outputHash: 'd07a4ffaa021b55528bee91710f4e9d2',
width: 290,
height: 218,
background: '#FFFFFF',
},
{
outputFilePath: 'images/channel-poster_sd.png',
outputHash: '66a311c639f89ff009e4624468282b2f',
width: 246,
height: 140,
background: '#FFFFFF',
},
],
}
+3 -3
View File
@@ -2,14 +2,14 @@ title=Playlet
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=13
minor_version=17
build_version=00000
ui_resolutions=hd
## Channel Assets
### Main Menu Icons / Channel Poster Artwork
#### Image sizes are FHD: 540x405px | HD: 290x218px | SD: 214x144px
#### Image sizes are FHD: 540x405px | HD: 290x218px | SD: 246x140px
mm_icon_focus_fhd=pkg:/images/channel-poster_fhd.png
mm_icon_focus_hd=pkg:/images/channel-poster_hd.png
mm_icon_focus_sd=pkg:/images/channel-poster_sd.png
@@ -29,7 +29,7 @@ supports_input_launch=1
playlet_lib_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.zip
playlet_lib_embedded_url=pkg:/lib/playlet-lib.zip
playlet_lib_debug_url=http://DEBUG_HOST_IP_ADDRESS:8080/playlet-lib.zip
playlet_lib_debug_url=http://DEBUG_HOST_IP_ADDRESS:8086/playlet-lib.zip
git_commit_sha=unknown
+3
View File
@@ -1,4 +1,5 @@
function ShowErrorDialog(message as object, bulletText as object, bottomMessage as object)
' TODO:P2 a null check on StandardMessageDialog, only available on 10.0 and later
dialog = CreateObject("roSGNode", "StandardMessageDialog")
dialog.message = message
dialog.bulletText = bulletText
@@ -19,5 +20,7 @@ function OnButtonSelected()
end function
function OnDialogClosed()
' TODO:P1 throw an exception to cause a crash report to be generated
' Should include which playlet lib failed to load
m.top.getScene().exitChannel = true
end function
+13 -18
View File
@@ -1,5 +1,5 @@
' Playlet (App to play videos from an Invidious server on Roku TVs)
' Copyright (C) 2022 Brahim Hadriche
' Copyright (C) 2023 Brahim Hadriche
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU Affero General Public License as published by
@@ -28,16 +28,16 @@ function Main(args as object) as void
scene.ObserveField("exitChannel", port)
scene.launchArgs = args
' These vars are needed to pass certification.
' The actual work is done in Playlet Lib
' bs:disable-next-line LINT1005
contentId = args.contentId
' bs:disable-next-line LINT1005
mediaType = args.mediaType
' Do not signal app launch complete here, we're doing it over at Playlet Lib
' This is needed to pass cetification
if false
' These vars are needed to pass certification.
' The actual work is done in Playlet Lib
' bs:disable-next-line LINT1005
contentId = args.contentId
' bs:disable-next-line LINT1005
mediaType = args.mediaType
' Do not signal app launch complete here, we're doing it over at Playlet Lib
' This is needed to pass cetification
scene.signalBeacon("AppLaunchComplete")
end if
@@ -66,7 +66,9 @@ function Main(args as object) as void
msg = wait(0, port)
msgType = type(msg)
if msgType = "roSystemLogEvent"
scene.systemLogEvent = msg.GetInfo()
info = msg.GetInfo()
info.DateTime = info.DateTime.ToISOString()
scene.systemLogEvent = info
else if msgType = "roSGScreenEvent"
if msg.isScreenClosed()
return
@@ -83,10 +85,3 @@ function Main(args as object) as void
end while
end function
function ClearPlayletLibUrlsIfNeeded(launchArgs as object) as void
if launchArgs = invalid or launchArgs.clearPlayletLibUrls = invalid
return
end if
DeleteRegistryKey("playlet_lib_urls", "Playlet")
end function
+7
View File
@@ -20,3 +20,10 @@ function GetPlayletLibUrlsFromRegistry() as object
urls = ParseJson(urlsJson)
return urls
end function
function ClearPlayletLibUrlsIfNeeded(launchArgs as object) as void
if launchArgs = invalid or launchArgs.clearPlayletLibUrls = invalid
return
end if
DeleteRegistryKey("playlet_lib_urls", "Playlet")
end function
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-lib",
"version": "0.13.0",
"version": "0.17.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-lib",
"version": "0.13.0"
"version": "0.17.0"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-lib",
"version": "0.13.0",
"version": "0.17.0",
"description": "Unofficial Youtube client for Roku",
"scripts": {
"prebuild": "rm -rf build/playlet-lib",
@@ -1,4 +1,6 @@
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:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Logging.bs"
@@ -10,6 +12,7 @@ function Init()
end function
function OnNodeReady()
InitializeLongPress(["options"])
NodeSetFocus(m.top.root, true)
end function
@@ -78,12 +81,50 @@ function GetRootScreen(screenName as string) as object
end function
function onKeyEvent(key as string, press as boolean) as boolean
if LongPressHandler(key, press)
return true
end if
if key = OPTIONS_LONG_PRESS_KEY and press
LogInfo("Opening PlayQueueView")
PlayQueueViewUtils.Open(m.top.playQueue, m.top)
return true
end if
if key = "options" and not press
if VideoUtils.ToggleVideoPictureInPicture()
return true
end if
end if
if not press
return false
end if
if key = "options"
VideoUtils.ToggleVideoPictureInPicture()
else if key = "back"
if key = "play"
if VideoUtils.TogglePause()
return true
end if
end if
if key = "pause"
if VideoUtils.PauseVideo()
return true
end if
end if
if key = "playonly"
if VideoUtils.ResumeVideo()
return true
end if
end if
if key = "back"
if VideoUtils.IsVideoPlayerOpen() and not VideoUtils.IsVideoPlayerFullScreen()
if VideoUtils.ToggleVideoPictureInPicture()
return true
end if
end if
dialog = DialogUtils.ShowDialogButtons("Do you want to exit Playlet?", "Exit", ["Exit", "Cancel"])
dialog.observeField("buttonSelected", FuncName(OnExitDialog), ["buttonSelected"])
return true
@@ -2,6 +2,7 @@
<interface>
<field id="root" type="node" />
<field id="stack" type="node" />
<field id="playQueue" type="node" />
<function name="PushScreen" />
<function name="PopScreen" />
<function name="FocusTopScreen" />
@@ -1,7 +1,10 @@
namespace ChannelUtils
function Open(contentNode as object)
function Open(contentNode as object, appController = invalid as object)
channelView = CreateObject("roSGNode", "ChannelView")
m.appController@.PushScreen(channelView)
if appController = invalid
appController = m.appController
end if
appController@.PushScreen(channelView)
channelView@.BindNode(invalid)
channelView.content = contentNode
end function
@@ -1,18 +1,28 @@
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/source/asyncTask/asyncTask.bs"
import "pkg:/source/utils/DisposableObserve.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
import "SubscribeTask.bs"
function Init()
m.container = m.top.findNode("container")
m.scrollAnimation = m.top.findNode("scrollAnimation")
m.scrollAnimationInterpolator = m.scrollAnimation.findNode("scrollAnimationInterpolator")
m.containerTranslation = m.scrollAnimation.findNode("containerTranslation")
m.bannerTranslation = m.scrollAnimation.findNode("bannerTranslation")
m.banner = m.top.findNode("banner")
m.thumbnail = m.top.findNode("thumbnail")
m.authorLabel = m.top.findNode("authorLabel")
m.subscribeButton = m.top.findNode("subscribeButton")
m.rowList = m.top.FindNode("rowList")
m.rowList.focusable = true
m.rowList.screen = m.top
m.banner.ObserveField("loadStatus", FuncName(OnBannerLoadStatus))
DisposableObserveField(m.banner, "loadStatus", FuncName(OnBannerLoadStatus))
m.author = ""
m.authorId = ""
InitializeTabs()
@@ -20,6 +30,17 @@ end function
function OnNodeready()
m.rowList@.BindNode(invalid)
SetNavigation(m.rowList, "up", m.subscribeButton)
SetNavigation(m.subscribeButton, "down", m.rowList)
m.subscribeButton.text = "Subscribe"
DisposableObserveField(m.subscribeButton, "buttonSelected", FuncName(OnSubscribeButtonSelected))
SetSubscribeButtonVisibility()
DisposableObserveFieldScoped(m.invidious, "authToken", FuncName(SetSubscribeButtonVisibility))
OnSubscriptionChanged()
DisposableObserveFieldScoped(m.invidious, "subscriptions", FuncName(OnSubscriptionChanged))
end function
function OnFocusChange() as void
@@ -33,12 +54,12 @@ end function
function OnContentSet() as void
content = m.top.content
if content = invalid
m.top.authorId = ""
return
end if
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.authorLabel.text = content._author
' TODO:P1 handle case where there's no banner - a big portion of the screen is blank
m.banner.uri = content.banner
if StringUtils.IsNullOrEmpty(content.thumbnail)
m.thumbnail.uri = ""
@@ -52,13 +73,17 @@ function OnContentSet() as void
content@.LoadChannel(m.invidious)
authorId = ValidString(content.authorId)
if authorId <> m.authorId and IsArray(content.tabs)
author = ValidString(content._author)
m.top.authorId = authorId
if (authorId <> m.authorId or author <> m.author) and IsArray(content.tabs)
m.authorId = authorId
m.rowList.contentData = CreateChannelFeeds(m.authorId, content.tabs)
m.author = author
m.rowList.feeds = CreateChannelFeeds(m.authorId, author, content.tabs)
end if
end function
function CreateChannelFeeds(authorId as string, tabs as object) as object
function CreateChannelFeeds(authorId as string, author as string, tabs as object) as object
if authorId = ""
return invalid
end if
@@ -67,13 +92,17 @@ function CreateChannelFeeds(authorId as string, tabs as object) as object
for i = 0 to tabs.count() - 1
tabName = tabs[i]
if m.tabs.DoesExist(tabName)
feeds.Push(m.tabs[tabName](authorId))
feeds.Push(m.tabs[tabName](authorId, author))
end if
end for
return feeds
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
@@ -87,6 +116,25 @@ end function
function Close()
m.appController@.PopScreen(invalid)
m.top.dispose = true
end function
function OnDispose()
m.rowList.dispose = true
DisposeObservers()
end function
function OnSubscribeButtonSelected()
if m.subscribeTask <> invalid
m.subscribeTask.cancel = true
end if
isSubbed = IsSubscribed()
m.subscribeTask = StartAsyncTask(SubscribeTask, {
invidious: m.invidious,
ucid: m.authorId,
subscribe: not isSubbed
})
end function
function OnBannerLoadStatus() as void
@@ -95,49 +143,111 @@ function OnBannerLoadStatus() as void
return
end if
aspect = m.banner.bitmapWidth / m.banner.bitmapHeight
m.banner.height = m.banner.width / aspect
m.banner.translation = [0, -m.banner.height]
bannerAspect = m.banner.bitmapWidth / m.banner.bitmapHeight
bannerHeight = m.banner.width / bannerAspect
m.banner.height = bannerHeight
m.banner.translation = [0, -bannerHeight]
m.banner.visible = true
startPos = [0, -bannerHeight]
endPos = [0, 0]
midPos = [0, (startPos[1] + endPos[1]) / 2]
m.bannerTranslation.keyValue = [startPos, midPos, endPos]
startPos = [0, 0]
endPos = [0, m.banner.height]
midPos = [0, m.banner.height / 2]
endPos = [0, bannerHeight - m.thumbnail.height * 0.4]
midPos = [0, (startPos[1] + endPos[1]) / 2]
m.containerTranslation.keyValue = [startPos, midPos, endPos]
m.scrollAnimationInterpolator.keyValue = [startPos, midPos, endPos]
m.scrollAnimation.control = "start"
end function
function InitializeTabs()
m.tabs = {
videos: function(authorId as string) as object
return CreateChannelFeed("Latest videos", "channel_videos", authorId)
videos: function(authorId as string, author as string) as object
return CreateChannelFeed("Latest videos", "channel_videos", authorId, author)
end function,
shorts: function(authorId as string) as object
return CreateChannelFeed("Shorts", "channel_shorts", authorId)
shorts: function(authorId as string, author as string) as object
return CreateChannelFeed("Shorts", "channel_shorts", authorId, author)
end function,
streams: function(authorId as string) as object
return CreateChannelFeed("Live", "channel_streams", authorId)
streams: function(authorId as string, author as string) as object
return CreateChannelFeed("Live", "channel_streams", authorId, author)
end function,
podcasts: function(authorId as string) as object
return CreateChannelFeed("Podcasts", "channel_podcasts", authorId)
podcasts: function(authorId as string, author as string) as object
return CreateChannelFeed("Podcasts", "channel_podcasts", authorId, author)
end function,
playlists: function(authorId as string) as object
return CreateChannelFeed("Playlists", "channel_playlists", authorId)
playlists: function(authorId as string, author as string) as object
return CreateChannelFeed("Playlists", "channel_playlists", authorId, author)
end function,
channels: function(authorId as string) as object
return CreateChannelFeed("Channels", "channel_channels", authorId)
channels: function(authorId as string, author as string) as object
return CreateChannelFeed("Channels", "channel_channels", authorId, author)
end function
}
end function
function CreateChannelFeed(title as string, endpoint as string, ucid as string) as object
function CreateChannelFeed(title as string, endpoint as string, ucid as string, author as string) as object
return {
title: title,
apiType: "Invidious",
endpoint: endpoint,
pathParams: {
ucid: ucid
}
feedSources: [{
"id": `inv_${endpoint}_${ucid}`,
"title": `${author} - ${title}`,
"apiType": "Invidious",
"endpoint": endpoint,
"pathParams": {
"ucid": ucid
}
}]
}
end function
function GetContextMenuOptionsForItem(video as object) as object
if StringUtils.IsNullOrEmpty(m.top.authorId)
return []
end if
return m.bookmarks@.GetMenuForChannel(m.top.content)
end function
function IsLoggedIn() as boolean
return m.invidious.authToken <> invalid
end function
function IsSubscribed() as boolean
authorId = m.top.authorId
if StringUtils.IsNullOrEmpty(authorId)
return false
end if
subscriptions = m.invidious.subscriptions
if subscriptions = invalid
return false
end if
if not subscriptions.DoesExist(authorId)
return false
end if
return subscriptions[authorId]
end function
function OnAuthorIdChange()
SetSubscribeButtonVisibility()
OnSubscriptionChanged()
end function
function SetSubscribeButtonVisibility()
isLogged = IsLoggedIn()
m.subscribeButton.visible = isLogged and not StringUtils.IsNullOrEmpty(m.top.authorId)
m.subscribeButton.focusable = m.subscribeButton.visible
if not m.subscribeButton.visible and m.subscribeButton.hasFocus()
NodeSetFocus(m.rowList, true)
end if
end function
function OnSubscriptionChanged()
isSubbed = IsSubscribed()
if isSubbed
m.subscribeButton.text = "Unsubscribe"
else
m.subscribeButton.text = "Subscribe"
end if
end function
@@ -1,8 +1,10 @@
<component name="ChannelView" extends="Group" includes="AutoBind,Focus">
<component name="ChannelView" extends="Group" includes="AutoBind,Focus,ContextMenuProvider,Disposable">
<interface>
<field id="content" type="node" onChange="OnContentSet" />
<field id="authorId" type="string" onChange="OnAuthorIdChange" />
<field id="appController" type="node" bind="/AppController" />
<field id="invidious" type="node" bind="/Invidious" />
<field id="bookmarks" type="node" bind="/Bookmarks" />
</interface>
<children>
<Rectangle
@@ -11,12 +13,12 @@
color="0x242424">
</Rectangle>
<Group id="container">
<Poster
id="banner"
width="1280"
visible="false" />
<Poster
id="banner"
width="1280"
visible="false" />
<Group id="container">
<Poster
translation="[115,20]"
width="104"
@@ -27,7 +29,8 @@
id="thumbnail"
width="100"
height="100"
translation="[2,2]" />
translation="[2,2]"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg" />
<Label
id="authorLabel"
@@ -35,6 +38,14 @@
font="font:MediumBoldSystemFont" />
</Poster>
<Button
id="subscribeButton"
iconUri=""
focusedIconUri=""
showFocusFootprint="true"
minWidth="200"
translation="[930,64]" />
<VideoRowList
itemComponentName="RowCell"
id="rowList"
@@ -57,7 +68,11 @@
delay="0.3"
duration="0.6">
<Vector2DFieldInterpolator
id="scrollAnimationInterpolator"
id="bannerTranslation"
key="[ 0.0, 0.5, 1.0 ]"
fieldToInterp="banner.translation" />
<Vector2DFieldInterpolator
id="containerTranslation"
key="[ 0.0, 0.5, 1.0 ]"
fieldToInterp="container.translation" />
</Animation>
@@ -0,0 +1,35 @@
import "pkg:/components/Services/Invidious/InvidiousService.bs"
@asynctask
function SubscribeTask(input as object) as object
invidiousNode = input.invidious
ucid = input.ucid
subscribe = input.subscribe
if m.top.cancel
return invalid
end if
service = new Invidious.InvidiousService(invidiousNode)
if subscribe
response = service.Subscribe(ucid)
else
response = service.Unsubscribe(ucid)
end if
if not response.IsSuccess()
error = response.ErrorMessage()
LogError("Failed to subscribe/unsubscribe to channel:", error)
return {
success: false,
error: error
}
end if
invidiousNode.refreshSubscribtions = true
return {
success: true
}
end function
@@ -4,21 +4,30 @@ function Init()
end function
function UpdateMaskSize()
width = m.top.poster.width
height = m.top.poster.height
width = m.top.width
height = m.top.height
maskSize = [width * GetScaleFactor(), height * GetScaleFactor()]
m.top.maskGroup.maskSize = maskSize
m.top.maskSize = [width * GetUIScaleFactor(), height * GetUIScaleFactor()]
end function
' MaskGroup component do not scale with with UI resolution
function GetScaleFactor() as float
if m.scaleFactor <> invalid
return m.scaleFactor
function GetUIScaleFactor() as float
if m.uiScaleFactor <> invalid
return m.uiScaleFactor
end if
if m.global.uiScaleFactor <> invalid
return m.global.uiScaleFactor
end if
deviceInfo = CreateObject("roDeviceInfo")
uiResolutionWidth = deviceInfo.GetUIResolution().width
' divide by 1280 because we have ui_resolutions=hd in manifest
m.scaleFactor = uiResolutionWidth / 1280
return m.scaleFactor
m.uiScaleFactor = uiResolutionWidth / 1280
if not m.global.hasField("uiScaleFactor")
m.global.addField("uiScaleFactor", "float", false)
end if
m.global.uiScaleFactor = m.uiScaleFactor
return m.uiScaleFactor
end function
@@ -11,6 +11,7 @@
<field id="loadStatus" type="string" alias="Poster.loadStatus" />
<field id="maskUri" type="uri" value="pkg:/images/circle-mask-500.png" alias="MaskGroup.maskuri" />
<field id="maskSize" type="vector2d" alias="MaskGroup.maskSize" />
</interface>
<children>
<MaskGroup
@@ -0,0 +1,5 @@
<component name="BookmarkContentNode" extends="ContentNode">
<interface>
<field id="feedSource" type="assocarray" />
</interface>
</component>
@@ -1,21 +1,23 @@
<component name="ChannelContentNode" extends="ContentNode">
<interface>
<field id="type" type="string" value="channel" />
<field id="loadState" type="string" />
<function name="LoadChannel" />
<field id="type" type="string" value="channel" />
<field id="loadState" type="string" />
<!-- index in a feed -->
<field id="feedSourcesIndex" type="integer" value="-1" />
<field id="HDItemWidth" type="float" value="196" />
<!-- NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation -->
<field id="_author" type="string" />
<field id="authorId" type="string" />
<field id="banner" type="string" />
<field id="channelHandle" type="string" />
<field id="description" type="string" />
<field id="subCount" type="integer" />
<field id="subCountText" type="string" />
<field id="tabs" type="array" />
<field id="thumbnail" type="string" />
<field id="videoCount" type="integer" />
<field id="videoCountText" type="string" />
<field id="thumbnail" type="string" />
<field id="banner" type="string" />
<field id="tabs" type="array" />
<field id="HDItemWidth" type="float" value="196" />
</interface>
</component>
@@ -0,0 +1,7 @@
<component name="ContextMenuItemContentNode" extends="ContentNode">
<interface>
<field id="node" type="node" />
<field id="func" type="string" />
<field id="args" type="array" />
</interface>
</component>
@@ -1,9 +1,7 @@
<component name="FeedContentNode" extends="ContentNode">
<interface>
<field id="feed" type="assocarray" />
<field id="feedSources" type="array" />
<field id="feedSourcesIndex" type="integer" />
<field id="loadState" type="string" />
<field id="paginationType" type="string" />
<field id="page" type="integer" value="0" />
<field id="continuation" type="string" />
</interface>
</component>
@@ -2,7 +2,9 @@
<interface>
<field id="type" type="string" value="playlist" />
<field id="loadState" type="string" />
<!--
<!-- index in a feed -->
<field id="feedSourcesIndex" type="integer" value="-1" />
<!--
For some strange reason, the "author" field can only be set once.
If you try to set it again, it will not be updated, with type mismatch warning:
@@ -20,16 +22,19 @@
Although we use the field "author" in other components, this is the only place where we modify it after
we set it for the first time (because a saved Playlist belongs to the Invidious user at first, but then
we can query it's original owner)
The issue happens on PlaylistContentNode and ChannelContentNode, but not VideoContentNode.
-->
<field id="_author" type="string" />
<field id="authorId" type="string" />
<field id="playlistId" type="string" />
<field id="thumbnail" type="uri" />
<field id="thumbnailBackground" type="uri" />
<field id="updated" type="integer" />
<field id="updatedText" type="string" />
<field id="videoCount" type="integer" value="-1" />
<field id="videoCountText" type="string" />
<field id="viewCount" type="integer" />
<field id="viewCountText" type="string" />
<field id="updated" type="integer" />
<field id="updatedText" type="string" />
</interface>
</component>
@@ -1,11 +1,13 @@
<component name="VideoContentNode" extends="ContentNode">
<interface>
<field id="type" type="string" value="video" />
<field id="author" type="string" />
<field id="hlsUrl" type="uri" />
<!-- index in a playlist -->
<field id="index" type="integer" value="-1" />
<!-- index in a feed -->
<field id="feedSourcesIndex" type="integer" value="-1" />
<field id="author" type="string" />
<field id="authorId" type="string" />
<field id="isUpcoming" type="boolean" />
<field id="lengthSeconds" type="integer" />
<field id="lengthText" type="string" />
@@ -0,0 +1,171 @@
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
' TODO:P0 Web app support
' TODO:P0 Web apis and open api spec updates
'
' From the main screen:
' When a video is selected:
' - "Play" - DONE
' - "Queue" - DONE
' - "Open Channel" - DONE
' - "Add to "Videos" bookmark" - DONE
' - If video is already in a bookmark, "Remove from Bookmarks" - DONE
'
' When a channel is selected:
' - "Open" - DONE
' - "Add to "Channels" bookmark" - DONE
' - "Add to <ChannelName> bookmark" - DONE
' - If channel is already in a bookmark, "Remove from Bookmarks" - DONE
' - PlaylistId starting with "IV" cannot be added to a bookmark - DONE
'
' When a playlist is selected:
' - "Play" - DONE
' - "Queue" - DONE
' - "Open" - DONE
' - "Add to "Playlists" bookmark" - DONE
' - "Add to <PlaylistName> bookmark" - DONE
' - If playlist is already in a bookmark, "Remove from Bookmarks" - DONE
' When any:
' - "Reload feed" - DONE
'
' From Playlist view:
' When a video is selected:
' - "Play" - DONE
' - "Queue" - DONE
' - "Play video" - DONE
' - "Queue video" - DONE
' - "Open Channel" - DONE
' - "Add to "Playlists" bookmark" - DONE
' - "Add to <PlaylistName> bookmark" - DONE
' - "Add to "Videos" bookmark" - DONE
'
' From Channel view:
' When a video is selected:
' - "Play" - DONE
' - "Queue" - DONE
' - "Add to "Channels" bookmark" - DONE
' - "Add to <ChannelName> - <feed> bookmark" feed being latest videos, live, shorts, etc - DONE
' - "Add to "Videos" bookmark" - DONE
'
' When a playlist is selected:
' - "Play" - DONE
' - "Queue" - DONE
' - "Open" - DONE
' - "Add to "Channels" bookmark" - DONE
' - "Add to <ChannelName> - <feed> bookmark" feed being latest videos, live, shorts, etc - DONE
' - "Add to "Playlists" bookmark" - DONE
' - "Add to <PlaylistName> bookmark" - DONE
'
' From search view:
' When a video/channel/playlist is selected:
' - Inherit options - DONE
' - "Add to "Search - ${q}" bookmark" - this includes the search filters used - DONE
'
' From bookmarks view:
' When a video/channel/playlist is selected:
' - Inherit options
' - "Remove item from Bookmarks"
' - "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
' - Add to "Channels" bookmark
' - Other "Channels" related context menu items
' - Playlist
' - Add to "Playlists" bookmark
' - "Play/Queue"
' - Other "Playlists" related context menu items
function Init()
m.optionsList = m.top.findNode("optionsList")
m.showAnimation = m.top.findNode("showAnimation")
end function
function Show(unsued as dynamic)
m.optionsList.ObserveField("itemSelected", FuncName(OnItemSelected))
m.showAnimation.control = "start"
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
NodeSetFocus(m.optionsList, true)
end function
function OnOptionsSet() as void
options = m.top.options
if options = invalid
return
end if
content = CreateObject("roSGNode", "ContentNode")
for each option in options
optionNode = CreateObject("roSGNode", "ContentNode")
optionNode.title = option.title
content.appendChild(optionNode)
end for
m.optionsList.content = content
end function
function OnItemSelected(event as object) as void
index = event.getData()
button = m.optionsList.content.getChild(index)
Close()
LogInfo("Menu button selected:", button.title)
options = m.top.options
if index >= options.count()
LogError("Menu button index out of range:", index)
return
end if
option = options[index]
node = option.node
func = option.func
args = option.args
if node = invalid or StringUtils.IsNullOrEmpty(func) or args = invalid
LogError("Menu button action is invalid")
return
end if
if args.count() = 1
node.callFunc(func, args[0])
else if args.count() = 2
node.callFunc(func, args[0], args[1])
else if args.count() = 3
node.callFunc(func, args[0], args[1], args[2])
else if args.count() = 4
node.callFunc(func, args[0], args[1], args[2], args[3])
else if args.count() = 5
node.callFunc(func, args[0], args[1], args[2], args[3], args[4])
else
LogError("Menu button action has too many arguments")
end if
end function
function OnkeyEvent(key as string, press as boolean) as boolean
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(invalid)
end function
@@ -0,0 +1,70 @@
<component name="ContextMenu" extends="Group" includes="Focus">
<interface>
<field id="thumbnail" type="uri" alias="thumbnail.uri" />
<field id="title" type="string" alias="titleLabel.text" />
<field id="subtitle" type="string" alias="subtitleLabel.text" />
<field id="options" type="nodearray" onChange="OnOptionsSet" />
<field id="appController" type="node" />
<function name="Show" />
</interface>
<children>
<Rectangle
id="background"
width="1280"
height="720"
color="#000000"
opacity="0" />
<Rectangle
id="container"
width="470"
height="720"
translation="[-470,0]"
color="0x242424">
<Poster
id="thumbnail"
width="190"
height="110"
loadDisplayMode="scaleToFit"
translation="[40,50]" />
<LayoutGroup
translation="[40,180]"
itemSpacings="[10]">
<Label
id="titleLabel"
width="390"
maxLines="2"
font="font:MediumBoldSystemFont"
wrap="true" />
<Label
id="subtitleLabel"
width="390"
font="font:SmallestBoldSystemFont"
wrap="true" />
</LayoutGroup>
<MarkupList
id="optionsList"
itemSize="[420,50]"
translation="[25,310]"
itemComponentName="ContextMenuRow"
vertFocusAnimationStyle="floatingFocus"
numRows="8" />
</Rectangle>
<Animation id="showAnimation"
duration="0.3"
optional="true">
<FloatFieldInterpolator
id="fadeInterpolator"
key="[0.0, 0.5, 1.0]"
keyValue="[0.0, 0.4, 0.8]"
fieldToInterp="background.opacity" />
<Vector2DFieldInterpolator
id="translationInterpolator"
key="[0.0, 0.5, 1.0]"
keyValue="[[-470,0], [-235,0], [0,0]]"
fieldToInterp="container.translation" />
</Animation>
</children>
</component>
@@ -0,0 +1,29 @@
function OnContentSet() as void
content = m.top.itemContent
if content = invalid
return
end if
m.top.text = content.title
end function
function OnItemHasFocus()
hasFocus = m.top.itemHasFocus
if hasFocus
m.top.font = "font:SmallestBoldSystemFont"
m.top.color = "0x262626ff"
else
m.top.font = "font:SmallestSystemFont"
m.top.color = "0xddddddff"
end if
end function
function OnFocusPercent()
if m.top.focusPercent > 0.5
m.top.font = "font:SmallestBoldSystemFont"
m.top.color = "0x262626ff"
else
m.top.font = "font:SmallestSystemFont"
m.top.color = "0xddddddff"
end if
end function
@@ -0,0 +1,19 @@
<component name="ContextMenuRow" extends="Group">
<interface>
<field id="text" type="string" alias="label.text" />
<field id="font" type="node" alias="label.font" />
<field id="color" type="color" alias="label.color" />
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="itemHasFocus" type="boolean" onChange="OnItemHasFocus" />
<field id="listHasFocus" type="boolean" />
<field id="focusPercent" type="float" onChange="OnFocusPercent" />
</interface>
<children>
<ScrollingLabel
id="label"
maxWidth="420"
height="50"
vertAlign="center"
font="font:SmallestSystemFont" />
</children>
</component>
@@ -0,0 +1,76 @@
import "pkg:/source/utils/Logging.bs"
namespace ContextMenuUtils
function Open(providers as object, appController as object, item as object) as object
if item = invalid
return invalid
end if
options = GetOptions(item, providers)
if options.Count() = 0
LogWarn("No context menu options available for item")
return invalid
end if
contextMenu = CreateObject("roSGNode", "ContextMenu")
contextMenu.appController = appController
appController@.PushScreen(contextMenu)
ContextMenuUtils.SetItem(contextMenu, item)
contextMenu.options = options
contextMenu@.Show(invalid)
return contextMenu
end function
function SetItem(contextMenu as object, item as object)
title = ""
subtitle = ""
thumbnail = ""
if item.type = "video"
LogInfo("Opening context menu for video:", item.videoId)
title = item.title
subtitle = item.author
thumbnail = item.thumbnail
else if item.type = "playlist"
LogInfo("Opening context menu for playlist:", item.playlistId)
title = item.title
subtitle = item._author
thumbnail = item.thumbnail
else if item.type = "channel"
LogInfo("Opening context menu for channel:", item.authorId)
title = item._author
thumbnail = item.thumbnail
end if
contextMenu.title = title
contextMenu.subtitle = subtitle
contextMenu.thumbnail = thumbnail
end function
function GetOptions(item as object, providers as object) as object
allOptions = []
for each provider in providers
if provider <> invalid and provider.hasField("supportsContextMenu") and provider.supportsContextMenu = true
options = provider@.GetContextMenuOptionsForItem(item)
if options <> invalid
allOptions.append(options)
end if
end if
end for
return allOptions
end function
function CreateOption(title as string, node as object, func as string, args as object) as object
option = CreateObject("roSGNode", "ContextMenuItemContentNode")
option.title = title
option.node = node
option.func = func
option.args = args
return option
end function
end namespace
@@ -12,9 +12,12 @@ namespace DialogUtils
dialog.title = title
dialog.buttons = buttons
if large
deviceInfo = CreateObject("roDeviceInfo")
displaySize = deviceInfo.GetDisplaySize()
dialog.width = displaySize.w - 100
if m._deviceDisplayWidth = invalid
deviceInfo = CreateObject("roDeviceInfo")
displaySize = deviceInfo.GetDisplaySize()
m._deviceDisplayWidth = displaySize.w
end if
dialog.width = m._deviceDisplayWidth - 100
end if
m.top.getScene().dialog = dialog
return dialog
+1
View File
@@ -1,4 +1,5 @@
import "pkg:/components/VideoPlayer/VideoUtils.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
+14 -1
View File
@@ -1,3 +1,4 @@
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/Types.bs"
function Init()
@@ -13,6 +14,18 @@ function Init()
end if
m.port = port
StartLogger(m.top)
end function
function StartLogger(logger as object, logLevel = LogLevel.Info as LogLevel) as void
if m.global.logger <> invalid
return
end if
logger.logLevel = logLevel
m.global.addFields({ logger: logger })
logger.control = "run"
end function
function LoggerLoop()
@@ -54,7 +67,7 @@ function OnLineSysLog(event as object, logsFile as string, buffer as object) as
if info.LogType <> "http.error"
return
end if
line = `[SysLog] ${FormatJson(info)}`
line = "[ERROR][SysLog] " + ToString(info)
' bs:disable-next-line LINT3012
print line
+1 -1
View File
@@ -1,7 +1,7 @@
<component name="Logger" extends="Task">
<interface>
<field id="logLevel" type="int" value="2" />
<field id="logLine" type="string" />
<field id="logLine" type="string" alwaysNotify="true" />
<field id="folder" type="string" value="cachefs:/logs" />
<field id="filename" type="string" value="app_logs.txt" />
<field id="filenamePrevious" type="string" value="app_logs_previous.txt" />
-3
View File
@@ -1,11 +1,8 @@
import "pkg:/components/EcpArgs.bs"
import "pkg:/components/parts/AutoBind/AutoBind.part.bs"
import "pkg:/source/utils/LoadingScreen.bs"
import "pkg:/source/utils/Logging.bs"
function Init()
InitializeLogger()
m.scene = m.top.getScene()
' At this point, the "MainScene" node is not yet added to the scene, and does not have a parent yet.
' Let's wait until it has one.
@@ -1,11 +1,9 @@
'import "pkg:/components/EcpArgs.bs"
'import "pkg:/components/parts/AutoBind/AutoBind.part.bs"
'import "pkg:/source/utils/LoadingScreen.bs"
'import "pkg:/source/utils/Logging.bs"
function Init()
InitializeBindings() ' auto-generated!
InitializeLogger()
m.scene = m.top.getScene()
' At this point, the "MainScene" node is not yet added to the scene, and does not have a parent yet.
' Let's wait until it has one.
@@ -9,23 +9,26 @@
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/AutoBind.part.brs" />
<script type="text/brightscript" uri="pkg:/components/MainScene_bindings.brs" />
<script type="text/brightscript" uri="pkg:/components/MainScene.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/Logging.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/LoadingScreen.brs" />
<script type="text/brightscript" uri="pkg:/components/EcpArgs.brs" />
<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">
<ContentNode role="items">
<NavBarItem screen="SearchScreen" text="Search" icon="pkg:/images/icons/search.png" canFocus="true" />
<NavBarItem screen="HomeScreen" text="Home" icon="pkg:/images/icons/home.png" canFocus="true" />
<NavBarItem screen="SettingsScreen" text="Settings" icon="pkg:/images/icons/settings.png" canFocus="true" />
<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="AppInfoScreen" text="Info" icon="pkg:/images/icons/info.png" />
</ContentNode>
@@ -37,6 +40,8 @@
<PlayQueue id="PlayQueue" />
<ApplicationInfo id="ApplicationInfo" />
<Preferences id="Preferences" />
<Bookmarks id="Bookmarks" />
<SearchHistory id="SearchHistory" />
<Invidious id="Invidious" />
<PlayletWebServer id="WebServer" port="8888" />
</AppController>
+23 -9
View File
@@ -1,6 +1,11 @@
<component name="MainScene" extends="Group" includes="AutoBind">
<children>
<AppController id="AppController" root="bind:./AppRoot" stack="bind:./Stack">
<!-- Logger should remain the first child, to make sure it is initialized first in the scene -->
<Logger id="Logger" />
<AppController id="AppController"
root="bind:./AppRoot"
stack="bind:./Stack"
playQueue="bind:./PlayQueue">
<Group id="Stack">
<AppRoot id="AppRoot">
<NavBar id="NavBar" focusIndex="1" appController="bind:/AppController">
@@ -8,20 +13,22 @@
<NavBarItem
screen="SearchScreen"
text="Search"
icon="pkg:/images/icons/search.png"
canFocus="true">
icon="pkg:/images/icons/search.png">
</NavBarItem>
<NavBarItem
screen="HomeScreen"
text="Home"
icon="pkg:/images/icons/home.png"
canFocus="true">
icon="pkg:/images/icons/home.png">
</NavBarItem>
<NavBarItem
screen="BookmarksScreen"
text="Bookmarks"
icon="pkg:/images/icons/star.png">
</NavBarItem>
<NavBarItem
screen="SettingsScreen"
text="Settings"
icon="pkg:/images/icons/settings.png"
canFocus="true">
icon="pkg:/images/icons/settings.png">
</NavBarItem>
<NavBarItem
screen="WebAppScreen"
@@ -43,9 +50,14 @@
<!-- No render nodes -->
<PlayQueue id="PlayQueue"
invidious="bind:../Invidious" />
invidious="bind:../Invidious"
notifications="bind:../Notifications"
preferences="bind:../Preferences" />
<ApplicationInfo id="ApplicationInfo" />
<Preferences id="Preferences" />
<Bookmarks id="Bookmarks" />
<SearchHistory id="SearchHistory"
preferences="bind:../Preferences" />
<Invidious id="Invidious"
webServer="bind:../WebServer"
@@ -55,10 +67,12 @@
<PlayletWebServer
id="WebServer"
port="8888"
appController="bind:/AppController"
applicationInfo="bind:../ApplicationInfo"
invidious="bind:../Invidious"
preferences="bind:../Preferences"
playQueue="bind:../PlayQueue" />
playQueue="bind:../PlayQueue"
bookmarks="bind:../Bookmarks" />
</AppController>
</children>
</component>
@@ -7,13 +7,19 @@ function InitializeBindings()
childProps: {
"AppController": {
"root": "./AppRoot",
"stack": "./Stack"
"stack": "./Stack",
"playQueue": "./PlayQueue"
},
"NavBar": {
"appController": "/AppController"
},
"PlayQueue": {
"invidious": "../Invidious"
"invidious": "../Invidious",
"notifications": "../Notifications",
"preferences": "../Preferences"
},
"SearchHistory": {
"preferences": "../Preferences"
},
"Invidious": {
"webServer": "../WebServer",
@@ -21,10 +27,12 @@ function InitializeBindings()
"preferences": "../Preferences"
},
"WebServer": {
"appController": "/AppController",
"applicationInfo": "../ApplicationInfo",
"invidious": "../Invidious",
"preferences": "../Preferences",
"playQueue": "../PlayQueue"
"playQueue": "../PlayQueue",
"bookmarks": "../Bookmarks"
}
}
}
@@ -50,8 +50,8 @@ function setIconSize()
m.buttonIcon.width = m.buttonIcon.height
m.buttonIcon.translation = [((width - m.buttonIcon.width) / 2), ((height - m.buttonIcon.height) / 2)]
m.buttonText.translation = [0, height]
m.buttonText.width = width
m.buttonText.translation = [-5, height]
m.buttonText.width = width + 10
end if
end function
+3 -3
View File
@@ -74,13 +74,13 @@ function onKeyEvent(key as string, press as boolean) as boolean
return false
end if
navBarItem = m.top.items.getChild(m.top.focusIndex)
if navBarItem.canFocus <> true
return false
end if
screen = m.appController@.GetRootScreen(navBarItem.screen)
if screen = invalid
return false
end if
if not screen.focusable
return false
end if
NodeSetFocus(screen, true)
return true
end if
+1 -1
View File
@@ -8,7 +8,7 @@
<children>
<Rectangle
height="720"
width="105"
width="115"
color="#242424"
opacity="0.9">
<LayoutGroup
@@ -3,6 +3,5 @@
<field id="screen" type="string" />
<field id="icon" type="string" />
<field id="text" type="string" />
<field id="canFocus" type="boolean" value="false" />
</interface>
</component>
@@ -0,0 +1,91 @@
const OK_LONG_PRESS_KEY = "OK_LONG_PRESS"
const OPTIONS_LONG_PRESS_KEY = "OPTIONS_LONG_PRESS"
function InitializeLongPress(keys as object, duration = 1.0 as float)
longPressKeyMap = {
"OK": OK_LONG_PRESS_KEY,
"options": OPTIONS_LONG_PRESS_KEY
}
m._longPressKeyMap = {}
for each key in keys
m._longPressKeyMap[key] = longPressKeyMap[key]
end for
#if DEBUG
' This is for testing long press using the VSCode extension.
' Using the keyboard:
' - press K to simulate an "OK" long press on the remote.
' - press O to simulate an "options" long press on the remote.
simulatedLongPressKeyMap = {
"OK": "Lit_k",
"options": "Lit_o"
}
m._simulatedLongPressKeyMap = {}
for each key in keys
m._simulatedLongPressKeyMap[simulatedLongPressKeyMap[key]] = key
end for
#end if
m._longPressTimer = CreateObject("roSGNode", "Timer")
m._longPressTimer.duration = duration
m._longPressFired = false
m._pressState = {}
m._longPressTimer.ObserveField("fire", FuncName(LongPressTimerFired))
end function
function LongPressHandler(key as string, press as boolean) as boolean
#if DEBUG
if m._simulatedLongPressKeyMap.DoesExist(key)
subtype = m.top.subtype()
simulatedKey = m._simulatedLongPressKeyMap[key]
LogInfo(`[${subtype}] Simulating`, simulatedKey, "long press using key:", key, "press:", press)
longPressKey = m._longPressKeyMap[simulatedKey]
m._longPressFired = true
return OnkeyEvent(longPressKey, press)
end if
#end if
isLongPressKey = m._longPressKeyMap.DoesExist(key)
if not isLongPressKey
return false
end if
if press
m._longPressTimer.control = "stop"
m._longPressTimer.control = "start"
m._longPressFired = false
m._longPressKey = key
m._pressState[key] = true
return true
end if
if not press
m._longPressTimer.control = "stop"
if m._longPressFired = true
m._longPressFired = false
m._pressState[key] = false
return true
end if
' This case is for handling a dialog: The dialog will be dismissed with the OK down event,
' and we would trigger the action with the OK up event. The action should only happen if
' we detected both down and up events.
wasPressed = m._pressState[key]
m._pressState[key] = false
if wasPressed <> true
return true
end if
end if
return false
end function
function LongPressTimerFired() as void
m._longPressFired = true
if StringUtils.IsNullOrEmpty(m._longPressKey) or not m._longPressKeyMap.DoesExist(m._longPressKey)
return
end if
OnkeyEvent(m._longPressKeyMap[m._longPressKey], true)
end function
@@ -0,0 +1,5 @@
<component name="ContentNodeReference" extends="ContentNode">
<interface>
<field id="refNode" type="node" />
</interface>
</component>
@@ -0,0 +1,41 @@
' 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
@@ -0,0 +1,67 @@
import "pkg:/components/NodeByRef/NodeByRef.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
' TODO:P2 a lot of shared logic with the SponsorBlock notification, should be refactored into a common notification
function Init()
m.translationAnimation = m.top.findNode("translationAnimation")
m.translationAnimationInterpolator = m.top.findNode("translationAnimationInterpolator")
m.animationTimer = m.top.findNode("animationTimer")
m.top.translation = [1280, 20]
m.translationAnimation.observeField("state", FuncName(OnAnimationState))
m.animationTimer.observeField("fire", FuncName(OnAnimationTimer))
end function
function OnContentSet() as void
content = m.top.content
content = NodeByRef.Unwrap(content)
if content = invalid
return
end if
if not StringUtils.IsNullOrEmpty(content.thumbnail)
m.top.thumbnail = content.thumbnail
else
m.top.thumbnail = "pkg:/images/thumbnail-missing.jpg"
end if
m.top.line1 = content.title
end function
function OnShow()
AnimateIn()
end function
function OnAnimationTimer()
AnimateOut()
end function
function AnimateIn()
m.translationAnimation.unobserveField("state")
m.animationTimer.control = "stop"
m.animationTimer.control = "start"
m.translationAnimation.observeField("state", FuncName(OnAnimationState))
Animate(false)
end function
function AnimateOut()
Animate(true)
end function
function Animate(reverse as boolean) as void
' We are already animating in the requested direction
if m.translationAnimationInterpolator.reverse = reverse and m.translationAnimation.control <> "none"
return
end if
m.translationAnimationInterpolator.reverse = reverse
m.translationAnimation.control = "start"
end function
function OnAnimationState()
if m.translationAnimation.state = "stopped" and m.translationAnimationInterpolator.reverse = true
m.top.getParent().removeChild(m.top)
end if
end function
@@ -0,0 +1,64 @@
<component name="PlayQueueNotification" extends="Group">
<interface>
<field id="content" type="node" onChange="OnContentSet" />
<field id="thumbnail" type="uri" alias="thumbnailPoster.uri" />
<field id="line1" type="string" alias="line1Label.text" />
<field id="show" type="boolean" alwaysNotify="true" onChange="OnShow" />
</interface>
<children>
<Poster
width="500"
height="144"
opacity="0.9"
uri="pkg:/images/white.9.png">
<Poster
id="thumbnailPoster"
loadDisplayMode="scaleToZoom"
width="170"
height="106"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg"
translation="[10,10]">
</Poster>
<LayoutGroup
itemSpacings="[10]"
translation="[190,10]">
<Label
width="300"
font="font:SmallestBoldSystemFont"
horizAlign="center"
color="0x262626ff"
text="Added to queue">
<Font role="font" uri="font:BoldSystemFontFile" size="22" />
</Label>
<Label
id="line1Label"
width="300"
font="font:SmallestSystemFont"
maxLines="3"
color="0x262626ff"
wrap="true" />
</LayoutGroup>
<Label
width="480"
font="font:SmallestSystemFont"
color="0x262626ff"
text="Press and hold Options (*) to open the queue"
translation="[10,120]" />
</Poster>
<Animation
id="translationAnimation"
duration="0.3"
optional="true">
<Vector2DFieldInterpolator
id="translationAnimationInterpolator"
key="[0.0, 0.5, 1.0]"
keyValue="[ [1280.0, 20.0], [1020.0, 20.0], [760.0, 20.0] ]"
fieldToInterp="PlayQueueNotification.translation" />
</Animation>
<Timer
id="animationTimer"
duration="3" />
</children>
</component>
@@ -0,0 +1,28 @@
namespace PlayQueue
const NOTIFICATION_NODE_ID = "PlayQueueNotification"
function ShowNotifcation(notifications as object, contentNode as object) as void
notification = notifications.findNode(NOTIFICATION_NODE_ID)
if notification = invalid
notification = notifications.createChild("PlayQueueNotification")
notification.id = NOTIFICATION_NODE_ID
end if
notification.content = contentNode
notification.show = true
end function
function RemoveNotifcation(notifications as object) as void
notification = notifications.findNode(NOTIFICATION_NODE_ID)
if notification <> invalid
notifications.RemoveChild(notification)
end if
end function
function SetVisible(notifications as object, visible as boolean)
notification = notifications.findNode(NOTIFICATION_NODE_ID)
if notification <> invalid
notification.visible = visible
end if
end function
end namespace
@@ -1,5 +1,7 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/NodeByRef/NodeByRef.bs"
import "pkg:/components/PlaylistView/PlaylistContentTask.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"
@@ -8,49 +10,74 @@ import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/Types.bs"
' TODO:P1 prevent adding duplicates of the same video/playlist
function Init()
m.pendingLoadTasks = {}
' TODO:P1 prevent adding duplicates of the same video/playlist
m.queue = CreateObject("roArray", 0, true)
m.content = m.top.findNode("Content")
m.top.content = m.content
m.content.addField("index", "integer", false)
m.content.index = m.top.index
end function
function Play(node as object, playlistIndex as integer)
m.top.index += 1
m.top.playlistIndex = playlistIndex
if m.top.index >= m.queue.Count()
m.queue.push(node)
m.top.index = m.queue.Count() - 1
node = WrapWithIndexField(node)
if m.top.index >= m.content.getChildCount()
m.content.appendChild(node)
m.top.index = m.content.getChildCount() - 1
else
ArrayUtils.Insert(m.queue, node, m.top.index)
m.content.insertChild(node, m.top.index)
end if
PlayItemAtCurrentIndex()
end function
function AddToQueue(node as object)
m.queue.push(node)
node = WrapWithIndexField(node)
m.content.appendChild(node)
queueNotifications = m.top.preferences["misc.queue_notifications"]
if queueNotifications
PlayQueue.ShowNotifcation(m.top.notifications, node)
end if
end function
' TODO:P1 better model of the queue (Now playing, etc)
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 item in m.queue
if item.type = "video"
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: item.type,
videoId: item.videoId,
title: item.title,
author: item.author,
thumbnail: item.thumbnail
type: nodeType,
videoId: node.videoId,
title: node.title,
author: node.author,
thumbnail: node.thumbnail
})
else if item.type = "playlist"
else if node.type = "playlist"
items.push({
type: item.type,
playlistId: item.playlistId,
title: item.title,
thumbnail: item.thumbnail,
videoCountText: item.videoCountText
type: nodeType,
playlistId: node.playlistId,
title: node.title,
thumbnail: node.thumbnail,
videoCountText: node.videoCountText
})
end if
end for
@@ -63,21 +90,24 @@ function GetQueue(unused as dynamic) as object
end function
function Clear(unused as dynamic)
m.queue.Clear()
m.content.removeChildrenIndex(m.content.getChildCount(), 0)
m.top.index = -1
m.top.playlistIndex = -1
end function
function PlayNextItem(unused as dynamic) as boolean
if m.queue.Count() = 0
childCount = m.content.getChildCount()
if childCount = 0
return false
end if
if m.top.index <> -1
if m.top.index >= m.queue.Count()
index = m.top.index
if index <> -1
if index >= childCount
return false
end if
node = m.queue[m.top.index]
node = m.content.getChild(index)
node = NodeByRef.Unwrap(node)
if node.type = "playlist"
m.top.playlistIndex += 1
if PlayPlaylistAtCurrentIndex(node)
@@ -88,15 +118,22 @@ function PlayNextItem(unused as dynamic) as boolean
m.top.index += 1
m.top.playlistIndex = -1
if m.top.index >= m.queue.Count()
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.queue[m.top.index]
node = m.content.getChild(m.top.index)
node = NodeByRef.Unwrap(node)
if node = invalid
return false
end if
@@ -113,17 +150,18 @@ function PlayItemAtCurrentIndex() as boolean
end function
function PlayPlaylistAtCurrentIndex(playlist as object) as boolean
playlist = NodeByRef.Unwrap(playlist)
if playlist.videoCount < 0
LoadPlaylist(playlist)
return true
end if
index = m.top.playlistIndex
if index < 0 or index >= playlist.videoCount
playlistIndex = m.top.playlistIndex
if playlistIndex < 0 or playlistIndex >= playlist.videoCount
return false
end if
if index < playlist.getChildCount()
child = playlist.getChild(index)
if playlistIndex < playlist.getChildCount()
child = playlist.getChild(playlistIndex)
VideoUtils.PlayVideo(child)
return true
end if
@@ -172,3 +210,12 @@ function OnPlaylistContentTaskResult(output as object) as void
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
@@ -1,13 +1,19 @@
<component name="PlayQueue" extends="Node">
<interface>
<field id="queue" type="array" />
<field id="index" type="integer" value="-1" />
<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" />
</interface>
<children>
<ContentNode id="Content" />
</children>
</component>
@@ -0,0 +1,83 @@
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(invalid)
end function
function OnClearButtonSelected()
m.top.playQueue@.Clear(invalid)
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
@@ -0,0 +1,64 @@
<component name="PlayQueueView" extends="Group" includes="Focus">
<interface>
<field id="content" type="node" onChange="OnContentSet" />
<field id="jumpToItem" type="integer" alias="queueList.jumpToItem" />
<field id="playQueue" type="node" />
<field id="appController" type="node" />
<function name="Show" />
</interface>
<children>
<Rectangle
id="background"
width="1280"
height="720"
color="#000000"
opacity="0" />
<Rectangle
id="container"
width="470"
height="720"
translation="[-470,0]"
color="0x242424">
<Label
id="queueLabel"
width="270"
height="52"
text="Queue"
vertAlign="center"
font="font:MediumBoldSystemFont"
translation="[20,20]" />
<Button
id="clearButton"
minWidth="150"
height="52"
text="Clear"
showFocusFootprint="true"
translation="[295,15]" />
<MarkupGrid
id="queueList"
itemComponentName="PlayQueueViewCell"
itemSize="[432,90]"
itemSpacing="[0,15]"
numColumns="1"
numRows="6"
vertFocusAnimationStyle="floatingFocus"
translation="[20,90]" />
</Rectangle>
<Animation id="showAnimation"
duration="0.3"
optional="true">
<FloatFieldInterpolator
id="fadeInterpolator"
key="[0.0, 0.5, 1.0]"
keyValue="[0.0, 0.4, 0.8]"
fieldToInterp="background.opacity" />
<Vector2DFieldInterpolator
id="translationInterpolator"
key="[0.0, 0.5, 1.0]"
keyValue="[[-470,0], [-235,0], [0,0]]"
fieldToInterp="container.translation" />
</Animation>
</children>
</component>
@@ -0,0 +1,75 @@
import "pkg:/components/NodeByRef/NodeByRef.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")
end function
function OnContentSet() as void
content = m.top.itemContent
content = NodeByRef.Unwrap(content)
if content = invalid
return
end if
m.top.title = content.title
m.top.thumbnailUri = content.thumbnail
contentType = ValidString(content.type)
if contentType = "video" and ValidInt(content.lengthSeconds) <> 0
SetDurationText(content.lengthText)
m.top.durationRectVisible = true
else if contentType = "playlist" and not StringUtils.IsNullOrEmpty(content.videoCountText)
SetDurationText(content.videoCountText)
m.top.durationRectVisible = true
else
m.top.durationRectVisible = false
end if
SetHighlight()
end function
function SetDurationText(text as string) as void
m.top.duration = text
label = m.durationLabel
rect = m.durationRect
if label = invalid or rect = invalid
return
end if
rectParent = rect.getParent()
size = label.localBoundingRect()
rect.width = size.width + 16
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
end function
function SetHighlight() as void
content = m.top.itemContent
playQueueContent = content.getParent()
if playQueueContent = invalid
return
end if
playQueue = playQueueContent.getParent()
if playQueue = invalid
return
end if
playQueueIndex = playQueue.index
index = m.top.index
if playQueueIndex = index
m.top.thumbnailBlendColor = "#FFFFFFFF"
m.top.highlightUri = "pkg:/images/focus_grid.9.png"
else
m.top.thumbnailBlendColor = "#606060FF"
m.top.highlightUri = ""
end if
end function
@@ -0,0 +1,50 @@
<component name="PlayQueueViewCell" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="index" type="integer" />
<field id="title" type="string" alias="titleLabel.text" />
<field id="thumbnailUri" type="uri" alias="thumbnailPoster.uri" />
<field id="thumbnailBlendColor" type="color" alias="thumbnailPoster.blendColor" />
<field id="highlightUri" type="uri" alias="highlightPoster.uri" />
<field id="duration" type="string" alias="durationLabel.text" />
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
</interface>
<children>
<Poster
id="thumbnailPoster"
loadDisplayMode="scaleToZoom"
width="160"
height="90"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg"
translation="[2,2]">
<Rectangle
id="durationRect"
width="60"
height="26"
color="0x000000"
opacity="0.8"
translation="[100, 58]">
<Label
height="26"
id="durationLabel"
horizAlign="center"
vertAlign="center"
font="font:SmallestSystemFont"
translation="[8, 0]" />
</Rectangle>
</Poster>
<Poster
id="highlightPoster"
blendColor="0xFF0000"
width="164"
height="94" />
<Label
id="titleLabel"
width="260"
font="font:SmallestBoldSystemFont"
maxLines="3"
wrap="true"
translation="[172,2]" />
</children>
</component>
@@ -0,0 +1,23 @@
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(invalid)
return playQueueView
end function
end namespace
@@ -1,7 +1,10 @@
namespace PlaylistUtils
function Open(contentNode as object)
function Open(contentNode as object, appController = invalid as object)
playlistView = CreateObject("roSGNode", "PlaylistView")
m.appController@.PushScreen(playlistView)
if appController = invalid
appController = m.appController
end if
appController@.PushScreen(playlistView)
playlistView@.BindNode(invalid)
playlistView.content = contentNode
end function
@@ -1,4 +1,7 @@
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/PlaylistView/PlaylistContentTask.bs"
import "pkg:/components/VideoFeed/FeedLoadState.bs"
import "pkg:/components/VideoPlayer/VideoUtils.bs"
@@ -21,7 +24,7 @@ end function
function OnNodeReady()
m.list.ObserveField("itemFocused", FuncName(OnItemFocused))
m.list.observeField("itemSelected", FuncName(OnItemSelected))
InitializeLongPress(["OK"])
end function
function OnFocusChange() as void
@@ -50,7 +53,9 @@ function OnContentSet() as void
m.background.uri = content.thumbnailBackground
itemFocused = m.list.itemFocused
m.list.content = content
if not content.isSameNode(m.list.content)
m.list.content = content
end if
if itemFocused > -1 and content.getChildCount() > itemFocused
m.list.jumpToItem = itemFocused
end if
@@ -58,6 +63,20 @@ function OnContentSet() as void
end function
function OnkeyEvent(key as string, press as boolean) as boolean
if LongPressHandler(key, press)
return true
end if
if key = OK_LONG_PRESS_KEY and press
OnItemLongPressed(m.list.itemFocused)
return true
end if
if key = "OK" and not press
OnItemSelected(m.list.itemFocused)
return true
end if
if press = false
return false
end if
@@ -81,18 +100,97 @@ function OnItemFocused()
LoadPlaylistIfNeeded()
end function
function OnItemSelected(event as object)
index = event.getData()
function OnItemSelected(index as integer) as void
playlist = m.list.content
if playlist = invalid
return
end if
if index < 0 or index >= playlist.getChildCount()
return
end if
playlistId = playlist.playlistId
video = playlist.getChild(index)
videoId = video.videoId
if not StringUtils.IsNullOrEmpty(videoId)
LogInfo("Play playlist: " + playlistId + " video: " + videoId)
LogInfo("Play playlist:", playlistId, "video:", videoId)
m.playQueue@.Play(playlist, index)
end if
end function
function OnItemLongPressed(index as integer) as void
playlist = m.list.content
if playlist = invalid
return
end if
if index < 0 or index >= playlist.getChildCount()
return
end if
playlistId = playlist.playlistId
video = playlist.getChild(index)
videoId = video.videoId
if StringUtils.IsNullOrEmpty(videoId)
LogWarn("Long press video with no id in playlist/ playlist:", playlistId, "video:", videoId)
return
end if
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
function GetContextMenuOptionsForItem(video as object) as object
playlist = m.list.content
if playlist = invalid
return []
end if
index = m.list.itemFocused
if index < 0 or index >= playlist.getChildCount()
return []
end if
selectedVideo = playlist.getChild(m.list.itemFocused)
if selectedVideo = invalid or not selectedVideo.isSameNode(video)
return []
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]),
]
if not StringUtils.IsNullOrEmpty(playlist.authorId)
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [playlist]))
end if
options.append(m.bookmarks@.GetMenuForPlaylist(playlist))
options.append(m.bookmarks@.GetMenuForVideo(video))
return options
end function
function OpenPlaylistChannel(playlist as object) as void
authorId = playlist.authorId
if StringUtils.IsNullOrEmpty(authorId)
LogWarn("Invalid authorId:", authorId)
return
end if
channel = InvidiousContent.ToChannelContentNode(invalid, { authorId: authorId }, invalid)
ChannelUtils.Open(channel)
end function
'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
content = m.top.content
if content = invalid
@@ -1,16 +1,17 @@
<component name="PlaylistView" extends="Group" includes="AutoBind,Focus">
<component name="PlaylistView" extends="Group" includes="AutoBind,Focus,ContextMenuProvider">
<interface>
<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="bookmarks" type="node" bind="/Bookmarks" />
<function name="OpenPlaylistChannel" />
</interface>
<children>
<Rectangle
width="1280"
height="720"
color="0x242424">
</Rectangle>
color="0x242424" />
<Poster
id="backgroundSmall"
width="1280"
@@ -2,13 +2,8 @@ import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.titleLabel = m.top.findNode("titleLabel")
m.authorLabel = m.top.findNode("authorLabel")
m.thumbnail = m.top.findNode("thumbnail")
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")
m.thumbnail.failedBitmapUri = "pkg:/images/thumbnail-missing.jpg"
end function
function OnContentSet() as void
@@ -18,27 +13,31 @@ function OnContentSet() as void
return
end if
m.titleLabel.text = content.title
m.authorLabel.text = content.author
m.top.title = content.title
m.top.author = content.author
m.top.thumbnailUri = content.thumbnail
m.thumbnail.uri = content.thumbnail
if ValidInt(content.lengthSeconds) <> 0
SetDurationText(content.lengthText)
m.durationRect.visible = true
m.top.durationRectVisible = true
else
m.durationRect.visible = false
m.top.durationRectVisible = false
end if
end function
function SetDurationText(text as string)
function SetDurationText(text as string) as void
m.top.duration = text
label = m.durationLabel
rect = m.durationRect
rectParent = rect.getParent()
if label = invalid or rect = invalid
return
end if
label.text = text
rectParent = rect.getParent()
size = label.localBoundingRect()
rect.width = size.width + 16
rect.translation = [rectParent.width - rect.width, 72]
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
end function
@@ -1,13 +1,19 @@
<component name="PlaylistViewCell" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="title" type="string" alias="titleLabel.text" />
<field id="author" type="string" alias="authorLabel.text" />
<field id="thumbnailUri" type="uri" alias="thumbnailPoster.uri" />
<field id="duration" type="string" alias="durationLabel.text" />
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
</interface>
<children>
<Poster
id="thumbnail"
id="thumbnailPoster"
loadDisplayMode="scaleToZoom"
width="190"
height="106">
height="106"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg">
<Rectangle
id="durationRect"
width="60"
@@ -0,0 +1,100 @@
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.noBookmarks = m.top.findNode("noBookmarks")
m.yesBookmarks = m.top.findNode("yesBookmarks")
m.rowList = m.top.FindNode("rowList")
m.rowList.screen = m.top
m.isDirty = true
m.top.ObserveField("visible", FuncName(OnVisibleChange))
end function
function OnNodeReady()
SetNavigation(invalid, "back", m.navBar)
SetNavigation(invalid, "left", m.navBar)
m.rowList@.BindNode(invalid)
OnBookmarksChange()
m.bookmarks.ObserveField("contentChange", FuncName(OnBookmarksChange))
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
if m.yesBookmarks.visible
NodeSetFocus(m.rowList, true)
else
NodeSetFocus(m.navBar, true)
end if
end function
function OnVisibleChange()
if m.top.visible and m.isDirty
OnBookmarksChange()
end if
end function
function Refresh(unused as dynamic)
m.isDirty = true
OnBookmarksChange()
end function
function OnBookmarksChange() as void
if not m.top.visible
m.isDirty = true
return
end if
m.isDirty = false
hasBookmarks = m.bookmarks.content.getChildCount() > 0
m.noBookmarks.visible = not hasBookmarks
m.yesBookmarks.visible = hasBookmarks
m.top.focusable = hasBookmarks
if hasBookmarks
SetRowListContent(m.bookmarks.content)
else
if m.rowList.hasFocus()
NodeSetFocus(m.navBar, true)
end if
end if
end function
function SetRowListContent(bookmarksContent as object)
bookmarkGroupNodes = bookmarksContent.getChildren(-1, 0)
feeds = []
for each bookmarkGroupNode in bookmarkGroupNodes
bookmarkNodes = bookmarkGroupNode.getChildren(-1, 0)
feedSources = []
for each bookmarkNode in bookmarkNodes
feedSources.push(bookmarkNode.feedSource)
end for
feeds.push({
"title": bookmarkGroupNode.title,
"feedSources": feedSources
})
end for
m.rowList.feeds = feeds
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 GetContextMenuOptionsForItem(rowItem as object) as object
refreshItem = ContextMenuUtils.CreateOption("Refresh Bookmarks", m.top, "Refresh", [invalid])
return [refreshItem]
end function
@@ -0,0 +1,38 @@
<component name="BookmarksScreen" extends="Group" includes="AutoBind,Focus,ContextMenuProvider">
<interface>
<field id="navBar" type="node" bind="/NavBar" />
<field id="applicationInfo" type="node" bind="/ApplicationInfo" />
<field id="bookmarks" type="node" bind="/Bookmarks" />
<function name="Refresh" />
</interface>
<children>
<Group id="noBookmarks" visible="false">
<Label
height="720"
width="1280"
font="font:MediumBoldSystemFont"
horizAlign="center"
vertAlign="center"
text="You currently have no bookmarks.&#xA;&#xA;To add bookmarks, long-press 'OK' on a video, playlist or channel.&#xA;&#xA;Please note that Bookmarks is an experimental feature."
wrap="true" />
</Group>
<Group id="yesBookmarks" visible="false">
<VideoRowList
itemComponentName="RowCell"
id="rowList"
translation="[0,50]"
numRows="2"
rowitemSize="[[350,196]]"
rowItemSpacing="[[25,0]]"
itemSize="[1280,326]"
itemSpacing="[0,65]"
rowLabelOffset="[[125,20]]"
focusXOffset="[125]"
showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true"
focusBitmapUri="pkg:/images/focus_grid.9.png"
/>
</Group>
</children>
</component>
@@ -1,8 +1,11 @@
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/source/utils/FocusManagement.bs"
function Init()
m.top.focusable = true
m.rowList = m.top.FindNode("rowList")
m.rowList.screen = m.top
m.pendingLoadTasks = {}
end function
@@ -11,7 +14,7 @@ function OnNodeReady()
SetNavigation(invalid, "left", m.navBar)
m.rowList@.BindNode(invalid)
m.rowList.contentData = ParseJson(ReadAsciiFile(m.top.feedFile))
m.rowList.feeds = ParseJson(ReadAsciiFile(m.top.feedFile))
end function
function OnFocusChange() as void
@@ -27,3 +30,8 @@ function OnkeyEvent(key as string, press as boolean) as boolean
end if
return false
end function
function GetContextMenuOptionsForItem(rowItem as object) as object
refresh = ContextMenuUtils.CreateOption("Refresh Home", m.rowList, "Refresh", [invalid])
return [refresh]
end function
@@ -1,8 +1,8 @@
<component name="HomeScreen" extends="Group" includes="AutoBind,Focus">
<component name="HomeScreen" extends="Group" includes="AutoBind,Focus,ContextMenuProvider">
<interface>
<field id="navBar" type="node" bind="/NavBar" />
<field id="invidious" type="node" bind="/Invidious" />
<field id="feedFile" type="string" value="libpkg:/config/default_home_layout.json5" />
<field id="feedFile" type="string" value="libpkg:/config/default_home_layout.yaml" />
</interface>
<children>
<VideoRowList
@@ -14,8 +14,8 @@
rowItemSpacing="[[25,0]]"
itemSize="[1280,326]"
itemSpacing="[0,65]"
rowLabelOffset="[[115,20]]"
focusXOffset="[115]"
rowLabelOffset="[[125,20]]"
focusXOffset="[125]"
showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true"
@@ -1,13 +1,14 @@
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/Screens/SearchScreen/SearchSuggestionsTask.bs"
import "pkg:/components/Services/SearchHistory/SearchHistoryUtils.bs"
import "pkg:/source/asyncTask/asyncTask.bs"
import "pkg:/source/services/SearchHistory.bs"
import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/LoadingScreen.bs"
import "pkg:/source/utils/Logging.bs"
function Init()
m.top.focusable = true
m.container = m.top.FindNode("container")
m.keyboard = m.top.FindNode("keyboard")
m.rowList = m.top.FindNode("rowList")
@@ -16,6 +17,8 @@ function Init()
m.suggestions = m.top.FindNode("suggestions")
m.filtersButton = m.top.FindNode("filtersButton")
m.rowList.screen = m.top
textEditBox = m.keyboard.textEditBox
textEditBox.voiceEntryType = "generic"
textEditBox.voiceEnabled = true
@@ -96,7 +99,8 @@ function OnTextChange() as void
m.searchSuggestionsTask = StartAsyncTask(SearchSuggestionsTask, {
q: m.keyboard.text,
invidious: m.invidious
invidious: m.invidious,
preferences: m.preferences
}, OnSearchSuggestionsTaskResults)
end function
@@ -152,7 +156,7 @@ end function
function OnSearchButtonSelected()
selected = m.suggestions.buttonSelected
text = m.suggestions.buttons[selected]
SearchHistory.Save(text)
SearchHistoryUtils.Save(m.preferences, text)
Search(text)
end function
@@ -200,12 +204,13 @@ function Search(text as string)
m.rowlist.ObserveFieldScoped("someContentReady", FuncName(OnSearchContentReady))
ShowLoadingScreen()
requestData = {
title: `Search - ${text}`,
apiType: "Invidious",
endpoint: "search",
queryParams: {
q: text
feedSource = {
"id": `inv_search_${CryptoUtils.GetMd5(text)}`,
"title": `Search - ${text}`,
"apiType": "Invidious",
"endpoint": "search",
"queryParams": {
"q": text
}
}
@@ -213,18 +218,21 @@ function Search(text as string)
for each filter in filters
value = filters[filter]
if IsString(value) and value.len() > 0
requestData.queryParams[filter] = value
feedSource.queryParams[filter] = value
else if IsArray(value) and value.Count() > 0
' TODO:P1 this is http client implementation details leaking
' We need a declarative way to set array types
requestData.queryParams[filter] = {
feedSource.queryParams[filter] = {
value: value,
__arrayType: HttpClient.QueryParamArrayType.CommaSeparated
}
end if
end for
m.rowList.contentData = [requestData]
m.rowList.feeds = [{
"title": `Search - ${text}`,
"feedSources": [feedSource]
}]
end function
function OnSearchContentReady() as void
@@ -243,7 +251,7 @@ function OnSearchContentReady() as void
end function
function OnSearchError()
m.rowlist.contentData = invalid
m.rowlist.feeds = invalid
m.rowlist.focusable = false
HideLoadingScreen()
end function
@@ -258,7 +266,7 @@ end function
function ClearSearch()
m.keyboard.text = ""
m.rowlist.contentData = invalid
m.rowlist.feeds = invalid
m.rowlist.focusable = false
ScrollUp()
end function
@@ -3,6 +3,7 @@
<field id="navBar" type="node" bind="/NavBar" />
<field id="invidious" type="node" bind="/Invidious" />
<field id="appController" type="node" bind="/AppController" />
<field id="preferences" type="node" bind="/Preferences" />
<field id="filters" type="assocarray" />
</interface>
<children>
@@ -10,7 +11,7 @@
<Button
id="filtersButton"
translation="[160,40]"
minWidth="180"
minWidth="240"
height="48"
showFocusFootprint="true"
iconUri="pkg:/images/icons/filters-white.png"
@@ -40,8 +41,8 @@
rowItemSpacing="[[25,0]]"
itemSize="[1280,326]"
itemSpacing="[0,65]"
rowLabelOffset="[[115,20]]"
focusXOffset="[115]"
rowLabelOffset="[[125,20]]"
focusXOffset="[125]"
showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true"
@@ -1,10 +1,11 @@
import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/source/services/SearchHistory.bs"
import "pkg:/components/Services/SearchHistory/SearchHistoryUtils.bs"
@asynctask
function SearchSuggestionsTask(input as object) as object
q = input.q
invidiousNode = input.invidious
preferencesNode = input.preferences
service = new Invidious.InvidiousService(invidiousNode)
@@ -18,7 +19,7 @@ function SearchSuggestionsTask(input as object) as object
return invalid
end if
history = SearchHistory.GetSaved(q)
history = SearchHistoryUtils.GetSaved(preferencesNode, q)
if searchSuggestsions <> invalid
history = MergeSearchSuggestions(history, searchSuggestsions.suggestions)
@@ -1,5 +1,5 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/source/services/SearchHistory.bs"
import "pkg:/components/Services/SearchHistory/SearchHistoryUtils.bs"
import "pkg:/source/utils/FocusManagement.bs"
function Init()
@@ -21,6 +21,6 @@ function BindPreference(preferences as object, key as string)
end function
function OnButtonSelected()
SearchHistory.Clear()
SearchHistoryUtils.Clear()
DialogUtils.ShowDialog("Search history cleared.", "Success")
end function
@@ -7,6 +7,7 @@
<children>
<Button
id="Button"
minWidth="340"
showFocusFootprint="true" />
<Label id="DescriptionLabel"
width="450"
@@ -22,6 +22,8 @@ end function
function PrepareTests() as object
content = CreateObject("roSGNode", "ContentNode")
' TODO:P2 test if video data is reachable (head?)
' TODO:P2 test if video data is reachable in proxy mode (local=true)
content.AppendChild(CreateTestNode("Valid url", IsValidUrl))
content.AppendChild(CreateTestNode("Instance reachable", IsReachable))
content.AppendChild(CreateTestNode("Fetch video details", CanFetchVideoDetails))
@@ -51,7 +53,9 @@ function RunTests(instance as string, content as object) as void
for each testNode in testNodes
timer.Mark()
m[testNode.func](instance, testNode)
testNode.duration = timer.TotalMilliseconds()
testNode.title = `${testNode.title} (${testNode.duration}ms)`
if testNode.state = "failed"
LogError(testNode.details)
@@ -101,14 +105,21 @@ function IsReachable(instance as string, testNode as object) as void
return
end if
name = json.software?.name
if not IsString(name)
software = json.software
if software = invalid
testNode.state = "failed"
testNode.details = `Invalid json from ${url} (couldn't read software.name)`
testNode.details = `Invalid json from ${url} (couldn't read $.software)`
return
end if
version = json.software?.version
name = software.name
if not IsString(name)
testNode.state = "failed"
testNode.details = `Invalid json from ${url} (couldn't read $.software.name)`
return
end if
version = software.version
if not IsString(version)
testNode.state = "failed"
testNode.details = `Invalid json from ${url} (couldn't read software.version)`
@@ -3,6 +3,7 @@ import "pkg:/components/Navigation/ScrollTo.bs"
import "pkg:/source/utils/FocusManagement.bs"
function Init()
m.top.focusable = true
m.container = m.top.findNode("Container")
m.scrollAnimation = m.top.findNode("scrollAnimation")
m.scrollAnimationInterpolator = m.scrollAnimation.findNode("scrollAnimationInterpolator")
@@ -0,0 +1,330 @@
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
import "pkg:/source/utils/CryptoUtils.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RegistryUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
const VIDEOS_GROUP = "Videos"
const CHANNELS_GROUP = "Channels"
const PLAYLISTS_GROUP = "Playlists"
function Init()
m.top.content = m.top.findNode("content")
m.bookmarksString = ""
Load()
m.top.ObserveField("contentChange", FuncName(OnContentChange))
end function
function Load() as void
bookmarksString = RegistryUtils.Read(RegistryUtils.BOOKMARKS)
if bookmarksString = invalid
return
end if
m.bookmarksString = bookmarksString
bookmarks = ParseJson(bookmarksString)
if bookmarks = invalid
LogWarn("Failed to parse bookmarks json")
return
end if
for each bookmarkGroup in bookmarks.groups
bookmarkGroupNode = GetOrCreateBookmarkGroup(bookmarkGroup.title)
bookmarksCount = bookmarkGroup.bookmarks.Count()
' AddFeedSourceBookmark inserts at the beginning of the list, so we need to iterate backwards
for i = bookmarksCount - 1 to 0 step -1
bookmark = bookmarkGroup.bookmarks[i]
AddFeedSourceBookmark(bookmark.feedSource, bookmark.id, bookmarkGroupNode)
end for
end for
end function
function Save() as void
bookmarkGroupNodes = m.top.content.getChildren(-1, 0)
if bookmarkGroupNodes.Count() = 0
RegistryUtils.Delete(RegistryUtils.BOOKMARKS)
return
end if
groups = []
for each bookmarkGroupNode in bookmarkGroupNodes
bookmarks = []
bookmarkNodes = bookmarkGroupNode.getChildren(-1, 0)
for each bookmarkNode in bookmarkNodes
bookmarks.push({
"id": bookmarkNode.id,
"feedSource": bookmarkNode.feedSource
})
end for
groups.push({
"title": bookmarkGroupNode.title,
"bookmarks": bookmarks
})
end for
bookmarksString = FormatJson({
"__version": m.top.__version,
"groups": groups
})
if m.bookmarksString = bookmarksString
return
end if
RegistryUtils.Write(RegistryUtils.BOOKMARKS, bookmarksString)
m.bookmarksString = bookmarksString
end function
function GetOrCreateBookmarkGroup(groupName as string) as object
id = CryptoUtils.GetMd5(groupName)
node = m.top.content.findNode(id)
if node <> invalid
return node
end if
node = CreateObject("roSGNode", "ContentNode")
node.id = id
node.title = groupName
m.top.content.appendChild(node)
LogInfo("Added bookmark group:", groupName)
return node
end function
function AddFeedSourceBookmark(feedSource as object, id as string, bookmarkGroupNode as dynamic)
if IsString(bookmarkGroupNode)
bookmarkGroupNode = GetOrCreateBookmarkGroup(bookmarkGroupNode)
end if
feedSource.Delete("state")
bookmarkNode = CreateObject("roSGNode", "BookmarkContentNode")
bookmarkNode.id = id
bookmarkNode.feedSource = feedSource
bookmarkGroupNode.insertChild(bookmarkNode, 0)
LogInfo("Added feedSource bookmark. title:", feedSource.title, "id:", id)
m.top.contentChange = true
end function
function AddVideoBookmark(id as string, groupName as string)
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
feedSource = {
"apiType": "Invidious",
"endpoint": "video_info",
"pathParams": {
"id": id
}
}
AddFeedSourceBookmark(feedSource, id, bookmarkGroupNode)
end function
function AddPlaylistBookmark(id as string, groupName as string)
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
feedSource = {
"apiType": "Invidious",
"endpoint": "playlist_info",
"pathParams": {
"plid": id
}
}
AddFeedSourceBookmark(feedSource, id, bookmarkGroupNode)
end function
function AddPlaylistBookmarkWithSpread(id as string, groupName as string)
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
feedSource = {
"id": `inv_playlist_${id}`,
"title": `${groupName} videos`,
"apiType": "Invidious",
"endpoint": "playlist",
"pathParams": {
"plid": id
}
}
AddFeedSourceBookmark(feedSource, `inv_playlist_${id}`, bookmarkGroupNode)
feedSource = {
"apiType": "Invidious",
"endpoint": "playlist_info",
"pathParams": {
"plid": id
}
}
AddFeedSourceBookmark(feedSource, id, bookmarkGroupNode)
end function
function AddChannelBookmark(id as string, groupName as string)
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
feedSource = {
"apiType": "Invidious",
"endpoint": "channel_info",
"pathParams": {
"ucid": id
}
}
AddFeedSourceBookmark(feedSource, id, bookmarkGroupNode)
end function
function AddChannelBookmarkWithSpread(id as string, groupName as string)
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
feedSource = {
"id": `inv_channel_videos_${id}`,
"title": `${groupName} videos`,
"apiType": "Invidious",
"endpoint": "channel_videos",
"pathParams": {
"ucid": id
}
}
AddFeedSourceBookmark(feedSource, `inv_channel_videos_${id}`, bookmarkGroupNode)
feedSource = {
"apiType": "Invidious",
"endpoint": "channel_info",
"pathParams": {
"ucid": id
}
}
AddFeedSourceBookmark(feedSource, id, bookmarkGroupNode)
end function
function RemoveBookmark(id as string) as void
node = m.top.content.findNode(id)
if node = invalid
return
end if
group = node.getParent()
group.removeChild(node)
LogInfo("Removed bookmark:", id)
if group.getChildCount() = 0
m.top.content.removeChild(group)
LogInfo("Removed bookmark group:", group.title)
end if
m.top.contentChange = true
end function
function OnContentChange(event as object) as void
Save()
end function
function GetContextMenuOptionsForItem(item as object) as object
options = []
if item.type = "video"
options.append(GetMenuForVideo(item))
else if item.type = "playlist"
options.append(GetMenuForPlaylist(item))
else if item.type = "channel"
options.append(GetMenuForChannel(item))
end if
options.append(GetMenuForParentFeedSource(item))
return options
end function
function GetMenuForVideo(videoNode as object) as object
videoId = videoNode.videoId
if StringUtils.IsNullOrEmpty(videoId)
return []
end if
menu = []
bookmark = m.top.content.findNode(videoId)
isInBookmarks = bookmark <> invalid
if isInBookmarks
bookmarkGroup = bookmark.getParent()
item = ContextMenuUtils.CreateOption(`Remove from "${bookmarkGroup.title}" bookmarks`, m.top, "RemoveBookmark", [videoId])
menu.push(item)
else
item = ContextMenuUtils.CreateOption(`Add to "${VIDEOS_GROUP}" bookmark`, m.top, "AddVideoBookmark", [videoId, VIDEOS_GROUP])
menu.push(item)
end if
return menu
end function
function GetMenuForPlaylist(playlistNode as object) as object
playlistId = playlistNode.playlistId
if StringUtils.IsNullOrEmpty(playlistId) or playlistId.StartsWith("IV")
return []
end if
menu = []
bookmark = m.top.content.findNode(playlistId)
isInBookmarks = bookmark <> invalid
if isInBookmarks
bookmarkGroup = bookmark.getParent()
item = ContextMenuUtils.CreateOption(`Remove from "${bookmarkGroup.title}" bookmarks`, m.top, "RemoveBookmark", [playlistId])
menu.push(item)
else
item = ContextMenuUtils.CreateOption(`Add to "${PLAYLISTS_GROUP}" bookmark`, m.top, "AddPlaylistBookmark", [playlistId, PLAYLISTS_GROUP])
menu.push(item)
item = ContextMenuUtils.CreateOption(`Add to "${playlistNode.title}" bookmark`, m.top, "AddPlaylistBookmarkWithSpread", [playlistId, playlistNode.title])
menu.push(item)
end if
return menu
end function
function GetMenuForChannel(channelNode as object) as object
authorId = channelNode.authorId
if StringUtils.IsNullOrEmpty(authorId)
return []
end if
menu = []
bookmark = m.top.content.findNode(authorId)
isInBookmarks = bookmark <> invalid
if isInBookmarks
bookmarkGroup = bookmark.getParent()
item = ContextMenuUtils.CreateOption(`Remove from "${bookmarkGroup.title}" bookmarks`, m.top, "RemoveBookmark", [authorId])
menu.push(item)
else
item = ContextMenuUtils.CreateOption(`Add to "${CHANNELS_GROUP}" bookmark`, m.top, "AddChannelBookmark", [authorId, CHANNELS_GROUP])
menu.push(item)
item = ContextMenuUtils.CreateOption(`Add to "${channelNode._author}" bookmark`, m.top, "AddChannelBookmarkWithSpread", [authorId, channelNode._author])
menu.push(item)
end if
return menu
end function
function GetMenuForParentFeedSource(itemNode as object) as object
if itemNode = invalid
return []
end if
if itemNode.type <> "video" and itemNode.type <> "playlist" and itemNode.type <> "channel"
return []
end if
if not IsInt(itemNode.feedSourcesIndex) or itemNode.feedSourcesIndex = -1
return []
end if
feedContentNode = itemNode.getParent()
if feedContentNode = invalid or feedContentNode.subtype() <> "FeedContentNode"
return []
end if
feedSource = feedContentNode.feedSources[itemNode.feedSourcesIndex]
if StringUtils.IsNullOrEmpty(feedSource.title) or StringUtils.IsNullOrEmpty(feedSource.id)
return []
end if
title = feedSource.title
feedSourceId = feedSource.id
menu = []
isInBookmarks = m.top.content.findNode(feedSourceId) <> invalid
if isInBookmarks
item = ContextMenuUtils.CreateOption(`Remove "${feedSource.title}" from bookmarks`, m.top, "RemoveBookmark", [feedSourceId])
menu.push(item)
else
item = ContextMenuUtils.CreateOption(`Add to "${title}" bookmark`, m.top, "AddFeedSourceBookmark", [feedSource, feedSourceId, title])
menu.push(item)
end if
return menu
end function
@@ -0,0 +1,20 @@
<component name="Bookmarks" extends="Node" includes="ContextMenuProvider">
<interface>
<field id="__version" type="integer" value="1" />
<field id="content" type="node" />
<field id="contentChange" type="boolean" alwaysNotify="true" />
<function name="AddFeedSourceBookmark" />
<function name="AddVideoBookmark" />
<function name="AddPlaylistBookmark" />
<function name="AddPlaylistBookmarkWithSpread" />
<function name="AddChannelBookmark" />
<function name="AddChannelBookmarkWithSpread" />
<function name="RemoveBookmark" />
<function name="GetMenuForVideo" />
<function name="GetMenuForPlaylist" />
<function name="GetMenuForChannel" />
</interface>
<children>
<ContentNode id="content" />
</children>
</component>
@@ -0,0 +1,373 @@
import "pkg:/components/Web/WebServer/Http/HttpUtils.bs"
import "pkg:/source/services/XmlObject.bs"
import "pkg:/source/utils/StringUtils.bs"
class DashManifest
public invidiousInstance as dynamic
function new(invidiousInstance as string)
m.utils = new Http.Utils()
m.invidiousInstance = invidiousInstance
end function
function fromVideoMetadata(metadata as object, local as boolean) as string
adaptiveFormats = []
adaptiveFormats.Append (metadata.adaptiveFormats)
if local
urlRegex = CreateObject("roRegex", "https?:\/\/\S+(\/\S+)", "i")
for i = 0 to adaptiveFormats.Count() - 1
adaptiveFormats[i].url = urlRegex.replace(adaptiveFormats[i].url, m.invidiousInstance + "\1")
end for
end if
audioStreams = m.getAudioStreams(adaptiveFormats)
videoStreams = m.getVideoStreams(adaptiveFormats)
videoMimeTypes = m.getMimeTypes(videoStreams)
audioSets = m.getMimeTypeLanguageCombos(audioStreams)
storyboards = metadata.storyboards
xml = new XmlObject()
if xml.Node("MPD", {
"xmlns": "urn:mpeg:dash:schema:mpd:2011",
"profiles": "urn:mpeg:dash:profile:full:2011",
"minBufferTime": "PT1.5S",
"type": "static",
"mediaPresentationDuration": `PT${metadata.lengthSeconds ?? 0}S`
})
if xml.Node("Period")
id = 0
for each audioSet in audioSets
adaptationSetAttributes = {
"id": `${id}`,
"mimeType": audioSet.mimeType,
"startWithSAP": "1",
"subsegmentAlignment": "true"
}
if not StringUtils.IsNullOrEmpty(audioSet.lang)
adaptationSetAttributes["lang"] = audioSet.lang
end if
if xml.Node("AdaptationSet", adaptationSetAttributes)
xml.Node("Role", {
"schemeIdUri": "urn:mpeg:dash:role:2011",
"value": audioSet.acont = "original" ? "main" : "alternate"
})
xml.End()
for i = 0 to audioStreams.Count() - 1
stream = audioStreams[i]
streamMimeType = stream.type.Tokenize(";")[0]
if streamMimeType <> audioSet.mimeType or stream.languageInfo.lang <> audioSet.lang or stream.languageInfo.acont <> audioSet.acont
continue for
end if
codecs = stream.type.split("codecs=")[1]
if codecs.startsWith(`"`)
codecs = codecs.mid(1)
end if
if codecs.endsWith(`"`)
codecs = codecs.left(codecs.len() - 1)
end if
if xml.Node("Representation", {
"id": stream.itag,
"codecs": codecs,
"bandwidth": stream.bitrate
})
xml.Node("AudioChannelConfiguration", {
"schemeIdUri": "urn:mpeg:dash:23003:3:audio_channel_configuration:2011",
"value": `${stream.audioChannels}`
})
xml.End()
if xml.Node("BaseURL")
xml.Text(stream.url)
xml.End()
end if
if xml.Node("SegmentBase", {
"indexRange": stream.index
})
if xml.Node("Initialization", {
"range": stream.init
})
xml.End()
end if
xml.End()
end if
xml.End()
end if
end for
xml.End()
end if
id += 1
end for
for each mimeType in videoMimeTypes
if xml.Node("AdaptationSet", {
"id": `${id}`,
"mimeType": mimeType,
"startWithSAP": "1",
"subsegmentAlignment": "true"
})
for i = 0 to videoStreams.Count() - 1
stream = videoStreams[i]
streamMimeType = stream.type.Tokenize(";")[0]
if streamMimeType <> mimeType
continue for
end if
codecs = stream.type.split("codecs=")[1]
if codecs.startsWith(`"`)
codecs = codecs.mid(1)
end if
if codecs.endsWith(`"`)
codecs = codecs.left(codecs.len() - 1)
end if
representationAttributes = {
"id": stream.itag,
"codecs": codecs,
"startWithSAP": "1",
"maxPlayoutRate": "1",
"bandwidth": stream.bitrate
}
if stream.width <> invalid
representationAttributes["width"] = `${stream.width}`
end if
if stream.height <> invalid
representationAttributes["height"] = `${stream.height}`
end if
if stream.fps <> invalid
representationAttributes["frameRate"] = `${stream.fps}`
end if
if xml.Node("Representation", representationAttributes)
if xml.Node("BaseURL")
xml.Text(stream.url)
xml.End()
end if
if xml.Node("SegmentBase", {
"indexRange": stream.index
})
if xml.Node("Initialization", {
"range": stream.init
})
xml.End()
end if
xml.End()
end if
xml.End()
end if
end for
xml.End()
end if
id += 1
end for
' https://developer.roku.com/en-ca/docs/developer-program/media-playback/trick-mode/hls-and-dash.md#dash-standard-thumbnail-tiles
for each storyboard in storyboards
interval = ValidInt(storyboard.interval)
if interval = 0
LogWarn("Invalid storyboard interval=0")
continue for
end if
templateUrl = storyboard.templateUrl
if templateUrl.Instr("$M") = -1
LogWarn("Invalid storyboard url: url does not contain $M:", templateUrl)
continue for
end if
storyboardWidth = storyboard.storyboardWidth
storyboardHeight = storyboard.storyboardHeight
storyboardCount = storyboard.storyboardCount
tileWidthInPixels = storyboard.width
tileHeightInPixels = storyboard.height
totalTileCount = storyboard.count
' For the last page, the image height might be smaller than the storyboard height
if storyboardCount = 1
storyboardHeight = totalTileCount \ storyboardWidth
if totalTileCount mod storyboardWidth > 0
storyboardHeight += 1
end if
end if
intervalInSeconds = interval \ 1000
' Youtube template uses the var $M for tile pages
' DASH-IF uses $Number$ in the SegmentTemplate
' https://dashif.org/docs/DASH-IF-IOP-v4.3.pdf
url = templateUrl.replace("$M", "$Number$")
tilesPerPage = storyboardWidth * storyboardHeight
duration = tilesPerPage * intervalInSeconds
storyboardWidthInPixels = tileWidthInPixels * storyboardWidth
storyboardHeightInPixels = tileHeightInPixels * storyboardHeight
' Bandwidth is kind of a guess...
bandwidth = ((storyboardWidthInPixels * storyboardHeightInPixels * 0.5) / duration)
if xml.Node("AdaptationSet", {
"id": `${id}`,
"mimeType": "image/jpeg",
"contentType": "image"
})
xml.Node("SegmentTemplate", {
"media": url,
"duration": duration,
"startNumber": 0
})
xml.End()
if xml.Node("Representation", {
"id": `thumbnails_${id}`,
"bandwidth": bandwidth,
"width": storyboardWidthInPixels,
"height": storyboardHeightInPixels
})
xml.Node("EssentialProperty", {
"schemeIdUri": "http://dashif.org/guidelines/thumbnail_tile",
"value": `${storyboardWidth}x${storyboardHeight}`
})
xml.End()
xml.End()
end if
xml.End()
end if
id += 1
end for
xml.End()
end if
xml.End()
end if
return xml.ToXmlString()
end function
function getAudioStreams(streams as object) as object
audioStreams = []
for i = 0 to streams.Count() - 1
stream = streams[i]
if stream.type.startsWith("audio/")
if stream.bitrate = invalid
LogWarn("Invalid audio stream bitrate, itag:", stream.itag)
continue for
end if
if stream.init = invalid
LogWarn("Invalid audio stream init, itag:", stream.itag)
continue for
end if
if stream.index = invalid
LogWarn("Invalid audio stream index, itag:", stream.itag)
continue for
end if
stream.languageInfo = m.ParseAudioLanguage(stream.url)
audioStreams.Push(stream)
end if
end for
audioStreams.SortBy("bitrate", "r")
return audioStreams
end function
function getVideoStreams(streams as object) as object
videoStreams = []
for i = 0 to streams.Count() - 1
stream = streams[i]
if stream.type.startsWith("video/")
if stream.bitrate = invalid
LogWarn("Invalid video stream bitrate, itag:", stream.itag)
continue for
end if
if stream.init = invalid
LogWarn("Invalid video stream init, itag:", stream.itag)
continue for
end if
if stream.index = invalid
LogWarn("Invalid video stream index, itag:", stream.itag)
continue for
end if
videoStreams.Push(stream)
end if
end for
videoStreams.SortBy("bitrate", "r")
return videoStreams
end function
function getMimeTypes(streams as object) as object
mimeTypes = {}
for i = 0 to streams.Count() - 1
stream = streams[i]
mimeType = stream.type.Tokenize(";")[0]
mimeTypes[mimeType] = true
end for
return mimeTypes.Keys()
end function
function getMimeTypeLanguageCombos(streams as object) as object
types = {}
for i = 0 to streams.Count() - 1
stream = streams[i]
mimeType = stream.type.Tokenize(";")[0]
types[`${mimeType}-${stream.languageInfo.lang}-${stream.languageInfo.acont}`] = {
"mimeType": mimeType,
"lang": stream.languageInfo.lang,
"acont": stream.languageInfo.acont
}
end for
combos = []
for each t in types
combos.Push(types[t])
end for
return combos
end function
function ParseAudioLanguage(url as string) as object
result = { lang: "", acont: "" }
queryParams = m.utils.ParseUrlQueryComponents(url)
if StringUtils.IsNullOrEmpty(queryParams["xtags"])
return result
end if
xtags = queryParams["xtags"].split(":")
for each xtag in xtags
if xtag.instr("=") > 0
parts = xtag.split("=")
if parts.Count() = 2
if parts[0] = "lang"
result["lang"] = parts[1]
end if
if parts[0] = "acont"
result["acont"] = parts[1]
end if
end if
end if
end for
return result
end function
end class
@@ -1,7 +1,9 @@
import "InvidiousService.bs"
import "InvidiousSubscriptionsTask.bs"
import "pkg:/source/asyncTask/asyncTask.bs"
function Init()
m.top.apiDefinitions = ParseJson(ReadAsciiFile("libpkg:/config/invidious_video_api.json5"))
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
@@ -17,3 +19,18 @@ 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
function GetSubscriptions() as void
if m.subscriptionsTask <> invalid
m.subscriptionsTask.cancel = true
end if
if m.top.authToken = invalid
m.top.subscriptions = invalid
return
end if
m.subscriptionsTask = StartAsyncTask(InvidiousSubscriptionsTask, { invidious: m.top })
end function
@@ -4,8 +4,10 @@
<field id="preferences" type="node" />
<field id="webServer" type="node" />
<field id="authToken" type="assocarray" />
<field id="authToken" type="assocarray" onChange="OnAuthTokenChange" />
<field id="apiDefinitions" type="assocarray" />
<field id="refreshSubscribtions" type="boolean" alwaysNotify="true" onChange="GetSubscriptions" />
<field id="subscriptions" type="assocarray" />
<function name="GetCurrentInstance" />
<function name="GetAuthorizeTokenLink" />
@@ -22,8 +22,10 @@ namespace Invidious
const SEARCH_SUGGEST_ENDPOINT = "/api/v1/search/suggestions"
const AUTH_SCOPES = "GET:feed,GET:playlists*,POST:tokens/register,POST:tokens/unregister,POST:history*"
const AUTH_SCOPES = "GET:feed,GET:playlists*,POST:tokens/*,POST:history*,:subscriptions*"
const AUTH_PLAYLISTS = "/api/v1/auth/playlists"
const AUTH_SUBSCRIPTIONS = "/api/v1/auth/subscriptions"
const AUTH_TOKENS_UNREGISTER = "/api/v1/auth/tokens/unregister"
const AUTH_TOKENS_REGISTER = "/api/v1/auth/tokens/register"
@@ -36,19 +38,16 @@ namespace Invidious
function new(node as object)
m.node = node
' TODO:P2 api definitions are not needed everytime, move them to a separate function and lazy load
apiDefinitions = node.apiDefinitions
m.endpoints = {}
for each apiDefinition in apiDefinitions.endpoints
m.endpoints[apiDefinition.name] = apiDefinition
end for
m.endpoints = node.apiDefinitions
m.responseHanlders = {
DefaultHandler: m.DefaultHandler,
AuthFeedHandler: m.AuthFeedHandler,
PlaylistHandler: m.PlaylistHandler,
VideoInfoHandler: m.VideoInfoHandler,
PlaylistInfoHandler: m.PlaylistInfoHandler,
ChannelInfoHandler: m.ChannelInfoHandler,
ChannelVideosHandler: m.ChannelVideosHandler,
ChannelPlaylistsHandler: m.ChannelPlaylistsHandler,
ChannelRelatedChannelsHandler: m.ChannelRelatedChannelsHandler
@@ -89,7 +88,7 @@ namespace Invidious
url = `${authToken.instance}${Invidious.HISTORY_ENDPOINT}/${videoId}`
request = HttpClient.Post(url, "")
request.Headers(m.GetAuthenticationHeaders(authToken.token))
request.SendAndForget()
request.Await()
end function
function SearchSuggestions(q as string, cancellation = invalid as object) as object
@@ -99,7 +98,11 @@ namespace Invidious
request = HttpClient.Get(url)
request.QueryParams(m.DefaultQueryParams())
request.QueryParam("q", q)
request.CacheSeconds(60 * 60 * 6)' 6 hours
' 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)
request.Cancellation(cancellation)
@@ -145,6 +148,8 @@ namespace Invidious
request = HttpClient.Get(url)
request.QueryParams(m.DefaultQueryParams())
request.Cancellation(cancellation)
request.CacheSeconds(60 * 60 * 24)' 24 hours
request.TryCount(3)
return request.Await()
end function
@@ -154,39 +159,50 @@ namespace Invidious
return `${instance}/latest_version?id=${videoId}`
end function
function MarkFeedPagination(contentNode as object) as void
requestData = contentNode.feed
function MarkFeedPagination(feedContentNode as object) as object
feedSources = feedContentNode.feedSources
feedSourcesIndex = feedContentNode.feedSourcesIndex
endpoint = m.endpoints[requestData.endpoint]
feedSource = feedSources[feedSourcesIndex]
endpoint = m.endpoints[feedSource.endpoint]
if endpoint = invalid or StringUtils.IsNullOrEmpty(endpoint.paginationType)
return
return feedSource
end if
if not requestData.DoesExist("queryParams")
requestData.queryParams = {}
feedSourceState = feedSource.state
if not feedSourceState.DoesExist("queryParams")
feedSourceState["queryParams"] = {}
end if
contentNode.paginationType = endpoint.paginationType
if endpoint.paginationType = PaginationType.Pages
contentNode.page += 1
requestData.queryParams.page = contentNode.page
else if endpoint.paginationType = PaginationType.Continuation
continuation = contentNode.continuation
feedSourceState.paginationType = endpoint.paginationType
if feedSourceState.paginationType = PaginationType.Pages
if not IsInt(feedSourceState.page)
feedSourceState.page = 0
end if
feedSourceState.page += 1
feedSourceState.queryParams.page = feedSourceState.page
else if feedSourceState.paginationType = PaginationType.Continuation
continuation = feedSourceState.continuation
if not StringUtils.IsNullOrEmpty(continuation)
requestData.queryParams.continuation = continuation
feedSourceState.queryParams.continuation = continuation
else
feedSourceState.queryParams.Delete("continuation")
end if
end if
contentNode.feed = requestData
feedSource.state = feedSourceState
feedSources[feedSourcesIndex] = feedSource
feedContentNode.feedSources = feedSources
return feedSource
end function
function MakeRequest(requestData as object, cancellation = invalid as object) as object
endpoint = m.endpoints[requestData.endpoint]
function MakeRequest(feedSource as object, additionalQueryParams = invalid as object, cancellation = invalid as object) as object
endpoint = m.endpoints[feedSource.endpoint]
if endpoint = invalid
return {
success: false,
error: `Endpoint ${requestData.endpoint} not found`
error: `Endpoint ${feedSource.endpoint} not found`
}
end if
@@ -229,18 +245,28 @@ namespace Invidious
end for
end if
if requestData.cacheSeconds <> invalid
request.CacheSeconds(requestData.cacheSeconds)
if feedSource.cacheSeconds <> invalid
request.CacheSeconds(feedSource.cacheSeconds)
else if endpoint.cacheSeconds <> invalid
request.CacheSeconds(endpoint.cacheSeconds)
end if
if requestData.queryParams <> invalid
request.QueryParams(requestData.queryParams)
if feedSource.tryCount <> invalid
request.TryCount(feedSource.tryCount)
else if endpoint.tryCount <> invalid
request.TryCount(endpoint.tryCount)
end if
if requestData.pathParams <> invalid
request.PathParams(requestData.pathParams)
if feedSource.queryParams <> invalid
request.QueryParams(feedSource.queryParams)
end if
if additionalQueryParams <> invalid
request.QueryParams(additionalQueryParams)
end if
if feedSource.pathParams <> invalid
request.PathParams(feedSource.pathParams)
end if
request.Cancellation(cancellation)
@@ -249,7 +275,7 @@ namespace Invidious
responseHandler = endpoint.responseHandler <> invalid ? m.responseHanlders[endpoint.responseHandler] : m.responseHanlders["DefaultHandler"]
result = responseHandler(m, requestData, response)
result = responseHandler(m, feedSource, response)
if response.IsSuccess() and result <> invalid
return {
@@ -264,7 +290,7 @@ namespace Invidious
end if
end function
function DefaultHandler(m as object, requestData as object, response as object) as object
function DefaultHandler(m as object, feedSource as object, response as object) as object
if response.StatusCode() = 200
json = response.Json()
return {
@@ -274,7 +300,7 @@ namespace Invidious
return invalid
end function
function PlaylistHandler(m as object, requestData as object, response as object) as object
function PlaylistHandler(m as object, feedSource as object, response as object) as object
if response.StatusCode() = 200
json = response.Json()
return {
@@ -284,7 +310,7 @@ namespace Invidious
return invalid
end function
function ChannelVideosHandler(m as object, requestData as object, response as object) as object
function ChannelVideosHandler(m as object, feedSource as object, response as object) as object
if response.StatusCode() = 200
json = response.Json()
return {
@@ -295,7 +321,7 @@ namespace Invidious
return invalid
end function
function ChannelPlaylistsHandler(m as object, requestData as object, response as object) as object
function ChannelPlaylistsHandler(m as object, feedSource as object, response as object) as object
if response.StatusCode() = 200
json = response.Json()
return {
@@ -306,7 +332,7 @@ namespace Invidious
return invalid
end function
function ChannelRelatedChannelsHandler(m as object, requestData as object, response as object) as object
function ChannelRelatedChannelsHandler(m as object, feedSource as object, response as object) as object
if response.StatusCode() = 200
json = response.Json()
return {
@@ -317,21 +343,66 @@ namespace Invidious
return invalid
end function
function AuthFeedHandler(m as object, requestData as object, response as object) as object
m.DeleteExpiredToken(response)
function VideoInfoHandler(m as object, feedSource as object, response as object) as object
if response.StatusCode() = 200
json = response.Json()
videos = []
videos.Append(json.notifications)
videos.Append(json.videos)
json.type = "video"
return {
items: videos
items: [json]
}
end if
return invalid
end function
function PlaylistInfoHandler(m as object, feedSource as object, response as object) as object
if response.StatusCode() = 200
json = response.Json()
json.type = "playlist"
return {
items: [json]
}
end if
return invalid
end function
function ChannelInfoHandler(m as object, feedSource as object, response as object) as object
if response.StatusCode() = 200
json = response.Json()
json.type = "channel"
return {
items: [json]
}
end if
return invalid
end function
function AuthFeedHandler(m as object, feedSource as object, response as object) as object
m.DeleteExpiredToken(response)
if response.StatusCode() <> 200
return invalid
end if
json = response.Json()
if json = invalid
return invalid
end if
videos = []
if IsArray(json.notifications)
videos.Append(json.notifications)
end if
if IsArray(json.videos)
videos.Append(json.videos)
end if
return {
items: videos
}
end function
function DeleteExpiredToken(response as object)
if response.StatusCode() = 403
LogWarn(`Invidious instance responded with 403: ${response.Text()}`)
@@ -411,7 +482,7 @@ namespace Invidious
request.Headers(m.GetAuthenticationHeaders(authToken.token))
request.Header("Content-Type", "application/json")
request.SendAndForget()
request.Await()
end function
function GetAuthorizeTokenLink() as dynamic
@@ -431,6 +502,47 @@ namespace Invidious
return `${invidiousHost}/authorize_token?scopes=${scope}&callback_url=${callbackUrl}&expire=${expire}`
end function
function GetSubscriptions(cancellation = invalid as object) as object
authToken = m.node.authToken
if authToken = invalid
return invalid
end if
url = `${authToken.instance}${Invidious.AUTH_SUBSCRIPTIONS}`
request = HttpClient.Get(url)
request.Headers(m.GetAuthenticationHeaders(authToken.token))
request.Cancellation(cancellation)
return request.Await()
end function
function Subscribe(channelId as string, cancellation = invalid as object) as object
authToken = m.node.authToken
if authToken = invalid
return invalid
end if
url = `${authToken.instance}${Invidious.AUTH_SUBSCRIPTIONS}/${channelId}`
request = HttpClient.Post(url, "")
request.Headers(m.GetAuthenticationHeaders(authToken.token))
request.Cancellation(cancellation)
return request.Await()
end function
function Unsubscribe(channelId as string, cancellation = invalid as object) as object
authToken = m.node.authToken
if authToken = invalid
return invalid
end if
url = `${authToken.instance}${Invidious.AUTH_SUBSCRIPTIONS}/${channelId}`
request = HttpClient.Delete(url)
request.Headers(m.GetAuthenticationHeaders(authToken.token))
request.Cancellation(cancellation)
return request.Await()
end function
end class
end namespace
@@ -0,0 +1,42 @@
import "InvidiousService.bs"
import "pkg:/source/utils/Logging.bs"
@asynctask
function InvidiousSubscriptionsTask(input as object) as object
invidiousNode = input.invidious
service = new Invidious.InvidiousService(invidiousNode)
response = service.GetSubscriptions(m.top.cancellation)
if m.top.cancel
return invalid
end if
subscriptions = response.Json()
if not response.IsSuccess() or subscriptions = invalid
error = response.ErrorMessage()
LogError("Error getting subscriptions:", error)
return {
success: false,
error: response.ErrorMessage()
}
end if
if m.top.cancel
return invalid
end if
subscriptionsDict = {}
for each subscription in subscriptions
subscriptionsDict[subscription.authorId] = true
end for
invidiousNode.subscriptions = subscriptionsDict
return {
success: true
}
end function
@@ -34,16 +34,13 @@ namespace InvidiousContent
node.type = "video"
SetIfExists(node, "author", item, "author")
SetIfExists(node, "hlsUrl", item, "hlsUrl")
SetIfExists(node, "isUpcoming", item, "isUpcoming")
SetIfExists(node, "authorId", item, "authorId")
SetIfExists(node, "lengthSeconds", item, "lengthSeconds")
node.lengthText = TimeUtils.GetFormattedTime(item.lengthSeconds)
node.liveNow = VideoIsLive(item)
VideoSetPremiereTimestampText(node, item)
SetIfExists(node, "publishedText", item, "publishedText")
if not StringUtils.IsNullOrEmpty(instance)
node.thumbnail = VideoGetThumbnail(item, instance) ?? "pkg:/images/thumbnail-missing.jpg"
end if
VideoSetThumbnail(node, item, instance)
SetIfExists(node, "title", item, "title")
SetIfExists(node, "timestamp", item, "timestamp")
SetIfExists(node, "videoId", item, "videoId")
@@ -62,6 +59,7 @@ namespace InvidiousContent
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
SetIfExists(node, "_author", item, "author")
SetIfExists(node, "authorId", item, "authorId")
SetIfExists(node, "description", item, "description")
SetIfExists(node, "playlistId", item, "playlistId")
SetIfExists(node, "title", item, "title")
@@ -108,6 +106,7 @@ namespace InvidiousContent
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
SetIfExists(node, "_author", item, "author")
SetIfExists(node, "authorId", item, "authorId")
SetIfExists(node, "channelHandle", item, "channelHandle")
SetIfExists(node, "description", item, "description")
SetIfExists(node, "subCount", item, "subCount")
node.subCountText = GetChannelSubCountText(item)
@@ -126,10 +125,11 @@ namespace InvidiousContent
end if
end function
function VideoGetThumbnail(videoItem as object, instance as dynamic, quality = "medium" as string) as dynamic
function VideoSetThumbnail(node as object, videoItem as object, instance as dynamic, quality = "medium" as string) as boolean
videoThumbnails = videoItem.videoThumbnails
if videoThumbnails = invalid or videoThumbnails.Count() = 0
return invalid
node.thumbnail = "pkg:/images/thumbnail-missing.jpg"
return false
end if
url = invalid
for each thumbnail in videoThumbnails
@@ -141,10 +141,14 @@ namespace InvidiousContent
if url = invalid
url = videoThumbnails[0].url
end if
if url.startsWith("/") and not StringUtils.IsNullOrEmpty(instance)
if url.startsWith("/")
if StringUtils.IsNullOrEmpty(instance)
return false
end if
url = instance + url
end if
return url
node.thumbnail = url
return true
end function
function VideoIsLive(videoItem as object) as boolean
@@ -156,11 +160,12 @@ namespace InvidiousContent
end function
function VideoIsUpcoming(videoItem as object) as boolean
return videoItem.isUpcoming = true
return videoItem.isUpcoming = true and ValidInt(videoItem.premiereTimestamp) <> 0
end function
function VideoSetPremiereTimestampText(node as object, videoItem as object)
if VideoIsUpcoming(videoItem) and videoItem.premiereTimestamp <> invalid
if VideoIsUpcoming(videoItem)
node.isUpcoming = true
node.premiereTimestampText = `Premeres in ${TimeUtils.GetFormattedTimeLeft(videoItem.premiereTimestamp)}`
end if
end function
@@ -205,7 +210,9 @@ namespace InvidiousContent
end if
thumbnail = thumbnailUrl
else if playlistItem.videos <> invalid and playlistItem.videos.Count() > 0 and playlistItem.videos[0].index = 0
thumbnail = VideoGetThumbnail(playlistItem.videos[0], instance, quality)
if VideoSetThumbnail(node, playlistItem.videos[0], instance, quality)
return
end if
else if node.getChildCount() > 0
thumbnail = node.getChild(0).thumbnail
end if
@@ -0,0 +1,18 @@
import "pkg:/components/Services/SearchHistory/SearchHistoryUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
end function
function OnNodeReady()
OnSearchHistoryPreference()
m.preferences.observeFieldScoped("search_history.enabled", FuncName(OnSearchHistoryPreference))
end function
function OnSearchHistoryPreference() as void
seachHistoryEnabled = m.preferences["search_history.enabled"]
if seachHistoryEnabled
return
end if
SearchHistoryUtils.Clear()
end function
@@ -0,0 +1,5 @@
<component name="SearchHistory" extends="Node" includes="AutoBind">
<interface>
<field id="preferences" type="node" />
</interface>
</component>
@@ -2,9 +2,14 @@ import "pkg:/source/utils/ArrayUtils.bs"
import "pkg:/source/utils/RegistryUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
namespace SearchHistory
function Save(q as string, maxItems = 10 as integer)
history = GetAllSaved()
namespace SearchHistoryUtils
function Save(preferencesNode as object, q as string, maxItems = 10 as integer) as void
seachHistoryEnabled = preferencesNode["search_history.enabled"]
if not seachHistoryEnabled
return
end if
history = GetAllSaved(preferencesNode)
index = ArrayUtils.IndexOfString(history, q)
if index <> -1
history.Delete(index)
@@ -21,8 +26,8 @@ namespace SearchHistory
RegistryUtils.Write(RegistryUtils.SEARCH_HISTORY, history)
end function
function GetSaved(q as string) as object
history = GetAllSaved()
function GetSaved(preferencesNode as object, q as string) as object
history = GetAllSaved(preferencesNode)
if history.count() = 0
return []
end if
@@ -39,7 +44,12 @@ namespace SearchHistory
return result
end function
function GetAllSaved() as object
function GetAllSaved(preferencesNode as object) as object
seachHistoryEnabled = preferencesNode["search_history.enabled"]
if not seachHistoryEnabled
return []
end if
history = RegistryUtils.Read(RegistryUtils.SEARCH_HISTORY)
if history = invalid
return []
@@ -47,7 +57,6 @@ namespace SearchHistory
return ParseJson(history)
end function
function Clear()
RegistryUtils.Delete(RegistryUtils.SEARCH_HISTORY)
end function
Loaded 100 of 220 files, more files were not shown because too many files have changed in this diff. Show more