Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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,8 +1,6 @@
|
||||
name: Linter
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Use Node.js 18.x
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18.x
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build Playlet
|
||||
run: npm run build:release:ci
|
||||
|
||||
- name: Delete unstable release
|
||||
uses: dev-drprasad/delete-tag-and-release@v1.0
|
||||
with:
|
||||
tag_name: unstable
|
||||
github_token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: Create unstable release
|
||||
run: gh release create unstable ./release/playlet.zip ./playlet/src/lib/playlet-lib.zip --notes "This is an automated release." --prerelease --title unstable
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"RokuCommunity.brightscript",
|
||||
"svelte.svelte-vscode",
|
||||
]
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"brightscript.output.clearConsoleOnChannelStart": false
|
||||
"brightscript.bsdk": "node_modules/brightscript",
|
||||
"brightscript.output.clearConsoleOnChannelStart": false,
|
||||
}
|
||||
@@ -1,20 +1,88 @@
|
||||
# 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.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 +91,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 +123,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 +132,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 +144,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 +162,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 +176,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,10 +1,24 @@
|
||||
# Playlet
|
||||
<p align="center">
|
||||
<img src="banner.png" style="display:block;text-align:center" alt="Playlet Logo" width="800"/>
|
||||
<br/><br/>
|
||||
<a href="https://github.com/iBicha/playlet/actions/workflows/release.yml?query=branch%3Amain">
|
||||
<img alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/iBicha/playlet/release.yml.svg?branch=main"/>
|
||||
</a>
|
||||
<a href="https://github.com/iBicha/playlet/releases">
|
||||
<img alt="Current Release" src="https://img.shields.io/github/release/iBicha/playlet.svg"/>
|
||||
<img alt="Total Downloads" src="https://img.shields.io/github/downloads/iBicha/playlet/latest/playlet-lib.zip.svg"/>
|
||||
</a>
|
||||
<a href="https://github.com/iBicha/playlet">
|
||||
<img alt="AGPL-3.0 license" src="https://img.shields.io/github/license/iBicha/playlet.svg"/>
|
||||
</a>
|
||||
<a href="https://channelstore.roku.com/en-ca/details/840aec36f51bfe6d96cf6db9055a372a/playlet">
|
||||
<img alt="Roku Channel Store" src="https://img.shields.io/badge/Roku%20Store-Install-blueviolet?logo=roku&logoColor=blueviolet&labelColor=white"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
# Playlet
|
||||
|
||||
Unofficial Youtube client for Roku 📺
|
||||
Playlet is an unofficial Youtube client for Roku 📺
|
||||
|
||||
## Features
|
||||
- 🔥 No Ads (Not now, not ever)
|
||||
@@ -13,6 +27,7 @@ Unofficial Youtube client for Roku 📺
|
||||
- ⚔️ SponsorBlock integration (skips undesirable sections in videos)
|
||||
- 📱 Cast from phone
|
||||
- 🔮 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
|
||||
@@ -30,13 +45,13 @@ Unofficial Youtube client for Roku 📺
|
||||
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
|
||||
[Playlet on Roku channel store](https://channelstore.roku.com/en-ca/details/840aec36f51bfe6d96cf6db9055a372a/playlet)
|
||||
Or use the link https://my.roku.com/account/add?channel=PLAYLET
|
||||
|
||||
### Sideloaded (Dev app)
|
||||
#### Enable Roku Developer Mode
|
||||
@@ -56,22 +71,6 @@ By now, you should have the following
|
||||
- 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
|
||||
|
||||
@@ -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,27 +1,28 @@
|
||||
{
|
||||
"name": "playlet",
|
||||
"version": "0.7.0",
|
||||
"version": "0.10.0",
|
||||
"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",
|
||||
"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"
|
||||
"typescript": "^5.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "<19.0.0"
|
||||
@@ -37,7 +38,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",
|
||||
@@ -52,9 +54,12 @@
|
||||
"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
|
||||
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,19 +104,9 @@ 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()
|
||||
@@ -92,6 +116,12 @@ end function
|
||||
function OnWebServerCommand()
|
||||
if m.serverTask.command.StartsWith("play:")
|
||||
sender = m.videoContainer.sender ?? m.currentFocued
|
||||
if m.videoContainer.fullscreen
|
||||
dialog = m.top.getScene().dialog
|
||||
if dialog <> invalid
|
||||
dialog.close = true
|
||||
end if
|
||||
end if
|
||||
PlayVideo(m.serverTask.command.Mid(5), { sender: sender })
|
||||
end if
|
||||
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,356 @@
|
||||
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
|
||||
focusedChild = m.top.focusedChild
|
||||
if focusedChild = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
while not focusedChild.id.StartsWith("Control")
|
||||
focusedChild = focusedChild.focusedChild
|
||||
if focusedChild = invalid
|
||||
return invalid
|
||||
end if
|
||||
end while
|
||||
return focusedChild
|
||||
end function
|
||||
|
||||
function MenuGoLeft() as boolean
|
||||
return MenuNavigate(-1)
|
||||
end function
|
||||
|
||||
function MenuGoRight() as boolean
|
||||
return MenuNavigate(1)
|
||||
end function
|
||||
|
||||
function MenuNavigate(direction as integer) as boolean
|
||||
focusedControl = GetFocusedControl()
|
||||
container = focusedControl.getParent()
|
||||
containerParent = container.getParent()
|
||||
containerCount = containerParent.getChildCount()
|
||||
index = GetChildIndex(containerParent, container)
|
||||
|
||||
index += direction
|
||||
|
||||
if index >= containerCount or index < 0
|
||||
return false
|
||||
end if
|
||||
|
||||
newFocusedContainer = containerParent.getChild(index)
|
||||
childCount = newFocusedContainer.getChildCount()
|
||||
for i = 0 to childCount - 1
|
||||
child = newFocusedContainer.getChild(i)
|
||||
if child.visible
|
||||
child.setFocus(true)
|
||||
RefreshUI(index + 1)
|
||||
return true
|
||||
end if
|
||||
end for
|
||||
|
||||
return false
|
||||
end function
|
||||
|
||||
function GetChildIndex(node as object, child as object) as integer
|
||||
childCount = node.getChildCount()
|
||||
for i = 0 to childCount - 1
|
||||
c = node.getChild(i)
|
||||
if child.id = c.id
|
||||
return i
|
||||
end if
|
||||
end for
|
||||
return -1
|
||||
end function
|
||||
|
||||
function GetPreferenceValue(key as string) as dynamic
|
||||
return m.service.GetValue(key)
|
||||
end function
|
||||
|
||||
function SetPreferenceValue(key as string, value as dynamic)
|
||||
m.service.SetValue(key, value)
|
||||
end function
|
||||
|
||||
function GetUserPreferences(unused as object) as object
|
||||
return m.service.GetUserPreferences()
|
||||
end function
|
||||
|
||||
function ApplyUserPreferences(preferences as object) as void
|
||||
m.service.ApplyUserPreferences(preferences)
|
||||
end function
|
||||
|
||||
function ClearUserPreferences(unused as object) as void
|
||||
m.service.ClearUserPreferences()
|
||||
end function
|
||||
@@ -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,59 @@
|
||||
function Init()
|
||||
m.textEditBox = m.top.findNode("TextEditBox")
|
||||
m.top.observeField("focusedChild", "OnFocusChanged")
|
||||
m.top.observeField("value", "OnValueChanged")
|
||||
m.top.observeField("settings", "OnSettingsScreen")
|
||||
m.keyboardWasClosedByButton = false
|
||||
end function
|
||||
|
||||
function OnSettingsScreen()
|
||||
m.top.value = m.top.settings@.GetPreferenceValue(m.top.key)
|
||||
end function
|
||||
|
||||
function OnFocusChanged()
|
||||
focused = m.top.hasFocus()
|
||||
if focused
|
||||
ShowEditKeyboard()
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnValueChanged()
|
||||
value = m.top.value
|
||||
m.top.editText = value
|
||||
m.top.settings@.SetPreferenceValue(m.top.key, value)
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
return m.top.settings@.OnkeyEvent(key, press)
|
||||
end function
|
||||
|
||||
function ShowEditKeyboard()
|
||||
keyboardDialog = createObject("roSGNode", "StandardKeyboardDialog")
|
||||
keyboardDialog.title = m.top.displayText
|
||||
keyboardDialog.message = [m.top.description]
|
||||
keyboardDialog.text = m.top.value
|
||||
keyboardDialog.buttons = ["OK", "Cancel"]
|
||||
keyboardDialog.observeField("wasClosed", "OnKeyboardClosed")
|
||||
keyboardDialog.observeField("buttonSelected", "OnButtonSelected")
|
||||
|
||||
m.top.getScene().dialog = keyboardDialog
|
||||
end function
|
||||
|
||||
function OnButtonSelected(event as object)
|
||||
keyboard = event.getRoSGNode()
|
||||
buttonSelected = keyboard.buttonSelected
|
||||
if buttonSelected = 0
|
||||
m.top.value = keyboard.text
|
||||
end if
|
||||
m.keyboardWasClosedByButton = true
|
||||
keyboard.close = true
|
||||
end function
|
||||
|
||||
function OnKeyboardClosed() as void
|
||||
' The keyboard was closed by something else (like cast from web app)
|
||||
' In this case, we do nothing, since the focus might be moved to the video player
|
||||
if not m.keyboardWasClosedByButton
|
||||
return
|
||||
end if
|
||||
m.top.settings@.MenuNavigate(-1)
|
||||
end function
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="StringControl" extends="Group">
|
||||
<interface>
|
||||
<field id="key" type="string" />
|
||||
<field id="level" type="int" />
|
||||
<field id="editText" type="string" alias="TextEditBox.text" />
|
||||
<field id="value" type="string" />
|
||||
<field id="displayText" type="string" />
|
||||
<field id="description" type="string" />
|
||||
<field id="settings" type="node" />
|
||||
</interface>
|
||||
<children>
|
||||
<TextEditBox id="TextEditBox" clearOnDownKey="false">
|
||||
</TextEditBox>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,58 @@
|
||||
import "pkg:/source/services/SponsorBlock.bs"
|
||||
|
||||
function Init()
|
||||
m.categoryLabel = m.top.findNode("categoryLabel")
|
||||
m.translationAnimation = m.top.findNode("translationAnimation")
|
||||
m.translationAnimationInterpolator = m.top.findNode("translationAnimationInterpolator")
|
||||
m.animationTimer = m.top.findNode("animationTimer")
|
||||
|
||||
m.top.translation = [1280, 20]
|
||||
m.translationAnimation.observeField("state", "OnAnimationState")
|
||||
m.animationTimer.observeField("fire", "OnAnimationTimer")
|
||||
end function
|
||||
|
||||
function OnActionSet()
|
||||
action = m.top.action
|
||||
category = m.top.segment.category
|
||||
categoryTitle = SponsorBlock.SegmentShortTitle(category)
|
||||
if action = "AutoSkip"
|
||||
m.categoryLabel.text = "Skipped" + chr(10) + categoryTitle
|
||||
else
|
||||
m.categoryLabel.text = categoryTitle
|
||||
end if
|
||||
|
||||
AnimateIn()
|
||||
end function
|
||||
|
||||
function OnAnimationTimer()
|
||||
AnimateOut()
|
||||
end function
|
||||
|
||||
function AnimateIn()
|
||||
m.translationAnimation.unobserveField("state")
|
||||
m.animationTimer.control = "stop"
|
||||
m.animationTimer.control = "start"
|
||||
m.translationAnimation.observeField("state", "OnAnimationState")
|
||||
|
||||
Animate(false)
|
||||
end function
|
||||
|
||||
function AnimateOut()
|
||||
Animate(true)
|
||||
end function
|
||||
|
||||
function Animate(reverse as boolean) as void
|
||||
' We are already animating in the requested direction
|
||||
if m.translationAnimationInterpolator.reverse = reverse and m.translationAnimation.control <> "none"
|
||||
return
|
||||
end if
|
||||
|
||||
m.translationAnimationInterpolator.reverse = reverse
|
||||
m.translationAnimation.control = "start"
|
||||
end function
|
||||
|
||||
function OnAnimationState()
|
||||
if m.translationAnimation.state = "stopped" and m.translationAnimationInterpolator.reverse = true
|
||||
m.top.getParent().removeChild(m.top)
|
||||
end if
|
||||
end function
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="SponsorBlockNotification" extends="Group">
|
||||
<interface>
|
||||
<field id="segment" type="assocarray" onChange="OnSegmentSet" />
|
||||
<field id="action" type="string" onChange="OnActionSet" alwaysNotify="true"/>
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
width="250"
|
||||
height="70"
|
||||
color="#414141"
|
||||
opacity="0.8">
|
||||
<Poster
|
||||
uri="libpkg:/images/LogoSponsorBlockSimple256px.png"
|
||||
width="50"
|
||||
height="50"
|
||||
translation="[10,10]">
|
||||
</Poster>
|
||||
<Label
|
||||
id="categoryLabel"
|
||||
text="..."
|
||||
font="font:SmallestBoldSystemFont"
|
||||
lineSpacing="5"
|
||||
horizAlign="center"
|
||||
vertAlign="center"
|
||||
wrap="true"
|
||||
width="170"
|
||||
height="70"
|
||||
translation="[70,0]">
|
||||
</Label>
|
||||
</Rectangle>
|
||||
<Animation
|
||||
id="translationAnimation"
|
||||
duration="0.3"
|
||||
optional="true">
|
||||
<Vector2DFieldInterpolator
|
||||
id="translationAnimationInterpolator"
|
||||
key="[0.0, 0.5, 1.0]"
|
||||
keyValue="[ [1280.0, 20.0], [1140.0, 20.0], [1000.0, 20.0] ]"
|
||||
fieldToInterp="SponsorBlockNotification.translation" />
|
||||
</Animation>
|
||||
<Timer
|
||||
id="animationTimer"
|
||||
duration="3"
|
||||
/>
|
||||
</children>
|
||||
</component>
|
||||
@@ -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
|
||||
@@ -1,5 +1,8 @@
|
||||
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
|
||||
@@ -23,6 +26,7 @@ function PlayVideo(videoId as string, args = invalid as object)
|
||||
videoContainer.sender = sender
|
||||
end if
|
||||
videoContainer.videoPlayer = videoContainer.createChild("VideoPlayer")
|
||||
videoContainer.insertChild(videoContainer.videoPlayer, 0)
|
||||
videoContainer.videoPlayer.id = "VideoPlayer"
|
||||
videoContainer.videoPlayer.metadata = metadata
|
||||
videoContainer.videoPlayer.videoId = videoId
|
||||
@@ -33,6 +37,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 +55,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}`
|
||||
@@ -116,30 +117,20 @@ function OnVideoDetailsTaskResults(output as object) as void
|
||||
end if
|
||||
playletStreamUrls.push(hlsUrlLocal)
|
||||
else
|
||||
if metadata.dashUrl <> invalid
|
||||
|
||||
#if DASH_THUMBNAILS
|
||||
' Redirect to our server so we can inject thumbnails (storyboards) into the DASH manifest
|
||||
dashUrl = `http://${GetLocalIpAddress()}:8888/dash?v=${videoId}`
|
||||
#else
|
||||
dashUrl = metadata.dashUrl
|
||||
#end if
|
||||
playletStreamUrls.push(dashUrl)
|
||||
|
||||
if dashUrl.InStr("?") = -1
|
||||
dashUrlLocal = dashUrl + "?local=true"
|
||||
else
|
||||
dashUrlLocal = dashUrl + "&local=true"
|
||||
end if
|
||||
playletStreamUrls.push(dashUrlLocal)
|
||||
settings = FindAndGetPreferenceValues(["playback.preferred_quality", "invidious.proxy_videos"])
|
||||
if settings = invalid
|
||||
settings = {
|
||||
"playback.preferred_quality": "auto",
|
||||
"invidious.proxy_videos": "if_needed"
|
||||
}
|
||||
end if
|
||||
|
||||
if metadata.formatStreams.Count() > 0
|
||||
stream = metadata.formatStreams[metadata.formatStreams.Count() - 1]
|
||||
itag = stream.itag
|
||||
|
||||
playletStreamUrls.push(Invidious.GetVideoUrl(videoId, itag, false))
|
||||
playletStreamUrls.push(Invidious.GetVideoUrl(videoId, itag, true))
|
||||
if settings["playback.preferred_quality"] = "720p"
|
||||
AddStreamUrls(playletStreamUrls, metadata, settings)
|
||||
AddDashUrls(playletStreamUrls, metadata, settings)
|
||||
else
|
||||
AddDashUrls(playletStreamUrls, metadata, settings)
|
||||
AddStreamUrls(playletStreamUrls, metadata, settings)
|
||||
end if
|
||||
end if
|
||||
|
||||
@@ -161,6 +152,57 @@ function OnVideoDetailsTaskResults(output as object) as void
|
||||
m.videoContainer@.watchedVideosAdd(videoId)
|
||||
end function
|
||||
|
||||
function AddDashUrls(playletStreamUrls as object, metadata as object, settings as object) as void
|
||||
if metadata.dashUrl = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
#if DASH_THUMBNAILS
|
||||
' Redirect to our server so we can inject thumbnails (storyboards) into the DASH manifest
|
||||
dashUrl = `http://${GetLocalIpAddress()}:8888/dash?v=${videoId}`
|
||||
#else
|
||||
dashUrl = metadata.dashUrl
|
||||
#end if
|
||||
|
||||
if dashUrl.InStr("?") = -1
|
||||
dashUrlLocal = dashUrl + "?local=true"
|
||||
else
|
||||
dashUrlLocal = dashUrl + "&local=true"
|
||||
end if
|
||||
|
||||
proxyVideos = settings["invidious.proxy_videos"]
|
||||
if proxyVideos = "if_needed"
|
||||
playletStreamUrls.push(dashUrl)
|
||||
playletStreamUrls.push(dashUrlLocal)
|
||||
else if proxyVideos = "never"
|
||||
playletStreamUrls.push(dashUrl)
|
||||
else if proxyVideos = "always"
|
||||
playletStreamUrls.push(dashUrlLocal)
|
||||
else
|
||||
playletStreamUrls.push(dashUrl)
|
||||
playletStreamUrls.push(dashUrlLocal)
|
||||
end if
|
||||
end function
|
||||
|
||||
function AddStreamUrls(playletStreamUrls as object, metadata as object, settings as object) as void
|
||||
if metadata.formatStreams = invalid or metadata.formatStreams.Count() = 0
|
||||
return
|
||||
end if
|
||||
|
||||
proxyVideos = settings["invidious.proxy_videos"]
|
||||
if proxyVideos = "if_needed"
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(metadata.videoId, false))
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(metadata.videoId, true))
|
||||
else if proxyVideos = "never"
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(metadata.videoId, false))
|
||||
else if proxyVideos = "always"
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(metadata.videoId, true))
|
||||
else
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(metadata.videoId, false))
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(metadata.videoId, true))
|
||||
end if
|
||||
end function
|
||||
|
||||
function FindChildNodeOfType(node as object, nodeType as string) as object
|
||||
if node.subtype() = nodeType
|
||||
return node
|
||||
@@ -298,6 +340,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 +382,5 @@ function OnFullScreenChange()
|
||||
m.translationAnimation.control = "start"
|
||||
|
||||
m.top.enableUI = m.videoContainer.fullscreen
|
||||
SponsorBlockNotifcationSetVisible(m.videoContainer.fullscreen)
|
||||
end function
|
||||
@@ -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,9 +1,19 @@
|
||||
import "pkg:/source/asyncTask/asyncTask.bs"
|
||||
import "pkg:/components/VideoPlayer/SponsorBlockTask.bs"
|
||||
import "pkg:/components/VideoPlayer/SponsorBlockTrackingTask.bs"
|
||||
import "pkg:/components/SponsorBlockNotification/SponsorBlockNotificationManager.bs"
|
||||
import "pkg:/components/SettingsScreen/Settings.bs"
|
||||
|
||||
function SetupSponsorBlock() as void
|
||||
LoadSponsorBlockSettings()
|
||||
if not m.sponsorBlockEnabled = true
|
||||
return
|
||||
end if
|
||||
|
||||
function SetupSponsorBlock()
|
||||
PositionChapterLabel()
|
||||
|
||||
SponsorBlockNotifcationSetVisible(m.videoContainer.fullscreen)
|
||||
|
||||
m.timeLabel = FindTimeLabel()
|
||||
m.top.trickPlayBar.observeField("visible", "OnTrickPlayBarVisible")
|
||||
m.chapterLabelTimer = m.top.findNode("chapterLabelTimer")
|
||||
@@ -11,6 +21,18 @@ function SetupSponsorBlock()
|
||||
m.top.observeField("videoId", "StartSponsorBlockTask")
|
||||
end function
|
||||
|
||||
function LoadSponsorBlockSettings() as void
|
||||
settings = FindAndGetPreferenceValues(["sponsorblock.enabled", "sponsorblock.show_notifications"])
|
||||
if settings = invalid
|
||||
m.sponsorBlockEnabled = false
|
||||
m.sponsorBlockShowNotifications = false
|
||||
return
|
||||
end if
|
||||
|
||||
m.sponsorBlockEnabled = settings["sponsorblock.enabled"]
|
||||
m.sponsorBlockShowNotifications = settings["sponsorblock.show_notifications"]
|
||||
end function
|
||||
|
||||
function PositionChapterLabel()
|
||||
m.chapterLabel = m.top.findNode("chapterLabel")
|
||||
m.chapterLabel.reparent(m.top.trickPlayBar, false)
|
||||
@@ -105,46 +127,44 @@ function OnSponsorBlockTaskResults(output as object)
|
||||
end function
|
||||
|
||||
function OnPositionChangeSkipSponsorBlockSections() as void
|
||||
shouldMute = false
|
||||
muteCategory = ""
|
||||
segments = m.skipSegments
|
||||
if segments = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
for each segment in segments
|
||||
' TODO: handle other action types
|
||||
if segment["actionType"] = "skip"
|
||||
segmentRange = segment["segment"]
|
||||
segmentStart = segmentRange[0]
|
||||
segmentEnd = segmentRange[1]
|
||||
currentPosition = m.top.position
|
||||
if (segmentStart < currentPosition) and ((segmentEnd - 1) > currentPosition)
|
||||
' TODO: if segmentEnd is at the end of the video, close video
|
||||
segmentRange = segment["segment"]
|
||||
segmentStart = segmentRange[0]
|
||||
segmentEnd = segmentRange[1]
|
||||
currentPosition = m.top.position
|
||||
if (segmentStart < currentPosition) and ((segmentEnd - 1) > currentPosition)
|
||||
action = GetActionForSegment(segment)
|
||||
if m.sponsorBlockShowNotifications = true
|
||||
ShowSponsorBlockNotifcation(segment, action)
|
||||
end if
|
||||
|
||||
if action = "AutoSkip"
|
||||
m.top.seek = segmentEnd
|
||||
print("Skipping section:" + segment["category"])
|
||||
SendSkippedSectionEvent(segment.UUID)
|
||||
return
|
||||
end if
|
||||
end if
|
||||
|
||||
if segment["actionType"] = "mute"
|
||||
segmentRange = segment["segment"]
|
||||
segmentStart = segmentRange[0]
|
||||
segmentEnd = segmentRange[1]
|
||||
currentPosition = m.top.position
|
||||
if (segmentStart < currentPosition) and (segmentEnd > currentPosition)
|
||||
shouldMute = true
|
||||
muteCategory = segment["category"]
|
||||
exit for
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
|
||||
if m.top.mute <> shouldMute
|
||||
print(`Muting section: ${muteCategory} - ${shouldMute}`)
|
||||
m.top.mute = shouldMute
|
||||
function GetActionForSegment(segment as object) as dynamic
|
||||
category = segment["category"]
|
||||
if category = "sponsor"
|
||||
return "AutoSkip"
|
||||
else if category = "poi_highlight"
|
||||
return "ManualSkip"
|
||||
else if category = "exclusive_access"
|
||||
return "ShowOverlay"
|
||||
else if category = "chapter"
|
||||
return "ShowOverlay"
|
||||
end if
|
||||
return ""
|
||||
end function
|
||||
|
||||
function SendSkippedSectionEvent(segmentId as string)
|
||||
|
||||
@@ -87,7 +87,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
|
||||
|
||||
@@ -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>
|
||||
@@ -27,8 +27,13 @@ namespace Http
|
||||
server.task.top.command = `play:${videoId}`
|
||||
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,19 +17,15 @@ namespace Http
|
||||
v = request.query.v
|
||||
local = request.query.local
|
||||
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
metadata = router.GetVideoMetadata(context, v)
|
||||
dashUrl = `${instance}/api/manifest/dash/id/${v}`
|
||||
dashUrl = Invidious.GetVideoDashUrl(v, local <> invalid)
|
||||
|
||||
if metadata = invalid and local = invalid
|
||||
response.Redirect(dashUrl)
|
||||
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"
|
||||
|
||||
@@ -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,63 @@ 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"]
|
||||
' TODO: remove null check after 6 months of https://github.com/iv-org/invidious/pull/3603
|
||||
if username <> invalid
|
||||
username = username.DecodeUriComponent().DecodeUriComponent()
|
||||
end if
|
||||
|
||||
InvidiousSettings.SetAuthToken(token, referer, username)
|
||||
server.task.top.login = true
|
||||
end if
|
||||
response.Redirect("/")
|
||||
return true
|
||||
end function)
|
||||
|
||||
' This is an endpoint allowing the web app to make an authenticated request
|
||||
' without needing the Invidious token
|
||||
m.Get("/invidious/authenticated-request", function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
requestData = request.query["request-data"]
|
||||
if requestData = invalid
|
||||
response.Default(400, "Expected request-data")
|
||||
return true
|
||||
end if
|
||||
|
||||
token = InvidiousSettings.GetAuthToken()
|
||||
if token = invalid
|
||||
response.Default(403, "No token, not logged in")
|
||||
return true
|
||||
end if
|
||||
|
||||
requestData = ParseJson(requestData)
|
||||
' Format object again because FormatJson formats in a specific way (sorts keys, etc.)
|
||||
' so we want an exact string for the md5 hash to match
|
||||
requestDataJson = FormatJson(requestData)
|
||||
cacheKey = GetMd5(requestDataJson)
|
||||
path = `tmp:/${cacheKey}.json`
|
||||
|
||||
fs = CreateObject("roFilesystem")
|
||||
if fs.exists(path)
|
||||
cacheData = ReadAsciiFile(path)
|
||||
response.SetBodyDataString(cacheData)
|
||||
response.ContentType("application/json")
|
||||
response.source = Http.HttpResponseSource.GENERATED
|
||||
return true
|
||||
end if
|
||||
|
||||
invService = new InvidiousService()
|
||||
result = invService.MakeRequest(requestData)
|
||||
if result = invalid
|
||||
response.Default(500, "Failed to make request")
|
||||
return true
|
||||
end if
|
||||
response.Json(result)
|
||||
return true
|
||||
end function)
|
||||
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
@@ -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"
|
||||
@@ -39,15 +41,16 @@ 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()
|
||||
#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 +59,24 @@ function WebServerLoop()
|
||||
m.server.UseRouter(new Http.DashRouter())
|
||||
m.server.UseRouter(new Http.CommandsApiRouter())
|
||||
m.server.UseRouter(new Http.StateApiRouter())
|
||||
m.server.UseRouter(new Http.PreferencesRouter())
|
||||
m.server.UseRouter(new Http.InvidiousRouter())
|
||||
m.server.UseRouter(new Http.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
|
||||
|
||||
@@ -5,5 +5,4 @@
|
||||
<field id="login" type="boolean" alwaysNotify="true" />
|
||||
<field id="command" type="string" 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]
|
||||
|
||||
@@ -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",
|
||||
"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
|
||||
minor_version=10
|
||||
build_version=00000
|
||||
|
||||
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=true;CAPTION_INSTANCE_SEARCH=false
|
||||
@@ -13,11 +13,12 @@ namespace Invidious
|
||||
const STATS_ENDPOINT = "/api/v1/stats"
|
||||
|
||||
const VIDEOS_ENDPOINT = "/api/v1/videos"
|
||||
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_SCOPE = "GET:feed,GET:playlists,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"
|
||||
@@ -31,7 +32,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 +42,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 +70,31 @@ 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
|
||||
}
|
||||
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 +110,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,7 +145,7 @@ 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://")
|
||||
|
||||
@@ -127,7 +154,8 @@ namespace Invidious
|
||||
expire = TimeUtils.Now().AsSeconds() + 60 * 60 * 24 * 365 * 2 '2 years from now
|
||||
|
||||
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_SCOPE}`.EncodeUriComponent()
|
||||
return `${invidiousHost}/authorize_token?scopes=${scope}&callback_url=${callbackUrl}&expire=${expire}`
|
||||
end function
|
||||
|
||||
function GetAuthenticationHeaders(token as string) as object
|
||||
|
||||
@@ -2,6 +2,7 @@ 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"
|
||||
|
||||
class InvidiousService
|
||||
@@ -30,7 +31,7 @@ class InvidiousService
|
||||
return invalid
|
||||
end if
|
||||
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
instance = InvidiousSettings.GetCurrentInstance()
|
||||
|
||||
url = instance + endpoint.url
|
||||
|
||||
@@ -72,15 +73,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 +95,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 +107,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 +116,9 @@ 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))
|
||||
result.push(m.ProcessPlaylist(requestData, playlist))
|
||||
end for
|
||||
return result
|
||||
end if
|
||||
@@ -124,17 +128,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
|
||||
@@ -172,4 +173,11 @@ class InvidiousService
|
||||
currentTime = TimeUtils.Now().AsSeconds()
|
||||
return expire < currentTime
|
||||
end function
|
||||
|
||||
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,37 @@
|
||||
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)
|
||||
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
|
||||
|
||||
json = FormatJson(obj)
|
||||
RegistryUtils.Write(RegistryUtils.INVIDIOUS_TOKEN, json)
|
||||
end function
|
||||
|
||||
function GetAuthToken() as dynamic
|
||||
@@ -59,27 +42,34 @@ namespace InvidiousSettings
|
||||
return ParseJson(tokenPayload)
|
||||
end function
|
||||
|
||||
function GetRegistryInstances() as object
|
||||
instances = RegistryUtils.Read(RegistryUtils.INVIDIOUS_INSTANCES)
|
||||
if instances = invalid
|
||||
return []
|
||||
function GetBackupInstances() as object
|
||||
if m.global.hasField("invidiousBackupInstances")
|
||||
return m.global.invidiousBackupInstances
|
||||
end if
|
||||
return ParseJson(instances)
|
||||
return []
|
||||
end function
|
||||
|
||||
function SetRegistryInstances(instances as object)
|
||||
RegistryUtils.Write(RegistryUtils.INVIDIOUS_INSTANCES, FormatJson(instances))
|
||||
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 +80,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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,6 +2,11 @@ namespace RegistryUtils
|
||||
|
||||
const DEFAULT_SECTION = "Playlet"
|
||||
|
||||
const USER_PREFERENCES = "user_prefs"
|
||||
|
||||
const SEARCH_HISTORY = "search_history"
|
||||
const PLAYLET_LIB_URLS = "playlet_lib_urls"
|
||||
|
||||
const INVIDIOUS_INSTANCES = "invidious_instances"
|
||||
const INVIDIOUS_TOKEN = "invidious_token"
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace WebUtils
|
||||
if Instr(0, component, "=")
|
||||
keyValue = component.split("=")
|
||||
key = keyValue[0]
|
||||
value = keyValue[1]
|
||||
value = keyValue[1].DecodeUriComponent()
|
||||
hasValue = true
|
||||
end if
|
||||
|
||||
@@ -22,11 +22,13 @@ namespace WebUtils
|
||||
if GetInterface(oldValue, "ifArray") = invalid
|
||||
oldValue = [oldValue]
|
||||
end if
|
||||
oldValue.push(value)
|
||||
oldValue.push(value.DecodeUriComponent())
|
||||
value = oldValue
|
||||
end if
|
||||
|
||||
query[key] = value
|
||||
if key <> ""
|
||||
query[key] = value
|
||||
end if
|
||||
end for
|
||||
return query
|
||||
end function
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
||||
<title>Playlet</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playlet-web",
|
||||
"version": "0.7.0",
|
||||
"version": "0.10.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -9,19 +9,20 @@
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^1.1.0",
|
||||
"@tsconfig/svelte": "^3.0.0",
|
||||
"autoprefixer": "^10.4.13",
|
||||
"daisyui": "^2.42.1",
|
||||
"dotenv": "^16.0.3",
|
||||
"internal-ip": "^7.0.0",
|
||||
"postcss": "^8.4.19",
|
||||
"svelte": "^3.52.0",
|
||||
"svelte-check": "^2.9.2",
|
||||
"svelte-preprocess": "^4.10.7",
|
||||
"tailwindcss": "^3.2.4",
|
||||
"tslib": "^2.4.0",
|
||||
"typescript": "^4.6.4",
|
||||
"vite": "^3.2.3"
|
||||
"@sveltejs/vite-plugin-svelte": "^2.4.2",
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
"@tsconfig/svelte": "^4.0.1",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"daisyui": "^3.1.6",
|
||||
"dotenv": "^16.3.1",
|
||||
"ip": "^1.1.8",
|
||||
"postcss": "^8.4.24",
|
||||
"svelte": "^4.0.0",
|
||||
"svelte-check": "^3.4.4",
|
||||
"svelte-preprocess": "^5.0.4",
|
||||
"tailwindcss": "^3.3.2",
|
||||
"tslib": "^2.5.3",
|
||||
"typescript": "^5.1.3",
|
||||
"vite": "^4.3.9"
|
||||
}
|
||||
}
|
||||
@@ -1,373 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Playlet</title>
|
||||
<style>
|
||||
table,
|
||||
th,
|
||||
td {
|
||||
border: 1px solid;
|
||||
cursor: all-scroll;
|
||||
}
|
||||
|
||||
table {
|
||||
-webkit-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body ondrop="OnBodyDrop(event);" ondragover="OnBodyDragover(event);">
|
||||
<h2>Playlet - Youtube Player for Roku</h2>
|
||||
<h4 id="app-version">Version: </h4>
|
||||
<h4>Invidious Instance: <a id="instance" target="_blank">None</a></h4>
|
||||
<button onclick="PlayVideo()">Play Video</button>
|
||||
<label for="video-id">Video ID:</label>
|
||||
<input type="text" id="video-id" name="video-id" style="min-width:300px;">
|
||||
<div><small>Hint: drag and drop links or video thumbnails from Youtube or Invidious into this page</small></div>
|
||||
|
||||
<h4 id="logged-in">Logged In: </h4>
|
||||
<button style="display: none" id="login-button" onclick="Login()">Login</button>
|
||||
<button style="display: none" id="logout-button" onclick="Logout()">Logout</button>
|
||||
|
||||
<br />
|
||||
|
||||
<table id="instances">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Instances - find more at <a href="https://api.invidious.io/" target="_blank">api.invidious.io</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr id="instance-input-row">
|
||||
<td>
|
||||
<input type="text" id="instance-input" name="new-instance" oninput="OnNewInstanceTextChanged()"
|
||||
style="min-width:300px;">
|
||||
</td>
|
||||
<td>
|
||||
<button id="instance-add" disabled="true" onclick="AddInstance()">Add</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div><small>Hint: drag and drop instances to reorder them. The one at the top will be used.</small></div>
|
||||
<button style="display: none" id="update-instances" onclick="UpdateInstances()">Update Instances</button>
|
||||
</br>
|
||||
<button onclick="ClearSearchHistory()">Clear Search History</button>
|
||||
|
||||
<h5>Instructions</h5>
|
||||
<ul>
|
||||
<li>Make sure you are logged in the Invidious instance before logging in on this page</li>
|
||||
<li>If this is your first time using this invidious Instance, you might want to create an account</li>
|
||||
<li>Once you are logged in to your current instance, click "Login" on this page, and authorize the token</li>
|
||||
<li>Once logged in, this page should show "Logged In: true"</li>
|
||||
<li>After login, the home page should refresh automatically. You should then be able to see your Subscription feed
|
||||
and Playlists, if you have any.</li>
|
||||
</ul>
|
||||
<p>
|
||||
This is a barebone page for now, <a href="/index.html">click here for the redesigned page!</a>
|
||||
</p>
|
||||
<h5>Feedback is welcome over at: <a id="feedback-url" href="https://github.com/iBicha/playlet"
|
||||
target="_blank">https://github.com/iBicha/playlet</a></h5>
|
||||
|
||||
<script>
|
||||
function Login() {
|
||||
if (!window.appState) {
|
||||
alert("Error with login, please refresh the page.")
|
||||
}
|
||||
window.location = window.appState.invidious.auth_url
|
||||
}
|
||||
|
||||
function Logout() {
|
||||
PostJson('/api/command', { command: "logout" })
|
||||
.then(function (response) {
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(function (err) {
|
||||
alert(err)
|
||||
});
|
||||
}
|
||||
|
||||
function PlayVideo() {
|
||||
let v = document.getElementById('video-id').value
|
||||
if (IsValidHttpUrl(v)) {
|
||||
v = GetVideoId(v)
|
||||
}
|
||||
if (!v || v.length < 8) {
|
||||
alert("Please set video id")
|
||||
return
|
||||
}
|
||||
PostJson('/api/command', { command: "play", videoId: v })
|
||||
.catch(function (err) {
|
||||
alert(err)
|
||||
});
|
||||
}
|
||||
|
||||
function ClearSearchHistory() {
|
||||
PostJson('/api/command', { command: "clear-search-history" })
|
||||
.then(function (response) {
|
||||
alert("Search history cleared");
|
||||
})
|
||||
.catch(function (err) {
|
||||
alert(err)
|
||||
});
|
||||
}
|
||||
|
||||
function CreateGithubIssueUrl() {
|
||||
title = "[Feedback] Playlet"
|
||||
body = `### Feedback
|
||||
_insert feedback here_
|
||||
|
||||
#### App Info
|
||||
\`\`\`
|
||||
${JSON.stringify(window.appState.app, null, 2)}
|
||||
\`\`\`
|
||||
|
||||
#### Device Info
|
||||
\`\`\`
|
||||
${JSON.stringify(window.appState.device, null, 2)}
|
||||
\`\`\`
|
||||
|
||||
#### Invidious settings
|
||||
\`\`\`
|
||||
${JSON.stringify(window.appState.invidious, null, 2)}
|
||||
\`\`\``;
|
||||
return `https://github.com/iBicha/playlet/issues/new?title=${encodeURIComponent(title)}&body=${encodeURIComponent(body)}`
|
||||
}
|
||||
|
||||
function IsValidHttpUrl(string) {
|
||||
let url;
|
||||
try {
|
||||
url = new URL(string);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
return url.protocol === "http:" || url.protocol === "https:";
|
||||
}
|
||||
|
||||
function GetVideoId(url) {
|
||||
// Share/Short url
|
||||
const YoutubeUrls = [
|
||||
"https://youtu.be/",
|
||||
"http://youtu.be/",
|
||||
"https://www.youtu.be/",
|
||||
"http://www.youtu.be/",
|
||||
"https://youtube.com/shorts/",
|
||||
"http://youtube.com/shorts/",
|
||||
"https://www.youtube.com/shorts/",
|
||||
"http://www.youtube.com/shorts/",
|
||||
]
|
||||
for (var i in YoutubeUrls) {
|
||||
let youtubeUrl = YoutubeUrls[i];
|
||||
if (url.startsWith(youtubeUrl)) {
|
||||
url = url.replace(youtubeUrl, "")
|
||||
if (url.includes("?")) {
|
||||
url = url.substring(0, url.indexOf("?"))
|
||||
}
|
||||
return url
|
||||
}
|
||||
}
|
||||
|
||||
// regular url
|
||||
url = new URL(url)
|
||||
const urlSearchParams = new URLSearchParams(url.search);
|
||||
return urlSearchParams.get('v')
|
||||
}
|
||||
|
||||
function OnNewInstanceTextChanged() {
|
||||
document.getElementById("instance-add").disabled = !IsValidHttpUrl(document.getElementById("instance-input").value)
|
||||
}
|
||||
|
||||
function AddInstance() {
|
||||
instance = document.getElementById("instance-input").value
|
||||
AddInstanceRow(instance)
|
||||
document.getElementById("instance-input").value = ""
|
||||
document.getElementById("update-instances").style.display = "block";
|
||||
}
|
||||
|
||||
function AddInstanceRow(instance) {
|
||||
instances = document.getElementById("instances").getElementsByTagName('tbody')[0];
|
||||
var row = instances.insertRow();
|
||||
row.draggable = true
|
||||
row.addEventListener('dragstart', OnTableRowDragStart);
|
||||
row.addEventListener('dragover', OnTableRowDragover);
|
||||
row.addEventListener('drop', OnTableRowDrop);
|
||||
var cell = row.insertCell();
|
||||
style = instance === window.appState.invidious.selected_instance ? `style="font-weight:bold"` : ""
|
||||
cell.innerHTML = `<a href="${instance}" ${style} target="_blank">${instance}</a>`
|
||||
cell = row.insertCell();
|
||||
cell.innerHTML = `<button onclick="RemoveInstance('${instance}')">Remove</button>`
|
||||
}
|
||||
|
||||
function RemoveInstance(instance) {
|
||||
instanceRows = Array.from(document.getElementById("instances")
|
||||
.getElementsByTagName('tbody')[0]
|
||||
.getElementsByTagName('tr'));
|
||||
|
||||
for (const i in instanceRows) {
|
||||
currentInstance = instanceRows[i].getElementsByTagName('a')[0].innerText
|
||||
if (currentInstance === instance) {
|
||||
instanceRows[i].remove()
|
||||
document.getElementById("update-instances").style.display = "block";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function UpdateInstances() {
|
||||
instances = Array.from(document.getElementById("instances")
|
||||
.getElementsByTagName('tbody')[0]
|
||||
.getElementsByTagName('td'))
|
||||
.map(el => el.getElementsByTagName('a')[0])
|
||||
.filter(a => !!a)
|
||||
.map(a => a.innerText);
|
||||
|
||||
PostJson('/invidious/instances', instances)
|
||||
.then(function (response) {
|
||||
alert("Instances updated. Restart Playlet to reflect changes.")
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(function (err) {
|
||||
alert(err)
|
||||
});
|
||||
}
|
||||
|
||||
function PostJson(url, payload) {
|
||||
return fetch(url,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload)
|
||||
})
|
||||
}
|
||||
|
||||
function Initialize() {
|
||||
fetch("/api/state")
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function (appState) {
|
||||
window.appState = appState
|
||||
console.log(appState)
|
||||
|
||||
document.getElementById("app-version").innerText = `Version: ${appState.app.version}`
|
||||
|
||||
if (appState.invidious.logged_in) {
|
||||
document.getElementById("logged-in").innerHTML = `Logged In: true (<a href="${appState.invidious.logged_in_instance}" target="_blank">${appState.invidious.logged_in_instance}</a>)`
|
||||
} else {
|
||||
document.getElementById("logged-in").innerHTML = "Logged In: false"
|
||||
}
|
||||
|
||||
instanceEl = document.getElementById("instance")
|
||||
instanceEl.innerText = instanceEl.href = appState.invidious.selected_instance
|
||||
|
||||
for (var i in appState.invidious.instances) {
|
||||
AddInstanceRow(appState.invidious.instances[i])
|
||||
}
|
||||
|
||||
loginButton = document.getElementById("login-button")
|
||||
loginButton.innerText = `Login (${appState.invidious.selected_instance})`
|
||||
loginButton.style.display = appState.invidious.logged_in ? "none" : "block";
|
||||
|
||||
document.getElementById("logout-button").style.display = !appState.invidious.logged_in ? "none" : "block";
|
||||
|
||||
document.getElementById("feedback-url").href = CreateGithubIssueUrl()
|
||||
})
|
||||
.catch(function (err) {
|
||||
alert(err)
|
||||
});
|
||||
|
||||
SetupWebSocket();
|
||||
}
|
||||
|
||||
var tableRow;
|
||||
function OnTableRowDragStart(event) {
|
||||
target = event.target;
|
||||
while (target && target.tagName !== 'TR') {
|
||||
target = target.parentNode
|
||||
}
|
||||
if (target.id === "instance-input-row") {
|
||||
return
|
||||
}
|
||||
tableRow = target
|
||||
}
|
||||
|
||||
function OnTableRowDragover(event) {
|
||||
event.preventDefault();
|
||||
|
||||
if (!tableRow) {
|
||||
return
|
||||
}
|
||||
|
||||
target = event.target;
|
||||
while (target && target.tagName !== 'TR') {
|
||||
target = target.parentNode
|
||||
}
|
||||
if (!target || target.id === "instance-input-row") {
|
||||
return
|
||||
}
|
||||
|
||||
let children = Array.from(target.parentNode.children);
|
||||
|
||||
if (children.indexOf(target) > children.indexOf(tableRow))
|
||||
target.after(tableRow);
|
||||
else
|
||||
target.before(tableRow);
|
||||
}
|
||||
|
||||
function OnTableRowDrop(event) {
|
||||
event.preventDefault();
|
||||
tableRow = undefined
|
||||
document.getElementById("update-instances").style.display = "block";
|
||||
}
|
||||
|
||||
function OnBodyDrop(event) {
|
||||
for (var i in event.dataTransfer.items) {
|
||||
let item = event.dataTransfer.items[i]
|
||||
if (item.kind = 'string' && item.getAsString) {
|
||||
item.getAsString((dataString) => {
|
||||
if (IsValidHttpUrl(dataString) && GetVideoId(dataString)) {
|
||||
document.getElementById('video-id').value = dataString
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
function OnBodyDragover(event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
function SetupWebSocket() {
|
||||
var socket = new WebSocket(`ws://${window.location.host}`);
|
||||
socket.onopen = function (event) {
|
||||
console.log("WebSocket connected!")
|
||||
const message = "Hello?"
|
||||
console.log(`Sending: "${message}"`)
|
||||
socket.send(message);
|
||||
};
|
||||
socket.onclose = function (event) {
|
||||
console.log("WebSocket closed!")
|
||||
};
|
||||
socket.onerror = function (event) {
|
||||
console.log('WebSocket error: ', event);
|
||||
};
|
||||
socket.onmessage = function (event) {
|
||||
console.log(`Received: "${event.data}"`);
|
||||
}
|
||||
}
|
||||
|
||||
Initialize();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,25 +1,66 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import InstanceInfo from "./lib/InstanceInfo.svelte";
|
||||
import NavBar from "./lib/NavBar.svelte";
|
||||
import PlayVideo from "./lib/PlayVideo.svelte";
|
||||
import ClearSearchHistory from "./lib/ClearSearchHistory.svelte";
|
||||
import { PlayletApi } from "./lib/PlayletApi";
|
||||
import { playletStateStore } from "./lib/Stores";
|
||||
import LegacyUI from "./lib/LegacyUI.svelte";
|
||||
import { appStateStore, homeLayoutFileStore, invidiousVideoApiStore, playletStateStore, preferencesModelStore, searchHistoryStore, userPreferencesStore } from "./lib/Stores";
|
||||
import BottomNavigation from "./lib/BottomNavigation.svelte";
|
||||
import ScreenHome from "./lib/ScreenHome.svelte";
|
||||
import type { AppState } from "./lib/Types";
|
||||
import ScreenSearch from "./lib/ScreenSearch.svelte";
|
||||
import ScreenSettings from "./lib/ScreenSettings.svelte";
|
||||
import ScreenInfo from "./lib/ScreenInfo.svelte";
|
||||
import LinkDragDrop from "./lib/LinkDragDrop.svelte";
|
||||
|
||||
onMount(async () => {
|
||||
const playletState = await PlayletApi.getState();
|
||||
playletStateStore.set(playletState);
|
||||
PlayletApi.getState().then((value) => {
|
||||
playletStateStore.set(value);
|
||||
});
|
||||
|
||||
PlayletApi.getHomeLayoutFile().then((value) => {
|
||||
homeLayoutFileStore.set(value);
|
||||
});
|
||||
|
||||
PlayletApi.getInvidiousVideoApiFile().then((invidiousVideoApiFile) => {
|
||||
const invidiousVideoApiDefinitions =
|
||||
invidiousVideoApiFile.endpoints.reduce((acc, endpoint) => {
|
||||
acc[endpoint.name] = endpoint;
|
||||
return acc;
|
||||
}, {});
|
||||
invidiousVideoApiStore.set(invidiousVideoApiDefinitions);
|
||||
});
|
||||
|
||||
PlayletApi.getPreferencesFile().then((value) => {
|
||||
preferencesModelStore.set(value);
|
||||
});
|
||||
|
||||
PlayletApi.getUserPreferences().then((value) => {
|
||||
userPreferencesStore.set(value);
|
||||
});
|
||||
|
||||
PlayletApi.getSearchHistory().then((value) => {
|
||||
searchHistoryStore.set(value);
|
||||
});
|
||||
});
|
||||
|
||||
let currentScreen: AppState["screen"];
|
||||
appStateStore.subscribe((value) => {
|
||||
currentScreen = value.screen;
|
||||
});
|
||||
</script>
|
||||
|
||||
<main>
|
||||
<LinkDragDrop />
|
||||
|
||||
<NavBar />
|
||||
<div class="p-6 space-y-2 form-control">
|
||||
<InstanceInfo />
|
||||
<PlayVideo />
|
||||
<ClearSearchHistory />
|
||||
<LegacyUI />
|
||||
<!-- TODO: a better way to make the BottomNavigation not hide screens -->
|
||||
<div style="margin-bottom: 4rem">
|
||||
<ScreenSearch visibility={currentScreen == "search"} />
|
||||
|
||||
<ScreenHome visibility={currentScreen == "home"} />
|
||||
|
||||
<ScreenSettings visibility={currentScreen == "settings"} />
|
||||
|
||||
<ScreenInfo visibility={currentScreen == "info"} />
|
||||
</div>
|
||||
<BottomNavigation />
|
||||
</main>
|
||||
@@ -0,0 +1,6 @@
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet" focusable="false" style="pointer-events: none; display: block; width: 100%; height: 100%;">
|
||||
<g class="fill-current">
|
||||
<path d="M4,10V21h6V15h4v6h6V10L12,3Z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 364 B |
@@ -0,0 +1,6 @@
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 122.88 122.88" preserveAspectRatio="xMidYMid meet" focusable="false" style="pointer-events: none; display: block; width: 100%; height: 100%;">
|
||||
<g class="fill-current">
|
||||
<path d="M61.44,9.23c-1.85,0-3.64,0.08-5.35,0.25c-1.71,0.17-3.44,0.42-5.17,0.77c-1.72,0.34-3.39,0.77-5,1.26 c-1.59,0.49-3.16,1.07-4.7,1.72l-0.1,0.05l0,0c-1.63,0.7-3.18,1.45-4.67,2.25c-1.5,0.81-2.94,1.68-4.31,2.6 c-1.38,0.93-2.72,1.92-3.99,2.97c-1.27,1.05-2.5,2.16-3.68,3.35l-0.04,0.04c-1.18,1.18-2.29,2.4-3.33,3.66 c-1.05,1.28-2.04,2.61-2.97,3.99c-0.92,1.36-1.78,2.8-2.59,4.3c-0.8,1.49-1.56,3.05-2.26,4.67l-0.05,0.11l0,0l-0.07,0.14 c-0.63,1.5-1.19,3.04-1.67,4.61c-0.49,1.59-0.9,3.23-1.24,4.93c-0.35,1.73-0.6,3.45-0.77,5.17c-0.17,1.72-0.25,3.5-0.25,5.35 c0,1.85,0.08,3.64,0.25,5.35c0.17,1.71,0.42,3.44,0.77,5.17c0.35,1.72,0.77,3.39,1.27,5c0.49,1.57,1.05,3.13,1.7,4.66 c0.04,0.07,0.07,0.14,0.1,0.21c0.69,1.6,1.43,3.13,2.23,4.6c0.81,1.5,1.68,2.94,2.59,4.3c0.93,1.39,1.92,2.72,2.98,4 c1.02,1.24,2.11,2.44,3.26,3.59c0.07,0.06,0.13,0.12,0.19,0.19c1.16,1.16,2.36,2.24,3.59,3.26c1.28,1.05,2.61,2.04,3.99,2.97 c1.36,0.92,2.8,1.78,4.3,2.59c1.49,0.8,3.05,1.56,4.67,2.26l0.21,0.1c1.52,0.64,3.07,1.2,4.67,1.69c1.58,0.49,3.23,0.9,4.92,1.24 c1.73,0.35,3.45,0.6,5.17,0.77c1.72,0.17,3.5,0.25,5.35,0.25c1.85,0,3.64-0.08,5.35-0.25c1.71-0.17,3.44-0.42,5.17-0.77 c1.72-0.35,3.39-0.77,5-1.27c1.59-0.49,3.16-1.07,4.71-1.73l0.09-0.04l0-0.01c1.63-0.7,3.18-1.45,4.67-2.25 c1.5-0.81,2.94-1.68,4.31-2.6c1.38-0.93,2.72-1.92,3.99-2.97c1.25-1.03,2.45-2.12,3.62-3.29c0.06-0.06,0.11-0.12,0.18-0.18 c1.15-1.15,2.23-2.35,3.25-3.58c1.05-1.28,2.05-2.61,2.98-4c0.92-1.36,1.78-2.8,2.59-4.3c0.8-1.49,1.56-3.04,2.26-4.67l0.1-0.22 c0.64-1.51,1.2-3.06,1.69-4.65c0.49-1.59,0.9-3.23,1.24-4.93c0.35-1.73,0.6-3.45,0.77-5.17c0.17-1.72,0.25-3.5,0.25-5.35 c0-1.85-0.08-3.64-0.25-5.35c-0.17-1.71-0.42-3.44-0.77-5.17c-0.35-1.72-0.77-3.39-1.27-5c-0.49-1.59-1.07-3.16-1.73-4.71 l-0.04-0.09l0,0c-0.7-1.63-1.45-3.18-2.25-4.67c-0.81-1.5-1.68-2.94-2.59-4.3c-0.93-1.38-1.92-2.72-2.97-3.99 c-1.02-1.24-2.12-2.45-3.28-3.61c-0.07-0.06-0.13-0.12-0.18-0.18c-1.16-1.16-2.35-2.24-3.59-3.26c-1.28-1.05-2.61-2.04-3.99-2.97 c-1.37-0.92-2.8-1.78-4.3-2.59c-1.49-0.8-3.04-1.56-4.67-2.25l-0.19-0.09c-1.52-0.64-3.08-1.21-4.68-1.7 c-1.58-0.49-3.23-0.9-4.93-1.24c-1.73-0.35-3.45-0.6-5.17-0.77C65.08,9.31,63.29,9.23,61.44,9.23L61.44,9.23z M63.34,31.17 c2.19,0,3.91,0.63,5.16,1.88c1.24,1.25,1.87,2.96,1.87,5.17c0,2.24-1.07,4.22-3.21,5.97c-2.16,1.74-4.66,2.62-7.52,2.62 c-2.14,0-3.85-0.6-5.16-1.8c-1.31-1.22-1.96-2.79-1.96-4.75c0-2.47,1.07-4.59,3.19-6.4C57.82,32.06,60.37,31.17,63.34,31.17 L63.34,31.17L63.34,31.17z M75.55,91.71H47.33v-4.75h5.3V57.95h-5.3v-3.78h13.19c3.33,0,6.61-0.4,9.85-1.22v34.01h5.18L75.55,91.71 L75.55,91.71L75.55,91.71z M49.12,1.2c1.96-0.39,3.99-0.69,6.08-0.89C57.29,0.1,59.37,0,61.44,0c2.07,0,4.15,0.1,6.24,0.31 c2.09,0.2,4.12,0.5,6.08,0.89c1.94,0.39,3.88,0.88,5.82,1.48c1.88,0.58,3.74,1.26,5.58,2.04l0.19,0.07l0,0l0.06,0.02 c1.85,0.8,3.65,1.67,5.38,2.61c1.71,0.93,3.4,1.95,5.07,3.07c1.63,1.1,3.21,2.27,4.73,3.52c1.52,1.25,2.97,2.56,4.34,3.95 c1.38,1.38,2.7,2.83,3.95,4.34c1.25,1.52,2.42,3.09,3.52,4.73c1.09,1.63,2.11,3.32,3.06,5.06l0,0l0.01,0 c0.94,1.74,1.82,3.54,2.61,5.39c0.02,0.05,0.04,0.1,0.06,0.15c0.78,1.83,1.46,3.7,2.05,5.6c0.61,1.96,1.11,3.92,1.5,5.89 c0.39,1.96,0.69,3.99,0.89,6.08c0.2,2.09,0.3,4.17,0.3,6.24c0,2.07-0.1,4.15-0.31,6.24c-0.2,2.09-0.5,4.12-0.89,6.08 c-0.39,1.94-0.88,3.88-1.48,5.82c-0.58,1.89-1.27,3.76-2.05,5.62l-0.04,0.09l0,0l-0.05,0.11c-0.8,1.85-1.67,3.65-2.61,5.38 c-0.93,1.71-1.95,3.4-3.07,5.07c-1.1,1.63-2.27,3.21-3.52,4.73c-1.25,1.52-2.56,2.96-3.95,4.34c-1.38,1.38-2.83,2.7-4.35,3.95 c-1.52,1.25-3.09,2.42-4.72,3.51c-1.63,1.09-3.32,2.11-5.06,3.06c-1.78,0.96-3.57,1.84-5.39,2.62c-0.05,0.02-0.1,0.04-0.16,0.06 c-1.83,0.78-3.7,1.46-5.6,2.05c-1.96,0.61-3.92,1.11-5.88,1.5c-1.96,0.39-3.99,0.69-6.08,0.89c-2.09,0.2-4.17,0.3-6.24,0.3 s-4.15-0.1-6.24-0.3c-2.09-0.2-4.12-0.5-6.08-0.89c-1.94-0.39-3.88-0.88-5.82-1.48c-1.89-0.58-3.76-1.27-5.61-2.05l-0.2-0.08l0,0 c-1.85-0.8-3.65-1.67-5.38-2.61c-1.71-0.93-3.4-1.95-5.07-3.07c-1.63-1.09-3.21-2.27-4.72-3.51c-1.52-1.25-2.97-2.57-4.35-3.95 c-1.38-1.38-2.7-2.83-3.95-4.34c-1.25-1.52-2.42-3.1-3.52-4.73c-1.09-1.63-2.11-3.32-3.06-5.06c-0.97-1.78-1.84-3.58-2.62-5.4 c-0.02-0.05-0.04-0.1-0.06-0.15c-0.78-1.83-1.46-3.7-2.05-5.6c-0.61-1.96-1.11-3.93-1.5-5.89c-0.39-1.96-0.69-3.99-0.89-6.08 C0.1,65.59,0,63.51,0,61.44c0-2.07,0.1-4.15,0.31-6.24c0.2-2.09,0.5-4.12,0.89-6.08c0.39-1.94,0.88-3.88,1.48-5.82 c0.58-1.88,1.26-3.74,2.04-5.59l0.09-0.23l0,0c0.8-1.85,1.67-3.65,2.61-5.38c0.93-1.71,1.95-3.4,3.07-5.07 c1.1-1.63,2.27-3.21,3.52-4.73c1.25-1.52,2.56-2.96,3.95-4.34c1.38-1.38,2.83-2.7,4.34-3.95c1.52-1.25,3.09-2.42,4.73-3.52 c1.67-1.12,3.36-2.14,5.07-3.07l0.13-0.06c1.73-0.94,3.48-1.78,5.26-2.55c0.05-0.02,0.1-0.04,0.15-0.06 c1.83-0.78,3.7-1.46,5.6-2.05C45.19,2.09,47.15,1.59,49.12,1.2L49.12,1.2z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="371"
|
||||
height="142"
|
||||
viewBox="0 0 98.160945 37.570857"
|
||||
version="1.1"
|
||||
id="svg9602"
|
||||
sodipodi:docname="logo-light.svg"
|
||||
inkscape:version="1.2.1 (9c6d41e4, 2022-07-14)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview
|
||||
id="namedview20"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
showgrid="false"
|
||||
inkscape:zoom="2.6316652"
|
||||
inkscape:cx="125.96587"
|
||||
inkscape:cy="61.177994"
|
||||
inkscape:window-width="1440"
|
||||
inkscape:window-height="744"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="25"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg9602" />
|
||||
<defs
|
||||
id="defs9599" />
|
||||
<g
|
||||
id="layer1"
|
||||
transform="translate(-22.260864,-34.716253)">
|
||||
<rect
|
||||
style="fill:#242424;fill-opacity:0.99;stroke:none;stroke-width:1.24539;stroke-linejoin:round;stroke-dasharray:none"
|
||||
id="rect8445"
|
||||
width="65.39537"
|
||||
height="36.795055"
|
||||
x="22.703459"
|
||||
y="35.180595"
|
||||
rx="6.8266635"
|
||||
ry="6.5550508" />
|
||||
<g
|
||||
aria-label="P"
|
||||
transform="matrix(0.44612332,0,0,0.44612332,-53.310985,-114.20369)"
|
||||
id="text416-2"
|
||||
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
|
||||
<path
|
||||
d="m 182.08151,397.45387 v -50.02669 h 15.38134 q 4.032,0 7.54134,1.49333 3.50933,1.49334 6.12267,4.18134 2.61333,2.61333 4.10667,6.12267 1.49333,3.50933 1.49333,7.54133 0,3.95734 -1.49333,7.46667 -1.49334,3.50934 -4.10667,6.12267 -2.61334,2.53867 -6.12267,4.03201 -3.50934,1.49333 -7.54134,1.49333 h -8.81067 v 11.57334 z m 6.57067,-18.14401 h 8.81067 q 2.61334,0 4.928,-0.97067 2.31467,-1.04533 4.03201,-2.688 1.71733,-1.71733 2.688,-3.95733 1.04533,-2.31467 1.04533,-4.92801 0,-2.688 -1.04533,-5.00267 -0.97067,-2.31466 -2.688,-4.032 -1.71734,-1.71733 -4.03201,-2.688 -2.31466,-0.97067 -4.928,-0.97067 h -8.81067 z"
|
||||
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
|
||||
id="path9573" />
|
||||
</g>
|
||||
<g
|
||||
aria-label="l"
|
||||
transform="matrix(0.44612332,0,0,0.44612332,-36.59502,-114.22526)"
|
||||
id="text416-2-1"
|
||||
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-8);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
|
||||
<path
|
||||
d="m 189.92152,349.36851 v 48.08536 h -6.27201 v -48.08536 z"
|
||||
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
|
||||
id="path9570" />
|
||||
</g>
|
||||
<g
|
||||
aria-label="e"
|
||||
transform="matrix(0.44612332,0,0,0.44612332,15.071073,-114.17511)"
|
||||
id="text416-2-5"
|
||||
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-53);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
|
||||
<path
|
||||
d="m 216.35353,388.8672 q -3.06134,4.55467 -7.24267,6.64533 -4.10667,2.09067 -8.96001,2.09067 -3.808,0 -7.168,-1.41867 -3.36,-1.49333 -5.824,-3.95733 -2.464,-2.464 -3.95734,-5.824 -1.41867,-3.36001 -1.41867,-7.16801 0,-3.88267 1.41867,-7.24267 1.49334,-3.36 3.95734,-5.824 2.464,-2.53867 5.824,-3.95734 3.36,-1.49333 7.168,-1.49333 4.85334,0 9.10934,2.24 4.33067,2.24 7.46667,6.944 l -21.65334,20.16001 q 1.19466,0.82134 2.98667,1.19467 1.792,0.29867 3.584,0.0747 3.136,-0.37334 5.824,-2.09067 2.76267,-1.792 4.62934,-4.48 z m -28.59735,-10.60267 q -0.224,2.83733 0.74667,5.22666 0.97066,2.38934 2.76267,3.73334 l 17.09867,-16.65067 q -1.41867,-1.71734 -3.808,-2.76267 -2.38934,-1.12 -5.22667,-0.97067 -2.31467,0.14933 -4.33067,1.04533 -2.016,0.896 -3.584,2.46401 -1.49333,1.49333 -2.464,3.50933 -0.97067,2.016 -1.19467,4.40534 z"
|
||||
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
|
||||
id="path9558" />
|
||||
</g>
|
||||
<g
|
||||
aria-label="t"
|
||||
transform="matrix(0.44612332,0,0,0.44612332,32.445174,-114.17841)"
|
||||
id="text416-2-59"
|
||||
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-6);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
|
||||
<path
|
||||
d="m 180.21484,360.71785 h 3.43467 v -11.34934 h 6.34667 v 11.34934 h 6.64534 v 5.22667 h -6.64534 v 20.23468 q 0,2.61333 1.64267,4.256 1.64267,1.568 4.256,1.568 v 5.6 q -6.048,0 -9.184,-2.912 -3.06134,-2.912 -3.06134,-8.512 v -20.23468 h -3.43467 z"
|
||||
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
|
||||
id="path9555" />
|
||||
</g>
|
||||
<g
|
||||
aria-label="l"
|
||||
transform="matrix(0.44612332,0,0,0.44612332,9.157916,-114.17642)"
|
||||
id="text416-2-8"
|
||||
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-5);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
|
||||
<path
|
||||
d="m 189.92152,349.36851 v 48.08536 h -6.27201 v -48.08536 z"
|
||||
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
|
||||
id="path9561" />
|
||||
</g>
|
||||
<g
|
||||
aria-label="a"
|
||||
transform="matrix(0.44612332,0,0,0.44612332,-30.719029,-114.24707)"
|
||||
id="text416-2-4"
|
||||
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-1);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
|
||||
<path
|
||||
d="m 181.85751,379.23519 q 0,-3.88267 1.344,-7.24267 1.344,-3.36 3.584,-5.824 2.31467,-2.53867 5.37601,-3.95734 3.136,-1.49333 6.72,-1.49333 4.256,0 7.76534,2.09067 3.50933,2.016 5.74933,5.45067 v -7.39201 h 6.34667 v 36.58669 h -6.34667 v -7.31734 q -2.24,3.43467 -5.74933,5.45067 -3.50934,2.016 -7.76534,2.016 -3.584,0 -6.72,-1.41867 -3.06134,-1.49333 -5.37601,-3.95733 -2.24,-2.464 -3.584,-5.824 -1.344,-3.36001 -1.344,-7.16801 z m 6.34667,0 q 0,2.464 0.896,4.704 0.97067,2.16534 2.53867,3.80801 1.64267,1.64266 3.808,2.61333 2.24,0.896 4.77867,0.896 2.464,0 4.62934,-0.896 2.24,-0.97067 3.88266,-2.61333 1.64267,-1.64267 2.61334,-3.80801 0.97067,-2.24 0.97067,-4.704 0,-2.464 -0.97067,-4.704 -0.97067,-2.24 -2.61334,-3.88267 -1.64266,-1.64267 -3.88266,-2.61333 -2.16534,-0.97067 -4.62934,-0.97067 -2.53867,0 -4.77867,0.97067 -2.16533,0.97066 -3.808,2.61333 -1.568,1.64267 -2.53867,3.88267 -0.896,2.24 -0.896,4.704 z"
|
||||
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
|
||||
id="path9567" />
|
||||
</g>
|
||||
<g
|
||||
aria-label="y"
|
||||
transform="matrix(0.44612332,0,0,0.44612332,-11.285794,-114.11033)"
|
||||
id="text416-2-84"
|
||||
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-3);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
|
||||
<path
|
||||
d="m 186.56151,360.86718 10.97601,28.07468 10.752,-28.07468 h 6.72001 l -18.74135,47.56269 h -6.272 l 4.256,-10.82667 -14.48534,-36.73602 z"
|
||||
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
|
||||
id="path9564" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 7.8 KiB |
@@ -0,0 +1,6 @@
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" preserveAspectRatio="xMidYMid meet" focusable="false" style="pointer-events: none; display: block; width: 100%; height: 100%;">
|
||||
<g class="fill-current">
|
||||
<path d="M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352c79.5 0 144-64.5 144-144s-64.5-144-144-144S64 128.5 64 208s64.5 144 144 144z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 605 B |
@@ -0,0 +1,6 @@
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet" focusable="false" style="pointer-events: none; display: block; width: 100%; height: 100%;">
|
||||
<g class="fill-current">
|
||||
<path d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,8c-2.21,0-4,1.79-4,4s1.79,4,4,4s4-1.79,4-4 S14.21,8,12,8L12,8z M13.22,3l0.55,2.2l0.13,0.51l0.5,0.18c0.61,0.23,1.19,0.56,1.72,0.98l0.4,0.32l0.5-0.14l2.17-0.62l1.22,2.11 l-1.63,1.59l-0.37,0.36l0.08,0.51c0.05,0.32,0.08,0.64,0.08,0.98s-0.03,0.66-0.08,0.98l-0.08,0.51l0.37,0.36l1.63,1.59l-1.22,2.11 l-2.17-0.62l-0.5-0.14l-0.4,0.32c-0.53,0.43-1.11,0.76-1.72,0.98l-0.5,0.18l-0.13,0.51L13.22,21h-2.44l-0.55-2.2l-0.13-0.51 l-0.5-0.18C9,17.88,8.42,17.55,7.88,17.12l-0.4-0.32l-0.5,0.14l-2.17,0.62L3.6,15.44l1.63-1.59l0.37-0.36l-0.08-0.51 C5.47,12.66,5.44,12.33,5.44,12s0.03-0.66,0.08-0.98l0.08-0.51l-0.37-0.36L3.6,8.56l1.22-2.11l2.17,0.62l0.5,0.14l0.4-0.32 C8.42,6.45,9,6.12,9.61,5.9l0.5-0.18l0.13-0.51L10.78,3H13.22 M14,2h-4L9.26,4.96c-0.73,0.27-1.4,0.66-2,1.14L4.34,5.27l-2,3.46 l2.19,2.13C4.47,11.23,4.44,11.61,4.44,12s0.03,0.77,0.09,1.14l-2.19,2.13l2,3.46l2.92-0.83c0.6,0.48,1.27,0.87,2,1.14L10,22h4 l0.74-2.96c0.73-0.27,1.4-0.66,2-1.14l2.92,0.83l2-3.46l-2.19-2.13c0.06-0.37,0.09-0.75,0.09-1.14s-0.03-0.77-0.09-1.14l2.19-2.13 l-2-3.46L16.74,6.1c-0.6-0.48-1.27-0.87-2-1.14L14,2L14,2z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 39 KiB |
@@ -0,0 +1,50 @@
|
||||
<script lang="ts">
|
||||
import HomeIcon from "../assets/home-icon.svg.svelte";
|
||||
import InfoIcon from "../assets/info-icon.svg.svelte";
|
||||
import SearchIcon from "../assets/search-icon.svg.svelte";
|
||||
import SettingsIcon from "../assets/settings-icon.svg.svelte";
|
||||
import { appStateStore } from "./Stores";
|
||||
import type { AppState } from "./Types";
|
||||
|
||||
function setScreen(screen: AppState["screen"]) {
|
||||
appStateStore.update((state) => {
|
||||
state.screen = screen;
|
||||
return state;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="btm-nav">
|
||||
<button
|
||||
on:click={() => setScreen("search")}
|
||||
class={$appStateStore.screen === "search" ? "active" : ""}
|
||||
>
|
||||
<div class="h-6">
|
||||
<SearchIcon />
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
on:click={() => setScreen("home")}
|
||||
class={$appStateStore.screen === "home" ? "active" : ""}
|
||||
>
|
||||
<div class="h-6">
|
||||
<HomeIcon />
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
on:click={() => setScreen("settings")}
|
||||
class={$appStateStore.screen === "settings" ? "active" : ""}
|
||||
>
|
||||
<div class="h-6">
|
||||
<SettingsIcon />
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
on:click={() => setScreen("info")}
|
||||
class={$appStateStore.screen === "info" ? "active" : ""}
|
||||
>
|
||||
<div class="h-6">
|
||||
<InfoIcon />
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
@@ -1,11 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { PlayletApi } from "./PlayletApi";
|
||||
|
||||
const clearSearchHistory = async () => {
|
||||
await PlayletApi.clearSearchHistory();
|
||||
};
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<button class="btn" on:click={clearSearchHistory}>Clear search history</button>
|
||||
</div>
|
||||
@@ -0,0 +1,64 @@
|
||||
<script>
|
||||
import { onMount } from "svelte";
|
||||
import { PlayletApi } from "./PlayletApi";
|
||||
|
||||
let selectedRelease = ''
|
||||
let releases = [];
|
||||
onMount(async () => {
|
||||
releases = await fetchReleaseTags();
|
||||
});
|
||||
|
||||
async function fetchReleaseTags() {
|
||||
const response = await fetch(
|
||||
"https://api.github.com/repos/iBicha/playlet/releases"
|
||||
);
|
||||
const releases = await response.json();
|
||||
return releases.map((release) => {
|
||||
return {
|
||||
name: release.tag_name,
|
||||
enabled:
|
||||
release.assets.filter((asset) => asset.name === "playlet-lib.zip")
|
||||
.length > 0,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
let version = selectedRelease;
|
||||
if (version === "") {
|
||||
version = "latest";
|
||||
}
|
||||
if (confirm(`Are you sure you want to change the Playlet Library version to "${version}"?`)) {
|
||||
await PlayletApi.setPlayletLibVersion(selectedRelease);
|
||||
alert("Playlet Library version set. Restart playlet to apply changes.");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="m-5">
|
||||
<div class="text-2xl">Developer settings</div>
|
||||
<div class="text-xs text-gray-500">
|
||||
Options for Playlet developers. Do not change unless you "know what you're
|
||||
doing"™
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="m-5">
|
||||
<div class="text-lg">Playlet Library version</div>
|
||||
<div class="text-xs text-gray-500">
|
||||
The version of Playlet Lib to use. These correspond to tagged releases on
|
||||
Github. Releases that do not have a playlet-lib.zip file are disabled.
|
||||
</div>
|
||||
|
||||
<div class="join w-full m-1">
|
||||
<select bind:value={selectedRelease} class="select select-bordered join-item w-full mr-1">
|
||||
<option selected value="">latest (default)</option>
|
||||
{#each releases as release}
|
||||
<option disabled={!release.enabled} value={release.name}
|
||||
>{release.name}</option
|
||||
>
|
||||
{/each}
|
||||
</select>
|
||||
<button class="join-item btn" on:click={apply}>Apply</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,33 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { PlayletApi } from "./PlayletApi";
|
||||
import { playletStateStore } from "./Stores";
|
||||
|
||||
let selectedInstance;
|
||||
let inputInstance;
|
||||
|
||||
playletStateStore.subscribe((value) => {
|
||||
selectedInstance = value?.invidious?.selected_instance ?? "N/A";
|
||||
inputInstance = selectedInstance;
|
||||
});
|
||||
|
||||
const updateInstance = async () => {
|
||||
await PlayletApi.updateInstances([inputInstance]);
|
||||
// TODO: reload state
|
||||
window.location.reload();
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="form-control">
|
||||
<label class="input-group">
|
||||
<span>Invidious Instance</span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="http://my-instance.com"
|
||||
class="input input-bordered"
|
||||
bind:value={inputInstance}
|
||||
/>
|
||||
{#if inputInstance !== selectedInstance}
|
||||
<button class="btn" on:click={updateInstance}>Update</button>
|
||||
{/if}
|
||||
</label>
|
||||
</div>
|
||||
@@ -0,0 +1,128 @@
|
||||
import { PlayletApi } from "./PlayletApi";
|
||||
|
||||
export class InvidiousApi {
|
||||
public instance: string;
|
||||
public endpoints: any;
|
||||
public isLoggedIn: boolean = false;
|
||||
public userCountryCode: string = 'US';
|
||||
|
||||
responseHandlers: any;
|
||||
|
||||
constructor() {
|
||||
// Note: AuthFeedHandler and AuthPlaylistsHandler are not needed, since it is handled server side
|
||||
this.responseHandlers = {
|
||||
"DefaultHandler": (requestData, response) => this.DefaultHandler(requestData, response),
|
||||
"PlaylistHandler": (requestData, response) => this.PlaylistHandler(requestData, response),
|
||||
}
|
||||
}
|
||||
|
||||
public async searchSuggestions(query: string) {
|
||||
const response = await fetch(`${this.instance}/api/v1/search/suggestions?q=${encodeURIComponent(query)}®ion=${this.userCountryCode}`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
public async search(query: string) {
|
||||
const response = await fetch(`${this.instance}/api/v1/search?q=${encodeURIComponent(query)}®ion=${this.userCountryCode}`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
public async getVideoMetadata(videoId: string) {
|
||||
const response = await fetch(`${this.instance}/api/v1/videos/${videoId}`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
public async makeRequest(requestData: any) {
|
||||
if (!requestData || !this.instance || !this.endpoints) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let endpoint = this.endpoints[requestData.endpoint];
|
||||
if (!endpoint) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let url = this.instance + endpoint.url
|
||||
let queryParams = {}
|
||||
let headers = {}
|
||||
|
||||
if (endpoint.authenticated) {
|
||||
// Authenticated requests on the web app would be blocked by CORS, so we use the Playlet API as a proxy
|
||||
if (!this.isLoggedIn) {
|
||||
return null;
|
||||
}
|
||||
return await PlayletApi.invidiousAuthenticatedRequest(requestData);
|
||||
}
|
||||
|
||||
if (endpoint.queryParams !== undefined) {
|
||||
for (let queryParamKey in endpoint.queryParams) {
|
||||
let queryParam = endpoint.queryParams[queryParamKey];
|
||||
if (queryParam.default !== undefined) {
|
||||
if (queryParam.type === "string") {
|
||||
queryParams[queryParamKey] = queryParam.default;
|
||||
} else if (queryParam.type === "#ISO3166") {
|
||||
if (queryParam.default === "GetUserCountryCode") {
|
||||
queryParams[queryParamKey] = this.userCountryCode;
|
||||
} else {
|
||||
queryParams[queryParamKey] = queryParam.default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (requestData.queryParams !== undefined) {
|
||||
queryParams = { ...queryParams, ...requestData.queryParams };
|
||||
}
|
||||
|
||||
if (requestData.pathParams !== undefined) {
|
||||
for (let param in requestData.pathParams) {
|
||||
url = url.replace(`:${param}`, requestData.pathParams[param]);
|
||||
}
|
||||
}
|
||||
|
||||
url = this.makeUrl(url, queryParams);
|
||||
const response = await fetch(url, { headers: headers });
|
||||
|
||||
let responseHandler = endpoint.responseHandler !== undefined ? this.responseHandlers[endpoint.responseHandler] : this.responseHandlers["DefaultHandler"];
|
||||
if (!responseHandler) {
|
||||
return null;
|
||||
}
|
||||
return await responseHandler(requestData, response);
|
||||
}
|
||||
|
||||
private async DefaultHandler(requestData, response) {
|
||||
const json = await response.json();
|
||||
return [{ title: requestData.title, videos: json }]
|
||||
}
|
||||
|
||||
private async PlaylistHandler(requestData, response) {
|
||||
const playlist = await response.json();
|
||||
return [this.ProcessPlaylist(requestData, playlist)]
|
||||
}
|
||||
|
||||
private ProcessPlaylist(requestData, playlist) {
|
||||
const title = this.ProcessTemplate(requestData.title, playlist)
|
||||
return { title: title, videos: playlist.videos }
|
||||
}
|
||||
|
||||
private ProcessTemplate(template: string, data) {
|
||||
let result = template;
|
||||
for (let key in data) {
|
||||
result = result.replace(`%${key}%`, `${data[key]}`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private makeUrl(url: string, params: any) {
|
||||
const encodedUrl = new URL(url);
|
||||
const existingParams = new URLSearchParams(encodedUrl.search);
|
||||
|
||||
let mergedParams = new URLSearchParams({
|
||||
...Object.fromEntries(existingParams),
|
||||
...params
|
||||
});
|
||||
|
||||
encodedUrl.search = mergedParams.toString();
|
||||
return encodedUrl.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { getHost } from "./Host";
|
||||
|
||||
const goToLegacyUI = async () => {
|
||||
window.location.href = `http://${getHost()}`
|
||||
};
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<button class="btn" on:click={goToLegacyUI}>Legacy UI</button>
|
||||
</div>
|
||||
@@ -0,0 +1,152 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy, onMount } from "svelte";
|
||||
import { PlayletApi } from "./PlayletApi";
|
||||
import { playletStateStore } from "./Stores";
|
||||
import { InvidiousApi } from "./InvidiousApi";
|
||||
|
||||
let modal;
|
||||
let isDragging;
|
||||
let isLoading;
|
||||
let dragEndTimeout;
|
||||
|
||||
let videoMetadata;
|
||||
|
||||
let tvName = "Roku TV";
|
||||
let invidiousInstance;
|
||||
|
||||
let invidiousApi = new InvidiousApi();
|
||||
|
||||
playletStateStore.subscribe((value) => {
|
||||
tvName = value?.device?.friendly_name ?? "Roku TV";
|
||||
invidiousApi.instance = invidiousInstance =
|
||||
value?.invidious?.current_instance;
|
||||
});
|
||||
|
||||
onMount(async () => {
|
||||
document.body.addEventListener("drop", onDrop);
|
||||
document.body.addEventListener("dragover", onDragOver);
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
document.body.removeEventListener("drop", onDrop);
|
||||
document.body.removeEventListener("dragover", onDragOver);
|
||||
});
|
||||
|
||||
async function onDrop(event) {
|
||||
event.preventDefault();
|
||||
modal.close();
|
||||
|
||||
isDragging = false;
|
||||
for (var i in event.dataTransfer.items) {
|
||||
let item = event.dataTransfer.items[i];
|
||||
if (item.kind === "string" && item.getAsString) {
|
||||
let dataString = await new Promise((resolve) =>
|
||||
item.getAsString(resolve)
|
||||
);
|
||||
if (IsValidHttpUrl(dataString)) {
|
||||
const videoId = GetVideoId(dataString);
|
||||
if (videoId) {
|
||||
searchForVideoById(videoId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function searchForVideoById(videoId) {
|
||||
try {
|
||||
isLoading = true;
|
||||
videoMetadata = await invidiousApi.getVideoMetadata(videoId);
|
||||
modal.showModal();
|
||||
} finally {
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onDragOver(event) {
|
||||
modal.close();
|
||||
clearTimeout(dragEndTimeout);
|
||||
dragEndTimeout = setTimeout(() => {
|
||||
isDragging = false;
|
||||
}, 200);
|
||||
isDragging = true;
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
function IsValidHttpUrl(string) {
|
||||
let url;
|
||||
try {
|
||||
url = new URL(string);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
return url.protocol === "http:" || url.protocol === "https:";
|
||||
}
|
||||
|
||||
function GetVideoId(url) {
|
||||
// Share/Short url
|
||||
// TODO: use regex, and support timestamped videos
|
||||
const YoutubeUrls = [
|
||||
"https://youtu.be/",
|
||||
"http://youtu.be/",
|
||||
"https://www.youtu.be/",
|
||||
"http://www.youtu.be/",
|
||||
"https://youtube.com/shorts/",
|
||||
"http://youtube.com/shorts/",
|
||||
"https://www.youtube.com/shorts/",
|
||||
"http://www.youtube.com/shorts/",
|
||||
];
|
||||
for (var i in YoutubeUrls) {
|
||||
let youtubeUrl = YoutubeUrls[i];
|
||||
if (url.startsWith(youtubeUrl)) {
|
||||
url = url.replace(youtubeUrl, "");
|
||||
if (url.includes("?")) {
|
||||
url = url.substring(0, url.indexOf("?"));
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
// regular url
|
||||
url = new URL(url);
|
||||
const urlSearchParams = new URLSearchParams(url.search);
|
||||
return urlSearchParams.get("v");
|
||||
}
|
||||
|
||||
async function playVideoOnTv() {
|
||||
await PlayletApi.playVideo(videoMetadata?.videoId);
|
||||
}
|
||||
|
||||
function openInvidiousInNewTab() {
|
||||
window.open(`${invidiousInstance}/watch?v=${videoMetadata?.videoId}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="{isDragging || isLoading
|
||||
? ''
|
||||
: 'hidden'} absolute w-full h-full bg-base-100/80 z-50 flex justify-center items-center"
|
||||
>
|
||||
{#if isDragging}
|
||||
<div class="text-2xl font-bold">Drop a Youtube link here</div>
|
||||
{:else if isLoading}
|
||||
<span class="loading loading-spinner loading-md" />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<dialog bind:this={modal} id="modal_video_drag_drop" class="modal">
|
||||
<form method="dialog" class="modal-box bg-base-100">
|
||||
<h3 class="text-lg m-5">{videoMetadata?.title}</h3>
|
||||
<div class="flex flex-col">
|
||||
<button class="btn m-2" on:click={playVideoOnTv}>Play on {tvName}</button>
|
||||
<button class="btn m-2" on:click={openInvidiousInNewTab}
|
||||
>Open in Invidious</button
|
||||
>
|
||||
<button class="btn m-2">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
<form method="dialog" class="modal-backdrop">
|
||||
<button>close</button>
|
||||
</form>
|
||||
</dialog>
|
||||
@@ -1,50 +1,84 @@
|
||||
<script lang="ts">
|
||||
import playletLogo from "../assets/logo-dark.svg";
|
||||
import { PlayletApi } from "./PlayletApi";
|
||||
import { playletStateStore } from "./Stores";
|
||||
import playletLogoDark from "../assets/logo-dark.svg";
|
||||
import playletLogoLight from "../assets/logo-light.svg";
|
||||
import userIcon from "../assets/user.png";
|
||||
import { PlayletApi } from "./PlayletApi";
|
||||
import { appThemeStore, playletStateStore } from "./Stores";
|
||||
import ThemeSelect from "./ThemeToggle.svelte";
|
||||
|
||||
let version;
|
||||
let loggedIn = false;
|
||||
let auth_url;
|
||||
let selectedInstance;
|
||||
let loggedInInstance;
|
||||
|
||||
playletStateStore.subscribe((value) => {
|
||||
version = value?.app?.version ?? "";
|
||||
loggedIn = value?.invidious?.logged_in;
|
||||
auth_url = value?.invidious?.auth_url;
|
||||
selectedInstance = value?.invidious?.selected_instance;
|
||||
loggedInInstance = value?.invidious?.logged_in_instance;
|
||||
let version;
|
||||
let loggedIn = false;
|
||||
let auth_url;
|
||||
let currentInstance;
|
||||
let loggedInInstance;
|
||||
let username;
|
||||
|
||||
playletStateStore.subscribe((value) => {
|
||||
version = value?.app?.lib_version ?? "";
|
||||
loggedIn = value?.invidious?.logged_in;
|
||||
auth_url = value?.invidious?.auth_url;
|
||||
currentInstance = value?.invidious?.current_instance;
|
||||
loggedInInstance = value?.invidious?.logged_in_instance;
|
||||
username = value?.invidious?.logged_in_username;
|
||||
});
|
||||
|
||||
const login = () => {
|
||||
if (!auth_url) {
|
||||
alert("Error with login, please refresh the page.");
|
||||
return;
|
||||
}
|
||||
window.location = auth_url;
|
||||
};
|
||||
const logout = async () => {
|
||||
await PlayletApi.logout();
|
||||
PlayletApi.getState().then((value) => {
|
||||
playletStateStore.set(value);
|
||||
});
|
||||
|
||||
const login = () => {
|
||||
if (!auth_url) {
|
||||
alert("Error with login, please refresh the page.");
|
||||
return;
|
||||
}
|
||||
window.location = auth_url;
|
||||
};
|
||||
const logout = async () => {
|
||||
await PlayletApi.logout();
|
||||
// TODO: reload state
|
||||
window.location.reload();
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="navbar bg-base-100">
|
||||
<div class="flex-1">
|
||||
<img src={playletLogo} class="h-12" alt="Playlet Logo" />
|
||||
<h4 class="label brightness-75">{version}</h4>
|
||||
</div>
|
||||
<div class="flex-none">
|
||||
<div class="navbar bg-base-100 sticky top-0 z-40">
|
||||
<div class="flex-1">
|
||||
<img src={$appThemeStore === 'dark' ? playletLogoDark : playletLogoLight} class="h-8" alt="Playlet Logo" />
|
||||
<h4 class="label brightness-75">{version}</h4>
|
||||
</div>
|
||||
<div class="flex-none">
|
||||
<ThemeSelect />
|
||||
{#if loggedIn && username}
|
||||
<div class="badge badge-outline">
|
||||
<span>{username}</span>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="dropdown dropdown-end">
|
||||
<div tabindex="-1" class="btn btn-ghost btn-circle avatar">
|
||||
<div class="w-8 rounded-full">
|
||||
<img src={userIcon} alt="User" />
|
||||
</div>
|
||||
</div>
|
||||
<ul
|
||||
tabindex="-1"
|
||||
class="menu menu-sm dropdown-content mt-3 p-2 shadow bg-base-100 rounded-box"
|
||||
>
|
||||
{#if loggedIn}
|
||||
<div class="tooltip tooltip-left" data-tip={loggedInInstance}>
|
||||
<button class="btn" on:click={logout}>Logout</button>
|
||||
<li>
|
||||
<div
|
||||
class="tooltip tooltip-left"
|
||||
data-tip={`Logout from ${loggedInInstance}`}
|
||||
>
|
||||
<button on:click={logout}>Logout</button>
|
||||
</div>
|
||||
</li>
|
||||
{:else}
|
||||
<div class="tooltip tooltip-left" data-tip={selectedInstance}>
|
||||
<button class="btn" on:click={login}>Login</button>
|
||||
<li>
|
||||
<div
|
||||
class="tooltip tooltip-left"
|
||||
data-tip={`Login using ${currentInstance}`}
|
||||
>
|
||||
<button on:click={login}>Login</button>
|
||||
</div>
|
||||
</li>
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,69 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { PlayletApi } from "./PlayletApi";
|
||||
|
||||
let videoId;
|
||||
|
||||
function IsValidHttpUrl(string) {
|
||||
let url;
|
||||
try {
|
||||
url = new URL(string);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
return url.protocol === "http:" || url.protocol === "https:";
|
||||
}
|
||||
|
||||
function GetVideoId(url) {
|
||||
// Share/Short url
|
||||
const YoutubeUrls = [
|
||||
"https://youtu.be/",
|
||||
"http://youtu.be/",
|
||||
"https://www.youtu.be/",
|
||||
"http://www.youtu.be/",
|
||||
"https://youtube.com/shorts/",
|
||||
"http://youtube.com/shorts/",
|
||||
"https://www.youtube.com/shorts/",
|
||||
"http://www.youtube.com/shorts/",
|
||||
];
|
||||
for (var i in YoutubeUrls) {
|
||||
let youtubeUrl = YoutubeUrls[i];
|
||||
if (url.startsWith(youtubeUrl)) {
|
||||
url = url.replace(youtubeUrl, "");
|
||||
if (url.includes("?")) {
|
||||
url = url.substring(0, url.indexOf("?"));
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
// regular url
|
||||
url = new URL(url);
|
||||
const urlSearchParams = new URLSearchParams(url.search);
|
||||
return urlSearchParams.get("v");
|
||||
}
|
||||
|
||||
const playVideo = async () => {
|
||||
let v = videoId;
|
||||
if (IsValidHttpUrl(v)) {
|
||||
v = GetVideoId(v);
|
||||
}
|
||||
if (!v || v.length < 8) {
|
||||
alert("Please set video id");
|
||||
return;
|
||||
}
|
||||
|
||||
await PlayletApi.playVideo(v);
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="form-control">
|
||||
<div class="input-group">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Video ID"
|
||||
class="input input-bordered"
|
||||
bind:value={videoId}
|
||||
/>
|
||||
<button class="btn" on:click={playVideo}> Play </button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -8,20 +8,77 @@ export class PlayletApi {
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
static async getPreferencesFile() {
|
||||
const response = await fetch(`${PlayletApi.host()}/config/preferences.json`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
static async getHomeLayoutFile() {
|
||||
const response = await fetch(`${PlayletApi.host()}/config/default_home_layout.json`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
static async getInvidiousVideoApiFile() {
|
||||
const response = await fetch(`${PlayletApi.host()}/config/invidious_video_api.json`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
static async invidiousAuthenticatedRequest(requestData) {
|
||||
const url = PlayletApi.host() + "/invidious/authenticated-request?request-data=" + encodeURIComponent(JSON.stringify(requestData));
|
||||
const response = await fetch(url);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
static async getUserPreferences() {
|
||||
const response = await fetch(`${PlayletApi.host()}/api/preferences`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
static async saveUserPreference(key, value) {
|
||||
const response = await this.putJson(`${PlayletApi.host()}/api/preferences`, { [key]: value });
|
||||
return await response;
|
||||
}
|
||||
|
||||
static async logout() {
|
||||
return await PlayletApi.postJson(`${PlayletApi.host()}/api/command`, { command: "logout" });
|
||||
}
|
||||
|
||||
static async playVideo(videoId) {
|
||||
if (!videoId) {
|
||||
return;
|
||||
}
|
||||
return await PlayletApi.postJson(`${PlayletApi.host()}/api/command`, { command: "play", videoId: videoId });
|
||||
}
|
||||
|
||||
static async clearSearchHistory() {
|
||||
return await PlayletApi.postJson(`${PlayletApi.host()}/api/command`, { command: "clear-search-history" });
|
||||
static async getSearchHistory() {
|
||||
const response = await fetch(`${PlayletApi.host()}/api/search-history`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
static async updateInstances(instances) {
|
||||
return await PlayletApi.postJson(`${PlayletApi.host()}/invidious/instances`, instances);
|
||||
static async putSearchHistory(query: string) {
|
||||
const response = await PlayletApi.putJson(`${PlayletApi.host()}/api/search-history`, { query });
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
static async clearSearchHistory() {
|
||||
return await fetch(`${PlayletApi.host()}/api/search-history`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
static async updateInstance(instance) {
|
||||
return await PlayletApi.putJson(`${PlayletApi.host()}/api/preferences`, { "invidious.instance": instance });
|
||||
}
|
||||
|
||||
static async setPlayletLibVersion(tag) {
|
||||
let content = null
|
||||
|
||||
if (tag !== "") {
|
||||
content = JSON.stringify([{
|
||||
link: `https://github.com/iBicha/playlet/releases/download/${tag}/playlet-lib.zip`,
|
||||
type: 'custom'
|
||||
}]);
|
||||
}
|
||||
|
||||
await this.postJson(`${PlayletApi.host()}/api/command`, { command: "set-playlet-lib-urls", content: content });
|
||||
}
|
||||
|
||||
private static postJson(url, payload) {
|
||||
@@ -33,4 +90,14 @@ export class PlayletApi {
|
||||
body: JSON.stringify(payload)
|
||||
})
|
||||
}
|
||||
|
||||
private static putJson(url, payload) {
|
||||
return fetch(url, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
method: "PUT",
|
||||
body: JSON.stringify(payload)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<script lang="ts">
|
||||
import ScreenHomeRow from "./ScreenHomeRow.svelte";
|
||||
import { homeLayoutFileStore } from "./Stores";
|
||||
|
||||
export let visibility: boolean;
|
||||
</script>
|
||||
|
||||
<div class={visibility ? "" : "hidden"}>
|
||||
{#each $homeLayoutFileStore as homeLayoutItem}
|
||||
<ScreenHomeRow requestData={homeLayoutItem} />
|
||||
{/each}
|
||||
</div>
|
||||
@@ -0,0 +1,51 @@
|
||||
<script lang="ts">
|
||||
import { InvidiousApi } from "./InvidiousApi";
|
||||
import {
|
||||
invidiousVideoApiStore,
|
||||
playletStateStore,
|
||||
} from "./Stores";
|
||||
import VideoCell from "./VideoCell.svelte";
|
||||
|
||||
export let requestData: any = undefined;
|
||||
export let videoRowData = undefined;
|
||||
|
||||
let invidiousApi = new InvidiousApi();
|
||||
|
||||
playletStateStore.subscribe((value) => {
|
||||
invidiousApi.instance = value?.invidious?.current_instance;
|
||||
invidiousApi.userCountryCode = value?.device?.user_country_code ?? "US";
|
||||
invidiousApi.isLoggedIn = value.invidious?.logged_in ?? false;
|
||||
updateRow();
|
||||
});
|
||||
|
||||
invidiousVideoApiStore.subscribe((value) => {
|
||||
invidiousApi.endpoints = value;
|
||||
updateRow();
|
||||
});
|
||||
|
||||
async function updateRow() {
|
||||
const result = await invidiousApi.makeRequest(requestData);
|
||||
if (result) {
|
||||
videoRowData = result;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if videoRowData}
|
||||
{#if Array.isArray(videoRowData)}
|
||||
{#each videoRowData as child}
|
||||
<svelte:self videoRowData={child} />
|
||||
{/each}
|
||||
{:else if videoRowData.title && videoRowData.videos}
|
||||
<div class="text-lg font-semibold m-4">{videoRowData.title}</div>
|
||||
<div
|
||||
class="carousel carousel-center rounded-box w-full space-x-4"
|
||||
>
|
||||
{#each videoRowData.videos as video}
|
||||
<div class="carousel-item">
|
||||
<VideoCell {...video} />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||