Compare commits

...
54 Commits
Author SHA1 Message Date
Brahim Hadriche 6adbe94a1e Release 0.8.0 (#54) 2023-03-02 16:36:12 -05:00
Brahim Hadriche aaea507fde Use format streams by default instead of DASH (#53) 2023-03-02 16:26:15 -05:00
Brahim Hadriche 52b4feb130 Fix return type 2023-03-01 18:01:32 -05:00
Brahim Hadriche 0d79c4975e Feature/cherrypick ws (#52)
* int to hex

* Websocket frame size

* Hash methods refactor

* Uri components fix
2023-02-27 20:10:21 -05:00
Brahim Hadriche 0e2be8d5bb Decode username https://github.com/iv-org/invidious/pull/3656 2023-02-22 09:00:41 -05:00
Brahim Hadriche 71453237c4 Add username to web app and state api (#50) 2023-02-21 13:54:13 -05:00
Brahim Hadriche 5baab67bb4 [PoC] Invidious import export (#45)
* Invidious import export

* Delete duplicate profiles

* Subscription cleanup

* No need for export

* Load user playlists

* Write profile to file

* playlist limit
2023-02-19 10:35:54 -05:00
Brahim Hadriche ece50b547e Update README.md 2023-02-17 09:07:52 -05:00
Brahim Hadriche 7a27bc673e Update README.md 2023-02-16 16:49:32 -05:00
Brahim Hadriche 822f95bb9d Update CHANGELOG.md 2023-02-14 19:14:28 -05:00
Brahim Hadriche 57f4c7a4a2 Add benchmark video 2023-02-14 19:08:38 -05:00
Brahim Hadriche d1cb877784 Format views for billions 2023-02-14 16:28:32 -05:00
Brahim Hadriche 0de521c525 Add git commit to the state api 2023-02-12 10:27:37 -05:00
Brahim Hadriche 447e58c336 Update release.yml 2023-02-12 10:09:40 -05:00
Brahim Hadriche 66cf61059b Update release.yml 2023-02-12 09:39:39 -05:00
Brahim Hadriche f1f1e550bc Update ci (#49)
* Update lint.yml

* Update release.yml

* Update release.yml

* Update release.yml

* Update release.yml
2023-02-12 09:34:36 -05:00
Brahim Hadriche fb7a898cfa Fix web build on ci 2023-02-12 08:57:25 -05:00
Brahim Hadriche f40e0b7471 Remove image generation from ci command 2023-02-11 22:11:41 -05:00
Brahim Hadriche 43f0159510 Update lint.yml 2023-02-10 21:02:21 -05:00
Brahim Hadriche 80d67cf417 Update release.yml 2023-02-10 20:59:50 -05:00
Brahim Hadriche b0bbb97626 Update release.yml 2023-02-10 20:58:08 -05:00
Brahim Hadriche beb607a2d0 Create release.yml 2023-02-10 20:56:36 -05:00
Brahim Hadriche 043a0e5301 [part 1] Feature/ci release (#48)
* Git status check

* Add git hash to manifest
2023-02-10 20:31:25 -05:00
Brahim Hadricheandgithub-action linter e0020ffa66 SponsorBlock Notification (#47)
* SponsorBlock Notification

* Lint fix

* Reuse animation for multiple skips

* Small change

* Rename color utils

* Lint fix

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-02-10 15:20:08 -05:00
Brahim Hadriche 9697ac58d0 Fix crash in case GetLocalIpAddress returns invalid 2023-02-07 20:40:25 -05:00
Brahim Hadriche 97921aab6e Add comment 2023-02-05 17:42:25 -05:00
Brahim Hadriche e4489cd2cb Release 0.7.0 (#46) 2023-02-04 19:05:00 -05:00
Brahim Hadriche aea2cb39d7 Add playlet lib url to settings 2023-02-04 18:56:11 -05:00
Brahim Hadriche 98e07877e3 Deps bump 2023-02-04 11:39:34 -05:00
Brahim Hadriche a4970b3e14 Input args always notify 2023-02-04 11:32:20 -05:00
Brahim Hadriche 0bd05cdba6 Fix debugger 2023-02-04 11:30:35 -05:00
github-action linter 9dcfd20c57 Lint fix 2023-02-03 18:15:08 +00:00
Brahim Hadriche 757bd50701 Fix Issue where auto-play keeps playing the same videos in a loop 2023-02-03 13:14:24 -05:00
Brahim Hadriche ae37623756 json playlet lib urls 2023-02-02 14:55:38 -05:00
Brahim Hadriche 2cffe72d7b Inject Rale task 2023-02-02 14:32:30 -05:00
Brahim Hadriche 3f85d609d8 Put ip package back 2023-01-30 14:18:27 -05:00
Brahim Hadriche 1faec073f0 Fix bsconst plugin 2023-01-30 08:35:00 -05:00
Brahim Hadriche 5aac07d36c Add support for multiple caption languages 2023-01-29 20:27:24 -05:00
Brahim Hadriche d91411b740 Fixes to pass certification (#44) 2023-01-29 18:09:09 -05:00
Brahim Hadriche d14c729c91 Changelog 2023-01-29 17:00:44 -05:00
Brahim Hadricheandgithub-action linter 9d8a3d1cea Create Component Library (#43)
* Move src under playlet-lib

* Update configuration

* Update script

* Update script

* Working version

* Vs code config WIP

* Package lock sync

* Lint fix

* Fix images

* Reuse config files

* Kind of a working setup

* Lock node version

* Rename scripts to tools

* Fix build scripts, lib url system

* Lint fix

* rale

* Fix args and web server

* Load fallbacks and build script cleanups

* Remove unused method

* no message

* no message

* Remove generic message field

* Lint fix

* no message

* Use loading indicator on main app

* Add playlet lib version to settings

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-01-29 16:50:28 -05:00
Brahim Hadricheandgithub-action linter 90df81df4b Better login (#39)
* Better login

* Lint fix

* Restore some changes

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-01-25 07:52:23 -05:00
Brahim Hadriche fa1bc29220 Add common folder to debug routes 2023-01-23 19:09:21 -05:00
Brahim Hadriche 1366284453 Fix for sync script 2023-01-22 22:37:37 -05:00
Brahim Hadriche a38c6ebf7f Redirect with 302 by default 2023-01-22 21:42:47 -05:00
Brahim Hadriche ee29d7a4b3 Remove not needed utils 2023-01-22 21:40:11 -05:00
Brahim Hadriche 9848c2a31a Small tweak 2023-01-22 15:33:19 -05:00
Brahim Hadriche 2ff73c3bc7 Simple script to import youtube data to invidious (#41)
* Simple script to import youtube data to invidious

* Lazy playlist to avoid hanging

* argparse
2023-01-22 14:47:16 -05:00
Brahim Hadriche 4926965daf Add invidious settings to feedback url 2023-01-21 11:12:52 -05:00
Brahim Hadriche 7045386901 Add comment 2023-01-20 10:03:37 -05:00
Brahim Hadriche cc8ab757cf Update README.md 2023-01-18 14:32:02 -05:00
Brahim Hadriche c9e9e34b42 Update dependencies, do not parse non json 2023-01-14 13:11:47 -05:00
Brahim Hadriche 7a155c689e Sign app for publishing (#38)
* Sign app for publishing

* update gitignore

* refactor input args

* Change instance api sorting

* Better instance sorting

* Instance filter

* remove hardcoded instance

* script cleanups

* Unused function
2023-01-11 11:52:43 -05:00
Brahim Hadriche 4640a34863 Create PRIVACY.md 2023-01-10 19:27:47 -05:00
178 changed files with 5846 additions and 3596 deletions

No files matched your search

-2
View File
@@ -1,8 +1,6 @@
name: Linter
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
+35
View File
@@ -0,0 +1,35 @@
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
run: gh release delete unstable --cleanup-tag --yes || echo "unstable release was not deleted"
env:
GH_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 }}
+3 -1
View File
@@ -3,5 +3,7 @@ out/
node_modules
.vscode/.env
**/roku_modules/**
playlet-lib/src/www
playlet/src/lib/playlet-lib.zip
release/playlet.zip
src/www
release/playlet.pkg
+1
View File
@@ -0,0 +1 @@
engine-strict=true
+27 -3
View File
@@ -10,10 +10,27 @@
"stopOnEntry": false,
"enableDebuggerAutoRecovery": false,
"stopDebuggerOnAppExit": false,
"rootDir": "${workspaceFolder}/dist/build",
"rootDir": "${workspaceFolder}/dist/build/playlet",
"sourceDirs": [
"${workspaceFolder}/playlet/src"
],
"files": [
"**/*"
],
"componentLibraries": [
{
"rootDir": "${workspaceFolder}/dist/build/playlet-lib",
"outFile": "playlet-lib.zip",
"files": [
"**/*"
]
}
],
"preLaunchTask": "build-dev",
"name": "Playlet (dev)",
"injectRdbOnDeviceComponent": true
"injectRdbOnDeviceComponent": true,
"injectRaleTrackerTask": true,
"raleTrackerTaskFileLocation": "${workspaceFolder}/tools/RALE/TrackerTask.xml"
},
{
"type": "brightscript",
@@ -24,7 +41,14 @@
"stopOnEntry": false,
"enableDebuggerAutoRecovery": false,
"stopDebuggerOnAppExit": false,
"rootDir": "${workspaceFolder}/dist/build",
"rootDir": "${workspaceFolder}/dist/build/playlet",
"sourceDirs": [
"${workspaceFolder}/playlet/src",
"${workspaceFolder}/playlet-lib/src"
],
"files": [
"**/*",
],
"preLaunchTask": "build-prod",
"name": "Playlet (prod)"
},
+3
View File
@@ -0,0 +1,3 @@
{
"brightscript.output.clearConsoleOnChannelStart": false
}
+42 -13
View File
@@ -3,22 +3,51 @@
"tasks": [
{
"label": "build-dev",
"presentation": {
"close": true,
"reveal": "silent",
"revealProblems": "onProblem"
},
"script": "build:dev",
"type": "npm"
"dependsOn": [
"build-app-dev"
]
},
{
"label": "build-app-dev",
"script": "build:app:dev",
"type": "npm",
"dependsOn": [
"build-lib-dev"
]
},
{
"label": "build-lib-dev",
"script": "build:lib:dev",
"type": "npm",
"dependsOn": [
"build-web"
]
},
{
"label": "build-prod",
"presentation": {
"close": true,
"reveal": "silent",
"revealProblems": "onProblem"
},
"script": "build:prod",
"dependsOn": [
"build-app-prod"
]
},
{
"label": "build-app-prod",
"script": "build:app:prod",
"type": "npm",
"dependsOn": [
"build-lib-prod"
]
},
{
"label": "build-lib-prod",
"script": "build:lib:prod",
"type": "npm",
"dependsOn": [
"build-web"
]
},
{
"label": "build-web",
"script": "build:web",
"type": "npm"
}
]
+19 -1
View File
@@ -4,6 +4,24 @@ 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.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
@@ -25,7 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
+39
View File
@@ -0,0 +1,39 @@
# PRIVACY POLICY
## Playlet
Playlet, the Roku app, does not collect any user information whatsoever.
In fact, it does not have any servers capable of collecting any form of data.
Playlet does not show advertising, whether personalized or non personalized.
## Invidious
Playlet may request information from one or more [Invidious](https://invidious.io/)
servers, depending on user configuration. With these requests, absolutely no
user data is collected, and only the bare minimum and necessary information
is sent, which is used to enable the viewing of content.
Please note that some of the [Invidious](https://invidious.io/) servers used
could be public instances hosted by volenteers. These instances are available
[here](https://api.invidious.io/).
While invidious does no data collection by default, and it is in fact built to
be privacy driven, but in theory, from a playlet request it is possible to
know the IP address of a user, the identifiers of watched video, and search
keywords. In case the user is unreasonably paranoid, they can host their own
Invidious instance and use it from Playlet.
## SponsorBlock
Playlet may request information from a [SponsorBlock](https://github.com/ajayyy/SponsorBlock)
server, in order to get sponsor sections for requested videos to watch.
With these requests, absolutely no
user data is collected, and only the bare minimum and necessary information
is sent, which is used to enable the viewing of content.
Playlet uses hashing when requesting video metadata, which obfuscates
the video id requested. This is a SponsorBlock privacy feature that protects
user privacy.
Additionally, Playlet may send a "skipped" event to SponsorBlock, to indicate
that a section of a video has been skipped. This event does not have any
tracking information attached to it, and it is anonymous. It is merely to
indicate to contributers how much their contributions are being used in the wild.
+20 -9
View File
@@ -1,10 +1,18 @@
# 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">
<img alt="AGPL-3.0 license" src="https://img.shields.io/github/license/iBicha/playlet.svg"/>
</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>
</p>
# Playlet
Unofficial Youtube client for Roku 📺
Playlet is an unofficial Youtube client for Roku 📺
## Features
- 🔥 No Ads (Not now, not ever)
@@ -13,6 +21,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 +39,15 @@ 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"/>
| ![](screenshot1.jpg) | ![](screenshot2.jpg) | ![](screenshot3.jpg) |
|----------------------|----------------------|----------------------|
## Installation
### Roku Store (Published app)
Search for "Playlet" in the Roku Store, or use the link https://my.roku.com/account/add?channel=PLAYLET
### Enable Roku Developer Mode
### Sideloaded (Dev app)
#### Enable Roku Developer Mode
First, you need to enable developer mode on your Roku TV (if you have not done that already).
Using your Roku remote, enter the following sequence:
@@ -47,13 +58,13 @@ For full instructions, see [Set up your Roku device to enable Developer Settings
Make sure to remember the password you set during this step, you will need it later.
### Gather your info
#### Gather your info
By now, you should have the following
- Your Roku Dev password (setup in the previous step)
- Your Roku TV local IP address
- You can find this information in your TV network settings. It should look like 192.168.X.X or so
### Install Playlet (command line)
#### Install Playlet (command line)
Install Playlet as a dev channel using this command, and replace:
- `REPLACE_PASSWORD_HERE` : with your Roku Dev password
@@ -69,7 +80,7 @@ curl https://raw.githubusercontent.com/iBicha/playlet/main/install.sh | ROKU_DEV
If successful, you should see some output on your terminal, with `Status: 200`.
### Install Playlet (Manual)
#### Install Playlet (Manual)
1. Go to `https://github.com/iBicha/playlet/releases` and download `playlet.zip`
2. Open `http://REPLACE_IP_ADDRESS_HERE/` (e.g. http://192.168.1.2/) in your browser
3. If prompted for username and password
-5
View File
@@ -1,5 +0,0 @@
{
"extends": "config/bsconfig.base.json",
"host": "If your Roku IP is static, you can set it here and remove the host entry from .vscode/launch.json",
"password": ""
}
+6 -5
View File
@@ -12,16 +12,19 @@
"source/**/*",
"components/**/*",
"images/**/*",
"!images/vector/**/*",
"fonts/**/*",
"config/**/*",
"lib/**/*",
"www/**/*.*",
"manifest"
],
"lintConfig": "config/bslint.jsonc",
"lintConfig": "./config/bslint.jsonc",
"plugins": [
"roku-log-bsc-plugin",
"@rokucommunity/bslint",
"../scripts/asynctask-plugin.ts"
"../tools/asynctask-plugin.ts",
"../tools/manifest-bsconst-debug-plugin.ts"
],
"retainStagingDir": true,
"require": [
@@ -32,7 +35,5 @@
"removeComments": false,
"strip": false
},
"rootDir": "../src/",
"sourceMap": true,
"stagingDir": "dist/build"
"sourceMap": true
}
+1015 -3159
View File
File diff suppressed because it is too large. Load diff
+36 -21
View File
@@ -1,27 +1,34 @@
{
"name": "playlet",
"version": "0.6.0",
"version": "0.8.0",
"description": "Unofficial Youtube client for Roku",
"dependencies": {
"bslib": "npm:@rokucommunity/bslib@^0.1.1",
"log": "npm:roku-log@^0.8.0",
"roku-requests": "^0.2.0"
"log": "npm:roku-log@^0.9.3",
"roku-requests": "^1.1.0"
},
"devDependencies": {
"@rokucommunity/bslint": "^0.7.5",
"@rokucommunity/bslint": "^0.8.1",
"@types/node": "^18.11.18",
"brighterscript": "^0.60.6",
"brighterscript-formatter": "^1.6.19",
"argparse": "^2.0.1",
"brighterscript": "^0.61.3",
"brighterscript-formatter": "^1.6.23",
"convert-svg-to-png": "^0.6.4",
"dotenv": "^16.0.3",
"roku-log-bsc-plugin": "^0.6.1",
"ropm": "^0.10.10",
"express": "^4.18.2",
"ip": "^1.1.8",
"roku-log-bsc-plugin": "^0.7.0",
"ropm": "^0.10.11",
"semver": "^7.3.8",
"shelljs": "^0.8.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
"typescript": "^4.9.5"
},
"engines": {
"node": "<19.0.0"
},
"ropm": {
"rootDir": "src",
"rootDir": "playlet-lib/src",
"noprefix": [
"roku-requests"
]
@@ -29,21 +36,29 @@
"scripts": {
"dev:web": "cd playlet-web && npm run dev",
"prebuild": "rm -rf dist",
"build:dev": "npm run build:web && npm run build:lib:dev && npm run build:app:dev",
"build:prod": "npm run build:web && npm run build:lib:prod && npm run build:app:prod",
"build:release": "npm run build:release:ci && npm run sign-package",
"build:release:ci": "npm run format:fix && npm run lint:fix && npm run manifest-version && npm run manifest-git-hash && npm run build:prod",
"build:app": "cd playlet && bsc --create-package --lintConfig ../config/bslint.jsonc",
"build:app:dev": "npm run build:app -- --debug=true",
"build:app:prod": "npm run build:app -- --debug=false --sourceMap=false",
"build:lib": "cd playlet-lib && bsc --create-package --lintConfig ../config/bslint.jsonc",
"build:lib:dev": "npm run build:lib -- --debug=true",
"build:lib:prod": "npm run build:lib -- --debug=false --sourceMap=false",
"build:web": "cd playlet-web && npm run build",
"build": "npm run build:web && bsc",
"build:dev": "npm run manifest-symbols -- DEBUG=true && npm run build",
"build:prod": "npm run manifest-symbols -- DEBUG=false && npm run build -- --sourceMap=false",
"build:release": "npm run format:fix && npm run lint:fix && npm run manifest-version && npm run generate-images && npm run build:prod && npm run zip-package",
"lint": "bslint --project config/bsconfig.lint.json --lintConfig config/bslint.jsonc",
"lint": "bslint --project playlet-lib/bsconfig.lint.json --lintConfig config/bslint.jsonc && bslint --project playlet/bsconfig.lint.json --lintConfig config/bslint.jsonc",
"lint:fix": "npm run lint -- --fix",
"format:base": "bsfmt \"src/**/*.brs\" \"src/**/*.bs\" \"!src/components/lib/**/*\" \"!src/source/lib/**/*\" \"!**/bslib.brs\" \"!**/roku_modules/**/*\" --bsfmt-path \"config/bsfmt.jsonc\"",
"format:base": "bsfmt \"playlet/src/**/*.brs\" \"playlet/src/**/*.bs\" \"!playlet/src/components/lib/**/*\" \"!playlet/src/source/lib/**/*\" \"!**/bslib.brs\" \"!**/roku_modules/**/*\" \"playlet-lib/src/**/*.brs\" \"playlet-lib/src/**/*.bs\" \"!playlet-lib/src/components/lib/**/*\" \"!playlet-lib/src/source/lib/**/*\" \"!**/bslib.brs\" \"!**/roku_modules/**/*\" --bsfmt-path \"config/bsfmt.jsonc\"",
"format": "npm run format:base -- --check",
"format:fix": "npm run format:base -- --write",
"generate-images": "node scripts/generate-images.js",
"manifest-version": "node scripts/update-manifest-version.js",
"zip-package": "node scripts/zip-package.js",
"screenshot": "node scripts/screenshot.js",
"manifest-symbols": "node scripts/update-manifest-symbols.js",
"generate-images": "node tools/generate-images.js",
"manifest-version": "node tools/update-manifest-version.js",
"manifest-git-hash": "node tools/update-manifest-git-hash.js",
"sign-package": "node tools/sign-package.js",
"screenshot": "node tools/screenshot.js",
"profile-sync": "node tools/profile-sync.js",
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
"postinstall": "npx ropm copy && cd playlet-web && npm install"
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "../config/bsconfig.base.json",
"rootDir": "src/",
"stagingDir": "../dist/build/playlet-lib",
"outFile": "../playlet/src/lib/playlet-lib.zip"
}
@@ -1,7 +1,7 @@
{
"createPackage": false,
"deploy": false,
"extends": "bsconfig.base.json",
"extends": "bsconfig.json",
"retainStagingDir": false,
"sourceMap": false
}
File renamed without changes.
@@ -8,8 +8,6 @@ function Init()
m.top.ObserveField("focus", "OnFocusChange")
m.top.ObserveField("refresh", "OnRefresh")
m.top.focus = true
InitContent()
end function
@@ -32,7 +30,7 @@ function InitContent()
}, true)
m.top.content = contentNode
m.defaultLayout = ParseJson(ReadAsciiFile("pkg:/config/default_home_layout.json"))
m.defaultLayout = ParseJson(ReadAsciiFile("libpkg:/config/default_home_layout.json"))
if m.defaultLayout.Count() > 0
m.currentLoadingIndex = 0
@@ -4,20 +4,15 @@ import "pkg:/components/VideoPlayer/Video.bs"
function Init()
log.initializeLogManager(["log_PrintTransport"], 2)
m.top.backgroundColor = "0x242424FF"
m.top.backgroundURI = ""
m.loadingIndicator = m.top.findNode("LoadingIndicator")
m.videoContainer = m.top.findNode("VideoContainer")
m.global.addFields({
loadingIndicator: m.loadingIndicator,
videoContainer: m.videoContainer
})
m.loadingIndicator.visible = true
m.homeGridScreen = m.top.findNode("HomeGridScreen")
m.homeGridScreen.ObserveField("escape", "OnHomeGridScreenEscape")
m.homeGridScreen.SetFocus(true)
m.currentFocued = m.homeGridScreen
m.settingsScreen = m.top.findNode("SettingsScreen")
@@ -28,9 +23,13 @@ function Init()
m.navBar.ObserveField("escapeIndex", "OnNavBarEscape")
m.navBar.ObserveField("focusIndex", "OnNavIndexChange")
m.currentFocued = m.homeGridScreen
InitWebServer()
LaunchArgumentsReceived()
scene = m.top.getScene()
scene.ObserveField("inputArgs", "InputArgumentsReceived")
scene.signalBeacon("AppLaunchComplete")
end function
function InitWebServer()
@@ -97,29 +96,25 @@ function OnWebServerCommand()
end if
end function
function GetIndexOfChild(parent as object, childId as string) as integer
count = parent.getChildCount()
for i = 0 to count - 1
child = parent.getChild(i)
if child.id = childId
return i
end if
end for
return -1
function LaunchArgumentsReceived() as void
scene = m.top.getScene()
launchArgs = scene.launchArgs
? "LaunchArgumentsReceived " launchArgs
PlayVideoFromArgs(launchArgs)
end function
function LaunchArgumentsReceived()
? "LaunchArgumentsReceived" m.top.launchArgs
if m.top.launchArgs <> invalid and m.top.launchArgs.contentId <> invalid
sender = m.videoContainer.sender ?? m.currentFocued
PlayVideo(m.top.launchArgs.contentId, { sender: sender })
end if
function InputArgumentsReceived() as void
scene = m.top.getScene()
inputArgs = scene.inputArgs
? "InputArgumentsReceived " inputArgs
PlayVideoFromArgs(inputArgs)
end function
function InputArgumentsReceived()
? "InputArgumentsReceived" m.top.inputArgs
if m.top.inputArgs <> invalid and m.top.inputArgs.contentId <> invalid
sender = m.videoContainer.sender ?? m.currentFocued
PlayVideo(m.top.inputArgs.contentId, { sender: sender })
function PlayVideoFromArgs(args as object) as void
if args = invalid or args.contentId = invalid
return
end if
sender = m.videoContainer.sender ?? m.currentFocued
PlayVideo(args.contentId, { sender: sender })
end function
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="MainScene" extends="Group">
<children>
<SearchScreen id="SearchScreen" visible="false" />
<HomeGridScreen id="HomeGridScreen" />
<SettingsScreen id="SettingsScreen" visible="false" />
<NavBar id="NavBar" />
<VideoContainer id="VideoContainer" />
</children>
</component>
@@ -51,7 +51,7 @@ function OnExitDialog(event as object)
buttonIndex = event.GetData()
if buttonIndex = 0 ' Exit
? "EXITING APP"
m.top.GetScene().exitChannel = true
m.top.getScene().exitChannel = true
end if
end function
@@ -4,7 +4,10 @@ import "pkg:/source/roku_modules/rokurequests/Requests.brs"
@asynctask
function AppVersionTask() as object
latest = "N/A"
response = Requests().request("HEAD", "https://github.com/iBicha/playlet/releases/latest", 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
@@ -1,13 +1,22 @@
import "pkg:/source/utils/General.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/asyncTask/asyncTask.bs"
import "pkg:/components/SettingsScreen/AppVersionTask.bs"
function Init()
m.versionLabel = m.top.findNode("VersionLabel")
m.playletLibUrlLabel = m.top.findNode("PlayletLibUrlLabel")
m.top.url = `http://${GetLocalIpAddress()}:8888`
appInfo = GetAppInfo()
m.currentVersion = appInfo.version
SetVersionLabel(m.currentVersion, "N/A")
m.top.appVersion = appInfo.version
m.top.libVersion = appInfo.lib_version
scene = m.top.getScene()
if scene.playletLibLoadedUrl <> invalid
m.top.libUrl = `[${scene.playletLibLoadedUrl.type}|${scene.playletLibLoadedUrl.link}]`
end if
GetLatestVersion()
end function
@@ -24,11 +33,15 @@ end function
function GetLatestVersion()
StartAsyncTask(AppVersionTask, {}, function(output as object) as void
if output.result.latest <> invalid
SetVersionLabel(m.currentVersion, output.result.latest)
m.top.latestVersion = output.result.latest
end if
end function)
end function
function SetVersionLabel(current as string, latest as string)
m.versionLabel.text = `Version: ${current} | Latest: ${latest}`
function SetVersionLabel()
m.versionLabel.text = `Playlet: ${m.top.appVersion} | Playlet-Lib: ${m.top.libVersion} | Latest: ${m.top.latestVersion}`
end function
function SetPlayletLibUrlLabel()
m.playletLibUrlLabel.text = `Playlet-Lib: ${m.top.libUrl}`
end function
@@ -2,16 +2,28 @@
<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" />
</interface>
<children>
<Label
id='VersionLabel'
height='50'
height='60'
width='1280'
font='font:MediumBoldSystemFont'
horizAlign="center"
translation="[0,100]"
translation="[0,80]"
/>
<Label
id='PlayletLibUrlLabel'
height='60'
width='1280'
font='font:SmallestBoldSystemFont'
horizAlign="center"
translation="[0,120]"
/>
<QRPoster
id='SettingsQRPoster'
@@ -0,0 +1,65 @@
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 OnSegmentSet()
category = m.top.segment.category
categoryTitle = SponsorBlock.SegmentShortTitle(category)
m.categoryLabel.text = "Skipped" + chr(10) + categoryTitle
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.state = "running"
return
end if
' Check if we are already at the destination
if m.translationAnimation.state = "stopped"
if reverse
destination = m.translationAnimationInterpolator.keyValue[0][0]
else
destination = m.translationAnimationInterpolator.keyValue[1][0]
end if
current = m.top.translation[0]
if current = destination
return
end if
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,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="SponsorBlockNotification" extends="Group">
<interface>
<field id="segment" type="assocarray" onChange="OnSegmentSet" />
</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,27 @@
import "pkg:/components/VideoPlayer/Video.bs"
function ShowSponsorBlockNotifcation(segment as object)
videoContainer = GetVideoContainer()
notification = videoContainer.findNode("sponsorBlockNotification")
if notification = invalid
notification = videoContainer.createChild("SponsorBlockNotification")
notification.id = "sponsorBlockNotification"
end if
notification.segment = segment
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
@@ -1,5 +1,6 @@
import "pkg:/source/services/Invidious.bs"
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/SponsorBlockNotification/SponsorBlockNotificationManager.bs"
function PlayVideo(videoId as string, args = invalid as object)
sender = args?.sender
@@ -23,6 +24,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
@@ -49,6 +51,7 @@ function CloseVideo(setFocus = true as boolean)
videoContainer.sender.SetFocus(true)
end if
end if
SponsorBlockNotifcationSetVisible(false)
end function
function ToggleVideoPictureInPicture(sender = invalid as object) as boolean
@@ -0,0 +1,20 @@
import "pkg:/source/utils/RingBuffer.bs"
function Init()
m.watchedVideos = new RingBuffer(100)
end function
function watchedVideosContain(videoId as string) as boolean
return m.watchedVideos.Contains(videoId)
end function
function watchedVideosAdd(videoId as string)
if not watchedVideosContain(videoId)
m.watchedVideos.Push(videoId)
end if
end function
' watchedVideosClear needs at least one arg https://github.com/rokucommunity/brighterscript/blob/master/docs/callfunc-operator.md#callfunc-evaluation-with-no-arguments
function watchedVideosClear(unused as dynamic)
m.watchedVideos = new RingBuffer(100)
end function
@@ -5,5 +5,8 @@
<field id="videoPlayer" type="node" />
<field id="sender" type="node" />
<field id="fullscreen" type="boolean" value="true" />
<function name="watchedVideosContain" />
<function name="watchedVideosAdd" />
<function name="watchedVideosClear" />
</interface>
</component>
@@ -4,6 +4,8 @@ import "pkg:/components/VideoPlayer/Video.bs"
import "pkg:/components/VideoPlayer/VideoDetailsTask.bs"
function Init()
m.videoContainer = GetVideoContainer()
SetupSponsorBlock()
SetupAnimation()
SetupBusySpinner()
@@ -12,7 +14,6 @@ function Init()
m.top.bufferingBar.filledBarBlendColor = "0xFF0000FF"
m.top.retrievingBar.filledBarBlendColor = "0xFF0000FF"
m.videoContainer = GetVideoContainer()
m.top.enableUI = m.videoContainer.fullscreen
m.videoContainer.observeFieldScoped("fullscreen", "OnFullScreenChange")
@@ -38,6 +39,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
end if
end if
if key = "back"
m.videoContainer@.watchedVideosClear()
CloseVideo()
return true
end if
@@ -115,6 +117,14 @@ function OnVideoDetailsTaskResults(output as object) as void
end if
playletStreamUrls.push(hlsUrlLocal)
else
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))
end if
if metadata.dashUrl <> invalid
#if DASH_THUMBNAILS
@@ -133,13 +143,6 @@ function OnVideoDetailsTaskResults(output as object) as void
playletStreamUrls.push(dashUrlLocal)
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))
end if
end if
metadata.playletStreamUrls = playletStreamUrls
@@ -156,6 +159,8 @@ function OnVideoDetailsTaskResults(output as object) as void
m.busySpinner.control = "stop"
m.top.content = contentNode
m.top.control = "play"
m.videoContainer@.watchedVideosAdd(videoId)
end function
function FindChildNodeOfType(node as object, nodeType as string) as object
@@ -277,11 +282,8 @@ function OnVideoPlayerStateChange() as void
if state = "finished"
metadata = m.top.content?.metadata
metadata = metadata?.recommendedVideos?.GetEntry(0)
videoId = metadata?.videoId
if videoId <> invalid
PlayVideo(videoId, { metadata: metadata })
else
if not PlayNextRecommendedVideo(metadata?.recommendedVideos)
CloseVideo()
end if
end if
@@ -297,6 +299,25 @@ function OnVideoPlayerStateChange() as void
end if
end function
function PlayNextRecommendedVideo(recommendedVideos as object) as boolean
if recommendedVideos = invalid or recommendedVideos.Count() = 0
return false
end if
for each metadata in recommendedVideos
videoId = metadata?.videoId
if videoId = invalid
continue for
end if
if not m.videoContainer@.watchedVideosContain(videoId)
PlayVideo(videoId, { metadata: metadata })
return true
end if
end for
return false
end function
function SetupAnimation()
m.widthAnimation = m.top.findNode("widthAnimation")
m.widthAnimationInterpolator = m.top.findNode("widthAnimationInterpolator")
@@ -316,4 +337,5 @@ function OnFullScreenChange()
m.translationAnimation.control = "start"
m.top.enableUI = m.videoContainer.fullscreen
SponsorBlockNotifcationSetVisible(m.videoContainer.fullscreen)
end function
@@ -0,0 +1,21 @@
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"))
' TODO: loop through instances until valid captions are found
' Captions are rate limited https://github.com/iv-org/invidious/issues/2567
instance = InvidiousSettings.GetSelectedInstance()
subtitleTracks = []
for each caption in metadata.captions
subtitleTracks.Push({
Description: caption.label,
Language: isoLanguageList[caption.language_code] ?? caption.language_code,
TrackName: instance + caption.url
})
end for
contentNode.ClosedCaptions = True
contentNode.SubtitleTracks = subtitleTracks
end function
@@ -1,9 +1,13 @@
import "pkg:/source/asyncTask/asyncTask.bs"
import "pkg:/components/VideoPlayer/SponsorBlockTask.bs"
import "pkg:/components/VideoPlayer/SponsorBlockTrackingTask.bs"
import "pkg:/components/SponsorBlockNotification/SponsorBlockNotificationManager.bs"
function SetupSponsorBlock()
PositionChapterLabel()
SponsorBlockNotifcationSetVisible(m.videoContainer.fullscreen)
m.timeLabel = FindTimeLabel()
m.top.trickPlayBar.observeField("visible", "OnTrickPlayBarVisible")
m.chapterLabelTimer = m.top.findNode("chapterLabelTimer")
@@ -123,6 +127,7 @@ function OnPositionChangeSkipSponsorBlockSections() as void
' TODO: if segmentEnd is at the end of the video, close video
m.top.seek = segmentEnd
print("Skipping section:" + segment["category"])
ShowSponsorBlockNotifcation(segment)
SendSkippedSectionEvent(segment.UUID)
return
end if
@@ -1,42 +1,45 @@
import "pkg:/source/utils/TimeUtils.bs"
function OnContentSet()
function OnContentSet() as void
content = m.top.itemContent
if content <> invalid
m.top.FindNode("titleLabel").text = content.title
m.top.FindNode("authorLabel").text = content.author
if content = invalid
return
end if
if IsVideoUpcoming(content)
m.top.FindNode("viewCountDateLabel").text = `Premeres in ${TimeUtils.GetFormattedTimeLeft(content.premiereTimestamp)}`
m.top.FindNode("titleLabel").text = content.title
m.top.FindNode("authorLabel").text = content.author
if IsVideoUpcoming(content)
m.top.FindNode("viewCountDateLabel").text = `Premeres in ${TimeUtils.GetFormattedTimeLeft(content.premiereTimestamp)}`
else
publishedText = validstr(content.publishedText)
viewCount = FormatViewCount(content.viewCount)
if publishedText = "" and viewCount = ""
m.top.FindNode("viewCountDateLabel").text = ""
else
publishedText = validstr(content.publishedText)
viewCount = FormatViewCount(content.viewCount)
if publishedText = "" and viewCount = ""
m.top.FindNode("viewCountDateLabel").text = ""
else
m.top.FindNode("viewCountDateLabel").text = `${publishedText} • ${viewCount}`
end if
end if
m.thumbnail = m.top.FindNode("thumbnail")
m.thumbnail.observeField("loadStatus", "OnThumbnailLoadFailed")
m.thumbnail.uri = GetThumbnailUrl(content.videoThumbnails)
m.thumbnail.id = `thumbnail-${content.videoId}`
if IsVideoLive(content)
m.top.FindNode("liveRect").visible = true
m.top.FindNode("durationRect").visible = false
else
m.top.FindNode("liveRect").visible = false
if content.lengthSeconds <> invalid and content.lengthSeconds <> 0
m.top.FindNode("durationLabel").text = TimeUtils.GetFormattedTime(content.lengthSeconds)
m.top.FindNode("durationRect").visible = true
else
m.top.FindNode("durationRect").visible = false
end if
m.top.FindNode("viewCountDateLabel").text = `${publishedText} • ${viewCount}`
end if
end if
m.thumbnail = m.top.FindNode("thumbnail")
m.thumbnail.observeField("loadStatus", "OnThumbnailLoadFailed")
m.thumbnail.uri = GetThumbnailUrl(content.videoThumbnails)
m.thumbnail.id = `thumbnail-${content.videoId}`
if IsVideoLive(content)
m.top.FindNode("liveRect").visible = true
m.top.FindNode("durationRect").visible = false
else
m.top.FindNode("liveRect").visible = false
if content.lengthSeconds <> invalid and content.lengthSeconds <> 0
m.top.FindNode("durationLabel").text = TimeUtils.GetFormattedTime(content.lengthSeconds)
m.top.FindNode("durationRect").visible = true
else
m.top.FindNode("durationRect").visible = false
end if
end if
end function
function OnThumbnailLoadFailed() as void
@@ -84,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
@@ -72,7 +72,7 @@ namespace Http
m.source = Http.HttpResponseSource.GENERATED
end function
function Redirect(where as string, code = 301 as integer)
function Redirect(where as string, code = 302 as integer)
m.headers["Location"] = where
message = "Moved to: <a href=" + Quote() + where + Quote() + ">" + where + "</a>"
m.Default(code, message)
@@ -88,6 +88,12 @@ namespace Http
m.source = Http.HttpResponseSource.GENERATED
end function
function SetBodyDataBuffer(buffer as object)
m.body_buffer = buffer
m.body_buffer_length = m.body_buffer.count()
m.ContentLength(m.body_buffer_length)
end function
function SetBodyDataString(data as string)
m.body_buffer.fromasciistring(data)
m.body_buffer_length = m.body_buffer.count()
@@ -22,7 +22,7 @@ namespace Http
dashUrl = `${instance}/api/manifest/dash/id/${v}`
if metadata = invalid and local = invalid
response.Redirect(dashUrl, 302)
response.Redirect(dashUrl)
return true
end if
@@ -30,9 +30,10 @@ namespace Http
dashUrl = `${dashUrl}?local=${local}`
end if
resp = Requests().get(dashUrl)
resp = Requests().get(dashUrl, { parseJson: false })
text = resp.text ?? ""
if resp.statuscode = 200 and local = "true"
' TODO: no longer needed, remove after 6 months of https://github.com/iv-org/invidious/pull/3554
text = text.Replace("<BaseURL>/videoplayback", `<BaseURL>${instance}/videoplayback`)
end if
@@ -7,8 +7,9 @@ namespace Http
private route
private showDirectories
private showHidden
private fsCheck
function new(route as string, root as string, showDirectories = false as boolean, showHidden = false as boolean)
function new(route as string, root as string, showDirectories = false as boolean, showHidden = false as boolean, fsCheck = true as boolean)
super()
m.log = new log.Logger("HttpStaticFilesRouter")
@@ -16,6 +17,7 @@ namespace Http
m.route = route
m.showDirectories = showDirectories
m.showHidden = showHidden
m.fsCheck = fsCheck
m.Get("*", function(context as object) as boolean
router = context.router
@@ -28,9 +30,22 @@ namespace Http
path_in_route = request.route.Mid(router.route.Len())
decoded_path = WebUtils.UrlUnescape(path_in_route)
decoded_path = path_in_route.DecodeUri()
full_path = PathJoin(router.root, decoded_path)
if not router.fsCheck
' libpkg:/ does not work with roFilesystem...
buffer = createObject("roByteArray")
if buffer.ReadFile(full_path) and buffer.count() > 0
mimetype = WebUtils.MimeType(decoded_path)
response.SetBodyDataBuffer(buffer)
response.ContentType(mimetype)
response.http_code = 200
response.source = Http.HttpResponseSource.GENERATED
return true
end if
end if
path = CreateObject("roPath", full_path)
fs = CreateObject("roFilesystem")
@@ -142,7 +157,7 @@ namespace Http
listing = listing + "<title>" + response.settings.ServerName + "</title>" + UnixNL()
listing = listing + "</head>" + UnixNL()
listing = listing + "<body>" + UnixNL()
listing = listing + "<h1>" + WebUtils.URLUnescape(request.uri) + "</h1>" + UnixNL()
listing = listing + "<h1>" + request.uri.DecodeUri() + "</h1>" + UnixNL()
listing = listing + "<tt><pre>" + UnixNL()
dir = path.getString()
@@ -32,14 +32,20 @@ namespace Http
response = context.response
server = context.server
if request.query["token"] <> invalid and request.query["referer"] <> invalid
if request.query["token"] <> invalid and request.query["ref"] <> invalid
' Token is encoded twice for some reason
token = WebUtils.UrlUnescape(request.query["token"]).DecodeUriComponent()
referer = WebUtils.UrlUnescape(request.query["referer"])
InvidiousSettings.SetAuthToken(token, referer)
token = request.query["token"].DecodeUri().DecodeUriComponent()
referer = request.query["ref"].DecodeUri()
username = request.query["username"]
' TODO: remove null check after 6 months of https://github.com/iv-org/invidious/pull/3603
if username <> invalid
username = username.DecodeUriComponent().DecodeUriComponent()
end if
InvidiousSettings.SetAuthToken(token, referer, username)
server.task.top.login = true
end if
response.Redirect("/", 302)
response.Redirect("/")
return true
end function)
end function
@@ -38,7 +38,8 @@ namespace Http
selected_instance: InvidiousSettings.GetSelectedInstance(),
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
@@ -21,7 +21,7 @@ function WebServerLoop()
m.settings = new Http.HttpSettings(m.webServerPort)
' Root at www to get http://IP_ADDRESS:PORT/index.html
m.settings.WwwRoot = "pkg:/www"
m.settings.WwwRoot = "libpkg:/www"
' Short interval to keep polling on web socket messages
m.settings.Timeout = 500
m.server = new Http.HttpServer(m.settings, m)
@@ -39,7 +39,7 @@ function WebServerLoop()
homeRouter = new Http.HttpRouter()
homeRouter.Get("/", function(context as object) as boolean
response = context.response
response.Redirect("/index.v1.html", 302)
response.Redirect("/index.v1.html")
return true
end function)
@@ -48,6 +48,7 @@ function WebServerLoop()
#else
allowedOrigin = `http://${GetLocalIpAddress()}:8888`
#end if
m.server.UseRouter(new Http.CorsMiddleware(allowedOrigin))
#if WEB_SOCKETS
m.server.UseRouter(new Http.WebSocketMiddleware())
@@ -57,11 +58,13 @@ function WebServerLoop()
m.server.UseRouter(new Http.CommandsApiRouter())
m.server.UseRouter(new Http.StateApiRouter())
m.server.UseRouter(new Http.InvidiousRouter())
m.server.UseRouter(new Http.HttpStaticFilesRouter("/", m.settings.WwwRoot))
m.server.UseRouter(new Http.HttpStaticFilesRouter("/", m.settings.WwwRoot, false, false, false))
#if DEBUG
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/libpkg", "libpkg:/", true, true, false))
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/pkg", "pkg:/", true, true))
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/tmp", "tmp:/", true, true))
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/cachefs", "cachefs:/", true, true))
m.server.UseRouter(new Http.HttpStaticFilesRouter("/debug/common", "common:/", true, true))
#end if
#if WEB_SERVER_BASIC_AUTH
m.server.UseRouter(new Http.BasicAuthMiddleware())
@@ -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]
Loaded 100 of 178 files, more files were not shown because too many files have changed in this diff. Show more