Compare commits

..
57 Commits
Author SHA1 Message Date
Brahim Hadriche e59e45e310 Release v0.18.1 (#248) 2024-01-02 12:48:57 -05:00
Brahim Hadriche 2548fb9097 Fix/invalid subs (#247)
* Sort

* Remove invalid

* Fix for unsupported subtitles

* Actually disable unsupported subs
2024-01-02 12:34:44 -05:00
Brahim Hadriche 1cb80f71b5 Use asyncStopSemantics to prevent execution timeout crashes (#246)
* Use asyncStopSemantics to prevent execution timeout crashes

* Clarify

* Changelog

* no message
2024-01-02 11:05:47 -05:00
Brahim Hadriche 0a7a6c65e2 Bug fix 2024-01-02 10:57:14 -05:00
Brahim Hadriche 529b915d7f [skip ci] Add comment with supported subtitle languages 2024-01-01 15:15:21 -05:00
Brahim Hadriche a76a2cb77f [skip ci] typo 2024-01-01 13:01:49 -05:00
Brahim Hadriche 707739b901 small refactor 2024-01-01 10:52:14 -05:00
Brahim Hadriche 8c72258879 Add TODO 2024-01-01 10:40:13 -05:00
Brahim Hadriche d245c072e9 Remove Funny and News from home screen (#245) 2023-12-30 22:47:06 -05:00
Brahim Hadriche 0f000590a0 Fixes for RowList cells (#244)
* Fixes for RowList cells

* typo
2023-12-30 22:32:43 -05:00
Brahim Hadriche 93c1e48d39 Add TODO 2023-12-30 19:21:21 -05:00
d6c7d81347 [chore] update dependencies (#243)
* Add TODO

* update dependencies

* plugin fix

---------

Co-authored-by: Brahim Hadriche <brahim.hadriche@gmail.com>
Co-authored-by: iBicha <iBicha@users.noreply.github.com>
2023-12-29 22:46:52 -05:00
Brahim Hadriche 331f2ff3cb Add playlist updated field in web app 2023-12-29 17:58:30 -05:00
Brahim Hadriche 6c42fbe056 Add tab titles in web app 2023-12-29 11:04:19 -05:00
Brahim Hadriche 7e8c828007 Remove legacy stuff 2023-12-28 18:17:42 -05:00
Brahim Hadriche ba59aad767 Release v0.18.0 (#240) 2023-12-28 14:27:28 -05:00
Brahim Hadriche 36ae525154 Fix another bug related to public instances 2023-12-28 14:19:45 -05:00
Brahim Hadriche 5ef130bc51 Fix tests 2023-12-23 10:55:58 -05:00
Brahim Hadriche 39591abc34 Adjust diagnostic filters 2023-12-23 10:52:08 -05:00
Brahim Hadriche 84bd50d970 Update bsc 2023-12-23 10:39:17 -05:00
fd0259615b [chore] update dependencies (#239)
* update dependencies

* Revert bsc update

---------

Co-authored-by: iBicha <iBicha@users.noreply.github.com>
Co-authored-by: Brahim Hadriche <brahim.hadriche@gmail.com>
2023-12-22 19:53:58 -05:00
Brahim Hadriche e53ad785c6 Refresh lint rules (#238)
* Lint

* Color rules

* Update sponsorblock config file

* Small tweak

* Color adjustments
2023-12-22 19:36:36 -05:00
Brahim Hadriche cbda8dbf9b Fix formatting 2023-12-22 15:22:02 -05:00
Brahim Hadriche 242298911c Fix dialog palette 2023-12-22 15:19:19 -05:00
Brahim Hadriche 8f1d3778d8 Add unused arg validation rule 2023-12-22 11:42:51 -05:00
Brahim Hadriche 192401c847 Remove LOCAL_DASH feature flag 2023-12-22 10:54:42 -05:00
Brahim Hadriche 132e3ec3e3 Add a sleep before canary release as a workaround 2023-12-20 17:13:32 -05:00
Brahim Hadriche 3570f011c4 Formatting 2023-12-20 17:01:22 -05:00
Brahim Hadriche 482daf5e12 Color adjustments 2023-12-20 16:59:15 -05:00
Brahim Hadriche 64f5985aae Small bug fix 2023-12-20 16:42:45 -05:00
Brahim Hadriche a1aed7d253 Watch history (#232)
* [PoC] Watch history

* Render watch history on web app

* Changelog

* Log out user on insufficient access
2023-12-20 09:39:42 -05:00
Brahim Hadriche f581d568d9 Fix sponsor skip infinite loop bug (#231) 2023-12-19 20:02:15 -05:00
Brahim Hadriche 54b0acbe8f Add medium video quality video to the settings (#230) 2023-12-19 19:18:06 -05:00
Brahim Hadriche 6e4262e6a5 Support for legacy browsers (#228) 2023-12-18 22:18:38 -05:00
Brahim Hadriche 4c90cf1e98 Restart playlet from web app 2023-12-18 08:53:49 -05:00
Brahim Hadriche 72f547cc22 Styling fix for Safari 2023-12-18 08:25:59 -05:00
Brahim Hadricheandgithub-action linter 1cee5d61ab Feature/web socket (#180)
* Websockets

* Sending payloads

* Lint fix

* Remove example code

* Disable web sockets

* remove todo

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-12-17 11:51:53 -05:00
github-actions[bot]andiBicha d87337d389 update dependencies (#223)
Co-authored-by: iBicha <iBicha@users.noreply.github.com>
2023-12-15 21:31:01 -05:00
Brahim Hadriche 2ba2115da7 (Regression) Fix issue where auto-play keeps playing the same videos in a loop 2023-12-15 21:27:41 -05:00
Brahim Hadriche 49be599c32 No xmas 2023-12-13 16:51:31 -05:00
Brahim Hadriche 8d5646aeb3 Release v0.17.3 (#222) 2023-12-13 16:27:41 -05:00
Brahim Hadriche 07b0e422ff Xmas 2023-12-13 16:22:40 -05:00
Brahim Hadriche 35325bfae2 lint 2023-12-12 20:16:05 -05:00
Brahim Hadriche c122d286dc Missed a rename 2023-12-12 20:15:19 -05:00
Brahim Hadriche 66208d941d Adjust config files 2023-12-12 20:07:43 -05:00
Brahim Hadriche 9cf6626efb Adjust messages 2023-12-12 18:06:23 -05:00
Brahim Hadriche 69c87228af Create README.md 2023-12-12 09:38:40 -05:00
Brahim Hadriche 2502eae462 Add some randomness to loading messages 2023-12-11 08:46:58 -05:00
Brahim Hadriche b0e0c2d09d Small refactor in bootstrap scene 2023-12-11 08:19:15 -05:00
Brahim Hadriche 5982b5a75f validation rule for callFunc operator 2023-12-10 22:54:00 -05:00
Brahim Hadriche 51966cb33f Use local ip for dash 2023-12-10 22:35:53 -05:00
Brahim Hadriche bfe8a3c860 Downgrade todos 2023-12-10 22:14:14 -05:00
Brahim Hadriche ef17ff44af Update signing script 2023-12-10 15:51:53 -05:00
Brahim Hadriche 826228e939 Release v0.17.2 (#221) 2023-12-10 15:30:04 -05:00
Brahim Hadricheandgithub-action linter b77519493d Feature/loading messages (#220)
* Add loading message

* Add messages and cache file

* Lint fix

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-12-10 15:24:30 -05:00
Brahim Hadriche 6a46d4cd09 Fix typo 2023-12-09 09:32:38 -05:00
github-actions[bot]andiBicha 382cbe33d3 update dependencies (#218)
Co-authored-by: iBicha <iBicha@users.noreply.github.com>
2023-12-09 09:31:31 -05:00
193 changed files with 3903 additions and 1180 deletions

No files matched your search

+5
View File
@@ -64,6 +64,11 @@ jobs:
latest_release=$(awk 'BEGIN { RS="## \\[" } NR==2 { print "## ["$0 }' CHANGELOG.md)
echo -e "\n$latest_release" >> docs/canary-changelog.md
# A bug in gh cli causes the release to be created as a draft, and not released.
# See https://github.com/cli/cli/issues/8458
- name: Wait 10 seconds
run: sleep 10
- name: Create Canary release
run: gh release create canary ./release/playlet.zip ./release/playlet-lib.zip --notes-file docs/canary-changelog.md --prerelease --title Canary
env:
+2 -2
View File
@@ -31,6 +31,6 @@ jobs:
uses: peter-evans/create-pull-request@v5
with:
commit-message: "update dependencies"
branch: shore/update-deps
title: "[shore] update dependencies"
branch: chore/update-deps
title: "[chore] update dependencies"
body: "Weekly pull request to update dependencies."
+49
View File
@@ -5,6 +5,55 @@ 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.18.1] - 2024-01-02
### Fixed
- A rare bug that causes the app to crash when displaying video cells
- A rare bug where a long press can cause a crash
- [Attempt] to fix a crash caused by execution timeout when stopping a video takes too long
- Unsupported subtitles (subtitles that can be rendered will not be used)
### Removed
- `Funny` and `News` from the Home screen.
- These are not standard feeds (like `Trending`), and are just search results for `Funny` and `News`. They were added in earlier Playlet versions to have more content in the Home screen.
- If you like to add these two feeds to your bookmarks:
- Search for `Funny` (or `News`)
- Set the `Sort by` filter to `Upload date`
- Press and hold the `Ok` button while a video from the search result is selected
- Choose the `Add to "Search - Funny"` option
## [0.18.0] - 2023-12-28
### Added
- Medium video quality in the settings (For most videos, this is 360p)
- Invidious watch history feed
### Fixed
- (Regression) Issue where auto-play keeps playing the same videos in a loop
- Small search box styling bug for Safari
- A bug where the skipping of a sponsored section at the end of a video leads to an infinite loop
- A couple of bugs when listing Invidious public instances
### Removed
- Xmas theme logo - can't publish it before end of year... ([link](https://blog.roku.com/developer/channel-store-blackouts-2023))
## [0.17.3] - 2023-12-13
### Added
- Xmas theme logo
## [0.17.2] - 2023-12-10
### Added
- Loading message
## [0.17.1] - 2023-12-08
### Added
@@ -3,11 +3,16 @@
"createPackage": false,
"diagnosticFilters": [
{
"src": "**/roku_modules/**/*.*"
},
1090
"src": "**/*.part.xml",
"codes": [
// 1067 - Cannot find function with name '${name}' in component scope
// This is to prevent errors where the onChange function is not found in the component scope
1067
]
}
],
"diagnosticLevel": "error",
// The validation regex rules are validated using the validation-plugin.ts plugin
"validation": [
{
"code": "NO_SET_FOCUS",
@@ -20,6 +25,21 @@
"regex": "\\.observeField(scoped)?\\s*\\(\\s*\"\\w+\"\\s*,\\s*\"\\w+\"\\s*\\)",
"regexFlags": "ig",
"message": "observeField(\"field\", \"callback\") is not allowed. Use observeField(\"field\", FuncName(callback)) instead."
},
{
"code": "NO_INVALID_CALLFUNC_ARG",
"regex": "@\\.\\w+\\(invalid\\)",
"regexFlags": "ig",
"message": "the arg invalid in @.func(invalid) is not needed. Just use @.func() instead."
},
{
// Tagging unused variables (Available since Roku OS 11.0) – Variables can explicitly
// be marked as unused by prepending an underscore to the value (for example, sub myTask(_x)).
// https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#types
"code": "UNUSED_ARG_STARTS_WITH_UNDERSCORE",
"regex": "\\b(?!_unused)unused\\b",
"regexFlags": "ig",
"message": "unused args should start with _ (e.g. _unused)"
}
],
"files": [
@@ -56,10 +76,5 @@
"require": [
"ts-node/register"
],
"rokuLog": {
"insertPkgPath": true,
"removeComments": false,
"strip": false
},
"sourceMap": true
}
@@ -1,5 +1,5 @@
{
"extends": "bsconfig.base.json",
"extends": "bsconfig.base.jsonc",
"files": [
"source/**",
"components/**",
+21 -12
View File
@@ -5,23 +5,32 @@
"**/bslib.brs"
],
"rules": {
"aa-comma-style": "no-dangling",
"anon-function-style": "no-sub",
"assign-all-paths": "warn",
"block-if-style": "no-then",
"case-sensitivity": "warn",
"condition-style": "no-group",
"consistent-return": "error",
"eol-last": "always",
// Code style
"inline-if-style": "never",
"block-if-style": "no-then",
"condition-style": "no-group",
"named-function-style": "no-sub",
"anon-function-style": "no-sub",
"aa-comma-style": "never",
"no-print": "warn",
"no-stop": "error",
"no-todo": "off",
"no-stop": "error",
"eol-last": "always",
// Strictness
"type-annotations": "all",
"unreachable-code": "warn",
// Color
"color-format": "hash-hex",
"color-case": "upper",
"color-alpha": "always",
"color-alpha-defaults": "allowed",
"color-cert": "always",
// Code flow
"assign-all-paths": "error",
"unsafe-path-loop": "error",
"unsafe-iterators": "error",
"unsafe-path-loop": "warn",
"unused-variable": "warn"
"unreachable-code": "warn",
"case-sensitivity": "error",
"unused-variable": "error",
"consistent-return": "error"
}
}
+1 -1
View File
@@ -42,7 +42,7 @@ 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.**
- Switch to main branch and pull changes, **including tags** - **match commit corresponding to the release.**
- `npm run build:release:ci`
- This makes sure to have a valid app in the staging folder
- `npm run sign-released-package`
+1 -1
View File
@@ -2,7 +2,7 @@ openapi: 3.0.0
info:
title: Playlet Web API
version: 0.17.1
version: 0.18.1
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
+5 -2
View File
@@ -428,7 +428,7 @@ myNode = CreateObject("roSGNode", "MyComponent")
' Add it to the right parent
myParentNode.appendChild(myNode)
' Trigger the binding manually
myNode@.BindNode(invalid)
myNode@.BindNode()
```
calling `BindNode` will trigger all the binding steps just for this node. But it is expected that all its dependencies are already in the scene and can be found.
@@ -512,9 +512,11 @@ The logger plugin does some code transformation to log calls, which can add call
### How
The logger plugin searches for calls to the predefined functions `LogError`, `LogWarn`, `LogInfo` and `LogDebug`. Once found, it does the following (we take `LogError` as an example):
- It replaces calls of `LogError` with `LogErrorX` where X is the number of arguments.
- For example, it replaces `LogError("Cannot complete operation:", error)` with `LogError2("Cannot complete operation:", error)`
- Based on usage, it generates `LogErrorX` functions used. Example:
```
function LogError2(arg0, arg1) as void
logger = m.global.logger
@@ -524,11 +526,12 @@ function LogError2(arg0, arg1) as void
m.global.logger.logLine = "[ERROR]" + ToString(arg0) + " " + ToString(arg1)
end function
```
- Finally, it adds the caller file and line number to the args.
- `LogError("Cannot complete operation:", error)` is replaced with `LogError(CALLER, "Cannot complete operation:", error)`
- `CALLER` would be the full path to the source .bs file and line number, for easier debugging
- In release mode, `CALLER` would be only the file name and line number, without the full path. This is so that dev directory does not get "leaked" in releases.
This is implemented to make it easy to identify where logs came from, and to generate log functions with the right number of parameters based on usage. This way we do not need all combination of functions (`LogError`, `LogWarn`, `LogInfo` and `LogDebug` multiplied by number of parameters, `LogError1`, `LogError2`, `LogError3`, and so on). Since brightscript does not support function templates or function overloading, it is either this method, or use optional parameters (but then we would have to check which parameter was passed, and which was is using the default value.) and end up with a log function with logs of if's else'es.
To understand more about what's being generated, download `playlet-lib.zip` from [releases](https://github.com/iBicha/playlet/releases), extract, and inspect the file `source/utils/Logging.brs`. You will see it contains log functions in the form `LogVerbX`, that are generated based on usage.
+22 -154
View File
@@ -1,21 +1,21 @@
{
"name": "playlet",
"version": "0.17.1",
"version": "0.18.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet",
"version": "0.17.1",
"version": "0.18.1",
"hasInstallScript": true,
"devDependencies": {
"@rokucommunity/bslint": "^0.8.13",
"@types/crypto-js": "^4.2.1",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.10.4",
"@types/node": "^20.10.6",
"@types/xml2js": "^0.4.14",
"argparse": "^2.0.1",
"brighterscript": "0.65.10",
"brighterscript": "0.65.15",
"brighterscript-formatter": "^1.6.36",
"convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0",
@@ -28,11 +28,11 @@
"ip": "^1.1.8",
"json5": "^2.2.3",
"mailparser": "^3.6.5",
"roku-deploy": "^3.11.1",
"roku-deploy": "^3.11.2",
"rooibos-roku": "^5.8.0",
"semver": "^7.5.4",
"shelljs": "^0.8.5",
"ts-node": "^10.9.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"xml2js": "^0.6.2",
"yaml": "^2.3.4"
@@ -370,9 +370,9 @@
}
},
"node_modules/@types/node": {
"version": "20.10.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.4.tgz",
"integrity": "sha512-D08YG6rr8X90YB56tSIuBaddy/UXAA9RKJoFvrsnogAum/0pmjkgi4+2nx96A330FmioegBWmEYQ+syqCFaveg==",
"version": "20.10.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.6.tgz",
"integrity": "sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
@@ -728,9 +728,9 @@
}
},
"node_modules/brighterscript": {
"version": "0.65.10",
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.10.tgz",
"integrity": "sha512-JGBkH6VDgTfwTMHtvauwUeR8XAotuhURbtr3r9+zaWU/KyO0jwSCLUnoNUjSmsz9ddnWe6KOY3NpR5vVG/iraA==",
"version": "0.65.15",
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.15.tgz",
"integrity": "sha512-WDnHaeCQclDG8wic1SCLYavnZDSjjzHcWxo+efwYkvyTjZivPoGWXbEulsYM3Nm9VawPuWWwzVqzHiN0Y4RvxQ==",
"dev": true,
"dependencies": {
"@rokucommunity/bslib": "^0.1.1",
@@ -756,7 +756,7 @@
"parse-ms": "^2.1.0",
"readline": "^1.3.0",
"require-relative": "^0.8.7",
"roku-deploy": "^3.10.5",
"roku-deploy": "^3.11.2",
"serialize-error": "^7.0.1",
"source-map": "^0.7.4",
"vscode-languageserver": "7.0.0",
@@ -802,93 +802,6 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/brighterscript-formatter/node_modules/brighterscript": {
"version": "0.65.12",
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.12.tgz",
"integrity": "sha512-sXPLEH2CgjrPLFWi9tp2PXTNjS1S/6Xoa6EmafFauzYJBgXPKJd/ajzRNs5UPIJ4pqG0cst6NDWDHm7y2y4nEw==",
"dev": true,
"dependencies": {
"@rokucommunity/bslib": "^0.1.1",
"@xml-tools/parser": "^1.0.7",
"array-flat-polyfill": "^1.0.1",
"chalk": "^2.4.2",
"chevrotain": "^7.0.1",
"chokidar": "^3.5.1",
"clear": "^0.1.0",
"coveralls-next": "^4.2.0",
"cross-platform-clear-console": "^2.3.0",
"debounce-promise": "^3.1.0",
"eventemitter3": "^4.0.0",
"fast-glob": "^3.2.12",
"file-url": "^3.0.0",
"fs-extra": "^8.1.0",
"jsonc-parser": "^2.3.0",
"long": "^3.2.0",
"luxon": "^2.5.2",
"minimatch": "^3.0.4",
"moment": "^2.23.0",
"p-settle": "^2.1.0",
"parse-ms": "^2.1.0",
"readline": "^1.3.0",
"require-relative": "^0.8.7",
"roku-deploy": "^3.11.1",
"serialize-error": "^7.0.1",
"source-map": "^0.7.4",
"vscode-languageserver": "7.0.0",
"vscode-languageserver-protocol": "3.16.0",
"vscode-languageserver-textdocument": "^1.0.1",
"vscode-uri": "^2.1.1",
"xml2js": "^0.5.0",
"yargs": "^16.2.0"
},
"bin": {
"bsc": "dist/cli.js"
}
},
"node_modules/brighterscript-formatter/node_modules/brighterscript/node_modules/cliui": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
"integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==",
"dev": true,
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^7.0.0"
}
},
"node_modules/brighterscript-formatter/node_modules/brighterscript/node_modules/jsonc-parser": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.3.1.tgz",
"integrity": "sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg==",
"dev": true
},
"node_modules/brighterscript-formatter/node_modules/brighterscript/node_modules/yargs": {
"version": "16.2.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz",
"integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==",
"dev": true,
"dependencies": {
"cliui": "^7.0.2",
"escalade": "^3.1.1",
"get-caller-file": "^2.0.5",
"require-directory": "^2.1.1",
"string-width": "^4.2.0",
"y18n": "^5.0.5",
"yargs-parser": "^20.2.2"
},
"engines": {
"node": ">=10"
}
},
"node_modules/brighterscript-formatter/node_modules/brighterscript/node_modules/yargs-parser": {
"version": "20.2.9",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz",
"integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==",
"dev": true,
"engines": {
"node": ">=10"
}
},
"node_modules/brighterscript-formatter/node_modules/cliui": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
@@ -921,44 +834,12 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"node_modules/brighterscript-formatter/node_modules/fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"dev": true,
"dependencies": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
},
"engines": {
"node": ">=6 <7 || >=8"
}
},
"node_modules/brighterscript-formatter/node_modules/jsonc-parser": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz",
"integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==",
"dev": true
},
"node_modules/brighterscript-formatter/node_modules/jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==",
"dev": true,
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}
},
"node_modules/brighterscript-formatter/node_modules/universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"dev": true,
"engines": {
"node": ">= 4.0.0"
}
},
"node_modules/brighterscript-formatter/node_modules/wrap-ansi": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
@@ -976,19 +857,6 @@
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/brighterscript-formatter/node_modules/xml2js": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz",
"integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==",
"dev": true,
"dependencies": {
"sax": ">=0.6.0",
"xmlbuilder": "~11.0.0"
},
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/brighterscript-formatter/node_modules/y18n": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
@@ -2129,9 +1997,9 @@
"dev": true
},
"node_modules/fastq": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz",
"integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==",
"version": "1.16.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.16.0.tgz",
"integrity": "sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==",
"dev": true,
"dependencies": {
"reusify": "^1.0.4"
@@ -4055,9 +3923,9 @@
}
},
"node_modules/roku-deploy": {
"version": "3.11.1",
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.11.1.tgz",
"integrity": "sha512-ri3eJKGyPMexI+pwvBQxpi6I7I3z9670yOidTcVEohpbYhXpnaIHnKdLb2l87kuC+iTtIEsElgmx3fyEdI5Cjg==",
"version": "3.11.2",
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.11.2.tgz",
"integrity": "sha512-3JDlnbTxv6Xk5GVolQoA3+d34MLZXXwZWMySprHwazZoWLP3LvulYHP92YvFOJAo/aI4IZp/TFA8kR82IrmHKA==",
"dev": true,
"dependencies": {
"chalk": "^2.4.2",
@@ -4657,9 +4525,9 @@
"dev": true
},
"node_modules/ts-node": {
"version": "10.9.1",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz",
"integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==",
"version": "10.9.2",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz",
"integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==",
"dev": true,
"dependencies": {
"@cspotcode/source-map-support": "^0.8.0",
+5 -5
View File
@@ -1,15 +1,15 @@
{
"name": "playlet",
"version": "0.17.1",
"version": "0.18.1",
"description": "Unofficial Youtube client for Roku",
"devDependencies": {
"@rokucommunity/bslint": "^0.8.13",
"@types/crypto-js": "^4.2.1",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.10.4",
"@types/node": "^20.10.6",
"@types/xml2js": "^0.4.14",
"argparse": "^2.0.1",
"brighterscript": "0.65.10",
"brighterscript": "0.65.15",
"brighterscript-formatter": "^1.6.36",
"convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0",
@@ -22,11 +22,11 @@
"ip": "^1.1.8",
"json5": "^2.2.3",
"mailparser": "^3.6.5",
"roku-deploy": "^3.11.1",
"roku-deploy": "^3.11.2",
"rooibos-roku": "^5.8.0",
"semver": "^7.5.4",
"shelljs": "^0.8.5",
"ts-node": "^10.9.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"xml2js": "^0.6.2",
"yaml": "^2.3.4"
+1 -1
View File
@@ -1,5 +1,5 @@
{
"extends": "../config/bsconfig.base.json",
"extends": "../config/bsconfig.base.jsonc",
"rootDir": "src/",
"stagingDir": "../build/playlet-app",
"outFile": "../dist/playlet-app.zip"
+1 -1
View File
@@ -1,5 +1,5 @@
{
"extends": "../config/bsconfig.tests.base.json",
"extends": "../config/bsconfig.tests.base.jsonc",
"rootDir": "src/",
"stagingDir": "../build/playlet-app-tests",
"outFile": "../build/playlet-app-tests.zip"
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-app",
"version": "0.17.1",
"version": "0.18.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-app",
"version": "0.17.1"
"version": "0.18.1"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-app",
"version": "0.17.1",
"version": "0.18.1",
"description": "Unofficial Youtube client for Roku",
"scripts": {
"prebuild": "rm -rf build/playlet-app",
@@ -1,13 +1,21 @@
import "LoadingMessages.bs"
' TODO:P2 Add a "logQueue" field to the scene, and push it to the logger later when playlet-lib is loaded
' Alternatively, just log to the console and the known log file in cachefs
' TODO:P2 log the playlet-lib load status and load speed to the log queue
function Init() as void
m.top.backgroundColor = "0x242424FF"
m.scene = m.top.getScene()
m.top.backgroundColor = "#242424FF"
m.top.backgroundURI = ""
m.loadingIndicator = m.top.findNode("LoadingIndicator")
m.loadingIndicator.visible = true
m.global.addFields({
loadingIndicator: m.loadingIndicator
})
m.loadingIndicator.visible = true
m.loadingIndicator.message = GetLoadingMessage()
m.playletLibUrls = GetPlayletLibUrls()
m.playletLibUrlIndex = 0
@@ -42,14 +50,8 @@ function LoadPlayletLib() as void
end if
RemoveComponentLibrary()
m.lib = m.top.getScene().createChild("ComponentLibrary")
' bs:disable-next-line NO_OBSERVE_STRING_CALLBACK
m.lib.observeField("loadStatus", "OnLoadStatusChanged")
uri = m.playletLibUrls[m.playletLibUrlIndex].link
' bs:disable-next-line LINT3012
?"Loading Playlet lib from " uri
m.lib.uri = uri
LoadComponentLibrary(uri)
end function
function OnLoadStatusChanged() as void
@@ -58,9 +60,8 @@ function OnLoadStatusChanged() as void
RemoveComponentLibrary()
' bs:disable-next-line LINT3012
?"Playlet lib loaded from " libUrl.link
scene = m.top.getScene()
scene.playletLibLoadedUrl = libUrl
container = scene.findNode("MainSceneContainer")
m.scene.playletLibLoadedUrl = libUrl
container = m.scene.findNode("MainSceneContainer")
container.createChild("PlayletLib:MainScene")
return
end if
@@ -79,11 +80,20 @@ function RemoveComponentLibrary() as void
return
end if
scene = m.top.getScene()
scene.removeChild(m.lib)
m.lib.unobserveField("loadStatus")
m.scene.removeChild(m.lib)
m.lib = invalid
end function
function LoadComponentLibrary(uri as string)
m.lib = m.scene.createChild("ComponentLibrary")
' bs:disable-next-line NO_OBSERVE_STRING_CALLBACK
m.lib.observeField("loadStatus", "OnLoadStatusChanged")
' bs:disable-next-line LINT3012
?"Loading Playlet lib from " uri
m.lib.uri = uri
end function
function ShowPlayletLibLoadErrorDialog()
message = [
"Could not load Playlet component library from any of the following urls:",
@@ -0,0 +1,41 @@
function GetLoadingMessage() as string
messages = GetLoadingMessagesFromCache()
if messages = invalid or messages.count() = 0
messages = [
"Now loading Playlet...",
"One moment please...",
"Downloading the internet...",
"Unclogging the tubes...",
"Warming up the flux capacitor...",
"Loading, ehm, stuff...",
"Restoring quantum entanglement...",
"Searching for kitten videos...",
"One Mississippi... two Mississippi...",
"Checking the TV's extended warranty...",
"Deleting system32...",
"Updating: 3 hours 32 minutes remaining...",
"Asking ChatGPT for humorous loading messages...",
"Loading today's sponsor... NordVPN!",
"Don't worry, this is normal...",
"Don't forget to like and subscribe...",
"Shoveling coal into the server...",
"Counting down from infinity...",
]
end if
index = GetRandom(0, messages.count() - 1)
return messages[index]
end function
function GetLoadingMessagesFromCache() as object
messagesFile = ReadAsciiFile("cachefs:/loading_messages_v1.json")
if messagesFile = invalid or messagesFile = ""
return invalid
end if
return ParseJson(messagesFile)
end function
function GetRandom(min as integer, max as integer) as integer
dateTime = CreateObject("roDateTime")
random = Rnd(max) + dateTime.GetMilliseconds()
return min + (random mod (max - min + 1))
end function
@@ -1,4 +1,7 @@
<component name="LoadingIndicator" extends="Group">
<interface>
<field id="message" type="string" alias="messageLabel.text" />
</interface>
<children>
<Rectangle
width="1280"
@@ -9,6 +12,16 @@
id="busySpinner"
inheritParentOpacity="false"
spinInterval="1" />
<Label
id="messageLabel"
inheritParentOpacity="false"
width="1280"
height="200"
horizAlign="center"
translation="[0,460]"
wrap="true">
<Font role="font" uri="font:SystemFontFile" size="28" />
</Label>
</Rectangle>
</children>
</component>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

@@ -3,24 +3,24 @@
outputs: [
{
outputFilePath: 'images/channel-poster_fhd.png',
outputHash: 'd644a0db84deed0bcc41a41d08a4ef75',
outputHash: '50729b5bdd2a7c0fd4a1d502812117d4',
width: 540,
height: 405,
background: '#FFFFFF',
background: '#EEEEEE',
},
{
outputFilePath: 'images/channel-poster_hd.png',
outputHash: 'd07a4ffaa021b55528bee91710f4e9d2',
outputHash: '8022dc6fa993ce3194c5aea37d6ea49a',
width: 290,
height: 218,
background: '#FFFFFF',
background: '#EEEEEE',
},
{
outputFilePath: 'images/channel-poster_sd.png',
outputHash: '66a311c639f89ff009e4624468282b2f',
outputHash: '63b8f12ac155c29b4e85db17a2886817',
width: 246,
height: 140,
background: '#FFFFFF',
background: '#EEEEEE',
},
],
}
+1 -1
View File
@@ -2,7 +2,7 @@ title=Playlet
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=17
minor_version=18
build_version=00001
ui_resolutions=hd
+15 -1
View File
@@ -1,6 +1,7 @@
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
' Note: dialog can be null since StandardMessageDialog is only available on 10.0 and later
dialog = CreateObject("roSGNode", "StandardMessageDialog")
SetPalette(dialog)
dialog.message = message
dialog.bulletText = bulletText
dialog.bottomMessage = bottomMessage
@@ -15,6 +16,19 @@ function ShowErrorDialog(message as object, bulletText as object, bottomMessage
m.top.getScene().dialog = dialog
end function
function SetPalette(dialog as object)
palette = createObject("roSGNode", "RSGPalette")
palette.colors = {
DialogBackgroundColor: "#242424FF"
DialogFocusColor: "#CECECEFF"
DialogFocusItemColor: "#202020FF"
DialogSecondaryTextColor: "#DBDBDBFF"
DialogSecondaryItemColor: "#FF1C30FF"
DialogTextColor: "#DBDBDBFF"
}
dialog.palette = palette
end function
function OnButtonSelected()
m.top.getScene().dialog.close = true
end function
+1 -1
View File
@@ -1,5 +1,5 @@
' Playlet (App to play videos from an Invidious server on Roku TVs)
' Copyright (C) 2023 Brahim Hadriche
' Copyright (C) 2024 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
+1 -1
View File
@@ -1,5 +1,5 @@
{
"extends": "../config/bsconfig.base.json",
"extends": "../config/bsconfig.base.jsonc",
"rootDir": "src/",
"stagingDir": "../build/playlet-lib",
"outFile": "../dist/playlet-lib.zip"
+1 -1
View File
@@ -1,5 +1,5 @@
{
"extends": "../config/bsconfig.tests.base.json",
"extends": "../config/bsconfig.tests.base.jsonc",
"rootDir": "src/",
"stagingDir": "../build/playlet-lib-tests",
"outFile": "../build/playlet-lib-tests.zip"
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-lib",
"version": "0.17.1",
"version": "0.18.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-lib",
"version": "0.17.1"
"version": "0.18.1"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-lib",
"version": "0.17.1",
"version": "0.18.1",
"description": "Unofficial Youtube client for Roku",
"scripts": {
"prebuild": "rm -rf build/playlet-lib",
@@ -21,7 +21,7 @@ function PushScreen(node as object)
FocusTopScreen(invalid)
end function
function PopScreen(unused as dynamic)
function PopScreen(_unused as dynamic)
childCount = m.stack.getChildCount()
if childCount > 1
m.stack.removeChildIndex(childCount - 1)
@@ -29,7 +29,7 @@ function PopScreen(unused as dynamic)
end if
end function
function FocusTopScreen(unused as dynamic)
function FocusTopScreen(_unused as dynamic)
childCount = m.stack.getChildCount()
topScreen = m.stack.getChild(childCount - 1)
NodeSetFocus(topScreen, true)
@@ -60,7 +60,7 @@ function ShowRootScreen(screenName as string) as void
' insert child at 0 to make sure it is behind the navbar
m.root.insertChild(screen, 0)
if screen.hasField("binding_done")
screen@.BindNode(invalid)
screen@.BindNode()
end if
end if
screen = m.screens[screenName]
@@ -5,7 +5,7 @@ namespace ChannelUtils
appController = m.appController
end if
appController@.PushScreen(channelView)
channelView@.BindNode(invalid)
channelView@.BindNode()
channelView.content = contentNode
end function
end namespace
@@ -29,7 +29,7 @@ function Init()
end function
function OnNodeready()
m.rowList@.BindNode(invalid)
m.rowList@.BindNode()
SetNavigation(m.rowList, "up", m.subscribeButton)
SetNavigation(m.subscribeButton, "down", m.rowList)
@@ -115,7 +115,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
end function
function Close()
m.appController@.PopScreen(invalid)
m.appController@.PopScreen()
m.top.dispose = true
end function
@@ -135,8 +135,8 @@ function OnSubscribeButtonSelected()
isSubbed = IsSubscribed()
m.subscribeTask = StartAsyncTask(SubscribeTask, {
invidious: m.invidious,
ucid: m.authorId,
invidious: m.invidious
ucid: m.authorId
subscribe: not isSubbed
})
end function
@@ -172,33 +172,30 @@ function InitializeTabs()
m.tabs = {
videos: function(authorId as string, author as string) as object
return CreateChannelFeed("Latest videos", "channel_videos", authorId, author)
end function,
end function
shorts: function(authorId as string, author as string) as object
return CreateChannelFeed("Shorts", "channel_shorts", authorId, author)
end function,
end function
streams: function(authorId as string, author as string) as object
return CreateChannelFeed("Live", "channel_streams", authorId, author)
end function,
end function
podcasts: function(authorId as string, author as string) as object
return CreateChannelFeed("Podcasts", "channel_podcasts", authorId, author)
end function,
end function
playlists: function(authorId as string, author as string) as object
return CreateChannelFeed("Playlists", "channel_playlists", authorId, author)
end function,
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, author as string) as object
return {
title: title,
title: title
feedSources: [{
"id": `inv_${endpoint}_${ucid}`,
"title": `${author} - ${title}`,
"apiType": "Invidious",
"endpoint": endpoint,
"id": `inv_${endpoint}_${ucid}`
"title": `${author} - ${title}`
"apiType": "Invidious"
"endpoint": endpoint
"pathParams": {
"ucid": ucid
}
@@ -22,7 +22,7 @@ function SubscribeTask(input as object) as object
error = response.ErrorMessage()
LogError("Failed to subscribe/unsubscribe to channel:", error)
return {
success: false,
success: false
error: error
}
end if
@@ -18,7 +18,7 @@ function LoadChannel(invidiousNode as object) as void
m.top.loadState = FeedLoadState.Loading
m.contentTask = StartAsyncTask(ChannelContentTask, {
content: m.top,
content: m.top
invidious: invidiousNode
}, OnChannelContentTaskResult)
end function
@@ -24,7 +24,7 @@ function ChannelContentTask(input as object) as object
if not response.IsSuccess() or metadata = invalid
contentNode.loadState = FeedLoadState.Error
return {
success: false,
success: false
error: response.ErrorMessage()
}
end if
@@ -3,8 +3,8 @@ 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
' TODO:P1 Web app support
' TODO:P1 Web apis and open api spec updates
'
' From the main screen:
' When a video is selected:
@@ -167,5 +167,5 @@ function OnkeyEvent(key as string, press as boolean) as boolean
end function
function Close()
m.top.appController@.PopScreen(invalid)
m.top.appController@.PopScreen()
end function
@@ -11,19 +11,19 @@ function OnItemHasFocus()
hasFocus = m.top.itemHasFocus
if hasFocus
m.top.font = "font:SmallestBoldSystemFont"
m.top.color = "0x262626ff"
m.top.color = "#262626ff"
else
m.top.font = "font:SmallestSystemFont"
m.top.color = "0xddddddff"
m.top.color = "#DBDBDBFF"
end if
end function
function OnFocusPercent()
if m.top.focusPercent > 0.5
m.top.font = "font:SmallestBoldSystemFont"
m.top.color = "0x262626ff"
m.top.color = "#262626FF"
else
m.top.font = "font:SmallestSystemFont"
m.top.color = "0xddddddff"
m.top.color = "#DBDBDBFF"
end if
end function
@@ -19,7 +19,7 @@ namespace ContextMenuUtils
ContextMenuUtils.SetItem(contextMenu, item)
contextMenu.options = options
contextMenu@.Show(invalid)
contextMenu@.Show()
return contextMenu
end function
@@ -0,0 +1,12 @@
function SetPalette(dialog as object)
palette = createObject("roSGNode", "RSGPalette")
palette.colors = {
DialogBackgroundColor: "#242424FF"
DialogFocusColor: "#CECECEFF"
DialogFocusItemColor: "#202020FF"
DialogSecondaryTextColor: "#DBDBDBFF"
DialogSecondaryItemColor: "#FF1C30FF"
DialogTextColor: "#DBDBDBFF"
}
dialog.palette = palette
end function
@@ -1,9 +1,11 @@
import "DialogPalette.bs"
import "pkg:/components/Screens/WebAppScreen/GenerateQrCodeTask.bs"
import "pkg:/source/asyncTask/asyncTask.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
SetPalette(m.top)
m.urlLabel = m.top.findNode("urlLabel")
m.qrCode = m.top.findNode("QrCodePoster")
@@ -12,9 +14,9 @@ function Init()
end function
function OnNodeReady()
address = m.webserver@.GetServerAddress(invalid)
isValidIp = not StringUtils.IsNullOrEmpty(address)
if isValidIp
address = m.webserver@.GetServerAddress()
isValidAddress = not StringUtils.IsNullOrEmpty(address)
if isValidAddress
m.top.url = `${address}/invidious/login`
else
m.urlLabel.text = "No IP address found"
@@ -32,9 +34,9 @@ function OnUrlSet()
m.urlLabel.text = url
StartAsyncTask(GenerateQrCodeTask, {
poster: m.qrCode,
text: url,
size: m.qrCode.loadWidth,
poster: m.qrCode
text: url
size: m.qrCode.loadWidth
padding: 10
})
end function
@@ -18,7 +18,7 @@
horizAlign="right"
width="400"
extendToDialogEdge="false"
showDivider="true">
showDivider="false">
<Label
text="Scan the QR Code"
horizAlign="center"
@@ -1,6 +1,8 @@
import "DialogPalette.bs"
import "pkg:/source/utils/Types.bs"
function Init()
SetPalette(m.top)
m.top.observeField("buttonSelected", FuncName(CloseDialog))
end function
+3 -1
View File
@@ -1,5 +1,6 @@
import "pkg:/components/EcpArgs.bs"
import "pkg:/components/parts/AutoBind/AutoBind.part.bs"
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/source/utils/LoadingScreen.bs"
function Init()
@@ -16,9 +17,10 @@ function MainSceneContainerChanged()
HideLoadingScreen()
InitEcpArgs()
m.scene.signalBeacon("AppLaunchComplete")
CopyLoadingMessagesToCache()
end function
function StartWebServer()
m.webServer = m.top.findNode("WebServer")
m.webServer@.StartServer(invalid)
m.webServer@.StartServer()
end function
@@ -1,5 +1,6 @@
'import "pkg:/components/EcpArgs.bs"
'import "pkg:/components/parts/AutoBind/AutoBind.part.bs"
'import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
'import "pkg:/source/utils/LoadingScreen.bs"
function Init()
@@ -17,6 +18,7 @@ function MainSceneContainerChanged()
HideLoadingScreen()
InitEcpArgs()
m.scene.signalBeacon("AppLaunchComplete")
CopyLoadingMessagesToCache()
end function
function StartWebServer()
@@ -10,6 +10,7 @@
<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/LoadingScreen.brs" />
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/OnNodeReadyNoOp.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" />
+2 -3
View File
@@ -1,4 +1,3 @@
import "pkg:/source/utils/ColorUtils.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Types.bs"
@@ -31,8 +30,8 @@ function PopulateButtons() as void
buttons = []
for each item in navBarItems
button = CreateObject("roSGNode", "IconButton")
button.background = ColorUtils.HexToInt("242424")
button.focusBackground = ColorUtils.HexToInt("ff1c30")
button.background = "#242424FF"
button.focusBackground = "#FF1C30FF"
button.padding = 20
button.height = 50
button.width = 90
@@ -3,7 +3,7 @@ const OPTIONS_LONG_PRESS_KEY = "OPTIONS_LONG_PRESS"
function InitializeLongPress(keys as object, duration = 1.0 as float)
longPressKeyMap = {
"OK": OK_LONG_PRESS_KEY,
"OK": OK_LONG_PRESS_KEY
"options": OPTIONS_LONG_PRESS_KEY
}
m._longPressKeyMap = {}
@@ -17,7 +17,7 @@ function InitializeLongPress(keys as object, duration = 1.0 as float)
' - 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",
"OK": "Lit_k"
"options": "Lit_o"
}
@@ -10,8 +10,8 @@ function SetNavigation(fromNode as object, direction as string, toNode as object
end if
m._navigation[direction].push({
fromNode: fromNode,
toNode: toNode,
fromNode: fromNode
toNode: toNode
callback: callback
})
end function
@@ -19,7 +19,7 @@ end function
function NavigationKeyHandler(key as string, press as boolean) as object
if not press
return {
handled: false,
handled: false
node: invalid
}
end if
@@ -27,7 +27,7 @@ function NavigationKeyHandler(key as string, press as boolean) as object
navigations = m._navigation[key]
if navigations = invalid
return {
handled: false,
handled: false
node: invalid
}
end if
@@ -41,13 +41,13 @@ function NavigationKeyHandler(key as string, press as boolean) as object
item.callback()
end if
return {
handled: true,
handled: true
node: item.toNode
}
end if
end for
return {
handled: false,
handled: false
node: invalid
}
end function
@@ -8,6 +8,7 @@ import "pkg:/source/asyncTask/asyncTask.bs"
import "pkg:/source/utils/ArrayUtils.bs"
import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RingBuffer.bs"
import "pkg:/source/utils/Types.bs"
' TODO:P1 prevent adding duplicates of the same video/playlist
@@ -17,6 +18,8 @@ function Init()
m.top.content = m.content
m.content.addField("index", "integer", false)
m.content.index = m.top.index
' TODO:P2 use actual queue nodes instead of internal buffer
m.watchedVideos = new RingBuffer(100)
end function
function Play(node as object, playlistIndex as integer)
@@ -53,7 +56,7 @@ function WrapWithIndexField(node as object) as object
end function
' TODO:P0 better model of the queue (Now playing, etc)
function GetQueue(unused as dynamic) as object
function GetQueue(_unused as dynamic) as object
queueNodes = m.content.getChildren(-1, 0)
items = []
for each node in queueNodes
@@ -65,37 +68,37 @@ function GetQueue(unused as dynamic) as object
nodeType = node.type
if nodeType = "video"
items.push({
type: nodeType,
videoId: node.videoId,
title: node.title,
author: node.author,
type: nodeType
videoId: node.videoId
title: node.title
author: node.author
thumbnail: node.thumbnail
})
else if node.type = "playlist"
items.push({
type: nodeType,
playlistId: node.playlistId,
title: node.title,
thumbnail: node.thumbnail,
type: nodeType
playlistId: node.playlistId
title: node.title
thumbnail: node.thumbnail
videoCountText: node.videoCountText
})
end if
end for
return {
index: m.top.index,
playlistIndex: m.top.playlistIndex,
index: m.top.index
playlistIndex: m.top.playlistIndex
items: items
}
end function
function Clear(unused as dynamic)
function Clear(_unused as dynamic)
m.content.removeChildrenIndex(m.content.getChildCount(), 0)
m.top.index = -1
m.top.playlistIndex = -1
end function
function PlayNextItem(unused as dynamic) as boolean
function PlayNextItem(_unused as dynamic) as boolean
childCount = m.content.getChildCount()
if childCount = 0
return false
@@ -138,7 +141,7 @@ function PlayItemAtCurrentIndex() as boolean
return false
end if
if node.type = "video"
VideoUtils.PlayVideo(node)
PlayVideo(node)
return true
else if node.type = "playlist"
if m.top.playlistIndex = -1
@@ -162,7 +165,7 @@ function PlayPlaylistAtCurrentIndex(playlist as object) as boolean
if playlistIndex < playlist.getChildCount()
child = playlist.getChild(playlistIndex)
VideoUtils.PlayVideo(child)
PlayVideo(child)
return true
end if
@@ -170,6 +173,14 @@ function PlayPlaylistAtCurrentIndex(playlist as object) as boolean
return true
end function
function PlayVideo(node as object)
videoId = node.videoId
if not m.watchedVideos.Contains(videoId)
m.watchedVideos.Push(videoId)
end if
VideoUtils.PlayVideo(node)
end function
function LoadPlaylist(playlist as object) as void
if playlist.loadState = FeedLoadState.Loading
return
@@ -178,7 +189,7 @@ function LoadPlaylist(playlist as object) as void
playlist.loadState = FeedLoadState.Loading
task = StartAsyncTask(PlaylistContentTask, {
content: playlist,
content: playlist
invidious: m.top.invidious
}, OnPlaylistContentTaskResult)
m.pendingLoadTasks[task.id] = task
@@ -219,3 +230,11 @@ function OnIndexChange()
child.index = index
end for
end function
function watchedVideosContain(videoId as string) as boolean
return m.watchedVideos.Contains(videoId)
end function
function watchedVideosClear(_unused as dynamic)
m.watchedVideos = new RingBuffer(100)
end function
@@ -12,6 +12,8 @@
<function name="Clear" />
<function name="PlayNextItem" />
<function name="PlayItemAtIndex" />
<function name="watchedVideosContain" />
<function name="watchedVideosClear" />
</interface>
<children>
<ContentNode id="Content" />
@@ -61,11 +61,11 @@ function OnkeyEvent(key as string, press as boolean) as boolean
end function
function Close()
m.top.appController@.PopScreen(invalid)
m.top.appController@.PopScreen()
end function
function OnClearButtonSelected()
m.top.playQueue@.Clear(invalid)
m.top.playQueue@.Clear()
end function
function OnItemSelected() as void
@@ -66,6 +66,7 @@ function SetHighlight() as void
index = m.top.index
if playQueueIndex = index
' bs:disable-next-line LINT3023
m.top.thumbnailBlendColor = "#FFFFFFFF"
m.top.highlightUri = "pkg:/images/focus_grid.9.png"
else
@@ -35,7 +35,7 @@
</Poster>
<Poster
id="highlightPoster"
blendColor="0xFF0000"
blendColor="0xFF1C30"
width="164"
height="94" />
@@ -16,7 +16,7 @@ namespace PlayQueueViewUtils
playQueueView.jumpToItem = index
end if
playQueueView@.Show(invalid)
playQueueView@.Show()
return playQueueView
end function
@@ -27,7 +27,7 @@ function PlaylistContentTask(input as object) as object
if not response.IsSuccess() or metadata = invalid
contentNode.loadState = FeedLoadState.Error
return {
success: false,
success: false
error: response.ErrorMessage()
}
end if
@@ -5,7 +5,7 @@ namespace PlaylistUtils
appController = m.appController
end if
appController@.PushScreen(playlistView)
playlistView@.BindNode(invalid)
playlistView@.BindNode()
playlistView.content = contentNode
end function
end namespace
@@ -94,7 +94,7 @@ function Close()
m.playlistLoadTask = invalid
end if
m.appController@.PopScreen(invalid)
m.appController@.PopScreen()
end function
function OnItemFocused()
@@ -223,7 +223,7 @@ function LoadPlaylist() as void
m.top.content.loadState = FeedLoadState.Loading
m.playlistLoadTask = StartAsyncTask(PlaylistContentTask, {
content: m.top.content,
content: m.top.content
invidious: m.top.invidious
}, OnPlaylistContentTaskResult)
end function
@@ -3,28 +3,28 @@ import "pkg:/source/asyncTask/asyncTask.bs"
function Init()
' TODO:P2 Add tooltip to each field with description of what it means
m.displayNames = [{
key: "app_version",
key: "app_version"
displayText: "Playlet App Version"
}, {
key: "lib_version",
key: "lib_version"
displayText: "Playlet Library Version"
}, {
key: "lib_version_latest",
key: "lib_version_latest"
displayText: "Playlet Library Latest Version"
}, {
key: "lib_url",
key: "lib_url"
displayText: "Playlet Library URL"
}, {
key: "lib_url_type",
key: "lib_url_type"
displayText: "Playlet Library URL Type"
}, {
key: "app_git_commit_hash",
key: "app_git_commit_hash"
displayText: "Playlet App Git Commit Hash"
}, {
key: "lib_git_commit_hash",
key: "lib_git_commit_hash"
displayText: "Playlet Library Git Commit Hash"
}, {
key: "id",
key: "id"
displayText: "App ID"
}]
@@ -32,7 +32,7 @@ function Init()
end function
function OnNodeReady()
m.appInfo = m.applicationInfo@.GetAppInfo(invalid)
m.appInfo = m.applicationInfo@.GetAppInfo()
UpdateKeyValueList()
@@ -17,7 +17,7 @@ function OnNodeReady()
SetNavigation(invalid, "back", m.navBar)
SetNavigation(invalid, "left", m.navBar)
m.rowList@.BindNode(invalid)
m.rowList@.BindNode()
OnBookmarksChange()
m.bookmarks.ObserveField("contentChange", FuncName(OnBookmarksChange))
@@ -41,7 +41,7 @@ function OnVisibleChange()
end if
end function
function Refresh(unused as dynamic)
function Refresh(_unused as dynamic)
m.isDirty = true
OnBookmarksChange()
end function
@@ -79,7 +79,7 @@ function SetRowListContent(bookmarksContent as object)
end for
feeds.push({
"title": bookmarkGroupNode.title,
"title": bookmarkGroupNode.title
"feedSources": feedSources
})
end for
@@ -13,7 +13,7 @@ function OnNodeReady()
SetNavigation(invalid, "back", m.navBar)
SetNavigation(invalid, "left", m.navBar)
m.rowList@.BindNode(invalid)
m.rowList@.BindNode()
m.rowList.feeds = ParseJson(ReadAsciiFile(m.top.feedFile))
end function
@@ -5,110 +5,110 @@ import "pkg:/source/utils/Types.bs"
function Init()
options = {
date: [{
title: "Any date",
title: "Any date"
value: ""
}, {
title: "Last hour",
title: "Last hour"
value: "hour"
}, {
title: "Today",
title: "Today"
value: "today"
}, {
title: "This week",
title: "This week"
value: "week"
}, {
title: "This month",
title: "This month"
value: "month"
}, {
title: "This year",
title: "This year"
value: "year"
}],
}]
type: [{
title: "Any type",
title: "Any type"
value: ""
}, {
title: "Video",
title: "Video"
value: "video"
}, {
title: "Playlist",
title: "Playlist"
value: "playlist"
}, {
title: "Channel",
title: "Channel"
value: "channel"
}, {
title: "Movie",
title: "Movie"
value: "movie"
}, {
title: "Show",
title: "Show"
value: "show"
}],
}]
duration: [{
title: "Any duration",
title: "Any duration"
value: ""
}, {
title: "Under 4 minutes",
title: "Under 4 minutes"
value: "short"
}, {
title: "4 - 20 minutes",
title: "4 - 20 minutes"
value: "medium"
}, {
title: "Over 20 minutes",
title: "Over 20 minutes"
value: "long"
}],
}]
features: [{
title: "Live",
title: "Live"
value: "live"
}, {
title: "4K",
title: "4K"
value: "4k"
}, {
title: "HD",
title: "HD"
value: "hd"
}, {
title: "Subtitles/CC",
title: "Subtitles/CC"
value: "subtitles"
}, {
title: "Creative Commons",
title: "Creative Commons"
value: "creative_commons"
}, {
title: "360°",
title: "360°"
value: "360"
}, {
title: "VR180",
title: "VR180"
value: "vr180"
}, {
title: "3D",
title: "3D"
value: "3d"
}, {
title: "HDR",
title: "HDR"
value: "hdr"
}, {
title: "Purchased",
title: "Purchased"
value: "purchased"
}, {
title: "Location",
title: "Location"
value: "location"
}],
}]
sort_by: [{
title: "Relevance",
title: "Relevance"
value: ""
}, {
title: "Upload date",
title: "Upload date"
value: "upload_date"
}, {
title: "View count",
title: "View count"
value: "view_count"
}, {
title: "Rating",
title: "Rating"
value: "rating"
}]
}
m.controls = {
date: m.top.findNode("UploadDateList"),
type: m.top.findNode("TypeList"),
duration: m.top.findNode("DurationList"),
features: m.top.findNode("FeaturesList"),
date: m.top.findNode("UploadDateList")
type: m.top.findNode("TypeList")
duration: m.top.findNode("DurationList")
features: m.top.findNode("FeaturesList")
sort_by: m.top.findNode("SortByList")
}
@@ -118,10 +118,10 @@ function Init()
end for
m.contentNodes = {
date: m.controls.date.content,
type: m.controls.type.content,
duration: m.controls.duration.content,
features: m.controls.features.content,
date: m.controls.date.content
type: m.controls.type.content
duration: m.controls.duration.content
features: m.controls.features.content
sort_by: m.controls.sort_by.content
}
@@ -266,5 +266,5 @@ function OnkeyEvent(key as string, press as boolean) as boolean
end function
function Close()
m.appController@.PopScreen(invalid)
m.appController@.PopScreen()
end function
@@ -25,10 +25,10 @@ function Init()
textEditBox.voiceEnabled = true
m.top.filters = {
date: "",
type: "",
duration: "",
features: [],
date: ""
type: ""
duration: ""
features: []
sort_by: ""
}
@@ -36,7 +36,7 @@ function Init()
end function
function OnNodeReady()
m.rowlist@.BindNode(invalid)
m.rowlist@.BindNode()
m.keyboard.ObserveField("text", FuncName(OnTextChange))
m.suggestions.ObserveField("buttonFocused", FuncName(OnSearchButtonFocused))
m.suggestions.ObserveField("buttonSelected", FuncName(OnSearchButtonSelected))
@@ -99,8 +99,8 @@ function OnTextChange() as void
end if
m.searchSuggestionsTask = StartAsyncTask(SearchSuggestionsTask, {
q: m.keyboard.text,
invidious: m.invidious,
q: m.keyboard.text
invidious: m.invidious
preferences: m.preferences
}, OnSearchSuggestionsTaskResults)
end function
@@ -151,7 +151,7 @@ function OnFiltersButtonSelected()
searchFilters = CreateObject("roSGNode", "SearchFilters")
m.appController@.PushScreen(searchFilters)
searchFilters.searchScreen = m.top
searchFilters@.BindNode(invalid)
searchFilters@.BindNode()
end function
function OnSearchButtonSelected()
@@ -206,10 +206,10 @@ function Search(text as string)
ShowLoadingScreen()
feedSource = {
"id": `inv_search_${CryptoUtils.GetMd5(text)}`,
"title": `Search - ${text}`,
"apiType": "Invidious",
"endpoint": "search",
"id": `inv_search_${CryptoUtils.GetMd5(text)}`
"title": `Search - ${text}`
"apiType": "Invidious"
"endpoint": "search"
"queryParams": {
"q": text
}
@@ -222,14 +222,14 @@ function Search(text as string)
feedSource.queryParams[filter] = value
else if IsArray(value) and value.Count() > 0
feedSource.queryParams[filter] = {
value: value,
value: value
arrayType: UrlUtils.QueryParamArrayType.CommaSeparated
}
end if
end for
m.rowList.feeds = [{
"title": `Search - ${text}`,
"title": `Search - ${text}`
"feedSources": [feedSource]
}]
end function
@@ -26,7 +26,7 @@ function SearchSuggestionsTask(input as object) as object
end if
return {
q: q,
q: q
response: history
}
end function
@@ -1,3 +1,4 @@
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Types.bs"
@@ -54,7 +55,7 @@ end function
function OpenInvidiousInstanceSettings()
settings = CreateObject("roSGNode", "InvidiousInstanceSettings")
m.appController@.PushScreen(settings)
settings@.BindNode(invalid)
settings@.BindNode()
settings.text = m.top.value
settings.observeField("save", FuncName(OnSaveInvidiousInstance))
end function
@@ -1,4 +1,6 @@
import "pkg:/components/Dialog/DialogPalette.bs"
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/source/utils/Types.bs"
@@ -70,13 +72,14 @@ end function
function OnTestButtonSelected()
testing = CreateObject("roSGNode", "InvidiousInstanceTesting")
m.appController@.PushScreen(testing)
testing@.BindNode(invalid)
testing@.BindNode()
testing.instance = m.top.text
testing.run = true
end function
function OnEditButtonSelected()
keyboardDialog = createObject("roSGNode", "StandardKeyboardDialog")
SetPalette(keyboardDialog)
keyboardDialog.title = "Edit Instance"
keyboardDialog.message = [`Enter the instance url (e.g. ${Invidious.DEFAULT_INSTANCE})`]
keyboardDialog.text = m.top.text
@@ -103,5 +106,5 @@ function OnSaveButtonSelected()
end function
function Close()
m.appController@.PopScreen(invalid)
m.appController@.PopScreen()
end function
@@ -1,5 +1,6 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs"
import "pkg:/source/asyncTask/asyncTask.bs"
import "pkg:/source/utils/FocusManagement.bs"
@@ -47,7 +48,7 @@ function Close()
m.testingTask.cancel = true
end if
m.appController@.PopScreen(invalid)
m.appController@.PopScreen()
end function
function RunTestsTask()
@@ -58,7 +59,7 @@ function RunTestsTask()
end if
m.testingTask = StartAsyncTask(InvidiousInstanceTestingTask, {
instance: m.top.instance,
instance: m.top.instance
listNode: m.testList
})
end function
@@ -38,9 +38,9 @@ function CreateTestNode(title as string, func as function) as object
testNode = CreateObject("roSGNode", "ContentNode")
testNode.title = title
testNode.AddFields({
func: FuncName(func),
state: "loading",
details: "",
func: FuncName(func)
state: "loading"
details: ""
duration: 0
})
m[testNode.func] = func
@@ -12,7 +12,7 @@
translation="[190,60]" />
<Button
id="refreshButton"
minWidth="0"
minWidth="180"
text="Refresh"
translation="[340,130]" />
@@ -1,5 +1,6 @@
import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/Logging.bs"
@asynctask
function InvidiousPublicInstancesTask(input as object) as object
@@ -14,7 +15,7 @@ function InvidiousPublicInstancesTask(input as object) as object
if not response.IsSuccess() or instances = invalid
return {
success: false,
success: false
error: response.ErrorMessage()
}
end if
@@ -28,18 +29,10 @@ function InvidiousPublicInstancesTask(input as object) as object
content = CreateObject("roSGNode", "ContentNode")
for each instance in instances
item = CreateObject("roSGNode", "InvidiousPublicInstancesListItemContent")
item.setFields({
name: instance[0],
version: instance[1].stats.software.version,
users: instance[1].stats.usage.users.total,
signup: instance[1].stats.openRegistrations ? "Yes" : "No",
' Leave 5 spaces for the flag, just to simplify the layout
location: ` ${instance[1].region}`,
flag: GetFlagUrl(instance[1].flag),
health: instance[1].monitor["30dRatio"].ratio,
uri: instance[1].uri
})
item = CreateListItemContent(instance)
if item = invalid
continue for
end if
content.AppendChild(item)
end for
@@ -54,6 +47,11 @@ function FilterInstances(instances as object) as object
filtered = []
for each instance in instances
if not IsArray(instance) or instance.Count() < 2
LogWarn("Invalid instance:", instance)
continue for
end if
flags = instance[1]
if flags.type = "https" and flags.api = true and flags.cors = true
filtered.Push(instance)
@@ -63,12 +61,52 @@ function FilterInstances(instances as object) as object
return filtered
end function
function CreateListItemContent(instance as object) as object
if not IsArray(instance) or instance.Count() < 2
LogWarn("Invalid instance:", instance)
return invalid
end if
item = CreateObject("roSGNode", "InvidiousPublicInstancesListItemContent")
item.setFields({
name: instance[0]
version: DrillIntoObject(instance[1], ["stats", "software", "version"], "N/A")
users: DrillIntoObject(instance[1], ["stats", "usage", "users", "total"], "N/A")
signup: DrillIntoObject(instance[1], ["stats", "openRegistrations"], false) ? "Yes" : "No"
' Leave 5 spaces for the flag, just to simplify the layout
location: ` ${DrillIntoObject(instance[1], ["region"], "N/A")}`
flag: GetFlagUrl(DrillIntoObject(instance[1], ["flag"], ""))
health: DrillIntoObject(instance[1], ["monitor", "30dRatio", "ratio"], "N/A")
uri: instance[1].uri
})
return item
end function
function DrillIntoObject(obj as object, path as object, defaultValue as dynamic) as dynamic
if obj = invalid
return defaultValue
end if
for each key in path
if obj[key] = invalid
return defaultValue
end if
obj = obj[key]
end for
return obj
end function
function GetFlagUrl(flag as string) as string
codePoint = emojiToCodePoint(flag)
if flag = ""
return ""
end if
codePoint = EmojiToCodePoint(flag)
return `https://github.githubassets.com/images/icons/emoji/unicode/${codePoint}.png?v8`
end function
function emojiToCodePoint(emoji as string) as string
function EmojiToCodePoint(emoji as string) as string
codes = []
chars = emoji.Split("")
for i = 0 to chars.count() - 1
@@ -8,9 +8,9 @@ function Init()
m.scrollAnimation = m.top.findNode("scrollAnimation")
m.scrollAnimationInterpolator = m.scrollAnimation.findNode("scrollAnimationInterpolator")
m.viewport = {
x: 150,
y: 96,
width: 1920,
x: 150
y: 96
width: 1920
height: 550
}
end function
@@ -75,7 +75,7 @@ function CreateCategoryNode(item as object, container as object, startX as integ
node.displayText = item.displayText
node.description = item.description
return {
node: node,
node: node
rect: node.boundingRect()
}
end function
@@ -107,11 +107,11 @@ function CreateControls(item as object, container as object, startX as integer,
end for
return {
nodes: nodes,
nodes: nodes
rect: {
x: x,
y: y,
width: width,
x: x
y: y
width: width
height: height
}
}
@@ -137,12 +137,12 @@ function CreateControl(item as object, container as object, startX as integer, s
control.id = `preference.${item.key}`
control.translation = [startX, startY]
if control.hasField("binding_done")
control@.BindNode(invalid)
control@.BindNode()
end if
control@.BindPreference(m.preferences, item.key)
return {
node: control,
node: control
rect: control.boundingRect()
}
end function
@@ -1,3 +1,4 @@
import "pkg:/components/Dialog/DialogPalette.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Types.bs"
@@ -65,6 +66,7 @@ end function
function ShowEditKeyboard()
keyboardDialog = createObject("roSGNode", "StandardKeyboardDialog")
SetPalette(keyboardDialog)
keyboardDialog.title = m.top.displayText
keyboardDialog.message = [m.top.description]
keyboardDialog.text = m.top.value
@@ -6,13 +6,13 @@ function Init()
end function
function OnNodeReady()
address = m.webserver@.GetServerAddress(invalid)
isValidIp = not StringUtils.IsNullOrEmpty(address)
if isValidIp
address = m.webserver@.GetServerAddress()
isValidAddress = not StringUtils.IsNullOrEmpty(address)
if isValidAddress
m.top.url = address
end if
m.top.findNode("noInternet").visible = not isValidIp
m.top.findNode("yesInternet").visible = isValidIp
m.top.findNode("noInternet").visible = not isValidAddress
m.top.findNode("yesInternet").visible = isValidAddress
end function
function OnUrlSet()
@@ -23,9 +23,9 @@ function OnUrlSet()
qrCodePoster = m.top.findNode("QrCodePoster")
StartAsyncTask(GenerateQrCodeTask, {
poster: qrCodePoster,
text: url,
size: qrCodePoster.loadWidth,
poster: qrCodePoster
text: url
size: qrCodePoster.loadWidth
padding: 20
})
end function
@@ -7,23 +7,23 @@ function Init()
m.service = new ApplicationInfo(m.top)
end function
function GetAppInfo(unused as dynamic) as object
function GetAppInfo(_unused as dynamic) as object
return m.service.GetAppInfo()
end function
function GetDeviceInfo(unused as dynamic) as object
function GetDeviceInfo(_unused as dynamic) as object
return m.service.GetDeviceInfo()
end function
function GetUserCountryCode(unused as dynamic) as string
function GetUserCountryCode(_unused as dynamic) as string
return m.service.GetUserCountryCode()
end function
function GetLocalIpAddress(unused as dynamic) as dynamic
function GetLocalIpAddress(_unused as dynamic) as dynamic
return m.service.GetLocalIpAddress()
end function
function GetLatestPlayletLibVersion(unused as dynamic) as dynamic
function GetLatestPlayletLibVersion(_unused as dynamic) as dynamic
if not StringUtils.IsNullOrEmpty(m.top.lib_version_latest)
return m.top.lib_version_latest
end if
@@ -53,18 +53,18 @@ function Save() as void
bookmarkNodes = bookmarkGroupNode.getChildren(-1, 0)
for each bookmarkNode in bookmarkNodes
bookmarks.push({
"id": bookmarkNode.id,
"id": bookmarkNode.id
"feedSource": bookmarkNode.feedSource
})
end for
groups.push({
"title": bookmarkGroupNode.title,
"title": bookmarkGroupNode.title
"bookmarks": bookmarks
})
end for
bookmarksString = FormatJson({
"__version": m.top.__version,
"__version": m.top.__version
"groups": groups
})
@@ -110,8 +110,8 @@ function AddVideoBookmark(id as string, groupName as string)
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
feedSource = {
"apiType": "Invidious",
"endpoint": "video_info",
"apiType": "Invidious"
"endpoint": "video_info"
"pathParams": {
"id": id
}
@@ -123,8 +123,8 @@ function AddPlaylistBookmark(id as string, groupName as string)
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
feedSource = {
"apiType": "Invidious",
"endpoint": "playlist_info",
"apiType": "Invidious"
"endpoint": "playlist_info"
"pathParams": {
"plid": id
}
@@ -136,10 +136,10 @@ function AddPlaylistBookmarkWithSpread(id as string, groupName as string)
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
feedSource = {
"id": `inv_playlist_${id}`,
"title": `${groupName} videos`,
"apiType": "Invidious",
"endpoint": "playlist",
"id": `inv_playlist_${id}`
"title": `${groupName} videos`
"apiType": "Invidious"
"endpoint": "playlist"
"pathParams": {
"plid": id
}
@@ -147,8 +147,8 @@ function AddPlaylistBookmarkWithSpread(id as string, groupName as string)
AddFeedSourceBookmark(feedSource, `inv_playlist_${id}`, bookmarkGroupNode)
feedSource = {
"apiType": "Invidious",
"endpoint": "playlist_info",
"apiType": "Invidious"
"endpoint": "playlist_info"
"pathParams": {
"plid": id
}
@@ -160,8 +160,8 @@ function AddChannelBookmark(id as string, groupName as string)
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
feedSource = {
"apiType": "Invidious",
"endpoint": "channel_info",
"apiType": "Invidious"
"endpoint": "channel_info"
"pathParams": {
"ucid": id
}
@@ -173,10 +173,10 @@ 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",
"id": `inv_channel_videos_${id}`
"title": `${groupName} videos`
"apiType": "Invidious"
"endpoint": "channel_videos"
"pathParams": {
"ucid": id
}
@@ -184,8 +184,8 @@ function AddChannelBookmarkWithSpread(id as string, groupName as string)
AddFeedSourceBookmark(feedSource, `inv_channel_videos_${id}`, bookmarkGroupNode)
feedSource = {
"apiType": "Invidious",
"endpoint": "channel_info",
"apiType": "Invidious"
"endpoint": "channel_info"
"pathParams": {
"ucid": id
}
@@ -34,10 +34,10 @@ class DashManifest
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",
"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")
@@ -45,9 +45,9 @@ class DashManifest
id = 0
for each audioSet in audioSets
adaptationSetAttributes = {
"id": `${id}`,
"mimeType": audioSet.mimeType,
"startWithSAP": "1",
"id": `${id}`
"mimeType": audioSet.mimeType
"startWithSAP": "1"
"subsegmentAlignment": "true"
}
if not StringUtils.IsNullOrEmpty(audioSet.lang)
@@ -56,7 +56,7 @@ class DashManifest
if xml.Node("AdaptationSet", adaptationSetAttributes)
xml.Node("Role", {
"schemeIdUri": "urn:mpeg:dash:role:2011",
"schemeIdUri": "urn:mpeg:dash:role:2011"
"value": audioSet.acont = "original" ? "main" : "alternate"
})
xml.End()
@@ -77,13 +77,13 @@ class DashManifest
end if
if xml.Node("Representation", {
"id": stream.itag,
"codecs": codecs,
"id": stream.itag
"codecs": codecs
"bandwidth": stream.bitrate
})
xml.Node("AudioChannelConfiguration", {
"schemeIdUri": "urn:mpeg:dash:23003:3:audio_channel_configuration:2011",
"schemeIdUri": "urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
"value": `${stream.audioChannels}`
})
xml.End()
@@ -115,9 +115,9 @@ class DashManifest
for each mimeType in videoMimeTypes
if xml.Node("AdaptationSet", {
"id": `${id}`,
"mimeType": mimeType,
"startWithSAP": "1",
"id": `${id}`
"mimeType": mimeType
"startWithSAP": "1"
"subsegmentAlignment": "true"
})
@@ -137,10 +137,10 @@ class DashManifest
end if
representationAttributes = {
"id": stream.itag,
"codecs": codecs,
"startWithSAP": "1",
"maxPlayoutRate": "1",
"id": stream.itag
"codecs": codecs
"startWithSAP": "1"
"maxPlayoutRate": "1"
"bandwidth": stream.bitrate
}
if stream.width <> invalid
@@ -226,26 +226,26 @@ class DashManifest
bandwidth = ((storyboardWidthInPixels * storyboardHeightInPixels * 0.5) / duration)
if xml.Node("AdaptationSet", {
"id": `${id}`,
"mimeType": "image/jpeg",
"id": `${id}`
"mimeType": "image/jpeg"
"contentType": "image"
})
xml.Node("SegmentTemplate", {
"media": url,
"duration": duration,
"media": url
"duration": duration
"startNumber": 0
})
xml.End()
if xml.Node("Representation", {
"id": `thumbnails_${id}`,
"bandwidth": bandwidth,
"width": storyboardWidthInPixels,
"id": `thumbnails_${id}`
"bandwidth": bandwidth
"width": storyboardWidthInPixels
"height": storyboardHeightInPixels
})
xml.Node("EssentialProperty", {
"schemeIdUri": "http://dashif.org/guidelines/thumbnail_tile",
"schemeIdUri": "http://dashif.org/guidelines/thumbnail_tile"
"value": `${storyboardWidth}x${storyboardHeight}`
})
xml.End()
@@ -334,8 +334,8 @@ class DashManifest
stream = streams[i]
mimeType = stream.type.Tokenize(";")[0]
types[`${mimeType}-${stream.languageInfo.lang}-${stream.languageInfo.acont}`] = {
"mimeType": mimeType,
"lang": stream.languageInfo.lang,
"mimeType": mimeType
"lang": stream.languageInfo.lang
"acont": stream.languageInfo.acont
}
end for
@@ -8,11 +8,11 @@ function Init()
m.top.authToken = m.service.GetAuthToken()
end function
function GetCurrentInstance(unused as dynamic) as string
function GetCurrentInstance(_unused as dynamic) as string
return m.service.GetInstance()
end function
function GetAuthorizeTokenLink(unused as dynamic) as dynamic
function GetAuthorizeTokenLink(_unused as dynamic) as dynamic
return m.service.GetAuthorizeTokenLink()
end function
@@ -1,4 +1,7 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Services/Invidious/InvidiousUnregisterTokenTask.bs"
import "pkg:/components/VideoFeed/PaginationType.bs"
import "pkg:/source/asyncTask/asyncTask.bs"
import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/CryptoUtils.bs"
import "pkg:/source/utils/Logging.bs"
@@ -22,7 +25,7 @@ namespace Invidious
const SEARCH_SUGGEST_ENDPOINT = "/api/v1/search/suggestions"
const AUTH_SCOPES = "GET:feed,GET:playlists*,POST:tokens/*,POST:history*,:subscriptions*"
const AUTH_SCOPES = "GET:feed,GET:playlists*,POST:tokens/*,:history*,:subscriptions*"
const AUTH_PLAYLISTS = "/api/v1/auth/playlists"
const AUTH_SUBSCRIPTIONS = "/api/v1/auth/subscriptions"
@@ -42,21 +45,22 @@ namespace Invidious
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,
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
WatchHistoryHandler: m.WatchHistoryHandler
}
end function
function DefaultQueryParams() as object
return {
region: m.node.applicationInfo@.GetUserCountryCode(invalid)
region: m.node.applicationInfo@.GetUserCountryCode()
}
end function
@@ -154,9 +158,13 @@ namespace Invidious
return request.Await()
end function
function GetVideoStreamUrl(videoId as string) as string
function GetVideoStreamUrl(videoId as string, itag = invalid as dynamic) as string
instance = m.GetInstance()
return `${instance}/latest_version?id=${videoId}`
url = `${instance}/latest_version?id=${videoId}`
if itag <> invalid
url = `${url}&itag=${itag}`
end if
return url
end function
function MarkFeedPagination(feedContentNode as object) as object
@@ -201,7 +209,7 @@ namespace Invidious
endpoint = m.endpoints[feedSource.endpoint]
if endpoint = invalid
return {
success: false,
success: false
error: `Endpoint ${feedSource.endpoint} not found`
}
end if
@@ -214,7 +222,7 @@ namespace Invidious
authToken = m.node.authToken
if authToken = invalid
return {
success: false,
success: false
error: ERROR_NOT_AUTHENTICATED
}
end if
@@ -228,7 +236,7 @@ namespace Invidious
if queryParam.default <> invalid
if IsString(queryParam.type) and queryParam.type = "#ISO3166"
if queryParam.default = "GetUserCountryCode"
request.QueryParam(queryParamKey, m.node.applicationInfo@.GetUserCountryCode(invalid))
request.QueryParam(queryParamKey, m.node.applicationInfo@.GetUserCountryCode())
else
request.QueryParam(queryParamKey, queryParam.default)
end if
@@ -275,12 +283,12 @@ namespace Invidious
if response.IsSuccess() and result <> invalid
return {
success: true,
success: true
result: result
}
else
return {
success: false,
success: false
error: response.ErrorMessage()
}
end if
@@ -310,7 +318,7 @@ namespace Invidious
if response.StatusCode() = 200
json = response.Json()
return {
items: json.videos,
items: json.videos
continuation: json.continuation
}
end if
@@ -321,7 +329,7 @@ namespace Invidious
if response.StatusCode() = 200
json = response.Json()
return {
items: json.playlists,
items: json.playlists
continuation: json.continuation
}
end if
@@ -332,7 +340,7 @@ namespace Invidious
if response.StatusCode() = 200
json = response.Json()
return {
items: json.relatedChannels,
items: json.relatedChannels
continuation: json.continuation
}
end if
@@ -399,6 +407,31 @@ namespace Invidious
}
end function
function WatchHistoryHandler(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 = []
for each item in json
videos.push({
"type": "video"
"videoId": item
})
end for
return {
items: videos
}
end function
function DeleteExpiredToken(response as object)
if response.StatusCode() = 403
LogWarn(`Invidious instance responded with 403: ${response.Text()}`)
@@ -418,12 +451,18 @@ namespace Invidious
return invalid
end if
if not m.VerifyTokenScope(authToken.token)
' TODO:P1 automatically logging out the user is not a good experience
' We can at least show a message to the user on why they are logged out
' TODO:P2 right now we're probably in a UI thread, and we can't unregister the token
' So we're just going to ignore it for now
' m.UnregisterToken(authToken)
' Right now we're probably in a UI thread, and we can't unregister the token
' Without a Task
StartAsyncTask(InvidiousUnregisterTokenTask, {
invidious: m.node
authToken: authToken
})
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
message = `It looks like you are logged in to Invidious, but your access token does not have the required permissions.
For that reason, we have logged you out. Please log in again.
This can happen when Playlet is updated with new features.
We apologize for the inconvenience.`
DialogUtils.ShowDialog(message, "User logged out")
return invalid
end if
return authToken
@@ -431,8 +470,8 @@ namespace Invidious
function SetAuthToken(token as string, instance as string, username as dynamic)
obj = {
token: token,
instance: instance,
token: token
instance: instance
username: username
}
@@ -20,7 +20,7 @@ function InvidiousSubscriptionsTask(input as object) as object
LogError("Error getting subscriptions:", error)
return {
success: false,
success: false
error: response.ErrorMessage()
}
end if
@@ -128,7 +128,11 @@ namespace InvidiousContent
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
node.thumbnail = "pkg:/images/thumbnail-missing.jpg"
if StringUtils.IsNullOrEmpty(instance)
node.thumbnail = "pkg:/images/thumbnail-missing.jpg"
else
node.thumbnail = `${instance}/vi/${videoItem.videoId}/mqdefault.jpg`
end if
return false
end if
url = invalid
@@ -0,0 +1,12 @@
import "InvidiousService.bs"
@asynctask
function InvidiousUnregisterTokenTask(input as object) as object
invidiousNode = input.invidious
authToken = input.authToken
service = new Invidious.InvidiousService(invidiousNode)
service.UnregisterToken(authToken)
return invalid
end function
@@ -141,7 +141,7 @@ function ApplyToUserPreferences(userPrefs as object, model as object) as boolean
return isDirty
end function
function GetUserPreferences(unused as dynamic) as object
function GetUserPreferences(_unused as dynamic) as object
userPrefs = {}
prefsFields = m.top.preferenceFields
for each key in prefsFields
@@ -162,7 +162,7 @@ function ApplyUserPreferences(preferences as object) as void
SaveUserPreferencesToRegistry()
end function
function ClearUserPreferences(unused as dynamic) as void
function ClearUserPreferences(_unused as dynamic) as void
userPrefs = {}
ApplyDefaultsToUserPreferences(userPrefs)
ApplyUserPreferences(userPrefs)
@@ -1,6 +1,6 @@
<component name="SponsorBlockNotification" extends="Group">
<interface>
<field id="segment" type="assocarray" onChange="OnSegmentSet" />
<field id="segment" type="assocarray" />
<field id="action" type="string" onChange="OnActionSet" alwaysNotify="true" />
</interface>
<children>
@@ -6,9 +6,9 @@ namespace SponsorBlock
const SKIP_SEGMENT_ENDPOINT = "/api/skipSegments"
const VIEWED_SEGMENT_ENDPOINT = "/api/viewedVideoSponsorTime"
class SponsorBlockService
function new()
' TODO:P2 this is being read and parsed on every skipped segment. It should be cached.
m.sponsorBlockConfig = ParseJson(ReadAsciiFile("libpkg:/config/sponsorblock_config.json5"))
end function
@@ -15,8 +15,8 @@ function SponsorBlockTask(input as object) as object
end if
return {
videoId: videoId,
skipSegments: skipSegments,
videoId: videoId
skipSegments: skipSegments
barPath: barPath
}
end function
@@ -1,6 +1,6 @@
<component name="LoadingRowCell" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="itemContent" type="node" />
<field id="index" type="integer" onChange="OnIndexSet" />
<field id="type" type="string" value="loading" />
<field id="animationDelay" type="time" alias="loadingAnimation.delay" />
@@ -1,13 +1,8 @@
import "pkg:/source/utils/Types.bs"
function Init()
m.titleLabel = m.top.FindNode("titleLabel")
m.authorLabel = m.top.FindNode("authorLabel")
m.updatedLabel = m.top.FindNode("updatedLabel")
m.videoCountRect = m.top.FindNode("videoCountRect")
m.videoCountLabel = m.top.FindNode("videoCountLabel")
m.thumbnail = m.top.FindNode("thumbnail")
m.thumbnail.failedBitmapUri = "pkg:/images/thumbnail-missing.jpg"
end function
function OnContentSet() as void
@@ -17,23 +12,28 @@ function OnContentSet() as void
return
end if
m.titleLabel.text = content.title
m.top.title = content.title
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.authorLabel.text = content._author
m.updatedLabel.text = content.updatedText
m.top.author = content._author
m.top.updated = content.updatedText
m.thumbnail.uri = content.thumbnail
m.top.thumbnailUri = content.thumbnail
SetVideoCount(content.videoCountText)
end function
function SetVideoCount(videoCountText as string)
function SetVideoCount(videoCountText as string) as void
m.top.videoCount = videoCountText
label = m.videoCountLabel
rect = m.videoCountRect
if label = invalid or rect = invalid
return
end if
rectParent = rect.getParent()
label.text = videoCountText
size = label.localBoundingRect()
rect.width = size.width + 16
@@ -2,6 +2,11 @@
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="type" type="string" value="playlist" />
<field id="title" type="string" alias="titleLabel.text" />
<field id="author" type="string" alias="authorLabel.text" />
<field id="updated" type="string" alias="updatedLabel.text" />
<field id="thumbnailUri" type="uri" alias="thumbnail.uri" />
<field id="videoCount" type="string" alias="videoCountLabel.text" />
</interface>
<children>
<LayoutGroup
@@ -10,7 +15,8 @@
id="thumbnail"
loadDisplayMode="scaleToZoom"
width="350"
height="196">
height="196"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg">
<Rectangle
id="videoCountRect"
width="60"
@@ -4,18 +4,18 @@ function OnContentSet() as void
content = m.top.itemContent
visibleProperties = {
"video": "videoRowCellVisible",
"playlist": "playlistRowCellVisible",
"channel": "channelRowCellVisible",
"loading": "loadingRowCellVisible",
"video": "videoRowCellVisible"
"playlist": "playlistRowCellVisible"
"channel": "channelRowCellVisible"
"loading": "loadingRowCellVisible"
"action": "actionRowCellVisible"
}
contentProperties = {
"video": "videoRowCellItemContent",
"playlist": "playlistRowCellItemContent",
"channel": "channelRowCellItemContent",
"loading": "loadingRowCellItemContent",
"video": "videoRowCellItemContent"
"playlist": "playlistRowCellItemContent"
"channel": "channelRowCellItemContent"
"loading": "loadingRowCellItemContent"
"action": "actionRowCellItemContent"
}
@@ -3,19 +3,8 @@ import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
FindChildren()
end function
function FindChildren()
' TODO:P2 use component properties with alias instead of FindNode
m.titleLabel = m.top.FindNode("titleLabel")
m.authorLabel = m.top.FindNode("authorLabel")
m.viewCountDateLabel = m.top.FindNode("viewCountDateLabel")
m.liveRect = m.top.FindNode("liveRect")
m.upcomingRect = m.top.FindNode("upcomingRect")
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")
m.thumbnail = m.top.FindNode("thumbnail")
end function
function OnContentSet() as void
@@ -25,50 +14,51 @@ function OnContentSet() as void
return
end if
if m.titleLabel = invalid
FindChildren()
end if
m.titleLabel.text = content.title
m.authorLabel.text = content.author
m.top.title = content.title
m.top.author = content.author
if content.isUpcoming = true
m.viewCountDateLabel.text = content.premiereTimestampText
m.top.viewCountDate = content.premiereTimestampText
else if not StringUtils.IsNullOrEmpty(content.publishedText)
label = content.publishedText
if not StringUtils.IsNullOrEmpty(content.viewCountText)
label = `${label} • ${content.viewCountText}`
end if
m.viewCountDateLabel.text = label
m.top.viewCountDate = label
else
m.viewCountDateLabel.text = ""
m.top.viewCountDate = ""
end if
m.thumbnail.uri = content.thumbnail
m.top.thumbnailUri = content.thumbnail
m.durationRect.visible = false
m.upcomingRect.visible = false
m.liveRect.visible = false
m.top.durationRectVisible = false
m.top.upcomingRectVisible = false
m.top.liveRectVisible = false
if ValidInt(content.lengthSeconds) <> 0
SetDurationText(content.lengthText)
m.durationRect.visible = true
m.top.durationRectVisible = true
else
if content.isUpcoming = true
m.upcomingRect.visible = true
m.top.upcomingRectVisible = true
else if content.liveNow
m.liveRect.visible = true
m.top.liveRectVisible = true
end if
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
if label = invalid or rect = invalid
return
end if
rectParent = rect.getParent()
label.text = text
size = label.localBoundingRect()
rect.width = size.width + 16
@@ -2,6 +2,14 @@
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="type" type="string" value="video" />
<field id="title" type="string" alias="titleLabel.text" />
<field id="author" type="string" alias="authorLabel.text" />
<field id="viewCountDate" type="string" alias="viewCountDateLabel.text" />
<field id="liveRectVisible" type="boolean" alias="liveRect.visible" />
<field id="upcomingRectVisible" type="boolean" alias="upcomingRect.visible" />
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
<field id="duration" type="string" alias="durationLabel.text" />
<field id="thumbnailUri" type="string" alias="thumbnail.uri" />
</interface>
<children>
<LayoutGroup
@@ -111,7 +111,7 @@ function OnRowItemSelected(index as object) as void
else if rowItem.type = "action"
if rowItem.action = "LoginDialog"
dialog = CreateObject("roSGNode", "LoginDialog")
dialog@.BindNode(invalid)
dialog@.BindNode()
m.top.getScene().dialog = dialog
end if
end if
@@ -123,16 +123,21 @@ function OnRowItemLongPressed(index as object) as void
return
end if
if not IsArray(index) or index.count() <> 2
LogWarn("Invalid index:", index)
return
end if
rowIndex = index[0]
rowItemIndex = index[1]
if rowIndex < 0 or rowIndex >= content.GetChildCount()
if not IsInt(rowIndex) or rowIndex < 0 or rowIndex >= content.GetChildCount()
LogWarn("Invalid row index:", rowIndex)
return
end if
row = content.GetChild(rowIndex)
if rowItemIndex < 0 or rowItemIndex >= row.GetChildCount()
if not IsInt(rowItemIndex) or rowItemIndex < 0 or rowItemIndex >= row.GetChildCount()
LogWarn("Invalid row item index:", rowItemIndex)
return
end if
@@ -209,7 +214,7 @@ function InitContent() as void
end if
task = StartAsyncTask(VideoRowListContentTask, {
node: m.top,
node: m.top
feeds: m.top.feeds
}, OnVideoRowListContentTaskResult)
m.pendingLoadTasks[task.id] = task
@@ -282,8 +287,8 @@ function LoadRowContent(contentNode as object)
contentNode.loadState = FeedLoadState.Loading
task = StartAsyncTask(VideoRowListRowContentTask, {
rowList: m.top,
feedContentNode: contentNode,
rowList: m.top
feedContentNode: contentNode
invidious: m.invidious
}, OnVideoRowListRowContentTaskResult)
m.pendingLoadTasks[task.id] = task
@@ -143,7 +143,7 @@ function VideoRowListRowContentTask(input as object) as object
catch error
HandleFeedLoadErrorDialog(error, rowList)
return {
success: false,
success: false
error: error
}
end try
@@ -110,7 +110,7 @@ namespace SponsorBlock
barPath = output.result.barPath
if barPath <> invalid
m.top.trickPlayBar.trackImageUri = barPath
m.top.trickPlayBar.filledBarBlendColor = "0xFF000080"
m.top.trickPlayBar.filledBarBlendColor = "#FF000080"
end if
m.top.UnobserveFieldScoped("position")
@@ -135,10 +135,23 @@ namespace SponsorBlock
end if
if action = "AutoSkip"
m.top.seek = segmentEnd
LogInfo("Skipping section:", segment["category"])
SendSkippedSectionEvent(segment.UUID)
return
duration = m.top.duration
' Sometimes segmentEnd is greater than duration
if duration > 0 and segmentEnd > duration
segmentEnd = duration
end if
' If the segment is at the end of the video, skip the video instead of seeking
if duration > 0 and Abs(segmentEnd - duration) < 2
LogInfo("Skipping section:", segment["category"], "at end of video")
SendSkippedSectionEvent(segment.UUID)
OnVideoFinished()
return
else
LogInfo("Skipping section:", segment["category"])
SendSkippedSectionEvent(segment.UUID)
m.top.seek = segmentEnd
return
end if
end if
end if
end for
@@ -1,24 +0,0 @@
import "pkg:/source/utils/RingBuffer.bs"
function Init()
' We keep in memory the last videos we watched, to avoid a loop
' Sometimes recommended videos point to each other, and we're stuck watching
' The same 2 videos over and over again
' TODO:P1 get rid of `watchedVideos` and use the PlayQueue instead
m.watchedVideos = new RingBuffer(100)
end function
function watchedVideosContain(videoId as string) as boolean
return m.watchedVideos.Contains(videoId)
end function
function watchedVideosAdd(videoId as string)
if not watchedVideosContain(videoId)
m.watchedVideos.Push(videoId)
end if
end function
function watchedVideosClear(unused as dynamic)
m.watchedVideos = new RingBuffer(100)
end function
@@ -1,8 +1,5 @@
<component name="VideoContainer" extends="Group">
<interface>
<field id="fullscreen" type="boolean" value="true" />
<function name="watchedVideosContain" />
<function name="watchedVideosAdd" />
<function name="watchedVideosClear" />
</interface>
</component>
@@ -5,7 +5,7 @@ function VideoContentTask(input as object) as object
contentNode = input.content
invidiousNode = input.invidious
preferencesNode = input.preferences
playletServerUrl = input.playletServerUrl
playletServerPort = input.playletServerPort
if m.top.cancel
return invalid
@@ -27,7 +27,7 @@ function VideoContentTask(input as object) as object
if not response.IsSuccess() or metadata = invalid
return {
success: false,
success: false
error: response.ErrorMessage()
}
end if
@@ -35,15 +35,15 @@ function VideoContentTask(input as object) as object
contentNode.title = metadata.title
contentNode.secondaryTitle = metadata.author
streamUrls = CreateStreamUrls(metadata, service, preferencesNode, playletServerUrl)
streamUrls = CreateStreamUrls(metadata, service, preferencesNode, playletServerPort)
contentNode.url = streamUrls[0]
SetCaptions(metadata, service, contentNode)
contentNode.addFields({
metadata: metadata,
metadata: metadata
' StreamUrls is taken
playletStreamUrls: streamUrls,
playletStreamUrls: streamUrls
playletStreamUrlIndex: 0
})
@@ -52,7 +52,7 @@ function VideoContentTask(input as object) as object
}
end function
function CreateStreamUrls(metadata as object, service as Invidious.InvidiousService, preferences as object, playletServerUrl as string) as object
function CreateStreamUrls(metadata as object, service as Invidious.InvidiousService, preferences as object, playletServerPort as integer) as object
instance = service.GetInstance()
proxyVideos = preferences["invidious.proxy_videos"]
@@ -63,12 +63,12 @@ function CreateStreamUrls(metadata as object, service as Invidious.InvidiousServ
else
preferredQuality = preferences["playback.preferred_quality"]
if preferredQuality = "720p"
AddStreamUrls(streamUrls, metadata, service, proxyVideos)
AddDashUrls(streamUrls, metadata, proxyVideos, playletServerUrl)
if preferredQuality = "auto"
AddDashUrls(streamUrls, metadata, proxyVideos, playletServerPort)
AddStreamUrls(streamUrls, metadata, service, proxyVideos, preferredQuality)
else
AddDashUrls(streamUrls, metadata, proxyVideos, playletServerUrl)
AddStreamUrls(streamUrls, metadata, service, proxyVideos)
AddStreamUrls(streamUrls, metadata, service, proxyVideos, preferredQuality)
AddDashUrls(streamUrls, metadata, proxyVideos, playletServerPort)
end if
end if
@@ -84,29 +84,42 @@ function AddHlsUrls(streamUrls as object, metadata as object, proxyVideos as str
AddUrls(streamUrls, hlsUrl, hlsUrlLocal, proxyVideos)
end function
function AddDashUrls(streamUrls as object, metadata as object, proxyVideos as string, playletServerUrl as string) as void
#if LOCAL_DASH
' Redirect to Playet's local web server, where will will be
' dynamically generating the DASH manifest.
dashUrl = `${playletServerUrl}/api/dash?v=${metadata.videoId}`
#else
if metadata.dashUrl = invalid
return
end if
dashUrl = metadata.dashUrl
#end if
function AddDashUrls(streamUrls as object, metadata as object, proxyVideos as string, playletServerPort as integer) as void
' Redirect to Playet's local web server, where will will be
' dynamically generating the DASH manifest, instead of metadata.dashUrl
dashUrl = `http://127.0.0.1:${playletServerPort}/api/dash?v=${metadata.videoId}`
dashUrlLocal = AddLocalFlag(dashUrl)
AddUrls(streamUrls, dashUrl, dashUrlLocal, proxyVideos)
end function
function AddStreamUrls(streamUrls as object, metadata as object, service as Invidious.InvidiousService, proxyVideos as string) as void
function AddStreamUrls(streamUrls as object, metadata as object, service as Invidious.InvidiousService, proxyVideos as string, preferredQuality as string) as void
if metadata.formatStreams = invalid or metadata.formatStreams.Count() = 0
return
end if
url = service.GetVideoStreamUrl(metadata.videoId)
itag = invalid
' If we prefer medium quality, we check if we have a 360p or 480p streams
if preferredQuality = "medium"
' These are roughly the itags for 360p and 480p
' Most videos will hit 18, which is 360p
mediumItags = {
"18": true
"43": true
"44": true
"82": true
"83": true
"101": true
}
for each formatStream in metadata.formatStreams
if mediumItags[ValidString(formatStream.itag)] = true
itag = formatStream.itag
exit for
end if
end for
end if
url = service.GetVideoStreamUrl(metadata.videoId, itag)
localUrl = AddLocalFlag(url)
AddUrls(streamUrls, url, localUrl, proxyVideos)
@@ -151,6 +164,7 @@ function SetCaptions(metadata as object, service as object, contentNode as objec
if metadata.captions.Count() = 0
return
end if
' TODO:P2 we don't need to read and parse this every time
isoLanguageList = ParseJson(ReadAsciiFile("libpkg:/config/ISO-639-1-to-ISO-639-2T.json5"))
instance = service.GetInstance()
@@ -158,9 +172,25 @@ function SetCaptions(metadata as object, service as object, contentNode as objec
subtitleTracks = []
for each caption in metadata.captions
code = caption.language_code
if StringUtils.IsNullOrEmpty(code)
continue for
end if
if code.InStr("-") <> -1
code = code.Split("-")[0]
end if
if code.len() = 2
if not isoLanguageList.DoesExist(code)
continue for
end if
code = isoLanguageList[code]
end if
subtitleTracks.Push({
Description: caption.label,
Language: isoLanguageList[caption.language_code] ?? caption.language_code,
Description: caption.label
Language: code
TrackName: instance + caption.url
})
end for
@@ -168,4 +198,3 @@ function SetCaptions(metadata as object, service as object, contentNode as objec
contentNode.ClosedCaptions = True
contentNode.SubtitleTracks = subtitleTracks
end function
@@ -15,12 +15,22 @@ function Init()
' videoPlayingSuccess indicates if we started playing a video successfully
' We use it to detect if we should try another link for a video, or if another error
' occurred (such as a next work error)
' occurred (such as a network error)
m.videoPlayingSuccess = false
' ignoreNextFinishedState indicates if we should ignore the next finished state
' This is used to prevent the video from playing the next video when we are
' still trying to find a working stream url
m.ignoreNextFinishedState = false
' asyncStopSemantics available since Roku OS 12.5
' It is set to true because stopping synchronously causes timeout and crash
' Usually we would need to wait for the video state to move to "stopping" then to "stopped"
' before considering the video node closed, and creating a new one.
' However, since we have a task to load video details, there should be enough time for the
' video node to close before we create a new one.
if m.top.hasField("asyncStopSemantics")
m.top.asyncStopSemantics = true
end if
end function
function OnNodeReady()
@@ -35,7 +45,6 @@ function OnNodeReady()
m.container.observeFieldScoped("fullscreen", FuncName(OnFullScreenChange))
m.top.ObserveField("state", FuncName(OnVideoPlayerStateChange))
m.top.observeField("control", FuncName(OnControlChange))
SponsorBlock.SetupSponsorBlock()
end function
@@ -69,10 +78,10 @@ function StartVideoContentTask(videoContentNode as object)
m.top.content = videoContentNode
m.videoContentTask = StartAsyncTask(VideoContentTask, {
content: videoContentNode,
invidious: m.top.invidious,
preferences: m.top.preferences,
playletServerUrl: m.top.webServer@.GetServerAddress(invalid)
content: videoContentNode
invidious: m.top.invidious
preferences: m.top.preferences
playletServerPort: m.top.webServer.port
}, OnVideoContentTaskResults)
end function
@@ -110,13 +119,22 @@ end function
function MarkVideoWatched(videoId as string)
if m.top.invidious.authToken <> invalid
StartAsyncTask(MarkVideoWatchedTask, {
videoId: videoId,
videoId: videoId
invidious: m.top.invidious
})
end if
end function
function Close(unused as dynamic)
function Close(_unused as dynamic)
if m.videoContentTask <> invalid
m.videoContentTask.cancel = true
m.videoContentTask = invalid
end if
if m.sponsorBlockTask <> invalid
m.sponsorBlockTask.cancel = true
m.sponsorBlockTask = invalid
end if
m.top.control = "stop"
m.top.content = invalid
parent = m.top.getParent()
@@ -126,19 +144,6 @@ function Close(unused as dynamic)
SponsorBlock.RemoveNotifcation(m.notifications)
end function
function OnControlChange()
if m.top.control = "stop"
if m.videoContentTask <> invalid
m.videoContentTask.cancel = true
m.videoContentTask = invalid
end if
if m.sponsorBlockTask <> invalid
m.sponsorBlockTask.cancel = true
m.sponsorBlockTask = invalid
end if
end if
end function
function OnVideoPlayerStateChange() as void
state = m.top.state
content = m.top.content
@@ -185,23 +190,8 @@ function OnVideoPlayerStateChange() as void
end if
if state = "finished"
if content = invalid
m.container@.watchedVideosClear(invalid)
VideoUtils.CloseVideo()
return
end if
metadata = content.metadata
if metadata = invalid
m.container@.watchedVideosClear(invalid)
VideoUtils.CloseVideo()
return
end if
if not PlayNext(metadata.recommendedVideos)
m.container@.watchedVideosClear(invalid)
VideoUtils.CloseVideo()
end if
OnVideoFinished()
return
end if
if state = "error"
@@ -225,8 +215,29 @@ function OnVideoPlayerStateChange() as void
end if
end function
function OnVideoFinished() as void
content = m.top.content
if content = invalid
m.playQueue@.watchedVideosClear()
VideoUtils.CloseVideo()
return
end if
metadata = content.metadata
if metadata = invalid
m.playQueue@.watchedVideosClear()
VideoUtils.CloseVideo()
return
end if
if not PlayNext(metadata.recommendedVideos)
m.playQueue@.watchedVideosClear()
VideoUtils.CloseVideo()
end if
end function
function PlayNext(recommendedVideos as object) as boolean
if m.playQueue@.PlayNextItem(invalid)
if m.playQueue@.PlayNextItem()
return true
end if
@@ -251,9 +262,9 @@ function PlayNextRecommendedVideo(recommendedVideos as object) as boolean
if videoId = invalid
continue for
end if
if not m.container@.watchedVideosContain(videoId)
if not m.playQueue@.watchedVideosContain(videoId)
LogInfo(`Playing next recommended video (${videoId})`)
instance = m.invidious@.GetCurrentInstance(invalid)
instance = m.invidious@.GetCurrentInstance()
node = InvidiousContent.ToVideoContentNode(invalid, metadata, instance)
m.playQueue@.Play(node, -1)
return true
@@ -277,7 +288,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
end if
if key = "back"
m.container@.watchedVideosClear(invalid)
m.playQueue@.watchedVideosClear()
VideoUtils.CloseVideo()
return true
end if
@@ -1,12 +1,12 @@
function SetPlayerStyle()
m.top.trickPlayBar.filledBarBlendColor = "0xFF0000FF"
m.top.bufferingBar.filledBarBlendColor = "0xFF0000FF"
m.top.retrievingBar.filledBarBlendColor = "0xFF0000FF"
m.top.trickPlayBar.filledBarBlendColor = "#FF1C30FF"
m.top.bufferingBar.filledBarBlendColor = "#FF1C30FF"
m.top.retrievingBar.filledBarBlendColor = "#FF1C30FF"
' Find the BusySpinner built into the Video node
busySpinner = FindChildNodeOfType(m.top, "BusySpinner")
if busySpinner <> invalid
busySpinner.poster.blendColor = "0xFF0000FF"
busySpinner.poster.blendColor = "#FF1C30FF"
end if
end function
@@ -13,14 +13,14 @@ namespace VideoUtils
LogError("VideoContainer not found! Attempting to restore focus to top screen...")
appController = m.top.getScene().findNode("AppController")
if appController <> invalid
appController@.FocusTopScreen(invalid)
appController@.FocusTopScreen()
end if
DialogUtils.ShowDialog(`VideoContainer not found!\nPlease try again. If the problem persist, contact Playlet authors.`, "Error playing video")
return
end if
videoPlayer = container.createChild("videoPlayer")
videoPlayer.id = "VideoPlayer"
videoPlayer@.BindNode(invalid)
videoPlayer@.BindNode()
videoPlayer@.PlayWithContent(contentNode)
@@ -39,10 +39,10 @@ namespace VideoUtils
if videoPlayer = invalid
return
end if
videoPlayer@.Close(invalid)
videoPlayer@.Close()
if setFocus
videoPlayer.appController@.FocusTopScreen(invalid)
videoPlayer.appController@.FocusTopScreen()
end if
end function
@@ -76,7 +76,7 @@ namespace VideoUtils
if videoContainer.fullscreen
NodeSetFocus(videoPlayer, true)
else
videoPlayer.appController@.FocusTopScreen(invalid)
videoPlayer.appController@.FocusTopScreen()
end if
return true
end function
@@ -52,7 +52,7 @@ namespace Http
end for
feeds.push({
"title": bookmarkGroupNode.title,
"title": bookmarkGroupNode.title
"feedSources": feedSources
})
end for
Loaded 100 of 193 files, more files were not shown because too many files have changed in this diff. Show more