Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc78fb0ec1 | ||
|
|
05f2481f87 | ||
|
|
bdaaf17785 | ||
|
|
a675811488 | ||
|
|
d80240130d | ||
|
|
459a009293 | ||
|
|
cf08c67de5 | ||
|
|
9cd664fdd7 | ||
|
|
ad753deac7 | ||
|
|
3acf733eec | ||
|
|
6c84630cec | ||
|
|
682e0bae7f | ||
|
|
02e206ad22 | ||
|
|
c40428f2d6 | ||
|
|
cb45732965 | ||
|
|
9ccf1efee9 | ||
|
|
5a7ebf95bc | ||
|
|
fef289a201 | ||
|
|
98de5f223e | ||
|
|
90ccb4080c | ||
|
|
1c6a2e39d1 | ||
|
|
cf102d1bd1 | ||
|
|
3223fbd8f2 | ||
|
|
4433514975 | ||
|
|
1755220ee9 | ||
|
|
2fdbb18e33 | ||
|
|
8f8c7d38a8 | ||
|
|
9a631aab51 | ||
|
|
b7e6a1ea83 | ||
|
|
5c43bdf904 | ||
|
|
bd688854ae | ||
|
|
2a42f70178 | ||
|
|
f1d091941f | ||
|
|
e6b56ac495 | ||
|
|
a92ff6c601 | ||
|
|
322232a027 | ||
|
|
8ee9acadad | ||
|
|
ca11978995 | ||
|
|
4fb796b13b | ||
|
|
763cb64ba7 | ||
|
|
32bcc1dfc0 | ||
|
|
8169c7223d | ||
|
|
7d2d403e3f | ||
|
|
71045bf944 | ||
|
|
8f17be6036 | ||
|
|
3ce2baf683 | ||
|
|
8fa06bf05a | ||
|
|
82162d52c1 | ||
|
|
53f9249b9f | ||
|
|
6adbe94a1e | ||
|
|
aaea507fde | ||
|
|
52b4feb130 | ||
|
|
0d79c4975e | ||
|
|
0e2be8d5bb | ||
|
|
71453237c4 | ||
|
|
5baab67bb4 | ||
|
|
ece50b547e | ||
|
|
7a27bc673e | ||
|
|
822f95bb9d | ||
|
|
57f4c7a4a2 | ||
|
|
d1cb877784 | ||
|
|
0de521c525 | ||
|
|
447e58c336 | ||
|
|
66cf61059b | ||
|
|
f1f1e550bc | ||
|
|
fb7a898cfa | ||
|
|
f40e0b7471 | ||
|
|
43f0159510 | ||
|
|
80d67cf417 | ||
|
|
b0bbb97626 | ||
|
|
beb607a2d0 | ||
|
|
043a0e5301 | ||
|
|
e0020ffa66 | ||
|
|
9697ac58d0 | ||
|
|
97921aab6e | ||
|
|
e4489cd2cb | ||
|
|
aea2cb39d7 | ||
|
|
98e07877e3 | ||
|
|
a4970b3e14 | ||
|
|
0bd05cdba6 | ||
|
|
9dcfd20c57 | ||
|
|
757bd50701 | ||
|
|
ae37623756 | ||
|
|
2cffe72d7b | ||
|
|
3f85d609d8 | ||
|
|
1faec073f0 | ||
|
|
5aac07d36c | ||
|
|
d91411b740 | ||
|
|
d14c729c91 | ||
|
|
9d8a3d1cea | ||
|
|
90df81df4b | ||
|
|
fa1bc29220 | ||
|
|
1366284453 | ||
|
|
a38c6ebf7f | ||
|
|
ee29d7a4b3 | ||
|
|
9848c2a31a | ||
|
|
2ff73c3bc7 | ||
|
|
4926965daf | ||
|
|
7045386901 | ||
|
|
cc8ab757cf | ||
|
|
c9e9e34b42 | ||
|
|
7a155c689e | ||
|
|
4640a34863 |
No files matched your search
@@ -1,8 +1,6 @@
|
||||
name: Linter
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Use Node.js 18.x
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18.x
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build Playlet
|
||||
run: npm run build:release:ci
|
||||
|
||||
- name: Delete unstable release
|
||||
uses: dev-drprasad/delete-tag-and-release@v1.0
|
||||
with:
|
||||
tag_name: unstable
|
||||
github_token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: Create unstable release
|
||||
run: gh release create unstable ./release/playlet.zip ./playlet/src/lib/playlet-lib.zip --notes-file docs/unstable-changelog.md --prerelease --title unstable
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
+3
-1
@@ -3,5 +3,7 @@ out/
|
||||
node_modules
|
||||
.vscode/.env
|
||||
**/roku_modules/**
|
||||
playlet-lib/src/www
|
||||
playlet/src/lib/playlet-lib.zip
|
||||
release/playlet.zip
|
||||
src/www
|
||||
release/playlet.pkg
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"RokuCommunity.brightscript",
|
||||
"svelte.svelte-vscode",
|
||||
]
|
||||
}
|
||||
Vendored
+27
-3
@@ -10,10 +10,27 @@
|
||||
"stopOnEntry": false,
|
||||
"enableDebuggerAutoRecovery": false,
|
||||
"stopDebuggerOnAppExit": false,
|
||||
"rootDir": "${workspaceFolder}/dist/build",
|
||||
"rootDir": "${workspaceFolder}/dist/build/playlet",
|
||||
"sourceDirs": [
|
||||
"${workspaceFolder}/playlet/src"
|
||||
],
|
||||
"files": [
|
||||
"**/*"
|
||||
],
|
||||
"componentLibraries": [
|
||||
{
|
||||
"rootDir": "${workspaceFolder}/dist/build/playlet-lib",
|
||||
"outFile": "playlet-lib.zip",
|
||||
"files": [
|
||||
"**/*"
|
||||
]
|
||||
}
|
||||
],
|
||||
"preLaunchTask": "build-dev",
|
||||
"name": "Playlet (dev)",
|
||||
"injectRdbOnDeviceComponent": true
|
||||
"injectRdbOnDeviceComponent": true,
|
||||
"injectRaleTrackerTask": true,
|
||||
"raleTrackerTaskFileLocation": "${workspaceFolder}/tools/RALE/TrackerTask.xml"
|
||||
},
|
||||
{
|
||||
"type": "brightscript",
|
||||
@@ -24,7 +41,14 @@
|
||||
"stopOnEntry": false,
|
||||
"enableDebuggerAutoRecovery": false,
|
||||
"stopDebuggerOnAppExit": false,
|
||||
"rootDir": "${workspaceFolder}/dist/build",
|
||||
"rootDir": "${workspaceFolder}/dist/build/playlet",
|
||||
"sourceDirs": [
|
||||
"${workspaceFolder}/playlet/src",
|
||||
"${workspaceFolder}/playlet-lib/src"
|
||||
],
|
||||
"files": [
|
||||
"**/*",
|
||||
],
|
||||
"preLaunchTask": "build-prod",
|
||||
"name": "Playlet (prod)"
|
||||
},
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"brightscript.bsdk": "node_modules/brightscript",
|
||||
"brightscript.output.clearConsoleOnChannelStart": false,
|
||||
}
|
||||
Vendored
+42
-13
@@ -3,22 +3,51 @@
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build-dev",
|
||||
"presentation": {
|
||||
"close": true,
|
||||
"reveal": "silent",
|
||||
"revealProblems": "onProblem"
|
||||
},
|
||||
"script": "build:dev",
|
||||
"type": "npm"
|
||||
"dependsOn": [
|
||||
"build-app-dev"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "build-app-dev",
|
||||
"script": "build:app:dev",
|
||||
"type": "npm",
|
||||
"dependsOn": [
|
||||
"build-lib-dev"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "build-lib-dev",
|
||||
"script": "build:lib:dev",
|
||||
"type": "npm",
|
||||
"dependsOn": [
|
||||
"build-web"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "build-prod",
|
||||
"presentation": {
|
||||
"close": true,
|
||||
"reveal": "silent",
|
||||
"revealProblems": "onProblem"
|
||||
},
|
||||
"script": "build:prod",
|
||||
"dependsOn": [
|
||||
"build-app-prod"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "build-app-prod",
|
||||
"script": "build:app:prod",
|
||||
"type": "npm",
|
||||
"dependsOn": [
|
||||
"build-lib-prod"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "build-lib-prod",
|
||||
"script": "build:lib:prod",
|
||||
"type": "npm",
|
||||
"dependsOn": [
|
||||
"build-web"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "build-web",
|
||||
"script": "build:web",
|
||||
"type": "npm"
|
||||
}
|
||||
]
|
||||
|
||||
+109
-2
@@ -1,11 +1,100 @@
|
||||
# Changelog
|
||||
|
||||
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.6.0] - 2023-01-10
|
||||
## [0.10.1] - 2023-06-28
|
||||
|
||||
### Added
|
||||
|
||||
- Support playing a video from a specific time (cast from phone, drag and drop, open in Invidious)
|
||||
|
||||
### Fixed
|
||||
|
||||
- A crash where the saved auth token is not in a valid format
|
||||
- Video duration formatting for long videos
|
||||
- A bug where app would lose focus when playing the next video (0.10.0 regression)
|
||||
|
||||
## [0.10.0] - 2023-06-25
|
||||
|
||||
### Added
|
||||
|
||||
- New web app, mirroring Playlet app
|
||||
- Includes home page, search, settings and info
|
||||
- Dark mode
|
||||
- Also includes a dev menu
|
||||
- Hidden by default, use `dev=1` in the browser to show it
|
||||
- Improved drag and drop functionality (drag and drop a link from Youtube into the web app)
|
||||
- New settings page, available on TV and web app
|
||||
- New preferences system
|
||||
- Unified settings between TV and web app
|
||||
- Web API allowing to import/export preferences (no UI for that yet)
|
||||
- Added launch argument `clearPlayletLibUrls`
|
||||
- If the dev menu is used to load a custom Playlet lib url, but the lib does not have a functionality to revert back, `curl -d '' "http://$ROKU_DEV_TARGET:8060/launch/dev?clearPlayletLibUrls=true"` can be used to remove the custom lib, and revert to using default.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Issue where a dialog remains on screen when a video was cast from web app
|
||||
|
||||
### Changed
|
||||
|
||||
- SponsorBlock segments are not skipped by default, except for sponsor segments
|
||||
- Web app QR Code is now in its own page
|
||||
- Roku OS 10.0 minimum is required
|
||||
|
||||
### Removed
|
||||
|
||||
- The ability to set multiple Invidious instances. This was anticipated to use as fallback in case of failure, but it was never implemented. This is now removed to avoid confusion
|
||||
- Sometimes it is necesary to check multiple instances for closed captions in case one instance is saturated. For this case, publicly hosted Invidious instances will be used. This feature is still behind a feature flag, and not on by default, because it might delay the start of videos.
|
||||
- Of course, if no instance if provided, a public instance will be used by default. This behaviour did not change and it is now implicit.
|
||||
|
||||
## [0.9.0] - 2023-04-21
|
||||
|
||||
### Added
|
||||
|
||||
- Add watched videos to Invidious watch history
|
||||
- App info screen
|
||||
- A dev menu selector to test newer or older versions of playlet lib
|
||||
- Makes it possible to test unstable releases before they officially release
|
||||
|
||||
### Fixed
|
||||
|
||||
- A crash where the metadata of a video is not validated [#57](https://github.com/iBicha/playlet/issues/57)
|
||||
- A crash where the video details in home screen are null [#56](https://github.com/iBicha/playlet/issues/56)
|
||||
- A crash where the video details are not returned in json [#63](https://github.com/iBicha/playlet/issues/63)
|
||||
- Revert to using DASH instead of 720p by default
|
||||
- A crash where request cache fails [#62](https://github.com/iBicha/playlet/issues/62)
|
||||
|
||||
## [0.8.0] - 2023-03-02
|
||||
|
||||
### Added
|
||||
|
||||
- SponsorBlock notification
|
||||
- Invidious username to web app v1
|
||||
|
||||
### Fixed
|
||||
|
||||
- Crash in case GetLocalIpAddress() returns invalid
|
||||
- Use Format Stream (720p) instead of DASH (<https://github.com/iv-org/invidious/issues/3666>)
|
||||
|
||||
## [0.7.0] - 2023-02-04
|
||||
|
||||
### Added
|
||||
|
||||
- A script to sync between Youtube profile and and Invidious profile
|
||||
- Moved most of Playlet logic to Playlet Lib
|
||||
- Support for multiple caption languages
|
||||
|
||||
#### Fixed
|
||||
|
||||
- Issue where auto-play keeps playing the same videos in a loop
|
||||
|
||||
## [0.6.0] - 2023-01-10
|
||||
|
||||
### Added
|
||||
|
||||
- Ability to clear search history from web app
|
||||
- WebSocket server for realtime events
|
||||
- SponsorBlock tracking
|
||||
@@ -14,22 +103,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Caching for video details
|
||||
|
||||
### Changed
|
||||
|
||||
- The License has changed from MIT to AGPL
|
||||
- Now videos play the next related/recommended video once finished
|
||||
- This does not take into account the videos in playlists
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bug where app freezes if metadata fails to fetch
|
||||
- Bug where SponsorBlock returning videoDuration of zero causes the app to hang
|
||||
- Bug where app would lose focus when casting from web app
|
||||
- Bug where DASH stream is not compatible. Play format stream as a fallback
|
||||
- Showing upcoming videos correctly
|
||||
|
||||
# Removed
|
||||
### Removed
|
||||
|
||||
- Dependency on [roku-promise](https://github.com/rokucommunity/roku-promise)
|
||||
|
||||
## [0.5.0] - 2022-12-02
|
||||
|
||||
### Added
|
||||
|
||||
- Version check in settings page
|
||||
- Support for web request body parsing
|
||||
- Error dialog for video load fail
|
||||
@@ -41,6 +135,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Error and Exit dialogs
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bug where playing and exiting a video too quickly would cause the video to play in the background.
|
||||
- Bug where logging in causes issues if a video is already playing
|
||||
- Bug where casting from web app while playing a video from the search
|
||||
@@ -49,7 +144,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Race condition where button group gains focus before suggestions are set in Search Page
|
||||
|
||||
## [0.4.0] - 2022-11-24
|
||||
|
||||
### Added
|
||||
|
||||
- Play video API
|
||||
- Play video by ID/URL in web app
|
||||
- Metadata to Video Player
|
||||
@@ -59,13 +156,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Very basic UI to customize/change invidious instance
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bug where Settings page and home page are both visible, if settings page is selected, and user logs in.
|
||||
|
||||
## [0.3.0] - 2022-11-19
|
||||
|
||||
### Changed
|
||||
|
||||
- App name! new name: **Playlet**
|
||||
|
||||
### Added
|
||||
|
||||
- Nav bar / menu
|
||||
- Web server now always on
|
||||
- Settings page with QR Code
|
||||
@@ -73,7 +174,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- New UI
|
||||
|
||||
## [0.2.0] - 2022-11-06
|
||||
|
||||
### Added
|
||||
|
||||
- QrCode component to take user to invidious token page
|
||||
- Web server allowing the recption of the token through call back
|
||||
- The web server can also be used to serve a web app, facilitating the
|
||||
@@ -85,7 +188,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Added basic instructions
|
||||
|
||||
## [0.1.0] - 2022-10-30
|
||||
|
||||
### Added
|
||||
|
||||
- Initial version
|
||||
- Reads feeds from popular and trending videos using Invidious APIs
|
||||
- Skips sections using SponsorBlock
|
||||
|
||||
<!-- markdownlint-configure-file {"MD024": { "siblings_only": true } } -->
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
# PRIVACY POLICY
|
||||
|
||||
## Playlet
|
||||
Playlet, the Roku app, does not collect any user information whatsoever.
|
||||
In fact, it does not have any servers capable of collecting any form of data.
|
||||
|
||||
Playlet does not show advertising, whether personalized or non personalized.
|
||||
|
||||
## Invidious
|
||||
Playlet may request information from one or more [Invidious](https://invidious.io/)
|
||||
servers, depending on user configuration. With these requests, absolutely no
|
||||
user data is collected, and only the bare minimum and necessary information
|
||||
is sent, which is used to enable the viewing of content.
|
||||
|
||||
Please note that some of the [Invidious](https://invidious.io/) servers used
|
||||
could be public instances hosted by volenteers. These instances are available
|
||||
[here](https://api.invidious.io/).
|
||||
|
||||
While invidious does no data collection by default, and it is in fact built to
|
||||
be privacy driven, but in theory, from a playlet request it is possible to
|
||||
know the IP address of a user, the identifiers of watched video, and search
|
||||
keywords. In case the user is unreasonably paranoid, they can host their own
|
||||
Invidious instance and use it from Playlet.
|
||||
|
||||
## SponsorBlock
|
||||
Playlet may request information from a [SponsorBlock](https://github.com/ajayyy/SponsorBlock)
|
||||
server, in order to get sponsor sections for requested videos to watch.
|
||||
With these requests, absolutely no
|
||||
user data is collected, and only the bare minimum and necessary information
|
||||
is sent, which is used to enable the viewing of content.
|
||||
|
||||
Playlet uses hashing when requesting video metadata, which obfuscates
|
||||
the video id requested. This is a SponsorBlock privacy feature that protects
|
||||
user privacy.
|
||||
|
||||
Additionally, Playlet may send a "skipped" event to SponsorBlock, to indicate
|
||||
that a section of a video has been skipped. This event does not have any
|
||||
tracking information attached to it, and it is anonymous. It is merely to
|
||||
indicate to contributers how much their contributions are being used in the wild.
|
||||
@@ -1,23 +1,39 @@
|
||||
# Playlet
|
||||
<p align="center">
|
||||
<img src="banner.png" style="display:block;text-align:center" alt="Playlet Logo" width="800"/>
|
||||
<br/><br/>
|
||||
<a href="https://github.com/iBicha/playlet/actions/workflows/release.yml?query=branch%3Amain">
|
||||
<img alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/iBicha/playlet/release.yml.svg?branch=main"/>
|
||||
</a>
|
||||
<a href="https://github.com/iBicha/playlet/releases">
|
||||
<img alt="Current Release" src="https://img.shields.io/github/release/iBicha/playlet.svg"/>
|
||||
<img alt="Total Downloads" src="https://img.shields.io/github/downloads/iBicha/playlet/latest/playlet-lib.zip.svg"/>
|
||||
</a>
|
||||
<a href="https://github.com/iBicha/playlet">
|
||||
<img alt="AGPL-3.0 license" src="https://img.shields.io/github/license/iBicha/playlet.svg"/>
|
||||
</a>
|
||||
<a href="https://channelstore.roku.com/en-ca/details/840aec36f51bfe6d96cf6db9055a372a/playlet">
|
||||
<img alt="Roku Channel Store" src="https://img.shields.io/badge/Roku%20Store-Install-blueviolet?logo=roku&logoColor=blueviolet&labelColor=white"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
# Playlet
|
||||
|
||||
Unofficial Youtube client for Roku 📺
|
||||
Playlet is an unofficial Youtube client for Roku 📺
|
||||
|
||||
## Features
|
||||
- 🔥 No Ads (Not now, not ever)
|
||||
- 🕵️ No Tracking
|
||||
- 🛡️ Privacy driven (uses Invidious backend)
|
||||
- ⚔️ SponsorBlock integration (skips undesirable sections in videos)
|
||||
- 📱 Cast from phone
|
||||
- 📱 Browse, search, and cast from phone using the web app
|
||||
- 🔮 Picture-in-picture mode
|
||||
- ⚡ Fast! [Check out how we compare with the official Youtube app](https://youtu.be/qmSvA-QQW20)
|
||||
|
||||
### Cast from phone
|
||||
1. Open settings in Playlet
|
||||
1. Open "Web app" tab in Playlet
|
||||
1. Scan QR Code with Phone
|
||||
1. Enter video ID or video url, and press Play button
|
||||
1. Browse or search videos
|
||||
1. Click the video and choose the "Play on TV" option
|
||||
|
||||
### Picture-in-picture
|
||||
- When viewing a video in full screen, press ⬇️ (down) button on your remote to shrink the video
|
||||
@@ -28,15 +44,25 @@ Unofficial Youtube client for Roku 📺
|
||||
1. Open settings in Playlet
|
||||
1. Scan QR Code with Phone
|
||||
1. Change the Invidious instance
|
||||
1. You can also do this from the settings tab
|
||||
|
||||
## Screenshots
|
||||
<img src="screenshot1.jpg" alt="Screenshot of Playlet" width="350"/>
|
||||
<img src="screenshot2.jpg" alt="Screenshot of Playlet" width="350"/>
|
||||
<img src="screenshot3.jpg" alt="Screenshot of Playlet" width="350"/>
|
||||
<a href="./screenshots/README.md">
|
||||
|
||||
|  |  |  |
|
||||
|----------------------------------|----------------------------------|----------------------------------|
|
||||
|
||||
</a>
|
||||
|
||||
More under [Screenshots](./screenshots/README.md)
|
||||
|
||||
## Installation
|
||||
### Roku Store (Published app)
|
||||
[Playlet on Roku channel store](https://channelstore.roku.com/en-ca/details/840aec36f51bfe6d96cf6db9055a372a/playlet)
|
||||
Or use the link https://my.roku.com/account/add?channel=PLAYLET
|
||||
|
||||
### Enable Roku Developer Mode
|
||||
### Sideloaded (Dev app)
|
||||
#### Enable Roku Developer Mode
|
||||
First, you need to enable developer mode on your Roku TV (if you have not done that already).
|
||||
|
||||
Using your Roku remote, enter the following sequence:
|
||||
@@ -47,29 +73,13 @@ For full instructions, see [Set up your Roku device to enable Developer Settings
|
||||
|
||||
Make sure to remember the password you set during this step, you will need it later.
|
||||
|
||||
### Gather your info
|
||||
#### Gather your info
|
||||
By now, you should have the following
|
||||
- Your Roku Dev password (setup in the previous step)
|
||||
- Your Roku TV local IP address
|
||||
- You can find this information in your TV network settings. It should look like 192.168.X.X or so
|
||||
|
||||
### Install Playlet (command line)
|
||||
|
||||
Install Playlet as a dev channel using this command, and replace:
|
||||
- `REPLACE_PASSWORD_HERE` : with your Roku Dev password
|
||||
- `REPLACE_IP_ADDRESS_HERE` : with your Roku TV local IP address
|
||||
```
|
||||
curl https://raw.githubusercontent.com/iBicha/playlet/main/install.sh | ROKU_DEV_TARGET=REPLACE_IP_ADDRESS_HERE DEVPASSWORD=REPLACE_PASSWORD_HERE sh
|
||||
```
|
||||
Example:
|
||||
```
|
||||
curl https://raw.githubusercontent.com/iBicha/playlet/main/install.sh | ROKU_DEV_TARGET=192.168.1.2 DEVPASSWORD=1234 sh
|
||||
```
|
||||
|
||||
|
||||
If successful, you should see some output on your terminal, with `Status: 200`.
|
||||
|
||||
### Install Playlet (Manual)
|
||||
#### Install Playlet (Manual)
|
||||
1. Go to `https://github.com/iBicha/playlet/releases` and download `playlet.zip`
|
||||
2. Open `http://REPLACE_IP_ADDRESS_HERE/` (e.g. http://192.168.1.2/) in your browser
|
||||
3. If prompted for username and password
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"extends": "config/bsconfig.base.json",
|
||||
"host": "If your Roku IP is static, you can set it here and remove the host entry from .vscode/launch.json",
|
||||
"password": ""
|
||||
}
|
||||
@@ -12,16 +12,19 @@
|
||||
"source/**/*",
|
||||
"components/**/*",
|
||||
"images/**/*",
|
||||
"!images/vector/**/*",
|
||||
"fonts/**/*",
|
||||
"config/**/*",
|
||||
"lib/**/*",
|
||||
"www/**/*.*",
|
||||
"manifest"
|
||||
],
|
||||
"lintConfig": "config/bslint.jsonc",
|
||||
"lintConfig": "./config/bslint.jsonc",
|
||||
"plugins": [
|
||||
"roku-log-bsc-plugin",
|
||||
"@rokucommunity/bslint",
|
||||
"../scripts/asynctask-plugin.ts"
|
||||
"../tools/asynctask-plugin.ts",
|
||||
"../tools/manifest-bsconst-debug-plugin.ts"
|
||||
],
|
||||
"retainStagingDir": true,
|
||||
"require": [
|
||||
@@ -32,7 +35,5 @@
|
||||
"removeComments": false,
|
||||
"strip": false
|
||||
},
|
||||
"rootDir": "../src/",
|
||||
"sourceMap": true,
|
||||
"stagingDir": "dist/build"
|
||||
"sourceMap": true
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<!-- markdownlint-disable MD036 -->
|
||||
|
||||
# Releasing
|
||||
|
||||
These are mostly the steps when releasing a new version:
|
||||
|
||||
## Playlet lib
|
||||
|
||||
- Create local branch `release/$VERSION` e.g. `release/0.10.0`
|
||||
- Set version in package.json
|
||||
- Update CHANGELOG.md section from `[Unreleased]` to `[$VERSION] - DATE`
|
||||
- `npm run build:release`
|
||||
- This should fail because there are uncommitted changes. This is expected.
|
||||
- Commit changes
|
||||
- Create pull request
|
||||
- Title: `Release v$VERSION`
|
||||
- Comment: `Release $VERSION \nIt should contain everything planned from #6`
|
||||
- Wait for CI and merge
|
||||
- Wait for CI on main branch to create the `unstable` release
|
||||
- Edit `unstable` release
|
||||
- Tag: `v$VERSION`
|
||||
- Title: `v$VERSION`
|
||||
- Body: the content from CHANGELOG.md for this version
|
||||
- Uncheck `Set as a pre-release`
|
||||
- Check `Set as the latest release`
|
||||
- Click `update release`
|
||||
- Update [Roadmap](https://github.com/iBicha/playlet/issues/6)
|
||||
- If current versions says `Planned for $VERSION`, change it to `Released in $VERSION`
|
||||
- Add a `Planned for $VERSION` for the next version
|
||||
|
||||
**The newest Playlet lib is now LIVE**
|
||||
|
||||
## Playlet
|
||||
|
||||
For releasing to the store (when needed), this is done following a Playlet lib release:
|
||||
|
||||
- Switch to main branch and pull changes - **match commit corresponding to the release.**
|
||||
- `npm run build:release`
|
||||
- This should create the signed package under `release/playlet.pkg`
|
||||
- Upload to dashboard, and schedule a release (takes a couple of days)
|
||||
@@ -0,0 +1,11 @@
|
||||
<!-- markdownlint-disable MD041 -->
|
||||
|
||||
This is an automated release. It is generated when new code is pushed to the main branch.
|
||||
|
||||
To test this release:
|
||||
|
||||
- Open Playlet web app in dev mode (`http://ROKU_IP_ADDRESS:8888/index.html?dev=1`)
|
||||
- Go to settings, and scroll down to `Developer settings`
|
||||
- Set `Playlet Library version` to `unstable` and click `Apply`
|
||||
- Restart Playlet
|
||||
- You can verify that you're testing the `unstable` release in the `Info` tab in Playlet or the web app
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
# Installs the playlet.zip app as a dev channel
|
||||
|
||||
if [ -z "$ROKU_DEV_TARGET" ];
|
||||
then
|
||||
echo "Variable ROKU_DEV_TARGET is not set. What is your Roku TV IP address? Example: 192.168.1.2";
|
||||
read ROKU_DEV_TARGET
|
||||
fi
|
||||
|
||||
if [ -z "$DEVPASSWORD" ];
|
||||
then
|
||||
echo "Variable DEVPASSWORD is not set. What is your Roku Dev password? Example: 1234";
|
||||
read DEVPASSWORD
|
||||
fi
|
||||
|
||||
tmp_folder=$(mktemp -d)
|
||||
tmp_zip_file="$tmp_folder/playlet.zip"
|
||||
tmp_http_response_file="$tmp_folder/roku-response.html"
|
||||
|
||||
echo "Downloading archive to temporary folder ..."
|
||||
|
||||
# TODO: Check for curl, use wget if curl is not available
|
||||
curl -L https://github.com/iBicha/playlet/releases/latest/download/playlet.zip -o $tmp_zip_file
|
||||
|
||||
echo "Installing app on device at $ROKU_DEV_TARGET ..."
|
||||
|
||||
curl --user rokudev:$DEVPASSWORD --digest --silent --show-error -F "mysubmit=Install" -F "archive=@$tmp_zip_file" --output $tmp_http_response_file --write-out "Status: %{http_code}" http://$ROKU_DEV_TARGET/plugin_install
|
||||
|
||||
echo "\nDeleting temporary folder ..."
|
||||
|
||||
rm -rf $tmp_folder
|
||||
Generated
+1309
-3303
File diff suppressed because it is too large.
Load diff
+37
-24
@@ -1,27 +1,31 @@
|
||||
{
|
||||
"name": "playlet",
|
||||
"version": "0.6.0",
|
||||
"version": "0.10.1",
|
||||
"description": "Unofficial Youtube client for Roku",
|
||||
"dependencies": {
|
||||
"bslib": "npm:@rokucommunity/bslib@^0.1.1",
|
||||
"log": "npm:roku-log@^0.8.0",
|
||||
"roku-requests": "^0.2.0"
|
||||
"log": "npm:roku-log@^0.9.3",
|
||||
"roku-requests": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rokucommunity/bslint": "^0.7.5",
|
||||
"@types/node": "^18.11.18",
|
||||
"brighterscript": "^0.60.6",
|
||||
"brighterscript-formatter": "^1.6.19",
|
||||
"@rokucommunity/bslint": "^0.8.6",
|
||||
"@types/node": "^20.3.1",
|
||||
"argparse": "^2.0.1",
|
||||
"brighterscript": "^0.65.1",
|
||||
"brighterscript-formatter": "^1.6.29",
|
||||
"convert-svg-to-png": "^0.6.4",
|
||||
"dotenv": "^16.0.3",
|
||||
"roku-log-bsc-plugin": "^0.6.1",
|
||||
"ropm": "^0.10.10",
|
||||
"semver": "^7.3.8",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2",
|
||||
"ip": "^1.1.8",
|
||||
"roku-log-bsc-plugin": "^0.8.1",
|
||||
"ropm": "^0.10.15",
|
||||
"semver": "^7.5.3",
|
||||
"shelljs": "^0.8.5",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.9.4"
|
||||
"typescript": "^5.1.3"
|
||||
},
|
||||
"ropm": {
|
||||
"rootDir": "src",
|
||||
"rootDir": "playlet-lib/src",
|
||||
"noprefix": [
|
||||
"roku-requests"
|
||||
]
|
||||
@@ -29,21 +33,30 @@
|
||||
"scripts": {
|
||||
"dev:web": "cd playlet-web && npm run dev",
|
||||
"prebuild": "rm -rf dist",
|
||||
"build:dev": "npm run build:web && npm run build:lib:dev && npm run build:app:dev",
|
||||
"build:prod": "npm run build:web && npm run build:lib:prod && npm run build:app:prod",
|
||||
"build:release": "npm run build:release:ci && npm run sign-package",
|
||||
"build:release:ci": "npm run format:fix && npm run lint:fix && npm run manifest-version && npm run manifest-git-hash && npm run build:prod",
|
||||
"build:app": "cd playlet && bsc --create-package --lintConfig ../config/bslint.jsonc",
|
||||
"build:app:dev": "npm run build:app -- --debug=true",
|
||||
"build:app:prod": "npm run build:app -- --debug=false --sourceMap=false",
|
||||
"build:lib": "cd playlet-lib && bsc --create-package --lintConfig ../config/bslint.jsonc",
|
||||
"build:lib:dev": "npm run build:lib -- --debug=true",
|
||||
"build:lib:prod": "npm run build:lib -- --debug=false --sourceMap=false",
|
||||
"build:web": "cd playlet-web && npm run build",
|
||||
"build": "npm run build:web && bsc",
|
||||
"build:dev": "npm run manifest-symbols -- DEBUG=true && npm run build",
|
||||
"build:prod": "npm run manifest-symbols -- DEBUG=false && npm run build -- --sourceMap=false",
|
||||
"build:release": "npm run format:fix && npm run lint:fix && npm run manifest-version && npm run generate-images && npm run build:prod && npm run zip-package",
|
||||
"lint": "bslint --project config/bsconfig.lint.json --lintConfig config/bslint.jsonc",
|
||||
"lint": "bslint --project playlet-lib/bsconfig.lint.json --lintConfig config/bslint.jsonc && bslint --project playlet/bsconfig.lint.json --lintConfig config/bslint.jsonc",
|
||||
"lint:fix": "npm run lint -- --fix",
|
||||
"format:base": "bsfmt \"src/**/*.brs\" \"src/**/*.bs\" \"!src/components/lib/**/*\" \"!src/source/lib/**/*\" \"!**/bslib.brs\" \"!**/roku_modules/**/*\" --bsfmt-path \"config/bsfmt.jsonc\"",
|
||||
"format:base": "bsfmt \"playlet/src/**/*.brs\" \"playlet/src/**/*.bs\" \"!playlet/src/components/lib/**/*\" \"!playlet/src/source/lib/**/*\" \"!**/bslib.brs\" \"!**/roku_modules/**/*\" \"playlet-lib/src/**/*.brs\" \"playlet-lib/src/**/*.bs\" \"!playlet-lib/src/components/lib/**/*\" \"!playlet-lib/src/source/lib/**/*\" \"!**/bslib.brs\" \"!**/roku_modules/**/*\" --bsfmt-path \"config/bsfmt.jsonc\"",
|
||||
"format": "npm run format:base -- --check",
|
||||
"format:fix": "npm run format:base -- --write",
|
||||
"generate-images": "node scripts/generate-images.js",
|
||||
"manifest-version": "node scripts/update-manifest-version.js",
|
||||
"zip-package": "node scripts/zip-package.js",
|
||||
"screenshot": "node scripts/screenshot.js",
|
||||
"manifest-symbols": "node scripts/update-manifest-symbols.js",
|
||||
"generate-images": "node tools/generate-images.js",
|
||||
"manifest-version": "node tools/update-manifest-version.js",
|
||||
"manifest-git-hash": "node tools/update-manifest-git-hash.js",
|
||||
"sign-package": "node tools/sign-package.js",
|
||||
"screenshot": "node tools/screenshot.js",
|
||||
"profile-sync": "node tools/profile-sync.js",
|
||||
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
|
||||
"update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip",
|
||||
"postinstall": "npx ropm copy && cd playlet-web && npm install"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "../config/bsconfig.base.json",
|
||||
"rootDir": "src/",
|
||||
"stagingDir": "../dist/build/playlet-lib",
|
||||
"outFile": "../playlet/src/lib/playlet-lib.zip"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"createPackage": false,
|
||||
"deploy": false,
|
||||
"extends": "bsconfig.base.json",
|
||||
"extends": "bsconfig.json",
|
||||
"retainStagingDir": false,
|
||||
"sourceMap": false
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import "pkg:/source/utils/General.bs"
|
||||
import "pkg:/components/AppInfoScreen/AppVersionTask.bs"
|
||||
import "pkg:/source/asyncTask/asyncTask.bs"
|
||||
|
||||
function Init()
|
||||
m.displayNames = {
|
||||
"version": "Playlet Version",
|
||||
"lib_version": "Playlet Library Version",
|
||||
"lib_version_latest": "Playlet Library Latest Version",
|
||||
"lib_url": "Playlet Library URL",
|
||||
"lib_url_type": "Playlet Library URL Type",
|
||||
"git_commit_hash": "Playlet Git Commit Hash",
|
||||
"lib_git_commit_hash": "Playlet Library Git Commit Hash",
|
||||
"id": "App ID"
|
||||
}
|
||||
|
||||
m.keyValueList = m.top.findNode("KeyValueListContent")
|
||||
m.appInfo = GetAppInfo()
|
||||
m.appInfo["lib_version_latest"] = "N/A"
|
||||
m.appInfo["lib_url"] = "N/A"
|
||||
m.appInfo["lib_url_type"] = "N/A"
|
||||
|
||||
scene = m.top.getScene()
|
||||
if scene.playletLibLoadedUrl <> invalid
|
||||
m.appInfo["lib_url"] = scene.playletLibLoadedUrl.link
|
||||
m.appInfo["lib_url_type"] = scene.playletLibLoadedUrl.type
|
||||
end if
|
||||
|
||||
UpdateKeyValueList()
|
||||
GetLatestVersion()
|
||||
end function
|
||||
|
||||
function UpdateKeyValueList()
|
||||
while m.keyValueList.getChildCount() > 0
|
||||
m.keyValueList.removeChildIndex(0)
|
||||
end while
|
||||
|
||||
for each item in m.appInfo
|
||||
value = `${m.displayNames[item]}: ${m.appInfo[item]}`
|
||||
contentNode = m.keyValueList.createChild("ContentNode")
|
||||
contentNode.title = value
|
||||
end for
|
||||
end function
|
||||
|
||||
function GetLatestVersion()
|
||||
StartAsyncTask(AppVersionTask, {}, function(output as object) as void
|
||||
if output.result.latest <> invalid
|
||||
m.appInfo["lib_version_latest"] = output.result.latest
|
||||
UpdateKeyValueList()
|
||||
end if
|
||||
end function)
|
||||
end function
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="AppInfoScreen" extends="Group">
|
||||
<interface>
|
||||
</interface>
|
||||
<children>
|
||||
<LabelList
|
||||
translation="[170,92]"
|
||||
itemSize="[1020,48]"
|
||||
font='font:SmallestBoldSystemFont'>
|
||||
<ContentNode id="KeyValueListContent" role="content">
|
||||
</ContentNode>
|
||||
</LabelList>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,11 @@
|
||||
import "pkg:/source/utils/General.bs"
|
||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||
|
||||
@asynctask
|
||||
function AppVersionTask() as object
|
||||
latest = GetLatestPlayletLibVersion()
|
||||
|
||||
return {
|
||||
latest: latest
|
||||
}
|
||||
end function
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+7
-6
@@ -7,10 +7,6 @@ function Init()
|
||||
m.top.ObserveField("rowItemSelected", "OnHomeGridScreenVideoSelected")
|
||||
m.top.ObserveField("focus", "OnFocusChange")
|
||||
m.top.ObserveField("refresh", "OnRefresh")
|
||||
|
||||
m.top.focus = true
|
||||
|
||||
InitContent()
|
||||
end function
|
||||
|
||||
function OnFocusChange()
|
||||
@@ -32,7 +28,7 @@ function InitContent()
|
||||
}, true)
|
||||
m.top.content = contentNode
|
||||
|
||||
m.defaultLayout = ParseJson(ReadAsciiFile("pkg:/config/default_home_layout.json"))
|
||||
m.defaultLayout = ParseJson(ReadAsciiFile("libpkg:/config/default_home_layout.json"))
|
||||
|
||||
if m.defaultLayout.Count() > 0
|
||||
m.currentLoadingIndex = 0
|
||||
@@ -59,10 +55,15 @@ function StartFetchTask() as void
|
||||
StartAsyncTask(GetHomeScreenContent, {
|
||||
index: currentLoadingIndex,
|
||||
requestData: m.defaultLayout[currentLoadingIndex]
|
||||
}, function(output as object)
|
||||
}, function(output as object) as void
|
||||
' TODO: this whole logic is not good.
|
||||
' The view should have placeholder, and child nodes get replaced as
|
||||
' They get ready.
|
||||
if output = invalid
|
||||
StartFetchTask()
|
||||
return
|
||||
end if
|
||||
|
||||
m.sortedContent.Push(output.result)
|
||||
|
||||
if output.result.rootChildren.Count() > 0
|
||||
+2
-2
@@ -20,8 +20,8 @@
|
||||
rowItemSpacing="[[25,0]]"
|
||||
itemSize="[1280,326]"
|
||||
itemSpacing="[0,65]"
|
||||
rowLabelOffset="[[95,20]]"
|
||||
focusXOffset="[95]"
|
||||
rowLabelOffset="[[105,20]]"
|
||||
focusXOffset="[105]"
|
||||
showRowLabel="[true]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
focusBitmapUri="pkg:/images/focus_grid.9.png"
|
||||
+3
-10
@@ -10,19 +10,12 @@ function GetHomeScreenContent(input as object) as object
|
||||
|
||||
response = service.MakeRequest(requestData)
|
||||
if response <> invalid
|
||||
if type(response) = "roAssociativeArray"
|
||||
for each key in response
|
||||
rowContent = GetCategoryContent(key, response[key])
|
||||
if rowContent <> invalid
|
||||
rootChildren.Push(rowContent)
|
||||
end if
|
||||
end for
|
||||
else
|
||||
rowContent = GetCategoryContent(requestData.title, response)
|
||||
for each item in response
|
||||
rowContent = GetCategoryContent(item.title, item.videos)
|
||||
if rowContent <> invalid
|
||||
rootChildren.Push(rowContent)
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
return {
|
||||
@@ -0,0 +1,13 @@
|
||||
import "pkg:/source/services/InvidiousSettings.bs"
|
||||
|
||||
@asynctask
|
||||
function InvidiousPublicInstancesTask(input as object) as object
|
||||
' TODO: Move this to a better place
|
||||
' Caching backup instances in this task to avoid having to do it in the UI thread
|
||||
' Should be moved to a better place
|
||||
backupInstances = InvidiousSettings.FetchBackupInstances()
|
||||
|
||||
return {
|
||||
backupInstances: backupInstances
|
||||
}
|
||||
end function
|
||||
@@ -0,0 +1,153 @@
|
||||
import "pkg:/source/roku_modules/log/LogMixin.brs"
|
||||
import "pkg:/components/VideoPlayer/Video.bs"
|
||||
import "pkg:/components/Invidious/InvidiousPublicInstancesTask.bs"
|
||||
|
||||
function Init()
|
||||
log.initializeLogManager(["log_PrintTransport"], 2)
|
||||
|
||||
m.videoContainer = m.top.findNode("VideoContainer")
|
||||
m.global.addFields({
|
||||
videoContainer: m.videoContainer
|
||||
})
|
||||
|
||||
m.homeGridScreen = m.top.findNode("HomeGridScreen")
|
||||
m.homeGridScreen.ObserveField("escape", "OnHomeGridScreenEscape")
|
||||
m.homeGridScreen.SetFocus(true)
|
||||
m.currentFocued = m.homeGridScreen
|
||||
|
||||
m.settingsScreen = m.top.findNode("SettingsScreen")
|
||||
m.settingsScreen.ObserveField("escape", "OnSettingsScreenEscape")
|
||||
|
||||
m.appInfoScreen = m.top.findNode("AppInfoScreen")
|
||||
|
||||
m.webAppScreen = m.top.findNode("WebAppScreen")
|
||||
|
||||
m.searchScreen = m.top.findNode("SearchScreen")
|
||||
m.searchScreen.ObserveField("escape", "OnSearchScreenEscape")
|
||||
|
||||
m.navBar = m.top.findNode("NavBar")
|
||||
m.navBarScreens = [{
|
||||
node: m.searchScreen,
|
||||
canEscape: true
|
||||
}, {
|
||||
node: m.homeGridScreen,
|
||||
canEscape: true
|
||||
}, {
|
||||
node: m.settingsScreen,
|
||||
canEscape: true
|
||||
}, {
|
||||
node: m.webAppScreen,
|
||||
canEscape: false
|
||||
}, {
|
||||
node: m.appInfoScreen,
|
||||
canEscape: false
|
||||
}]
|
||||
m.navBar.ObserveField("escapeIndex", "OnNavBarEscape")
|
||||
m.navBar.ObserveField("focusIndex", "OnNavIndexChange")
|
||||
|
||||
InitWebServer()
|
||||
|
||||
StartAsyncTask(InvidiousPublicInstancesTask, {}, OnInvidiousPublicInstancesTaskResults)
|
||||
end function
|
||||
|
||||
function OnInvidiousPublicInstancesTaskResults(output as object)
|
||||
backupInstances = output.result.backupInstances
|
||||
m.global.addFields({
|
||||
invidiousBackupInstances: backupInstances
|
||||
})
|
||||
|
||||
m.homeGridScreen.refresh = true
|
||||
|
||||
LaunchArgumentsReceived()
|
||||
|
||||
scene = m.top.getScene()
|
||||
scene.ObserveField("inputArgs", "InputArgumentsReceived")
|
||||
scene.signalBeacon("AppLaunchComplete")
|
||||
end function
|
||||
|
||||
function InitWebServer()
|
||||
m.serverTask = createObject("roSGNode", "WebServerTask")
|
||||
m.serverTask.id = "WebServerTask"
|
||||
m.serverTask.ObserveField("login", "OnWebServerLogin")
|
||||
m.serverTask.ObserveField("command", "OnWebServerCommand")
|
||||
m.serverTask.control = "RUN"
|
||||
end function
|
||||
|
||||
function OnSearchScreenEscape()
|
||||
m.navBar.SetFocus(true)
|
||||
m.navBar.focusIndex = 0
|
||||
m.currentFocued = m.navBar
|
||||
end function
|
||||
|
||||
function OnSettingsScreenEscape()
|
||||
m.navBar.SetFocus(true)
|
||||
m.navBar.focusIndex = 2
|
||||
m.currentFocued = m.navBar
|
||||
end function
|
||||
|
||||
function OnHomeGridScreenEscape()
|
||||
m.navBar.SetFocus(true)
|
||||
m.navBar.focusIndex = 1
|
||||
m.currentFocued = m.navBar
|
||||
end function
|
||||
|
||||
function OnNavBarEscape()
|
||||
index = m.navBar.escapeIndex
|
||||
m.navBarScreens[index].node.focus = true
|
||||
if m.navBarScreens[index].canEscape
|
||||
m.currentFocued = m.navBarScreens[index].node
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnNavIndexChange() as void
|
||||
index = m.navBar.focusIndex
|
||||
if index = -1
|
||||
return
|
||||
end if
|
||||
for i = 0 to m.navBarScreens.count() - 1
|
||||
m.navBarScreens[i].node.visible = i = index
|
||||
end for
|
||||
end function
|
||||
|
||||
function OnWebServerLogin()
|
||||
m.homeGridScreen.refresh = true
|
||||
end function
|
||||
|
||||
function OnWebServerCommand() as void
|
||||
if m.serverTask.command = invalid or m.serverTask.command.command = invalid
|
||||
return
|
||||
end if
|
||||
if m.serverTask.command.command = "play"
|
||||
sender = m.videoContainer.sender ?? m.currentFocued
|
||||
if m.videoContainer.fullscreen
|
||||
dialog = m.top.getScene().dialog
|
||||
if dialog <> invalid
|
||||
dialog.close = true
|
||||
end if
|
||||
end if
|
||||
PlayVideo(m.serverTask.command.videoId, { sender: sender, timestamp: m.serverTask.command.timestamp })
|
||||
end if
|
||||
end function
|
||||
|
||||
function LaunchArgumentsReceived() as void
|
||||
scene = m.top.getScene()
|
||||
launchArgs = scene.launchArgs
|
||||
? "LaunchArgumentsReceived " launchArgs
|
||||
PlayVideoFromArgs(launchArgs)
|
||||
end function
|
||||
|
||||
function InputArgumentsReceived() as void
|
||||
scene = m.top.getScene()
|
||||
inputArgs = scene.inputArgs
|
||||
? "InputArgumentsReceived " inputArgs
|
||||
PlayVideoFromArgs(inputArgs)
|
||||
end function
|
||||
|
||||
function PlayVideoFromArgs(args as object) as void
|
||||
if args = invalid or args.contentId = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
sender = m.videoContainer.sender ?? m.currentFocued
|
||||
PlayVideo(args.contentId, { sender: sender, timestamp: args.timestamp })
|
||||
end function
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="MainScene" extends="Group">
|
||||
<children>
|
||||
<SearchScreen id="SearchScreen" visible="false" />
|
||||
<HomeGridScreen id="HomeGridScreen" />
|
||||
<SettingsScreen id="SettingsScreen" visible="false" />
|
||||
<WebAppScreen id="WebAppScreen" visible="false" />
|
||||
<AppInfoScreen id="AppInfoScreen" visible="false" />
|
||||
<NavBar id="NavBar" />
|
||||
<VideoContainer id="VideoContainer" />
|
||||
</children>
|
||||
</component>
|
||||
+4
-3
@@ -38,8 +38,8 @@ function onTextChanged()
|
||||
end function
|
||||
|
||||
function setIconSize()
|
||||
height = m.buttonBackground.height
|
||||
width = m.buttonBackground.width
|
||||
height = m.top.height
|
||||
width = m.top.width
|
||||
if height > 0 and width > 0
|
||||
' TODO: Use smallest number between them
|
||||
m.buttonIcon.height = m.top.height
|
||||
@@ -62,7 +62,8 @@ function onHeightChanged()
|
||||
end function
|
||||
|
||||
function onWidthChanged()
|
||||
m.buttonBackground.width = m.top.width
|
||||
m.buttonBackground.width = m.top.width - 10
|
||||
m.buttonBackground.translation = [5, 0]
|
||||
setIconSize()
|
||||
end function
|
||||
|
||||
File renamed without changes.
@@ -32,7 +32,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
||||
return true
|
||||
else if key = "right"
|
||||
' Can only escape to search screen or home screen
|
||||
allowedEscapes = { "0": true, "1": true }
|
||||
allowedEscapes = { "0": true, "1": true, "2": true }
|
||||
if allowedEscapes[StrI(m.top.focusIndex).Trim()] = true
|
||||
m.top.escapeIndex = m.top.focusIndex
|
||||
m.top.focusIndex = -1
|
||||
@@ -51,7 +51,7 @@ function OnExitDialog(event as object)
|
||||
buttonIndex = event.GetData()
|
||||
if buttonIndex = 0 ' Exit
|
||||
? "EXITING APP"
|
||||
m.top.GetScene().exitChannel = true
|
||||
m.top.getScene().exitChannel = true
|
||||
end if
|
||||
end function
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<interface>
|
||||
<field id="focusIndex" type="int" alwaysNotify="true" />
|
||||
<field id="escapeIndex" type="int" alwaysNotify="true" />
|
||||
</interface>
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
height="720"
|
||||
width="80"
|
||||
width="90"
|
||||
color="#242424"
|
||||
opacity="0.9">
|
||||
<ButtonGroup
|
||||
@@ -23,7 +23,7 @@
|
||||
icon="pkg:/images/icons/search.png"
|
||||
text="Search"
|
||||
height="50"
|
||||
width="80" />
|
||||
width="90" />
|
||||
<IconButton
|
||||
id="homeButton"
|
||||
background="#242424"
|
||||
@@ -32,7 +32,7 @@
|
||||
icon="pkg:/images/icons/home.png"
|
||||
text="Home"
|
||||
height="50"
|
||||
width="80" />
|
||||
width="90" />
|
||||
<IconButton
|
||||
id="settingsButton"
|
||||
background="#242424"
|
||||
@@ -41,7 +41,25 @@
|
||||
icon="pkg:/images/icons/settings.png"
|
||||
text="Settings"
|
||||
height="50"
|
||||
width="80" />
|
||||
width="90" />
|
||||
<IconButton
|
||||
id="webAppButton"
|
||||
background="#242424"
|
||||
focusBackground="#ff1c30"
|
||||
padding="20"
|
||||
icon="pkg:/images/icons/phone.png"
|
||||
text="Web app"
|
||||
height="50"
|
||||
width="90" />
|
||||
<IconButton
|
||||
id="appInfoButton"
|
||||
background="#242424"
|
||||
focusBackground="#ff1c30"
|
||||
padding="20"
|
||||
icon="pkg:/images/icons/info.png"
|
||||
text="Info"
|
||||
height="50"
|
||||
width="90" />
|
||||
</ButtonGroup>
|
||||
</Rectangle>
|
||||
</children>
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
import "pkg:/source/asyncTask/asyncTask.bs"
|
||||
import "pkg:/components/VideoPlayer/Video.bs"
|
||||
import "pkg:/components/SearchScreen/SearchHistory.bs"
|
||||
import "pkg:/source/services/SearchHistory.bs"
|
||||
import "pkg:/components/SearchScreen/SearchSuggestionsTask.bs"
|
||||
import "pkg:/components/SearchScreen/SearchTask.bs"
|
||||
|
||||
@@ -89,7 +89,7 @@ end function
|
||||
function OnSearchButtonSelected()
|
||||
selected = m.suggestions.buttonSelected
|
||||
text = m.suggestions.buttons[selected]
|
||||
SaveSearchHistory(text)
|
||||
SearchHistory.Save(text)
|
||||
Search(text)
|
||||
end function
|
||||
|
||||
@@ -130,6 +130,8 @@ end function
|
||||
function OnVisibilityChange()
|
||||
if m.top.visible = false
|
||||
ClearSearch()
|
||||
else
|
||||
OnTextChange()
|
||||
end if
|
||||
end function
|
||||
|
||||
File renamed without changes.
+2
-2
@@ -1,5 +1,5 @@
|
||||
import "pkg:/source/services/Invidious.bs"
|
||||
import "pkg:/components/SearchScreen/SearchHistory.bs"
|
||||
import "pkg:/source/services/SearchHistory.bs"
|
||||
|
||||
@asynctask
|
||||
function SearchSuggestionsTask(input as object) as object
|
||||
@@ -7,7 +7,7 @@ function SearchSuggestionsTask(input as object) as object
|
||||
|
||||
searchSuggestsions = q <> "" ? Invidious.SearchSuggestions(q) : invalid
|
||||
|
||||
history = GetSavedSearchHistory(q)
|
||||
history = SearchHistory.GetSaved(q)
|
||||
|
||||
if searchSuggestsions <> invalid
|
||||
history = MergeSearchSuggestions(history, searchSuggestsions.suggestions)
|
||||
File renamed without changes.
@@ -0,0 +1,42 @@
|
||||
function Init()
|
||||
m.radioButtonList = m.top.findNode("RadioButtonList")
|
||||
|
||||
m.top.observeField("value", "OnValueChanged")
|
||||
m.radioButtonList.observeField("checkedItem", "OnCheckedItemChanged")
|
||||
m.top.observeField("focusedChild", "OnFocusChanged")
|
||||
m.top.observeField("settings", "OnSettingsScreen")
|
||||
end function
|
||||
|
||||
function OnSettingsScreen()
|
||||
m.top.value = m.top.settings@.GetPreferenceValue(m.top.key)
|
||||
end function
|
||||
|
||||
function OnValueChanged()
|
||||
value = m.top.value
|
||||
if value = true
|
||||
m.radioButtonList.checkedItem = 0
|
||||
else if value = false
|
||||
m.radioButtonList.checkedItem = 1
|
||||
end if
|
||||
|
||||
m.top.settings@.SetPreferenceValue(m.top.key, value)
|
||||
end function
|
||||
|
||||
function OnCheckedItemChanged()
|
||||
checkedItem = m.radioButtonList.checkedItem
|
||||
if checkedItem = 0
|
||||
m.top.value = true
|
||||
else if checkedItem = 1
|
||||
m.top.value = false
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnFocusChanged()
|
||||
if m.top.hasFocus()
|
||||
m.radioButtonList.setFocus(true)
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
return m.top.settings@.OnkeyEvent(key, press)
|
||||
end function
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="BooleanControl" extends="Group">
|
||||
<interface>
|
||||
<field id="key" type="string" />
|
||||
<field id="level" type="int" />
|
||||
<field id="value" type="bool" alwaysNotify="true" />
|
||||
<field id="settings" type="node" />
|
||||
</interface>
|
||||
<children>
|
||||
<RadioButtonList id="RadioButtonList">
|
||||
<ContentNode role="content">
|
||||
<ContentNode title="Yes" />
|
||||
<ContentNode title="No" />
|
||||
</ContentNode>
|
||||
</RadioButtonList>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,38 @@
|
||||
import "pkg:/source/services/SearchHistory.bs"
|
||||
|
||||
function Init()
|
||||
m.button = m.top.findNode("clearButton")
|
||||
m.button.observeField("buttonSelected", "OnButtonSelected")
|
||||
m.top.observeField("focusedChild", "OnFocusChanged")
|
||||
end function
|
||||
|
||||
function OnFocusChanged()
|
||||
focused = m.top.hasFocus()
|
||||
if focused
|
||||
m.button.SetFocus(true)
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnButtonSelected()
|
||||
SearchHistory.Clear()
|
||||
SearchClearedDialog()
|
||||
end function
|
||||
|
||||
function SearchClearedDialog()
|
||||
dialog = CreateObject("roSGNode", "StandardMessageDialog")
|
||||
dialog.title = "Success"
|
||||
dialog.message = ["Search history cleared."]
|
||||
dialog.buttons = ["OK"]
|
||||
|
||||
dialog.observeField("buttonSelected", "OnDialogButtonSelected")
|
||||
|
||||
m.top.getScene().dialog = dialog
|
||||
end function
|
||||
|
||||
function OnDialogButtonSelected()
|
||||
m.top.getScene().dialog.close = true
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
return m.top.settings@.OnkeyEvent(key, press)
|
||||
end function
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="ClearSearchHistoryControl" extends="Group">
|
||||
<interface>
|
||||
<field id="key" type="string" />
|
||||
<field id="level" type="int" />
|
||||
<field id="value" type="bool" alwaysNotify="true" />
|
||||
<field id="settings" type="node" />
|
||||
</interface>
|
||||
<children>
|
||||
<Button id="clearButton" text="Clear Search History">
|
||||
</Button>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,63 @@
|
||||
function Init()
|
||||
m.radioButtonList = m.top.findNode("RadioButtonList")
|
||||
m.radioButtonListContent = m.top.findNode("RadioButtonListContent")
|
||||
|
||||
m.top.observeField("value", "OnValueChanged")
|
||||
m.top.observeField("options", "OnOptionsChanged")
|
||||
m.radioButtonList.observeField("checkedItem", "OnCheckedItemChanged")
|
||||
m.top.observeField("focusedChild", "OnFocusChanged")
|
||||
m.top.observeField("settings", "OnSettingsScreen")
|
||||
end function
|
||||
|
||||
function OnSettingsScreen()
|
||||
m.top.value = m.top.settings@.GetPreferenceValue(m.top.key)
|
||||
end function
|
||||
|
||||
function OnValueChanged()
|
||||
value = m.top.value
|
||||
options = m.top.options
|
||||
|
||||
checkedItem = -1
|
||||
for i = 0 to options.Count() - 1
|
||||
option = options[i].value
|
||||
if value = option
|
||||
checkedItem = i
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
|
||||
m.radioButtonList.checkedItem = checkedItem
|
||||
|
||||
m.top.settings@.SetPreferenceValue(m.top.key, value)
|
||||
end function
|
||||
|
||||
function OnCheckedItemChanged()
|
||||
checkedItem = m.radioButtonList.checkedItem
|
||||
options = m.top.options
|
||||
|
||||
if checkedItem >= 0 and checkedItem < options.Count()
|
||||
m.top.value = options[checkedItem].value
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnFocusChanged()
|
||||
if m.top.hasFocus()
|
||||
m.radioButtonList.setFocus(true)
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
return m.top.settings@.OnkeyEvent(key, press)
|
||||
end function
|
||||
|
||||
function OnOptionsChanged()
|
||||
options = m.top.options
|
||||
|
||||
m.radioButtonListContent.removeChildrenIndex(m.radioButtonListContent.getChildCount(), 0)
|
||||
for i = 0 to options.Count() - 1
|
||||
option = options[i].displayText
|
||||
node = CreateObject("roSGNode", "ContentNode")
|
||||
node.title = option
|
||||
m.radioButtonListContent.appendChild(node)
|
||||
end for
|
||||
end function
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="RadioControl" extends="Group">
|
||||
<interface>
|
||||
<field id="key" type="string" />
|
||||
<field id="level" type="int" />
|
||||
<field id="value" type="string" alwaysNotify="true" />
|
||||
<field id="options" type="array" alwaysNotify="true" />
|
||||
<field id="settings" type="node" />
|
||||
</interface>
|
||||
<children>
|
||||
<RadioButtonList id="RadioButtonList">
|
||||
<ContentNode id="RadioButtonListContent" role="content">
|
||||
</ContentNode>
|
||||
</RadioButtonList>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,14 @@
|
||||
' TODO: this is being called from many places, including possibly background threads
|
||||
' It should be made better than this
|
||||
function FindAndGetPreferenceValues(keys as object) as object
|
||||
values = {}
|
||||
settings = m.top.getScene().findNode("SettingsScreen")
|
||||
if settings = invalid
|
||||
return values
|
||||
end if
|
||||
|
||||
for each key in keys
|
||||
values[key] = settings@.GetPreferenceValue(key)
|
||||
end for
|
||||
return values
|
||||
end function
|
||||
@@ -0,0 +1,356 @@
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/asyncTask/asyncTask.bs"
|
||||
import "pkg:/source/services/PreferencesService.bs"
|
||||
import "pkg:/components/VideoPlayer/Video.bs"
|
||||
|
||||
function Init()
|
||||
m.service = new PreferencesService()
|
||||
|
||||
m.menu = m.top.findNode("PreferencesMenu")
|
||||
m.hint = m.top.findNode("HintLabel")
|
||||
|
||||
LoadPreferencesTopLevel(m.service.prefs_model)
|
||||
RefreshUI(0)
|
||||
|
||||
m.top.ObserveField("focus", "OnFocusChange")
|
||||
m.top.ObserveField("visible", "OnVisibilityChange")
|
||||
end function
|
||||
|
||||
function LoadPreferencesTopLevel(model as object)
|
||||
m.uiElements = {}
|
||||
LoadPreferencesAtLevel(model, 0, "")
|
||||
end function
|
||||
|
||||
function LoadPreferencesAtLevel(model as object, level as integer, key as string)
|
||||
if m.menu.getChildCount() - 1 < level
|
||||
container = m.menu.createChild("Group")
|
||||
container.id = `Container${level}`
|
||||
else
|
||||
container = m.menu.getChild(level)
|
||||
end if
|
||||
|
||||
buttonGroup = CreateSubmenu(container, model, level, key)
|
||||
|
||||
buttons = []
|
||||
for each item in model
|
||||
if item.visibility = "web"
|
||||
continue for
|
||||
end if
|
||||
buttons.push(item.displayText)
|
||||
if item.children <> invalid
|
||||
LoadPreferencesAtLevel(item.children, level + 1, item.key)
|
||||
else if item.type <> invalid
|
||||
CreateControl(item, level + 1, item.key)
|
||||
else if item.rokuComponent <> invalid
|
||||
CreateRokuComponent(item, level + 1, item.key)
|
||||
end if
|
||||
end for
|
||||
|
||||
buttonGroup.buttons = buttons
|
||||
buttonGroup.observeField("buttonFocused", "OnButtonFocused")
|
||||
end function
|
||||
|
||||
function CreateSubmenu(container as object, model as object, level as integer, key as string) as object
|
||||
buttonGroup = container.createChild("ButtonGroup")
|
||||
buttonGroup.minWidth = 300
|
||||
buttonGroup.iconUri = ""
|
||||
buttonGroup.id = `Control${level}`
|
||||
buttonGroup.visible = false
|
||||
|
||||
m.uiElements[key] = buttonGroup
|
||||
buttonGroup.addFields({
|
||||
"level": level,
|
||||
"key": key
|
||||
})
|
||||
return buttonGroup
|
||||
end function
|
||||
|
||||
function CreateControl(model as object, level as integer, key as string) as object
|
||||
menu = m.top.findNode("PreferencesMenu")
|
||||
if menu.getChildCount() - 1 < level
|
||||
container = menu.createChild("Group")
|
||||
container.id = `Container${level}`
|
||||
else
|
||||
container = menu.getChild(level)
|
||||
end if
|
||||
|
||||
if model.type = "string"
|
||||
return CreateStringControl(container, model, level, key)
|
||||
else if model.type = "boolean"
|
||||
return CreateBooleanControl(container, model, level, key)
|
||||
else if model.type = "radio"
|
||||
return CreateRadioControl(container, model, level, key)
|
||||
end if
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function CreateBooleanControl(container as object, model as object, level as integer, key as string) as object
|
||||
control = container.createChild("BooleanControl")
|
||||
control.id = `Control${level}`
|
||||
control.visible = false
|
||||
control.key = key
|
||||
control.level = level
|
||||
m.uiElements[key] = control
|
||||
control.settings = m.top
|
||||
return control
|
||||
end function
|
||||
|
||||
function CreateStringControl(container as object, model as object, level as integer, key as string) as object
|
||||
control = container.createChild("StringControl")
|
||||
control.id = `Control${level}`
|
||||
control.visible = false
|
||||
control.key = key
|
||||
control.level = level
|
||||
control.displayText = model.displayText
|
||||
control.description = model.description
|
||||
control.settings = m.top
|
||||
m.uiElements[key] = control
|
||||
return control
|
||||
end function
|
||||
|
||||
function CreateRadioControl(container as object, model as object, level as integer, key as string) as object
|
||||
control = container.createChild("RadioControl")
|
||||
control.id = `Control${level}`
|
||||
control.visible = false
|
||||
control.key = key
|
||||
control.level = level
|
||||
control.options = model.options
|
||||
control.settings = m.top
|
||||
m.uiElements[key] = control
|
||||
return control
|
||||
end function
|
||||
|
||||
function CreateRokuComponent(model as object, level as integer, key as string) as object
|
||||
menu = m.top.findNode("PreferencesMenu")
|
||||
if menu.getChildCount() - 1 < level
|
||||
container = menu.createChild("Group")
|
||||
container.id = `Container${level}`
|
||||
else
|
||||
container = menu.getChild(level)
|
||||
end if
|
||||
|
||||
component = container.createChild(model.rokuComponent)
|
||||
component.id = `Control${level}`
|
||||
component.settings = m.top
|
||||
component.visible = false
|
||||
component.key = key
|
||||
component.level = level
|
||||
|
||||
m.uiElements[key] = component
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function OnButtonFocused(event as object)
|
||||
buttonGroup = event.getRoSGNode()
|
||||
RefreshUI(buttonGroup.level + 1)
|
||||
end function
|
||||
|
||||
function RefreshUI(maxLevel = 0 as integer)
|
||||
for each key in m.uiElements
|
||||
m.uiElements[key].visible = false
|
||||
end for
|
||||
|
||||
topLevel = m.top.findNode("Control0")
|
||||
topLevel.visible = true
|
||||
|
||||
ShowButtonGroup(m.service.prefs_model, topLevel.buttonFocused, maxLevel)
|
||||
RefreshHint()
|
||||
end function
|
||||
|
||||
function ShowButtonGroup(model as object, index as integer, maxLevel as integer) as void
|
||||
item = model[index]
|
||||
element = m.uiElements[item.key]
|
||||
if element = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
if element.level > maxLevel
|
||||
return
|
||||
end if
|
||||
|
||||
element.visible = true
|
||||
|
||||
if item.children <> invalid
|
||||
ShowButtonGroup(item.children, element.buttonFocused, maxLevel)
|
||||
end if
|
||||
end function
|
||||
|
||||
function RefreshHint() as void
|
||||
focusedButtonGroup = GetFocusedControl()
|
||||
if focusedButtonGroup = invalid
|
||||
return
|
||||
end if
|
||||
selectedIndex = focusedButtonGroup.buttonFocused
|
||||
if selectedIndex = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
children = FindModelChildrenByKey(focusedButtonGroup.key, m.service.prefs_model)
|
||||
if children = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
if children.Count() <= selectedIndex
|
||||
return
|
||||
end if
|
||||
|
||||
displayText = children[selectedIndex].displayText
|
||||
description = children[selectedIndex].description
|
||||
if description = invalid or description = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.hint.text = `${displayText}: ${description}`
|
||||
end function
|
||||
|
||||
function FindModelChildrenByKey(key as string, model as object) as object
|
||||
if key = ""
|
||||
return m.service.prefs_model
|
||||
end if
|
||||
|
||||
for each item in model
|
||||
if item.key = key
|
||||
return item.children
|
||||
end if
|
||||
if item.children <> invalid
|
||||
result = FindModelChildrenByKey(key, item.children)
|
||||
if result <> invalid
|
||||
return result
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if m.top.focus <> true
|
||||
return
|
||||
end if
|
||||
|
||||
topLevelButtonGroup = m.top.findNode("Control0")
|
||||
if topLevelButtonGroup <> invalid
|
||||
topLevelButtonGroup.setFocus(true)
|
||||
RefreshUI(1)
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnVisibilityChange() as void
|
||||
if m.top.visible <> true
|
||||
return
|
||||
end if
|
||||
|
||||
topLevelButtonGroup = m.top.findNode("Control0")
|
||||
if topLevelButtonGroup <> invalid
|
||||
topLevelButtonGroup.visible = true
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
if press = false
|
||||
return false
|
||||
end if
|
||||
if key = "options"
|
||||
if ToggleVideoPictureInPicture(m.top)
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
if key = "back"
|
||||
m.top.escape = key
|
||||
return true
|
||||
end if
|
||||
if key = "left"
|
||||
if not MenuGoLeft()
|
||||
RefreshUI(0)
|
||||
m.top.escape = key
|
||||
end if
|
||||
return true
|
||||
end if
|
||||
if key = "right"
|
||||
if MenuGoRight()
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
return false
|
||||
end function
|
||||
|
||||
function GetFocusedControl() as object
|
||||
focusedChild = m.top.focusedChild
|
||||
if focusedChild = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
while not focusedChild.id.StartsWith("Control")
|
||||
focusedChild = focusedChild.focusedChild
|
||||
if focusedChild = invalid
|
||||
return invalid
|
||||
end if
|
||||
end while
|
||||
return focusedChild
|
||||
end function
|
||||
|
||||
function MenuGoLeft() as boolean
|
||||
return MenuNavigate(-1)
|
||||
end function
|
||||
|
||||
function MenuGoRight() as boolean
|
||||
return MenuNavigate(1)
|
||||
end function
|
||||
|
||||
function MenuNavigate(direction as integer) as boolean
|
||||
focusedControl = GetFocusedControl()
|
||||
container = focusedControl.getParent()
|
||||
containerParent = container.getParent()
|
||||
containerCount = containerParent.getChildCount()
|
||||
index = GetChildIndex(containerParent, container)
|
||||
|
||||
index += direction
|
||||
|
||||
if index >= containerCount or index < 0
|
||||
return false
|
||||
end if
|
||||
|
||||
newFocusedContainer = containerParent.getChild(index)
|
||||
childCount = newFocusedContainer.getChildCount()
|
||||
for i = 0 to childCount - 1
|
||||
child = newFocusedContainer.getChild(i)
|
||||
if child.visible
|
||||
child.setFocus(true)
|
||||
RefreshUI(index + 1)
|
||||
return true
|
||||
end if
|
||||
end for
|
||||
|
||||
return false
|
||||
end function
|
||||
|
||||
function GetChildIndex(node as object, child as object) as integer
|
||||
childCount = node.getChildCount()
|
||||
for i = 0 to childCount - 1
|
||||
c = node.getChild(i)
|
||||
if child.id = c.id
|
||||
return i
|
||||
end if
|
||||
end for
|
||||
return -1
|
||||
end function
|
||||
|
||||
function GetPreferenceValue(key as string) as dynamic
|
||||
return m.service.GetValue(key)
|
||||
end function
|
||||
|
||||
function SetPreferenceValue(key as string, value as dynamic)
|
||||
m.service.SetValue(key, value)
|
||||
end function
|
||||
|
||||
function GetUserPreferences(unused as object) as object
|
||||
return m.service.GetUserPreferences()
|
||||
end function
|
||||
|
||||
function ApplyUserPreferences(preferences as object) as void
|
||||
m.service.ApplyUserPreferences(preferences)
|
||||
end function
|
||||
|
||||
function ClearUserPreferences(unused as object) as void
|
||||
m.service.ClearUserPreferences()
|
||||
end function
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="SettingsScreen" extends="Group">
|
||||
<interface>
|
||||
<field id="escape" type="string" alwaysNotify="true" />
|
||||
<field id="focus" type="boolean" alwaysNotify="true" />
|
||||
<function name="OnkeyEvent" />
|
||||
<function name="MenuNavigate" />
|
||||
<function name="GetPreferenceValue" />
|
||||
<function name="SetPreferenceValue" />
|
||||
<function name="GetUserPreferences" />
|
||||
<function name="ApplyUserPreferences" />
|
||||
<function name="ClearUserPreferences" />
|
||||
</interface>
|
||||
<children>
|
||||
<LayoutGroup
|
||||
id="PreferencesMenu"
|
||||
layoutDirection="horiz"
|
||||
translation="[130,100]"
|
||||
itemSpacings="[20]"
|
||||
>
|
||||
</LayoutGroup>
|
||||
<Label
|
||||
id="HintLabel"
|
||||
height='100'
|
||||
width='1020'
|
||||
wrap='true'
|
||||
font='font:SmallestBoldSystemFont'
|
||||
translation="[130,600]"
|
||||
/>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,59 @@
|
||||
function Init()
|
||||
m.textEditBox = m.top.findNode("TextEditBox")
|
||||
m.top.observeField("focusedChild", "OnFocusChanged")
|
||||
m.top.observeField("value", "OnValueChanged")
|
||||
m.top.observeField("settings", "OnSettingsScreen")
|
||||
m.keyboardWasClosedByButton = false
|
||||
end function
|
||||
|
||||
function OnSettingsScreen()
|
||||
m.top.value = m.top.settings@.GetPreferenceValue(m.top.key)
|
||||
end function
|
||||
|
||||
function OnFocusChanged()
|
||||
focused = m.top.hasFocus()
|
||||
if focused
|
||||
ShowEditKeyboard()
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnValueChanged()
|
||||
value = m.top.value
|
||||
m.top.editText = value
|
||||
m.top.settings@.SetPreferenceValue(m.top.key, value)
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
return m.top.settings@.OnkeyEvent(key, press)
|
||||
end function
|
||||
|
||||
function ShowEditKeyboard()
|
||||
keyboardDialog = createObject("roSGNode", "StandardKeyboardDialog")
|
||||
keyboardDialog.title = m.top.displayText
|
||||
keyboardDialog.message = [m.top.description]
|
||||
keyboardDialog.text = m.top.value
|
||||
keyboardDialog.buttons = ["OK", "Cancel"]
|
||||
keyboardDialog.observeField("wasClosed", "OnKeyboardClosed")
|
||||
keyboardDialog.observeField("buttonSelected", "OnButtonSelected")
|
||||
|
||||
m.top.getScene().dialog = keyboardDialog
|
||||
end function
|
||||
|
||||
function OnButtonSelected(event as object)
|
||||
keyboard = event.getRoSGNode()
|
||||
buttonSelected = keyboard.buttonSelected
|
||||
if buttonSelected = 0
|
||||
m.top.value = keyboard.text
|
||||
end if
|
||||
m.keyboardWasClosedByButton = true
|
||||
keyboard.close = true
|
||||
end function
|
||||
|
||||
function OnKeyboardClosed() as void
|
||||
' The keyboard was closed by something else (like cast from web app)
|
||||
' In this case, we do nothing, since the focus might be moved to the video player
|
||||
if not m.keyboardWasClosedByButton
|
||||
return
|
||||
end if
|
||||
m.top.settings@.MenuNavigate(-1)
|
||||
end function
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="StringControl" extends="Group">
|
||||
<interface>
|
||||
<field id="key" type="string" />
|
||||
<field id="level" type="int" />
|
||||
<field id="editText" type="string" alias="TextEditBox.text" />
|
||||
<field id="value" type="string" />
|
||||
<field id="displayText" type="string" />
|
||||
<field id="description" type="string" />
|
||||
<field id="settings" type="node" />
|
||||
</interface>
|
||||
<children>
|
||||
<TextEditBox id="TextEditBox" clearOnDownKey="false">
|
||||
</TextEditBox>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,58 @@
|
||||
import "pkg:/source/services/SponsorBlock.bs"
|
||||
|
||||
function Init()
|
||||
m.categoryLabel = m.top.findNode("categoryLabel")
|
||||
m.translationAnimation = m.top.findNode("translationAnimation")
|
||||
m.translationAnimationInterpolator = m.top.findNode("translationAnimationInterpolator")
|
||||
m.animationTimer = m.top.findNode("animationTimer")
|
||||
|
||||
m.top.translation = [1280, 20]
|
||||
m.translationAnimation.observeField("state", "OnAnimationState")
|
||||
m.animationTimer.observeField("fire", "OnAnimationTimer")
|
||||
end function
|
||||
|
||||
function OnActionSet()
|
||||
action = m.top.action
|
||||
category = m.top.segment.category
|
||||
categoryTitle = SponsorBlock.SegmentShortTitle(category)
|
||||
if action = "AutoSkip"
|
||||
m.categoryLabel.text = "Skipped" + chr(10) + categoryTitle
|
||||
else
|
||||
m.categoryLabel.text = categoryTitle
|
||||
end if
|
||||
|
||||
AnimateIn()
|
||||
end function
|
||||
|
||||
function OnAnimationTimer()
|
||||
AnimateOut()
|
||||
end function
|
||||
|
||||
function AnimateIn()
|
||||
m.translationAnimation.unobserveField("state")
|
||||
m.animationTimer.control = "stop"
|
||||
m.animationTimer.control = "start"
|
||||
m.translationAnimation.observeField("state", "OnAnimationState")
|
||||
|
||||
Animate(false)
|
||||
end function
|
||||
|
||||
function AnimateOut()
|
||||
Animate(true)
|
||||
end function
|
||||
|
||||
function Animate(reverse as boolean) as void
|
||||
' We are already animating in the requested direction
|
||||
if m.translationAnimationInterpolator.reverse = reverse and m.translationAnimation.control <> "none"
|
||||
return
|
||||
end if
|
||||
|
||||
m.translationAnimationInterpolator.reverse = reverse
|
||||
m.translationAnimation.control = "start"
|
||||
end function
|
||||
|
||||
function OnAnimationState()
|
||||
if m.translationAnimation.state = "stopped" and m.translationAnimationInterpolator.reverse = true
|
||||
m.top.getParent().removeChild(m.top)
|
||||
end if
|
||||
end function
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="SponsorBlockNotification" extends="Group">
|
||||
<interface>
|
||||
<field id="segment" type="assocarray" onChange="OnSegmentSet" />
|
||||
<field id="action" type="string" onChange="OnActionSet" alwaysNotify="true"/>
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
width="250"
|
||||
height="70"
|
||||
color="#414141"
|
||||
opacity="0.8">
|
||||
<Poster
|
||||
uri="libpkg:/images/LogoSponsorBlockSimple256px.png"
|
||||
width="50"
|
||||
height="50"
|
||||
translation="[10,10]">
|
||||
</Poster>
|
||||
<Label
|
||||
id="categoryLabel"
|
||||
text="..."
|
||||
font="font:SmallestBoldSystemFont"
|
||||
lineSpacing="5"
|
||||
horizAlign="center"
|
||||
vertAlign="center"
|
||||
wrap="true"
|
||||
width="170"
|
||||
height="70"
|
||||
translation="[70,0]">
|
||||
</Label>
|
||||
</Rectangle>
|
||||
<Animation
|
||||
id="translationAnimation"
|
||||
duration="0.3"
|
||||
optional="true">
|
||||
<Vector2DFieldInterpolator
|
||||
id="translationAnimationInterpolator"
|
||||
key="[0.0, 0.5, 1.0]"
|
||||
keyValue="[ [1280.0, 20.0], [1140.0, 20.0], [1000.0, 20.0] ]"
|
||||
fieldToInterp="SponsorBlockNotification.translation" />
|
||||
</Animation>
|
||||
<Timer
|
||||
id="animationTimer"
|
||||
duration="3"
|
||||
/>
|
||||
</children>
|
||||
</component>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
import "pkg:/components/VideoPlayer/Video.bs"
|
||||
|
||||
function ShowSponsorBlockNotifcation(segment as object, action as dynamic) as void
|
||||
videoContainer = GetVideoContainer()
|
||||
notification = videoContainer.findNode("sponsorBlockNotification")
|
||||
if notification = invalid
|
||||
notification = videoContainer.createChild("SponsorBlockNotification")
|
||||
notification.id = "sponsorBlockNotification"
|
||||
end if
|
||||
notification.segment = segment
|
||||
notification.action = action
|
||||
end function
|
||||
|
||||
function RemoveSponsorBlockNotifcation()
|
||||
videoContainer = GetVideoContainer()
|
||||
notification = videoContainer.findNode("sponsorBlockNotification")
|
||||
if notification <> invalid
|
||||
videoContainer.RemoveChild(notification)
|
||||
end if
|
||||
end function
|
||||
|
||||
function SponsorBlockNotifcationSetVisible(visible as boolean)
|
||||
videoContainer = GetVideoContainer()
|
||||
notification = videoContainer.findNode("sponsorBlockNotification")
|
||||
if notification <> invalid
|
||||
notification.visible = visible
|
||||
end if
|
||||
end function
|
||||
@@ -0,0 +1,11 @@
|
||||
import "pkg:/source/services/Invidious.bs"
|
||||
|
||||
@asynctask
|
||||
function MarkVideoWatchedTask(input as object) as object
|
||||
videoId = input.videoId
|
||||
|
||||
success = Invidious.MarkVideoWatched(videoId)
|
||||
return {
|
||||
success: success
|
||||
}
|
||||
end function
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,14 +1,22 @@
|
||||
import "pkg:/source/asyncTask/asyncTask.bs"
|
||||
import "pkg:/source/services/Invidious.bs"
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/SponsorBlockNotification/SponsorBlockNotificationManager.bs"
|
||||
import "pkg:/components/VideoPlayer/MarkVideoWatchedTask.bs"
|
||||
|
||||
function PlayVideo(videoId as string, args = invalid as object)
|
||||
sender = args?.sender
|
||||
metadata = args?.metadata
|
||||
timestamp = args?.timestamp
|
||||
|
||||
if metadata <> invalid and GetInterface(metadata, "ifSGNodeField") <> invalid
|
||||
metadata = args.metadata.getFields()
|
||||
end if
|
||||
|
||||
if timestamp = invalid
|
||||
timestamp = 0
|
||||
end if
|
||||
|
||||
width = 1280
|
||||
height = 720
|
||||
translation = [0.0, 0.0]
|
||||
@@ -18,13 +26,18 @@ function PlayVideo(videoId as string, args = invalid as object)
|
||||
height = videoContainer.videoPlayer.height
|
||||
translation = videoContainer.videoPlayer.translation
|
||||
end if
|
||||
previousSender = videoContainer.sender
|
||||
CloseVideo(false)
|
||||
if sender <> invalid
|
||||
videoContainer.sender = sender
|
||||
else
|
||||
videoContainer.sender = previousSender
|
||||
end if
|
||||
videoContainer.videoPlayer = videoContainer.createChild("VideoPlayer")
|
||||
videoContainer.insertChild(videoContainer.videoPlayer, 0)
|
||||
videoContainer.videoPlayer.id = "VideoPlayer"
|
||||
videoContainer.videoPlayer.metadata = metadata
|
||||
videoContainer.videoPlayer.timestamp = timestamp
|
||||
videoContainer.videoPlayer.videoId = videoId
|
||||
videoContainer.videoPlayer.width = width
|
||||
videoContainer.videoPlayer.height = height
|
||||
@@ -33,6 +46,8 @@ function PlayVideo(videoId as string, args = invalid as object)
|
||||
if videoContainer.fullscreen
|
||||
videoContainer.videoPlayer.SetFocus(true)
|
||||
end if
|
||||
|
||||
StartAsyncTask(MarkVideoWatchedTask, { videoId: videoId })
|
||||
end function
|
||||
|
||||
function CloseVideo(setFocus = true as boolean)
|
||||
@@ -49,6 +64,8 @@ function CloseVideo(setFocus = true as boolean)
|
||||
videoContainer.sender.SetFocus(true)
|
||||
end if
|
||||
end if
|
||||
videoContainer.sender = invalid
|
||||
SponsorBlockNotifcationSetVisible(false)
|
||||
end function
|
||||
|
||||
function ToggleVideoPictureInPicture(sender = invalid as object) as boolean
|
||||
@@ -0,0 +1,20 @@
|
||||
import "pkg:/source/utils/RingBuffer.bs"
|
||||
|
||||
function Init()
|
||||
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
|
||||
|
||||
' watchedVideosClear needs at least one arg https://github.com/rokucommunity/brighterscript/blob/master/docs/callfunc-operator.md#callfunc-evaluation-with-no-arguments
|
||||
function watchedVideosClear(unused as dynamic)
|
||||
m.watchedVideos = new RingBuffer(100)
|
||||
end function
|
||||
+3
@@ -5,5 +5,8 @@
|
||||
<field id="videoPlayer" type="node" />
|
||||
<field id="sender" type="node" />
|
||||
<field id="fullscreen" type="boolean" value="true" />
|
||||
<function name="watchedVideosContain" />
|
||||
<function name="watchedVideosAdd" />
|
||||
<function name="watchedVideosClear" />
|
||||
</interface>
|
||||
</component>
|
||||
File renamed without changes.
+100
-30
@@ -4,6 +4,8 @@ import "pkg:/components/VideoPlayer/Video.bs"
|
||||
import "pkg:/components/VideoPlayer/VideoDetailsTask.bs"
|
||||
|
||||
function Init()
|
||||
m.videoContainer = GetVideoContainer()
|
||||
|
||||
SetupSponsorBlock()
|
||||
SetupAnimation()
|
||||
SetupBusySpinner()
|
||||
@@ -12,7 +14,6 @@ function Init()
|
||||
m.top.bufferingBar.filledBarBlendColor = "0xFF0000FF"
|
||||
m.top.retrievingBar.filledBarBlendColor = "0xFF0000FF"
|
||||
|
||||
m.videoContainer = GetVideoContainer()
|
||||
m.top.enableUI = m.videoContainer.fullscreen
|
||||
m.videoContainer.observeFieldScoped("fullscreen", "OnFullScreenChange")
|
||||
|
||||
@@ -38,6 +39,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
end if
|
||||
end if
|
||||
if key = "back"
|
||||
m.videoContainer@.watchedVideosClear()
|
||||
CloseVideo()
|
||||
return true
|
||||
end if
|
||||
@@ -85,7 +87,7 @@ function OnVideoDetailsTaskResults(output as object) as void
|
||||
if videoId <> m.top.videoId
|
||||
return
|
||||
end if
|
||||
if not metadata.success
|
||||
if (not metadata.success) or (metadata.data = invalid)
|
||||
m.busySpinner.visible = false
|
||||
m.busySpinner.control = "stop"
|
||||
message = `Failed to load video information for ${videoId}`
|
||||
@@ -115,30 +117,20 @@ function OnVideoDetailsTaskResults(output as object) as void
|
||||
end if
|
||||
playletStreamUrls.push(hlsUrlLocal)
|
||||
else
|
||||
if metadata.dashUrl <> invalid
|
||||
|
||||
#if DASH_THUMBNAILS
|
||||
' Redirect to our server so we can inject thumbnails (storyboards) into the DASH manifest
|
||||
dashUrl = `http://${GetLocalIpAddress()}:8888/dash?v=${videoId}`
|
||||
#else
|
||||
dashUrl = metadata.dashUrl
|
||||
#end if
|
||||
playletStreamUrls.push(dashUrl)
|
||||
|
||||
if dashUrl.InStr("?") = -1
|
||||
dashUrlLocal = dashUrl + "?local=true"
|
||||
else
|
||||
dashUrlLocal = dashUrl + "&local=true"
|
||||
end if
|
||||
playletStreamUrls.push(dashUrlLocal)
|
||||
settings = FindAndGetPreferenceValues(["playback.preferred_quality", "invidious.proxy_videos"])
|
||||
if settings = invalid
|
||||
settings = {
|
||||
"playback.preferred_quality": "auto",
|
||||
"invidious.proxy_videos": "if_needed"
|
||||
}
|
||||
end if
|
||||
|
||||
if metadata.formatStreams.Count() > 0
|
||||
stream = metadata.formatStreams[metadata.formatStreams.Count() - 1]
|
||||
itag = stream.itag
|
||||
|
||||
playletStreamUrls.push(Invidious.GetVideoUrl(videoId, itag, false))
|
||||
playletStreamUrls.push(Invidious.GetVideoUrl(videoId, itag, true))
|
||||
if settings["playback.preferred_quality"] = "720p"
|
||||
AddStreamUrls(playletStreamUrls, metadata, settings)
|
||||
AddDashUrls(playletStreamUrls, metadata, settings)
|
||||
else
|
||||
AddDashUrls(playletStreamUrls, metadata, settings)
|
||||
AddStreamUrls(playletStreamUrls, metadata, settings)
|
||||
end if
|
||||
end if
|
||||
|
||||
@@ -156,6 +148,59 @@ function OnVideoDetailsTaskResults(output as object) as void
|
||||
m.busySpinner.control = "stop"
|
||||
m.top.content = contentNode
|
||||
m.top.control = "play"
|
||||
|
||||
m.videoContainer@.watchedVideosAdd(videoId)
|
||||
end function
|
||||
|
||||
function AddDashUrls(playletStreamUrls as object, metadata as object, settings as object) as void
|
||||
if metadata.dashUrl = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
#if DASH_THUMBNAILS
|
||||
' Redirect to our server so we can inject thumbnails (storyboards) into the DASH manifest
|
||||
dashUrl = `http://${GetLocalIpAddress()}:8888/dash?v=${videoId}`
|
||||
#else
|
||||
dashUrl = metadata.dashUrl
|
||||
#end if
|
||||
|
||||
if dashUrl.InStr("?") = -1
|
||||
dashUrlLocal = dashUrl + "?local=true"
|
||||
else
|
||||
dashUrlLocal = dashUrl + "&local=true"
|
||||
end if
|
||||
|
||||
proxyVideos = settings["invidious.proxy_videos"]
|
||||
if proxyVideos = "if_needed"
|
||||
playletStreamUrls.push(dashUrl)
|
||||
playletStreamUrls.push(dashUrlLocal)
|
||||
else if proxyVideos = "never"
|
||||
playletStreamUrls.push(dashUrl)
|
||||
else if proxyVideos = "always"
|
||||
playletStreamUrls.push(dashUrlLocal)
|
||||
else
|
||||
playletStreamUrls.push(dashUrl)
|
||||
playletStreamUrls.push(dashUrlLocal)
|
||||
end if
|
||||
end function
|
||||
|
||||
function AddStreamUrls(playletStreamUrls as object, metadata as object, settings as object) as void
|
||||
if metadata.formatStreams = invalid or metadata.formatStreams.Count() = 0
|
||||
return
|
||||
end if
|
||||
|
||||
proxyVideos = settings["invidious.proxy_videos"]
|
||||
if proxyVideos = "if_needed"
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(metadata.videoId, false))
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(metadata.videoId, true))
|
||||
else if proxyVideos = "never"
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(metadata.videoId, false))
|
||||
else if proxyVideos = "always"
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(metadata.videoId, true))
|
||||
else
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(metadata.videoId, false))
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(metadata.videoId, true))
|
||||
end if
|
||||
end function
|
||||
|
||||
function FindChildNodeOfType(node as object, nodeType as string) as object
|
||||
@@ -241,8 +286,11 @@ function OnVideoPlayerStateChange() as void
|
||||
|
||||
' If we successfully played the video, then any error that comes later is not due to a 403 (FORBIDDEN).
|
||||
' This is to reduce false positives, as we do not want retry another link if the first link is working fine.
|
||||
if state = "playing"
|
||||
if state = "playing" and not m.videoPlayingSuccess
|
||||
m.videoPlayingSuccess = true
|
||||
if m.top.timestamp <> 0
|
||||
m.top.seek = m.top.timestamp
|
||||
end if
|
||||
end if
|
||||
|
||||
if state = "error"
|
||||
@@ -277,11 +325,8 @@ function OnVideoPlayerStateChange() as void
|
||||
|
||||
if state = "finished"
|
||||
metadata = m.top.content?.metadata
|
||||
metadata = metadata?.recommendedVideos?.GetEntry(0)
|
||||
videoId = metadata?.videoId
|
||||
if videoId <> invalid
|
||||
PlayVideo(videoId, { metadata: metadata })
|
||||
else
|
||||
|
||||
if not PlayNextRecommendedVideo(metadata?.recommendedVideos)
|
||||
CloseVideo()
|
||||
end if
|
||||
end if
|
||||
@@ -297,6 +342,30 @@ function OnVideoPlayerStateChange() as void
|
||||
end if
|
||||
end function
|
||||
|
||||
function PlayNextRecommendedVideo(recommendedVideos as object) as boolean
|
||||
settings = FindAndGetPreferenceValues(["playback.autoplay"])
|
||||
if settings = invalid or settings["playback.autoplay"] <> true
|
||||
return false
|
||||
end if
|
||||
|
||||
if recommendedVideos = invalid or recommendedVideos.Count() = 0
|
||||
return false
|
||||
end if
|
||||
|
||||
for each metadata in recommendedVideos
|
||||
videoId = metadata?.videoId
|
||||
if videoId = invalid
|
||||
continue for
|
||||
end if
|
||||
if not m.videoContainer@.watchedVideosContain(videoId)
|
||||
PlayVideo(videoId, { metadata: metadata })
|
||||
return true
|
||||
end if
|
||||
end for
|
||||
|
||||
return false
|
||||
end function
|
||||
|
||||
function SetupAnimation()
|
||||
m.widthAnimation = m.top.findNode("widthAnimation")
|
||||
m.widthAnimationInterpolator = m.top.findNode("widthAnimationInterpolator")
|
||||
@@ -316,4 +385,5 @@ function OnFullScreenChange()
|
||||
m.translationAnimation.control = "start"
|
||||
|
||||
m.top.enableUI = m.videoContainer.fullscreen
|
||||
SponsorBlockNotifcationSetVisible(m.videoContainer.fullscreen)
|
||||
end function
|
||||
+1
@@ -7,6 +7,7 @@
|
||||
<field id="chapter" type="string" alias="chapterLabel.text" />
|
||||
<field id="videoId" type="string" />
|
||||
<field id="metadata" type="assocarray" />
|
||||
<field id="timestamp" type="integer" />
|
||||
</interface>
|
||||
<children>
|
||||
<Label
|
||||
@@ -0,0 +1,54 @@
|
||||
import "pkg:/components/VideoPlayer/VideoPlayerCaptionsTask.bs"
|
||||
|
||||
function SetCaptions(metadata as object, videoPlayer as object, contentNode as object) as void
|
||||
if metadata.captions.Count() = 0
|
||||
return
|
||||
end if
|
||||
isoLanguageList = ParseJson(ReadAsciiFile("libpkg:/config/ISO-639-1-to-ISO-639-2T.json"))
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
|
||||
subtitleTracks = []
|
||||
|
||||
for each caption in metadata.captions
|
||||
subtitleTracks.Push({
|
||||
Description: caption.label,
|
||||
Language: isoLanguageList[caption.language_code] ?? caption.language_code,
|
||||
TrackName: instance + caption.url
|
||||
})
|
||||
end for
|
||||
contentNode.ClosedCaptions = True
|
||||
contentNode.SubtitleTracks = subtitleTracks
|
||||
|
||||
' Captions are rate limited https://github.com/iv-org/invidious/issues/2567
|
||||
' We loop through a list of backup instances hoping to find working subtitles.
|
||||
' Searching for a working caption could cause a delay in the video player start.
|
||||
' This is why it is behind a feature flag.
|
||||
#if CAPTION_INSTANCE_SEARCH
|
||||
StartAsyncTask(VideoPlayerCaptionsTask, {
|
||||
videoId: metadata.videoId,
|
||||
instance: instance,
|
||||
subtitleTracks: subtitleTracks
|
||||
}, OnVideoPlayerCaptionsTaskResults)
|
||||
#end if
|
||||
end function
|
||||
|
||||
function OnVideoPlayerCaptionsTaskResults(output as object) as void
|
||||
changed = output.result.changed
|
||||
if not changed
|
||||
return
|
||||
end if
|
||||
|
||||
videoId = output.result.videoId
|
||||
if m.top.videoId <> videoId
|
||||
return
|
||||
end if
|
||||
|
||||
state = m.top.state
|
||||
contentNode = m.top.content
|
||||
contentNode.Update({
|
||||
SubtitleTracks: output.result.subtitleTracks
|
||||
})
|
||||
if state = "buffering" or state = "playing"
|
||||
m.top.control = "play"
|
||||
end if
|
||||
end function
|
||||
@@ -0,0 +1,62 @@
|
||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||
import "pkg:/source/services/InvidiousSettings.bs"
|
||||
|
||||
@asynctask
|
||||
function VideoPlayerCaptionsTask(input as object) as object
|
||||
originalInstance = input.instance
|
||||
subtitleTracks = input.subtitleTracks
|
||||
if subtitleTracks.Count() = 0
|
||||
return {
|
||||
changed: false
|
||||
}
|
||||
end if
|
||||
|
||||
track = subtitleTracks[0]
|
||||
url = track.TrackName
|
||||
|
||||
if IsValidSubtitleTrack(url)
|
||||
return {
|
||||
changed: false
|
||||
}
|
||||
end if
|
||||
|
||||
failedInstances = {}
|
||||
failedInstances[originalInstance] = true
|
||||
|
||||
instances = InvidiousSettings.GetBackupInstances()
|
||||
for each instance in instances
|
||||
if failedInstances[instance] = true
|
||||
continue for
|
||||
end if
|
||||
|
||||
instanceUrl = url.Replace(originalInstance, instance)
|
||||
if IsValidSubtitleTrack(instanceUrl)
|
||||
for i = 0 to subtitleTracks.Count() - 1
|
||||
subtitleTracks[i].TrackName = subtitleTracks[i].TrackName.Replace(originalInstance, instance)
|
||||
end for
|
||||
|
||||
return {
|
||||
changed: true,
|
||||
videoId: input.videoId,
|
||||
subtitleTracks: subtitleTracks
|
||||
}
|
||||
else
|
||||
failedInstances[instance] = true
|
||||
end if
|
||||
|
||||
end for
|
||||
|
||||
return {
|
||||
changed: false
|
||||
}
|
||||
end function
|
||||
|
||||
function IsValidSubtitleTrack(url as string) as boolean
|
||||
response = Requests().get(url, { parseJson: false })
|
||||
' A popular instance will return a valid format
|
||||
' WEBVTT
|
||||
' Kind: captions
|
||||
' Language: en
|
||||
' But won't include any caption items
|
||||
return response.ok and response.text.StartsWith("WEBVTT") and response.text.len() > 50
|
||||
end function
|
||||
+46
-26
@@ -1,9 +1,19 @@
|
||||
import "pkg:/source/asyncTask/asyncTask.bs"
|
||||
import "pkg:/components/VideoPlayer/SponsorBlockTask.bs"
|
||||
import "pkg:/components/VideoPlayer/SponsorBlockTrackingTask.bs"
|
||||
import "pkg:/components/SponsorBlockNotification/SponsorBlockNotificationManager.bs"
|
||||
import "pkg:/components/SettingsScreen/Settings.bs"
|
||||
|
||||
function SetupSponsorBlock() as void
|
||||
LoadSponsorBlockSettings()
|
||||
if not m.sponsorBlockEnabled = true
|
||||
return
|
||||
end if
|
||||
|
||||
function SetupSponsorBlock()
|
||||
PositionChapterLabel()
|
||||
|
||||
SponsorBlockNotifcationSetVisible(m.videoContainer.fullscreen)
|
||||
|
||||
m.timeLabel = FindTimeLabel()
|
||||
m.top.trickPlayBar.observeField("visible", "OnTrickPlayBarVisible")
|
||||
m.chapterLabelTimer = m.top.findNode("chapterLabelTimer")
|
||||
@@ -11,6 +21,18 @@ function SetupSponsorBlock()
|
||||
m.top.observeField("videoId", "StartSponsorBlockTask")
|
||||
end function
|
||||
|
||||
function LoadSponsorBlockSettings() as void
|
||||
settings = FindAndGetPreferenceValues(["sponsorblock.enabled", "sponsorblock.show_notifications"])
|
||||
if settings = invalid
|
||||
m.sponsorBlockEnabled = false
|
||||
m.sponsorBlockShowNotifications = false
|
||||
return
|
||||
end if
|
||||
|
||||
m.sponsorBlockEnabled = settings["sponsorblock.enabled"]
|
||||
m.sponsorBlockShowNotifications = settings["sponsorblock.show_notifications"]
|
||||
end function
|
||||
|
||||
function PositionChapterLabel()
|
||||
m.chapterLabel = m.top.findNode("chapterLabel")
|
||||
m.chapterLabel.reparent(m.top.trickPlayBar, false)
|
||||
@@ -105,46 +127,44 @@ function OnSponsorBlockTaskResults(output as object)
|
||||
end function
|
||||
|
||||
function OnPositionChangeSkipSponsorBlockSections() as void
|
||||
shouldMute = false
|
||||
muteCategory = ""
|
||||
segments = m.skipSegments
|
||||
if segments = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
for each segment in segments
|
||||
' TODO: handle other action types
|
||||
if segment["actionType"] = "skip"
|
||||
segmentRange = segment["segment"]
|
||||
segmentStart = segmentRange[0]
|
||||
segmentEnd = segmentRange[1]
|
||||
currentPosition = m.top.position
|
||||
if (segmentStart < currentPosition) and ((segmentEnd - 1) > currentPosition)
|
||||
' TODO: if segmentEnd is at the end of the video, close video
|
||||
segmentRange = segment["segment"]
|
||||
segmentStart = segmentRange[0]
|
||||
segmentEnd = segmentRange[1]
|
||||
currentPosition = m.top.position
|
||||
if (segmentStart < currentPosition) and ((segmentEnd - 1) > currentPosition)
|
||||
action = GetActionForSegment(segment)
|
||||
if m.sponsorBlockShowNotifications = true
|
||||
ShowSponsorBlockNotifcation(segment, action)
|
||||
end if
|
||||
|
||||
if action = "AutoSkip"
|
||||
m.top.seek = segmentEnd
|
||||
print("Skipping section:" + segment["category"])
|
||||
SendSkippedSectionEvent(segment.UUID)
|
||||
return
|
||||
end if
|
||||
end if
|
||||
|
||||
if segment["actionType"] = "mute"
|
||||
segmentRange = segment["segment"]
|
||||
segmentStart = segmentRange[0]
|
||||
segmentEnd = segmentRange[1]
|
||||
currentPosition = m.top.position
|
||||
if (segmentStart < currentPosition) and (segmentEnd > currentPosition)
|
||||
shouldMute = true
|
||||
muteCategory = segment["category"]
|
||||
exit for
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
|
||||
if m.top.mute <> shouldMute
|
||||
print(`Muting section: ${muteCategory} - ${shouldMute}`)
|
||||
m.top.mute = shouldMute
|
||||
function GetActionForSegment(segment as object) as dynamic
|
||||
category = segment["category"]
|
||||
if category = "sponsor"
|
||||
return "AutoSkip"
|
||||
else if category = "poi_highlight"
|
||||
return "ManualSkip"
|
||||
else if category = "exclusive_access"
|
||||
return "ShowOverlay"
|
||||
else if category = "chapter"
|
||||
return "ShowOverlay"
|
||||
end if
|
||||
return ""
|
||||
end function
|
||||
|
||||
function SendSkippedSectionEvent(segmentId as string)
|
||||
@@ -0,0 +1,116 @@
|
||||
import "pkg:/source/utils/TimeUtils.bs"
|
||||
|
||||
function OnContentSet() as void
|
||||
content = m.top.itemContent
|
||||
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.FindNode("titleLabel").text = content.title
|
||||
m.top.FindNode("authorLabel").text = content.author
|
||||
|
||||
if IsVideoUpcoming(content)
|
||||
m.top.FindNode("viewCountDateLabel").text = `Premeres in ${TimeUtils.GetFormattedTimeLeft(content.premiereTimestamp)}`
|
||||
else
|
||||
publishedText = validstr(content.publishedText)
|
||||
viewCount = FormatViewCount(content.viewCount)
|
||||
if publishedText = "" and viewCount = ""
|
||||
m.top.FindNode("viewCountDateLabel").text = ""
|
||||
else
|
||||
m.top.FindNode("viewCountDateLabel").text = `${publishedText} • ${viewCount}`
|
||||
end if
|
||||
end if
|
||||
|
||||
m.thumbnail = m.top.FindNode("thumbnail")
|
||||
m.thumbnail.observeField("loadStatus", "OnThumbnailLoadFailed")
|
||||
m.thumbnail.uri = GetThumbnailUrl(content.videoThumbnails)
|
||||
m.thumbnail.id = `thumbnail-${content.videoId}`
|
||||
|
||||
if IsVideoLive(content)
|
||||
m.top.FindNode("liveRect").visible = true
|
||||
m.top.FindNode("durationRect").visible = false
|
||||
else
|
||||
m.top.FindNode("liveRect").visible = false
|
||||
if content.lengthSeconds <> invalid and content.lengthSeconds <> 0
|
||||
SetDurationText(TimeUtils.GetFormattedTime(content.lengthSeconds))
|
||||
m.top.FindNode("durationRect").visible = true
|
||||
else
|
||||
m.top.FindNode("durationRect").visible = false
|
||||
end if
|
||||
end if
|
||||
|
||||
end function
|
||||
|
||||
function SetDurationText(text as string)
|
||||
label = m.top.FindNode("durationLabel")
|
||||
rect = m.top.FindNode("durationRect")
|
||||
rectParent = rect.getParent()
|
||||
|
||||
label.text = text
|
||||
size = label.localBoundingRect()
|
||||
|
||||
rect.width = size.width + 16
|
||||
rect.translation = [rectParent.width - rect.width, 162]
|
||||
end function
|
||||
|
||||
function OnThumbnailLoadFailed() as void
|
||||
if m.thumbnail.loadStatus <> "failed"
|
||||
return
|
||||
end if
|
||||
m.thumbnail.uri = "pkg:/images/thumbnail-missing.jpg"
|
||||
end function
|
||||
|
||||
function GetThumbnailUrl(videoThumbnails as object, quality = "medium" as string) as string
|
||||
if videoThumbnails.Count() = 0
|
||||
return ""
|
||||
end if
|
||||
for each thumbnail in videoThumbnails
|
||||
if thumbnail.quality = quality
|
||||
return thumbnail.url
|
||||
end if
|
||||
end for
|
||||
return videoThumbnails[0].url
|
||||
end function
|
||||
|
||||
function IsVideoUpcoming(metadata as object) as boolean
|
||||
return metadata.isUpcoming = true
|
||||
end function
|
||||
|
||||
function IsVideoLive(metadata as object) as boolean
|
||||
if metadata.liveNow = true
|
||||
return true
|
||||
end if
|
||||
' TODO: metadata.liveNow is returning false for live videos...
|
||||
return metadata.lengthSeconds = 0 and metadata.viewCount = 0
|
||||
end function
|
||||
|
||||
function FormatViewCount(viewCount as dynamic) as string
|
||||
if viewCount = invalid
|
||||
return ""
|
||||
end if
|
||||
if viewCount < 1000
|
||||
return `${FormatFloat(viewCount)} views`
|
||||
end if
|
||||
|
||||
viewCount = viewCount / 1000
|
||||
if viewCount < 1000
|
||||
return `${FormatFloat(viewCount)}K views`
|
||||
end if
|
||||
|
||||
viewCount = viewCount / 1000
|
||||
if viewCount < 1000
|
||||
return `${FormatFloat(viewCount)}M views`
|
||||
end if
|
||||
|
||||
viewCount = viewCount / 1000
|
||||
return `${FormatFloat(viewCount)}B views`
|
||||
end function
|
||||
|
||||
function FormatFloat(X as integer) as integer
|
||||
X = X * 10
|
||||
X = X + 0.5
|
||||
X = Fix(X)
|
||||
X = X / 10
|
||||
return X
|
||||
end function
|
||||
+3
-3
@@ -17,18 +17,18 @@
|
||||
<Rectangle
|
||||
id="durationRect"
|
||||
width="60"
|
||||
height="25"
|
||||
height="26"
|
||||
color="0x000000"
|
||||
opacity="0.8"
|
||||
translation="[290, 162]"
|
||||
>
|
||||
<Label
|
||||
width="60"
|
||||
height="25"
|
||||
height="26"
|
||||
id="durationLabel"
|
||||
horizAlign="center"
|
||||
vertAlign="center"
|
||||
font="font:SmallestSystemFont"
|
||||
translation="[8, 0]"
|
||||
/>
|
||||
</Rectangle>
|
||||
<Rectangle
|
||||
@@ -0,0 +1,21 @@
|
||||
import "pkg:/source/utils/General.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
function Init()
|
||||
ip = GetLocalIpAddress()
|
||||
if ip = invalid
|
||||
m.top.url = "(Could not get IP address: are we connected to the internet?)"
|
||||
else
|
||||
m.top.url = `http://${ip}:8888`
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnUrlSet()
|
||||
url = m.top.url
|
||||
|
||||
qrCode = m.top.findNode("SettingsQRPoster")
|
||||
qrCode.text = url
|
||||
|
||||
urlLabel = m.top.findNode("urlLabel")
|
||||
urlLabel.text = url
|
||||
end function
|
||||
+4
-4
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="SettingsScreen" extends="Group">
|
||||
<component name="WebAppScreen" extends="Group">
|
||||
<interface>
|
||||
<field id="url" type="string" onChange="OnUrlSet" />
|
||||
</interface>
|
||||
<children>
|
||||
<Label
|
||||
id='VersionLabel'
|
||||
height='50'
|
||||
height='60'
|
||||
width='1280'
|
||||
font='font:MediumBoldSystemFont'
|
||||
horizAlign="center"
|
||||
translation="[0,100]"
|
||||
translation="[0,92]"
|
||||
text="Scan the QR code with your phone camera, or open the URL in a web browser:"
|
||||
/>
|
||||
<QRPoster
|
||||
id='SettingsQRPoster'
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+7
-1
@@ -72,7 +72,7 @@ namespace Http
|
||||
m.source = Http.HttpResponseSource.GENERATED
|
||||
end function
|
||||
|
||||
function Redirect(where as string, code = 301 as integer)
|
||||
function Redirect(where as string, code = 302 as integer)
|
||||
m.headers["Location"] = where
|
||||
message = "Moved to: <a href=" + Quote() + where + Quote() + ">" + where + "</a>"
|
||||
m.Default(code, message)
|
||||
@@ -88,6 +88,12 @@ namespace Http
|
||||
m.source = Http.HttpResponseSource.GENERATED
|
||||
end function
|
||||
|
||||
function SetBodyDataBuffer(buffer as object)
|
||||
m.body_buffer = buffer
|
||||
m.body_buffer_length = m.body_buffer.count()
|
||||
m.ContentLength(m.body_buffer_length)
|
||||
end function
|
||||
|
||||
function SetBodyDataString(data as string)
|
||||
m.body_buffer.fromasciistring(data)
|
||||
m.body_buffer_length = m.body_buffer.count()
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+8
-4
@@ -23,12 +23,16 @@ namespace Http
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
else if payload.command = "play"
|
||||
videoId = payload.videoId
|
||||
server.task.top.command = `play:${videoId}`
|
||||
server.task.top.command = payload
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
else if payload.command = "clear-search-history"
|
||||
RegistryUtils.Delete("search_history")
|
||||
else if payload.command = "set-playlet-lib-urls"
|
||||
content = payload.content
|
||||
if content = invalid
|
||||
RegistryUtils.Delete(RegistryUtils.PLAYLET_LIB_URLS)
|
||||
else
|
||||
RegistryUtils.Write(RegistryUtils.PLAYLET_LIB_URLS, content)
|
||||
end if
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
end if
|
||||
+5
-1
@@ -2,12 +2,15 @@ namespace Http
|
||||
|
||||
class CorsMiddleware extends HttpRouter
|
||||
private origin
|
||||
private headers
|
||||
private methods
|
||||
|
||||
function new(origin = "*" as string, headers = "*" as string)
|
||||
function new(origin = "*" as string, headers = "*" as string, methods = "POST, PUT, GET, DELETE, OPTIONS" as string)
|
||||
super()
|
||||
|
||||
m.origin = origin
|
||||
m.headers = headers
|
||||
m.methods = methods
|
||||
|
||||
m.All("*", function(context as object) as boolean
|
||||
router = context.router
|
||||
@@ -15,6 +18,7 @@ namespace Http
|
||||
response = context.response
|
||||
response.headers["Access-Control-Allow-Origin"] = router.origin
|
||||
response.headers["Access-Control-Allow-Headers"] = router.headers
|
||||
response.headers["Access-Control-Allow-Methods"] = router.methods
|
||||
|
||||
if request.method = "OPTIONS"
|
||||
response.header_only = true
|
||||
+5
-8
@@ -17,22 +17,19 @@ namespace Http
|
||||
v = request.query.v
|
||||
local = request.query.local
|
||||
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
metadata = router.GetVideoMetadata(context, v)
|
||||
dashUrl = `${instance}/api/manifest/dash/id/${v}`
|
||||
dashUrl = Invidious.GetVideoDashUrl(v, local <> invalid)
|
||||
|
||||
if metadata = invalid and local = invalid
|
||||
response.Redirect(dashUrl, 302)
|
||||
response.Redirect(dashUrl)
|
||||
return true
|
||||
end if
|
||||
|
||||
if local <> invalid
|
||||
dashUrl = `${dashUrl}?local=${local}`
|
||||
end if
|
||||
|
||||
resp = Requests().get(dashUrl)
|
||||
resp = Requests().get(dashUrl, { parseJson: false })
|
||||
text = resp.text ?? ""
|
||||
if resp.statuscode = 200 and local = "true"
|
||||
' TODO: no longer needed, remove after 6 months of https://github.com/iv-org/invidious/pull/3554
|
||||
text = text.Replace("<BaseURL>/videoplayback", `<BaseURL>${instance}/videoplayback`)
|
||||
end if
|
||||
|
||||
File renamed without changes.
+18
-3
@@ -7,8 +7,9 @@ namespace Http
|
||||
private route
|
||||
private showDirectories
|
||||
private showHidden
|
||||
private fsCheck
|
||||
|
||||
function new(route as string, root as string, showDirectories = false as boolean, showHidden = false as boolean)
|
||||
function new(route as string, root as string, showDirectories = false as boolean, showHidden = false as boolean, fsCheck = true as boolean)
|
||||
super()
|
||||
m.log = new log.Logger("HttpStaticFilesRouter")
|
||||
|
||||
@@ -16,6 +17,7 @@ namespace Http
|
||||
m.route = route
|
||||
m.showDirectories = showDirectories
|
||||
m.showHidden = showHidden
|
||||
m.fsCheck = fsCheck
|
||||
|
||||
m.Get("*", function(context as object) as boolean
|
||||
router = context.router
|
||||
@@ -28,9 +30,22 @@ namespace Http
|
||||
|
||||
path_in_route = request.route.Mid(router.route.Len())
|
||||
|
||||
decoded_path = WebUtils.UrlUnescape(path_in_route)
|
||||
decoded_path = path_in_route.DecodeUri()
|
||||
full_path = PathJoin(router.root, decoded_path)
|
||||
|
||||
if not router.fsCheck
|
||||
' libpkg:/ does not work with roFilesystem...
|
||||
buffer = createObject("roByteArray")
|
||||
if buffer.ReadFile(full_path) and buffer.count() > 0
|
||||
mimetype = WebUtils.MimeType(decoded_path)
|
||||
response.SetBodyDataBuffer(buffer)
|
||||
response.ContentType(mimetype)
|
||||
response.http_code = 200
|
||||
response.source = Http.HttpResponseSource.GENERATED
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
path = CreateObject("roPath", full_path)
|
||||
fs = CreateObject("roFilesystem")
|
||||
|
||||
@@ -142,7 +157,7 @@ namespace Http
|
||||
listing = listing + "<title>" + response.settings.ServerName + "</title>" + UnixNL()
|
||||
listing = listing + "</head>" + UnixNL()
|
||||
listing = listing + "<body>" + UnixNL()
|
||||
listing = listing + "<h1>" + WebUtils.URLUnescape(request.uri) + "</h1>" + UnixNL()
|
||||
listing = listing + "<h1>" + request.uri.DecodeUri() + "</h1>" + UnixNL()
|
||||
listing = listing + "<tt><pre>" + UnixNL()
|
||||
|
||||
dir = path.getString()
|
||||
@@ -0,0 +1,82 @@
|
||||
import "pkg:/source/services/InvidiousSettings.bs"
|
||||
import "pkg:/source/services/InvidiousService.bs"
|
||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||
|
||||
namespace Http
|
||||
|
||||
class InvidiousRouter extends HttpRouter
|
||||
|
||||
function new()
|
||||
super()
|
||||
|
||||
m.Get(Invidious.TOKEN_CALLBACK, function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
server = context.server
|
||||
|
||||
if request.query["token"] <> invalid and request.query["ref"] <> invalid
|
||||
' Token is encoded twice for some reason
|
||||
token = request.query["token"].DecodeUri().DecodeUriComponent()
|
||||
referer = request.query["ref"].DecodeUri()
|
||||
username = request.query["username"]
|
||||
' TODO: remove null check after 6 months of https://github.com/iv-org/invidious/pull/3603
|
||||
if username <> invalid
|
||||
username = username.DecodeUriComponent().DecodeUriComponent()
|
||||
end if
|
||||
|
||||
InvidiousSettings.SetAuthToken(token, referer, username)
|
||||
server.task.top.login = true
|
||||
end if
|
||||
response.Redirect("/")
|
||||
return true
|
||||
end function)
|
||||
|
||||
' This is an endpoint allowing the web app to make an authenticated request
|
||||
' without needing the Invidious token
|
||||
m.Get("/invidious/authenticated-request", function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
requestData = request.query["request-data"]
|
||||
if requestData = invalid
|
||||
response.Default(400, "Expected request-data")
|
||||
return true
|
||||
end if
|
||||
|
||||
token = InvidiousSettings.GetAuthToken()
|
||||
if token = invalid
|
||||
response.Default(403, "No token, not logged in")
|
||||
return true
|
||||
end if
|
||||
|
||||
requestData = ParseJson(requestData)
|
||||
' Format object again because FormatJson formats in a specific way (sorts keys, etc.)
|
||||
' so we want an exact string for the md5 hash to match
|
||||
requestDataJson = FormatJson(requestData)
|
||||
cacheKey = GetMd5(requestDataJson)
|
||||
path = `tmp:/${cacheKey}.json`
|
||||
|
||||
fs = CreateObject("roFilesystem")
|
||||
if fs.exists(path)
|
||||
cacheData = ReadAsciiFile(path)
|
||||
response.SetBodyDataString(cacheData)
|
||||
response.ContentType("application/json")
|
||||
response.source = Http.HttpResponseSource.GENERATED
|
||||
return true
|
||||
end if
|
||||
|
||||
invService = new InvidiousService()
|
||||
result = invService.MakeRequest(requestData)
|
||||
if result = invalid
|
||||
response.Default(500, "Failed to make request")
|
||||
return true
|
||||
end if
|
||||
response.Json(result)
|
||||
return true
|
||||
end function)
|
||||
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -0,0 +1,70 @@
|
||||
namespace Http
|
||||
|
||||
class PreferencesRouter extends HttpRouter
|
||||
|
||||
function new()
|
||||
super()
|
||||
|
||||
' Get preferences
|
||||
m.Get("/api/preferences", function(context as object) as boolean
|
||||
response = context.response
|
||||
task = context.server.task
|
||||
scene = task.top.getScene()
|
||||
settings = scene.findNode("SettingsScreen")
|
||||
if settings = invalid
|
||||
response.Default(500, `Settings screen not found: scene.findNode("SettingsScreen") returned invalid`)
|
||||
return true
|
||||
end if
|
||||
|
||||
' Passing invalid because of call limitation
|
||||
preferences = settings@.GetUserPreferences(invalid)
|
||||
response.Json(preferences)
|
||||
return true
|
||||
end function)
|
||||
|
||||
' Update preferences
|
||||
m.Put("/api/preferences", function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
task = context.server.task
|
||||
|
||||
payload = request.Json()
|
||||
if payload = invalid
|
||||
response.Default(400, `Invalid JSON payload`)
|
||||
return true
|
||||
end if
|
||||
|
||||
scene = task.top.getScene()
|
||||
settings = scene.findNode("SettingsScreen")
|
||||
if settings = invalid
|
||||
response.Default(500, `Settings screen not found: scene.findNode("SettingsScreen") returned invalid`)
|
||||
return true
|
||||
end if
|
||||
|
||||
settings@.ApplyUserPreferences(payload)
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
end function)
|
||||
|
||||
' Reset default preferences
|
||||
m.Delete("/api/preferences", function(context as object) as boolean
|
||||
response = context.response
|
||||
task = context.server.task
|
||||
|
||||
scene = task.top.getScene()
|
||||
settings = scene.findNode("SettingsScreen")
|
||||
if settings = invalid
|
||||
response.Default(500, `Settings screen not found: scene.findNode("SettingsScreen") returned invalid`)
|
||||
return true
|
||||
end if
|
||||
|
||||
settings@.ClearUserPreferences(invalid)
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
end function)
|
||||
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
File renamed without changes.
@@ -0,0 +1,49 @@
|
||||
import "pkg:/source/services/SearchHistory.bs"
|
||||
|
||||
namespace Http
|
||||
|
||||
class SearchHistoryRouter extends HttpRouter
|
||||
|
||||
function new()
|
||||
super()
|
||||
|
||||
m.Get("/api/search-history", function(context as object) as boolean
|
||||
response = context.response
|
||||
response.Json(SearchHistory.GetAllSaved())
|
||||
return true
|
||||
end function)
|
||||
|
||||
m.Put("/api/search-history", function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
payload = request.Json()
|
||||
if payload = invalid
|
||||
response.Default(400, `Invalid JSON payload`)
|
||||
return true
|
||||
end if
|
||||
|
||||
query = payload.query
|
||||
if query = invalid
|
||||
response.Default(400, `missing "query" property in JSON payload`)
|
||||
return true
|
||||
end if
|
||||
|
||||
SearchHistory.Save(query)
|
||||
response.Json(SearchHistory.GetAllSaved())
|
||||
return true
|
||||
end function)
|
||||
|
||||
m.Delete("/api/search-history", function(context as object) as boolean
|
||||
response = context.response
|
||||
|
||||
SearchHistory.Clear()
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
end function)
|
||||
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
+24
-4
@@ -11,8 +11,9 @@ namespace Http
|
||||
m.Get("/api/state", function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
task = context.server.task
|
||||
|
||||
keys = ["app", "device", "invidious"]
|
||||
keys = ["app", "device", "invidious", "preferences"]
|
||||
|
||||
if request.query.DoesExist("key")
|
||||
keys = request.query["key"]
|
||||
@@ -25,6 +26,13 @@ namespace Http
|
||||
|
||||
if ArrayIndexOf(keys, "app") <> -1
|
||||
state["app"] = GetAppInfo()
|
||||
scene = task.top.getScene()
|
||||
if scene.playletLibLoadedUrl <> invalid
|
||||
state["app"]["lib_url"] = scene.playletLibLoadedUrl.link
|
||||
state["app"]["lib_url_type"] = scene.playletLibLoadedUrl.type
|
||||
end if
|
||||
latestPlayletLibVersion = GetLatestPlayletLibVersion()
|
||||
state["app"]["lib_version_latest"] = latestPlayletLibVersion
|
||||
end if
|
||||
|
||||
if ArrayIndexOf(keys, "device") <> -1
|
||||
@@ -34,14 +42,26 @@ namespace Http
|
||||
if ArrayIndexOf(keys, "invidious") <> -1
|
||||
authToken = InvidiousSettings.GetAuthToken()
|
||||
state["invidious"] = {
|
||||
instances: InvidiousSettings.GetCurrentInstances(),
|
||||
selected_instance: InvidiousSettings.GetSelectedInstance(),
|
||||
current_instance: InvidiousSettings.GetCurrentInstance(),
|
||||
backup_instances: InvidiousSettings.GetBackupInstances(),
|
||||
auth_url: Invidious.GetAuthorizeTokenLink(),
|
||||
logged_in: authToken <> invalid,
|
||||
logged_in_instance: authToken <> invalid ? authToken.instance : invalid
|
||||
logged_in_instance: authToken <> invalid ? authToken.instance : invalid,
|
||||
logged_in_username: authToken <> invalid ? authToken.username : invalid
|
||||
}
|
||||
end if
|
||||
|
||||
if ArrayIndexOf(keys, "preferences") <> -1
|
||||
scene = task.top.getScene()
|
||||
settings = scene.findNode("SettingsScreen")
|
||||
if settings = invalid
|
||||
response.Default(500, `Settings screen not found: scene.findNode("SettingsScreen") returned invalid`)
|
||||
return true
|
||||
end if
|
||||
|
||||
state["preferences"] = settings@.GetUserPreferences(invalid)
|
||||
end if
|
||||
|
||||
response.Json(state)
|
||||
return true
|
||||
end function)
|
||||
+14
-4
@@ -5,6 +5,8 @@ import "pkg:/components/WebServer/Middleware/HttpDefaultRouter.bs"
|
||||
import "pkg:/components/WebServer/Middleware/InvidiousRouter.bs"
|
||||
import "pkg:/components/WebServer/Middleware/RegistryApiRouter.bs"
|
||||
import "pkg:/components/WebServer/Middleware/StateApiRouter.bs"
|
||||
import "pkg:/components/WebServer/Middleware/PreferencesRouter.bs"
|
||||
import "pkg:/components/WebServer/Middleware/SearchHistoryRouter.bs"
|
||||
import "pkg:/components/WebServer/Middleware/CommandsApiRouter.bs"
|
||||
import "pkg:/components/WebServer/Middleware/CorsMiddleware.bs"
|
||||
import "pkg:/components/WebServer/Middleware/BasicAuthMiddleware.bs"
|
||||
@@ -21,7 +23,7 @@ function WebServerLoop()
|
||||
|
||||
m.settings = new Http.HttpSettings(m.webServerPort)
|
||||
' Root at www to get http://IP_ADDRESS:PORT/index.html
|
||||
m.settings.WwwRoot = "pkg:/www"
|
||||
m.settings.WwwRoot = "libpkg:/www"
|
||||
' Short interval to keep polling on web socket messages
|
||||
m.settings.Timeout = 500
|
||||
m.server = new Http.HttpServer(m.settings, m)
|
||||
@@ -39,7 +41,7 @@ function WebServerLoop()
|
||||
homeRouter = new Http.HttpRouter()
|
||||
homeRouter.Get("/", function(context as object) as boolean
|
||||
response = context.response
|
||||
response.Redirect("/index.v1.html", 302)
|
||||
response.Redirect("/index.html")
|
||||
return true
|
||||
end function)
|
||||
|
||||
@@ -48,6 +50,7 @@ function WebServerLoop()
|
||||
#else
|
||||
allowedOrigin = `http://${GetLocalIpAddress()}:8888`
|
||||
#end if
|
||||
|
||||
m.server.UseRouter(new Http.CorsMiddleware(allowedOrigin))
|
||||
#if WEB_SOCKETS
|
||||
m.server.UseRouter(new Http.WebSocketMiddleware())
|
||||
@@ -56,17 +59,24 @@ function WebServerLoop()
|
||||
m.server.UseRouter(new Http.DashRouter())
|
||||
m.server.UseRouter(new Http.CommandsApiRouter())
|
||||
m.server.UseRouter(new Http.StateApiRouter())
|
||||
m.server.UseRouter(new Http.PreferencesRouter())
|
||||
m.server.UseRouter(new Http.InvidiousRouter())
|
||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/", m.settings.WwwRoot))
|
||||
m.server.UseRouter(new Http.SearchHistoryRouter())
|
||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/", m.settings.WwwRoot, false, false, false))
|
||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/config", "libpkg:/config", false, false, false))
|
||||
#if DEBUG
|
||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/libpkg", "libpkg:/", true, true, false))
|
||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/pkg", "pkg:/", true, true))
|
||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/tmp", "tmp:/", true, true))
|
||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/cachefs", "cachefs:/", true, true))
|
||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/common", "common:/", true, true))
|
||||
#end if
|
||||
#if WEB_SERVER_BASIC_AUTH
|
||||
m.server.UseRouter(new Http.BasicAuthMiddleware())
|
||||
#end if
|
||||
m.server.UseRouter(new Http.RegistryApiRouter())
|
||||
#if DEBUG
|
||||
m.server.UseRouter(new Http.RegistryApiRouter())
|
||||
#end if
|
||||
m.server.UseRouter(new Http.HttpDefaultRouter())
|
||||
|
||||
timeout = m.settings.Timeout
|
||||
+1
-1
@@ -3,6 +3,6 @@
|
||||
<component name="WebServerTask" extends="Task">
|
||||
<interface>
|
||||
<field id="login" type="boolean" alwaysNotify="true" />
|
||||
<field id="command" type="string" alwaysNotify="true" />
|
||||
<field id="command" type="assocarray" alwaysNotify="true" />
|
||||
</interface>
|
||||
</component>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+30
-4
@@ -36,13 +36,11 @@ namespace Web
|
||||
|
||||
secondByte = m.ReadByte()
|
||||
m.is_masked = (secondByte and &h80) <> 0
|
||||
m.payload_size = secondByte and &h7F
|
||||
|
||||
if not m.is_masked
|
||||
return false
|
||||
end if
|
||||
|
||||
if m.payload_size >= 126
|
||||
if not m.ReadPayloadSize(secondByte)
|
||||
return false
|
||||
end if
|
||||
|
||||
@@ -56,13 +54,41 @@ namespace Web
|
||||
return true
|
||||
end function
|
||||
|
||||
function ReadPayloadSize(secondByte as integer) as boolean
|
||||
payloadSize = secondByte and &h7F
|
||||
if payloadSize < 126
|
||||
m.payload_size = payloadSize
|
||||
return true
|
||||
else if payloadSize = 126
|
||||
payloadSize = (m.ReadByte() << 8) or m.ReadByte()
|
||||
m.payload_size = payloadSize
|
||||
return true
|
||||
else
|
||||
'TODO: Read size in 8 bytes
|
||||
return false
|
||||
end if
|
||||
end function
|
||||
|
||||
function WritePayloadSize(payloadSize as integer)
|
||||
if payloadSize < 126
|
||||
m.WriteByte(payloadSize)
|
||||
else if payloadSize < 65536
|
||||
m.WriteByte(126)
|
||||
m.WriteByte(payloadSize >> 8)
|
||||
m.WriteByte(payloadSize and &hFF)
|
||||
else
|
||||
m.WriteByte(127)
|
||||
'TODO: Write size in 8 bytes
|
||||
end if
|
||||
end function
|
||||
|
||||
function WriteToBuffer(buffer as object, index as integer, length as integer) as integer
|
||||
m.buffer = buffer
|
||||
m.index = index
|
||||
m.length = length
|
||||
|
||||
m.WriteByte(m.fin or m.opcode)
|
||||
m.WriteByte(m.payload_size)
|
||||
m.WritePayloadSize(m.payload_size)
|
||||
|
||||
for i = 0 to m.payload_size - 1
|
||||
m.buffer[m.index] = m.payload[i]
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 260 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user