Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
982dd0cd2e | ||
|
|
4827537f57 | ||
|
|
586925c2da | ||
|
|
dd79d85cca | ||
|
|
584ee9a38a | ||
|
|
6051d45a80 | ||
|
|
549913ef7d | ||
|
|
8975861615 | ||
|
|
03e08c99c6 | ||
|
|
072b93728a | ||
|
|
57fa1c5c3f | ||
|
|
58ce2d6396 | ||
|
|
837386b6e0 | ||
|
|
9baa132ca3 | ||
|
|
ed2ec9bea5 | ||
|
|
2bc4d43f51 | ||
|
|
a61c0afe16 | ||
|
|
6fd34c13d1 | ||
|
|
e1b7500d7c | ||
|
|
7bfe657401 | ||
|
|
ceeb2bf37b | ||
|
|
3b69140398 | ||
|
|
25e573a1e1 | ||
|
|
d123393b2f | ||
|
|
6e0ee8adf4 | ||
|
|
74742c7e28 | ||
|
|
c740d5e0a0 | ||
|
|
620a8a6e2b | ||
|
|
84835e26e0 | ||
|
|
64f3683a22 | ||
|
|
e80fcabae5 | ||
|
|
a12b6cca11 | ||
|
|
b2f5ed2275 | ||
|
|
fc161ffe4c | ||
|
|
fc3629de09 | ||
|
|
4efbdda167 | ||
|
|
0aad02f5e6 | ||
|
|
ea5ca1c45d |
No files matched your search
@@ -17,6 +17,7 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
|
||||
- name: Configure repo
|
||||
run: |
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"files": [
|
||||
"**"
|
||||
],
|
||||
"componentLibrariesPort": 8086,
|
||||
"componentLibraries": [
|
||||
{
|
||||
"rootDir": "${workspaceFolder}/build/playlet-lib",
|
||||
@@ -59,7 +60,7 @@
|
||||
"command": "npm run dev:web",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "Playlet Web (Chrome)",
|
||||
"type": "chrome",
|
||||
@@ -79,7 +80,10 @@
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Playlet Web (Debug)",
|
||||
"configurations": ["Playlet Web (Dev)", "Playlet Web (Chrome)"],
|
||||
"configurations": [
|
||||
"Playlet Web (Dev)",
|
||||
"Playlet Web (Chrome)"
|
||||
],
|
||||
"stopAll": true
|
||||
}
|
||||
]
|
||||
|
||||
@@ -5,6 +5,44 @@ 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.14.0] - 2023-10-25
|
||||
|
||||
### Added
|
||||
|
||||
- Bookmarks: different items can now be bookmarked, and be found in the `Bookmarks` screen.
|
||||
Things that can be bookmarked:
|
||||
- A video
|
||||
- A channel
|
||||
- A playlist
|
||||
- Subscriptions
|
||||
- Trending
|
||||
- Popular
|
||||
- Playlists
|
||||
- Search results
|
||||
- Channel tabs (latest videos, live streams, playlists, shorts, podcasts, related channels)
|
||||
- Context menu: press and hold `OK` to show a context menu to:
|
||||
- Play/queue a video or a playlist
|
||||
- Open the channel of a playlist or of a video
|
||||
- Manage bookmarks
|
||||
- Local DASH manifest generation
|
||||
- This adds support for multi languages audio tracks
|
||||
- Also adds thumbnails/preview in trick play mode
|
||||
- Known issue: thumbnails might appear cropped/misaligned at the end of videos. This will be addressed in a later release.
|
||||
- Search filters in web app
|
||||
- Channels and Playlists can be opened on TV from web app
|
||||
- Channel links can be drag and dropped into the web app
|
||||
|
||||
### Fixed
|
||||
|
||||
- Layout in channel view so that the upload time and view count of videos is visible
|
||||
- A few things in the logger
|
||||
- A bug where channels show "0 videos". Channel handle is shown instead.
|
||||
|
||||
### Changed
|
||||
|
||||
- Cache format so it does less parsing work
|
||||
- Removed "chapter" from SponsorBlock categories
|
||||
|
||||
## [0.13.1] - 2023-10-08
|
||||
|
||||
### Added
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
# Playlet
|
||||
|
||||
<!-- markdownlint-disable MD033 -->
|
||||
<!-- markdownlint-disable MD033 MD041 -->
|
||||
<p align="center">
|
||||
<img src="docs/banner.png" style="display:block;text-align:center" alt="Playlet Logo" width="800"/>
|
||||
<br/><br/>
|
||||
@@ -19,6 +17,8 @@
|
||||
</a>
|
||||
</p>
|
||||
|
||||
# Playlet
|
||||
|
||||
Playlet is an unofficial Youtube client for Roku 📺
|
||||
|
||||
## Screenshots
|
||||
|
||||
@@ -210,13 +210,13 @@ Additionally, the web server exposes the settings under `/api/preferences`, whic
|
||||
|
||||
When Playlet starts, it shows a video feed on the screen. Subscription, Trending videos, and so on.
|
||||
|
||||
The layout is defined under [playlet-lib/src/config/default_home_layout.json5](/playlet-lib/src/config/default_home_layout.json5).
|
||||
The layout is defined under [playlet-lib/src/config/default_home_layout.yaml](/playlet-lib/src/config/default_home_layout.yaml).
|
||||
|
||||
This could allow users to define custom layouts, so they can see what they find relevant in the home page. This can include Subscription, Trending, Popular videos, Search per keywords, or Playlists.
|
||||
|
||||
Additionally each feed has information on how it is fetched. For now, only Invidious can be data source, but other systems should be configured in the same way.
|
||||
|
||||
Invidious API definitions are defined under [playlet-lib/src/config/invidious_video_api.json5](/playlet-lib/src/config/invidious_video_api.json5), and Playlet parses these at runtime and make the right API calls to fetch the data.
|
||||
Invidious API definitions are defined under [playlet-lib/src/config/invidious_video_api.yaml](/playlet-lib/src/config/invidious_video_api.yaml), and Playlet parses these at runtime and make the right API calls to fetch the data.
|
||||
|
||||
Finally, this layout system is what allows both the BrightScript app and the Web app to display the same homepage.
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@ These are mostly the steps when releasing a new version:
|
||||
For releasing to the store (when needed), this is done following a Playlet lib release:
|
||||
|
||||
- Switch to main branch and pull changes - **match commit corresponding to the release.**
|
||||
- `npm run build:release`
|
||||
- `npm run build:release:ci`
|
||||
- This makes sure to have a valid app in the staging folder
|
||||
- `npm run sign-released-package`
|
||||
- This should create the signed package under `release/playlet.pkg`
|
||||
- Upload to dashboard, and schedule a release (takes a couple of days)
|
||||
@@ -0,0 +1,48 @@
|
||||
<!-- TODO:P1 document models better -->
|
||||
|
||||
# Models
|
||||
|
||||
ApiEndpoint:
|
||||
|
||||
- id
|
||||
- url
|
||||
- queryParams
|
||||
- pathParams
|
||||
- cacheSeconds
|
||||
- paginationType
|
||||
- authenticated
|
||||
- responseHandler
|
||||
|
||||
FeedSource:
|
||||
|
||||
- id
|
||||
- title
|
||||
- apiType: string ("Invidious")
|
||||
- endpoint: ApiEndpoint
|
||||
- pathParams
|
||||
- queryParams
|
||||
- state:
|
||||
- paginationtype (Runtime field)
|
||||
- page (Runtime field)
|
||||
- continuation (Runtime field)
|
||||
- queryParams.page (Runtime field)
|
||||
- queryParams.continuation (Runtime field)
|
||||
|
||||
Feed/FeedContentNode:
|
||||
|
||||
- Title
|
||||
- feedSources: FeedSource[]
|
||||
- feedSourceIndex (Runtime field)
|
||||
|
||||
RowListLayout
|
||||
|
||||
- Feed[]
|
||||
|
||||
Bookmarks
|
||||
|
||||
- BookmarkGroup[]
|
||||
|
||||
BookmarkGroup
|
||||
|
||||
- title
|
||||
- feedSources: FeedSource[]
|
||||
@@ -2,7 +2,7 @@ openapi: 3.0.0
|
||||
|
||||
info:
|
||||
title: Playlet Web API
|
||||
version: 0.13.1
|
||||
version: 0.14.0
|
||||
description:
|
||||
Playlet Web API is a RESTful API for controlling the Playlet app on
|
||||
Roku devices. The API is intended to be used by the Playlet web app, but can
|
||||
@@ -204,6 +204,29 @@ paths:
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
/api/view/open:
|
||||
get:
|
||||
summary: Open a channel view or a playlist view
|
||||
description: Open a channel view or a playlist view. If a video is playing in full screen, it is shrinked.
|
||||
operationId: openView
|
||||
parameters:
|
||||
- name: channelId
|
||||
in: query
|
||||
description: The ID of the channel to open
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
- name: playlistId
|
||||
in: query
|
||||
description: The ID of the playlist to open
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
"400":
|
||||
description: Bad Request
|
||||
/api/playlet-lib-urls:
|
||||
get:
|
||||
summary: Get Playlet lib URLs
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
{
|
||||
"name": "playlet",
|
||||
"version": "0.13.1",
|
||||
"version": "0.14.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playlet",
|
||||
"version": "0.13.1",
|
||||
"version": "0.14.0",
|
||||
"hasInstallScript": true,
|
||||
"devDependencies": {
|
||||
"@rokucommunity/bslint": "^0.8.10",
|
||||
"@rokucommunity/bslint": "^0.8.11",
|
||||
"@types/crypto-js": "^4.1.2",
|
||||
"@types/fs-extra": "^11.0.2",
|
||||
"@types/node": "^20.7.2",
|
||||
"@types/node": "^20.8.4",
|
||||
"@types/xml2js": "^0.4.12",
|
||||
"argparse": "^2.0.1",
|
||||
"brighterscript": "^0.65.7",
|
||||
"brighterscript-formatter": "^1.6.33",
|
||||
"brighterscript": "^0.65.8",
|
||||
"brighterscript-formatter": "^1.6.34",
|
||||
"convert-svg-to-png": "^0.6.4",
|
||||
"cross-fetch": "^4.0.0",
|
||||
"crypto-js": "^4.1.1",
|
||||
@@ -274,9 +274,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@rokucommunity/bslint": {
|
||||
"version": "0.8.10",
|
||||
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.10.tgz",
|
||||
"integrity": "sha512-2aaWPtt5xACm7sIaKR5ctF7f3HrjKGfTVSAT6ZGdojDsXPQanHK2+XyYX20fQVdjJFVn414UCfVkUiaO0PTtog==",
|
||||
"version": "0.8.11",
|
||||
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.11.tgz",
|
||||
"integrity": "sha512-PKtYRngih4oybTN7IEZ4aQp2Bm6a1P4GyKo+F6eJkUmzbCN2glVXvWq+REHBinqEAYyL/3YiSsD4brFWCVPHcw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"fs-extra": "^10.0.0",
|
||||
@@ -355,10 +355,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.7.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.2.tgz",
|
||||
"integrity": "sha512-RcdC3hOBOauLP+r/kRt27NrByYtDjsXyAuSbR87O6xpsvi763WI+5fbSIvYJrXnt9w4RuxhV6eAXfIs7aaf/FQ==",
|
||||
"dev": true
|
||||
"version": "20.8.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.4.tgz",
|
||||
"integrity": "sha512-ZVPnqU58giiCjSxjVUESDtdPk4QR5WQhhINbc9UBrKLU68MX5BF6kbQzTrkwbolyr0X8ChBpXfavr5mZFKZQ5A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~5.25.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/xml2js": {
|
||||
"version": "0.4.12",
|
||||
@@ -710,9 +713,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/brighterscript": {
|
||||
"version": "0.65.7",
|
||||
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.7.tgz",
|
||||
"integrity": "sha512-cmV0JzlYuKIKkMsbHR2FyaD2YugHeHESdMmUOtK61EsEUS895Y6yXftDVnFUwij7beLiZR6s1oRpMfiS7MJ40g==",
|
||||
"version": "0.65.8",
|
||||
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.8.tgz",
|
||||
"integrity": "sha512-mqarSnGCl/VSTRj1oY9wRMZJV9s8dH+rZZ2P1yE7d1nZQucVpAIGICW83G9AJHQYUDjrGsKHn5UfAfaZaE1KCA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@rokucommunity/bslib": "^0.1.1",
|
||||
@@ -753,12 +756,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/brighterscript-formatter": {
|
||||
"version": "1.6.33",
|
||||
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.6.33.tgz",
|
||||
"integrity": "sha512-XmirSAOBBHsprJvLOuh8nzXNiPQJXQa2NJ581OZdQrofFdBNPGH+yFhV6XXUZ+pA6fVLSxMxXA0toF83jtKjrA==",
|
||||
"version": "1.6.34",
|
||||
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.6.34.tgz",
|
||||
"integrity": "sha512-qGjoiIVrbvgit4RkSF4iNZKFCaavzQG/7G9ZgJs87rBHeCOvqBy+e264cD/KwDnhg4kMdvty45zZ+Um8Oeo2UQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"brighterscript": "^0.65.7",
|
||||
"brighterscript": "^0.65.8",
|
||||
"glob-all": "^3.3.0",
|
||||
"jsonc-parser": "^3.0.0",
|
||||
"source-map": "^0.7.3",
|
||||
@@ -4352,6 +4355,12 @@
|
||||
"integrity": "sha512-vohX7ywgBjRxDNw+f3wHclSXmO0z9HsEfmGObOuG7G0yi7kZ6OtCG8kAxtDSNklmua5KR6ev2drTFqMGqpYEbg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "5.25.3",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz",
|
||||
"integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"name": "playlet",
|
||||
"version": "0.13.1",
|
||||
"version": "0.14.0",
|
||||
"description": "Unofficial Youtube client for Roku",
|
||||
"devDependencies": {
|
||||
"@rokucommunity/bslint": "^0.8.10",
|
||||
"@rokucommunity/bslint": "^0.8.11",
|
||||
"@types/crypto-js": "^4.1.2",
|
||||
"@types/fs-extra": "^11.0.2",
|
||||
"@types/node": "^20.7.2",
|
||||
"@types/node": "^20.8.4",
|
||||
"@types/xml2js": "^0.4.12",
|
||||
"argparse": "^2.0.1",
|
||||
"brighterscript": "^0.65.7",
|
||||
"brighterscript-formatter": "^1.6.33",
|
||||
"brighterscript": "^0.65.8",
|
||||
"brighterscript-formatter": "^1.6.34",
|
||||
"convert-svg-to-png": "^0.6.4",
|
||||
"cross-fetch": "^4.0.0",
|
||||
"crypto-js": "^4.1.1",
|
||||
@@ -57,6 +57,7 @@
|
||||
"version-sync": "node tools/version-sync.js",
|
||||
"manifest-git-hash": "node tools/update-manifest-git-hash.js",
|
||||
"sign-package": "node tools/sign-package.js",
|
||||
"sign-released-package": "node tools/sign-released-package.js",
|
||||
"screenshot": "node tools/screenshot.js",
|
||||
"profile-sync": "node tools/profile-sync.js",
|
||||
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "playlet-app",
|
||||
"version": "0.13.1",
|
||||
"version": "0.14.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playlet-app",
|
||||
"version": "0.13.1"
|
||||
"version": "0.14.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playlet-app",
|
||||
"version": "0.13.1",
|
||||
"version": "0.14.0",
|
||||
"description": "Unofficial Youtube client for Roku",
|
||||
"scripts": {
|
||||
"prebuild": "rm -rf build/playlet-app",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<field id="launchArgs" type="assocarray" />
|
||||
<field id="inputArgs" type="assocarray" alwaysNotify="true" />
|
||||
<field id="playletLibLoadedUrl" type="assocarray" />
|
||||
<field id="systemLogEvent" type="assocarray" />
|
||||
<field id="systemLogEvent" type="assocarray" alwaysNotify="true" />
|
||||
</interface>
|
||||
<script type="text/brightscript" uri="pkg:/source/Dialog.bs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/Manifest.bs" />
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
inputHash: '0536f51fa72c2e4e368ea0e901aadfc1',
|
||||
outputs: [
|
||||
{
|
||||
outputFilePath: 'src/images/splash-screen_fhd.jpg',
|
||||
outputFilePath: 'images/splash-screen_fhd.jpg',
|
||||
outputHash: 'b15f3a3f1ccc459cbca12cb828b78d16',
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
background: '#242424',
|
||||
},
|
||||
{
|
||||
outputFilePath: 'src/images/splash-screen_hd.jpg',
|
||||
outputFilePath: 'images/splash-screen_hd.jpg',
|
||||
outputHash: '25e9c4220f8a42101d6333e548e33aa8',
|
||||
width: 1280,
|
||||
height: 720,
|
||||
background: '#242424',
|
||||
},
|
||||
{
|
||||
outputFilePath: 'src/images/splash-screen_sd.jpg',
|
||||
outputFilePath: 'images/splash-screen_sd.jpg',
|
||||
outputHash: 'c54a2f7fa65f443263806962450f2c04',
|
||||
width: 720,
|
||||
height: 480,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
inputHash: "d61131ccc714d8df0b4514ca76883494",
|
||||
inputHash: 'd61131ccc714d8df0b4514ca76883494',
|
||||
outputs: [],
|
||||
}
|
||||
}
|
||||
@@ -2,21 +2,21 @@
|
||||
inputHash: '3452c6ea1c84f59aedf5530bf86a7a51',
|
||||
outputs: [
|
||||
{
|
||||
outputFilePath: 'src/images/channel-poster_fhd.png',
|
||||
outputFilePath: 'images/channel-poster_fhd.png',
|
||||
outputHash: 'd644a0db84deed0bcc41a41d08a4ef75',
|
||||
width: 540,
|
||||
height: 405,
|
||||
background: '#FFFFFF',
|
||||
},
|
||||
{
|
||||
outputFilePath: 'src/images/channel-poster_hd.png',
|
||||
outputFilePath: 'images/channel-poster_hd.png',
|
||||
outputHash: 'd07a4ffaa021b55528bee91710f4e9d2',
|
||||
width: 290,
|
||||
height: 218,
|
||||
background: '#FFFFFF',
|
||||
},
|
||||
{
|
||||
outputFilePath: 'src/images/channel-poster_sd.png',
|
||||
outputFilePath: 'images/channel-poster_sd.png',
|
||||
outputHash: '66a311c639f89ff009e4624468282b2f',
|
||||
width: 246,
|
||||
height: 140,
|
||||
|
||||
@@ -2,8 +2,8 @@ title=Playlet
|
||||
|
||||
# Do not update version manually, it is auto updated from package.json
|
||||
major_version=0
|
||||
minor_version=13
|
||||
build_version=00001
|
||||
minor_version=14
|
||||
build_version=00000
|
||||
|
||||
ui_resolutions=hd
|
||||
|
||||
@@ -29,7 +29,7 @@ supports_input_launch=1
|
||||
|
||||
playlet_lib_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.zip
|
||||
playlet_lib_embedded_url=pkg:/lib/playlet-lib.zip
|
||||
playlet_lib_debug_url=http://DEBUG_HOST_IP_ADDRESS:8080/playlet-lib.zip
|
||||
playlet_lib_debug_url=http://DEBUG_HOST_IP_ADDRESS:8086/playlet-lib.zip
|
||||
|
||||
git_commit_sha=unknown
|
||||
|
||||
|
||||
@@ -66,7 +66,9 @@ function Main(args as object) as void
|
||||
msg = wait(0, port)
|
||||
msgType = type(msg)
|
||||
if msgType = "roSystemLogEvent"
|
||||
scene.systemLogEvent = msg.GetInfo()
|
||||
info = msg.GetInfo()
|
||||
info.DateTime = info.DateTime.ToISOString()
|
||||
scene.systemLogEvent = info
|
||||
else if msgType = "roSGScreenEvent"
|
||||
if msg.isScreenClosed()
|
||||
return
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "playlet-lib",
|
||||
"version": "0.13.1",
|
||||
"version": "0.14.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playlet-lib",
|
||||
"version": "0.13.1"
|
||||
"version": "0.14.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playlet-lib",
|
||||
"version": "0.13.1",
|
||||
"version": "0.14.0",
|
||||
"description": "Unofficial Youtube client for Roku",
|
||||
"scripts": {
|
||||
"prebuild": "rm -rf build/playlet-lib",
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
namespace ChannelUtils
|
||||
function Open(contentNode as object)
|
||||
function Open(contentNode as object, appController = invalid as object)
|
||||
channelView = CreateObject("roSGNode", "ChannelView")
|
||||
m.appController@.PushScreen(channelView)
|
||||
if appController = invalid
|
||||
appController = m.appController
|
||||
end if
|
||||
appController@.PushScreen(channelView)
|
||||
channelView@.BindNode(invalid)
|
||||
channelView.content = contentNode
|
||||
end function
|
||||
|
||||
@@ -5,14 +5,17 @@ import "pkg:/source/utils/Types.bs"
|
||||
function Init()
|
||||
m.container = m.top.findNode("container")
|
||||
m.scrollAnimation = m.top.findNode("scrollAnimation")
|
||||
m.scrollAnimationInterpolator = m.scrollAnimation.findNode("scrollAnimationInterpolator")
|
||||
m.containerTranslation = m.scrollAnimation.findNode("containerTranslation")
|
||||
m.bannerTranslation = m.scrollAnimation.findNode("bannerTranslation")
|
||||
|
||||
m.banner = m.top.findNode("banner")
|
||||
m.thumbnail = m.top.findNode("thumbnail")
|
||||
m.authorLabel = m.top.findNode("authorLabel")
|
||||
m.rowList = m.top.FindNode("rowList")
|
||||
m.rowList.screen = m.top
|
||||
|
||||
m.banner.ObserveField("loadStatus", FuncName(OnBannerLoadStatus))
|
||||
m.author = ""
|
||||
m.authorId = ""
|
||||
|
||||
InitializeTabs()
|
||||
@@ -38,7 +41,6 @@ function OnContentSet() as void
|
||||
|
||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||
m.authorLabel.text = content._author
|
||||
' TODO:P1 handle case where there's no banner - a big portion of the screen is blank
|
||||
m.banner.uri = content.banner
|
||||
if StringUtils.IsNullOrEmpty(content.thumbnail)
|
||||
m.thumbnail.uri = ""
|
||||
@@ -52,13 +54,15 @@ function OnContentSet() as void
|
||||
content@.LoadChannel(m.invidious)
|
||||
|
||||
authorId = ValidString(content.authorId)
|
||||
if authorId <> m.authorId and IsArray(content.tabs)
|
||||
author = ValidString(content._author)
|
||||
if (authorId <> m.authorId or author <> m.author) and IsArray(content.tabs)
|
||||
m.authorId = authorId
|
||||
m.rowList.contentData = CreateChannelFeeds(m.authorId, content.tabs)
|
||||
m.author = author
|
||||
m.rowList.feeds = CreateChannelFeeds(m.authorId, author, content.tabs)
|
||||
end if
|
||||
end function
|
||||
|
||||
function CreateChannelFeeds(authorId as string, tabs as object) as object
|
||||
function CreateChannelFeeds(authorId as string, author as string, tabs as object) as object
|
||||
if authorId = ""
|
||||
return invalid
|
||||
end if
|
||||
@@ -67,7 +71,7 @@ function CreateChannelFeeds(authorId as string, tabs as object) as object
|
||||
for i = 0 to tabs.count() - 1
|
||||
tabName = tabs[i]
|
||||
if m.tabs.DoesExist(tabName)
|
||||
feeds.Push(m.tabs[tabName](authorId))
|
||||
feeds.Push(m.tabs[tabName](authorId, author))
|
||||
end if
|
||||
end for
|
||||
return feeds
|
||||
@@ -95,49 +99,70 @@ function OnBannerLoadStatus() as void
|
||||
return
|
||||
end if
|
||||
|
||||
aspect = m.banner.bitmapWidth / m.banner.bitmapHeight
|
||||
m.banner.height = m.banner.width / aspect
|
||||
m.banner.translation = [0, -m.banner.height]
|
||||
bannerAspect = m.banner.bitmapWidth / m.banner.bitmapHeight
|
||||
bannerHeight = m.banner.width / bannerAspect
|
||||
m.banner.height = bannerHeight
|
||||
m.banner.translation = [0, -bannerHeight]
|
||||
m.banner.visible = true
|
||||
|
||||
startPos = [0, -bannerHeight]
|
||||
endPos = [0, 0]
|
||||
midPos = [0, (startPos[1] + endPos[1]) / 2]
|
||||
|
||||
m.bannerTranslation.keyValue = [startPos, midPos, endPos]
|
||||
|
||||
startPos = [0, 0]
|
||||
endPos = [0, m.banner.height]
|
||||
midPos = [0, m.banner.height / 2]
|
||||
endPos = [0, bannerHeight - m.thumbnail.height * 0.4]
|
||||
midPos = [0, (startPos[1] + endPos[1]) / 2]
|
||||
|
||||
m.containerTranslation.keyValue = [startPos, midPos, endPos]
|
||||
|
||||
m.scrollAnimationInterpolator.keyValue = [startPos, midPos, endPos]
|
||||
m.scrollAnimation.control = "start"
|
||||
end function
|
||||
|
||||
function InitializeTabs()
|
||||
m.tabs = {
|
||||
videos: function(authorId as string) as object
|
||||
return CreateChannelFeed("Latest videos", "channel_videos", authorId)
|
||||
videos: function(authorId as string, author as string) as object
|
||||
return CreateChannelFeed("Latest videos", "channel_videos", authorId, author)
|
||||
end function,
|
||||
shorts: function(authorId as string) as object
|
||||
return CreateChannelFeed("Shorts", "channel_shorts", authorId)
|
||||
shorts: function(authorId as string, author as string) as object
|
||||
return CreateChannelFeed("Shorts", "channel_shorts", authorId, author)
|
||||
end function,
|
||||
streams: function(authorId as string) as object
|
||||
return CreateChannelFeed("Live", "channel_streams", authorId)
|
||||
streams: function(authorId as string, author as string) as object
|
||||
return CreateChannelFeed("Live", "channel_streams", authorId, author)
|
||||
end function,
|
||||
podcasts: function(authorId as string) as object
|
||||
return CreateChannelFeed("Podcasts", "channel_podcasts", authorId)
|
||||
podcasts: function(authorId as string, author as string) as object
|
||||
return CreateChannelFeed("Podcasts", "channel_podcasts", authorId, author)
|
||||
end function,
|
||||
playlists: function(authorId as string) as object
|
||||
return CreateChannelFeed("Playlists", "channel_playlists", authorId)
|
||||
playlists: function(authorId as string, author as string) as object
|
||||
return CreateChannelFeed("Playlists", "channel_playlists", authorId, author)
|
||||
end function,
|
||||
channels: function(authorId as string) as object
|
||||
return CreateChannelFeed("Channels", "channel_channels", authorId)
|
||||
channels: function(authorId as string, author as string) as object
|
||||
return CreateChannelFeed("Channels", "channel_channels", authorId, author)
|
||||
end function
|
||||
}
|
||||
end function
|
||||
|
||||
function CreateChannelFeed(title as string, endpoint as string, ucid as string) as object
|
||||
function CreateChannelFeed(title as string, endpoint as string, ucid as string, author as string) as object
|
||||
return {
|
||||
title: title,
|
||||
apiType: "Invidious",
|
||||
endpoint: endpoint,
|
||||
pathParams: {
|
||||
ucid: ucid
|
||||
}
|
||||
feedSources: [{
|
||||
"id": `inv_${endpoint}_${ucid}`,
|
||||
"title": `${author} - ${title}`,
|
||||
"apiType": "Invidious",
|
||||
"endpoint": endpoint,
|
||||
"pathParams": {
|
||||
"ucid": ucid
|
||||
}
|
||||
}]
|
||||
}
|
||||
end function
|
||||
|
||||
function GetContextMenuOptionsForItem(video as object) as object
|
||||
content = m.top.content
|
||||
if content = invalid or StringUtils.IsNullOrEmpty(content.authorId)
|
||||
return []
|
||||
end if
|
||||
|
||||
return m.bookmarks@.GetMenuForChannel(content)
|
||||
end function
|
||||
@@ -1,8 +1,9 @@
|
||||
<component name="ChannelView" extends="Group" includes="AutoBind,Focus">
|
||||
<component name="ChannelView" extends="Group" includes="AutoBind,Focus,ContextMenuProvider">
|
||||
<interface>
|
||||
<field id="content" type="node" onChange="OnContentSet" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
<field id="invidious" type="node" bind="/Invidious" />
|
||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
@@ -11,12 +12,12 @@
|
||||
color="0x242424">
|
||||
</Rectangle>
|
||||
|
||||
<Group id="container">
|
||||
<Poster
|
||||
id="banner"
|
||||
width="1280"
|
||||
visible="false" />
|
||||
<Poster
|
||||
id="banner"
|
||||
width="1280"
|
||||
visible="false" />
|
||||
|
||||
<Group id="container">
|
||||
<Poster
|
||||
translation="[115,20]"
|
||||
width="104"
|
||||
@@ -58,7 +59,11 @@
|
||||
delay="0.3"
|
||||
duration="0.6">
|
||||
<Vector2DFieldInterpolator
|
||||
id="scrollAnimationInterpolator"
|
||||
id="bannerTranslation"
|
||||
key="[ 0.0, 0.5, 1.0 ]"
|
||||
fieldToInterp="banner.translation" />
|
||||
<Vector2DFieldInterpolator
|
||||
id="containerTranslation"
|
||||
key="[ 0.0, 0.5, 1.0 ]"
|
||||
fieldToInterp="container.translation" />
|
||||
</Animation>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<component name="BookmarkContentNode" extends="ContentNode">
|
||||
<interface>
|
||||
<field id="feedSource" type="assocarray" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -3,10 +3,12 @@
|
||||
<field id="type" type="string" value="channel" />
|
||||
<field id="loadState" type="string" />
|
||||
<function name="LoadChannel" />
|
||||
|
||||
<!-- index in a feed -->
|
||||
<field id="feedSourcesIndex" type="integer" value="-1" />
|
||||
<!-- NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation -->
|
||||
<field id="_author" type="string" />
|
||||
<field id="authorId" type="string" />
|
||||
<field id="channelHandle" type="string" />
|
||||
<field id="description" type="string" />
|
||||
<field id="subCount" type="integer" />
|
||||
<field id="subCountText" type="string" />
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<component name="ContextMenuItemContentNode" extends="ContentNode">
|
||||
<interface>
|
||||
<field id="node" type="node" />
|
||||
<field id="func" type="string" />
|
||||
<field id="args" type="array" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -1,9 +1,7 @@
|
||||
<component name="FeedContentNode" extends="ContentNode">
|
||||
<interface>
|
||||
<field id="feed" type="assocarray" />
|
||||
<field id="feedSources" type="array" />
|
||||
<field id="feedSourcesIndex" type="integer" />
|
||||
<field id="loadState" type="string" />
|
||||
<field id="paginationType" type="string" />
|
||||
<field id="page" type="integer" value="0" />
|
||||
<field id="continuation" type="string" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -2,6 +2,8 @@
|
||||
<interface>
|
||||
<field id="type" type="string" value="playlist" />
|
||||
<field id="loadState" type="string" />
|
||||
<!-- index in a feed -->
|
||||
<field id="feedSourcesIndex" type="integer" value="-1" />
|
||||
<!--
|
||||
For some strange reason, the "author" field can only be set once.
|
||||
If you try to set it again, it will not be updated, with type mismatch warning:
|
||||
@@ -22,6 +24,7 @@
|
||||
we can query it's original owner)
|
||||
-->
|
||||
<field id="_author" type="string" />
|
||||
<field id="authorId" type="string" />
|
||||
<field id="playlistId" type="string" />
|
||||
<field id="thumbnail" type="uri" />
|
||||
<field id="thumbnailBackground" type="uri" />
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
<field id="type" type="string" value="video" />
|
||||
|
||||
<field id="author" type="string" />
|
||||
<field id="authorId" type="string" />
|
||||
<field id="hlsUrl" type="uri" />
|
||||
<!-- index in a playlist -->
|
||||
<field id="index" type="integer" value="-1" />
|
||||
<!-- index in a feed -->
|
||||
<field id="feedSourcesIndex" type="integer" value="-1" />
|
||||
<field id="isUpcoming" type="boolean" />
|
||||
<field id="lengthSeconds" type="integer" />
|
||||
<field id="lengthText" type="string" />
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
' TODO:P0 Web app support
|
||||
' TODO:P0 Web apis and open api spec updates
|
||||
'
|
||||
' From the main screen:
|
||||
' When a video is selected:
|
||||
' - "Play" - DONE
|
||||
' - "Queue" - DONE
|
||||
' - "Open Channel" - DONE
|
||||
' - "Add to "Videos" bookmark" - DONE
|
||||
' - If video is already in a bookmark, "Remove from Bookmarks" - DONE
|
||||
'
|
||||
' When a channel is selected:
|
||||
' - "Open" - DONE
|
||||
' - "Add to "Channels" bookmark" - DONE
|
||||
' - "Add to <ChannelName> bookmark" - DONE
|
||||
' - If channel is already in a bookmark, "Remove from Bookmarks" - DONE
|
||||
' - PlaylistId starting with "IV" cannot be added to a bookmark - DONE
|
||||
'
|
||||
' When a playlist is selected:
|
||||
' - "Play" - DONE
|
||||
' - "Queue" - DONE
|
||||
' - "Open" - DONE
|
||||
' - "Add to "Playlists" bookmark" - DONE
|
||||
' - "Add to <PlaylistName> bookmark" - DONE
|
||||
' - If playlist is already in a bookmark, "Remove from Bookmarks" - DONE
|
||||
' When any:
|
||||
' - "Reload feed" - DONE
|
||||
'
|
||||
' From Playlist view:
|
||||
' When a video is selected:
|
||||
' - "Play" - DONE
|
||||
' - "Queue" - DONE
|
||||
' - "Play video" - DONE
|
||||
' - "Queue video" - DONE
|
||||
' - "Open Channel" - DONE
|
||||
' - "Add to "Playlists" bookmark" - DONE
|
||||
' - "Add to <PlaylistName> bookmark" - DONE
|
||||
' - "Add to "Videos" bookmark" - DONE
|
||||
'
|
||||
' From Channel view:
|
||||
' When a video is selected:
|
||||
' - "Play" - DONE
|
||||
' - "Queue" - DONE
|
||||
' - "Add to "Channels" bookmark" - DONE
|
||||
' - "Add to <ChannelName> - <feed> bookmark" feed being latest videos, live, shorts, etc - DONE
|
||||
' - "Add to "Videos" bookmark" - DONE
|
||||
'
|
||||
' When a playlist is selected:
|
||||
' - "Play" - DONE
|
||||
' - "Queue" - DONE
|
||||
' - "Open" - DONE
|
||||
' - "Add to "Channels" bookmark" - DONE
|
||||
' - "Add to <ChannelName> - <feed> bookmark" feed being latest videos, live, shorts, etc - DONE
|
||||
' - "Add to "Playlists" bookmark" - DONE
|
||||
' - "Add to <PlaylistName> bookmark" - DONE
|
||||
'
|
||||
' From search view:
|
||||
' When a video/channel/playlist is selected:
|
||||
' - Inherit options - DONE
|
||||
' - "Add to "Search - ${q}" bookmark" - this includes the search filters used - DONE
|
||||
'
|
||||
' From bookmarks view:
|
||||
' When a video/channel/playlist is selected:
|
||||
' - Inherit options
|
||||
' - "Remove item from Bookmarks"
|
||||
' - "Remove group from Bookmarks"
|
||||
' - "Reload bookmarks" - DONE
|
||||
'
|
||||
' TODO:P1 Playlist item seletected from the bookmarks need to play as a playlist, not as a single video
|
||||
' TODO:P1 Context menu might need to be scrollable (both horizontally and vertically)
|
||||
' TODO:P1 Context menu might need sections. Example:
|
||||
' In a Channel view, while selecting a playlist:
|
||||
' - Channel
|
||||
' - Add to "Channels" bookmark
|
||||
' - Other "Channels" related context menu items
|
||||
' - Playlist
|
||||
' - Add to "Playlists" bookmark
|
||||
' - "Play/Queue"
|
||||
' - Other "Playlists" related context menu items
|
||||
|
||||
function Init()
|
||||
m.optionsList = m.top.findNode("optionsList")
|
||||
m.showAnimation = m.top.findNode("showAnimation")
|
||||
end function
|
||||
|
||||
function Show(unsued as dynamic)
|
||||
m.optionsList.ObserveField("itemSelected", FuncName(OnItemSelected))
|
||||
m.showAnimation.control = "start"
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
NodeSetFocus(m.optionsList, true)
|
||||
end function
|
||||
|
||||
function OnOptionsSet() as void
|
||||
options = m.top.options
|
||||
if options = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
for each option in options
|
||||
optionNode = CreateObject("roSGNode", "ContentNode")
|
||||
optionNode.title = option.title
|
||||
content.appendChild(optionNode)
|
||||
end for
|
||||
|
||||
m.optionsList.content = content
|
||||
end function
|
||||
|
||||
function OnItemSelected(event as object) as void
|
||||
index = event.getData()
|
||||
button = m.optionsList.content.getChild(index)
|
||||
Close()
|
||||
LogInfo("Menu button selected:", button.title)
|
||||
|
||||
options = m.top.options
|
||||
if index >= options.count()
|
||||
LogError("Menu button index out of range:", index)
|
||||
return
|
||||
end if
|
||||
|
||||
option = options[index]
|
||||
|
||||
node = option.node
|
||||
func = option.func
|
||||
args = option.args
|
||||
|
||||
if node = invalid or StringUtils.IsNullOrEmpty(func) or args = invalid
|
||||
LogError("Menu button action is invalid")
|
||||
return
|
||||
end if
|
||||
|
||||
if args.count() = 1
|
||||
node.callFunc(func, args[0])
|
||||
else if args.count() = 2
|
||||
node.callFunc(func, args[0], args[1])
|
||||
else if args.count() = 3
|
||||
node.callFunc(func, args[0], args[1], args[2])
|
||||
else if args.count() = 4
|
||||
node.callFunc(func, args[0], args[1], args[2], args[3])
|
||||
else if args.count() = 5
|
||||
node.callFunc(func, args[0], args[1], args[2], args[3], args[4])
|
||||
else
|
||||
LogError("Menu button action has too many arguments")
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
if press = false
|
||||
return false
|
||||
end if
|
||||
|
||||
if key = "back"
|
||||
Close()
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
function Close()
|
||||
m.top.appController@.PopScreen(invalid)
|
||||
end function
|
||||
@@ -0,0 +1,70 @@
|
||||
<component name="ContextMenu" extends="Group" includes="Focus">
|
||||
<interface>
|
||||
<field id="thumbnail" type="uri" alias="thumbnail.uri" />
|
||||
<field id="title" type="string" alias="titleLabel.text" />
|
||||
<field id="subtitle" type="string" alias="subtitleLabel.text" />
|
||||
<field id="options" type="nodearray" onChange="OnOptionsSet" />
|
||||
<field id="appController" type="node" />
|
||||
<function name="Show" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
id="background"
|
||||
width="1280"
|
||||
height="720"
|
||||
color="#000000"
|
||||
opacity="0" />
|
||||
<Rectangle
|
||||
id="container"
|
||||
width="470"
|
||||
height="720"
|
||||
translation="[-470,0]"
|
||||
color="0x242424">
|
||||
<Poster
|
||||
id="thumbnail"
|
||||
width="190"
|
||||
height="110"
|
||||
loadDisplayMode="scaleToFit"
|
||||
translation="[40,50]" />
|
||||
|
||||
<LayoutGroup
|
||||
translation="[40,180]"
|
||||
itemSpacings="[10]">
|
||||
<Label
|
||||
id="titleLabel"
|
||||
width="390"
|
||||
maxLines="2"
|
||||
font="font:MediumBoldSystemFont"
|
||||
wrap="true" />
|
||||
<Label
|
||||
id="subtitleLabel"
|
||||
width="390"
|
||||
font="font:SmallestBoldSystemFont"
|
||||
wrap="true" />
|
||||
</LayoutGroup>
|
||||
|
||||
<MarkupList
|
||||
id="optionsList"
|
||||
itemSize="[420,50]"
|
||||
translation="[25,310]"
|
||||
itemComponentName="ContextMenuRow"
|
||||
vertFocusAnimationStyle="floatingFocus"
|
||||
numRows="8" />
|
||||
</Rectangle>
|
||||
|
||||
<Animation id="showAnimation"
|
||||
duration="0.3"
|
||||
optional="true">
|
||||
<FloatFieldInterpolator
|
||||
id="fadeInterpolator"
|
||||
key="[0.0, 0.5, 1.0]"
|
||||
keyValue="[0.0, 0.4, 0.8]"
|
||||
fieldToInterp="background.opacity" />
|
||||
<Vector2DFieldInterpolator
|
||||
id="translationInterpolator"
|
||||
key="[0.0, 0.5, 1.0]"
|
||||
keyValue="[[-470,0], [-235,0], [0,0]]"
|
||||
fieldToInterp="container.translation" />
|
||||
</Animation>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,29 @@
|
||||
function OnContentSet() as void
|
||||
content = m.top.itemContent
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.text = content.title
|
||||
end function
|
||||
|
||||
function OnItemHasFocus()
|
||||
hasFocus = m.top.itemHasFocus
|
||||
if hasFocus
|
||||
m.top.font = "font:SmallestBoldSystemFont"
|
||||
m.top.color = "0x262626ff"
|
||||
else
|
||||
m.top.font = "font:SmallestSystemFont"
|
||||
m.top.color = "0xddddddff"
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnFocusPercent()
|
||||
if m.top.focusPercent > 0.5
|
||||
m.top.font = "font:SmallestBoldSystemFont"
|
||||
m.top.color = "0x262626ff"
|
||||
else
|
||||
m.top.font = "font:SmallestSystemFont"
|
||||
m.top.color = "0xddddddff"
|
||||
end if
|
||||
end function
|
||||
@@ -0,0 +1,19 @@
|
||||
<component name="ContextMenuRow" extends="Group">
|
||||
<interface>
|
||||
<field id="text" type="string" alias="label.text" />
|
||||
<field id="font" type="node" alias="label.font" />
|
||||
<field id="color" type="color" alias="label.color" />
|
||||
<field id="itemContent" type="node" onChange="OnContentSet" />
|
||||
<field id="itemHasFocus" type="boolean" onChange="OnItemHasFocus" />
|
||||
<field id="listHasFocus" type="boolean" />
|
||||
<field id="focusPercent" type="float" onChange="OnFocusPercent" />
|
||||
</interface>
|
||||
<children>
|
||||
<ScrollingLabel
|
||||
id="label"
|
||||
maxWidth="420"
|
||||
height="50"
|
||||
vertAlign="center"
|
||||
font="font:SmallestSystemFont" />
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,76 @@
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
|
||||
namespace ContextMenuUtils
|
||||
function Open(providers as object, appController as object, item as object) as object
|
||||
if item = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
options = GetOptions(item, providers)
|
||||
if options.Count() = 0
|
||||
LogWarn("No context menu options available for item")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
contextMenu = CreateObject("roSGNode", "ContextMenu")
|
||||
contextMenu.appController = appController
|
||||
appController@.PushScreen(contextMenu)
|
||||
|
||||
ContextMenuUtils.SetItem(contextMenu, item)
|
||||
contextMenu.options = options
|
||||
|
||||
contextMenu@.Show(invalid)
|
||||
return contextMenu
|
||||
end function
|
||||
|
||||
function SetItem(contextMenu as object, item as object)
|
||||
title = ""
|
||||
subtitle = ""
|
||||
thumbnail = ""
|
||||
|
||||
if item.type = "video"
|
||||
LogInfo("Opening context menu for video:", item.videoId)
|
||||
title = item.title
|
||||
subtitle = item.author
|
||||
thumbnail = item.thumbnail
|
||||
else if item.type = "playlist"
|
||||
LogInfo("Opening context menu for playlist:", item.playlistId)
|
||||
title = item.title
|
||||
subtitle = item._author
|
||||
thumbnail = item.thumbnail
|
||||
else if item.type = "channel"
|
||||
LogInfo("Opening context menu for channel:", item.authorId)
|
||||
title = item._author
|
||||
thumbnail = item.thumbnail
|
||||
end if
|
||||
|
||||
contextMenu.title = title
|
||||
contextMenu.subtitle = subtitle
|
||||
contextMenu.thumbnail = thumbnail
|
||||
end function
|
||||
|
||||
function GetOptions(item as object, providers as object) as object
|
||||
allOptions = []
|
||||
|
||||
for each provider in providers
|
||||
if provider <> invalid and provider.hasField("supportsContextMenu") and provider.supportsContextMenu = true
|
||||
options = provider@.GetContextMenuOptionsForItem(item)
|
||||
if options <> invalid
|
||||
allOptions.append(options)
|
||||
end if
|
||||
end if
|
||||
|
||||
end for
|
||||
|
||||
return allOptions
|
||||
end function
|
||||
|
||||
function CreateOption(title as string, node as object, func as string, args as object) as object
|
||||
option = CreateObject("roSGNode", "ContextMenuItemContentNode")
|
||||
option.title = title
|
||||
option.node = node
|
||||
option.func = func
|
||||
option.args = args
|
||||
return option
|
||||
end function
|
||||
end namespace
|
||||
@@ -1,4 +1,5 @@
|
||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
@@ -13,6 +14,18 @@ function Init()
|
||||
end if
|
||||
|
||||
m.port = port
|
||||
|
||||
StartLogger(m.top)
|
||||
end function
|
||||
|
||||
function StartLogger(logger as object, logLevel = LogLevel.Info as LogLevel) as void
|
||||
if m.global.logger <> invalid
|
||||
return
|
||||
end if
|
||||
|
||||
logger.logLevel = logLevel
|
||||
m.global.addFields({ logger: logger })
|
||||
logger.control = "run"
|
||||
end function
|
||||
|
||||
function LoggerLoop()
|
||||
@@ -54,7 +67,7 @@ function OnLineSysLog(event as object, logsFile as string, buffer as object) as
|
||||
if info.LogType <> "http.error"
|
||||
return
|
||||
end if
|
||||
line = `[SysLog] ${FormatJson(info)}`
|
||||
line = "[ERROR][SysLog] " + ToString(info)
|
||||
' bs:disable-next-line LINT3012
|
||||
print line
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<component name="Logger" extends="Task">
|
||||
<interface>
|
||||
<field id="logLevel" type="int" value="2" />
|
||||
<field id="logLine" type="string" />
|
||||
<field id="logLine" type="string" alwaysNotify="true" />
|
||||
<field id="folder" type="string" value="cachefs:/logs" />
|
||||
<field id="filename" type="string" value="app_logs.txt" />
|
||||
<field id="filenamePrevious" type="string" value="app_logs_previous.txt" />
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import "pkg:/components/EcpArgs.bs"
|
||||
import "pkg:/components/parts/AutoBind/AutoBind.part.bs"
|
||||
import "pkg:/source/utils/LoadingScreen.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
|
||||
function Init()
|
||||
InitializeLogger()
|
||||
|
||||
m.scene = m.top.getScene()
|
||||
' At this point, the "MainScene" node is not yet added to the scene, and does not have a parent yet.
|
||||
' Let's wait until it has one.
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
'import "pkg:/components/EcpArgs.bs"
|
||||
'import "pkg:/components/parts/AutoBind/AutoBind.part.bs"
|
||||
'import "pkg:/source/utils/LoadingScreen.bs"
|
||||
'import "pkg:/source/utils/Logging.bs"
|
||||
|
||||
function Init()
|
||||
InitializeBindings() ' auto-generated!
|
||||
InitializeLogger()
|
||||
m.scene = m.top.getScene()
|
||||
' At this point, the "MainScene" node is not yet added to the scene, and does not have a parent yet.
|
||||
' Let's wait until it has one.
|
||||
|
||||
@@ -9,24 +9,26 @@
|
||||
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/AutoBind.part.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/MainScene_bindings.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/MainScene.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/Logging.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/LoadingScreen.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/EcpArgs.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/Types.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/StringUtils.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/Logging.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/VideoPlayer/VideoUtils.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/FocusManagement.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/Dialog/DialogUtils.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
||||
<children>
|
||||
<Logger id="Logger" />
|
||||
<AppController id="AppController">
|
||||
<Group id="Stack">
|
||||
<AppRoot id="AppRoot">
|
||||
<NavBar id="NavBar" focusIndex="1">
|
||||
<ContentNode role="items">
|
||||
<NavBarItem screen="SearchScreen" text="Search" icon="pkg:/images/icons/search.png" canFocus="true" />
|
||||
<NavBarItem screen="HomeScreen" text="Home" icon="pkg:/images/icons/home.png" canFocus="true" />
|
||||
<NavBarItem screen="SettingsScreen" text="Settings" icon="pkg:/images/icons/settings.png" canFocus="true" />
|
||||
<NavBarItem screen="SearchScreen" text="Search" icon="pkg:/images/icons/search.png" />
|
||||
<NavBarItem screen="HomeScreen" text="Home" icon="pkg:/images/icons/home.png" />
|
||||
<NavBarItem screen="BookmarksScreen" text="Bookmarks" icon="pkg:/images/icons/star.png" />
|
||||
<NavBarItem screen="SettingsScreen" text="Settings" icon="pkg:/images/icons/settings.png" />
|
||||
<NavBarItem screen="WebAppScreen" text="Web App" icon="pkg:/images/icons/phone.png" />
|
||||
<NavBarItem screen="AppInfoScreen" text="Info" icon="pkg:/images/icons/info.png" />
|
||||
</ContentNode>
|
||||
@@ -38,6 +40,7 @@
|
||||
<PlayQueue id="PlayQueue" />
|
||||
<ApplicationInfo id="ApplicationInfo" />
|
||||
<Preferences id="Preferences" />
|
||||
<Bookmarks id="Bookmarks" />
|
||||
<Invidious id="Invidious" />
|
||||
<PlayletWebServer id="WebServer" port="8888" />
|
||||
</AppController>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<component name="MainScene" extends="Group" includes="AutoBind">
|
||||
<children>
|
||||
<!-- Logger should remain the first child, to make sure it is initialized first in the scene -->
|
||||
<Logger id="Logger" />
|
||||
<AppController id="AppController" root="bind:./AppRoot" stack="bind:./Stack">
|
||||
<Group id="Stack">
|
||||
<AppRoot id="AppRoot">
|
||||
@@ -8,20 +10,22 @@
|
||||
<NavBarItem
|
||||
screen="SearchScreen"
|
||||
text="Search"
|
||||
icon="pkg:/images/icons/search.png"
|
||||
canFocus="true">
|
||||
icon="pkg:/images/icons/search.png">
|
||||
</NavBarItem>
|
||||
<NavBarItem
|
||||
screen="HomeScreen"
|
||||
text="Home"
|
||||
icon="pkg:/images/icons/home.png"
|
||||
canFocus="true">
|
||||
icon="pkg:/images/icons/home.png">
|
||||
</NavBarItem>
|
||||
<NavBarItem
|
||||
screen="BookmarksScreen"
|
||||
text="Bookmarks"
|
||||
icon="pkg:/images/icons/star.png">
|
||||
</NavBarItem>
|
||||
<NavBarItem
|
||||
screen="SettingsScreen"
|
||||
text="Settings"
|
||||
icon="pkg:/images/icons/settings.png"
|
||||
canFocus="true">
|
||||
icon="pkg:/images/icons/settings.png">
|
||||
</NavBarItem>
|
||||
<NavBarItem
|
||||
screen="WebAppScreen"
|
||||
@@ -46,6 +50,7 @@
|
||||
invidious="bind:../Invidious" />
|
||||
<ApplicationInfo id="ApplicationInfo" />
|
||||
<Preferences id="Preferences" />
|
||||
<Bookmarks id="Bookmarks" />
|
||||
|
||||
<Invidious id="Invidious"
|
||||
webServer="bind:../WebServer"
|
||||
@@ -55,10 +60,12 @@
|
||||
<PlayletWebServer
|
||||
id="WebServer"
|
||||
port="8888"
|
||||
appController="bind:/AppController"
|
||||
applicationInfo="bind:../ApplicationInfo"
|
||||
invidious="bind:../Invidious"
|
||||
preferences="bind:../Preferences"
|
||||
playQueue="bind:../PlayQueue" />
|
||||
playQueue="bind:../PlayQueue"
|
||||
bookmarks="bind:../Bookmarks" />
|
||||
</AppController>
|
||||
</children>
|
||||
</component>
|
||||
@@ -21,10 +21,12 @@ function InitializeBindings()
|
||||
"preferences": "../Preferences"
|
||||
},
|
||||
"WebServer": {
|
||||
"appController": "/AppController",
|
||||
"applicationInfo": "../ApplicationInfo",
|
||||
"invidious": "../Invidious",
|
||||
"preferences": "../Preferences",
|
||||
"playQueue": "../PlayQueue"
|
||||
"playQueue": "../PlayQueue",
|
||||
"bookmarks": "../Bookmarks"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ function setIconSize()
|
||||
m.buttonIcon.width = m.buttonIcon.height
|
||||
|
||||
m.buttonIcon.translation = [((width - m.buttonIcon.width) / 2), ((height - m.buttonIcon.height) / 2)]
|
||||
m.buttonText.translation = [0, height]
|
||||
m.buttonText.width = width
|
||||
m.buttonText.translation = [-5, height]
|
||||
m.buttonText.width = width + 10
|
||||
end if
|
||||
end function
|
||||
|
||||
|
||||
@@ -74,13 +74,13 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
||||
return false
|
||||
end if
|
||||
navBarItem = m.top.items.getChild(m.top.focusIndex)
|
||||
if navBarItem.canFocus <> true
|
||||
return false
|
||||
end if
|
||||
screen = m.appController@.GetRootScreen(navBarItem.screen)
|
||||
if screen = invalid
|
||||
return false
|
||||
end if
|
||||
if not screen.focusable
|
||||
return false
|
||||
end if
|
||||
NodeSetFocus(screen, true)
|
||||
return true
|
||||
end if
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<children>
|
||||
<Rectangle
|
||||
height="720"
|
||||
width="105"
|
||||
width="115"
|
||||
color="#242424"
|
||||
opacity="0.9">
|
||||
<LayoutGroup
|
||||
|
||||
@@ -3,6 +3,5 @@
|
||||
<field id="screen" type="string" />
|
||||
<field id="icon" type="string" />
|
||||
<field id="text" type="string" />
|
||||
<field id="canFocus" type="boolean" value="false" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -0,0 +1,49 @@
|
||||
const LONG_PRESS_KEY = "OK_LONG_PRESS"
|
||||
|
||||
function InitializeLongPressTimer(duration = 1.0 as float)
|
||||
m._longPressTimer = CreateObject("roSGNode", "Timer")
|
||||
m._longPressTimer.duration = duration
|
||||
m._longPressFired = false
|
||||
m._longPressTimer.ObserveField("fire", FuncName(LongPressTimerFired))
|
||||
end function
|
||||
|
||||
function LongPressHandler(key as string, press as boolean) as boolean
|
||||
#if DEBUG
|
||||
if key = "Lit_l"
|
||||
LogInfo("Simulating long press using key:", key, "press:", press)
|
||||
m._longPressFired = true
|
||||
return OnkeyEvent(LONG_PRESS_KEY, press)
|
||||
end if
|
||||
#end if
|
||||
if key = "OK" and press
|
||||
m._longPressTimer.control = "stop"
|
||||
m._longPressTimer.control = "start"
|
||||
m._longPressFired = false
|
||||
m._okPressed = true
|
||||
return true
|
||||
end if
|
||||
|
||||
if key = "OK" and not press
|
||||
m._longPressTimer.control = "stop"
|
||||
if m._longPressFired = true
|
||||
m._longPressFired = false
|
||||
m._okPressed = false
|
||||
return true
|
||||
end if
|
||||
' This case is for handling a dialog: The dialog will be dismissed with the OK down event,
|
||||
' and we would trigger the action with the OK up event. The action should only happen if
|
||||
' we detected both down and up events.
|
||||
wasOkPressed = m._okPressed
|
||||
m._okPressed = false
|
||||
if wasOkPressed <> true
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
return false
|
||||
end function
|
||||
|
||||
function LongPressTimerFired()
|
||||
m._longPressFired = true
|
||||
OnkeyEvent(LONG_PRESS_KEY, true)
|
||||
end function
|
||||
@@ -1,7 +1,10 @@
|
||||
namespace PlaylistUtils
|
||||
function Open(contentNode as object)
|
||||
function Open(contentNode as object, appController = invalid as object)
|
||||
playlistView = CreateObject("roSGNode", "PlaylistView")
|
||||
m.appController@.PushScreen(playlistView)
|
||||
if appController = invalid
|
||||
appController = m.appController
|
||||
end if
|
||||
appController@.PushScreen(playlistView)
|
||||
playlistView@.BindNode(invalid)
|
||||
playlistView.content = contentNode
|
||||
end function
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import "pkg:/components/ChannelView/ChannelUtils.bs"
|
||||
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Navigation/LongPress.bs"
|
||||
import "pkg:/components/PlaylistView/PlaylistContentTask.bs"
|
||||
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
||||
@@ -21,7 +24,7 @@ end function
|
||||
|
||||
function OnNodeReady()
|
||||
m.list.ObserveField("itemFocused", FuncName(OnItemFocused))
|
||||
m.list.observeField("itemSelected", FuncName(OnItemSelected))
|
||||
InitializeLongPressTimer()
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
@@ -58,6 +61,20 @@ function OnContentSet() as void
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
if LongPressHandler(key, press)
|
||||
return true
|
||||
end if
|
||||
|
||||
if key = LONG_PRESS_KEY and press
|
||||
OnItemLongPressed(m.list.itemFocused)
|
||||
return true
|
||||
end if
|
||||
|
||||
if key = "OK" and not press
|
||||
OnItemSelected(m.list.itemFocused)
|
||||
return true
|
||||
end if
|
||||
|
||||
if press = false
|
||||
return false
|
||||
end if
|
||||
@@ -81,18 +98,94 @@ function OnItemFocused()
|
||||
LoadPlaylistIfNeeded()
|
||||
end function
|
||||
|
||||
function OnItemSelected(event as object)
|
||||
index = event.getData()
|
||||
function OnItemSelected(index as integer) as void
|
||||
playlist = m.list.content
|
||||
if playlist = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
if index < 0 or index >= playlist.getChildCount()
|
||||
return
|
||||
end if
|
||||
|
||||
playlistId = playlist.playlistId
|
||||
video = playlist.getChild(index)
|
||||
videoId = video.videoId
|
||||
if not StringUtils.IsNullOrEmpty(videoId)
|
||||
LogInfo("Play playlist: " + playlistId + " video: " + videoId)
|
||||
LogInfo("Play playlist:", playlistId, "video:", videoId)
|
||||
m.playQueue@.Play(playlist, index)
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnItemLongPressed(index as integer) as void
|
||||
playlist = m.list.content
|
||||
if playlist = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
if index < 0 or index >= playlist.getChildCount()
|
||||
return
|
||||
end if
|
||||
|
||||
playlistId = playlist.playlistId
|
||||
video = playlist.getChild(index)
|
||||
videoId = video.videoId
|
||||
if StringUtils.IsNullOrEmpty(videoId)
|
||||
LogWarn("Long press video with no id in playlist/ playlist:", playlistId, "video:", videoId)
|
||||
return
|
||||
end if
|
||||
|
||||
LogInfo("Long press: playlist:", playlistId, "video:", videoId)
|
||||
|
||||
contextMenuProviders = [m.top]
|
||||
ContextMenuUtils.Open(contextMenuProviders, m.appController, video)
|
||||
end function
|
||||
|
||||
function GetContextMenuOptionsForItem(video as object) as object
|
||||
playlist = m.list.content
|
||||
if playlist = invalid
|
||||
return []
|
||||
end if
|
||||
|
||||
index = m.list.itemFocused
|
||||
if index < 0 or index >= playlist.getChildCount()
|
||||
return []
|
||||
end if
|
||||
|
||||
selectedVideo = playlist.getChild(m.list.itemFocused)
|
||||
if selectedVideo = invalid or not selectedVideo.isSameNode(video)
|
||||
return []
|
||||
end if
|
||||
|
||||
options = [
|
||||
ContextMenuUtils.CreateOption("Play", m.playQueue, "Play", [playlist, index]),
|
||||
ContextMenuUtils.CreateOption("Queue", m.playQueue, "AddToQueue", [playlist])
|
||||
ContextMenuUtils.CreateOption("Play video", m.playQueue, "Play", [video, -1]),
|
||||
ContextMenuUtils.CreateOption("Queue video", m.playQueue, "AddToQueue", [video]),
|
||||
]
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(playlist.authorId)
|
||||
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [playlist]))
|
||||
end if
|
||||
|
||||
options.append(m.bookmarks@.GetMenuForPlaylist(playlist))
|
||||
options.append(m.bookmarks@.GetMenuForVideo(video))
|
||||
|
||||
return options
|
||||
end function
|
||||
|
||||
function OpenPlaylistChannel(playlist as object) as void
|
||||
authorId = playlist.authorId
|
||||
if StringUtils.IsNullOrEmpty(authorId)
|
||||
LogWarn("Invalid authorId:", authorId)
|
||||
return
|
||||
end if
|
||||
channel = InvidiousContent.ToChannelContentNode(invalid, { authorId: authorId }, invalid)
|
||||
ChannelUtils.Open(channel)
|
||||
end function
|
||||
|
||||
'TODO:P1 a playlist could have been opened from the bookmarks, which can be as old as 3 days
|
||||
' We should make a request in this case, and let the cache handle freshness.
|
||||
function LoadPlaylistIfNeeded() as void
|
||||
content = m.top.content
|
||||
if content = invalid
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
<component name="PlaylistView" extends="Group" includes="AutoBind,Focus">
|
||||
<component name="PlaylistView" extends="Group" includes="AutoBind,Focus,ContextMenuProvider">
|
||||
<interface>
|
||||
<field id="content" type="node" onChange="OnContentSet" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
<field id="invidious" type="node" bind="/Invidious" />
|
||||
<field id="playQueue" type="node" bind="/PlayQueue" />
|
||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
||||
<function name="OpenPlaylistChannel" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
width="1280"
|
||||
height="720"
|
||||
color="0x242424">
|
||||
</Rectangle>
|
||||
color="0x242424" />
|
||||
<Poster
|
||||
id="backgroundSmall"
|
||||
width="1280"
|
||||
|
||||
@@ -2,13 +2,6 @@ import "pkg:/source/utils/TimeUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
FindChildren()
|
||||
end function
|
||||
|
||||
function FindChildren()
|
||||
m.titleLabel = m.top.findNode("titleLabel")
|
||||
m.authorLabel = m.top.findNode("authorLabel")
|
||||
m.thumbnail = m.top.findNode("thumbnail")
|
||||
m.durationRect = m.top.FindNode("durationRect")
|
||||
m.durationLabel = m.top.FindNode("durationLabel")
|
||||
end function
|
||||
@@ -20,29 +13,29 @@ function OnContentSet() as void
|
||||
return
|
||||
end if
|
||||
|
||||
if m.titleLabel = invalid
|
||||
FindChildren()
|
||||
end if
|
||||
m.top.title = content.title
|
||||
m.top.author = content.author
|
||||
m.top.thumbnailUri = content.thumbnail
|
||||
|
||||
m.titleLabel.text = content.title
|
||||
m.authorLabel.text = content.author
|
||||
|
||||
m.thumbnail.uri = content.thumbnail
|
||||
if ValidInt(content.lengthSeconds) <> 0
|
||||
SetDurationText(content.lengthText)
|
||||
m.durationRect.visible = true
|
||||
m.top.durationRectVisible = true
|
||||
else
|
||||
m.durationRect.visible = false
|
||||
m.top.durationRectVisible = false
|
||||
end if
|
||||
end function
|
||||
|
||||
function SetDurationText(text as string)
|
||||
function SetDurationText(text as string) as void
|
||||
m.top.duration = text
|
||||
|
||||
label = m.durationLabel
|
||||
rect = m.durationRect
|
||||
|
||||
rectParent = rect.getParent()
|
||||
if label = invalid or rect = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
label.text = text
|
||||
rectParent = rect.getParent()
|
||||
size = label.localBoundingRect()
|
||||
|
||||
rect.width = size.width + 16
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
<component name="PlaylistViewCell" extends="Group">
|
||||
<interface>
|
||||
<field id="itemContent" type="node" onChange="OnContentSet" />
|
||||
<field id="title" type="string" alias="titleLabel.text" />
|
||||
<field id="author" type="string" alias="authorLabel.text" />
|
||||
<field id="thumbnailUri" type="uri" alias="thumbnailPoster.uri" />
|
||||
<field id="duration" type="string" alias="durationLabel.text" />
|
||||
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
|
||||
</interface>
|
||||
<children>
|
||||
<Poster
|
||||
id="thumbnail"
|
||||
id="thumbnailPoster"
|
||||
loadDisplayMode="scaleToZoom"
|
||||
width="190"
|
||||
height="106"
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.noBookmarks = m.top.findNode("noBookmarks")
|
||||
m.yesBookmarks = m.top.findNode("yesBookmarks")
|
||||
m.rowList = m.top.FindNode("rowList")
|
||||
m.rowList.screen = m.top
|
||||
m.isDirty = true
|
||||
|
||||
m.top.ObserveField("visible", FuncName(OnVisibleChange))
|
||||
end function
|
||||
|
||||
function OnNodeReady()
|
||||
SetNavigation(invalid, "back", m.navBar)
|
||||
SetNavigation(invalid, "left", m.navBar)
|
||||
|
||||
m.rowList@.BindNode(invalid)
|
||||
|
||||
OnBookmarksChange()
|
||||
m.bookmarks.ObserveField("contentChange", FuncName(OnBookmarksChange))
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
|
||||
if m.yesBookmarks.visible
|
||||
NodeSetFocus(m.rowList, true)
|
||||
else
|
||||
NodeSetFocus(m.navBar, true)
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnVisibleChange()
|
||||
if m.top.visible and m.isDirty
|
||||
OnBookmarksChange()
|
||||
end if
|
||||
end function
|
||||
|
||||
function Refresh(unused as dynamic)
|
||||
m.isDirty = true
|
||||
OnBookmarksChange()
|
||||
end function
|
||||
|
||||
function OnBookmarksChange() as void
|
||||
if not m.top.visible
|
||||
m.isDirty = true
|
||||
return
|
||||
end if
|
||||
m.isDirty = false
|
||||
|
||||
hasBookmarks = m.bookmarks.content.getChildCount() > 0
|
||||
m.noBookmarks.visible = not hasBookmarks
|
||||
m.yesBookmarks.visible = hasBookmarks
|
||||
m.top.focusable = hasBookmarks
|
||||
|
||||
if hasBookmarks
|
||||
SetRowListContent(m.bookmarks.content)
|
||||
else
|
||||
if m.rowList.hasFocus()
|
||||
NodeSetFocus(m.navBar, true)
|
||||
end if
|
||||
end if
|
||||
end function
|
||||
|
||||
function SetRowListContent(bookmarksContent as object)
|
||||
bookmarkGroupNodes = bookmarksContent.getChildren(-1, 0)
|
||||
|
||||
feeds = []
|
||||
for each bookmarkGroupNode in bookmarkGroupNodes
|
||||
bookmarkNodes = bookmarkGroupNode.getChildren(-1, 0)
|
||||
feedSources = []
|
||||
for each bookmarkNode in bookmarkNodes
|
||||
feedSources.push(bookmarkNode.feedSource)
|
||||
end for
|
||||
|
||||
feeds.push({
|
||||
"title": bookmarkGroupNode.title,
|
||||
"feedSources": feedSources
|
||||
})
|
||||
end for
|
||||
|
||||
m.rowList.feeds = feeds
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
if NavigationKeyHandler(key, press).handled
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
function GetContextMenuOptionsForItem(rowItem as object) as object
|
||||
refreshItem = ContextMenuUtils.CreateOption("Refresh Bookmarks", m.top, "Refresh", [invalid])
|
||||
return [refreshItem]
|
||||
end function
|
||||
@@ -0,0 +1,38 @@
|
||||
<component name="BookmarksScreen" extends="Group" includes="AutoBind,Focus,ContextMenuProvider">
|
||||
<interface>
|
||||
<field id="navBar" type="node" bind="/NavBar" />
|
||||
<field id="applicationInfo" type="node" bind="/ApplicationInfo" />
|
||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
||||
<function name="Refresh" />
|
||||
</interface>
|
||||
<children>
|
||||
<Group id="noBookmarks" visible="false">
|
||||
<Label
|
||||
height="720"
|
||||
width="1280"
|
||||
font="font:MediumBoldSystemFont"
|
||||
horizAlign="center"
|
||||
vertAlign="center"
|
||||
text="You currently have no bookmarks.

To add bookmarks, long-press 'OK' on a video, playlist or channel.

Please note that Bookmarks is an experimental feature."
|
||||
wrap="true" />
|
||||
</Group>
|
||||
<Group id="yesBookmarks" visible="false">
|
||||
<VideoRowList
|
||||
itemComponentName="RowCell"
|
||||
id="rowList"
|
||||
translation="[0,50]"
|
||||
numRows="2"
|
||||
rowitemSize="[[350,196]]"
|
||||
rowItemSpacing="[[25,0]]"
|
||||
itemSize="[1280,326]"
|
||||
itemSpacing="[0,65]"
|
||||
rowLabelOffset="[[125,20]]"
|
||||
focusXOffset="[125]"
|
||||
showRowLabel="[true]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
variableWidthItems="true"
|
||||
focusBitmapUri="pkg:/images/focus_grid.9.png"
|
||||
/>
|
||||
</Group>
|
||||
</children>
|
||||
</component>
|
||||
@@ -1,8 +1,11 @@
|
||||
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
|
||||
function Init()
|
||||
m.top.focusable = true
|
||||
m.rowList = m.top.FindNode("rowList")
|
||||
m.rowList.screen = m.top
|
||||
m.pendingLoadTasks = {}
|
||||
end function
|
||||
|
||||
@@ -11,7 +14,7 @@ function OnNodeReady()
|
||||
SetNavigation(invalid, "left", m.navBar)
|
||||
|
||||
m.rowList@.BindNode(invalid)
|
||||
m.rowList.contentData = ParseJson(ReadAsciiFile(m.top.feedFile))
|
||||
m.rowList.feeds = ParseJson(ReadAsciiFile(m.top.feedFile))
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
@@ -27,3 +30,8 @@ function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
function GetContextMenuOptionsForItem(rowItem as object) as object
|
||||
refresh = ContextMenuUtils.CreateOption("Refresh Home", m.rowList, "Refresh", [invalid])
|
||||
return [refresh]
|
||||
end function
|
||||
@@ -1,8 +1,8 @@
|
||||
<component name="HomeScreen" extends="Group" includes="AutoBind,Focus">
|
||||
<component name="HomeScreen" extends="Group" includes="AutoBind,Focus,ContextMenuProvider">
|
||||
<interface>
|
||||
<field id="navBar" type="node" bind="/NavBar" />
|
||||
<field id="invidious" type="node" bind="/Invidious" />
|
||||
<field id="feedFile" type="string" value="libpkg:/config/default_home_layout.json5" />
|
||||
<field id="feedFile" type="string" value="libpkg:/config/default_home_layout.yaml" />
|
||||
</interface>
|
||||
<children>
|
||||
<VideoRowList
|
||||
@@ -14,8 +14,8 @@
|
||||
rowItemSpacing="[[25,0]]"
|
||||
itemSize="[1280,326]"
|
||||
itemSpacing="[0,65]"
|
||||
rowLabelOffset="[[115,20]]"
|
||||
focusXOffset="[115]"
|
||||
rowLabelOffset="[[125,20]]"
|
||||
focusXOffset="[125]"
|
||||
showRowLabel="[true]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
variableWidthItems="true"
|
||||
|
||||
@@ -8,6 +8,7 @@ import "pkg:/source/utils/LoadingScreen.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
|
||||
function Init()
|
||||
m.top.focusable = true
|
||||
m.container = m.top.FindNode("container")
|
||||
m.keyboard = m.top.FindNode("keyboard")
|
||||
m.rowList = m.top.FindNode("rowList")
|
||||
@@ -16,6 +17,8 @@ function Init()
|
||||
m.suggestions = m.top.FindNode("suggestions")
|
||||
m.filtersButton = m.top.FindNode("filtersButton")
|
||||
|
||||
m.rowList.screen = m.top
|
||||
|
||||
textEditBox = m.keyboard.textEditBox
|
||||
textEditBox.voiceEntryType = "generic"
|
||||
textEditBox.voiceEnabled = true
|
||||
@@ -200,12 +203,13 @@ function Search(text as string)
|
||||
m.rowlist.ObserveFieldScoped("someContentReady", FuncName(OnSearchContentReady))
|
||||
ShowLoadingScreen()
|
||||
|
||||
requestData = {
|
||||
title: `Search - ${text}`,
|
||||
apiType: "Invidious",
|
||||
endpoint: "search",
|
||||
queryParams: {
|
||||
q: text
|
||||
feedSource = {
|
||||
"id": `inv_search_${CryptoUtils.GetMd5(text)}`,
|
||||
"title": `Search - ${text}`,
|
||||
"apiType": "Invidious",
|
||||
"endpoint": "search",
|
||||
"queryParams": {
|
||||
"q": text
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,18 +217,21 @@ function Search(text as string)
|
||||
for each filter in filters
|
||||
value = filters[filter]
|
||||
if IsString(value) and value.len() > 0
|
||||
requestData.queryParams[filter] = value
|
||||
feedSource.queryParams[filter] = value
|
||||
else if IsArray(value) and value.Count() > 0
|
||||
' TODO:P1 this is http client implementation details leaking
|
||||
' We need a declarative way to set array types
|
||||
requestData.queryParams[filter] = {
|
||||
feedSource.queryParams[filter] = {
|
||||
value: value,
|
||||
__arrayType: HttpClient.QueryParamArrayType.CommaSeparated
|
||||
}
|
||||
end if
|
||||
end for
|
||||
|
||||
m.rowList.contentData = [requestData]
|
||||
m.rowList.feeds = [{
|
||||
"title": `Search - ${text}`,
|
||||
"feedSources": [feedSource]
|
||||
}]
|
||||
end function
|
||||
|
||||
function OnSearchContentReady() as void
|
||||
@@ -243,7 +250,7 @@ function OnSearchContentReady() as void
|
||||
end function
|
||||
|
||||
function OnSearchError()
|
||||
m.rowlist.contentData = invalid
|
||||
m.rowlist.feeds = invalid
|
||||
m.rowlist.focusable = false
|
||||
HideLoadingScreen()
|
||||
end function
|
||||
@@ -258,7 +265,7 @@ end function
|
||||
|
||||
function ClearSearch()
|
||||
m.keyboard.text = ""
|
||||
m.rowlist.contentData = invalid
|
||||
m.rowlist.feeds = invalid
|
||||
m.rowlist.focusable = false
|
||||
ScrollUp()
|
||||
end function
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
rowItemSpacing="[[25,0]]"
|
||||
itemSize="[1280,326]"
|
||||
itemSpacing="[0,65]"
|
||||
rowLabelOffset="[[115,20]]"
|
||||
focusXOffset="[115]"
|
||||
rowLabelOffset="[[125,20]]"
|
||||
focusXOffset="[125]"
|
||||
showRowLabel="[true]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
variableWidthItems="true"
|
||||
|
||||
@@ -53,7 +53,9 @@ function RunTests(instance as string, content as object) as void
|
||||
for each testNode in testNodes
|
||||
timer.Mark()
|
||||
m[testNode.func](instance, testNode)
|
||||
|
||||
testNode.duration = timer.TotalMilliseconds()
|
||||
testNode.title = `${testNode.title} (${testNode.duration}ms)`
|
||||
|
||||
if testNode.state = "failed"
|
||||
LogError(testNode.details)
|
||||
|
||||
@@ -3,6 +3,7 @@ import "pkg:/components/Navigation/ScrollTo.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
|
||||
function Init()
|
||||
m.top.focusable = true
|
||||
m.container = m.top.findNode("Container")
|
||||
m.scrollAnimation = m.top.findNode("scrollAnimation")
|
||||
m.scrollAnimationInterpolator = m.scrollAnimation.findNode("scrollAnimationInterpolator")
|
||||
|
||||
@@ -0,0 +1,330 @@
|
||||
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
||||
import "pkg:/source/utils/CryptoUtils.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/RegistryUtils.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
const VIDEOS_GROUP = "Videos"
|
||||
const CHANNELS_GROUP = "Channels"
|
||||
const PLAYLISTS_GROUP = "Playlists"
|
||||
|
||||
function Init()
|
||||
m.top.content = m.top.findNode("content")
|
||||
m.bookmarksString = ""
|
||||
Load()
|
||||
m.top.ObserveField("contentChange", FuncName(OnContentChange))
|
||||
end function
|
||||
|
||||
function Load() as void
|
||||
bookmarksString = RegistryUtils.Read(RegistryUtils.BOOKMARKS)
|
||||
if bookmarksString = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.bookmarksString = bookmarksString
|
||||
bookmarks = ParseJson(bookmarksString)
|
||||
if bookmarks = invalid
|
||||
LogWarn("Failed to parse bookmarks json")
|
||||
return
|
||||
end if
|
||||
|
||||
for each bookmarkGroup in bookmarks.groups
|
||||
bookmarkGroupNode = GetOrCreateBookmarkGroup(bookmarkGroup.title)
|
||||
bookmarksCount = bookmarkGroup.bookmarks.Count()
|
||||
' AddFeedSourceBookmark inserts at the beginning of the list, so we need to iterate backwards
|
||||
for i = bookmarksCount - 1 to 0 step -1
|
||||
bookmark = bookmarkGroup.bookmarks[i]
|
||||
AddFeedSourceBookmark(bookmark.feedSource, bookmark.id, bookmarkGroupNode)
|
||||
end for
|
||||
end for
|
||||
end function
|
||||
|
||||
function Save() as void
|
||||
bookmarkGroupNodes = m.top.content.getChildren(-1, 0)
|
||||
if bookmarkGroupNodes.Count() = 0
|
||||
RegistryUtils.Delete(RegistryUtils.BOOKMARKS)
|
||||
return
|
||||
end if
|
||||
|
||||
groups = []
|
||||
for each bookmarkGroupNode in bookmarkGroupNodes
|
||||
bookmarks = []
|
||||
bookmarkNodes = bookmarkGroupNode.getChildren(-1, 0)
|
||||
for each bookmarkNode in bookmarkNodes
|
||||
bookmarks.push({
|
||||
"id": bookmarkNode.id,
|
||||
"feedSource": bookmarkNode.feedSource
|
||||
})
|
||||
end for
|
||||
groups.push({
|
||||
"title": bookmarkGroupNode.title,
|
||||
"bookmarks": bookmarks
|
||||
})
|
||||
end for
|
||||
|
||||
bookmarksString = FormatJson({
|
||||
"__version": m.top.__version,
|
||||
"groups": groups
|
||||
})
|
||||
|
||||
if m.bookmarksString = bookmarksString
|
||||
return
|
||||
end if
|
||||
|
||||
RegistryUtils.Write(RegistryUtils.BOOKMARKS, bookmarksString)
|
||||
m.bookmarksString = bookmarksString
|
||||
end function
|
||||
|
||||
function GetOrCreateBookmarkGroup(groupName as string) as object
|
||||
id = CryptoUtils.GetMd5(groupName)
|
||||
node = m.top.content.findNode(id)
|
||||
if node <> invalid
|
||||
return node
|
||||
end if
|
||||
node = CreateObject("roSGNode", "ContentNode")
|
||||
node.id = id
|
||||
node.title = groupName
|
||||
m.top.content.appendChild(node)
|
||||
LogInfo("Added bookmark group:", groupName)
|
||||
return node
|
||||
end function
|
||||
|
||||
function AddFeedSourceBookmark(feedSource as object, id as string, bookmarkGroupNode as dynamic)
|
||||
if IsString(bookmarkGroupNode)
|
||||
bookmarkGroupNode = GetOrCreateBookmarkGroup(bookmarkGroupNode)
|
||||
end if
|
||||
|
||||
feedSource.Delete("state")
|
||||
|
||||
bookmarkNode = CreateObject("roSGNode", "BookmarkContentNode")
|
||||
bookmarkNode.id = id
|
||||
bookmarkNode.feedSource = feedSource
|
||||
|
||||
bookmarkGroupNode.insertChild(bookmarkNode, 0)
|
||||
LogInfo("Added feedSource bookmark. title:", feedSource.title, "id:", id)
|
||||
m.top.contentChange = true
|
||||
end function
|
||||
|
||||
function AddVideoBookmark(id as string, groupName as string)
|
||||
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
|
||||
|
||||
feedSource = {
|
||||
"apiType": "Invidious",
|
||||
"endpoint": "video_info",
|
||||
"pathParams": {
|
||||
"id": id
|
||||
}
|
||||
}
|
||||
AddFeedSourceBookmark(feedSource, id, bookmarkGroupNode)
|
||||
end function
|
||||
|
||||
function AddPlaylistBookmark(id as string, groupName as string)
|
||||
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
|
||||
|
||||
feedSource = {
|
||||
"apiType": "Invidious",
|
||||
"endpoint": "playlist_info",
|
||||
"pathParams": {
|
||||
"plid": id
|
||||
}
|
||||
}
|
||||
AddFeedSourceBookmark(feedSource, id, bookmarkGroupNode)
|
||||
end function
|
||||
|
||||
function AddPlaylistBookmarkWithSpread(id as string, groupName as string)
|
||||
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
|
||||
|
||||
feedSource = {
|
||||
"id": `inv_playlist_${id}`,
|
||||
"title": `${groupName} videos`,
|
||||
"apiType": "Invidious",
|
||||
"endpoint": "playlist",
|
||||
"pathParams": {
|
||||
"plid": id
|
||||
}
|
||||
}
|
||||
AddFeedSourceBookmark(feedSource, `inv_playlist_${id}`, bookmarkGroupNode)
|
||||
|
||||
feedSource = {
|
||||
"apiType": "Invidious",
|
||||
"endpoint": "playlist_info",
|
||||
"pathParams": {
|
||||
"plid": id
|
||||
}
|
||||
}
|
||||
AddFeedSourceBookmark(feedSource, id, bookmarkGroupNode)
|
||||
end function
|
||||
|
||||
function AddChannelBookmark(id as string, groupName as string)
|
||||
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
|
||||
|
||||
feedSource = {
|
||||
"apiType": "Invidious",
|
||||
"endpoint": "channel_info",
|
||||
"pathParams": {
|
||||
"ucid": id
|
||||
}
|
||||
}
|
||||
AddFeedSourceBookmark(feedSource, id, bookmarkGroupNode)
|
||||
end function
|
||||
|
||||
function AddChannelBookmarkWithSpread(id as string, groupName as string)
|
||||
bookmarkGroupNode = GetOrCreateBookmarkGroup(groupName)
|
||||
|
||||
feedSource = {
|
||||
"id": `inv_channel_videos_${id}`,
|
||||
"title": `${groupName} videos`,
|
||||
"apiType": "Invidious",
|
||||
"endpoint": "channel_videos",
|
||||
"pathParams": {
|
||||
"ucid": id
|
||||
}
|
||||
}
|
||||
AddFeedSourceBookmark(feedSource, `inv_channel_videos_${id}`, bookmarkGroupNode)
|
||||
|
||||
feedSource = {
|
||||
"apiType": "Invidious",
|
||||
"endpoint": "channel_info",
|
||||
"pathParams": {
|
||||
"ucid": id
|
||||
}
|
||||
}
|
||||
AddFeedSourceBookmark(feedSource, id, bookmarkGroupNode)
|
||||
end function
|
||||
|
||||
function RemoveBookmark(id as string) as void
|
||||
node = m.top.content.findNode(id)
|
||||
if node = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
group = node.getParent()
|
||||
group.removeChild(node)
|
||||
LogInfo("Removed bookmark:", id)
|
||||
|
||||
if group.getChildCount() = 0
|
||||
m.top.content.removeChild(group)
|
||||
LogInfo("Removed bookmark group:", group.title)
|
||||
end if
|
||||
m.top.contentChange = true
|
||||
end function
|
||||
|
||||
function OnContentChange(event as object) as void
|
||||
Save()
|
||||
end function
|
||||
|
||||
function GetContextMenuOptionsForItem(item as object) as object
|
||||
options = []
|
||||
if item.type = "video"
|
||||
options.append(GetMenuForVideo(item))
|
||||
else if item.type = "playlist"
|
||||
options.append(GetMenuForPlaylist(item))
|
||||
else if item.type = "channel"
|
||||
options.append(GetMenuForChannel(item))
|
||||
end if
|
||||
options.append(GetMenuForParentFeedSource(item))
|
||||
return options
|
||||
end function
|
||||
|
||||
function GetMenuForVideo(videoNode as object) as object
|
||||
videoId = videoNode.videoId
|
||||
if StringUtils.IsNullOrEmpty(videoId)
|
||||
return []
|
||||
end if
|
||||
|
||||
menu = []
|
||||
bookmark = m.top.content.findNode(videoId)
|
||||
isInBookmarks = bookmark <> invalid
|
||||
if isInBookmarks
|
||||
bookmarkGroup = bookmark.getParent()
|
||||
item = ContextMenuUtils.CreateOption(`Remove from "${bookmarkGroup.title}" bookmarks`, m.top, "RemoveBookmark", [videoId])
|
||||
menu.push(item)
|
||||
else
|
||||
item = ContextMenuUtils.CreateOption(`Add to "${VIDEOS_GROUP}" bookmark`, m.top, "AddVideoBookmark", [videoId, VIDEOS_GROUP])
|
||||
menu.push(item)
|
||||
end if
|
||||
return menu
|
||||
end function
|
||||
|
||||
function GetMenuForPlaylist(playlistNode as object) as object
|
||||
playlistId = playlistNode.playlistId
|
||||
if StringUtils.IsNullOrEmpty(playlistId) or playlistId.StartsWith("IV")
|
||||
return []
|
||||
end if
|
||||
|
||||
menu = []
|
||||
bookmark = m.top.content.findNode(playlistId)
|
||||
isInBookmarks = bookmark <> invalid
|
||||
if isInBookmarks
|
||||
bookmarkGroup = bookmark.getParent()
|
||||
item = ContextMenuUtils.CreateOption(`Remove from "${bookmarkGroup.title}" bookmarks`, m.top, "RemoveBookmark", [playlistId])
|
||||
menu.push(item)
|
||||
else
|
||||
item = ContextMenuUtils.CreateOption(`Add to "${PLAYLISTS_GROUP}" bookmark`, m.top, "AddPlaylistBookmark", [playlistId, PLAYLISTS_GROUP])
|
||||
menu.push(item)
|
||||
|
||||
item = ContextMenuUtils.CreateOption(`Add to "${playlistNode.title}" bookmark`, m.top, "AddPlaylistBookmarkWithSpread", [playlistId, playlistNode.title])
|
||||
menu.push(item)
|
||||
end if
|
||||
return menu
|
||||
end function
|
||||
|
||||
function GetMenuForChannel(channelNode as object) as object
|
||||
authorId = channelNode.authorId
|
||||
if StringUtils.IsNullOrEmpty(authorId)
|
||||
return []
|
||||
end if
|
||||
|
||||
menu = []
|
||||
bookmark = m.top.content.findNode(authorId)
|
||||
isInBookmarks = bookmark <> invalid
|
||||
if isInBookmarks
|
||||
bookmarkGroup = bookmark.getParent()
|
||||
item = ContextMenuUtils.CreateOption(`Remove from "${bookmarkGroup.title}" bookmarks`, m.top, "RemoveBookmark", [authorId])
|
||||
menu.push(item)
|
||||
else
|
||||
item = ContextMenuUtils.CreateOption(`Add to "${CHANNELS_GROUP}" bookmark`, m.top, "AddChannelBookmark", [authorId, CHANNELS_GROUP])
|
||||
menu.push(item)
|
||||
|
||||
item = ContextMenuUtils.CreateOption(`Add to "${channelNode._author}" bookmark`, m.top, "AddChannelBookmarkWithSpread", [authorId, channelNode._author])
|
||||
menu.push(item)
|
||||
end if
|
||||
return menu
|
||||
end function
|
||||
|
||||
function GetMenuForParentFeedSource(itemNode as object) as object
|
||||
if itemNode = invalid
|
||||
return []
|
||||
end if
|
||||
if itemNode.type <> "video" and itemNode.type <> "playlist" and itemNode.type <> "channel"
|
||||
return []
|
||||
end if
|
||||
if not IsInt(itemNode.feedSourcesIndex) or itemNode.feedSourcesIndex = -1
|
||||
return []
|
||||
end if
|
||||
feedContentNode = itemNode.getParent()
|
||||
if feedContentNode = invalid or feedContentNode.subtype() <> "FeedContentNode"
|
||||
return []
|
||||
end if
|
||||
|
||||
feedSource = feedContentNode.feedSources[itemNode.feedSourcesIndex]
|
||||
if StringUtils.IsNullOrEmpty(feedSource.title) or StringUtils.IsNullOrEmpty(feedSource.id)
|
||||
return []
|
||||
end if
|
||||
|
||||
title = feedSource.title
|
||||
feedSourceId = feedSource.id
|
||||
|
||||
menu = []
|
||||
isInBookmarks = m.top.content.findNode(feedSourceId) <> invalid
|
||||
|
||||
if isInBookmarks
|
||||
item = ContextMenuUtils.CreateOption(`Remove "${feedSource.title}" from bookmarks`, m.top, "RemoveBookmark", [feedSourceId])
|
||||
menu.push(item)
|
||||
else
|
||||
item = ContextMenuUtils.CreateOption(`Add to "${title}" bookmark`, m.top, "AddFeedSourceBookmark", [feedSource, feedSourceId, title])
|
||||
menu.push(item)
|
||||
end if
|
||||
return menu
|
||||
end function
|
||||
@@ -0,0 +1,20 @@
|
||||
<component name="Bookmarks" extends="Node" includes="ContextMenuProvider">
|
||||
<interface>
|
||||
<field id="__version" type="integer" value="1" />
|
||||
<field id="content" type="node" />
|
||||
<field id="contentChange" type="boolean" alwaysNotify="true" />
|
||||
<function name="AddFeedSourceBookmark" />
|
||||
<function name="AddVideoBookmark" />
|
||||
<function name="AddPlaylistBookmark" />
|
||||
<function name="AddPlaylistBookmarkWithSpread" />
|
||||
<function name="AddChannelBookmark" />
|
||||
<function name="AddChannelBookmarkWithSpread" />
|
||||
<function name="RemoveBookmark" />
|
||||
<function name="GetMenuForVideo" />
|
||||
<function name="GetMenuForPlaylist" />
|
||||
<function name="GetMenuForChannel" />
|
||||
</interface>
|
||||
<children>
|
||||
<ContentNode id="content" />
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,373 @@
|
||||
import "pkg:/components/Web/WebServer/Http/HttpUtils.bs"
|
||||
import "pkg:/source/services/XmlObject.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
class DashManifest
|
||||
|
||||
public invidiousInstance as dynamic
|
||||
|
||||
function new(invidiousInstance as string)
|
||||
m.utils = new Http.Utils()
|
||||
m.invidiousInstance = invidiousInstance
|
||||
end function
|
||||
|
||||
function fromVideoMetadata(metadata as object, local as boolean) as string
|
||||
adaptiveFormats = []
|
||||
adaptiveFormats.Append (metadata.adaptiveFormats)
|
||||
|
||||
if local
|
||||
urlRegex = CreateObject("roRegex", "https?:\/\/\S+(\/\S+)", "i")
|
||||
|
||||
for i = 0 to adaptiveFormats.Count() - 1
|
||||
adaptiveFormats[i].url = urlRegex.replace(adaptiveFormats[i].url, m.invidiousInstance + "\1")
|
||||
end for
|
||||
end if
|
||||
|
||||
audioStreams = m.getAudioStreams(adaptiveFormats)
|
||||
videoStreams = m.getVideoStreams(adaptiveFormats)
|
||||
|
||||
videoMimeTypes = m.getMimeTypes(videoStreams)
|
||||
audioSets = m.getMimeTypeLanguageCombos(audioStreams)
|
||||
storyboards = metadata.storyboards
|
||||
|
||||
xml = new XmlObject()
|
||||
|
||||
if xml.Node("MPD", {
|
||||
"xmlns": "urn:mpeg:dash:schema:mpd:2011",
|
||||
"profiles": "urn:mpeg:dash:profile:full:2011",
|
||||
"minBufferTime": "PT1.5S",
|
||||
"type": "static",
|
||||
"mediaPresentationDuration": `PT${metadata.lengthSeconds ?? 0}S`
|
||||
})
|
||||
if xml.Node("Period")
|
||||
|
||||
id = 0
|
||||
for each audioSet in audioSets
|
||||
adaptationSetAttributes = {
|
||||
"id": `${id}`,
|
||||
"mimeType": audioSet.mimeType,
|
||||
"startWithSAP": "1",
|
||||
"subsegmentAlignment": "true"
|
||||
}
|
||||
if not StringUtils.IsNullOrEmpty(audioSet.lang)
|
||||
adaptationSetAttributes["lang"] = audioSet.lang
|
||||
end if
|
||||
|
||||
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
||||
xml.Node("Role", {
|
||||
"schemeIdUri": "urn:mpeg:dash:role:2011",
|
||||
"value": audioSet.acont = "original" ? "main" : "alternate"
|
||||
})
|
||||
xml.End()
|
||||
|
||||
for i = 0 to audioStreams.Count() - 1
|
||||
stream = audioStreams[i]
|
||||
streamMimeType = stream.type.Tokenize(";")[0]
|
||||
if streamMimeType <> audioSet.mimeType or stream.languageInfo.lang <> audioSet.lang or stream.languageInfo.acont <> audioSet.acont
|
||||
continue for
|
||||
end if
|
||||
|
||||
codecs = stream.type.split("codecs=")[1]
|
||||
if codecs.startsWith(`"`)
|
||||
codecs = codecs.mid(1)
|
||||
end if
|
||||
if codecs.endsWith(`"`)
|
||||
codecs = codecs.left(codecs.len() - 1)
|
||||
end if
|
||||
|
||||
if xml.Node("Representation", {
|
||||
"id": stream.itag,
|
||||
"codecs": codecs,
|
||||
"bandwidth": stream.bitrate
|
||||
})
|
||||
|
||||
xml.Node("AudioChannelConfiguration", {
|
||||
"schemeIdUri": "urn:mpeg:dash:23003:3:audio_channel_configuration:2011",
|
||||
"value": `${stream.audioChannels}`
|
||||
})
|
||||
xml.End()
|
||||
|
||||
if xml.Node("BaseURL")
|
||||
xml.Text(stream.url)
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
if xml.Node("SegmentBase", {
|
||||
"indexRange": stream.index
|
||||
})
|
||||
if xml.Node("Initialization", {
|
||||
"range": stream.init
|
||||
})
|
||||
xml.End()
|
||||
end if
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
end for
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
id += 1
|
||||
end for
|
||||
|
||||
for each mimeType in videoMimeTypes
|
||||
if xml.Node("AdaptationSet", {
|
||||
"id": `${id}`,
|
||||
"mimeType": mimeType,
|
||||
"startWithSAP": "1",
|
||||
"subsegmentAlignment": "true"
|
||||
})
|
||||
|
||||
for i = 0 to videoStreams.Count() - 1
|
||||
stream = videoStreams[i]
|
||||
streamMimeType = stream.type.Tokenize(";")[0]
|
||||
if streamMimeType <> mimeType
|
||||
continue for
|
||||
end if
|
||||
|
||||
codecs = stream.type.split("codecs=")[1]
|
||||
if codecs.startsWith(`"`)
|
||||
codecs = codecs.mid(1)
|
||||
end if
|
||||
if codecs.endsWith(`"`)
|
||||
codecs = codecs.left(codecs.len() - 1)
|
||||
end if
|
||||
|
||||
representationAttributes = {
|
||||
"id": stream.itag,
|
||||
"codecs": codecs,
|
||||
"startWithSAP": "1",
|
||||
"maxPlayoutRate": "1",
|
||||
"bandwidth": stream.bitrate
|
||||
}
|
||||
if stream.width <> invalid
|
||||
representationAttributes["width"] = `${stream.width}`
|
||||
end if
|
||||
if stream.height <> invalid
|
||||
representationAttributes["height"] = `${stream.height}`
|
||||
end if
|
||||
if stream.fps <> invalid
|
||||
representationAttributes["frameRate"] = `${stream.fps}`
|
||||
end if
|
||||
|
||||
if xml.Node("Representation", representationAttributes)
|
||||
if xml.Node("BaseURL")
|
||||
xml.Text(stream.url)
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
if xml.Node("SegmentBase", {
|
||||
"indexRange": stream.index
|
||||
})
|
||||
if xml.Node("Initialization", {
|
||||
"range": stream.init
|
||||
})
|
||||
xml.End()
|
||||
end if
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
end for
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
id += 1
|
||||
end for
|
||||
|
||||
' https://developer.roku.com/en-ca/docs/developer-program/media-playback/trick-mode/hls-and-dash.md#dash-standard-thumbnail-tiles
|
||||
for each storyboard in storyboards
|
||||
interval = ValidInt(storyboard.interval)
|
||||
if interval = 0
|
||||
LogWarn("Invalid storyboard interval=0")
|
||||
continue for
|
||||
end if
|
||||
|
||||
templateUrl = storyboard.templateUrl
|
||||
if templateUrl.Instr("$M") = -1
|
||||
LogWarn("Invalid storyboard url: url does not contain $M:", templateUrl)
|
||||
continue for
|
||||
end if
|
||||
|
||||
storyboardWidth = storyboard.storyboardWidth
|
||||
storyboardHeight = storyboard.storyboardHeight
|
||||
storyboardCount = storyboard.storyboardCount
|
||||
tileWidthInPixels = storyboard.width
|
||||
tileHeightInPixels = storyboard.height
|
||||
totalTileCount = storyboard.count
|
||||
|
||||
' For the last page, the image height might be smaller than the storyboard height
|
||||
if storyboardCount = 1
|
||||
storyboardHeight = totalTileCount \ storyboardWidth
|
||||
if totalTileCount mod storyboardWidth > 0
|
||||
storyboardHeight += 1
|
||||
end if
|
||||
end if
|
||||
|
||||
intervalInSeconds = interval \ 1000
|
||||
|
||||
' Youtube template uses the var $M for tile pages
|
||||
' DASH-IF uses $Number$ in the SegmentTemplate
|
||||
' https://dashif.org/docs/DASH-IF-IOP-v4.3.pdf
|
||||
url = templateUrl.replace("$M", "$Number$")
|
||||
|
||||
tilesPerPage = storyboardWidth * storyboardHeight
|
||||
duration = tilesPerPage * intervalInSeconds
|
||||
|
||||
storyboardWidthInPixels = tileWidthInPixels * storyboardWidth
|
||||
storyboardHeightInPixels = tileHeightInPixels * storyboardHeight
|
||||
|
||||
' Bandwidth is kind of a guess...
|
||||
bandwidth = ((storyboardWidthInPixels * storyboardHeightInPixels * 0.5) / duration)
|
||||
|
||||
if xml.Node("AdaptationSet", {
|
||||
"id": `${id}`,
|
||||
"mimeType": "image/jpeg",
|
||||
"contentType": "image"
|
||||
})
|
||||
xml.Node("SegmentTemplate", {
|
||||
"media": url,
|
||||
"duration": duration,
|
||||
"startNumber": 0
|
||||
})
|
||||
xml.End()
|
||||
|
||||
if xml.Node("Representation", {
|
||||
"id": `thumbnails_${id}`,
|
||||
"bandwidth": bandwidth,
|
||||
"width": storyboardWidthInPixels,
|
||||
"height": storyboardHeightInPixels
|
||||
})
|
||||
|
||||
xml.Node("EssentialProperty", {
|
||||
"schemeIdUri": "http://dashif.org/guidelines/thumbnail_tile",
|
||||
"value": `${storyboardWidth}x${storyboardHeight}`
|
||||
})
|
||||
xml.End()
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
id += 1
|
||||
end for
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
return xml.ToXmlString()
|
||||
end function
|
||||
|
||||
function getAudioStreams(streams as object) as object
|
||||
audioStreams = []
|
||||
for i = 0 to streams.Count() - 1
|
||||
stream = streams[i]
|
||||
if stream.type.startsWith("audio/")
|
||||
if stream.bitrate = invalid
|
||||
LogWarn("Invalid audio stream bitrate, itag:", stream.itag)
|
||||
continue for
|
||||
end if
|
||||
if stream.init = invalid
|
||||
LogWarn("Invalid audio stream init, itag:", stream.itag)
|
||||
continue for
|
||||
end if
|
||||
if stream.index = invalid
|
||||
LogWarn("Invalid audio stream index, itag:", stream.itag)
|
||||
continue for
|
||||
end if
|
||||
stream.languageInfo = m.ParseAudioLanguage(stream.url)
|
||||
audioStreams.Push(stream)
|
||||
end if
|
||||
end for
|
||||
|
||||
audioStreams.SortBy("bitrate", "r")
|
||||
return audioStreams
|
||||
end function
|
||||
|
||||
function getVideoStreams(streams as object) as object
|
||||
videoStreams = []
|
||||
for i = 0 to streams.Count() - 1
|
||||
stream = streams[i]
|
||||
if stream.type.startsWith("video/")
|
||||
if stream.bitrate = invalid
|
||||
LogWarn("Invalid video stream bitrate, itag:", stream.itag)
|
||||
continue for
|
||||
end if
|
||||
if stream.init = invalid
|
||||
LogWarn("Invalid video stream init, itag:", stream.itag)
|
||||
continue for
|
||||
end if
|
||||
if stream.index = invalid
|
||||
LogWarn("Invalid video stream index, itag:", stream.itag)
|
||||
continue for
|
||||
end if
|
||||
videoStreams.Push(stream)
|
||||
end if
|
||||
end for
|
||||
|
||||
videoStreams.SortBy("bitrate", "r")
|
||||
return videoStreams
|
||||
end function
|
||||
|
||||
function getMimeTypes(streams as object) as object
|
||||
mimeTypes = {}
|
||||
for i = 0 to streams.Count() - 1
|
||||
stream = streams[i]
|
||||
mimeType = stream.type.Tokenize(";")[0]
|
||||
mimeTypes[mimeType] = true
|
||||
end for
|
||||
return mimeTypes.Keys()
|
||||
end function
|
||||
|
||||
function getMimeTypeLanguageCombos(streams as object) as object
|
||||
types = {}
|
||||
for i = 0 to streams.Count() - 1
|
||||
stream = streams[i]
|
||||
mimeType = stream.type.Tokenize(";")[0]
|
||||
types[`${mimeType}-${stream.languageInfo.lang}-${stream.languageInfo.acont}`] = {
|
||||
"mimeType": mimeType,
|
||||
"lang": stream.languageInfo.lang,
|
||||
"acont": stream.languageInfo.acont
|
||||
}
|
||||
end for
|
||||
|
||||
combos = []
|
||||
for each t in types
|
||||
combos.Push(types[t])
|
||||
end for
|
||||
|
||||
return combos
|
||||
end function
|
||||
|
||||
function ParseAudioLanguage(url as string) as object
|
||||
result = { lang: "", acont: "" }
|
||||
queryParams = m.utils.ParseUrlQueryComponents(url)
|
||||
if StringUtils.IsNullOrEmpty(queryParams["xtags"])
|
||||
return result
|
||||
end if
|
||||
|
||||
xtags = queryParams["xtags"].split(":")
|
||||
for each xtag in xtags
|
||||
if xtag.instr("=") > 0
|
||||
parts = xtag.split("=")
|
||||
if parts.Count() = 2
|
||||
if parts[0] = "lang"
|
||||
result["lang"] = parts[1]
|
||||
end if
|
||||
if parts[0] = "acont"
|
||||
result["acont"] = parts[1]
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
return result
|
||||
end function
|
||||
end class
|
||||
@@ -1,7 +1,7 @@
|
||||
import "InvidiousService.bs"
|
||||
|
||||
function Init()
|
||||
m.top.apiDefinitions = ParseJson(ReadAsciiFile("libpkg:/config/invidious_video_api.json5"))
|
||||
m.top.apiDefinitions = ParseJson(ReadAsciiFile("libpkg:/config/invidious_video_api.yaml"))
|
||||
m.service = new Invidious.InvidiousService(m.top)
|
||||
m.top.authToken = m.service.GetAuthToken()
|
||||
end function
|
||||
|
||||
@@ -36,19 +36,16 @@ namespace Invidious
|
||||
|
||||
function new(node as object)
|
||||
m.node = node
|
||||
' TODO:P2 api definitions are not needed everytime, move them to a separate function and lazy load
|
||||
apiDefinitions = node.apiDefinitions
|
||||
|
||||
m.endpoints = {}
|
||||
|
||||
for each apiDefinition in apiDefinitions.endpoints
|
||||
m.endpoints[apiDefinition.name] = apiDefinition
|
||||
end for
|
||||
m.endpoints = node.apiDefinitions
|
||||
|
||||
m.responseHanlders = {
|
||||
DefaultHandler: m.DefaultHandler,
|
||||
AuthFeedHandler: m.AuthFeedHandler,
|
||||
PlaylistHandler: m.PlaylistHandler,
|
||||
VideoInfoHandler: m.VideoInfoHandler,
|
||||
PlaylistInfoHandler: m.PlaylistInfoHandler,
|
||||
ChannelInfoHandler: m.ChannelInfoHandler,
|
||||
ChannelVideosHandler: m.ChannelVideosHandler,
|
||||
ChannelPlaylistsHandler: m.ChannelPlaylistsHandler,
|
||||
ChannelRelatedChannelsHandler: m.ChannelRelatedChannelsHandler
|
||||
@@ -99,7 +96,11 @@ namespace Invidious
|
||||
request = HttpClient.Get(url)
|
||||
request.QueryParams(m.DefaultQueryParams())
|
||||
request.QueryParam("q", q)
|
||||
request.CacheSeconds(60 * 60 * 6)' 6 hours
|
||||
' 5 hours cache. Videos should expire in 6 hours, but since we don't
|
||||
' have the exact expiration time, we'll use 5 hours. Invidious currently
|
||||
' Does a fresh fetch if the cache is older than 10 minutes.
|
||||
' https://github.com/iv-org/invidious/blob/069e91d2a609b1df94bdfbb693335969b2a281d8/src/invidious/videos.cr#L349
|
||||
request.CacheSeconds(60 * 60 * 5)
|
||||
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
@@ -145,6 +146,7 @@ namespace Invidious
|
||||
request = HttpClient.Get(url)
|
||||
request.QueryParams(m.DefaultQueryParams())
|
||||
request.Cancellation(cancellation)
|
||||
request.CacheSeconds(60 * 60 * 24)' 24 hours
|
||||
|
||||
return request.Await()
|
||||
end function
|
||||
@@ -154,39 +156,50 @@ namespace Invidious
|
||||
return `${instance}/latest_version?id=${videoId}`
|
||||
end function
|
||||
|
||||
function MarkFeedPagination(contentNode as object) as void
|
||||
requestData = contentNode.feed
|
||||
function MarkFeedPagination(feedContentNode as object) as object
|
||||
feedSources = feedContentNode.feedSources
|
||||
feedSourcesIndex = feedContentNode.feedSourcesIndex
|
||||
|
||||
endpoint = m.endpoints[requestData.endpoint]
|
||||
feedSource = feedSources[feedSourcesIndex]
|
||||
|
||||
endpoint = m.endpoints[feedSource.endpoint]
|
||||
if endpoint = invalid or StringUtils.IsNullOrEmpty(endpoint.paginationType)
|
||||
return
|
||||
return feedSource
|
||||
end if
|
||||
|
||||
if not requestData.DoesExist("queryParams")
|
||||
requestData.queryParams = {}
|
||||
feedSourceState = feedSource.state
|
||||
if not feedSourceState.DoesExist("queryParams")
|
||||
feedSourceState["queryParams"] = {}
|
||||
end if
|
||||
|
||||
contentNode.paginationType = endpoint.paginationType
|
||||
|
||||
if endpoint.paginationType = PaginationType.Pages
|
||||
contentNode.page += 1
|
||||
requestData.queryParams.page = contentNode.page
|
||||
else if endpoint.paginationType = PaginationType.Continuation
|
||||
continuation = contentNode.continuation
|
||||
feedSourceState.paginationType = endpoint.paginationType
|
||||
if feedSourceState.paginationType = PaginationType.Pages
|
||||
if not IsInt(feedSourceState.page)
|
||||
feedSourceState.page = 0
|
||||
end if
|
||||
feedSourceState.page += 1
|
||||
feedSourceState.queryParams.page = feedSourceState.page
|
||||
else if feedSourceState.paginationType = PaginationType.Continuation
|
||||
continuation = feedSourceState.continuation
|
||||
if not StringUtils.IsNullOrEmpty(continuation)
|
||||
requestData.queryParams.continuation = continuation
|
||||
feedSourceState.queryParams.continuation = continuation
|
||||
else
|
||||
feedSourceState.queryParams.Delete("continuation")
|
||||
end if
|
||||
end if
|
||||
|
||||
contentNode.feed = requestData
|
||||
feedSource.state = feedSourceState
|
||||
feedSources[feedSourcesIndex] = feedSource
|
||||
feedContentNode.feedSources = feedSources
|
||||
return feedSource
|
||||
end function
|
||||
|
||||
function MakeRequest(requestData as object, cancellation = invalid as object) as object
|
||||
endpoint = m.endpoints[requestData.endpoint]
|
||||
function MakeRequest(feedSource as object, additionalQueryParams = invalid as object, cancellation = invalid as object) as object
|
||||
endpoint = m.endpoints[feedSource.endpoint]
|
||||
if endpoint = invalid
|
||||
return {
|
||||
success: false,
|
||||
error: `Endpoint ${requestData.endpoint} not found`
|
||||
error: `Endpoint ${feedSource.endpoint} not found`
|
||||
}
|
||||
end if
|
||||
|
||||
@@ -229,18 +242,22 @@ namespace Invidious
|
||||
end for
|
||||
end if
|
||||
|
||||
if requestData.cacheSeconds <> invalid
|
||||
request.CacheSeconds(requestData.cacheSeconds)
|
||||
if feedSource.cacheSeconds <> invalid
|
||||
request.CacheSeconds(feedSource.cacheSeconds)
|
||||
else if endpoint.cacheSeconds <> invalid
|
||||
request.CacheSeconds(endpoint.cacheSeconds)
|
||||
end if
|
||||
|
||||
if requestData.queryParams <> invalid
|
||||
request.QueryParams(requestData.queryParams)
|
||||
if feedSource.queryParams <> invalid
|
||||
request.QueryParams(feedSource.queryParams)
|
||||
end if
|
||||
|
||||
if requestData.pathParams <> invalid
|
||||
request.PathParams(requestData.pathParams)
|
||||
if additionalQueryParams <> invalid
|
||||
request.QueryParams(additionalQueryParams)
|
||||
end if
|
||||
|
||||
if feedSource.pathParams <> invalid
|
||||
request.PathParams(feedSource.pathParams)
|
||||
end if
|
||||
|
||||
request.Cancellation(cancellation)
|
||||
@@ -249,7 +266,7 @@ namespace Invidious
|
||||
|
||||
responseHandler = endpoint.responseHandler <> invalid ? m.responseHanlders[endpoint.responseHandler] : m.responseHanlders["DefaultHandler"]
|
||||
|
||||
result = responseHandler(m, requestData, response)
|
||||
result = responseHandler(m, feedSource, response)
|
||||
|
||||
if response.IsSuccess() and result <> invalid
|
||||
return {
|
||||
@@ -264,7 +281,7 @@ namespace Invidious
|
||||
end if
|
||||
end function
|
||||
|
||||
function DefaultHandler(m as object, requestData as object, response as object) as object
|
||||
function DefaultHandler(m as object, feedSource as object, response as object) as object
|
||||
if response.StatusCode() = 200
|
||||
json = response.Json()
|
||||
return {
|
||||
@@ -274,7 +291,7 @@ namespace Invidious
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function PlaylistHandler(m as object, requestData as object, response as object) as object
|
||||
function PlaylistHandler(m as object, feedSource as object, response as object) as object
|
||||
if response.StatusCode() = 200
|
||||
json = response.Json()
|
||||
return {
|
||||
@@ -284,7 +301,7 @@ namespace Invidious
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function ChannelVideosHandler(m as object, requestData as object, response as object) as object
|
||||
function ChannelVideosHandler(m as object, feedSource as object, response as object) as object
|
||||
if response.StatusCode() = 200
|
||||
json = response.Json()
|
||||
return {
|
||||
@@ -295,7 +312,7 @@ namespace Invidious
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function ChannelPlaylistsHandler(m as object, requestData as object, response as object) as object
|
||||
function ChannelPlaylistsHandler(m as object, feedSource as object, response as object) as object
|
||||
if response.StatusCode() = 200
|
||||
json = response.Json()
|
||||
return {
|
||||
@@ -306,7 +323,7 @@ namespace Invidious
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function ChannelRelatedChannelsHandler(m as object, requestData as object, response as object) as object
|
||||
function ChannelRelatedChannelsHandler(m as object, feedSource as object, response as object) as object
|
||||
if response.StatusCode() = 200
|
||||
json = response.Json()
|
||||
return {
|
||||
@@ -317,7 +334,40 @@ namespace Invidious
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function AuthFeedHandler(m as object, requestData as object, response as object) as object
|
||||
function VideoInfoHandler(m as object, feedSource as object, response as object) as object
|
||||
if response.StatusCode() = 200
|
||||
json = response.Json()
|
||||
json.type = "video"
|
||||
return {
|
||||
items: [json]
|
||||
}
|
||||
end if
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function PlaylistInfoHandler(m as object, feedSource as object, response as object) as object
|
||||
if response.StatusCode() = 200
|
||||
json = response.Json()
|
||||
json.type = "playlist"
|
||||
return {
|
||||
items: [json]
|
||||
}
|
||||
end if
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function ChannelInfoHandler(m as object, feedSource as object, response as object) as object
|
||||
if response.StatusCode() = 200
|
||||
json = response.Json()
|
||||
json.type = "channel"
|
||||
return {
|
||||
items: [json]
|
||||
}
|
||||
end if
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function AuthFeedHandler(m as object, feedSource as object, response as object) as object
|
||||
m.DeleteExpiredToken(response)
|
||||
|
||||
if response.StatusCode() = 200
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace InvidiousContent
|
||||
node.type = "video"
|
||||
|
||||
SetIfExists(node, "author", item, "author")
|
||||
SetIfExists(node, "authorId", item, "authorId")
|
||||
SetIfExists(node, "hlsUrl", item, "hlsUrl")
|
||||
SetIfExists(node, "isUpcoming", item, "isUpcoming")
|
||||
SetIfExists(node, "lengthSeconds", item, "lengthSeconds")
|
||||
node.lengthText = TimeUtils.GetFormattedTime(item.lengthSeconds)
|
||||
node.liveNow = VideoIsLive(item)
|
||||
@@ -62,6 +62,7 @@ namespace InvidiousContent
|
||||
|
||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||
SetIfExists(node, "_author", item, "author")
|
||||
SetIfExists(node, "authorId", item, "authorId")
|
||||
SetIfExists(node, "description", item, "description")
|
||||
SetIfExists(node, "playlistId", item, "playlistId")
|
||||
SetIfExists(node, "title", item, "title")
|
||||
@@ -108,6 +109,7 @@ namespace InvidiousContent
|
||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||
SetIfExists(node, "_author", item, "author")
|
||||
SetIfExists(node, "authorId", item, "authorId")
|
||||
SetIfExists(node, "channelHandle", item, "channelHandle")
|
||||
SetIfExists(node, "description", item, "description")
|
||||
SetIfExists(node, "subCount", item, "subCount")
|
||||
node.subCountText = GetChannelSubCountText(item)
|
||||
@@ -156,11 +158,12 @@ namespace InvidiousContent
|
||||
end function
|
||||
|
||||
function VideoIsUpcoming(videoItem as object) as boolean
|
||||
return videoItem.isUpcoming = true
|
||||
return videoItem.isUpcoming = true and ValidInt(videoItem.premiereTimestamp) <> 0
|
||||
end function
|
||||
|
||||
function VideoSetPremiereTimestampText(node as object, videoItem as object)
|
||||
if VideoIsUpcoming(videoItem) and videoItem.premiereTimestamp <> invalid
|
||||
if VideoIsUpcoming(videoItem)
|
||||
node.isUpcoming = true
|
||||
node.premiereTimestampText = `Premeres in ${TimeUtils.GetFormattedTimeLeft(videoItem.premiereTimestamp)}`
|
||||
end if
|
||||
end function
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace SponsorBlock
|
||||
return invalid
|
||||
end if
|
||||
|
||||
categories = ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "poi_highlight", "chapter", "filler", "exclusive_access"]
|
||||
categories = ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "poi_highlight", "filler", "exclusive_access"]
|
||||
actionTypes = ["skip", "mute", "chapter", "full", "poi"]
|
||||
|
||||
categoriesJson = FormatJson(categories).EncodeUriComponent()
|
||||
|
||||
@@ -8,6 +8,6 @@ function OnContentSet() as void
|
||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||
m.top._author = content._author
|
||||
m.top.subCountText = content.subCountText
|
||||
m.top.videoCountText = content.videoCountText
|
||||
m.top.channelHandle = content.channelHandle
|
||||
m.top.thumbnail = content.thumbnail
|
||||
end function
|
||||
@@ -3,7 +3,7 @@
|
||||
<field id="type" type="string" value="channel" />
|
||||
<field id="_author" type="string" alias="authorLabel.text" />
|
||||
<field id="subCountText" type="string" alias="subCountLabel.text" />
|
||||
<field id="videoCountText" type="string" alias="videoCountLabel.text" />
|
||||
<field id="channelHandle" type="string" alias="handleLabel.text" />
|
||||
<field id="thumbnail" type="uri" alias="thumbnail.uri" />
|
||||
<field id="itemContent" type="node" onChange="OnContentSet" />
|
||||
</interface>
|
||||
@@ -29,7 +29,7 @@
|
||||
height="25"
|
||||
font="font:SmallestSystemFont" />
|
||||
<Label
|
||||
id="videoCountLabel"
|
||||
id="handleLabel"
|
||||
width="196"
|
||||
height="25"
|
||||
font="font:SmallestSystemFont" />
|
||||
|
||||
@@ -17,6 +17,8 @@ function FindChildren()
|
||||
m.thumbnail = m.top.FindNode("thumbnail")
|
||||
end function
|
||||
|
||||
' TODO:P1 premeres in x hours is not displayed correctly, and ends up failing with an error
|
||||
' Need to try not a live event, but a video
|
||||
function OnContentSet() as void
|
||||
content = m.top.itemContent
|
||||
|
||||
@@ -31,14 +33,16 @@ function OnContentSet() as void
|
||||
m.titleLabel.text = content.title
|
||||
m.authorLabel.text = content.author
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(content.publishedText)
|
||||
if content.isUpcoming = true
|
||||
m.viewCountDateLabel.text = content.premiereTimestampText
|
||||
else if not StringUtils.IsNullOrEmpty(content.publishedText)
|
||||
label = content.publishedText
|
||||
if not StringUtils.IsNullOrEmpty(content.viewCountText)
|
||||
label = `${label} • ${content.viewCountText}`
|
||||
end if
|
||||
m.viewCountDateLabel.text = label
|
||||
else if content.isUpcoming = true
|
||||
m.viewCountDateLabel.text = content.premiereTimestampText
|
||||
else
|
||||
m.viewCountDateLabel.text = ""
|
||||
end if
|
||||
|
||||
m.thumbnail.uri = content.thumbnail
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import "pkg:/components/ChannelView/ChannelUtils.bs"
|
||||
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Navigation/LongPress.bs"
|
||||
import "pkg:/components/PlaylistView/PlaylistUtils.bs"
|
||||
import "pkg:/components/VideoFeed/VideoRowListContentTask.bs"
|
||||
import "pkg:/components/VideoFeed/VideoRowListRowContentTask.bs"
|
||||
@@ -18,11 +20,11 @@ end function
|
||||
function OnNodeReady()
|
||||
m.top.ObserveField("itemFocused", FuncName(OnItemFocused))
|
||||
m.top.ObserveField("rowItemFocused", FuncName(OnRowItemFocused))
|
||||
m.top.ObserveField("rowItemSelected", FuncName(OnRowItemSelected))
|
||||
m.top.observeField("focusedChild", FuncName(OnFocusedChildChange))
|
||||
m.top.ObserveField("visible", FuncName(OnVisibilityChange))
|
||||
|
||||
m.invidious.ObserveFieldScoped("authToken", FuncName(OnAuthTokenChange))
|
||||
InitializeLongPressTimer()
|
||||
end function
|
||||
|
||||
function OnFocusedChildChange() as void
|
||||
@@ -37,7 +39,7 @@ function OnVisibilityChange()
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnContentData() as void
|
||||
function OnFeedsChange() as void
|
||||
InitContent()
|
||||
end function
|
||||
|
||||
@@ -47,6 +49,11 @@ end function
|
||||
|
||||
function OnRowItemFocused(event as object) as void
|
||||
index = event.GetData()
|
||||
if index = invalid or index.count() <> 2
|
||||
LogWarn("Invalid index:", index)
|
||||
return
|
||||
end if
|
||||
|
||||
rowIndex = index[0]
|
||||
rowItemIndex = index[1]
|
||||
|
||||
@@ -60,12 +67,30 @@ function OnRowItemFocused(event as object) as void
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnRowItemSelected(event as object)
|
||||
index = event.GetData()
|
||||
function OnRowItemSelected(index as object) as void
|
||||
content = m.top.content
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
if index = invalid or index.count() <> 2
|
||||
LogWarn("Invalid index:", index)
|
||||
return
|
||||
end if
|
||||
|
||||
rowIndex = index[0]
|
||||
rowItemIndex = index[1]
|
||||
|
||||
row = m.top.content.GetChild(rowIndex)
|
||||
if rowIndex < 0 or rowIndex >= content.GetChildCount()
|
||||
LogWarn("Invalid row index:", rowIndex)
|
||||
return
|
||||
end if
|
||||
row = content.GetChild(rowIndex)
|
||||
|
||||
if rowItemIndex < 0 or rowItemIndex >= row.GetChildCount()
|
||||
LogWarn("Invalid row item index:", rowItemIndex)
|
||||
return
|
||||
end if
|
||||
rowItem = row.GetChild(rowItemIndex)
|
||||
|
||||
if rowItem.type = "video"
|
||||
@@ -75,11 +100,11 @@ function OnRowItemSelected(event as object)
|
||||
else if rowItem.type = "playlist"
|
||||
playlistId = rowItem.playlistId
|
||||
LogInfo("Open playlist: " + playlistId)
|
||||
PlaylistUtils.Open(rowItem)
|
||||
OpenPlaylist(rowItem)
|
||||
else if rowItem.type = "channel"
|
||||
authorId = rowItem.authorId
|
||||
LogInfo("Open channel: " + authorId)
|
||||
ChannelUtils.Open(rowItem)
|
||||
OpenChannel(rowItem)
|
||||
else if rowItem.type = "action"
|
||||
if rowItem.action = "LoginDialog"
|
||||
dialog = CreateObject("roSGNode", "LoginDialog")
|
||||
@@ -89,6 +114,82 @@ function OnRowItemSelected(event as object)
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnRowItemLongPressed(index as object) as void
|
||||
content = m.top.content
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
rowIndex = index[0]
|
||||
rowItemIndex = index[1]
|
||||
|
||||
if rowIndex < 0 or rowIndex >= content.GetChildCount()
|
||||
LogWarn("Invalid row index:", rowIndex)
|
||||
return
|
||||
end if
|
||||
row = content.GetChild(rowIndex)
|
||||
|
||||
if rowItemIndex < 0 or rowItemIndex >= row.GetChildCount()
|
||||
LogWarn("Invalid row item index:", rowItemIndex)
|
||||
return
|
||||
end if
|
||||
rowItem = row.GetChild(rowItemIndex)
|
||||
|
||||
contextMenuProviders = [m.top, m.bookmarks, m.top.screen]
|
||||
ContextMenuUtils.Open(contextMenuProviders, m.appController, rowItem)
|
||||
end function
|
||||
|
||||
function GetContextMenuOptionsForItem(rowItem as object) as object
|
||||
options = []
|
||||
|
||||
playAction = ContextMenuUtils.CreateOption("Play", m.playQueue, "Play", [rowItem, -1])
|
||||
queueAction = ContextMenuUtils.CreateOption("Queue", m.playQueue, "AddToQueue", [rowItem])
|
||||
|
||||
if rowItem.type = "video"
|
||||
options.push(playAction)
|
||||
options.push(queueAction)
|
||||
|
||||
item = ContextMenuUtils.CreateOption("Open channel", m.top, "OpenVideoChannel", [rowItem])
|
||||
options.push(item)
|
||||
else if rowItem.type = "playlist"
|
||||
options.push(playAction)
|
||||
options.push(queueAction)
|
||||
|
||||
item = ContextMenuUtils.CreateOption("Open", m.top, "OpenPlaylist", [rowItem])
|
||||
options.push(item)
|
||||
else if rowItem.type = "channel"
|
||||
item = ContextMenuUtils.CreateOption("Open", m.top, "OpenChannel", [rowItem])
|
||||
options.push(item)
|
||||
else
|
||||
LogWarn("Unknown long pressed item type:", rowItem.type)
|
||||
return []
|
||||
end if
|
||||
|
||||
return options
|
||||
end function
|
||||
|
||||
function OpenPlaylist(playlist as object)
|
||||
PlaylistUtils.Open(playlist)
|
||||
end function
|
||||
|
||||
function OpenChannel(channel as object)
|
||||
ChannelUtils.Open(channel)
|
||||
end function
|
||||
|
||||
function OpenVideoChannel(video as object) as void
|
||||
authorId = video.authorId
|
||||
if StringUtils.IsNullOrEmpty(authorId)
|
||||
LogWarn("Invalid authorId:", authorId)
|
||||
return
|
||||
end if
|
||||
channel = InvidiousContent.ToChannelContentNode(invalid, { authorId: authorId }, invalid)
|
||||
ChannelUtils.Open(channel)
|
||||
end function
|
||||
|
||||
function Refresh(unsued as dynamic)
|
||||
InitContent()
|
||||
end function
|
||||
|
||||
function OnAuthTokenChange()
|
||||
' TODO:P2: Reload only content that is authenticated
|
||||
' Should not reload if the page is not visible. Instead, capture state and reload when the page becomes visible
|
||||
@@ -99,14 +200,14 @@ function InitContent() as void
|
||||
CancelCurrentTasks()
|
||||
m.top.someContentReady = false
|
||||
|
||||
if m.top.contentData = invalid
|
||||
if m.top.feeds = invalid
|
||||
m.top.content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
task = StartAsyncTask(VideoRowListContentTask, {
|
||||
node: m.top,
|
||||
contentData: m.top.contentData
|
||||
feeds: m.top.feeds
|
||||
}, OnVideoRowListContentTaskResult)
|
||||
m.pendingLoadTasks[task.id] = task
|
||||
end function
|
||||
@@ -178,8 +279,8 @@ function LoadRowContent(contentNode as object)
|
||||
|
||||
contentNode.loadState = FeedLoadState.Loading
|
||||
task = StartAsyncTask(VideoRowListRowContentTask, {
|
||||
node: m.top,
|
||||
contentNode: contentNode,
|
||||
rowList: m.top,
|
||||
feedContentNode: contentNode,
|
||||
invidious: m.invidious
|
||||
}, OnVideoRowListRowContentTaskResult)
|
||||
m.pendingLoadTasks[task.id] = task
|
||||
@@ -191,19 +292,22 @@ function OnVideoRowListRowContentTaskResult(output as object) as void
|
||||
return
|
||||
end if
|
||||
|
||||
if not output.success or not output.result.success
|
||||
' output.error for unhandled exception
|
||||
error = output.error
|
||||
if error = invalid
|
||||
' output.result.error for network errors
|
||||
error = output.result.error
|
||||
end if
|
||||
error = ErrorUtils.Format(error)
|
||||
LogError(error)
|
||||
m.top.onError = error
|
||||
message = `Failed to load feed\n${error}`
|
||||
DialogUtils.ShowDialog(message, "Feed load fail", true)
|
||||
end if
|
||||
|
||||
LoadRowsIfNeeded()
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
if LongPressHandler(key, press)
|
||||
return true
|
||||
end if
|
||||
|
||||
if key = LONG_PRESS_KEY and press
|
||||
OnRowItemLongPressed(m.top.rowItemFocused)
|
||||
return true
|
||||
end if
|
||||
|
||||
if key = "OK" and not press
|
||||
OnRowItemSelected(m.top.rowItemFocused)
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
@@ -1,10 +1,16 @@
|
||||
<component name="VideoRowList" extends="RowList" includes="AutoBind">
|
||||
<component name="VideoRowList" extends="RowList" includes="AutoBind,ContextMenuProvider">
|
||||
<interface>
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
<field id="invidious" type="node" bind="/Invidious" />
|
||||
<field id="playQueue" type="node" bind="/PlayQueue" />
|
||||
<field id="contentData" type="array" onChange="OnContentData" />
|
||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
||||
<field id="screen" type="node" />
|
||||
<field id="feeds" type="array" onChange="OnFeedsChange" />
|
||||
<field id="someContentReady" type="bool" />
|
||||
<field id="onError" type="string" alwaysNotify="true" />
|
||||
<function name="OpenPlaylist" />
|
||||
<function name="OpenChannel" />
|
||||
<function name="OpenVideoChannel" />
|
||||
<function name="Refresh" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -1,17 +1,25 @@
|
||||
import "FeedLoadState.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
@asynctask
|
||||
function VideoRowListContentTask(input as object)
|
||||
contentData = input.contentData
|
||||
feeds = input.feeds
|
||||
rowList = input.node
|
||||
|
||||
contentNode = CreateObject("roSGNode", "ContentNode")
|
||||
|
||||
for each feed in contentData
|
||||
for each feed in feeds
|
||||
feedContentNode = CreateObject("roSGNode", "FeedContentNode")
|
||||
feedContentNode.feed = feed
|
||||
feedContentNode.loadState = FeedLoadState.None
|
||||
feedContentNode.title = feed.title
|
||||
feedContentNode.feedSourcesIndex = 0
|
||||
feedContentNode.loadState = FeedLoadState.None
|
||||
feedSources = feed.feedSources
|
||||
for i = 0 to feedSources.count() - 1
|
||||
feedSources[i].state = {
|
||||
loadState: FeedLoadState.None
|
||||
}
|
||||
end for
|
||||
feedContentNode.feedSources = feedSources
|
||||
|
||||
for i = 1 to 4
|
||||
feedContentNode.createChild("LoadingContentNode")
|
||||
|
||||
@@ -1,93 +1,156 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||
|
||||
@asynctask
|
||||
function VideoRowListRowContentTask(input as object) as object
|
||||
rowList = input.node
|
||||
contentNode = input.contentNode
|
||||
invidiousNode = input.invidious
|
||||
try
|
||||
rowList = input.rowList
|
||||
feedContentNode = input.feedContentNode
|
||||
invidiousNode = input.invidious
|
||||
|
||||
if m.top.cancel
|
||||
contentNode.loadState = FeedLoadState.None
|
||||
return invalid
|
||||
end if
|
||||
service = new Invidious.InvidiousService(invidiousNode)
|
||||
instance = service.GetInstance()
|
||||
|
||||
service = new Invidious.InvidiousService(invidiousNode)
|
||||
totalfetchedItems = 0
|
||||
|
||||
service.MarkFeedPagination(contentNode)
|
||||
response = service.MakeRequest(contentNode.feed, m.top.cancellation)
|
||||
while true
|
||||
if m.top.cancel
|
||||
feedContentNode.loadState = FeedLoadState.None
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if m.top.cancel
|
||||
contentNode.loadState = FeedLoadState.None
|
||||
return invalid
|
||||
end if
|
||||
feedSources = feedContentNode.feedSources
|
||||
feedSourcesIndex = feedContentNode.feedSourcesIndex
|
||||
|
||||
if not response.success
|
||||
if response.error = Invidious.ERROR_NOT_AUTHENTICATED
|
||||
RemovePlaceHolderItems(contentNode)
|
||||
actionNode = CreateObject("roSGNode", "ActionContentNode")
|
||||
actionNode.title = `Login to view ${contentNode.title}`
|
||||
actionNode.action = "LoginDialog"
|
||||
if feedSourcesIndex >= feedSources.Count()
|
||||
feedContentNode.loadState = FeedLoadState.Loaded
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
end if
|
||||
|
||||
contentNode.appendChild(actionNode)
|
||||
contentNode.loadState = FeedLoadState.Loaded
|
||||
feedSource = feedSources[feedSourcesIndex]
|
||||
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
end if
|
||||
if feedSource.state.loadState = FeedLoadState.Loaded or feedSource.state.loadState = FeedLoadState.Error
|
||||
feedSourcesIndex += 1
|
||||
if feedSourcesIndex >= feedSources.Count()
|
||||
feedContentNode.loadState = FeedLoadState.Loaded
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
end if
|
||||
feedContentNode.feedSourcesIndex = feedSourcesIndex
|
||||
continue while
|
||||
end if
|
||||
|
||||
' Invidious returns 500 and "{"error":"Closed stream"}" when the Popular feed is disabled
|
||||
' TODO:P2 check the endpoint.name instead of contentNode.title to avoid conflict with other feeds
|
||||
if contentNode.title = "Popular" and response.error.instr("Closed stream") > 0
|
||||
LogWarn("Deleting feed", contentNode.title, "-", response.error)
|
||||
parent = contentNode.getParent()
|
||||
parent.removeChild(contentNode)
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
end if
|
||||
feedSource = service.MarkFeedPagination(feedContentNode)
|
||||
|
||||
contentNode.loadState = FeedLoadState.Error
|
||||
contentNode.title += " (Failed to load)"
|
||||
return response
|
||||
end if
|
||||
response = service.MakeRequest(feedSource, feedSource.state.queryParams, m.top.cancellation)
|
||||
|
||||
instance = service.GetInstance()
|
||||
itemNodes = []
|
||||
for each item in response.result.items
|
||||
itemNode = InvidiousContent.ToRowCellContentNode(item, instance)
|
||||
if itemNode <> invalid
|
||||
itemNodes.Push(itemNode)
|
||||
end if
|
||||
end for
|
||||
if not response.success
|
||||
if response.error = Invidious.ERROR_NOT_AUTHENTICATED
|
||||
RemovePlaceHolderItems(feedContentNode)
|
||||
actionNode = CreateObject("roSGNode", "ActionContentNode")
|
||||
actionNode.title = `Login to view ${feedSource.title}`
|
||||
actionNode.action = "LoginDialog"
|
||||
|
||||
RemovePlaceHolderItems(contentNode)
|
||||
contentNode.appendChildren(itemNodes)
|
||||
feedSource.state.loadState = FeedLoadState.Loaded
|
||||
feedSources[feedSourcesIndex] = feedSource
|
||||
feedContentNode.feedSources = feedSources
|
||||
|
||||
hasContinuation = not StringUtils.IsNullOrEmpty(response.result.continuation)
|
||||
if hasContinuation
|
||||
contentNode.continuation = response.result.continuation
|
||||
end if
|
||||
feedContentNode.appendChild(actionNode)
|
||||
feedContentNode.loadState = FeedLoadState.Loaded
|
||||
|
||||
if response.result.items.Count() > 0
|
||||
pageType = contentNode.paginationType
|
||||
if pageType = PaginationType.Continuation and hasContinuation
|
||||
contentNode.loadState = FeedLoadState.LoadedPage
|
||||
else if pageType = PaginationType.Pages
|
||||
contentNode.loadState = FeedLoadState.LoadedPage
|
||||
else
|
||||
contentNode.loadState = FeedLoadState.Loaded
|
||||
end if
|
||||
else
|
||||
contentNode.loadState = FeedLoadState.Loaded
|
||||
end if
|
||||
continue while
|
||||
end if
|
||||
|
||||
if itemNodes.Count() > 0
|
||||
rowList.someContentReady = true
|
||||
end if
|
||||
' Invidious returns 500 and "{"error":"Closed stream"}" when the Popular feed is disabled
|
||||
if feedSource.endpoint = "popular" and response.error.instr("Closed stream") > -1
|
||||
LogWarn("Popular feedSource not available:", response.error)
|
||||
if feedSources.Count() = 1
|
||||
parent = feedContentNode.getParent()
|
||||
parent.removeChild(feedContentNode)
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
end if
|
||||
|
||||
return response
|
||||
continue while
|
||||
end if
|
||||
|
||||
feedSource.state.loadState = FeedLoadState.Error
|
||||
feedSources[feedSourcesIndex] = feedSource
|
||||
feedContentNode.feedSources = feedSources
|
||||
|
||||
if feedContentNode.title.instr(" (Failed to load)") = -1
|
||||
feedContentNode.title += " (Failed to load)"
|
||||
end if
|
||||
|
||||
HandleFeedLoadErrorDialog(response.error, rowList)
|
||||
continue while
|
||||
end if
|
||||
|
||||
itemNodes = []
|
||||
for each item in response.result.items
|
||||
itemNode = InvidiousContent.ToRowCellContentNode(item, instance)
|
||||
if itemNode <> invalid
|
||||
itemNode.feedSourcesIndex = feedSourcesIndex
|
||||
itemNodes.Push(itemNode)
|
||||
end if
|
||||
end for
|
||||
|
||||
RemovePlaceHolderItems(feedContentNode)
|
||||
feedContentNode.appendChildren(itemNodes)
|
||||
|
||||
hasContinuation = not StringUtils.IsNullOrEmpty(response.result.continuation)
|
||||
if hasContinuation
|
||||
feedSource.state.continuation = response.result.continuation
|
||||
end if
|
||||
|
||||
if response.result.items.Count() > 0
|
||||
pageType = feedSource.state.paginationType
|
||||
if pageType = PaginationType.Continuation and hasContinuation
|
||||
feedSource.state.loadState = FeedLoadState.LoadedPage
|
||||
else if pageType = PaginationType.Pages
|
||||
feedSource.state.loadState = FeedLoadState.LoadedPage
|
||||
else
|
||||
feedSource.state.loadState = FeedLoadState.Loaded
|
||||
end if
|
||||
else
|
||||
feedSource.state.loadState = FeedLoadState.Loaded
|
||||
end if
|
||||
|
||||
feedSources[feedSourcesIndex] = feedSource
|
||||
feedContentNode.feedSources = feedSources
|
||||
|
||||
if feedSource.state.loadState = FeedLoadState.Loaded and feedSourcesIndex = feedSources.Count() - 1
|
||||
feedContentNode.loadState = FeedLoadState.Loaded
|
||||
else
|
||||
feedContentNode.loadState = FeedLoadState.LoadedPage
|
||||
end if
|
||||
|
||||
if itemNodes.Count() > 0
|
||||
rowList.someContentReady = true
|
||||
end if
|
||||
|
||||
totalfetchedItems += response.result.items.Count()
|
||||
if totalfetchedItems > 3
|
||||
exit while
|
||||
end if
|
||||
end while
|
||||
|
||||
catch error
|
||||
HandleFeedLoadErrorDialog(error, rowList)
|
||||
return {
|
||||
success: false,
|
||||
error: error
|
||||
}
|
||||
end try
|
||||
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
end function
|
||||
|
||||
function RemovePlaceHolderItems(contentNode as object)
|
||||
@@ -101,3 +164,10 @@ function RemovePlaceHolderItems(contentNode as object)
|
||||
end if
|
||||
end while
|
||||
end function
|
||||
|
||||
function HandleFeedLoadErrorDialog(error as object, rowList as object)
|
||||
error = ErrorUtils.Format(error)
|
||||
LogError(error)
|
||||
rowList.onError = error
|
||||
DialogUtils.ShowDialog(error, "Failed to load feed", true)
|
||||
end function
|
||||
@@ -5,6 +5,7 @@ function VideoContentTask(input as object) as object
|
||||
contentNode = input.content
|
||||
invidiousNode = input.invidious
|
||||
preferencesNode = input.preferences
|
||||
playletServerUrl = input.playletServerUrl
|
||||
|
||||
if m.top.cancel
|
||||
return invalid
|
||||
@@ -34,7 +35,7 @@ function VideoContentTask(input as object) as object
|
||||
contentNode.title = metadata.title
|
||||
contentNode.secondaryTitle = metadata.author
|
||||
|
||||
streamUrls = CreateStreamUrls(metadata, service, preferencesNode)
|
||||
streamUrls = CreateStreamUrls(metadata, service, preferencesNode, playletServerUrl)
|
||||
contentNode.url = streamUrls[0]
|
||||
|
||||
SetCaptions(metadata, service, contentNode)
|
||||
@@ -51,7 +52,7 @@ function VideoContentTask(input as object) as object
|
||||
}
|
||||
end function
|
||||
|
||||
function CreateStreamUrls(metadata as object, service as Invidious.InvidiousService, preferences as object) as object
|
||||
function CreateStreamUrls(metadata as object, service as Invidious.InvidiousService, preferences as object, playletServerUrl as string) as object
|
||||
instance = service.GetInstance()
|
||||
proxyVideos = preferences["invidious.proxy_videos"]
|
||||
|
||||
@@ -64,9 +65,9 @@ function CreateStreamUrls(metadata as object, service as Invidious.InvidiousServ
|
||||
|
||||
if preferredQuality = "720p"
|
||||
AddStreamUrls(streamUrls, metadata, service, proxyVideos)
|
||||
AddDashUrls(streamUrls, metadata, proxyVideos)
|
||||
AddDashUrls(streamUrls, metadata, proxyVideos, playletServerUrl)
|
||||
else
|
||||
AddDashUrls(streamUrls, metadata, proxyVideos)
|
||||
AddDashUrls(streamUrls, metadata, proxyVideos, playletServerUrl)
|
||||
AddStreamUrls(streamUrls, metadata, service, proxyVideos)
|
||||
end if
|
||||
end if
|
||||
@@ -83,14 +84,20 @@ function AddHlsUrls(streamUrls as object, metadata as object, proxyVideos as str
|
||||
AddUrls(streamUrls, hlsUrl, hlsUrlLocal, proxyVideos)
|
||||
end function
|
||||
|
||||
function AddDashUrls(streamUrls as object, metadata as object, proxyVideos as string) as void
|
||||
if metadata.dashUrl = invalid
|
||||
return
|
||||
end if
|
||||
function AddDashUrls(streamUrls as object, metadata as object, proxyVideos as string, playletServerUrl as string) as void
|
||||
#if LOCAL_DASH
|
||||
' Redirect to Playet's local web server, where will will be
|
||||
' dynamically generating the DASH manifest.
|
||||
dashUrl = `${playletServerUrl}/api/dash?v=${metadata.videoId}`
|
||||
#else
|
||||
if metadata.dashUrl = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
dashUrl = metadata.dashUrl
|
||||
#end if
|
||||
|
||||
dashUrl = metadata.dashUrl
|
||||
dashUrlLocal = AddLocalFlag(dashUrl)
|
||||
|
||||
AddUrls(streamUrls, dashUrl, dashUrlLocal, proxyVideos)
|
||||
end function
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ function StartVideoContentTask(videoContentNode as object)
|
||||
m.videoContentTask = StartAsyncTask(VideoContentTask, {
|
||||
content: videoContentNode,
|
||||
invidious: m.top.invidious,
|
||||
preferences: m.top.preferences
|
||||
preferences: m.top.preferences,
|
||||
playletServerUrl: m.top.webServer@.GetServerAddress(invalid)
|
||||
}, OnVideoContentTaskResults)
|
||||
end function
|
||||
|
||||
@@ -140,37 +141,37 @@ end function
|
||||
|
||||
function OnVideoPlayerStateChange() as void
|
||||
state = m.top.state
|
||||
|
||||
content = m.top.content
|
||||
' If we successfully played the video, then any error that comes later is not due to a 403 (FORBIDDEN).
|
||||
' This is to reduce false positives, as we do not want retry another link if the first link is working fine.
|
||||
if state = "playing" and not m.videoPlayingSuccess
|
||||
LogInfo(`Now playing video ${m.top.content.url}`)
|
||||
LogInfo(`Now playing video ${content.url}`)
|
||||
m.videoPlayingSuccess = true
|
||||
end if
|
||||
|
||||
if state = "error"
|
||||
errorInfo = m.top.errorInfo
|
||||
LogError(`Error playing video ${m.top.content.videoId}`, errorInfo)
|
||||
LogError(`Error playing video ${content.videoId}`, errorInfo)
|
||||
if m.videoPlayingSuccess <> true
|
||||
' http for stream format, mediaerror for DASH
|
||||
if errorInfo.category = "http" or errorInfo.category = "mediaerror"
|
||||
currentUrl = m.top.content.url
|
||||
playletStreamUrls = m.top.content.playletStreamUrls
|
||||
playletStreamUrlIndex = m.top.content.playletStreamUrlIndex
|
||||
currentUrl = content.url
|
||||
playletStreamUrls = content.playletStreamUrls
|
||||
playletStreamUrlIndex = content.playletStreamUrlIndex
|
||||
playletStreamUrlIndex++
|
||||
m.top.content.playletStreamUrlIndex = playletStreamUrlIndex
|
||||
content.playletStreamUrlIndex = playletStreamUrlIndex
|
||||
if playletStreamUrlIndex < playletStreamUrls.Count()
|
||||
nextUrl = playletStreamUrls[playletStreamUrlIndex]
|
||||
LogError(`Stream ${currentUrl} failed to play. Trying next stream ${nextUrl}`)
|
||||
|
||||
m.top.content.url = nextUrl
|
||||
content.url = nextUrl
|
||||
' This video errored, and is about to finish, so don't close the video yet
|
||||
' That's why we should ignore the next "finished" event
|
||||
m.ignoreNextFinishedState = true
|
||||
m.top.control = "play"
|
||||
|
||||
if ValidInt(m.top.content.timestamp) > 0
|
||||
m.top.seek = m.top.content.timestamp
|
||||
if ValidInt(content.timestamp) > 0
|
||||
m.top.seek = content.timestamp
|
||||
end if
|
||||
return
|
||||
end if
|
||||
@@ -184,7 +185,7 @@ function OnVideoPlayerStateChange() as void
|
||||
end if
|
||||
|
||||
if state = "finished"
|
||||
metadata = m.top.content?.metadata
|
||||
metadata = content?.metadata
|
||||
if not PlayNext(metadata?.recommendedVideos)
|
||||
m.container@.watchedVideosClear(invalid)
|
||||
VideoUtils.CloseVideo()
|
||||
@@ -204,7 +205,7 @@ function OnVideoPlayerStateChange() as void
|
||||
end for
|
||||
end if
|
||||
|
||||
title = `Error playing video ${m.top.content.videoId}`
|
||||
title = `Error playing video ${content.videoId}`
|
||||
LogError(title, messageLines)
|
||||
DialogUtils.ShowDialog(messageLines, title, true)
|
||||
' TODO:P1 play next video in the queue after showing the error dialog
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<field id="playQueue" type="node" bind="../../PlayQueue" />
|
||||
<field id="preferences" type="node" bind="../../Preferences" />
|
||||
<field id="invidious" type="node" bind="../../Invidious" />
|
||||
<field id="webServer" type="node" bind="../../WebServer" />
|
||||
<field id="minRect" type="rect2D" value="[834,460,426,240]" />
|
||||
<field id="maxRect" type="rect2D" value="[0,0,1280,720]" />
|
||||
<field id="chapter" type="string" alias="chapterLabel.text" />
|
||||
|
||||
@@ -58,6 +58,14 @@ namespace VideoUtils
|
||||
return m.top.getScene().findNode("VideoContainer")
|
||||
end function
|
||||
|
||||
function IsVideoPlayerFullScreen() as boolean
|
||||
videoContainer = GetVideoContainer()
|
||||
if videoContainer = invalid
|
||||
return false
|
||||
end if
|
||||
return videoContainer.fullscreen
|
||||
end function
|
||||
|
||||
function ToggleVideoPictureInPicture() as boolean
|
||||
videoPlayer = GetVideoPlayer()
|
||||
if videoPlayer = invalid
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import "pkg:/source/utils/RegistryUtils.bs"
|
||||
|
||||
namespace Http
|
||||
|
||||
class BookmarksRouter extends HttpRouter
|
||||
|
||||
function new()
|
||||
super()
|
||||
|
||||
m.Get("/api/bookmarks", function(context as object) as boolean
|
||||
response = context.response
|
||||
|
||||
bookmarksString = RegistryUtils.Read(RegistryUtils.BOOKMARKS)
|
||||
if bookmarksString = invalid
|
||||
response.Json({
|
||||
groups: []
|
||||
})
|
||||
return true
|
||||
end if
|
||||
|
||||
response.SetBodyDataString(bookmarksString)
|
||||
response.ContentType("application/json")
|
||||
response.http_code = 200
|
||||
|
||||
return true
|
||||
end function)
|
||||
|
||||
m.Get("/api/bookmarks/feeds", function(context as object) as boolean
|
||||
response = context.response
|
||||
router = context.router
|
||||
bookmarks = context.server.task.bookmarks
|
||||
|
||||
feeds = router.BookmarksContentToFeeds(bookmarks.content)
|
||||
|
||||
response.Json(feeds)
|
||||
|
||||
return true
|
||||
end function)
|
||||
end function
|
||||
|
||||
' TODO:P1 refactor to share code with Bookmarks screen
|
||||
function BookmarksContentToFeeds(bookmarksContent as object) as object
|
||||
bookmarkGroupNodes = bookmarksContent.getChildren(-1, 0)
|
||||
|
||||
feeds = []
|
||||
for each bookmarkGroupNode in bookmarkGroupNodes
|
||||
bookmarkNodes = bookmarkGroupNode.getChildren(-1, 0)
|
||||
|
||||
feedSources = []
|
||||
for each bookmarkNode in bookmarkNodes
|
||||
feedSources.push(bookmarkNode.feedSource)
|
||||
end for
|
||||
|
||||
feeds.push({
|
||||
"title": bookmarkGroupNode.title,
|
||||
"feedSources": feedSources
|
||||
})
|
||||
end for
|
||||
|
||||
return feeds
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -0,0 +1,49 @@
|
||||
import "pkg:/components/Services/Dash/DashManifest.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace Http
|
||||
|
||||
class DashRouter extends HttpRouter
|
||||
|
||||
function new()
|
||||
super()
|
||||
|
||||
m.Get("/api/dash", function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
task = context.server.task
|
||||
invidiousNode = task.invidious
|
||||
|
||||
v = request.query.v
|
||||
local = request.query.local
|
||||
|
||||
if StringUtils.IsNullOrEmpty(v)
|
||||
response.Default(400, "Missing video id")
|
||||
return true
|
||||
end if
|
||||
|
||||
service = new Invidious.InvidiousService(invidiousNode)
|
||||
metadataRequest = service.GetVideoMetadata(v)
|
||||
if not metadataRequest.IsSuccess()
|
||||
response.Default(metadataRequest.StatusCode(), metadataRequest.ErrorMessage())
|
||||
return true
|
||||
end if
|
||||
|
||||
metadata = metadataRequest.Json()
|
||||
instance = service.GetInstance()
|
||||
|
||||
dash = new DashManifest(instance)
|
||||
xmlContent = dash.fromVideoMetadata(metadata, ValidString(local) = "true")
|
||||
|
||||
response.http_code = 200
|
||||
response.SetBodyDataString(xmlContent)
|
||||
response.ContentType("application/dash+xml")
|
||||
|
||||
return true
|
||||
end function)
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -47,14 +47,15 @@ namespace Http
|
||||
|
||||
' This is an endpoint allowing the web app to make an authenticated request
|
||||
' without needing the Invidious token
|
||||
' This is a GET not a POST for better caching
|
||||
m.Get("/invidious/authenticated-request", function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
invidiousNode = context.server.task.invidious
|
||||
|
||||
requestData = request.query["request-data"]
|
||||
if requestData = invalid
|
||||
response.Default(400, "Expected request-data")
|
||||
feedSource = request.query["feed-source"]
|
||||
if feedSource = invalid
|
||||
response.Default(400, "Expected feed-source")
|
||||
return true
|
||||
end if
|
||||
|
||||
@@ -64,12 +65,10 @@ namespace Http
|
||||
return true
|
||||
end if
|
||||
|
||||
requestData = ParseJson(requestData)
|
||||
feedSource = ParseJson(feedSource)
|
||||
|
||||
' TODO:P1 handle pagination
|
||||
' Perhaps the page arg can be added to queryParam of requestData directly
|
||||
invService = new Invidious.InvidiousService(invidiousNode)
|
||||
invResponse = invService.MakeRequest(requestData)
|
||||
invResponse = invService.MakeRequest(feedSource, feedSource.state?.queryParams)
|
||||
if not invResponse.success
|
||||
response.Default(500, `Failed to make request: ${invResponse.error}`)
|
||||
return true
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import "pkg:/components/ChannelView/ChannelUtils.bs"
|
||||
import "pkg:/components/PlaylistView/PlaylistUtils.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||
|
||||
namespace Http
|
||||
|
||||
class ViewRouter extends HttpRouter
|
||||
|
||||
function new()
|
||||
super()
|
||||
|
||||
m.Get("/api/view/open", function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
appController = context.server.task.appController
|
||||
|
||||
playlistId = request.query.playlistId
|
||||
authorId = request.query.authorId
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(playlistId)
|
||||
contentNode = InvidiousContent.ToPlaylistContentNode(invalid, { playlistId: playlistId }, invalid)
|
||||
PlaylistUtils.Open(contentNode, appController)
|
||||
if VideoUtils.IsVideoPlayerOpen() and VideoUtils.IsVideoPlayerFullScreen()
|
||||
VideoUtils.ToggleVideoPictureInPicture()
|
||||
end if
|
||||
response.Default(204, "OK")
|
||||
else if not StringUtils.IsNullOrEmpty(authorId)
|
||||
contentNode = InvidiousContent.ToChannelContentNode(invalid, { authorId: authorId }, invalid)
|
||||
ChannelUtils.Open(contentNode, appController)
|
||||
if VideoUtils.IsVideoPlayerOpen() and VideoUtils.IsVideoPlayerFullScreen()
|
||||
VideoUtils.ToggleVideoPictureInPicture()
|
||||
end if
|
||||
response.Default(204, "OK")
|
||||
else
|
||||
response.Default(400, "Invalid request")
|
||||
end if
|
||||
|
||||
return true
|
||||
end function)
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -1,9 +1,12 @@
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/BookmarksRouter.bs"
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/DashRouter.bs"
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/InvidiousRouter.bs"
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayletLibUrlsRouter.bs"
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayQueueRouter.bs"
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/PreferencesRouter.bs"
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/SearchHistoryRouter.bs"
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/StateApiRouter.bs"
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/ViewRouter.bs"
|
||||
import "pkg:/components/Web/WebServer/Middleware/CorsMiddleware.bs"
|
||||
import "pkg:/components/Web/WebServer/Middleware/EtagMiddleware.bs"
|
||||
import "pkg:/components/Web/WebServer/Middleware/HttpStaticFilesRouter.bs"
|
||||
@@ -33,9 +36,12 @@ function SetupRoutes(server as object)
|
||||
server.UseRouter(new Http.CorsMiddleware())
|
||||
server.UseRouter(homeRouter)
|
||||
server.UseRouter(new Http.StateApiRouter())
|
||||
server.UseRouter(new Http.DashRouter())
|
||||
server.UseRouter(new Http.PreferencesRouter())
|
||||
server.UseRouter(new Http.InvidiousRouter())
|
||||
server.UseRouter(new Http.PlayQueueRouter())
|
||||
server.UseRouter(new Http.BookmarksRouter())
|
||||
server.UseRouter(new Http.ViewRouter())
|
||||
server.UseRouter(new Http.SearchHistoryRouter())
|
||||
server.UseRouter(new Http.PlayletLibUrlsRouter())
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<component name="PlayletWebServer" extends="WebServer" includes="AutoBind">
|
||||
<interface>
|
||||
<field id="appController" type="node" />
|
||||
<field id="preferences" type="node" />
|
||||
<field id="invidious" type="node" />
|
||||
<field id="applicationInfo" type="node" />
|
||||
<field id="playQueue" type="node" />
|
||||
<field id="bookmarks" type="node" />
|
||||
<function name="GetServerAddress" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -0,0 +1,7 @@
|
||||
<component name="ContextMenuProvider" extends="Group">
|
||||
<interface>
|
||||
<field id="supportsContextMenu" type="boolean" value="true" />
|
||||
<!-- bs:disable-next-line 1067 -->
|
||||
<function name="GetContextMenuOptionsForItem" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -1,64 +0,0 @@
|
||||
[
|
||||
{
|
||||
title: "Subscriptions",
|
||||
apiType: "Invidious",
|
||||
endpoint: "auth_feed",
|
||||
},
|
||||
{
|
||||
title: "Trending",
|
||||
apiType: "Invidious",
|
||||
endpoint: "trending",
|
||||
},
|
||||
{
|
||||
title: "Trending - Music",
|
||||
apiType: "Invidious",
|
||||
endpoint: "trending",
|
||||
queryParams: {
|
||||
type: "Music",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Trending - Gaming",
|
||||
apiType: "Invidious",
|
||||
endpoint: "trending",
|
||||
queryParams: {
|
||||
type: "Gaming",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Trending - Movies",
|
||||
apiType: "Invidious",
|
||||
endpoint: "trending",
|
||||
queryParams: {
|
||||
type: "Movies",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Popular",
|
||||
apiType: "Invidious",
|
||||
endpoint: "popular",
|
||||
},
|
||||
{
|
||||
title: "Funny",
|
||||
apiType: "Invidious",
|
||||
endpoint: "search",
|
||||
queryParams: {
|
||||
q: "Funny",
|
||||
sort_by: "upload_date",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "News",
|
||||
apiType: "Invidious",
|
||||
endpoint: "search",
|
||||
queryParams: {
|
||||
q: "News",
|
||||
sort_by: "upload_date",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Playlists",
|
||||
apiType: "Invidious",
|
||||
endpoint: "playlists",
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,74 @@
|
||||
- title: Subscriptions
|
||||
feedSources:
|
||||
- id: inv_auth_feed
|
||||
title: Subscriptions
|
||||
apiType: Invidious
|
||||
endpoint: auth_feed
|
||||
|
||||
- title: Trending
|
||||
feedSources:
|
||||
- id: inv_trending
|
||||
title: Trending
|
||||
apiType: Invidious
|
||||
endpoint: trending
|
||||
|
||||
- title: Trending - Music
|
||||
feedSources:
|
||||
- id: inv_trending_music
|
||||
title: Trending - Music
|
||||
apiType: Invidious
|
||||
endpoint: trending
|
||||
queryParams:
|
||||
type: Music
|
||||
|
||||
- title: Trending - Gaming
|
||||
feedSources:
|
||||
- id: inv_trending_gaming
|
||||
title: Trending - Gaming
|
||||
apiType: Invidious
|
||||
endpoint: trending
|
||||
queryParams:
|
||||
type: Gaming
|
||||
|
||||
- title: Trending - Movies
|
||||
feedSources:
|
||||
- id: inv_trending_movies
|
||||
title: Trending - Movies
|
||||
apiType: Invidious
|
||||
endpoint: trending
|
||||
queryParams:
|
||||
type: Movies
|
||||
|
||||
- title: Popular
|
||||
feedSources:
|
||||
- id: inv_popular
|
||||
title: Popular
|
||||
apiType: Invidious
|
||||
endpoint: popular
|
||||
|
||||
- title: Funny
|
||||
feedSources:
|
||||
- id: inv_search_funny
|
||||
title: Search - Funny
|
||||
apiType: Invidious
|
||||
endpoint: search
|
||||
queryParams:
|
||||
q: Funny
|
||||
sort_by: upload_date
|
||||
|
||||
- title: News
|
||||
feedSources:
|
||||
- id: inv_search_news
|
||||
title: Search - News
|
||||
apiType: Invidious
|
||||
endpoint: search
|
||||
queryParams:
|
||||
q: News
|
||||
sort_by: upload_date
|
||||
|
||||
- title: Playlists
|
||||
feedSources:
|
||||
- id: inv_auth_playlists
|
||||
title: Playlists
|
||||
apiType: Invidious
|
||||
endpoint: auth_playlists
|
||||
@@ -1,195 +0,0 @@
|
||||
{
|
||||
endpoints: [
|
||||
{
|
||||
name: "trending",
|
||||
displayName: "Trending",
|
||||
url: "/api/v1/trending",
|
||||
queryParams: {
|
||||
type: {
|
||||
required: false,
|
||||
type: ["Music", "Gaming", "Movies"],
|
||||
},
|
||||
region: {
|
||||
required: false,
|
||||
type: "#ISO3166",
|
||||
default: "GetUserCountryCode",
|
||||
},
|
||||
fields: {
|
||||
required: false,
|
||||
type: [],
|
||||
arrayType: "comma-separated",
|
||||
default: [
|
||||
"title",
|
||||
"videoId",
|
||||
"videoThumbnails",
|
||||
"lengthSeconds",
|
||||
"viewCount",
|
||||
"author",
|
||||
"publishedText",
|
||||
"liveNow",
|
||||
"isUpcoming",
|
||||
"premiereTimestamp",
|
||||
],
|
||||
},
|
||||
},
|
||||
cacheSeconds: 21600, // 6 hours
|
||||
},
|
||||
{
|
||||
name: "popular",
|
||||
displayName: "Popular",
|
||||
url: "/api/v1/popular",
|
||||
queryParams: {
|
||||
fields: {
|
||||
required: false,
|
||||
type: [],
|
||||
arrayType: "comma-separated",
|
||||
default: [
|
||||
"title",
|
||||
"videoId",
|
||||
"videoThumbnails",
|
||||
"lengthSeconds",
|
||||
"viewCount",
|
||||
"author",
|
||||
"publishedText",
|
||||
"liveNow",
|
||||
"isUpcoming",
|
||||
"premiereTimestamp",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "search",
|
||||
displayName: "Search",
|
||||
url: "/api/v1/search",
|
||||
paginationType: "Pages",
|
||||
queryParams: {
|
||||
q: {
|
||||
required: true,
|
||||
type: "string",
|
||||
},
|
||||
sort_by: {
|
||||
required: false,
|
||||
type: ["relevance", "rating", "upload_date", "view_count"],
|
||||
},
|
||||
date: {
|
||||
required: false,
|
||||
type: ["hour", "today", "week", "month", "year"],
|
||||
},
|
||||
duration: {
|
||||
required: false,
|
||||
type: ["short", "long"],
|
||||
},
|
||||
type: {
|
||||
required: false,
|
||||
type: ["video", "playlist", "channel", "all"],
|
||||
arrayType: "comma-separated",
|
||||
default: ["video", "playlist", "channel"],
|
||||
},
|
||||
features: {
|
||||
required: false,
|
||||
type: [
|
||||
"hd",
|
||||
"subtitles",
|
||||
"creative_commons",
|
||||
"3d",
|
||||
"live",
|
||||
"purchased",
|
||||
"4k",
|
||||
"360",
|
||||
"location",
|
||||
"hdr",
|
||||
],
|
||||
},
|
||||
region: {
|
||||
required: false,
|
||||
type: "#ISO3166",
|
||||
default: "GetUserCountryCode",
|
||||
},
|
||||
},
|
||||
cacheSeconds: 900, // 15 minutes
|
||||
},
|
||||
{
|
||||
name: "auth_feed",
|
||||
displayName: "User Feed",
|
||||
url: "/api/v1/auth/feed",
|
||||
authenticated: true,
|
||||
responseHandler: "AuthFeedHandler",
|
||||
queryParams: {
|
||||
max_results: {
|
||||
required: false,
|
||||
type: "number",
|
||||
default: 20,
|
||||
},
|
||||
},
|
||||
paginationType: "Pages",
|
||||
},
|
||||
{
|
||||
name: "playlists",
|
||||
displayName: "Playlists",
|
||||
url: "/api/v1/auth/playlists",
|
||||
authenticated: true,
|
||||
},
|
||||
{
|
||||
name: "playlist",
|
||||
displayName: "Playlist",
|
||||
url: "/api/v1/playlists/{plid}",
|
||||
responseHandler: "PlaylistHandler",
|
||||
paginationType: "Pages",
|
||||
},
|
||||
{
|
||||
name: "channel_videos",
|
||||
displayName: "Channel videos",
|
||||
url: "/api/v1/channels/{ucid}/videos",
|
||||
responseHandler: "ChannelVideosHandler",
|
||||
paginationType: "Continuation",
|
||||
queryParams: {
|
||||
sort_by: {
|
||||
required: false,
|
||||
type: ["newest", "oldest", "popular"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "channel_playlists",
|
||||
displayName: "Channel playlists",
|
||||
url: "/api/v1/channels/{ucid}/playlists",
|
||||
responseHandler: "ChannelPlaylistsHandler",
|
||||
paginationType: "Continuation",
|
||||
queryParams: {
|
||||
sort_by: {
|
||||
required: false,
|
||||
type: ["newest", "oldest", "last"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "channel_shorts",
|
||||
displayName: "Channel shorts",
|
||||
url: "/api/v1/channels/{ucid}/shorts",
|
||||
responseHandler: "ChannelVideosHandler",
|
||||
paginationType: "Continuation",
|
||||
},
|
||||
{
|
||||
name: "channel_streams",
|
||||
displayName: "Channel livestreams",
|
||||
url: "/api/v1/channels/{ucid}/streams",
|
||||
responseHandler: "ChannelVideosHandler",
|
||||
paginationType: "Continuation",
|
||||
},
|
||||
{
|
||||
name: "channel_podcasts",
|
||||
displayName: "Channel podcasts",
|
||||
url: "/api/v1/channels/{ucid}/podcasts",
|
||||
responseHandler: "ChannelPlaylistsHandler",
|
||||
paginationType: "Continuation",
|
||||
},
|
||||
{
|
||||
name: "channel_channels",
|
||||
displayName: "Related channels",
|
||||
url: "/api/v1/channels/{ucid}/channels",
|
||||
responseHandler: "ChannelRelatedChannelsHandler",
|
||||
paginationType: "Continuation",
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
trending:
|
||||
title: Trending
|
||||
url: /api/v1/trending
|
||||
cacheSeconds: 21600 # 6 hours
|
||||
queryParams:
|
||||
type:
|
||||
type:
|
||||
- Music
|
||||
- Gaming
|
||||
- Movies
|
||||
region:
|
||||
type: "#ISO3166"
|
||||
default: GetUserCountryCode
|
||||
fields:
|
||||
type: []
|
||||
arrayType: "comma-separated"
|
||||
default:
|
||||
- title
|
||||
- videoId
|
||||
- videoThumbnails
|
||||
- lengthSeconds
|
||||
- viewCount
|
||||
- author
|
||||
- authorId
|
||||
- publishedText
|
||||
- liveNow
|
||||
- isUpcoming
|
||||
- premiereTimestamp
|
||||
|
||||
popular:
|
||||
title: Popular
|
||||
url: /api/v1/popular
|
||||
queryParams:
|
||||
fields:
|
||||
type: []
|
||||
arrayType: "comma-separated"
|
||||
default:
|
||||
- title
|
||||
- videoId
|
||||
- videoThumbnails
|
||||
- lengthSeconds
|
||||
- viewCount
|
||||
- author
|
||||
- authorId
|
||||
- publishedText
|
||||
- liveNow
|
||||
- isUpcoming
|
||||
- premiereTimestamp
|
||||
|
||||
search:
|
||||
title: Search
|
||||
url: /api/v1/search
|
||||
paginationType: Pages
|
||||
queryParams:
|
||||
q:
|
||||
type: string
|
||||
sort_by:
|
||||
type:
|
||||
- relevance
|
||||
- rating
|
||||
- upload_date
|
||||
- view_count
|
||||
date:
|
||||
type:
|
||||
- hour
|
||||
- today
|
||||
- week
|
||||
- month
|
||||
- year
|
||||
duration:
|
||||
type:
|
||||
- short
|
||||
- long
|
||||
type:
|
||||
type:
|
||||
- video
|
||||
- playlist
|
||||
- channel
|
||||
- all
|
||||
arrayType: comma-separated
|
||||
default:
|
||||
- video
|
||||
- playlist
|
||||
- channel
|
||||
features:
|
||||
type:
|
||||
- hd
|
||||
- subtitles
|
||||
- creative_commons
|
||||
- 3d
|
||||
- live
|
||||
- purchased
|
||||
- 4k
|
||||
- 360
|
||||
- location
|
||||
- hdr
|
||||
arrayType: comma-separated
|
||||
region:
|
||||
type: "#ISO3166"
|
||||
default: GetUserCountryCode
|
||||
cacheSeconds: 900 # 15 minutes
|
||||
|
||||
# Auth endpoints
|
||||
auth_feed:
|
||||
title: Subscriptions
|
||||
url: /api/v1/auth/feed
|
||||
authenticated: true
|
||||
queryParams:
|
||||
max_results:
|
||||
type: number
|
||||
default: 20
|
||||
paginationType: Pages
|
||||
responseHandler: AuthFeedHandler
|
||||
|
||||
auth_playlists:
|
||||
title: Playlists
|
||||
url: /api/v1/auth/playlists
|
||||
authenticated: true
|
||||
|
||||
playlist:
|
||||
title: Playlist
|
||||
url: /api/v1/playlists/{plid}
|
||||
responseHandler: PlaylistHandler
|
||||
paginationType: Pages
|
||||
|
||||
# video_info, playlist_info and channel_info are used by the
|
||||
# Bookmarks, so they are cached for longer
|
||||
video_info:
|
||||
title: Video
|
||||
url: /api/v1/videos/{id}
|
||||
responseHandler: VideoInfoHandler
|
||||
cacheSeconds: 259200 # 3 days
|
||||
|
||||
playlist_info:
|
||||
title: Playlist
|
||||
url: /api/v1/playlists/{plid}
|
||||
responseHandler: PlaylistInfoHandler
|
||||
cacheSeconds: 259200 # 3 days
|
||||
|
||||
channel_info:
|
||||
title: Channel
|
||||
url: /api/v1/channels/{ucid}
|
||||
responseHandler: ChannelInfoHandler
|
||||
cacheSeconds: 259200 # 3 days
|
||||
|
||||
# Channel endpoints
|
||||
channel_videos:
|
||||
title: Channel videos
|
||||
url: /api/v1/channels/{ucid}/videos
|
||||
responseHandler: ChannelVideosHandler
|
||||
paginationType: Continuation
|
||||
queryParams:
|
||||
sort_by:
|
||||
# defaults to newest
|
||||
type:
|
||||
- newest
|
||||
- oldest
|
||||
- popular
|
||||
|
||||
channel_playlists:
|
||||
title: Channel playlists
|
||||
url: /api/v1/channels/{ucid}/playlists
|
||||
responseHandler: ChannelPlaylistsHandler
|
||||
paginationType: Continuation
|
||||
queryParams:
|
||||
sort_by:
|
||||
required: false
|
||||
type:
|
||||
- newest
|
||||
- oldest
|
||||
- last
|
||||
|
||||
channel_shorts:
|
||||
title: Channel shorts
|
||||
url: /api/v1/channels/{ucid}/shorts
|
||||
responseHandler: ChannelVideosHandler
|
||||
paginationType: Continuation
|
||||
|
||||
channel_streams:
|
||||
title: Channel streams
|
||||
url: /api/v1/channels/{ucid}/streams
|
||||
responseHandler: ChannelVideosHandler
|
||||
paginationType: Continuation
|
||||
|
||||
channel_podcasts:
|
||||
title: Channel podcasts
|
||||
url: /api/v1/channels/{ucid}/podcasts
|
||||
responseHandler: ChannelPlaylistsHandler
|
||||
paginationType: Continuation
|
||||
|
||||
channel_channels:
|
||||
title: Related channels
|
||||
url: /api/v1/channels/{ucid}/channels
|
||||
responseHandler: ChannelRelatedChannelsHandler
|
||||
paginationType: Continuation
|
||||
@@ -2,7 +2,7 @@
|
||||
inputHash: 'b88a05052cd01cb7a89bd6802418d79e',
|
||||
outputs: [
|
||||
{
|
||||
outputFilePath: 'src/images/icons/filters-black.png',
|
||||
outputFilePath: 'images/icons/filters-black.png',
|
||||
outputHash: 'f0a7539ae840c00a2d91292f993bb75e',
|
||||
width: 64,
|
||||
height: 64,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
inputHash: 'df7918a3b43642f707cc0d9fcfd2d9ee',
|
||||
outputs: [
|
||||
{
|
||||
outputFilePath: 'src/images/icons/filters-white.png',
|
||||
outputFilePath: 'images/icons/filters-white.png',
|
||||
outputHash: '914e2c8da9772c23c24bebbd39c918f2',
|
||||
width: 64,
|
||||
height: 64,
|
||||
|
||||
|
Before Width: | Height: | Size: 483 B After Width: | Height: | Size: 1.0 KiB |
@@ -2,10 +2,10 @@
|
||||
inputHash: '788d5e9ddc5a26953392afa17a85a05c',
|
||||
outputs: [
|
||||
{
|
||||
outputFilePath: 'src/images/icons/home.png',
|
||||
outputHash: '3da3ed864137ace837ef2f96a4e5e13d',
|
||||
width: 64,
|
||||
height: 64,
|
||||
outputFilePath: 'images/icons/home.png',
|
||||
outputHash: '2c223d1197313eac54d31fc47d5a3ea7',
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 2.5 KiB |
@@ -2,10 +2,10 @@
|
||||
inputHash: '92a5720049ca36c38c695969534c2bb5',
|
||||
outputs: [
|
||||
{
|
||||
outputFilePath: 'src/images/icons/info.png',
|
||||
outputHash: '31b5c5c342ded1bc99b3466c2fbaaf09',
|
||||
width: 64,
|
||||
height: 64,
|
||||
outputFilePath: 'images/icons/info.png',
|
||||
outputHash: '46ec11a1a70386f7c9df8b6f60228f06',
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
Before Width: | Height: | Size: 517 B After Width: | Height: | Size: 1.1 KiB |
@@ -2,10 +2,10 @@
|
||||
inputHash: 'e6318f56ce4c0cc637cf0cc3180a2013',
|
||||
outputs: [
|
||||
{
|
||||
outputFilePath: 'src/images/icons/phone.png',
|
||||
outputHash: '2d7ece94b64fa5a725adeea5a313cbcf',
|
||||
width: 64,
|
||||
height: 64,
|
||||
outputFilePath: 'images/icons/phone.png',
|
||||
outputHash: '6fbf881854e38acf3ba15febc88604aa',
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
Before Width: | Height: | Size: 925 B After Width: | Height: | Size: 2.7 KiB |
@@ -2,10 +2,10 @@
|
||||
inputHash: 'dede98d4bf3c835836c82c485600108c',
|
||||
outputs: [
|
||||
{
|
||||
outputFilePath: 'src/images/icons/search.png',
|
||||
outputHash: '5b5fb4128202a1e074b04ee570bbcf69',
|
||||
width: 64,
|
||||
height: 64,
|
||||
outputFilePath: 'images/icons/search.png',
|
||||
outputHash: '53e68de417adaddb44ae0194a18cf287',
|
||||
width: 128,
|
||||
height: 128,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 2.3 KiB |