Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57d39a6bb1 | ||
|
|
f2f8baa6b1 | ||
|
|
1a72c69b8e | ||
|
|
6ac8d54144 | ||
|
|
e5a932f62f | ||
|
|
2b147bbecf | ||
|
|
630668cff4 | ||
|
|
1e98e98c04 | ||
|
|
a5af36ddc0 | ||
|
|
11aef3e3aa | ||
|
|
1b1a9e3cce | ||
|
|
6da878edf9 | ||
|
|
fef8df454a | ||
|
|
a8c693852e | ||
|
|
725cf59508 | ||
|
|
a6710d3510 | ||
|
|
e8b48611ca | ||
|
|
3add083f6b | ||
|
|
e49aa9b7d8 | ||
|
|
5d38b325c5 | ||
|
|
fdc3434f15 | ||
|
|
77170edc0d | ||
|
|
ea5531f1c8 | ||
|
|
581beb5d32 | ||
|
|
2e8cdd2cec | ||
|
|
eb9bf48127 | ||
|
|
dccbf76c1a | ||
|
|
70d66f874d | ||
|
|
80bcd4c870 | ||
|
|
bd312484a9 | ||
|
|
6531650a39 | ||
|
|
3342e9f4da | ||
|
|
3179fad19f | ||
|
|
00df78d862 | ||
|
|
016d6de6d6 | ||
|
|
a224b86fca | ||
|
|
936eefeeb9 | ||
|
|
7b53ec820d | ||
|
|
25eccde5c3 | ||
|
|
093953c113 | ||
|
|
60e8b9200e | ||
|
|
a070343a78 | ||
|
|
d9dd6bc2f7 | ||
|
|
e65749e0de | ||
|
|
9cc12508cc | ||
|
|
37e43b5b32 | ||
|
|
d3fba0a8be | ||
|
|
05799b4932 | ||
|
|
3191bfe425 | ||
|
|
52d4222b5e | ||
|
|
5c2a590877 | ||
|
|
8bc9cec570 | ||
|
|
55fd1ba43c | ||
|
|
b1d8caf5c7 | ||
|
|
80dcc322cf | ||
|
|
f89bb2bbf1 | ||
|
|
581d5a8a42 | ||
|
|
f38c0b4106 | ||
|
|
191b88f4d0 | ||
|
|
c705ce86d3 | ||
|
|
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 |
No files matched your search
@@ -1,10 +1,12 @@
|
||||
name: Linter
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
branches: ["main"]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
@@ -25,8 +27,8 @@ jobs:
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18.x
|
||||
cache: 'npm'
|
||||
|
||||
cache: "npm"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
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: Use Java 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: "17"
|
||||
|
||||
- name: Download the Static Channel Analysis CLI
|
||||
run: |
|
||||
curl -sSL "https://devtools.web.roku.com/static-channel-analysis/sca-cmd.zip" -o sca-cmd.zip
|
||||
unzip sca-cmd.zip
|
||||
|
||||
- name: Run Analysis on Playlet Lib
|
||||
# Note: we don't set the exit code to on error, because sca treats the lib
|
||||
# as a standalone app, and logs all sorts of errors that are not relevant to
|
||||
# a Component Library.
|
||||
# This run is simply to check if there's any interesting output comes up.
|
||||
run: ./sca-cmd/bin/sca-cmd ./playlet/src/lib/playlet-lib.zip
|
||||
|
||||
- name: Run Analysis on Playlet App
|
||||
run: ./sca-cmd/bin/sca-cmd ./release/playlet.zip --exit error
|
||||
|
||||
- name: Delete unstable release
|
||||
uses: dev-drprasad/delete-tag-and-release@v1.0
|
||||
with:
|
||||
tag_name: unstable
|
||||
github_token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: Extract changelog
|
||||
run: |
|
||||
latest_release=$(awk 'BEGIN { RS="## \\[" } NR==2 { print "## ["$0 }' CHANGELOG.md)
|
||||
echo -e "\n$latest_release" >> docs/unstable-changelog.md
|
||||
|
||||
- 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 }}
|
||||
@@ -1,7 +1,7 @@
|
||||
dist/
|
||||
out/
|
||||
node_modules
|
||||
.vscode/.env
|
||||
.env
|
||||
**/roku_modules/**
|
||||
playlet-lib/src/www
|
||||
playlet/src/lib/playlet-lib.zip
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"RokuCommunity.brightscript",
|
||||
"svelte.svelte-vscode",
|
||||
]
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
{
|
||||
"type": "brightscript",
|
||||
"request": "launch",
|
||||
"envFile": "${workspaceFolder}/.vscode/.env",
|
||||
"envFile": "${workspaceFolder}/.env",
|
||||
"host": "${env:ROKU_DEV_TARGET}",
|
||||
"password": "${env:ROKU_DEVPASSWORD}",
|
||||
"stopOnEntry": false,
|
||||
@@ -35,7 +35,7 @@
|
||||
{
|
||||
"type": "brightscript",
|
||||
"request": "launch",
|
||||
"envFile": "${workspaceFolder}/.vscode/.env",
|
||||
"envFile": "${workspaceFolder}/.env",
|
||||
"host": "${env:ROKU_DEV_TARGET}",
|
||||
"password": "${env:ROKU_DEVPASSWORD}",
|
||||
"stopOnEntry": false,
|
||||
@@ -57,6 +57,19 @@
|
||||
"name": "Playlet Web (Dev)",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
},
|
||||
{
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"name": "Playlet Web (Chrome)",
|
||||
"webRoot": "${workspaceFolder}/playlet-web/src"
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Playlet Web (Debug)",
|
||||
"configurations": ["Playlet Web (Dev)", "Playlet Web (Chrome)"],
|
||||
"stopAll": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
{
|
||||
"brightscript.output.clearConsoleOnChannelStart": false
|
||||
"brightscript.output.clearConsoleOnChannelStart": false,
|
||||
"brightscript.bsdk": "node_modules/brighterscript",
|
||||
"editor.formatOnSave": true
|
||||
}
|
||||
@@ -1,20 +1,124 @@
|
||||
# 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.7.0] - 2023-02-04
|
||||
## [0.10.3] - 2023-07-24
|
||||
|
||||
### Added
|
||||
|
||||
- Support for saved playlists. By adding a playlist from a youtube channel to your Invidious profile, you can see the playlist on Playlet.
|
||||
|
||||
## [0.10.2] - 2023-07-10
|
||||
|
||||
### Added
|
||||
|
||||
- Links to the app info in web app
|
||||
- Loading indicator for search page in web app
|
||||
- Feedback link through email
|
||||
- Scopes and expire fields to the Invidious auth token. This is to detect when a token is close to expiry, or if we have missing permissions.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Video duration formatting in cast dialog
|
||||
- (Removed) Workaround for Invidious token expiring due to misconfigured instance
|
||||
- Crash when loading the home screen [#83](https://github.com/iBicha/playlet/issues/83)
|
||||
- Performance of home screen in web app
|
||||
- SponsorBlock segments where video duration is not provided (follow up to [#23](https://github.com/iBicha/playlet/pull/23))
|
||||
- Focus with the settings input field
|
||||
|
||||
## [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
|
||||
@@ -23,22 +127,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
|
||||
@@ -50,6 +159,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
|
||||
@@ -58,7 +168,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
|
||||
@@ -68,13 +180,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
|
||||
@@ -82,7 +198,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
|
||||
@@ -94,7 +212,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 } } -->
|
||||
@@ -1,102 +1,78 @@
|
||||
<p align="center">
|
||||
<img src="banner.png" style="display:block;text-align:center" alt="Playlet Logo" width="800"/>
|
||||
</p>
|
||||
|
||||
# Playlet
|
||||
|
||||
Unofficial Youtube client for Roku 📺
|
||||
<!-- markdownlint-disable MD033 -->
|
||||
<p align="center">
|
||||
<img src="docs/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 is an unofficial Youtube client for Roku 📺
|
||||
|
||||
## Screenshots
|
||||
|
||||
<a href="./docs/screenshots/README.md">
|
||||
|
||||
|  |  |  |
|
||||
|-------------------------------------------------|-------------------------------------------------|-------------------------------------------------|
|
||||
|
||||
</a>
|
||||
|
||||
More under [Screenshots](./docs/screenshots/README.md)
|
||||
|
||||
## Installation
|
||||
|
||||
[Playlet on Roku channel store](https://channelstore.roku.com/en-ca/details/840aec36f51bfe6d96cf6db9055a372a/playlet)
|
||||
|
||||
## 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
|
||||
- You can browser or search for videos while you watch
|
||||
- You can browser or search for videos while you watch
|
||||
- To restore currently playing video to full screen, press the ✳️ (options) button
|
||||
|
||||
### Customize Invidious instance
|
||||
|
||||
1. Open settings in Playlet
|
||||
1. Scan QR Code with Phone
|
||||
1. Change the Invidious instance
|
||||
|
||||
## 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"/>
|
||||
|
||||
## Installation
|
||||
### Roku Store (Published app)
|
||||
Search for "Playlet" in the Roku Store, or use the link https://my.roku.com/account/add?channel=PLAYLET
|
||||
|
||||
### 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:
|
||||
|
||||
<img src="https://image.roku.com/ZHZscHItMTc2/dev-startup1.png" alt="DevSequence" width="350"/>
|
||||
|
||||
For full instructions, see [Set up your Roku device to enable Developer Settings](https://developer.roku.com/en-ca/docs/developer-program/getting-started/developer-setup.md#step-1-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
|
||||
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)
|
||||
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
|
||||
- The username is `rokudev`
|
||||
- The password is whatever you set when you enabled Developer mode
|
||||
4. Click on `Upload` button and select the `playlet.zip` file you downloaded in step 1
|
||||
6. Click `Install with zip` button
|
||||
- If you're updating the app (or you already have a dev channel) the button would say `Replace with zip`
|
||||
1. You can also do this from the settings tab
|
||||
|
||||
## Development
|
||||
1. `git clone https://github.com/iBicha/playlet.git`
|
||||
1. `cd playlet`
|
||||
1. `npm install`
|
||||
|
||||
Create a file under `playlet/.vscode/.env` containing:
|
||||
```
|
||||
ROKU_DEV_TARGET=REPLACE_IP_ADDRESS_HERE
|
||||
ROKU_DEVPASSWORD=REPLACE_PASSWORD_HERE
|
||||
```
|
||||
|
||||
Then you can open the project using VS Code and deploy to your Roku TV using the Debug button.
|
||||
For everything related to Playlet app development, please see the [documentation](./docs/README.md)
|
||||
|
||||
## Why Playlet
|
||||
```
|
||||
|
||||
```none
|
||||
playlet - noun
|
||||
play•let /ˈplālət/
|
||||
: a short play
|
||||
@@ -112,5 +88,8 @@ By removing all the bloat, the ads, the tracking, we could end up with an even f
|
||||
In any case, I hope you find **Playlet** useful, and pleasant to use.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
**Playlet** does not serve or distribute any material from unauthorized sources.<br/>
|
||||
**Playlet** is simply a frontend to other systems (such as https://github.com/iv-org/invidious), bringing the watching experience to the TV, as opposed to the existing frontends that are web and mobile focused.
|
||||
**Playlet** is simply a frontend to other systems (such as [Invidious](https://github.com/iv-org/invidious)), bringing the watching experience to the TV, as opposed to the existing frontends that are web and mobile focused.
|
||||
|
||||
<!-- markdownlint-configure-file {"MD024": { "siblings_only": true } } -->
|
||||
@@ -23,8 +23,8 @@
|
||||
"plugins": [
|
||||
"roku-log-bsc-plugin",
|
||||
"@rokucommunity/bslint",
|
||||
"../tools/asynctask-plugin.ts",
|
||||
"../tools/manifest-bsconst-debug-plugin.ts"
|
||||
"../tools/bs-plugins/asynctask-plugin.ts",
|
||||
"../tools/bs-plugins/manifest-bsconst-debug-plugin.ts"
|
||||
],
|
||||
"retainStagingDir": true,
|
||||
"require": [
|
||||
|
||||
@@ -0,0 +1,324 @@
|
||||
# Playlet documentation
|
||||
|
||||
This documents contains verious kinds of information related to Playlet development. It's a bit of a [brain dump](https://en.wiktionary.org/wiki/brain_dump) that I tried to keep structured.
|
||||
|
||||
- [Environment setup](#environment-setup)
|
||||
- [Project setup](#project-setup)
|
||||
- [Roku Developer mode](#roku-developer-mode)
|
||||
- [Setting up Visual Studio Code](#setting-up-visual-studio-code)
|
||||
- [Tools](#tools)
|
||||
- [BrightScript Language Extension for VS Code](#brightscript-language-extension-for-vs-code)
|
||||
- [RALE (Roku Advanced Layout Editor)](#rale-roku-advanced-layout-editor)
|
||||
- [BrighterScript](#brighterscript)
|
||||
- [BrighterScript Linter/Formatter](#brighterscript-linterformatter)
|
||||
- [Playlet App](#playlet-app)
|
||||
- [Why separate between Playlet and Playlet Lib?](#why-separate-between-playlet-and-playlet-lib)
|
||||
- [Playlet Lib](#playlet-lib)
|
||||
- [WebServer](#webserver)
|
||||
- [Debug endpoints](#debug-endpoints)
|
||||
- [Releases from Github](#releases-from-github)
|
||||
- [Dev library hosted by VS Code Extension](#dev-library-hosted-by-vs-code-extension)
|
||||
- [AsyncAwait Task Generator](#asyncawait-task-generator)
|
||||
- [Feature flags](#feature-flags)
|
||||
- [User preferences](#user-preferences)
|
||||
- [Home page layout](#home-page-layout)
|
||||
- [Playlet Web App](#playlet-web-app)
|
||||
- [Svelte development](#svelte-development)
|
||||
- [Tailwind/Daisy UI](#tailwinddaisy-ui)
|
||||
- [API calls (proxy authenticated)](#api-calls-proxy-authenticated)
|
||||
- [Developer settings](#developer-settings)
|
||||
- [In case of a softlock](#in-case-of-a-softlock)
|
||||
- [CI/CD](#cicd)
|
||||
|
||||
## Environment setup
|
||||
|
||||
### Project setup
|
||||
|
||||
```bash
|
||||
git clone https://github.com/iBicha/playlet.git
|
||||
cd playlet
|
||||
npm install
|
||||
```
|
||||
|
||||
### Roku Developer mode
|
||||
|
||||
To develop Roku applications, you need to enable Developer mode on your Roku device.
|
||||
Using your Roku remote, enter the following sequence:
|
||||
|
||||
<!-- markdownlint-disable-next-line -->
|
||||
<img src="https://image.roku.com/ZHZscHItMTc2/dev-startup1.png" alt="DevSequence" width="350"/>
|
||||
|
||||
For full instructions, see [Set up your Roku device to enable Developer Settings](https://developer.roku.com/en-ca/docs/developer-program/getting-started/developer-setup.md#step-1-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.
|
||||
|
||||
### Setting up Visual Studio Code
|
||||
|
||||
Visual Studio Code is pretty much necessary for development.
|
||||
|
||||
> apologies if this is not your favorite IDE. Please do [share](https://github.com/iBicha/playlet/issues/new?title=I%20don%27t%20like%20VS%20Code) if you feel this should not be a requirement.
|
||||
|
||||
Once you have it installed, you probably want to install the recommened plugins for this project, such as [BrightScript Language extension for VSCode](https://marketplace.visualstudio.com/items?itemName=RokuCommunity.brightscript) and [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode)
|
||||
|
||||
Next, create a file `.env` containing the following:
|
||||
|
||||
```makefile
|
||||
ROKU_DEV_TARGET=INSERT_IP_HERE
|
||||
ROKU_DEVPASSWORD=INSERT_PASSWORD_HERE
|
||||
```
|
||||
|
||||
Where `ROKU_DEV_TARGET` is the local ip address of your Roku device, and `ROKU_DEVPASSWORD` is the developer password from [Roku Developer mode](#roku-developer-mode).
|
||||
|
||||
Now from VS Code, press the Play button with the target `Playlet (dev)` selected. This should build and run Playlet on your device in dev mode.
|
||||
|
||||
## Tools
|
||||
|
||||
### BrightScript Language Extension for VS Code
|
||||
|
||||
The [BrightScript Language extension for VSCode](https://marketplace.visualstudio.com/items?itemName=RokuCommunity.brightscript) includes many useful tools for development and debugging. Includes things like
|
||||
|
||||
- Sending commands to the App
|
||||
- Like getting the focused node, inspecting values, etc
|
||||
- SceneGraph inspector
|
||||
- Allows you to see the hiearchy of the scene, and even modify elements at runtime. Useful for quick tweaks or adjusting UI.
|
||||
- Roku Registry
|
||||
- Allows you to inspect the content of the [Registry](https://developer.roku.com/en-ca/docs/references/brightscript/components/roregistry.md)
|
||||
|
||||
Playlet is configured to have all these features available when ran in debug mode.
|
||||
|
||||
### RALE (Roku Advanced Layout Editor)
|
||||
|
||||
[The Roku Advanced Layout Editor, aka RALE](https://devtools.web.roku.com/roku-advanced-layout-editor/), is a tool that provides a hierarchical view of the node tree in a Roku Scene Graph channel.
|
||||
It's a standalone application that you can optionally install.
|
||||
|
||||
It's sometimes useful when designing UI and inspecting values of nodes.
|
||||
|
||||
Well, if you do happen to use it, Playlet is configured to connect to RALE.
|
||||
|
||||
### BrighterScript
|
||||
|
||||
[BrighterScript](https://github.com/rokucommunity/brighterscript) is a community driven programming language compiles to BrightScript and has [useful features](https://github.com/rokucommunity/BrighterScript/blob/master/docs/readme.md). Playlet uses BrighterScript features a lot across the code base, and even implements a couple of BrighterScript plugins (More on that later).
|
||||
|
||||
### BrighterScript Linter/Formatter
|
||||
|
||||
Playlet uses [bslint](https://github.com/rokucommunity/bslint) and [brighterscript-formatter](https://github.com/rokucommunity/brighterscript-formatter).
|
||||
|
||||
You can use these commands to lint/format Playlet code:
|
||||
|
||||
```bash
|
||||
npm run format
|
||||
npm run format:fix
|
||||
npm run lint
|
||||
npm run lint:fix
|
||||
```
|
||||
|
||||
## Playlet App
|
||||
|
||||
Playlet is split into two parts: `Playlet (the app)` and `Playlet Lib`.
|
||||
|
||||
Playlet (the app) is a regular Roku app, that uses a [ComponentLibrary](https://developer.roku.com/en-ca/docs/references/scenegraph/control-nodes/componentlibrary.md) to load the rest of the app from [Playlet Lib](#playlet-lib).
|
||||
|
||||
In a way, Playlet (the app) is a thin loader, while most of the logic lives in [Playlet Lib](#playlet-lib).
|
||||
|
||||
Playlet app is responsible for a few things:
|
||||
|
||||
- Load Playlet lib
|
||||
- By default, it tries to load the latest version from Github
|
||||
- If that fails (for example, if Github was down), it fallsback to loading an embedded copy of Playlet Lib
|
||||
- `if Github was down` -> yes, this has happened in the past, and it did not stop Playlet for working.
|
||||
- In dev mode, it loads playlet lib that's being served by [BrightScript Language Extension for VS Code](#brightscript-language-extension-for-vs-code)
|
||||
- Once loaded, Playlet loads the `MainScene` from Playlet Lib
|
||||
- Pass Launch parameters and Input parameters to Playlet Lib
|
||||
- Show a loading screen and wait for Playlet Lib to hide it
|
||||
|
||||
That's pretty much it.
|
||||
|
||||
### Why separate between Playlet and Playlet Lib?
|
||||
|
||||
There are a few reasons we made this separation:
|
||||
|
||||
- Playlet relies on [Invidious](https://github.com/iv-org/invidious). Invidious tries to keep up with Youtube making changes to their platform, but sometimes, a breaking change happens the requires Playlet to react quickly. Releasing through the Roku Channel store can take days, or a week. During this time, Playlet would be not functional, and that's not acceptable.
|
||||
- The ability to roll back: Sometimes an app breaking bug gets released. Allowing users to choose a seperate version is a flexible way to keep things working. Although right now rollbacks are behind a - hidden by default - developer menu, the reasoning still stands.
|
||||
- It is simply easier to release: Releasing Playlet Lib on Github, and everyone receiving the latest version immediately, is very conveninct and less of a hassle, than going through the Roku Channel store.
|
||||
- I've had instances where I was trying to pass the certfication for Playlet to publish it. One of the criterias is to pass a some automated tests. But the tests were failing because their system could not connect to their Roku test devices (connection keeps timing out). My only option was to keep trying over and over until it worked.
|
||||
|
||||
It might sound that Playlet Lib is just a workaround for the Roku Channel release process. But phrased differently, Roku Channel release process is not good enough of what we need for Playlet.
|
||||
|
||||
## Playlet Lib
|
||||
|
||||
Playlet Lib is a [ComponentLibrary](https://developer.roku.com/en-ca/docs/references/scenegraph/control-nodes/componentlibrary.md) that gets loaded by [Playlet App](#playlet-app). It containes pretty much all the logic needed to run the app.
|
||||
|
||||
### WebServer
|
||||
|
||||
Playlet lib comes equipped with a web server that runs on 8888 when the app starts. This server enables:
|
||||
|
||||
- The communication between Playlet and [Playlet Web App](#playlet-web-app)
|
||||
- Through http calls, and even through web sockets for real time events
|
||||
- Allows remotely casting videos, change preferences, etc
|
||||
- Authentication using Invidious
|
||||
|
||||
The web server runs on a continiously running [Task](https://developer.roku.com/en-ca/docs/references/scenegraph/control-nodes/task.md) and uses a middeware system to manage routes, serving static files, [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), and more
|
||||
|
||||
#### Debug endpoints
|
||||
|
||||
Additionally, the web server exposes Web APIs in debug mode to help with debugging. To name a few examples:
|
||||
|
||||
- `/debug/pkg` to inspect files under Playlet App
|
||||
- `/debug/libpkg` to inspect files under Playlet Lib
|
||||
- `/debug/tmp` and `/debug/cachefs` to inspect files in temporary and cache
|
||||
|
||||
These are useful to see if the files and caching are working as expected
|
||||
|
||||
### Releases from Github
|
||||
|
||||
Since Component Libraries are simply zip files hosted some https endpoint, Github releases are used to host and deliever Playet Lib to users. By default, Playlet grabs `https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.zip` and loads it, but this can be pointed to somewhere else, if for some reason the Github repository becomes unavailable.
|
||||
|
||||
### Dev library hosted by VS Code Extension
|
||||
|
||||
When in debug mode, Playlet lib is packaged and served locally on port 8080, and Playlet app would use it instead of the Playlet lib from Github. This is an important detail, because once you stop debugging in VS Code, the dev app on your Roku TV won't function anymore, with an error:
|
||||
> Could not load Playlet component library from any of the following urls:
|
||||
>
|
||||
> - \[debug\] http://192.168.1.x:8080/playlet-lib.zip <!-- markdownlint-disable-line -->
|
||||
> Please restart Playlet.
|
||||
> If the problem persist, contact Playlet authors.
|
||||
|
||||
### AsyncAwait Task Generator
|
||||
|
||||
To implement functionality that runs in background threads, [Task](https://developer.roku.com/en-ca/docs/references/scenegraph/control-nodes/task.md)s must be used.
|
||||
|
||||
Setting up a task involes lots of boilerplate: setting up the task in an xml file, defining inputs and outputs, code to listen for a task to finish, and so on.
|
||||
|
||||
That's why there's a BrighterScript plugin that generates a task for a function with the attribute `@asynctask`.
|
||||
|
||||
In a separate file, define the task function:
|
||||
|
||||
```brighterscript
|
||||
@asynctask
|
||||
function MyBackgroundTask(input as object) as object
|
||||
myVar = input.myVar
|
||||
|
||||
value = DoWork(myVar)
|
||||
|
||||
return {
|
||||
value: value
|
||||
}
|
||||
end function
|
||||
```
|
||||
|
||||
And use the function like so
|
||||
|
||||
```brighterscript
|
||||
StartAsyncTask(MyBackgroundTask, {myVar: "some input"}, function(output as object) as void
|
||||
if output.success
|
||||
print(output.result.value)
|
||||
end if
|
||||
end function)
|
||||
```
|
||||
|
||||
Although very useful, but this pattern might not be the best for long running tasks (like the Web Server) or other tasks that require task reuse. This is because `StartAsyncTask` create a new instance of the task every time.
|
||||
|
||||
### Feature flags
|
||||
|
||||
Playlet uses [bs_const](https://developer.roku.com/en-ca/docs/references/brightscript/language/conditional-compilation.md#manifest-constant) to define feature flags. The flags are usually for features that introduce a downside, or require further refinement.
|
||||
|
||||
### User preferences
|
||||
|
||||
Playlet uses a json file that lists user preferences. It should be under [playlet-lib/src/config/preferences.json](/playlet-lib/src/config/preferences.json)
|
||||
This file defines the kind of preferences that users can change, such as autoplay, preferred quality, and so on.
|
||||
|
||||
This file is parsed at runtime and UI for the settings is generated. The same mechanism is used to Playlet and the Web App.
|
||||
|
||||
Additionally, The web server exposes the settings under `/api/preferences`, which can enable importing/exporting user preferences.
|
||||
|
||||
### Home page layout
|
||||
|
||||
When playlet starts, it shows a video feed in the screen. Subscription, Trending videos, and so on.
|
||||
|
||||
The layout is defined under [playlet-lib/src/config/default_home_layout.json](/playlet-lib/src/config/default_home_layout.json).
|
||||
|
||||
This could allow users to define custom layouts, so they can see what they find relevant in the home page. This can include Subscription, Trending, Popular videos, Search per keywords, or Playlists.
|
||||
|
||||
Additionally each feed has information on how it is fetched. For now, only Invidious can be data source, but other systems should be configured in the same way.
|
||||
|
||||
Invidious API definitions are defined under [playlet-lib/src/config/invidious_video_api.json](/playlet-lib/src/config/invidious_video_api.json), and Playlet parses these at runtime and make the right api calls to fetch the data.
|
||||
|
||||
Finally, this layout system is what allows both the BrightScript app and the Web app to display the same homepage.
|
||||
|
||||
## Playlet Web App
|
||||
|
||||
Playlet comes with a web app built with [Svelte](https://svelte.dev/). The web app can be used to browse videos, search, cast videos to TV, and even change preferences.
|
||||
|
||||
The web app gets served using the Playlet Web server. It also interact with the web apis from web server.
|
||||
It's important to note that if Playlet is not ON (on your Roku device) or the TV is in screen saver mode, then the web app can't be used.
|
||||
|
||||
When Playlet gets built, several steps happen:
|
||||
|
||||
1. The web app gets kicked off first. The web app artifacts gets written to `playlet-lib/src/www`
|
||||
1. Playlet lib gets built second. As part of the build pipeline, a copy of `playlet-lib.zip` is made under `playlet/src/lib/playlet-lib.zip`
|
||||
1. Finally, Playlet app is built.
|
||||
|
||||
### Svelte development
|
||||
|
||||
The web app uses [Svelte](https://svelte.dev/), [Vite](https://vitejs.dev/) and [Typescript](https://www.typescriptlang.org/) primarily. It currently does not use [SvelteKit](https://kit.svelte.dev/), since it doesn't need some of the more advanced features that SvelteKit offers, such as routing or server-side rendering (SSR)
|
||||
|
||||
Since modifying the web app code requires building all three projects (playlet, playlet lib, and web app) this makes the iteration speed very slow, and we lose the benefits of web development, such as hot reloads.
|
||||
|
||||
For that reason, the recommeneded iteration when working on the dev app is:
|
||||
|
||||
1. Start `Playlet (dev)` (by selecting `Playlet (dev)` and pressing Play in VS Code)
|
||||
1. Once Playlet starts, switch to `Playlet Web (dev)` and press play. Do not stop `Playlet (dev)`
|
||||
1. The web app should start in the browser
|
||||
|
||||
You will notice that thr browser tab that just opened shows an url like `http://192.168.1.X:5173/?host=192.168.1.Y:8888`
|
||||
|
||||
This is because the web app will be served from Vite, while API calls to the playlet will be done to the Playlet lib webserver.
|
||||
|
||||
For debugging, choose the compound target `Playlet Web (Debug)`.
|
||||
|
||||
### Tailwind/Daisy UI
|
||||
|
||||
Playlet web app uses [Tailwind CSS](https://tailwindcss.com/) as its base styling library. Additionally, it uses [DaisyUI](https://daisyui.com/) as it offers a versatile set of components, and has built-in supports for themes.
|
||||
|
||||
### API calls (proxy authenticated)
|
||||
|
||||
When making authenticated calls to Invidious (for example to fetch the user Subscription feed) the Bearer token is needed.
|
||||
|
||||
In this case specifically, the web server acts as a proxy between Invidious and the web app. This is for a few reasons:
|
||||
|
||||
- CORS: Bearer token can't go through to Invidious from the web app (due to missing `Access-Control-Allow-Credentials` header)
|
||||
- The web server is not secure: it's not on HTTPS
|
||||
- It's best if the Invidious access token would not be served to the web app, and remain on the Roku device
|
||||
|
||||
For API calls that don't require authentication, the web app fetches data from invidious directly.
|
||||
|
||||
### Developer settings
|
||||
|
||||
To access developer settings, open the web app, and append the parameter `dev=1` to the url. Example:
|
||||
|
||||
```bash
|
||||
http://192.168.1.107:8888/index.html?dev=1
|
||||
```
|
||||
|
||||
This reveals an additional settings section in preferences. For now, it allows you to point to a different Github release other than the default `latest`.
|
||||
|
||||
This is mostly useful to QA the `unstable` release in a "production" setting before making it available to all users as the official "latest" version.
|
||||
|
||||
#### In case of a softlock
|
||||
|
||||
If the dev menu is used to load a custom Playlet lib url, but the lib does not have a functionality to revert back:
|
||||
|
||||
```bash
|
||||
curl -d '' "http://$ROKU_DEV_TARGET:8060/launch/dev?clearPlayletLibUrls=true"
|
||||
```
|
||||
|
||||
This will remove the custom lib, and revert to using default (latest release from Github).
|
||||
|
||||
## CI/CD
|
||||
|
||||
On pull requests, a Github action will run `lint:fix` and `format:fix` and push changes to the PR branch, to keep things tidy.
|
||||
|
||||
When merged to main branch, a Github action will build Playlet, run static analysis using Roku's [Static Channel Analysis tool](https://devtools.web.roku.com/#static-channel-analysis-tool), and release a new version tagged `unstable`, with the build artifacts attached, and changelog included.
|
||||
|
||||
Existing `unstable` release will be removed before creating a new one.
|
||||
|
||||
This makes [Releasing](./RELEASING.md) simpler.
|
||||
@@ -0,0 +1,48 @@
|
||||
<!-- markdownlint-disable MD036 -->
|
||||
|
||||
# Releasing
|
||||
|
||||
The release process for Playlet is very simple, since most of the work is automated.
|
||||
The automation makes `unstable` releases.
|
||||
|
||||
```makefile
|
||||
unstable release + QA = stable version
|
||||
```
|
||||
|
||||
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
|
||||
- This should be already included, just remove the notes about testing the unstable release
|
||||
- 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)
|
||||
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
@@ -0,0 +1,15 @@
|
||||
## Screenshots
|
||||
### Home
|
||||

|
||||
### Search
|
||||

|
||||
### Settings
|
||||

|
||||
### Link to web app
|
||||

|
||||
### App info
|
||||

|
||||
|
||||
### Web app
|
||||
|  |  |  |
|
||||
|----------------------------------|----------------------------------|----------------------------------|
|
||||
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 80 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 358 KiB |
|
After Width: | Height: | Size: 362 KiB |
|
After Width: | Height: | Size: 99 KiB |
@@ -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
|
||||
@@ -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
|
||||
@@ -1,30 +1,29 @@
|
||||
{
|
||||
"name": "playlet",
|
||||
"version": "0.7.0",
|
||||
"version": "0.10.3",
|
||||
"description": "Unofficial Youtube client for Roku",
|
||||
"dependencies": {
|
||||
"bslib": "npm:@rokucommunity/bslib@^0.1.1",
|
||||
"log": "npm:roku-log@^0.9.3",
|
||||
"roku-requests": "^1.1.0"
|
||||
"roku-requests": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rokucommunity/bslint": "^0.8.1",
|
||||
"@types/node": "^18.11.18",
|
||||
"@rokucommunity/bslint": "^0.8.6",
|
||||
"@types/node": "^20.3.1",
|
||||
"argparse": "^2.0.1",
|
||||
"brighterscript": "^0.61.3",
|
||||
"brighterscript-formatter": "^1.6.23",
|
||||
"brighterscript": "^0.65.1",
|
||||
"brighterscript-formatter": "^1.6.29",
|
||||
"convert-svg-to-png": "^0.6.4",
|
||||
"dotenv": "^16.0.3",
|
||||
"cross-fetch": "^4.0.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2",
|
||||
"ip": "^1.1.8",
|
||||
"roku-log-bsc-plugin": "^0.7.0",
|
||||
"ropm": "^0.10.11",
|
||||
"semver": "^7.3.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.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": "<19.0.0"
|
||||
"typescript": "^5.1.3"
|
||||
},
|
||||
"ropm": {
|
||||
"rootDir": "playlet-lib/src",
|
||||
@@ -37,7 +36,8 @@
|
||||
"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 format:fix && npm run lint:fix && npm run manifest-version && npm run generate-images && npm run build:prod && npm run sign-package",
|
||||
"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",
|
||||
@@ -45,16 +45,21 @@
|
||||
"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",
|
||||
"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",
|
||||
"lint:app": "bslint --project playlet/bsconfig.lint.json --lintConfig config/bslint.jsonc",
|
||||
"lint:lib": "bslint --project playlet-lib/bsconfig.lint.json --lintConfig config/bslint.jsonc",
|
||||
"lint": "npm run lint:lib && npm run lint:app",
|
||||
"lint:fix": "npm run lint:lib -- --fix && npm run lint:app -- --fix",
|
||||
"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 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,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
|
||||
@@ -7,8 +7,6 @@ function Init()
|
||||
m.top.ObserveField("rowItemSelected", "OnHomeGridScreenVideoSelected")
|
||||
m.top.ObserveField("focus", "OnFocusChange")
|
||||
m.top.ObserveField("refresh", "OnRefresh")
|
||||
|
||||
InitContent()
|
||||
end function
|
||||
|
||||
function OnFocusChange()
|
||||
@@ -57,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 or not output.success
|
||||
StartFetchTask()
|
||||
return
|
||||
end if
|
||||
|
||||
m.sortedContent.Push(output.result)
|
||||
|
||||
if output.result.rootChildren.Count() > 0
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
@@ -1,5 +1,6 @@
|
||||
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)
|
||||
@@ -15,16 +16,48 @@ function Init()
|
||||
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()
|
||||
@@ -46,6 +79,12 @@ function OnSearchScreenEscape()
|
||||
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
|
||||
@@ -54,14 +93,9 @@ end function
|
||||
|
||||
function OnNavBarEscape()
|
||||
index = m.navBar.escapeIndex
|
||||
if index = 0
|
||||
m.searchScreen.focus = true
|
||||
m.currentFocued = m.searchScreen
|
||||
else if index = 1
|
||||
m.homeGridScreen.focus = true
|
||||
m.currentFocued = m.homeGridScreen
|
||||
else if index = 2
|
||||
m.settingsScreen.focus = true
|
||||
m.navBarScreens[index].node.focus = true
|
||||
if m.navBarScreens[index].canEscape
|
||||
m.currentFocued = m.navBarScreens[index].node
|
||||
end if
|
||||
end function
|
||||
|
||||
@@ -70,29 +104,28 @@ function OnNavIndexChange() as void
|
||||
if index = -1
|
||||
return
|
||||
end if
|
||||
if index = 0
|
||||
m.searchScreen.visible = true
|
||||
m.homeGridScreen.visible = false
|
||||
m.settingsScreen.visible = false
|
||||
else if index = 1
|
||||
m.searchScreen.visible = false
|
||||
m.homeGridScreen.visible = true
|
||||
m.settingsScreen.visible = false
|
||||
else if index = 2
|
||||
m.searchScreen.visible = false
|
||||
m.homeGridScreen.visible = false
|
||||
m.settingsScreen.visible = true
|
||||
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()
|
||||
if m.serverTask.command.StartsWith("play:")
|
||||
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
|
||||
PlayVideo(m.serverTask.command.Mid(5), { sender: sender })
|
||||
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
|
||||
|
||||
@@ -116,5 +149,5 @@ function PlayVideoFromArgs(args as object) as void
|
||||
end if
|
||||
|
||||
sender = m.videoContainer.sender ?? m.currentFocued
|
||||
PlayVideo(args.contentId, { sender: sender })
|
||||
PlayVideo(args.contentId, { sender: sender, timestamp: args.timestamp })
|
||||
end function
|
||||
@@ -5,6 +5,8 @@
|
||||
<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>
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
function SaveSearchHistory(q as string, maxItems = 10 as integer)
|
||||
history = RegistryUtils.Read("search_history")
|
||||
if history <> invalid
|
||||
history = ParseJson(history)
|
||||
else
|
||||
history = []
|
||||
end if
|
||||
|
||||
index = ArrayIndexOf(history, q)
|
||||
if index <> -1
|
||||
history.Delete(index)
|
||||
end if
|
||||
|
||||
history.Unshift(q)
|
||||
|
||||
if history.Count() > maxItems
|
||||
history.Pop()
|
||||
end if
|
||||
|
||||
history = FormatJson(history)
|
||||
|
||||
RegistryUtils.Write("search_history", history)
|
||||
end function
|
||||
|
||||
function GetSavedSearchHistory(q as string) as object
|
||||
history = RegistryUtils.Read("search_history")
|
||||
if history = invalid
|
||||
return []
|
||||
end if
|
||||
history = ParseJson(history)
|
||||
if q = ""
|
||||
return history
|
||||
end if
|
||||
result = []
|
||||
for each keyword in history
|
||||
if keyword.InStr(q) = 0
|
||||
result.push(keyword)
|
||||
end if
|
||||
end for
|
||||
return result
|
||||
end function
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import "pkg:/source/utils/General.bs"
|
||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||
|
||||
@asynctask
|
||||
function AppVersionTask() as object
|
||||
latest = "N/A"
|
||||
args = {
|
||||
parseJson: false
|
||||
}
|
||||
response = Requests().request("HEAD", "https://github.com/iBicha/playlet/releases/latest", args)
|
||||
|
||||
if response.statusCode = 200
|
||||
if response.headers.location <> invalid
|
||||
regex = CreateObject("roRegex", "/v?(\d+\.\d+\.\d+)", "")
|
||||
match = regex.match(response.headers.location)
|
||||
if match.Count() = 2
|
||||
latest = match[1]
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
return {
|
||||
latest: latest
|
||||
}
|
||||
end function
|
||||
@@ -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
|
||||
@@ -1,47 +1,363 @@
|
||||
import "pkg:/source/utils/General.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/asyncTask/asyncTask.bs"
|
||||
import "pkg:/components/SettingsScreen/AppVersionTask.bs"
|
||||
import "pkg:/source/services/PreferencesService.bs"
|
||||
import "pkg:/components/VideoPlayer/Video.bs"
|
||||
|
||||
function Init()
|
||||
m.versionLabel = m.top.findNode("VersionLabel")
|
||||
m.playletLibUrlLabel = m.top.findNode("PlayletLibUrlLabel")
|
||||
m.service = new PreferencesService()
|
||||
|
||||
m.top.url = `http://${GetLocalIpAddress()}:8888`
|
||||
m.menu = m.top.findNode("PreferencesMenu")
|
||||
m.hint = m.top.findNode("HintLabel")
|
||||
|
||||
appInfo = GetAppInfo()
|
||||
m.top.appVersion = appInfo.version
|
||||
m.top.libVersion = appInfo.lib_version
|
||||
LoadPreferencesTopLevel(m.service.prefs_model)
|
||||
RefreshUI(0)
|
||||
|
||||
scene = m.top.getScene()
|
||||
if scene.playletLibLoadedUrl <> invalid
|
||||
m.top.libUrl = `[${scene.playletLibLoadedUrl.type}|${scene.playletLibLoadedUrl.link}]`
|
||||
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
|
||||
GetLatestVersion()
|
||||
end function
|
||||
|
||||
function OnUrlSet()
|
||||
url = m.top.url
|
||||
buttonGroup = CreateSubmenu(container, model, level, key)
|
||||
|
||||
qrCode = m.top.findNode("SettingsQRPoster")
|
||||
qrCode.text = url
|
||||
|
||||
urlLabel = m.top.findNode("urlLabel")
|
||||
urlLabel.text = url
|
||||
end function
|
||||
|
||||
function GetLatestVersion()
|
||||
StartAsyncTask(AppVersionTask, {}, function(output as object) as void
|
||||
if output.result.latest <> invalid
|
||||
m.top.latestVersion = output.result.latest
|
||||
buttons = []
|
||||
for each item in model
|
||||
if item.visibility = "web"
|
||||
continue for
|
||||
end if
|
||||
end function)
|
||||
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 SetVersionLabel()
|
||||
m.versionLabel.text = `Playlet: ${m.top.appVersion} | Playlet-Lib: ${m.top.libVersion} | Latest: ${m.top.latestVersion}`
|
||||
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 SetPlayletLibUrlLabel()
|
||||
m.playletLibUrlLabel.text = `Playlet-Lib: ${m.top.libUrl}`
|
||||
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
|
||||
node = m.top.focusedChild
|
||||
if node = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
while not node.id.StartsWith("Control")
|
||||
child = node.focusedChild
|
||||
if child = invalid
|
||||
return invalid
|
||||
end if
|
||||
if node.isSameNode(child)
|
||||
return invalid
|
||||
end if
|
||||
node = child
|
||||
end while
|
||||
return node
|
||||
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()
|
||||
if focusedControl = invalid
|
||||
return false
|
||||
end if
|
||||
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
|
||||
@@ -2,43 +2,31 @@
|
||||
|
||||
<component name="SettingsScreen" extends="Group">
|
||||
<interface>
|
||||
<field id="appVersion" type="string" value="N/A" onChange="SetVersionLabel" />
|
||||
<field id="libVersion" type="string" value="N/A" onChange="SetVersionLabel" />
|
||||
<field id="latestVersion" type="string" value="N/A" onChange="SetVersionLabel" />
|
||||
<field id="libUrl" type="string" value="N/A" onChange="SetPlayletLibUrlLabel" />
|
||||
<field id="url" type="string" onChange="OnUrlSet" />
|
||||
<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='VersionLabel'
|
||||
height='60'
|
||||
width='1280'
|
||||
font='font:MediumBoldSystemFont'
|
||||
horizAlign="center"
|
||||
translation="[0,80]"
|
||||
/>
|
||||
<Label
|
||||
id='PlayletLibUrlLabel'
|
||||
height='60'
|
||||
width='1280'
|
||||
id="HintLabel"
|
||||
height='100'
|
||||
width='1020'
|
||||
wrap='true'
|
||||
font='font:SmallestBoldSystemFont'
|
||||
horizAlign="center"
|
||||
translation="[0,120]"
|
||||
/>
|
||||
<QRPoster
|
||||
id='SettingsQRPoster'
|
||||
loadWidth='400'
|
||||
loadHeight='400'
|
||||
loadPadding='20'
|
||||
translation='[440, 160]' />
|
||||
|
||||
<Label
|
||||
id='UrlLabel'
|
||||
height='50'
|
||||
width='1280'
|
||||
font='font:MediumBoldSystemFont'
|
||||
horizAlign="center"
|
||||
translation="[0,600]"
|
||||
translation="[130,600]"
|
||||
/>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,52 @@
|
||||
function Init()
|
||||
m.textEditBox = m.top.findNode("TextEditBox")
|
||||
m.top.observeField("focusedChild", "OnFocusChanged")
|
||||
m.top.observeField("value", "OnValueChanged")
|
||||
m.top.observeField("settings", "OnSettingsScreen")
|
||||
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
|
||||
keyboard.close = true
|
||||
end function
|
||||
|
||||
function OnKeyboardClosed() as void
|
||||
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>
|
||||
@@ -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
|
||||
@@ -3,26 +3,14 @@ import "pkg:/source/services/SponsorBlock.bs"
|
||||
@asynctask
|
||||
function SponsorBlockTask(input as object) as object
|
||||
videoId = input.videoId
|
||||
lengthSeconds = input.metadata.lengthSeconds
|
||||
|
||||
sponsorBlockResponse = SponsorBlock.GetSkipSegmentsForVideo(videoId)
|
||||
skipSegments = SponsorBlock.GetSkipSegmentsForVideo(videoId)
|
||||
barPath = invalid
|
||||
|
||||
skipSegments = []
|
||||
if sponsorBlockResponse <> invalid
|
||||
for each segment in sponsorBlockResponse
|
||||
if segment.videoDuration > 0
|
||||
skipSegments.push(segment)
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
if skipSegments.Count() = 0
|
||||
skipSegments = invalid
|
||||
end if
|
||||
|
||||
if skipSegments <> invalid
|
||||
barPath = `tmp:/sponsorblock_bar_${videoId}.png`
|
||||
SponsorBlock.GenerateProgressBarBackground(skipSegments, barPath)
|
||||
SponsorBlock.GenerateProgressBarBackground(skipSegments, lengthSeconds, barPath)
|
||||
end if
|
||||
|
||||
return {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -86,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}`
|
||||
@@ -96,6 +97,9 @@ function OnVideoDetailsTaskResults(output as object) as void
|
||||
else if isAssocArray(metadata.data)
|
||||
message += `\nError: ${FormatJson(metadata.data)}`
|
||||
end if
|
||||
if isstr(metadata.failureReason)
|
||||
message += `\nError: ${metadata.failureReason}`
|
||||
end if
|
||||
ShowDialog(message, "Video load fail")
|
||||
CloseVideo()
|
||||
return
|
||||
@@ -116,30 +120,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
|
||||
|
||||
@@ -159,6 +153,59 @@ function OnVideoDetailsTaskResults(output as object) as void
|
||||
m.top.control = "play"
|
||||
|
||||
m.videoContainer@.watchedVideosAdd(videoId)
|
||||
|
||||
StartSponsorBlockTask()
|
||||
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
|
||||
@@ -244,8 +291,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"
|
||||
@@ -298,6 +348,11 @@ function OnVideoPlayerStateChange() as void
|
||||
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
|
||||
@@ -335,4 +390,5 @@ function OnFullScreenChange()
|
||||
m.translationAnimation.control = "start"
|
||||
|
||||
m.top.enableUI = m.videoContainer.fullscreen
|
||||
SponsorBlockNotifcationSetVisible(m.videoContainer.fullscreen)
|
||||
end function
|
||||
@@ -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
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
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.GetSelectedInstance()
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
|
||||
subtitleTracks = []
|
||||
|
||||
@@ -16,4 +18,37 @@ function SetCaptions(metadata as object, videoPlayer as object, contentNode as o
|
||||
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
|
||||
@@ -1,14 +1,35 @@
|
||||
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")
|
||||
m.chapterLabelTimer.observeField("fire", "OnChapterLabelTimer")
|
||||
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()
|
||||
@@ -81,12 +102,19 @@ function UpdateSponsorBlockChapter(time as integer) as void
|
||||
m.top.chapter = ""
|
||||
end function
|
||||
|
||||
function StartSponsorBlockTask()
|
||||
function StartSponsorBlockTask() as void
|
||||
if not m.sponsorBlockEnabled = true
|
||||
return
|
||||
end if
|
||||
|
||||
if m.sponsorBlockTask <> invalid
|
||||
m.sponsorBlockTask.control = "stop"
|
||||
end if
|
||||
|
||||
m.sponsorBlockTask = StartAsyncTask(SponsorBlockTask, { videoId: m.top.videoId }, OnSponsorBlockTaskResults)
|
||||
m.sponsorBlockTask = StartAsyncTask(SponsorBlockTask, {
|
||||
videoId: m.top.videoId,
|
||||
metadata: m.top.content.metadata
|
||||
}, OnSponsorBlockTaskResults)
|
||||
end function
|
||||
|
||||
function OnSponsorBlockTaskResults(output as object)
|
||||
@@ -105,46 +133,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)
|
||||
|
||||
@@ -33,7 +33,7 @@ function OnContentSet() as void
|
||||
else
|
||||
m.top.FindNode("liveRect").visible = false
|
||||
if content.lengthSeconds <> invalid and content.lengthSeconds <> 0
|
||||
m.top.FindNode("durationLabel").text = TimeUtils.GetFormattedTime(content.lengthSeconds)
|
||||
SetDurationText(TimeUtils.GetFormattedTime(content.lengthSeconds))
|
||||
m.top.FindNode("durationRect").visible = true
|
||||
else
|
||||
m.top.FindNode("durationRect").visible = false
|
||||
@@ -42,6 +42,18 @@ function OnContentSet() as void
|
||||
|
||||
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
|
||||
@@ -87,7 +99,12 @@ function FormatViewCount(viewCount as dynamic) as string
|
||||
end if
|
||||
|
||||
viewCount = viewCount / 1000
|
||||
return `${FormatFloat(viewCount)}M views`
|
||||
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
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="WebAppScreen" extends="Group">
|
||||
<interface>
|
||||
<field id="url" type="string" onChange="OnUrlSet" />
|
||||
</interface>
|
||||
<children>
|
||||
<Label
|
||||
height='60'
|
||||
width='1280'
|
||||
font='font:MediumBoldSystemFont'
|
||||
horizAlign="center"
|
||||
translation="[0,92]"
|
||||
text="Scan the QR code with your phone camera, or open the URL in a web browser:"
|
||||
/>
|
||||
<QRPoster
|
||||
id='SettingsQRPoster'
|
||||
loadWidth='400'
|
||||
loadHeight='400'
|
||||
loadPadding='20'
|
||||
translation='[440, 160]' />
|
||||
|
||||
<Label
|
||||
id='UrlLabel'
|
||||
height='50'
|
||||
width='1280'
|
||||
font='font:MediumBoldSystemFont'
|
||||
horizAlign="center"
|
||||
translation="[0,600]"
|
||||
/>
|
||||
</children>
|
||||
</component>
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -17,25 +17,16 @@ namespace Http
|
||||
v = request.query.v
|
||||
local = request.query.local
|
||||
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
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)
|
||||
return true
|
||||
end if
|
||||
|
||||
if local <> invalid
|
||||
dashUrl = `${dashUrl}?local=${local}`
|
||||
end if
|
||||
|
||||
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
|
||||
|
||||
if resp.statuscode = 200 and metadata <> invalid
|
||||
text = router.InjectStoryBoard(router, text, metadata)
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
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
|
||||
@@ -5,28 +9,6 @@ namespace Http
|
||||
function new()
|
||||
super()
|
||||
|
||||
m.Post("/invidious/instances", function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
instances = request.Json()
|
||||
|
||||
if GetInterface(instances, "ifArray") = invalid
|
||||
response.Default(400, "Expected json array")
|
||||
return true
|
||||
end if
|
||||
|
||||
for i = 0 to instances.Count() - 1
|
||||
if instances[i].right(1) = "/"
|
||||
instances[i] = instances[i].left(instances[i].len() - 1)
|
||||
end if
|
||||
end for
|
||||
|
||||
InvidiousSettings.SetRegistryInstances(instances)
|
||||
response.Default(200, "OK")
|
||||
return true
|
||||
end function)
|
||||
|
||||
m.Get(Invidious.TOKEN_CALLBACK, function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
@@ -36,12 +18,68 @@ namespace Http
|
||||
' Token is encoded twice for some reason
|
||||
token = request.query["token"].DecodeUri().DecodeUriComponent()
|
||||
referer = request.query["ref"].DecodeUri()
|
||||
InvidiousSettings.SetAuthToken(token, referer)
|
||||
username = request.query["username"]
|
||||
scopes = request.query["scopes"]
|
||||
expire = request.query["expire"]
|
||||
|
||||
if username <> invalid
|
||||
username = username.DecodeUriComponent().DecodeUriComponent()
|
||||
end if
|
||||
if scopes <> invalid
|
||||
scopes = scopes.DecodeUriComponent()
|
||||
end if
|
||||
|
||||
InvidiousSettings.SetAuthToken(token, referer, username, scopes, expire)
|
||||
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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
@@ -22,11 +24,15 @@ function WebServerLoop()
|
||||
m.settings = new Http.HttpSettings(m.webServerPort)
|
||||
' Root at www to get http://IP_ADDRESS:PORT/index.html
|
||||
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)
|
||||
|
||||
' TODO: server hangs sometimes when timeout is long. Need to investigate
|
||||
m.settings.Timeout = 500
|
||||
|
||||
#if WEB_SOCKETS
|
||||
' Short interval to keep polling on web socket messages
|
||||
m.settings.Timeout = 500
|
||||
|
||||
m.websocket = new Web.WebSocketServer()
|
||||
m.websocket.OnMessage(function(context as object)
|
||||
connection = context.connection
|
||||
@@ -39,15 +45,24 @@ function WebServerLoop()
|
||||
homeRouter = new Http.HttpRouter()
|
||||
homeRouter.Get("/", function(context as object) as boolean
|
||||
response = context.response
|
||||
response.Redirect("/index.v1.html")
|
||||
response.Redirect("/index.html")
|
||||
return true
|
||||
end function)
|
||||
|
||||
if IsDebugMode()
|
||||
' Redirect to new UI in case someone opens this
|
||||
' TODO: Remove this on September 2023
|
||||
homeRouter.Get("/index.v1.html", function(context as object) as boolean
|
||||
response = context.response
|
||||
response.Redirect("/index.html")
|
||||
return true
|
||||
end function)
|
||||
|
||||
#if DEBUG
|
||||
allowedOrigin = "*"
|
||||
else
|
||||
#else
|
||||
allowedOrigin = `http://${GetLocalIpAddress()}:8888`
|
||||
end if
|
||||
#end if
|
||||
|
||||
m.server.UseRouter(new Http.CorsMiddleware(allowedOrigin))
|
||||
#if WEB_SOCKETS
|
||||
m.server.UseRouter(new Http.WebSocketMiddleware())
|
||||
@@ -56,19 +71,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.SearchHistoryRouter())
|
||||
m.server.UseRouter(new Http.HttpStaticFilesRouter("/", m.settings.WwwRoot, false, false, false))
|
||||
if IsDebugMode()
|
||||
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
|
||||
#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
|
||||
@@ -76,9 +96,10 @@ function WebServerLoop()
|
||||
|
||||
while true
|
||||
m.server.PreWait()
|
||||
m.websocket.Poll()
|
||||
#if WEB_SOCKETS
|
||||
m.websocket.Poll()
|
||||
#end if
|
||||
msg = wait(timeout, msgPort)
|
||||
msg = wait(0, m.port)
|
||||
msgType = type(msg)
|
||||
if msgType = "roSocketEvent" or msg = invalid
|
||||
m.server.PostWait()
|
||||
|
||||
@@ -3,7 +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>
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/Debug.bs" />
|
||||
</component>
|
||||
@@ -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]
|
||||
|
||||
@@ -17,10 +17,9 @@ end function
|
||||
|
||||
function QRModes() as object
|
||||
return {
|
||||
MODE_NUMERIC : 1 << 0
|
||||
MODE_ALPHANUMERIC : 1 << 1
|
||||
MODE_BYTE : 1 << 2
|
||||
MODE_KANJI : 1 << 3
|
||||
MODE_NUMERIC: 1 << 0
|
||||
MODE_ALPHANUMERIC: 1 << 1
|
||||
MODE_BYTE: 1 << 2
|
||||
}
|
||||
end function
|
||||
|
||||
@@ -59,7 +58,7 @@ function QRMath() as object
|
||||
LOG_TABLE[EXP_TABLE[i]] = i
|
||||
end for
|
||||
|
||||
m.QRMath.glog = function (n as integer) as dynamic
|
||||
m.QRMath.glog = function(n as integer) as dynamic
|
||||
if n < 1
|
||||
' print "ERROR: invalid n passed to glog", n
|
||||
return invalid
|
||||
@@ -68,7 +67,7 @@ function QRMath() as object
|
||||
return m.LOG_TABLE[n]
|
||||
end function
|
||||
|
||||
m.QRMath.gexp = function (n as integer) as integer
|
||||
m.QRMath.gexp = function(n as integer) as integer
|
||||
while n < 0
|
||||
n += 255
|
||||
end while
|
||||
@@ -112,7 +111,7 @@ function QRPolynomial(num as object, shift as integer) as object
|
||||
QRMath: QRMath()
|
||||
}
|
||||
|
||||
result.getAt = function (index as integer) as integer
|
||||
result.getAt = function(index as integer) as integer
|
||||
if m._num[index] = invalid
|
||||
return 0
|
||||
else
|
||||
@@ -120,11 +119,11 @@ function QRPolynomial(num as object, shift as integer) as object
|
||||
end if
|
||||
end function
|
||||
|
||||
result.getLength = function () as integer
|
||||
result.getLength = function() as integer
|
||||
return m._num.count()
|
||||
end function
|
||||
|
||||
result.multiply = function (e) as object
|
||||
result.multiply = function(e) as object
|
||||
num = createObject("roArray", m.getLength() + e.getLength() - 1, false)
|
||||
|
||||
for i = 0 to m.getLength() - 1 step 1
|
||||
@@ -132,14 +131,14 @@ function QRPolynomial(num as object, shift as integer) as object
|
||||
if num[i + j] = invalid
|
||||
num[i + j] = 0
|
||||
end if
|
||||
num[i + j] = qrXOR(num[i + j], m.QRMath.gexp(m.QRMath.glog(m.getAt(i)) + m.QRMath.glog(e.getAt(j))))
|
||||
end for
|
||||
end for
|
||||
num[i + j] = qrXOR(num[i + j], m.QRMath.gexp(m.QRMath.glog(m.getAt(i)) + m.QRMath.glog(e.getAt(j))))
|
||||
end for
|
||||
end for
|
||||
|
||||
return QRPolynomial(num, 0)
|
||||
end function
|
||||
|
||||
result.modulo = function (e) as object
|
||||
result.modulo = function(e) as object
|
||||
if m.getLength() - e.getLength() < 0
|
||||
return m
|
||||
end if
|
||||
@@ -165,36 +164,36 @@ end function
|
||||
function QRMaskFunctions() as object
|
||||
result = {}
|
||||
|
||||
result.PATTERN000 = function (i, j) as boolean
|
||||
return (i + j) MOD 2 = 0
|
||||
result.PATTERN000 = function(i, j) as boolean
|
||||
return (i + j) mod 2 = 0
|
||||
end function
|
||||
|
||||
result.PATTERN001 = function (i, _j) as boolean
|
||||
return i MOD 2 = 0
|
||||
|
||||
result.PATTERN001 = function(i, _j) as boolean
|
||||
return i mod 2 = 0
|
||||
end function
|
||||
|
||||
result.PATTERN010 = function (_i, j) as boolean
|
||||
return j MOD 3 = 0
|
||||
|
||||
result.PATTERN010 = function(_i, j) as boolean
|
||||
return j mod 3 = 0
|
||||
end function
|
||||
|
||||
result.PATTERN011 = function (i, j) as boolean
|
||||
return (i + j) MOD 3 = 0
|
||||
|
||||
result.PATTERN011 = function(i, j) as boolean
|
||||
return (i + j) mod 3 = 0
|
||||
end function
|
||||
|
||||
result.PATTERN100 = function (i, j) as boolean
|
||||
return ((i \ 2) + (j \ 3)) MOD 2 = 0
|
||||
|
||||
result.PATTERN100 = function(i, j) as boolean
|
||||
return ((i \ 2) + (j \ 3)) mod 2 = 0
|
||||
end function
|
||||
|
||||
result.PATTERN101 = function (i, j) as boolean
|
||||
return ((i * j) MOD 2) + ((i * j) MOD 3) = 0
|
||||
|
||||
result.PATTERN101 = function(i, j) as boolean
|
||||
return ((i * j) mod 2) + ((i * j) mod 3) = 0
|
||||
end function
|
||||
|
||||
result.PATTERN110 = function (i, j) as boolean
|
||||
return (((i * j) MOD 2) + ((i * j) MOD 3)) MOD 2 = 0
|
||||
|
||||
result.PATTERN110 = function(i, j) as boolean
|
||||
return (((i * j) mod 2) + ((i * j) mod 3)) mod 2 = 0
|
||||
end function
|
||||
|
||||
result.PATTERN111 = function (i, j) as boolean
|
||||
return (((i * j) MOD 3) + ((i + j) MOD 2)) MOD 2 = 0
|
||||
|
||||
result.PATTERN111 = function(i, j) as boolean
|
||||
return (((i * j) mod 3) + ((i + j) mod 2)) mod 2 = 0
|
||||
end function
|
||||
|
||||
return result
|
||||
@@ -266,7 +265,7 @@ function QRUtil() as object
|
||||
|
||||
m.QRUtil = util
|
||||
|
||||
util.getBCHDigit = function (data as integer) as integer
|
||||
util.getBCHDigit = function(data as integer) as integer
|
||||
digit = 0
|
||||
data = abs(data)
|
||||
while data <> 0
|
||||
@@ -279,15 +278,15 @@ function QRUtil() as object
|
||||
util.G15_BCHDigit = util.getBCHDigit(util.G15)
|
||||
util.G18_BCHDigit = util.getBCHDigit(util.G18)
|
||||
|
||||
util.getBCHTypeInfo = function (data as integer) as integer
|
||||
d = data << 10
|
||||
while m.getBCHDigit(d) - m.G15_BCHDigit >= 0
|
||||
d = qrXOR(d, (m.G15 << (m.getBCHDigit(d) - m.G15_BCHDigit)))
|
||||
end while
|
||||
return qrXOR((data << 10) or d, m.G15_MASK)
|
||||
util.getBCHTypeInfo = function(data as integer) as integer
|
||||
d = data << 10
|
||||
while m.getBCHDigit(d) - m.G15_BCHDigit >= 0
|
||||
d = qrXOR(d, (m.G15 << (m.getBCHDigit(d) - m.G15_BCHDigit)))
|
||||
end while
|
||||
return qrXOR((data << 10) or d, m.G15_MASK)
|
||||
end function
|
||||
|
||||
util.getBCHTypeNumber = function (data as integer) as integer
|
||||
util.getBCHTypeNumber = function(data as integer) as integer
|
||||
d = data << 12
|
||||
while m.getBCHDigit(d) - m.G18_BCHDigit >= 0
|
||||
d = qrXOR(d, (m.G18 << (m.getBCHDigit(d) - m.G18_BCHDigit)))
|
||||
@@ -295,11 +294,11 @@ function QRUtil() as object
|
||||
return (data << 12) or d
|
||||
end function
|
||||
|
||||
util.getPatternPosition = function (typeNumber as integer) as object
|
||||
util.getPatternPosition = function(typeNumber as integer) as object
|
||||
return m.PATTERN_POSITION_TABLE[typeNumber - 1]
|
||||
end function
|
||||
|
||||
util.getMaskFunction = function (maskPattern as integer) as function
|
||||
util.getMaskFunction = function(maskPattern as integer) as function
|
||||
masks = QRMaskFunctions()
|
||||
patterns = QRMaskPatterns()
|
||||
|
||||
@@ -315,7 +314,7 @@ function QRUtil() as object
|
||||
return masks[maskId]
|
||||
end function
|
||||
|
||||
util.getErrorCorrectPolynomial = function (errorCorrectLength as integer) as object
|
||||
util.getErrorCorrectPolynomial = function(errorCorrectLength as integer) as object
|
||||
a = QRPolynomial([1], 0)
|
||||
for i = 0 to errorCorrectLength - 1 step 1
|
||||
a = a.multiply(QRPolynomial([1, m.QRMath.gexp(i)], 0))
|
||||
@@ -323,7 +322,7 @@ function QRUtil() as object
|
||||
return a
|
||||
end function
|
||||
|
||||
util.getLengthInBits = function (mode as integer, typeNumber as integer) as integer
|
||||
util.getLengthInBits = function(mode as integer, typeNumber as integer) as integer
|
||||
modes = QRModes()
|
||||
|
||||
if 1 <= typeNumber and typeNumber < 10
|
||||
@@ -331,19 +330,16 @@ function QRUtil() as object
|
||||
if mode = modes.MODE_NUMERIC then return 10
|
||||
if mode = modes.MODE_ALPHANUMERIC then return 9
|
||||
if mode = modes.MODE_BYTE then return 8
|
||||
if mode = modes.MODE_KANJI then return 8
|
||||
else if typeNumber < 27
|
||||
' 10 - 26
|
||||
if mode = modes.MODE_NUMERIC then return 12
|
||||
if mode = modes.MODE_ALPHANUMERIC then return 11
|
||||
if mode = modes.MODE_BYTE then return 16
|
||||
if mode = modes.MODE_KANJI then return 10
|
||||
else if typeNumber < 41
|
||||
' 27 - 40
|
||||
if mode = modes.MODE_NUMERIC then return 14
|
||||
if mode = modes.MODE_ALPHANUMERIC then return 13
|
||||
if mode = modes.MODE_BYTE then return 16
|
||||
if mode = modes.MODE_KANJI then return 12
|
||||
end if
|
||||
|
||||
print "Invalid mode and/or type", mode, typeNumber
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<field id="status" type="string" value="init" /><!-- can be one of: 'init', 'loading', 'ready' -->
|
||||
|
||||
<!-- Public -->
|
||||
<function name="addData" /><!-- params: data string, typeName (NUMERIC, ALPHANUMERIC, BYTE or KANJI) string -->
|
||||
<function name="addData" /><!-- params: data string, typeName (NUMERIC, ALPHANUMERIC or BYTE) string -->
|
||||
<function name="make" /><!-- call AFTER all data is added, to generate modules -->
|
||||
<function name="isDark" /><!-- row integer, col integer, returns boolean -->
|
||||
</interface>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<component name="QRData" extends="Node">
|
||||
|
||||
<interface>
|
||||
@@ -10,7 +10,6 @@
|
||||
<field id="MODE_NUMERIC" type="integer" value="1" />
|
||||
<field id="MODE_ALPHANUMERIC" type="integer" value="2" />
|
||||
<field id="MODE_BYTE" type="integer" value="4" />
|
||||
<field id="MODE_KANJI" type="integer" value="8" />
|
||||
|
||||
<function name="setData" /><!-- string -->
|
||||
<function name="writeToBuffer" /><!-- QRBitBuffer -->
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
sub init()
|
||||
m.top.mode = m.top.MODE_KANJI
|
||||
|
||||
initUnicodeMap()
|
||||
end sub
|
||||
|
||||
' @public
|
||||
' @param textual representation of value
|
||||
sub setData(data as string)
|
||||
m.bytes = stringToBytes(data)
|
||||
m.top.length = m.bytes.count() \ 2
|
||||
end sub
|
||||
|
||||
' @public
|
||||
' @param buffer QRBitBuffer
|
||||
sub writeToBuffer(buffer as object)
|
||||
i = 0
|
||||
data = m.bytes
|
||||
length = data.count()
|
||||
|
||||
while i + 1 < length
|
||||
c = ((&Hff and data[i]) << 8) or (&Hff and data[i + 1])
|
||||
|
||||
if &H8140 <= c and c <= &H9FFC
|
||||
c -= &H8140
|
||||
else if &HE040 <= c and c <= &HEBBF
|
||||
c -= &HC140
|
||||
else
|
||||
print "illegal character at", i + 1, "/", c
|
||||
end if
|
||||
|
||||
c = ((c >> 8) and &Hff) * &HC0 + (c and &Hff)
|
||||
|
||||
buffer.callFunc("put", c, 13)
|
||||
|
||||
i += 2
|
||||
end while
|
||||
|
||||
if i < length
|
||||
print "illegal character at", i + 1
|
||||
end if
|
||||
end sub
|
||||
|
||||
' @private
|
||||
sub initUnicodeMap()
|
||||
if m.UNICODE_MAP <> invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.UNICODE_MAP = m.global.QR_KANJI_MAP
|
||||
if m.UNICODE_MAP = invalid
|
||||
m.UNICODE_MAP = initQRKanjiMap()
|
||||
end if
|
||||
end sub
|
||||
|
||||
' @private
|
||||
function stringToBytes(text as string) as object
|
||||
result = []
|
||||
chars = text.split("")
|
||||
|
||||
unknownChar = asc("?")
|
||||
unicodeMap = m.UNICODE_MAP
|
||||
|
||||
for i = 0 to chars.count() - 1 step 1
|
||||
charcode = asc(chars[i])
|
||||
if charcode < 128
|
||||
result.push(charcode)
|
||||
else
|
||||
byte = unicodeMap[chars[i]]
|
||||
if byte = invalid
|
||||
result.push(unknownChar)
|
||||
else if (byte and &Hff) = byte
|
||||
' 1 byte
|
||||
result.push(byte)
|
||||
else
|
||||
' 2 bytes
|
||||
result.push(byte >> 8)
|
||||
result.push(byte and &Hff)
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
|
||||
return result
|
||||
end function
|
||||
|
||||
' @private
|
||||
function initQRKanjiMap() as object
|
||||
kanjiMap = {}
|
||||
|
||||
ba = createObject("roByteArray")
|
||||
if ba = invalid
|
||||
print "roByteArray is no available"
|
||||
goto finish
|
||||
end if
|
||||
|
||||
data = "AAAAAAABAAEAAgACAAMAAwAEAAQABQAFAAYABgAHAAcACAAIAAkACQAKAAoACwALAAwADAANAA0ADgAOAA8ADwAQABAAEQARABIAEgATABMAFAAUABUAFQAWABYAFwAXABgAGAAZABkAGgAaABsAGwAcABwAHQAdAB4AHgAfAB8AIAAgACEAIQAiACIAIwAjACQAJAAlACUAJgAmACcAJwAoACgAKQApACoAKgArACsALAAsAC0ALQAuAC4ALwAvADAAMAAxADEAMgAyADMAMwA0ADQANQA1ADYANgA3ADcAOAA4ADkAOQA6ADoAOwA7ADwAPAA9AD0APgA+AD8APwBAAEAAQQBBAEIAQgBDAEMARABEAEUARQBGAEYARwBHAEgASABJAEkASgBKAEsASwBMAEwATQBNAE4ATgBPAE8AUABQAFEAUQBSAFIAUwBTAFQAVABVAFUAVgBWAFcAVwBYAFgAWQBZAFoAWgBbAFsAXABcAF0AXQBeAF4AXwBfAGAAYABhAGEAYgBiAGMAYwBkAGQAZQBlAGYAZgBnAGcAaABoAGkAaQBqAGoAawBrAGwAbABtAG0AbgBuAG8AbwBwAHAAcQBxAHIAcgBzAHMAdAB0AHUAdQB2AHYAdwB3AHgAeAB5AHkAegB6AHsAewB8AHwAfQB9AH4AfgB\/AH8AooGRAKOBkgCngZgAqIFOAKyBygCwgYsAsYF9ALSBTAC2gfcA14F+APeBgAORg58DkoOgA5ODoQOUg6IDlYOjA5aDpAOXg6UDmIOmA5mDpwOag6gDm4OpA5yDqgOdg6sDnoOsA5+DrQOgg64DoYOvA6ODsAOkg7EDpYOyA6aDswOng7QDqIO1A6mDtgOxg78DsoPAA7ODwQO0g8IDtYPDA7aDxAO3g8UDuIPGA7mDxwO6g8gDu4PJA7yDygO9g8sDvoPMA7+DzQPAg84DwYPPA8OD0APEg9EDxYPSA8aD0wPHg9QDyIPVA8mD1gQBhEYEEIRABBGEQQQShEIEE4RDBBSERAQVhEUEFoRHBBeESAQYhEkEGYRKBBqESwQbhEwEHIRNBB2ETgQehE8EH4RQBCCEUQQhhFIEIoRTBCOEVAQkhFUEJYRWBCaEVwQnhFgEKIRZBCmEWgQqhFsEK4RcBCyEXQQthF4ELoRfBC+EYAQwhHAEMYRxBDKEcgQzhHMENIR0BDWEdQQ2hHcEN4R4BDiEeQQ5hHoEOoR7BDuEfAQ8hH0EPYR+BD6EgAQ\/hIEEQISCBEGEgwRChIQEQ4SFBESEhgRFhIcERoSIBEeEiQRIhIoESYSLBEqEjARLhI0ETISOBE2EjwROhJAET4SRBFGEdiAQgV0gFIFcIBaBYSAYgWUgGYFmIByBZyAdgWggIIH1ICGB9iAlgWQgJoFjIDCB8SAygYwgM4GNIDuBpiEDgY4hK4HwIZCBqSGRgaohkoGoIZOBqyHSgcsh1IHMIgCBzSICgd0iA4HOIgeB3iIIgbgiC4G5IhKBfCIageMiHYHlIh6BhyIggdoiJ4HIIiiBySIpgb8iKoG+IiuB5yIsgegiNIGIIjWB5iI9geQiUoHgImCBgiJhgd8iZoGFImeBhiJqgeEia4HiIoKBvCKDgb0ihoG6IoeBuyKlgdsjEoHcJQCEnyUBhKolAoSgJQOEqyUMhKElD4SsJRCEoiUThK0lFISkJReEryUYhKMlG4SuJRyEpSUdhLolIIS1JSOEsCUkhKclJYS8JSiEtyUrhLIlLISmJS+EtiUwhLslM4SxJTSEqCU3hLglOIS9JTuEsyU8hKklP4S5JUKEviVLhLQloIGhJaGBoCWygaMls4GiJbyBpSW9gaQlxoGfJceBniXLgZslzoGdJc+BnCXvgfwmBYGaJgaBmSZAgYomQoGJJmqB9CZtgfMmb4HyMACBQDABgUEwAoFCMAOBVjAFgVgwBoFZMAeBWjAIgXEwCYFyMAqBczALgXQwDIF1MA2BdjAOgXcwD4F4MBCBeTARgXowEoGnMBOBrDAUgWswFYFsMByBYDBBgp8wQoKgMEOCoTBEgqIwRYKjMEaCpDBHgqUwSIKmMEmCpzBKgqgwS4KpMEyCqjBNgqswToKsME+CrTBQgq4wUYKvMFKCsDBTgrEwVIKyMFWCszBWgrQwV4K1MFiCtjBZgrcwWoK4MFuCuTBcgrowXYK7MF6CvDBfgr0wYIK+MGGCvzBigsAwY4LBMGSCwjBlgsMwZoLEMGeCxTBogsYwaYLHMGqCyDBrgskwbILKMG2CyzBugswwb4LNMHCCzjBxgs8wcoLQMHOC0TB0gtIwdYLTMHaC1DB3gtUweILWMHmC1zB6gtgwe4LZMHyC2jB9gtswfoLcMH+C3TCAgt4wgYLfMIKC4DCDguEwhILiMIWC4zCGguQwh4LlMIiC5jCJgucwioLoMIuC6TCMguowjYLrMI6C7DCPgu0wkILuMJGC7zCSgvAwk4LxMJuBSjCcgUswnYFUMJ6BVTChg0AwooNBMKODQjCkg0MwpYNEMKaDRTCng0YwqINHMKmDSDCqg0kwq4NKMKyDSzCtg0wwroNNMK+DTjCwg08wsYNQMLKDUTCzg1IwtINTMLWDVDC2g1Uwt4NWMLiDVzC5g1gwuoNZMLuDWjC8g1swvYNcML6DXTC\/g14wwINfMMGDYDDCg2Eww4NiMMSDYzDFg2QwxoNlMMeDZjDIg2cwyYNoMMqDaTDLg2owzINrMM2DbDDOg20wz4NuMNCDbzDRg3Aw0oNxMNODcjDUg3Mw1YN0MNaDdTDXg3Yw2IN3MNmDeDDag3kw24N6MNyDezDdg3ww3oN9MN+DfjDgg4Aw4YOBMOKDgjDjg4Mw5IOEMOWDhTDmg4Yw54OHMOiDiDDpg4kw6oOKMOuDizDsg4ww7YONMO6DjjDvg48w8IOQMPGDkTDyg5Iw84OTMPSDlDD1g5Uw9oOWMPuBRTD8gVsw\/YFSMP6BU04AiOpOAZKaTgOOtU4HlpxOCI\/kTgmOT04Kj+NOC4m6Tg2Vc04Ol15OEJigThGJTk4Uio5OFZihThaQok4XmcBOGIt1ThmVuE4ej+VOIZe8TiaVwE4qmKJOLZKGTjGYo04yi\/hONpikTjiK2045kk9OO47lTjyYpU4\/mKZOQpinTkOUVE5Fi3ZOS5RWTk2T4U5OjMFOT5ZSTlXlaE5WmKhOV4\/mTliYqU5ZibNOXYvjTl6M7k5fludOYpukTnGXkE5zk\/tOfoqjToCLVE6CmKpOhZirToaXuU6Il1xOiZGIToqYrU6LjpZOjJPxTo6YsE6RiV1OkozdTpSM3E6ViOROmJhqTpmYaU6bjbFOnIifTp6YsU6fmLJOoJizTqGWU06imLROpIzwTqWI5U6mlpJOqIucTquLnU6si55OrZLgTq6Xuk6wmLVOs5i2TraYt066kGxOwI9ZTsGQbU7CmLxOxJi6TsaYu07Hi3dOyo2hTsuJ7k7NmLlOzpi4Ts+Vp07UjmVO1Y5kTtaRvE7XmL1O2JV0TtmQ5U7dgVdO3pi+Tt+YwE7jkeNO5JffTuWIyE7tmL9O7om8TvCLwk7ykodO9oyPTveYwU77lENPAYrpTwmYwk8KiMlPDYzeTw6K6k8PlZpPEJSwTxGLeE8aie9PHJjlTx2TYE8vlIxPMJjETzSUuk82l+BPOJBMTzqOZk88jpdPPYm+T0OSz09GkkFPR5jIT02Iyk9OkuFPT49aT1CNsk9Rl0NPU5HMT1WJvU9XmMdPWZddT1qYw09bmMVPXI3sT12Yxk9em0NPaZjOT2+Y0U9wmM9Pc4nAT3WVuU92mMlPe5jNT3yM8U9\/jmdPg4qkT4aY0k+ImMpPi5fhT42OmE+PmMtPkZjQT5aY00+YmMxPm4ufT52Iy0+gi6BPoYm\/T6ubRE+tlplPrpWOT6+M8k+1kE5Ptpe1T7+V1k\/CjFdPw5GjT8SJ4k\/Kj3JPzpjXT9CY3E\/RmNpP1JjVT9eRrU\/YmNhP2pjbT9uY2U\/dldtP35jWT+GQTU\/jlpNP5JjdT+WY3k\/uj0NP75jrT\/OUb0\/1lVVP9pjmT\/iV7k\/6ibRP\/pjqUAWY5FAGmO1QCZFxUAuMwlANlHtQD+DFUBGY7FASk3xQFJjhUBaM9FAZjPNQGpjfUB+O2FAhmOdQI5XtUCSSbFAlmONQJoyRUCiY4FApmOhQKpjiUCuXz1AsmOlQLZhgUDaL5FA5jJBQQ5juUEeY71BImPNQSYjMUE+VzlBQmPJQVZjxUFaY9VBamPRQXJLiUGWMklBsmPZQco7DUHSRpFB1kuNQdov0UHiY91B9i1VQgJj4UIWY+lCNllRQkYyGUJiOUFCZlPVQmpj5UKyNw1Ctl2JQspj8ULOZQlC0mPtQtY3CULePnVC+jFhQwplDUMWLzVDJmUBQyplBUM2TrVDPkZxQ0YuhUNWWbFDWmURQ2pe7UN6ZRVDjmUhQ5ZlGUOeRbVDtmUdQ7plJUPWZS1D5mUpQ+5XGUQCLVlEBmU1RAplOUQSJrVEJmUxREo7yURSZUVEVmVBRFplPURiY1FEamVJRH4+eUSGZU1Eql0RRMpbXUTeZVVE6mVRRO5lXUTyZVlE\/mVhRQJlZUUGI8lFDjLNRRIxaUUWPW1FGkptRR4uiUUiQ5lFJjPVRS42OUUyZW1FNlsZRTpNlUVCOmVFSmVpRVJlcUVqTfVFcipVRYpldUWWT\/FFokVNRaZlfUWqZYFFrlKpRbIz2UW2YWlFumWFRcYukUXWVulF2kbRRd4vvUXiTVFF8jJNRgJliUYKZY1GFk+BRhol+UYmZZlGKjftRjJllUY2NxFGPmWdRkOPsUZGZaFGSlmBRk5lpUZWZalGWmWtRl4\/nUZmOylGgiqVRopluUaSZbFGllrtRppltUaiVeVGpmW9RqplwUauZcVGsk35RsJl1UbGZc1GymXRRs5lyUbSN4VG1mXZRtpboUbeXLine truncated
|
||||
' count = 7070
|
||||
|
||||
ba.fromBase64String(data)
|
||||
|
||||
for i = 0 to ba.count() - 1 step 4
|
||||
b0 = ba[i]
|
||||
b1 = ba[i + 1]
|
||||
b2 = ba[i + 2]
|
||||
b3 = ba[i + 3]
|
||||
k = chr((b0 << 8) or b1)
|
||||
v = (b2 << 8) or b3
|
||||
kanjiMap[k] = v
|
||||
end for
|
||||
|
||||
finish:
|
||||
|
||||
m.global.QR_KANJI_MAP = kanjiMap
|
||||
return kanjiMap
|
||||
end function
|
||||
@@ -1,3 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<component name="QRData_Kanji" extends="QRData">
|
||||
</component>
|
||||
@@ -113,9 +113,6 @@
|
||||
"displayName": "User Feed",
|
||||
"url": "/api/v1/auth/feed",
|
||||
"authenticated": true,
|
||||
"requestArgs": {
|
||||
"retryCount": 3
|
||||
},
|
||||
"responseHandler": "AuthFeedHandler"
|
||||
},
|
||||
{
|
||||
@@ -123,9 +120,6 @@
|
||||
"displayName": "Playlists",
|
||||
"url": "/api/v1/auth/playlists",
|
||||
"authenticated": true,
|
||||
"requestArgs": {
|
||||
"retryCount": 3
|
||||
},
|
||||
"responseHandler": "AuthPlaylistsHandler"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
[
|
||||
{
|
||||
"displayText": "Playback",
|
||||
"key": "playback",
|
||||
"description": "Playback preferences",
|
||||
"children": [
|
||||
{
|
||||
"displayText": "Autoplay",
|
||||
"key": "playback.autoplay",
|
||||
"description": "When you finish a video, another plays automatically",
|
||||
"type": "boolean",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"displayText": "Preferred quality",
|
||||
"key": "playback.preferred_quality",
|
||||
"description": "Preferred video quality",
|
||||
"type": "radio",
|
||||
"defaultValue": "auto",
|
||||
"options": [
|
||||
{
|
||||
"displayText": "Auto",
|
||||
"value": "auto"
|
||||
},
|
||||
{
|
||||
"displayText": "720p",
|
||||
"value": "720p"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"displayText": "Invidious",
|
||||
"key": "invidious",
|
||||
"description": "Invidious preferences",
|
||||
"children": [
|
||||
{
|
||||
"displayText": "Instance",
|
||||
"key": "invidious.instance",
|
||||
"description": "Invidious instance to use. Example: https://vid.puffyan.us",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"displayText": "Proxy videos",
|
||||
"key": "invidious.proxy_videos",
|
||||
"description": "Proxy videos through the Invidious server. This is useful if videos are geoblocked.",
|
||||
"type": "radio",
|
||||
"defaultValue": "if_needed",
|
||||
"options": [
|
||||
{
|
||||
"displayText": "Always",
|
||||
"value": "always"
|
||||
},
|
||||
{
|
||||
"displayText": "Only if needed",
|
||||
"value": "if_needed"
|
||||
},
|
||||
{
|
||||
"displayText": "Never",
|
||||
"value": "never"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"displayText": "SponsorBlock",
|
||||
"key": "sponsorblock",
|
||||
"description": "SponsorBlock preferences",
|
||||
"children": [
|
||||
{
|
||||
"displayText": "Enabled",
|
||||
"key": "sponsorblock.enabled",
|
||||
"description": "Enable SponsorBlock",
|
||||
"type": "boolean",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"displayText": "Show notifications",
|
||||
"key": "sponsorblock.show_notifications",
|
||||
"description": "Show notifications when a segment is skipped",
|
||||
"type": "boolean",
|
||||
"defaultValue": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"displayText": "Search History",
|
||||
"key": "search_history",
|
||||
"description": "Search history preferences",
|
||||
"children": [
|
||||
{
|
||||
"displayText": "Clear Search History",
|
||||
"key": "search_history.clear_search_history",
|
||||
"description": "Clear search history from Playlet. This affects the search suggestions. This does not affect the watch history on Invidious.",
|
||||
"visibility": "web",
|
||||
"svelteComponent": "ClearSearchHistoryControl"
|
||||
},
|
||||
{
|
||||
"displayText": "Clear Search History",
|
||||
"key": "search_history.clear_search_history",
|
||||
"description": "Clear search history from Playlet. This affects the search suggestions. This does not affect the watch history on Invidious.",
|
||||
"visibility": "tv",
|
||||
"rokuComponent": "ClearSearchHistoryControl"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,115 @@
|
||||
{
|
||||
"serverAddress": "https://sponsor.ajay.app",
|
||||
"categoryList": [
|
||||
"sponsor",
|
||||
"selfpromo",
|
||||
"exclusive_access",
|
||||
"interaction",
|
||||
"poi_highlight",
|
||||
"intro",
|
||||
"outro",
|
||||
"preview",
|
||||
"filler",
|
||||
"chapter",
|
||||
"music_offtopic"
|
||||
],
|
||||
"categories": {
|
||||
"sponsor": {
|
||||
"title": "Sponsor",
|
||||
"short_title": "Sponsor",
|
||||
"categorySupport": [
|
||||
"skip",
|
||||
"mute",
|
||||
"full"
|
||||
],
|
||||
"color": "#00d400B3"
|
||||
},
|
||||
"selfpromo": {
|
||||
"title": "Unpaid/Self Promotion",
|
||||
"short_title": "Unpaid/Self Promotion",
|
||||
"categorySupport": [
|
||||
"skip",
|
||||
"mute",
|
||||
"full"
|
||||
],
|
||||
"color": "#ffff00B3"
|
||||
},
|
||||
"exclusive_access": {
|
||||
"title": "Exclusive Access",
|
||||
"short_title": "Exclusive Access",
|
||||
"categorySupport": [
|
||||
"full"
|
||||
],
|
||||
"color": "#008a5cB3"
|
||||
},
|
||||
"interaction": {
|
||||
"title": "Interaction Reminder (Subscribe)",
|
||||
"short_title": "Interaction Reminder",
|
||||
"categorySupport": [
|
||||
"skip",
|
||||
"mute"
|
||||
],
|
||||
"color": "#cc00ffB3"
|
||||
},
|
||||
"poi_highlight": {
|
||||
"title": "Highlight",
|
||||
"short_title": "Highlight",
|
||||
"categorySupport": [
|
||||
"poi"
|
||||
],
|
||||
"color": "#ff1684B3"
|
||||
},
|
||||
"intro": {
|
||||
"title": "Intermission/Intro Animation",
|
||||
"short_title": "Intermission",
|
||||
"categorySupport": [
|
||||
"skip",
|
||||
"mute"
|
||||
],
|
||||
"color": "#00ffffB3"
|
||||
},
|
||||
"outro": {
|
||||
"title": "Endcards/Credits",
|
||||
"short_title": "Endcards/Credits",
|
||||
"categorySupport": [
|
||||
"skip",
|
||||
"mute"
|
||||
],
|
||||
"color": "#0202edB3"
|
||||
},
|
||||
"preview": {
|
||||
"title": "Preview/Recap",
|
||||
"short_title": "Preview/Recap",
|
||||
"categorySupport": [
|
||||
"skip",
|
||||
"mute"
|
||||
],
|
||||
"color": "#008fd6B3"
|
||||
},
|
||||
"filler": {
|
||||
"title": "Filler Tangent/Jokes",
|
||||
"short_title": "Filler",
|
||||
"categorySupport": [
|
||||
"skip",
|
||||
"mute"
|
||||
],
|
||||
"color": "#7300FFE6"
|
||||
},
|
||||
"chapter": {
|
||||
"title": "Chapter",
|
||||
"short_title": "Chapter",
|
||||
"categorySupport": [
|
||||
"chapter"
|
||||
],
|
||||
"color": "#FFFFFFC8"
|
||||
},
|
||||
"music_offtopic": {
|
||||
"title": "Music: Non-Music Section",
|
||||
"short_title": "Non-Music",
|
||||
"categorySupport": [
|
||||
"skip"
|
||||
],
|
||||
"color": "#ff9900B3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 517 B |
@@ -2,10 +2,12 @@ title=PlayletLib
|
||||
|
||||
# Do not update version manually, it is auto updated from package.json
|
||||
major_version=0
|
||||
minor_version=7
|
||||
build_version=00000
|
||||
minor_version=10
|
||||
build_version=00003
|
||||
|
||||
sg_component_libs_provided=PlayletLib
|
||||
hidden=1
|
||||
|
||||
bs_const=DEBUG=false;WEB_SERVER_BASIC_AUTH=false;DASH_THUMBNAILS=false;WEB_SOCKETS=true
|
||||
git_commit_sha=unknown
|
||||
|
||||
bs_const=DEBUG=false;WEB_SERVER_BASIC_AUTH=false;DASH_THUMBNAILS=false;WEB_SOCKETS=false;CAPTION_INSTANCE_SEARCH=false
|
||||
@@ -13,14 +13,19 @@ namespace Invidious
|
||||
const STATS_ENDPOINT = "/api/v1/stats"
|
||||
|
||||
const VIDEOS_ENDPOINT = "/api/v1/videos"
|
||||
const PLAYLISTS_ENDPOINT = "/api/v1/playlists"
|
||||
const HISTORY_ENDPOINT = "/api/v1/auth/history"
|
||||
|
||||
const SEARCH_SUGGEST_ENDPOINT = "/api/v1/search/suggestions"
|
||||
const SEARCH_ENDPOINT = "/api/v1/search"
|
||||
|
||||
const AUTH_SCOPE = "GET:feed,GET:playlists,POST:tokens/unregister"
|
||||
const AUTH_SCOPES = "GET:feed,GET:playlists,POST:tokens/register,POST:tokens/unregister,POST:history*"
|
||||
const AUTH_FEED = "/api/v1/auth/feed"
|
||||
const AUTH_PLAYLISTS = "/api/v1/auth/playlists"
|
||||
const AUTH_TOKENS_UNREGISTER = "/api/v1/auth/tokens/unregister"
|
||||
const AUTH_TOKENS_REGISTER = "/api/v1/auth/tokens/register"
|
||||
|
||||
const TOKEN_TIMESPAN = 60 * 60 * 24 * 365 * 2 '2 years
|
||||
|
||||
function DefaultArgs() as object
|
||||
return {
|
||||
@@ -31,7 +36,7 @@ namespace Invidious
|
||||
end function
|
||||
|
||||
function GetServerStats() as object
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
url = `${instance}${Invidious.STATS_ENDPOINT}`
|
||||
|
||||
response = Requests().get(url)
|
||||
@@ -41,17 +46,26 @@ namespace Invidious
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function GetVideoUrl(videoId as string, itag as string, local as boolean) as string
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
url = `${instance}/latest_version?id=${videoId}&itag=${itag}`
|
||||
function GetVideoStreamUrl(videoId as string, local as boolean) as string
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
url = `${instance}/latest_version?id=${videoId}`
|
||||
if local
|
||||
url = url + "&local=true"
|
||||
end if
|
||||
return url
|
||||
end function
|
||||
|
||||
function GetVideoDashUrl(videoId as string, local as boolean) as string
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
url = `${instance}/api/manifest/dash/id/${videoId}`
|
||||
if local
|
||||
url = url + "?local=true"
|
||||
end if
|
||||
return url
|
||||
end function
|
||||
|
||||
function GetVideoMetadata(videoId as string) as object
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
|
||||
|
||||
args = Invidious.DefaultArgs()
|
||||
@@ -60,14 +74,44 @@ namespace Invidious
|
||||
response = Requests().get(url, args)
|
||||
|
||||
return {
|
||||
success: response.statuscode = 200,
|
||||
success: response.ok,
|
||||
statusCode: response.statuscode,
|
||||
data: response.json ?? response.text
|
||||
data: response.json,
|
||||
failureReason: response.GetFailureReason
|
||||
}
|
||||
end function
|
||||
|
||||
function GetPlaylist(playlistId as string) as object
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
url = `${instance}${Invidious.PLAYLISTS_ENDPOINT}/${playlistId}`
|
||||
|
||||
args = Invidious.DefaultArgs()
|
||||
response = Requests().get(url, args)
|
||||
if not response.ok
|
||||
return invalid
|
||||
end if
|
||||
return response.json
|
||||
end function
|
||||
|
||||
function MarkVideoWatched(videoId as string) as boolean
|
||||
authToken = InvidiousSettings.GetAuthToken()
|
||||
if authToken = invalid
|
||||
return false
|
||||
end if
|
||||
|
||||
url = `${authToken.instance}${Invidious.HISTORY_ENDPOINT}/${videoId}`
|
||||
headers = Invidious.GetAuthenticationHeaders(authToken.token)
|
||||
args = {
|
||||
headers: headers,
|
||||
parseJson: false
|
||||
}
|
||||
|
||||
response = Requests().post(url, args)
|
||||
return response.ok
|
||||
end function
|
||||
|
||||
function SearchSuggestions(q as string) as object 'SearchSuggestionResult
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
url = `${instance}${Invidious.SEARCH_SUGGEST_ENDPOINT}`
|
||||
|
||||
args = Invidious.DefaultArgs()
|
||||
@@ -83,7 +127,7 @@ namespace Invidious
|
||||
end function
|
||||
|
||||
function Search(q as string, args = invalid as dynamic) as object
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
url = `${instance}${Invidious.SEARCH_ENDPOINT}`
|
||||
|
||||
_args = Invidious.DefaultArgs()
|
||||
@@ -118,16 +162,17 @@ namespace Invidious
|
||||
end function
|
||||
|
||||
function GetAuthorizeTokenLink() as string
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
' Make sure the host is not on https, because https cannot redirect to http, which is our local server
|
||||
invidiousHost = instance.Replace("https://", "http://")
|
||||
|
||||
localIp = GetLocalIpAddress()
|
||||
webServerPort = 8888
|
||||
expire = TimeUtils.Now().AsSeconds() + 60 * 60 * 24 * 365 * 2 '2 years from now
|
||||
expire = TimeUtils.Now().AsSeconds() + TOKEN_TIMESPAN
|
||||
|
||||
callbackUrl = `http://${localIp}:${webServerPort}${Invidious.TOKEN_CALLBACK}?ref=${instance}`.EncodeUriComponent()
|
||||
return `${invidiousHost}/authorize_token?scopes=${Invidious.AUTH_SCOPE}&callback_url=${callbackUrl}&expire=${expire}`
|
||||
scope = `${Invidious.AUTH_SCOPES}`.EncodeUriComponent()
|
||||
return `${invidiousHost}/authorize_token?scopes=${scope}&callback_url=${callbackUrl}&expire=${expire}`
|
||||
end function
|
||||
|
||||
function GetAuthenticationHeaders(token as string) as object
|
||||
@@ -136,11 +181,63 @@ namespace Invidious
|
||||
}
|
||||
end function
|
||||
|
||||
function Logout() as boolean
|
||||
authToken = InvidiousSettings.GetAuthToken()
|
||||
if authToken = invalid
|
||||
function RefreshAuthToken() as boolean
|
||||
currentAuthToken = InvidiousSettings.GetAuthToken()
|
||||
if currentAuthToken = invalid
|
||||
return false
|
||||
end if
|
||||
|
||||
expire = TimeUtils.Now().AsSeconds() + TOKEN_TIMESPAN
|
||||
|
||||
newToken = RegisterToken(currentAuthToken, expire)
|
||||
if newToken = invalid
|
||||
return false
|
||||
end if
|
||||
InvidiousSettings.SetAuthToken(newToken.token, newToken.instance, newToken.username, newToken.scopes, newToken.expire)
|
||||
|
||||
UnregisterToken(currentAuthToken)
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
function RegisterToken(authToken as object, expire as integer) as dynamic
|
||||
headers = Invidious.GetAuthenticationHeaders(authToken.token)
|
||||
url = `${authToken.instance}${Invidious.AUTH_TOKENS_REGISTER}`
|
||||
|
||||
scopes = authToken.scopes
|
||||
if scopes = invalid
|
||||
parsedToken = ParseJson(authToken.token)
|
||||
if GetInterface(parsedToken.scopes, "ifArray") <> invalid
|
||||
scopes = parsedToken.scopes.join(",")
|
||||
else
|
||||
scopes = Invidious.AUTH_SCOPES
|
||||
end if
|
||||
end if
|
||||
|
||||
args = {
|
||||
headers: headers,
|
||||
json: {
|
||||
"scopes": scopes.Split(","),
|
||||
"expire": expire
|
||||
},
|
||||
parseJson: false
|
||||
}
|
||||
|
||||
response = Requests().post(url, args)
|
||||
if not response.ok
|
||||
return invalid
|
||||
end if
|
||||
|
||||
return {
|
||||
token: response.text,
|
||||
instance: authToken.instance,
|
||||
username: authToken.username,
|
||||
scopes: scopes,
|
||||
expire: expire
|
||||
}
|
||||
end function
|
||||
|
||||
function UnregisterToken(authToken as object) as boolean
|
||||
headers = Invidious.GetAuthenticationHeaders(authToken.token)
|
||||
|
||||
url = `${authToken.instance}${Invidious.AUTH_TOKENS_UNREGISTER}`
|
||||
@@ -149,10 +246,21 @@ namespace Invidious
|
||||
headers["Content-Type"] = "application/json"
|
||||
args = {
|
||||
headers: headers,
|
||||
data: authToken.token
|
||||
data: authToken.token,
|
||||
parseJson: false
|
||||
}
|
||||
|
||||
Requests().post(url, args)
|
||||
response = Requests().post(url, args)
|
||||
return response.ok
|
||||
end function
|
||||
|
||||
function Logout() as boolean
|
||||
authToken = InvidiousSettings.GetAuthToken()
|
||||
if authToken = invalid
|
||||
return false
|
||||
end if
|
||||
|
||||
UnregisterToken(authToken)
|
||||
|
||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
|
||||
return true
|
||||
|
||||
@@ -2,7 +2,9 @@ import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||
import "pkg:/source/utils/TimeUtils.bs"
|
||||
import "pkg:/source/utils/RegistryUtils.bs"
|
||||
import "pkg:/source/utils/General.bs"
|
||||
import "pkg:/source/utils/Crypto.bs"
|
||||
import "pkg:/source/services/InvidiousSettings.bs"
|
||||
import "pkg:/source/services/Invidious.bs"
|
||||
|
||||
class InvidiousService
|
||||
private endpoints
|
||||
@@ -30,7 +32,7 @@ class InvidiousService
|
||||
return invalid
|
||||
end if
|
||||
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
|
||||
url = instance + endpoint.url
|
||||
|
||||
@@ -72,15 +74,18 @@ class InvidiousService
|
||||
end for
|
||||
end if
|
||||
|
||||
if endpoint.requestArgs <> invalid
|
||||
args.append(endpoint.requestArgs)
|
||||
end if
|
||||
|
||||
response = Requests().get(url, args)
|
||||
|
||||
responseHandler = endpoint.responseHandler <> invalid ? m.responseHanlders[endpoint.responseHandler] : m.responseHanlders["DefaultHandler"]
|
||||
|
||||
return responseHandler(m, requestData, response)
|
||||
result = responseHandler(m, requestData, response)
|
||||
|
||||
if result <> invalid and endpoint.authenticated = true
|
||||
' Cache response for use by web app
|
||||
m.CacheResponse(requestData, result)
|
||||
end if
|
||||
|
||||
return result
|
||||
end function
|
||||
|
||||
function GetAuthenticationHeaders(token as string) as object
|
||||
@@ -91,7 +96,7 @@ class InvidiousService
|
||||
|
||||
function DefaultHandler(m as object, requestData as object, response as object) as object
|
||||
if response.statuscode = 200
|
||||
return response.json
|
||||
return [{ title: requestData.title, videos: response.json }]
|
||||
end if
|
||||
return invalid
|
||||
end function
|
||||
@@ -103,7 +108,7 @@ class InvidiousService
|
||||
videos = []
|
||||
videos.Append(response.json.notifications)
|
||||
videos.Append(response.json.videos)
|
||||
return videos
|
||||
return [{ title: requestData.title, videos: videos }]
|
||||
end if
|
||||
return invalid
|
||||
end function
|
||||
@@ -112,9 +117,16 @@ class InvidiousService
|
||||
m.DeleteExpiredToken(response)
|
||||
if response.statuscode = 200
|
||||
playlists = response.json
|
||||
result = {}
|
||||
result = []
|
||||
for each playlist in playlists
|
||||
result.append(m.ProcessPlaylist(requestData, playlist))
|
||||
' Saved playlists are not included in the response
|
||||
' https://github.com/iv-org/invidious/issues/3995
|
||||
if playlist.videos.count() = 0 and playlist.authorId = invalid and not playlist.playlistId.StartsWith("IV")
|
||||
playlist = Invidious.GetPlaylist(playlist.playlistId)
|
||||
end if
|
||||
if playlist <> invalid
|
||||
result.push(m.ProcessPlaylist(requestData, playlist))
|
||||
end if
|
||||
end for
|
||||
return result
|
||||
end if
|
||||
@@ -124,17 +136,14 @@ class InvidiousService
|
||||
function PlaylistHandler(m as object, requestData as object, response as object) as object
|
||||
if response.statuscode = 200
|
||||
playlist = response.json
|
||||
return m.ProcessPlaylist(requestData, playlist)
|
||||
return [m.ProcessPlaylist(requestData, playlist)]
|
||||
end if
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function ProcessPlaylist(requestData as object, playlist as object) as object
|
||||
title = requestData.title
|
||||
title = m.ProcessTemplate(title, playlist)
|
||||
result = {}
|
||||
result[title] = playlist.videos
|
||||
return result
|
||||
title = m.ProcessTemplate(requestData.title, playlist)
|
||||
return { title: title, videos: playlist.videos }
|
||||
end function
|
||||
|
||||
function ProcessTemplate(template as string, data as object) as string
|
||||
@@ -146,30 +155,16 @@ class InvidiousService
|
||||
|
||||
function DeleteExpiredToken(response as object)
|
||||
if response.statuscode = 403
|
||||
print(`Server responded with 403: ${response.text}`)
|
||||
if m.IsTokenMaybeExpired() = true
|
||||
print("deleting token...")
|
||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
|
||||
end if
|
||||
print(`Invidious instance responded with 403: ${response.text}`)
|
||||
print("Deleting Invidious token...")
|
||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
|
||||
end if
|
||||
end function
|
||||
|
||||
' Public Invidious instances fail a lot randomly, even with valid tokens
|
||||
' For that reason, it's better to make sure the token actually expired by date
|
||||
function IsTokenMaybeExpired() as dynamic
|
||||
authToken = InvidiousSettings.GetAuthToken()
|
||||
if authToken = invalid
|
||||
return invalid
|
||||
end if
|
||||
token = ParseJson(authToken.token)
|
||||
if token = invalid
|
||||
return invalid
|
||||
end if
|
||||
if not token.DoesExist("expire")
|
||||
return invalid
|
||||
end if
|
||||
expire = token["expire"]
|
||||
currentTime = TimeUtils.Now().AsSeconds()
|
||||
return expire < currentTime
|
||||
function CacheResponse(requestData as object, result as object)
|
||||
cacheKey = FormatJson(requestData)
|
||||
cacheKey = GetMd5(cacheKey)
|
||||
value = FormatJson(result)
|
||||
WriteAsciiFile(`tmp:/${cacheKey}.json`, value)
|
||||
end function
|
||||
end class
|
||||
@@ -1,54 +1,43 @@
|
||||
import "pkg:/source/utils/RegistryUtils.bs"
|
||||
import "pkg:/components/SettingsScreen/Settings.bs"
|
||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||
|
||||
namespace InvidiousSettings
|
||||
|
||||
const DEFAULT_INSTANCE = "https://vid.puffyan.us"
|
||||
|
||||
const INSTANCES_API = "https://api.invidious.io/instances.json?sort_by=type,users"
|
||||
|
||||
function GetCurrentInstances() as object
|
||||
' TODO: cache this call to avoid json parsing every time
|
||||
instances = InvidiousSettings.GetRegistryInstances()
|
||||
if instances.Count() > 0
|
||||
return instances
|
||||
function GetCurrentInstance() as object
|
||||
settings = FindAndGetPreferenceValues(["invidious.instance"])
|
||||
if settings <> invalid and settings["invidious.instance"] <> invalid and settings["invidious.instance"] <> ""
|
||||
return settings["invidious.instance"]
|
||||
end if
|
||||
|
||||
publicInstances = InvidiousSettings.GetPublicInstances()
|
||||
if publicInstances <> invalid
|
||||
for i = 0 to publicInstances.Count() - 1
|
||||
if InvidiousSettings.IsValidPublicInstance(publicInstances[i])
|
||||
instances.push(publicInstances[i].uri)
|
||||
end if
|
||||
if instances.Count() >= 5
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
backupInstances = InvidiousSettings.GetBackupInstances()
|
||||
if backupInstances.Count() > 0
|
||||
return backupInstances[0]
|
||||
end if
|
||||
|
||||
if instances.Count() > 0
|
||||
InvidiousSettings.SetRegistryInstances(instances)
|
||||
return instances
|
||||
end if
|
||||
|
||||
return [InvidiousSettings.DEFAULT_INSTANCE]
|
||||
return InvidiousSettings.DEFAULT_INSTANCE
|
||||
end function
|
||||
|
||||
function GetSelectedInstance() as string
|
||||
instances = InvidiousSettings.GetCurrentInstances()
|
||||
return instances[0]
|
||||
end function
|
||||
|
||||
function SetAuthToken(token as string, instance as string)
|
||||
json = FormatJson({
|
||||
function SetAuthToken(token as string, instance as string, username as dynamic, scopes as dynamic, expire as dynamic)
|
||||
obj = {
|
||||
token: token,
|
||||
instance: instance
|
||||
})
|
||||
RegistryUtils.Write(RegistryUtils.INVIDIOUS_TOKEN, json)
|
||||
|
||||
instances = InvidiousSettings.GetCurrentInstances()
|
||||
index = ArrayIndexOf(instances, instance)
|
||||
if index = -1
|
||||
instances.push(instance)
|
||||
InvidiousSettings.SetRegistryInstances(instances)
|
||||
}
|
||||
if username <> invalid
|
||||
obj.username = username
|
||||
end if
|
||||
if scopes <> invalid
|
||||
obj.scopes = scopes
|
||||
end if
|
||||
if expire <> invalid
|
||||
obj.expire = expire
|
||||
end if
|
||||
|
||||
json = FormatJson(obj)
|
||||
RegistryUtils.Write(RegistryUtils.INVIDIOUS_TOKEN, json)
|
||||
end function
|
||||
|
||||
function GetAuthToken() as dynamic
|
||||
@@ -56,30 +45,42 @@ namespace InvidiousSettings
|
||||
if tokenPayload = invalid
|
||||
return invalid
|
||||
end if
|
||||
return ParseJson(tokenPayload)
|
||||
end function
|
||||
|
||||
function GetRegistryInstances() as object
|
||||
instances = RegistryUtils.Read(RegistryUtils.INVIDIOUS_INSTANCES)
|
||||
if instances = invalid
|
||||
return []
|
||||
authData = ParseJson(tokenPayload)
|
||||
if authData = invalid or authData.instance = invalid or authData.token = invalid
|
||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
|
||||
return invalid
|
||||
end if
|
||||
return ParseJson(instances)
|
||||
return authData
|
||||
end function
|
||||
|
||||
function SetRegistryInstances(instances as object)
|
||||
RegistryUtils.Write(RegistryUtils.INVIDIOUS_INSTANCES, FormatJson(instances))
|
||||
function GetBackupInstances() as object
|
||||
if m.global.hasField("invidiousBackupInstances")
|
||||
return m.global.invidiousBackupInstances
|
||||
end if
|
||||
return []
|
||||
end function
|
||||
|
||||
function FetchBackupInstances() as object
|
||||
backupInstances = []
|
||||
publicInstances = InvidiousSettings.GetPublicInstances()
|
||||
for i = 0 to publicInstances.Count() - 1
|
||||
if InvidiousSettings.IsValidPublicInstance(publicInstances[i])
|
||||
backupInstances.push(publicInstances[i].uri)
|
||||
end if
|
||||
if backupInstances.Count() >= 5
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
|
||||
return backupInstances
|
||||
end function
|
||||
|
||||
function GetPublicInstances() as object
|
||||
if m.invidiousPublicInstances <> invalid
|
||||
return m.invidiousPublicInstances
|
||||
end if
|
||||
instances = []
|
||||
|
||||
response = Requests().get(InvidiousSettings.INSTANCES_API)
|
||||
if response.statuscode = 200
|
||||
json = response.json
|
||||
instances = []
|
||||
|
||||
for each instance in json
|
||||
data = instance[1]
|
||||
@@ -90,10 +91,9 @@ namespace InvidiousSettings
|
||||
instances.push(data)
|
||||
end for
|
||||
|
||||
m.invidiousPublicInstances = instances
|
||||
end if
|
||||
|
||||
return m.invidiousPublicInstances
|
||||
return instances
|
||||
end function
|
||||
|
||||
function IsValidPublicInstance(instance as object) as boolean
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
import "pkg:/source/utils/RegistryUtils.bs"
|
||||
|
||||
class PreferencesService
|
||||
private version = 1
|
||||
private prefs_model
|
||||
private user_prefs
|
||||
|
||||
function new()
|
||||
m.LoadConfigFile()
|
||||
m.LoadUserPreferences()
|
||||
end function
|
||||
|
||||
function LoadConfigFile()
|
||||
m.prefs_model = ParseJson(ReadAsciiFile("libpkg:/config/preferences.json"))
|
||||
end function
|
||||
|
||||
function LoadUserPreferences()
|
||||
' Step 1: Load user preferences from registry
|
||||
m.user_prefs = RegistryUtils.Read(RegistryUtils.USER_PREFERENCES)
|
||||
if m.user_prefs = invalid
|
||||
m.user_prefs = "{}"
|
||||
end if
|
||||
m.user_prefs = ParseJson(m.user_prefs)
|
||||
' Step 2: Migrate existing preferences to new format (if needed)
|
||||
isDirty = m.MigrateExistingPreferences()
|
||||
' Step 3: Apply defaults to user preferences (if needed)
|
||||
isDirty = m.ApplyDefaultsToUserPreferences() or isDirty
|
||||
if isDirty
|
||||
m.SaveUserPreferences()
|
||||
end if
|
||||
end function
|
||||
|
||||
function SaveUserPreferences()
|
||||
m.user_prefs.__version = m.version
|
||||
RegistryUtils.Write(RegistryUtils.USER_PREFERENCES, FormatJson(m.user_prefs))
|
||||
end function
|
||||
|
||||
function MigrateExistingPreferences() as boolean
|
||||
isDirty = false
|
||||
|
||||
' v0 -> v1
|
||||
instances = RegistryUtils.Read(RegistryUtils.INVIDIOUS_INSTANCES)
|
||||
if instances <> invalid
|
||||
currentInstance = m.user_prefs["invidious.instance"]
|
||||
if currentInstance = invalid or currentInstance = ""
|
||||
instances = ParseJson(instances)
|
||||
if instances.Count() > 0
|
||||
instance = instances[0]
|
||||
if instance <> invalid and instance <> ""
|
||||
m.user_prefs["invidious.instance"] = instance
|
||||
isDirty = true
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES)
|
||||
end if
|
||||
|
||||
' v1 -> v2 goes here (if needed)
|
||||
' if m.user_prefs.__version = 1
|
||||
' 'do stuff
|
||||
' end if
|
||||
|
||||
' TODO: handle case where saved preferences version is higher than current version (e.g. user downgraded)
|
||||
return isDirty
|
||||
end function
|
||||
|
||||
function ApplyDefaultsToUserPreferences() as boolean
|
||||
isDirty = false
|
||||
for each child in m.prefs_model
|
||||
isDirty = m.ApplyToUserPreferences(m.user_prefs, child) or isDirty
|
||||
end for
|
||||
return isDirty
|
||||
end function
|
||||
|
||||
function ApplyToUserPreferences(userPrefs as object, model as object) as boolean
|
||||
isDirty = false
|
||||
if model.children <> invalid
|
||||
for each child in model.children
|
||||
isDirty = m.ApplyToUserPreferences(userPrefs, child) or isDirty
|
||||
end for
|
||||
end if
|
||||
|
||||
if model.defaultValue <> invalid and (not userPrefs.DoesExist(model.key) or userPrefs[model.key] = invalid)
|
||||
userPrefs[model.key] = model.defaultValue
|
||||
isDirty = true
|
||||
end if
|
||||
return isDirty
|
||||
end function
|
||||
|
||||
function GetUserPreferences() as object
|
||||
return m.user_prefs
|
||||
end function
|
||||
|
||||
function ApplyUserPreferences(preferences as object) as void
|
||||
if preferences = invalid
|
||||
return
|
||||
end if
|
||||
' TODO: user input validation
|
||||
for each key in preferences
|
||||
m.user_prefs[key] = preferences[key]
|
||||
end for
|
||||
m.SaveUserPreferences()
|
||||
end function
|
||||
|
||||
function ClearUserPreferences() as void
|
||||
m.user_prefs = {}
|
||||
m.ApplyDefaultsToUserPreferences()
|
||||
m.SaveUserPreferences()
|
||||
end function
|
||||
|
||||
function GetValue(key as string) as dynamic
|
||||
return m.user_prefs[key]
|
||||
end function
|
||||
|
||||
function SetValue(key as string, value as dynamic) as void
|
||||
if m.user_prefs[key] = value
|
||||
return
|
||||
end if
|
||||
m.user_prefs[key] = value
|
||||
m.SaveUserPreferences()
|
||||
end function
|
||||
end class
|
||||
@@ -0,0 +1,54 @@
|
||||
import "pkg:/source/utils/General.bs"
|
||||
import "pkg:/source/utils/RegistryUtils.bs"
|
||||
|
||||
namespace SearchHistory
|
||||
function Save(q as string, maxItems = 10 as integer)
|
||||
history = GetAllSaved()
|
||||
index = ArrayIndexOf(history, q)
|
||||
if index <> -1
|
||||
history.Delete(index)
|
||||
end if
|
||||
|
||||
history.Unshift(q)
|
||||
|
||||
if history.Count() > maxItems
|
||||
history.Pop()
|
||||
end if
|
||||
|
||||
history = FormatJson(history)
|
||||
|
||||
RegistryUtils.Write(RegistryUtils.SEARCH_HISTORY, history)
|
||||
end function
|
||||
|
||||
function GetSaved(q as string) as object
|
||||
history = GetAllSaved()
|
||||
if history.count() = 0
|
||||
return []
|
||||
end if
|
||||
|
||||
if q = ""
|
||||
return history
|
||||
end if
|
||||
result = []
|
||||
for each keyword in history
|
||||
if keyword.InStr(q) = 0
|
||||
result.push(keyword)
|
||||
end if
|
||||
end for
|
||||
return result
|
||||
end function
|
||||
|
||||
function GetAllSaved() as object
|
||||
history = RegistryUtils.Read(RegistryUtils.SEARCH_HISTORY)
|
||||
if history = invalid
|
||||
return []
|
||||
end if
|
||||
return ParseJson(history)
|
||||
end function
|
||||
|
||||
|
||||
function Clear()
|
||||
RegistryUtils.Delete(RegistryUtils.SEARCH_HISTORY)
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -1,54 +1,53 @@
|
||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||
import "pkg:/source/utils/WebUtils.bs"
|
||||
import "pkg:/source/utils/Crypto.bs"
|
||||
import "pkg:/source/utils/ColorUtils.bs"
|
||||
|
||||
namespace SponsorBlock
|
||||
const API_URL = "https://sponsor.ajay.app"
|
||||
const SKIP_SEGMENT_ENDPOINT = "/api/skipSegments"
|
||||
const VIEWED_SEGMENT_ENDPOINT = "/api/viewedVideoSponsorTime"
|
||||
|
||||
function SegmentColor(category as string) as integer
|
||||
map = m.SponsorBlockColors
|
||||
if map = invalid
|
||||
map = {
|
||||
sponsor: &h00D400FF,
|
||||
selfpromo: &hFFFF00FF,
|
||||
exclusive_access: &h008A5CFF,
|
||||
interaction: &hCC00FFFF,
|
||||
poi_highlight: &hFF1684FF,
|
||||
intro: &h00FFFFFF,
|
||||
outro: &h0202EDFF,
|
||||
preview: &h008FD6FF,
|
||||
filler: &h7300FFFF,
|
||||
music_offtopic: &hFF9900FF
|
||||
}
|
||||
m.SponsorBlockColors = map
|
||||
function GetSponsorBlockConfig() as object
|
||||
if m.sponsorBlockConfig = invalid
|
||||
m.sponsorBlockConfig = ParseJson(ReadAsciiFile("libpkg:/config/sponsorblock_config.json"))
|
||||
end if
|
||||
if map.doesexist(category)
|
||||
return map[category]
|
||||
return m.sponsorBlockConfig
|
||||
end function
|
||||
|
||||
function SegmentColor(category as string) as integer
|
||||
config = SponsorBlock.GetSponsorBlockConfig()
|
||||
if config = invalid
|
||||
return 0
|
||||
end if
|
||||
|
||||
if config.categories.doesexist(category)
|
||||
color = config.categories[category].color
|
||||
return ColorUtils.HexToInt(color)
|
||||
end if
|
||||
return 0
|
||||
end function
|
||||
|
||||
function SegmentTitle(category as string) as string
|
||||
map = m.SponsorBlockTitles
|
||||
if map = invalid
|
||||
map = {
|
||||
sponsor: "Sponsor",
|
||||
selfpromo: "Unpaid/Self Promotion",
|
||||
exclusive_access: "Exclusive Access",
|
||||
interaction: "Interaction Reminder (Subscribe)",
|
||||
poi_highlight: "Highlight",
|
||||
intro: "Intermission/Intro Animation",
|
||||
outro: "Endcards/Credits",
|
||||
preview: "Preview/Recap",
|
||||
filler: "Filler Tangent/Jokes",
|
||||
music_offtopic: "Non-Music Section"
|
||||
}
|
||||
m.SponsorBlockTitles = map
|
||||
config = SponsorBlock.GetSponsorBlockConfig()
|
||||
if config = invalid
|
||||
return ""
|
||||
end if
|
||||
if map.doesexist(category)
|
||||
return map[category]
|
||||
|
||||
if config.categories.doesexist(category)
|
||||
return config.categories[category].title
|
||||
end if
|
||||
return ""
|
||||
end function
|
||||
|
||||
function SegmentShortTitle(category as string) as string
|
||||
config = SponsorBlock.GetSponsorBlockConfig()
|
||||
if config = invalid
|
||||
return ""
|
||||
end if
|
||||
|
||||
if config.categories.doesexist(category)
|
||||
return config.categories[category].short_title
|
||||
end if
|
||||
return ""
|
||||
end function
|
||||
@@ -82,14 +81,24 @@ namespace SponsorBlock
|
||||
return response.statuscode = 200
|
||||
end function
|
||||
|
||||
function GenerateProgressBarBackground(segments as object, path as string)
|
||||
function GenerateProgressBarBackground(segments as object, lengthSeconds as integer, path as string)
|
||||
bar = CreateObject("roBitmap", { width: 1000, height: 20, AlphaEnable: true })
|
||||
bar.Clear(&hFFFFFF80)
|
||||
width = bar.GetWidth()
|
||||
height = bar.GetHeight()
|
||||
for each segment in segments
|
||||
pixelStart = (segment.segment[0] / segment.videoDuration) * width
|
||||
pixelEnd = (segment.segment[1] / segment.videoDuration) * width
|
||||
videoDuration = lengthSeconds
|
||||
if videoDuration = 0 or videoDuration = invalid
|
||||
' We should ignore segment.videoDuration https://github.com/iBicha/playlet/pull/23#issuecomment-1431520676
|
||||
' But in case where we don't have lengthSeconds from Invidious, it's better than nothing
|
||||
videoDuration = segment.videoDuration
|
||||
end if
|
||||
if videoDuration = 0 or videoDuration = invalid
|
||||
continue for
|
||||
end if
|
||||
|
||||
pixelStart = (segment.segment[0] / videoDuration) * width
|
||||
pixelEnd = (segment.segment[1] / videoDuration) * width
|
||||
color = SponsorBlock.SegmentColor(segment.category)
|
||||
' highlight's duration is zero, so it is not visble on the bar.
|
||||
' Add a couple of pixels to see it
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace ColorUtils
|
||||
function HexToInt(color as dynamic) as integer
|
||||
if color = invalid
|
||||
return 0
|
||||
end if
|
||||
if color.left(1) = "#"
|
||||
color = color.mid(1)
|
||||
end if
|
||||
|
||||
value = Val(color.mid(0, 2), 16) * 16777216 + Val(color.mid(2, 2), 16) * 65536 + Val(color.mid(4, 2), 16) * 256
|
||||
if color.Len() = 6
|
||||
value += 255
|
||||
else if color.Len() = 8
|
||||
value += Val(color.mid(6, 2), 16)
|
||||
end if
|
||||
|
||||
return value
|
||||
end function
|
||||
|
||||
function IntToHex(color as integer) as string
|
||||
hexDigits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
|
||||
hexString = "#"
|
||||
|
||||
for i = 7 to 0 step -1
|
||||
hexString = hexString + hexDigits[(color >> (i * 4)) and &hF]
|
||||
end for
|
||||
|
||||
return hexString
|
||||
end function
|
||||
end namespace
|
||||
@@ -1,17 +1,20 @@
|
||||
function GetSha256(input as string) as string
|
||||
buffer = CreateObject("roByteArray")
|
||||
buffer.FromAsciiString(input)
|
||||
|
||||
digest = CreateObject("roEVPDigest")
|
||||
digest.Setup("sha256")
|
||||
return digest.Process(buffer)
|
||||
return GetEvpDigest(input, "sha256")
|
||||
end function
|
||||
|
||||
function GetSha1(input as string) as string
|
||||
return GetEvpDigest(input, "sha1")
|
||||
end function
|
||||
|
||||
function GetMd5(input as string) as string
|
||||
return GetEvpDigest(input, "md5")
|
||||
end function
|
||||
|
||||
function GetEvpDigest(input as string, method as string) as string
|
||||
buffer = CreateObject("roByteArray")
|
||||
buffer.FromAsciiString(input)
|
||||
|
||||
digest = CreateObject("roEVPDigest")
|
||||
digest.Setup("sha1")
|
||||
digest.Setup(method)
|
||||
return digest.Process(buffer)
|
||||
end function
|
||||
@@ -1,17 +0,0 @@
|
||||
function IsDebugMode() as boolean
|
||||
appInfo = CreateObject("roAppInfo")
|
||||
bsConst = appInfo.GetValue("bs_const")
|
||||
symbols = bsConst.Tokenize(";")
|
||||
|
||||
for each symbol in symbols
|
||||
keyValuePair = symbol.Tokenize("=")
|
||||
if keyValuePair.Count() <> 2
|
||||
continue for
|
||||
end if
|
||||
if UCase(keyValuePair[0]) = "DEBUG"
|
||||
return UCase(keyValuePair[1]) = "TRUE"
|
||||
end if
|
||||
end for
|
||||
|
||||
return false
|
||||
end function
|
||||
@@ -1,6 +1,7 @@
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||
|
||||
function GetLocalIpAddress() as string
|
||||
function GetLocalIpAddress() as dynamic
|
||||
if m.ipAddress = invalid or m.ipAddress = ""
|
||||
di = CreateObject("roDeviceInfo")
|
||||
ips = di.GetIPAddrs()
|
||||
@@ -25,12 +26,36 @@ function GetAppInfo() as object
|
||||
m.appInfo = {
|
||||
id: appInfo.GetID(),
|
||||
version: appInfo.GetVersion(),
|
||||
lib_version: GetLibVersion()
|
||||
git_commit_hash: appInfo.GetValue("git_commit_sha"),
|
||||
lib_version: GetLibVersion(),
|
||||
lib_git_commit_hash: GetLibGitCommitHash()
|
||||
}
|
||||
end if
|
||||
return m.appInfo
|
||||
end function
|
||||
|
||||
function GetLatestPlayletLibVersion() as dynamic
|
||||
if m.latestPlayletLibVersion = invalid
|
||||
args = {
|
||||
parseJson: false
|
||||
}
|
||||
response = Requests().request("HEAD", "https://github.com/iBicha/playlet/releases/latest", args)
|
||||
|
||||
if response.statusCode = 200
|
||||
if response.headers.location <> invalid
|
||||
regex = CreateObject("roRegex", "/v?(\d+\.\d+\.\d+)", "")
|
||||
match = regex.match(response.headers.location)
|
||||
if match.Count() = 2
|
||||
m.latestPlayletLibVersion = match[1]
|
||||
return m.latestPlayletLibVersion
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
m.latestPlayletLibVersion = "N/A"
|
||||
end if
|
||||
return m.latestPlayletLibVersion
|
||||
end function
|
||||
|
||||
function GetLibVersion() as string
|
||||
values = GetLibManifestValues()
|
||||
|
||||
@@ -41,22 +66,34 @@ function GetLibVersion() as string
|
||||
return `${Major}.${Minor}.${Build}`
|
||||
end function
|
||||
|
||||
function GetLibManifestValues() as object
|
||||
libManifest = ReadAsciiFile("libpkg:/manifest")
|
||||
lines = libManifest.Tokenize(UnixNL())
|
||||
values = {}
|
||||
for each line in lines
|
||||
if line.left(1) = "#"
|
||||
continue for
|
||||
end if
|
||||
keyValuePair = line.Tokenize("=")
|
||||
if keyValuePair.Count() <> 2
|
||||
continue for
|
||||
end if
|
||||
function GetLibGitCommitHash() as string
|
||||
values = GetLibManifestValues()
|
||||
|
||||
values[keyValuePair[0]] = keyValuePair[1]
|
||||
end for
|
||||
return values
|
||||
if values.doesexist("git_commit_sha")
|
||||
return values["git_commit_sha"]
|
||||
end if
|
||||
return ""
|
||||
end function
|
||||
|
||||
function GetLibManifestValues() as object
|
||||
if m.linManifestValues = invalid
|
||||
libManifest = ReadAsciiFile("libpkg:/manifest")
|
||||
lines = libManifest.Tokenize(UnixNL())
|
||||
values = {}
|
||||
for each line in lines
|
||||
if line.left(1) = "#"
|
||||
continue for
|
||||
end if
|
||||
keyValuePair = line.Tokenize("=")
|
||||
if keyValuePair.Count() <> 2
|
||||
continue for
|
||||
end if
|
||||
|
||||
values[keyValuePair[0]] = keyValuePair[1]
|
||||
end for
|
||||
m.linManifestValues = values
|
||||
end if
|
||||
return m.linManifestValues
|
||||
end function
|
||||
|
||||
function GetDeviceInfo() as object
|
||||
@@ -75,7 +112,9 @@ function GetDeviceInfo() as object
|
||||
video_mode: devInfo.GetVideoMode(),
|
||||
ui_resolution: devInfo.GetUIResolution(),
|
||||
graphics_platform: devInfo.GetGraphicsPlatform(),
|
||||
internet_status: devInfo.GetInternetStatus()
|
||||
internet_status: devInfo.GetInternetStatus(),
|
||||
user_country_code: devInfo.GetUserCountryCode(),
|
||||
friendly_name: devInfo.GetFriendlyName()
|
||||
}
|
||||
end if
|
||||
return m.deviceInfo
|
||||
|
||||