Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
891a5f8405 | ||
|
|
7ab98024c1 | ||
|
|
c2b6b75f94 | ||
|
|
2e09239123 | ||
|
|
fcae05a0da | ||
|
|
0bc5ab6117 | ||
|
|
cfd6bc8ec8 | ||
|
|
47896ae9dc | ||
|
|
9e3da6b67d | ||
|
|
4c94db2c03 | ||
|
|
8ff4847977 | ||
|
|
65a4a855a1 | ||
|
|
40e7014e55 | ||
|
|
d5f74d41c0 | ||
|
|
91081e09d5 | ||
|
|
e7fbe5c189 | ||
|
|
0151f4c81c | ||
|
|
e28c92c3d4 | ||
|
|
4676b45567 | ||
|
|
438050fcca | ||
|
|
70e2608e59 | ||
|
|
d2d875f124 | ||
|
|
6a1069337d | ||
|
|
eb67d9e4c0 | ||
|
|
6d9117a2a0 | ||
|
|
ab246e8080 | ||
|
|
7f3591409e | ||
|
|
650e70f271 | ||
|
|
a9f70b48aa | ||
|
|
becb8b04f5 | ||
|
|
68a4f9fade | ||
|
|
07ebd011cf | ||
|
|
d210d84d63 | ||
|
|
1e129e9a73 | ||
|
|
1c6b47a5a6 | ||
|
|
013e2f49ca | ||
|
|
d2fbd59d6a | ||
|
|
f681a7024c | ||
|
|
e9c2ab9f76 | ||
|
|
aed102f57a | ||
|
|
8b123b18f5 | ||
|
|
158788b42e | ||
|
|
8d42c0213b | ||
|
|
7c1aa80819 | ||
|
|
30ea007502 | ||
|
|
fc7a029147 | ||
|
|
cbb34d45fc | ||
|
|
beeb21283d | ||
|
|
89ec969c40 | ||
|
|
0e226cfc42 | ||
|
|
5762de656c | ||
|
|
a721cd3f0a | ||
|
|
8c0692dc10 | ||
|
|
21c7aee907 | ||
|
|
227a5157a5 | ||
|
|
4fc44becd2 | ||
|
|
918b763384 | ||
|
|
e821464451 | ||
|
|
fb030cee97 | ||
|
|
6e13e3009a | ||
|
|
b38f105e02 | ||
|
|
9b58bf47ad | ||
|
|
af12ac43be | ||
|
|
32f0477f36 | ||
|
|
dcadb1ec17 | ||
|
|
02c9358eb1 | ||
|
|
dea178f78e | ||
|
|
1268f63bbc | ||
|
|
cd10f237f4 | ||
|
|
64c23ade48 | ||
|
|
1dcd88a9a4 | ||
|
|
b040b2997c | ||
|
|
21a10705f1 | ||
|
|
1120d40085 | ||
|
|
2b633888f4 | ||
|
|
af4a6ee726 | ||
|
|
f3f9327c1c | ||
|
|
fae875845a | ||
|
|
17aca0b8bf | ||
|
|
49390ab0ae | ||
|
|
bb2ca5515b | ||
|
|
e15b6ec958 | ||
|
|
6a80fe6c74 | ||
|
|
0d61d1e337 | ||
|
|
33c6e174ee | ||
|
|
91b17fa4a4 | ||
|
|
943d39af33 | ||
|
|
e8015d52ff | ||
|
|
d919489f50 | ||
|
|
62675446b2 | ||
|
|
4a8b12294d | ||
|
|
5583f55aae | ||
|
|
d4f15e7dfb | ||
|
|
de7c3f8a99 | ||
|
|
b35dc4423e | ||
|
|
23146706ee | ||
|
|
d10444b96c | ||
|
|
2f7ba64488 | ||
|
|
f1f50cc19e | ||
|
|
b3a9887634 | ||
|
|
c56092144f | ||
|
|
750472912e | ||
|
|
ae83c47bfe | ||
|
|
e08bc86334 | ||
|
|
10aaf74c38 | ||
|
|
79464a003e | ||
|
|
f7b8aa6c29 | ||
|
|
59e378cc9c | ||
|
|
a1c178830a | ||
|
|
173e6ffa6c | ||
|
|
207614ac5c | ||
|
|
5c7c6e83c3 | ||
|
|
9ceb1c8963 | ||
|
|
106a664c9f | ||
|
|
bd3ac7b9c1 | ||
|
|
afe61c2df7 | ||
|
|
943f348d87 | ||
|
|
30b6551356 | ||
|
|
a46397fa46 | ||
|
|
32afe5afd9 | ||
|
|
371286344f | ||
|
|
ae39b8d0ab | ||
|
|
1c4067e7da | ||
|
|
b327a37576 | ||
|
|
0d8aae6a75 | ||
|
|
8f79d91c29 | ||
|
|
5c02d46f1d | ||
|
|
83627b67ec | ||
|
|
2b11d4b71c | ||
|
|
29a3206f17 | ||
|
|
12231fe2ec | ||
|
|
0b6cd0294f | ||
|
|
1964040900 | ||
|
|
3cb3c4b8ab | ||
|
|
4acc1bd0c6 | ||
|
|
3375ce9f4f | ||
|
|
75c965fd8b | ||
|
|
345f26f0b2 | ||
|
|
6a9fb2755d | ||
|
|
01103f7833 | ||
|
|
21a653571f | ||
|
|
caa3f18fcc | ||
|
|
6b62532b48 | ||
|
|
6fd99afd8a | ||
|
|
23401e7841 | ||
|
|
54b4750e8e | ||
|
|
1587c8fd26 | ||
|
|
cef4679770 | ||
|
|
fc3a9ce41f | ||
|
|
dfaf3fa87e | ||
|
|
f8988e9d13 | ||
|
|
6f74ee61f6 | ||
|
|
a598d362ba | ||
|
|
66ce75d62e | ||
|
|
975980a3b5 | ||
|
|
951a13be1f | ||
|
|
14eba620ac |
No files matched your search
+159
-1
@@ -5,6 +5,164 @@ 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.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.40.0] - 2025-06-01
|
||||
|
||||
### Added
|
||||
|
||||
- German translations
|
||||
- Support for multi-accounts, such as brand accounts
|
||||
- Support for manual skip in SponsorBlock
|
||||
- Customize SponsorBlock categories from the settings
|
||||
|
||||
### Fixed
|
||||
|
||||
- Show videos watch progress in playlist view
|
||||
- Missing localization in certain views
|
||||
|
||||
## [0.39.1] - 2025-05-23
|
||||
|
||||
### Fixed
|
||||
|
||||
- Regression with watch progress introduced in previous release
|
||||
|
||||
## [0.39.0] - 2025-05-23
|
||||
|
||||
### Added
|
||||
|
||||
- New settings category: `Content Feed`
|
||||
- New setting: `Disable Shorts`
|
||||
|
||||
### Fixed
|
||||
|
||||
- A regression with thumbnails not showing from previous release
|
||||
- Inability to login to Invidious when selected backend is Playlet (local)
|
||||
|
||||
## [0.38.2] - 2025-05-22
|
||||
|
||||
### Added
|
||||
|
||||
- German translation
|
||||
|
||||
### Changed
|
||||
|
||||
- Settings: Added a "backend" section, and removed backend selection from Playback to avoid confusion
|
||||
|
||||
### Removed
|
||||
|
||||
- [advanced users]: `playlet-web-api.yml` was removed. It was getting outdated, and too hard to maintain to justify keeping it
|
||||
|
||||
### Fixed
|
||||
|
||||
- Display issue in playlist view
|
||||
|
||||
## [0.38.1] - 2025-05-20
|
||||
|
||||
### Fixed
|
||||
|
||||
- Cache issue for watch history
|
||||
- Video progress not showing in web app
|
||||
- Video does not continuing from previous progress when opened
|
||||
|
||||
## [0.38.0] - 2025-05-19
|
||||
|
||||
### Added
|
||||
|
||||
- Watch progress for YouTube accounts: Progress is saved as you watch. Progress bar is shown on video thumbnails (only on user feeds, such as recommendations, subscriptions, and watch history)
|
||||
- Known bug: Watch progress doesn't update for all videos.
|
||||
|
||||
### Fixed
|
||||
|
||||
- A few issues related to Playlet backend feeds and caching
|
||||
- An error when Invidious doesn't return valid video metadata
|
||||
- A bug where playlists with small number of videos has duplicates
|
||||
- A bug where DASH manifest was not generated correctly for proxied Invidious videos
|
||||
- A bug where watch history videos repeat indefinitely
|
||||
|
||||
## [0.37.0] - 2025-05-16
|
||||
|
||||
### Added
|
||||
|
||||
- YouTube account support. The following features are now available:
|
||||
- The ability to login to one or multiple accounts
|
||||
- Both YouTube accounts and Invidious accounts are supported side-by-side
|
||||
- Subscriptions
|
||||
- User playlists
|
||||
- Watch History
|
||||
- Watched videos on Playlet are added to the watch history
|
||||
- Subscribe/Unsubscribe
|
||||
- Recommended videos for logged in YouTube user are available in the home screen
|
||||
- This feed can be enabled/disabled from the settings
|
||||
- When an Invidious user is logged in, this becomes "popular" since Invidious does not support recommendations
|
||||
|
||||
### Fixed
|
||||
|
||||
- A bug where Session data did not refresh after 24 hours
|
||||
|
||||
### Changed
|
||||
|
||||
- [advanced users]: the Playlet web server's CORS headers are no longer set to `*`, for security reasons.
|
||||
|
||||
## [0.36.7] - 2025-05-04
|
||||
|
||||
### Fixed
|
||||
|
||||
- Playlet backend error caused by Roku 14.5 update on Canada devices
|
||||
|
||||
## [0.36.6] - 2025-05-03
|
||||
|
||||
### Fixed
|
||||
|
||||
- Small UI bug in web app nav bar
|
||||
- Backend logging to improve debugging
|
||||
|
||||
## [0.36.5] - 2025-05-02
|
||||
|
||||
### Fixed
|
||||
|
||||
- Small error handling bug in Playlet backend
|
||||
|
||||
## [0.36.4] - 2025-04-19
|
||||
|
||||
### Added
|
||||
|
||||
- Portuguese (Brazil) translations (Thanks to davbrasan)
|
||||
|
||||
### Removed
|
||||
|
||||
- Startup announcement dialog
|
||||
|
||||
### Fixed
|
||||
|
||||
- German translation (Thanks to Atalanttore)
|
||||
|
||||
## [0.36.3] - 2025-04-02
|
||||
|
||||
### Fixed
|
||||
|
||||
- Playlet backend parsing issue in search results
|
||||
- Bug with saving search history
|
||||
|
||||
## [0.36.2] - 2025-02-28
|
||||
|
||||
### Added
|
||||
|
||||
- German translations (Thanks to Lacey Anaya and Bastian Veith)
|
||||
- Spanish (Mexico) translations (Thanks to Jean Carton)
|
||||
|
||||
## [0.36.1] - 2025-01-19
|
||||
|
||||
### Fixed
|
||||
|
||||
- Added `Visitor Data` to payload in Playlet backend
|
||||
- Session data persists for 24 hours
|
||||
- It reduces the privacy of the app, but can help with `Sign in to confirm you're not a bot` errors
|
||||
|
||||
### Changed
|
||||
|
||||
- Video queue view might be missing video titles and durations
|
||||
- This is done to reduce the risk of rate limiting. No video titles in the queue is better than no videos playing at all.
|
||||
- Only affects casting playlists from the YouTube mobile app.
|
||||
|
||||
## [0.36.0] - 2025-01-16
|
||||
|
||||
### Added
|
||||
@@ -610,7 +768,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Removed
|
||||
|
||||
- Xmas theme logo - can't publish it before end of year... ([link](https://blog.roku.com/developer/channel-store-blackouts-2023))
|
||||
- Xmas theme logo - can't publish it before end of year... ([channel-store-blackouts-2023](https://blog.roku.com/developer/channel-store-blackouts-2023))
|
||||
|
||||
## [0.17.3] - 2023-12-13
|
||||
|
||||
|
||||
@@ -32,6 +32,11 @@ Playlet makes requests directly to Innertube instead of Invidious.
|
||||
Similar to Invidious requests, only the bare minimum and necessary information
|
||||
is sent, which is used to enable the viewing of content.
|
||||
|
||||
Additionally, when a YouTube account is used in Playlet, Innertube traffic can
|
||||
become associated with the account, which further reduces user privacy. This
|
||||
is necessary to use features associated with YouTube accounts, such as
|
||||
subscriptions, playlists, and watch history.
|
||||
|
||||
## SponsorBlock
|
||||
|
||||
Playlet may request information from a [SponsorBlock](https://github.com/ajayyy/SponsorBlock)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<a href="/LICENSE">
|
||||
<img alt="AGPL-3.0 license" src="https://img.shields.io/github/license/iBicha/playlet.svg"/>
|
||||
</a>
|
||||
<a href="https://channelstore.roku.com/details/840aec36f51bfe6d96cf6db9055a372a/playlet">
|
||||
<a href="https://channelstore.roku.com/details/4a41d0921265a5e31429a7679442153f:b5bcb5b630c28b01e93bf59856317b43/playlet">
|
||||
<img alt="Roku Channel Store" src="https://img.shields.io/badge/Roku%20Store-Install-blueviolet?logo=roku&logoColor=blueviolet&labelColor=white"/>
|
||||
</a>
|
||||
<a href="https://github.com/iBicha/playlet/wiki">
|
||||
@@ -40,7 +40,7 @@ More under [Screenshots](./docs/screenshots/README.md)
|
||||
|
||||
## Installation
|
||||
|
||||
[Playlet on Roku channel store](https://channelstore.roku.com/details/840aec36f51bfe6d96cf6db9055a372a/playlet) or search "Playlet" in the Roku channel store on your device.
|
||||
[Playlet on Roku channel store](https://channelstore.roku.com/details/4a41d0921265a5e31429a7679442153f:b5bcb5b630c28b01e93bf59856317b43/playlet) or search "Playlet" in the Roku channel store on your device.
|
||||
|
||||
Can't install from the store? See [How to install Playlet as a sideloaded/dev app](https://github.com/iBicha/playlet/discussions/371)
|
||||
|
||||
@@ -49,6 +49,7 @@ Can't install from the store? See [How to install Playlet as a sideloaded/dev ap
|
||||
- 🔥 No Ads (Not now, not ever)
|
||||
- 🕵️ No Tracking
|
||||
- 🛡️ Privacy driven (uses [Invidious](https://invidious.io/) backend)
|
||||
- 🙋 User accounts (YouTube and Invidious accounts)
|
||||
- ⚔️ [SponsorBlock](https://sponsor.ajay.app/) integration (skips undesirable sections in videos)
|
||||
- 📱 Browse, search, and cast from phone using the YouTube app or the browser
|
||||
- 🔮 Picture-in-picture mode
|
||||
|
||||
@@ -91,7 +91,6 @@
|
||||
"../tools/bs-plugins/json-yaml-plugin.ts",
|
||||
"../tools/bs-plugins/validation-plugin.ts",
|
||||
"../tools/bs-plugins/logger-plugin.ts",
|
||||
"../tools/bs-plugins/image-gen-plugin.ts",
|
||||
"../tools/bs-plugins/type-gen-plugin.ts",
|
||||
"../tools/bs-plugins/web-server-plugin.ts",
|
||||
"../tools/bs-plugins/locale-validation-plugin.ts",
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
"../tools/bs-plugins/json-yaml-plugin.ts",
|
||||
"../tools/bs-plugins/validation-plugin.ts",
|
||||
"../tools/bs-plugins/logger-plugin.ts",
|
||||
"../tools/bs-plugins/image-gen-plugin.ts",
|
||||
"../tools/bs-plugins/type-gen-plugin.ts",
|
||||
"../tools/bs-plugins/web-server-plugin.ts",
|
||||
"../tools/bs-plugins/locale-validation-plugin.ts",
|
||||
|
||||
+1
-3
@@ -166,8 +166,6 @@ Playlet lib comes equipped with a web server that runs on port 8888 when the app
|
||||
|
||||
The web server runs on a continuously running [Task](https://developer.roku.com/en-ca/docs/references/scenegraph/control-nodes/task.md) and uses a middeware system to manage routes, serve static files, [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), and more.
|
||||
|
||||
The server's API enpoints are described through the Open API spec file [playlet-web-api.yml](./playlet-web-api.yml)
|
||||
|
||||
Please note: while we would like to keep the API stable as much as possible, Playlet can't reasonbly maintain multiple versions of the API like traditional web apis, because it adds complexity and maintainablity burden on an app the runs in constrained environment. In short, we'll try not to break the API, but we might from time to time.
|
||||
|
||||
#### Debug endpoints
|
||||
@@ -276,7 +274,7 @@ The Playlet web app uses [Tailwind CSS](https://tailwindcss.com/) as its base st
|
||||
|
||||
### API calls
|
||||
|
||||
The Playlet web app communicates with the Playlet Roku app using web APIs. Most of the APIs used are described in the OpenAPI spec [playlet-web-api.yml](./playlet-web-api.yml). The web app also uses Invidious apis documented at [https://docs.invidious.io/api](https://docs.invidious.io/api)
|
||||
The Playlet web app communicates with the Playlet Roku app using web APIs. The web app also uses Invidious apis documented at [https://docs.invidious.io/api](https://docs.invidious.io/api)
|
||||
|
||||
#### API calls (proxy authenticated)
|
||||
|
||||
|
||||
@@ -1,644 +0,0 @@
|
||||
openapi: 3.0.0
|
||||
|
||||
info:
|
||||
title: Playlet Web API
|
||||
version: 0.36.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
|
||||
also be used by other apps.
|
||||
contact:
|
||||
name: Brahim Hadriche
|
||||
url: https://github.com/iBicha
|
||||
email: brahim.hadriche@gmail.com
|
||||
|
||||
servers:
|
||||
- url: http://{ROKU_DEV_TARGET}:{PORT}
|
||||
description: Playlet server
|
||||
variables:
|
||||
ROKU_DEV_TARGET:
|
||||
description: The IP address of the Roku device
|
||||
default: 192.168.1.x
|
||||
PORT:
|
||||
description: The port number of the Playlet server
|
||||
default: "8888"
|
||||
|
||||
paths:
|
||||
/api/state:
|
||||
get:
|
||||
summary: Get Playlet app state
|
||||
description: >
|
||||
Get the current state of the Playlet app. The `key` parameter is
|
||||
optional and can be omitted to get the entire state. If the `key`
|
||||
parameter is specified, only the specified key(s) will be returned.
|
||||
operationId: getPlayletState
|
||||
parameters:
|
||||
- name: key
|
||||
in: query
|
||||
description: specific key(s) to get
|
||||
required: false
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
enum:
|
||||
- app
|
||||
- device
|
||||
- invidious
|
||||
- preferences
|
||||
- profiles
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PlayletAppState"
|
||||
/api/preferences:
|
||||
get:
|
||||
summary: Get preferences
|
||||
description: |
|
||||
Get the current user preferences.
|
||||
operationId: getPreferences
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PreferencesObject"
|
||||
put:
|
||||
summary: Set preferences
|
||||
description: >
|
||||
Set the current user preferences. The request body can contain some or
|
||||
all of the preferences. Any preferences not specified in the request
|
||||
body will be left unchanged.
|
||||
operationId: setPreferences
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PreferencesObject"
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
"400":
|
||||
description: Bad Request
|
||||
delete:
|
||||
summary: Reset preferences
|
||||
description: |
|
||||
Reset the current user preferences to their default values.
|
||||
operationId: resetPreferences
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
/api/search-history:
|
||||
get:
|
||||
summary: Get search history
|
||||
description: |
|
||||
Get the current search history.
|
||||
operationId: getSearchHistory
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
post:
|
||||
summary: Add to search history
|
||||
description: |
|
||||
Add a query to the search history.
|
||||
operationId: addToSearchHistory
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
query:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
"400":
|
||||
description: Bad Request
|
||||
delete:
|
||||
summary: Clear search history
|
||||
description: |
|
||||
Clear the search history.
|
||||
operationId: clearSearchHistory
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
/api/queue:
|
||||
get:
|
||||
summary: Get video queue
|
||||
description: Get the current videos in the queue.
|
||||
operationId: getVideoQueue
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
items:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/VideoQueueObject"
|
||||
index:
|
||||
type: integer
|
||||
nowPlaying:
|
||||
$ref: "#/components/schemas/VideoQueueObject"
|
||||
post:
|
||||
summary: Add to video queue
|
||||
description: Add a video or a playlist to the queue.
|
||||
operationId: addToVideoQueue
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/VideoQueueObject"
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
delete:
|
||||
summary: Clear video queue
|
||||
description: Clear the video queue.
|
||||
operationId: clearVideoQueue
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
/api/queue/play:
|
||||
post:
|
||||
summary: Play video
|
||||
description: Play a video or playlist. This adds the video or playlist to the current position in the queue and plays it.
|
||||
operationId: playVideoQueue
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/VideoQueueObject"
|
||||
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/home-layout:
|
||||
get:
|
||||
summary: Get home layout
|
||||
description: Get the current home layout. This is the layout of the home screen, based on user preferences.
|
||||
operationId: getHomeLayout
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
title:
|
||||
type: string
|
||||
feedSources:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
apiType:
|
||||
type: string
|
||||
endpoint:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
queryParams:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
title:
|
||||
type: string
|
||||
/api/playlet-lib-urls:
|
||||
get:
|
||||
summary: Get Playlet lib URLs
|
||||
description: Get the currently loaded Playlet lib url, and the saved ones to be loaded on next start.
|
||||
operationId: getPlayletLibUrls
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
loaded:
|
||||
type: object
|
||||
properties:
|
||||
link:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
saved:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
link:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
post:
|
||||
summary: Set Playlet lib URLs
|
||||
description: >
|
||||
Set a list of Playlet lib URLs to be loaded on next start. Playlet will try to load them one after the other
|
||||
until one succeeds.
|
||||
operationId: setPlayletLibUrls
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
link:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
"400":
|
||||
description: Bad Request
|
||||
delete:
|
||||
summary: Clear Playlet lib URLs
|
||||
description: Clear the Playlet lib URLs. This affects the saved links in the registry, and will take effect on next start.
|
||||
operationId: clearPlayletLibUrls
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
|
||||
/invidious/login:
|
||||
get:
|
||||
summary: Redirect to the Invidious auth URL
|
||||
description: Redirect to the Invidious auth URL, to allow authorizing an access token. Redirects to the Invidious auth URL.
|
||||
operationId: invidiousLoginUrl
|
||||
responses:
|
||||
"302":
|
||||
description: Found
|
||||
headers:
|
||||
Location:
|
||||
schema:
|
||||
type: string
|
||||
format: uri
|
||||
/api/profiles:
|
||||
get:
|
||||
summary: Get profiles
|
||||
description: Get the logged profiles, and the currently active profile.
|
||||
operationId: getProfiles
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
currentProfile:
|
||||
type: string
|
||||
profiles:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ProfileObject"
|
||||
delete:
|
||||
summary: Logout from a profile
|
||||
description: Logout from a profile. This will remove the profile from the list of logged profiles.
|
||||
operationId: logoutProfile
|
||||
parameters:
|
||||
- name: id
|
||||
in: query
|
||||
description: The ID of the profile to logout
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
"400":
|
||||
description: Bad Request
|
||||
"404":
|
||||
description: Not Found
|
||||
/api/profiles/activate:
|
||||
post:
|
||||
summary: Activate a profile
|
||||
description: Activate a profile. This will set the profile as the active profile.
|
||||
operationId: activateProfile
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
"400":
|
||||
description: Bad Request
|
||||
"404":
|
||||
description: Not Found
|
||||
|
||||
# Roku External Control Protocol (ECP)
|
||||
/input/{appId}:
|
||||
servers:
|
||||
- url: http://{ROKU_DEV_TARGET}:8060
|
||||
description: Roku ECP endpoint
|
||||
variables:
|
||||
ROKU_DEV_TARGET:
|
||||
description: The IP address of the Roku device
|
||||
default: 192.168.1.x
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/ecpAppId"
|
||||
post:
|
||||
summary: Send input to Playlet through ECP
|
||||
description: Send input to Playlet through Roku External Control Protocol (ECP). This enables the deep-linking functionality.
|
||||
operationId: ecpInput
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/ecpContentId"
|
||||
- $ref: "#/components/parameters/ecpMediaType"
|
||||
- $ref: "#/components/parameters/ecpVideoId"
|
||||
- $ref: "#/components/parameters/ecpTimestamp"
|
||||
- $ref: "#/components/parameters/ecpTitle"
|
||||
- $ref: "#/components/parameters/ecpAuthor"
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
/launch/{appId}:
|
||||
servers:
|
||||
- url: http://{ROKU_DEV_TARGET}:8060
|
||||
description: Roku ECP endpoint
|
||||
variables:
|
||||
ROKU_DEV_TARGET:
|
||||
description: The IP address of the Roku device
|
||||
default: 192.168.1.x
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/ecpAppId"
|
||||
post:
|
||||
summary: Launch Playlet using ECP with arguments
|
||||
description: Launch Playlet through Roku External Control Protocol (ECP) with arguments. This enables the deep-linking functionality.
|
||||
operationId: ecpLaunch
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/ecpClearPlayletLibUrls"
|
||||
- $ref: "#/components/parameters/ecpContentId"
|
||||
- $ref: "#/components/parameters/ecpMediaType"
|
||||
- $ref: "#/components/parameters/ecpVideoId"
|
||||
- $ref: "#/components/parameters/ecpTimestamp"
|
||||
- $ref: "#/components/parameters/ecpTitle"
|
||||
- $ref: "#/components/parameters/ecpAuthor"
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
|
||||
components:
|
||||
parameters:
|
||||
ecpAppId:
|
||||
name: appId
|
||||
in: path
|
||||
description: The app ID of the Playlet app
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
enum:
|
||||
- "693751" # Playlet app id
|
||||
- dev
|
||||
default: "693751"
|
||||
ecpContentId:
|
||||
name: contentId
|
||||
in: query
|
||||
description: The ID of the content to play. If specified with mediaType=video, this is the videoId.
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
ecpMediaType:
|
||||
name: mediaType
|
||||
in: query
|
||||
description: The type of the content of ContentId. To be used with the contentId argument.
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
enum:
|
||||
- video
|
||||
ecpVideoId:
|
||||
name: videoId
|
||||
in: query
|
||||
description: The video ID of the video to play. If specified, the video will be played.
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
ecpTimestamp:
|
||||
name: timestamp
|
||||
in: query
|
||||
description: The timestamp of the video to play. To be used with the contentId argument.
|
||||
required: false
|
||||
schema:
|
||||
type: integer
|
||||
ecpTitle:
|
||||
name: title
|
||||
in: query
|
||||
description: The title of the video. This is optionally added so we can display the title while loading, or when displaying the "Added to queue" notification.
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
ecpAuthor:
|
||||
name: author
|
||||
in: query
|
||||
description: The author of the video. This is optionally added so we can display the author while loading, or when displaying the "Added to queue" notification.
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
ecpClearPlayletLibUrls:
|
||||
name: clearPlayletLibUrls
|
||||
in: query
|
||||
description: If specified, the Playlet lib URLs will be cleared.
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
|
||||
schemas:
|
||||
PlayletAppState:
|
||||
type: object
|
||||
properties:
|
||||
app:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
version:
|
||||
type: string
|
||||
git_commit_hash:
|
||||
type: string
|
||||
lib_version:
|
||||
type: string
|
||||
lib_git_commit_hash:
|
||||
type: string
|
||||
lib_version_latest:
|
||||
type: string
|
||||
lib_url_type:
|
||||
type: string
|
||||
device:
|
||||
type: object
|
||||
properties:
|
||||
model:
|
||||
type: string
|
||||
model_display_name:
|
||||
type: string
|
||||
model_type:
|
||||
type: string
|
||||
model_details:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
os_version:
|
||||
type: object
|
||||
properties:
|
||||
build:
|
||||
type: string
|
||||
major:
|
||||
type: string
|
||||
minor:
|
||||
type: string
|
||||
revision:
|
||||
type: string
|
||||
display_type:
|
||||
type: string
|
||||
display_mode:
|
||||
type: string
|
||||
display_aspect_ratio:
|
||||
type: string
|
||||
display_size:
|
||||
type: object
|
||||
properties:
|
||||
w:
|
||||
type: integer
|
||||
h:
|
||||
type: integer
|
||||
video_mode:
|
||||
type: string
|
||||
ui_resolution:
|
||||
type: object
|
||||
properties:
|
||||
height:
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
width:
|
||||
type: integer
|
||||
graphics_platform:
|
||||
type: string
|
||||
internet_status:
|
||||
type: boolean
|
||||
user_country_code:
|
||||
type: string
|
||||
friendly_name:
|
||||
type: string
|
||||
current_locale:
|
||||
type: string
|
||||
invidious:
|
||||
type: object
|
||||
properties:
|
||||
current_instance:
|
||||
type: string
|
||||
auth_url:
|
||||
type: string
|
||||
preferences:
|
||||
$ref: "#/components/schemas/PreferencesObject"
|
||||
profiles:
|
||||
type: object
|
||||
properties:
|
||||
currentProfile:
|
||||
type: string
|
||||
profiles:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ProfileObject"
|
||||
PreferencesObject:
|
||||
type: object
|
||||
properties:
|
||||
invidious.instance:
|
||||
type: string
|
||||
invidious.proxy_videos:
|
||||
type: string
|
||||
enum:
|
||||
- always
|
||||
- if_needed
|
||||
- never
|
||||
playback.autoplay:
|
||||
type: string
|
||||
enum:
|
||||
- auto
|
||||
- 720p
|
||||
playback.preferred_quality:
|
||||
type: string
|
||||
sponsorblock.enabled:
|
||||
type: boolean
|
||||
sponsorblock.show_notifications:
|
||||
type: boolean
|
||||
ProfileObject:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
username:
|
||||
type: string
|
||||
serverUrl:
|
||||
type: string
|
||||
# TODO:P1 add the rest of properties
|
||||
VideoQueueObject:
|
||||
type: object
|
||||
properties:
|
||||
videoId:
|
||||
type: string
|
||||
playlistId:
|
||||
type: string
|
||||
playlistIndex:
|
||||
type: integer
|
||||
timestamp:
|
||||
type: integer
|
||||
title:
|
||||
type: string
|
||||
author:
|
||||
type: string
|
||||
@@ -1,7 +1,6 @@
|
||||
# Playlet Brighterscript Plugins
|
||||
|
||||
- [Json5/Yaml support](#json5yaml-support)
|
||||
- [Convert images](#convert-images)
|
||||
- [Manifest editing](#manifest-editing)
|
||||
- [Validation](#validation)
|
||||
- [Includes](#includes)
|
||||
@@ -33,21 +32,6 @@ Brightscript can only parse json natively using [ParseJson](https://developer.ro
|
||||
|
||||
At the end of the build, the plugin scans for certain files (`jsonc`, `json`, `json5` and `yaml`), and converts them to plain json, while keeping the original file name. That way they are all parsable by the [ParseJson](https://developer.roku.com/en-ca/docs/references/brightscript/language/global-utility-functions.md#parsejsonjsonstring-as-string-flags---as-string-as-object) function, even though their original format is not compatible.
|
||||
|
||||
## Convert images
|
||||
|
||||
**[Source](/tools/bs-plugins/image-gen-plugin.ts)**
|
||||
|
||||
This plugin allows us to convert svg files to png files.
|
||||
|
||||
### Why
|
||||
|
||||
This is used to convert splash screen, app poster, as well as icons in the app. Having svg images (or vector images in general) as the source of truth is better, in case images need to be modified or resized. Since Roku can't load them, we convert them to png.
|
||||
|
||||
### How
|
||||
|
||||
Each `.svg` file found will have an associated `.svg.meta.json5` file, which will contain the hash (MD5) of the svg, conversion paramters, and the hash of the output files. This allows us to hash existing files and see if a conversion is needed.
|
||||
Notice how each `.svg` file can be configured to generate multiple png files. This is especially the case to generate the app artwork (splash screen/poster) with different sizes from the same logo `.svg` file.
|
||||
|
||||
## Manifest editing
|
||||
|
||||
**[Source](/tools/bs-plugins/manifest-edit-plugin.ts)**
|
||||
|
||||
@@ -6,7 +6,12 @@ import { utils } from 'roku-test-automation';
|
||||
const envFile = path.join(__dirname, '../.env');
|
||||
const config = getEnvVars(['ROKU_DEV_TARGET', 'ROKU_DEVPASSWORD']);
|
||||
|
||||
export function setupEnvironment() {
|
||||
export enum AppId {
|
||||
DEV = 'dev',
|
||||
PROD = '693751',
|
||||
}
|
||||
|
||||
export function setupEnvironment(appId = AppId.DEV) {
|
||||
utils.setupEnvironmentFromConfig({
|
||||
RokuDevice: {
|
||||
devices: [{
|
||||
@@ -16,7 +21,7 @@ export function setupEnvironment() {
|
||||
},
|
||||
ECP: {
|
||||
default: {
|
||||
launchChannelId: 'dev'
|
||||
launchChannelId: appId,
|
||||
}
|
||||
},
|
||||
OnDeviceComponent: {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// integration test to play a video on the Roku device
|
||||
// 1. Run dev channel on the Roku device (Playlet (dev))
|
||||
// 2. npm run restart-app && npm run test:integration
|
||||
|
||||
import { ecp, odc } from 'roku-test-automation';
|
||||
import { setupEnvironment } from './common';
|
||||
import { AppId, setupEnvironment } from './common';
|
||||
import { Key } from 'roku-test-automation/client/dist/ECP';
|
||||
|
||||
setupEnvironment();
|
||||
async function playVideoDev() {
|
||||
setupEnvironment(AppId.DEV);
|
||||
|
||||
(async () => {
|
||||
await ecp.sendInput({ params: { contentId: "jNQXAC9IVRw" } });
|
||||
await ecp.sendLaunchChannel({ params: { contentId: "jNQXAC9IVRw" } });
|
||||
await ecp.sleep(5000);
|
||||
|
||||
await odc.onFieldChangeOnce({
|
||||
base: "scene",
|
||||
@@ -18,7 +18,35 @@ setupEnvironment();
|
||||
|
||||
console.log("Video started playing");
|
||||
|
||||
await ecp.sendKeypress(Key.Back);
|
||||
|
||||
await odc.shutdown();
|
||||
await ecp.sendKeypress(Key.Home);
|
||||
}
|
||||
|
||||
async function playVideoProd() {
|
||||
setupEnvironment(AppId.PROD);
|
||||
|
||||
let playerState = (await ecp.getMediaPlayer()).state;
|
||||
await ecp.sendLaunchChannel({ params: { contentId: "jNQXAC9IVRw" } });
|
||||
|
||||
const TIMEOUT = 20000;
|
||||
const start = Date.now();
|
||||
while (Date.now() - start < TIMEOUT) {
|
||||
const newPlayerState = (await ecp.getMediaPlayer()).state;
|
||||
if (newPlayerState !== playerState) {
|
||||
console.log("Player state changed: ", newPlayerState);
|
||||
playerState = newPlayerState;
|
||||
}
|
||||
if (playerState === "play") {
|
||||
console.log("Video started playing");
|
||||
break;
|
||||
}
|
||||
await ecp.sleep(1000);
|
||||
}
|
||||
|
||||
await ecp.sendKeypress(Key.Home);
|
||||
}
|
||||
|
||||
(async () => {
|
||||
await playVideoDev();
|
||||
await playVideoProd();
|
||||
})();
|
||||
Generated
+752
-487
File diff suppressed because it is too large.
Load diff
+25
-22
@@ -1,36 +1,37 @@
|
||||
{
|
||||
"name": "playlet",
|
||||
"version": "0.36.0",
|
||||
"version": "0.40.0",
|
||||
"description": "Unofficial YouTube client for Roku",
|
||||
"devDependencies": {
|
||||
"@rokucommunity/bslint": "^0.8.27",
|
||||
"@rokucommunity/bslint": "^0.8.31",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/node": "^22.10.5",
|
||||
"@types/node": "^22.15.29",
|
||||
"@types/xml2js": "^0.4.14",
|
||||
"argparse": "^2.0.1",
|
||||
"brighterscript": "0.68.2",
|
||||
"brighterscript-formatter": "^1.7.7",
|
||||
"brighterscript": "0.68.5",
|
||||
"brighterscript-formatter": "^1.7.14",
|
||||
"cheerio": "1.0.0-rc.11",
|
||||
"convert-svg-to-png": "^0.6.4",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dotenv": "^16.4.7",
|
||||
"fs-extra": "^11.2.0",
|
||||
"glob": "^11.0.1",
|
||||
"dotenv": "^16.5.0",
|
||||
"fs-extra": "^11.3.0",
|
||||
"glob": "^11.0.2",
|
||||
"imap": "^0.8.19",
|
||||
"ip": "^2.0.1",
|
||||
"json5": "^2.2.3",
|
||||
"mailparser": "^3.7.2",
|
||||
"mailparser": "^3.7.3",
|
||||
"protocol-buffers-schema": "^3.6.0",
|
||||
"roku-deploy": "^3.12.3",
|
||||
"roku-test-automation": "^2.0.10",
|
||||
"rooibos-roku": "5.14.0",
|
||||
"roku-deploy": "^3.12.5",
|
||||
"roku-test-automation": "^2.0.13",
|
||||
"rooibos-roku": "5.15.7",
|
||||
"rounded-rect-9patch": "^1.1.2",
|
||||
"semver": "^7.6.3",
|
||||
"shelljs": "^0.8.5",
|
||||
"semver": "^7.7.2",
|
||||
"shelljs": "^0.10.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "5.7.3",
|
||||
"typescript": "5.8.3",
|
||||
"xml2js": "^0.6.2",
|
||||
"yaml": "^2.7.0"
|
||||
"yaml": "^2.8.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "20"
|
||||
@@ -46,8 +47,8 @@
|
||||
"build:lib:dev": "cd playlet-lib && npm run build:dev",
|
||||
"build:lib:prod": "cd playlet-lib && npm run build:prod",
|
||||
"build:web": "cd playlet-web && npm run build",
|
||||
"lint": "cd playlet-lib && npm run lint && cd ../playlet-app && npm run lint",
|
||||
"lint:fix": "cd playlet-lib && npm run lint:fix && cd ../playlet-app && npm run lint:fix",
|
||||
"lint": "cd playlet-lib && npm run lint && cd ../playlet-app && npm run lint && cd ../playlet-web && npm run lint",
|
||||
"lint:fix": "cd playlet-lib && npm run lint:fix && cd ../playlet-app && npm run lint:fix && cd ../playlet-web && npm run lint",
|
||||
"format": "cd playlet-lib && npm run format && cd ../playlet-app && npm run format",
|
||||
"format:fix": "cd playlet-lib && npm run format:fix && cd ../playlet-app && npm run format:fix",
|
||||
"test": "npm run test:lib && npm run test:app",
|
||||
@@ -61,16 +62,18 @@
|
||||
"manifest-git-hash": "node tools/update-manifest-git-hash.js",
|
||||
"sign-released-package": "node tools/sign-released-package.js",
|
||||
"screenshot": "node tools/screenshot.js",
|
||||
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
|
||||
"convert-images": "node tools/convert-images.js",
|
||||
"update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip",
|
||||
"postinstall": "cd playlet-lib && npm install && cd ../playlet-app && npm install && cd ../playlet-web && npm install",
|
||||
"update-deps": "npx npm-check-updates --deep --upgrade --install always",
|
||||
"update-deps": "npx npm-check-updates --deep --upgrade --install always --reject tailwindcss,cheerio,brighterscript,daisyui",
|
||||
"registry:write": "node tools/registry.js --input registry.json",
|
||||
"registry:read": "node tools/registry.js --output registry.json",
|
||||
"registry:clear": "node tools/registry.js --clear",
|
||||
"restart-app": "node tools/restart-app.js"
|
||||
"restart-app": "node tools/restart-app.js",
|
||||
"check-for-updates": "node tools/check-for-updates.js",
|
||||
"shutdown": "node tools/shutdown.js"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rollup/rollup-linux-x64-gnu": "^4.30.1"
|
||||
"@rollup/rollup-linux-x64-gnu": "^4.41.1"
|
||||
}
|
||||
}
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "playlet-app",
|
||||
"version": "0.36.0",
|
||||
"version": "0.40.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playlet-app",
|
||||
"version": "0.36.0"
|
||||
"version": "0.40.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playlet-app",
|
||||
"version": "0.36.0",
|
||||
"version": "0.40.0",
|
||||
"description": "Unofficial YouTube client for Roku",
|
||||
"scripts": {
|
||||
"prebuild": "rm -rf ../build/playlet-app",
|
||||
|
||||
@@ -2,7 +2,7 @@ title=Playlet
|
||||
|
||||
# Do not update version manually, it is auto updated from package.json
|
||||
major_version=0
|
||||
minor_version=36
|
||||
minor_version=40
|
||||
build_version=00000
|
||||
|
||||
ui_resolutions=hd
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "playlet-lib",
|
||||
"version": "0.36.0",
|
||||
"version": "0.40.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playlet-lib",
|
||||
"version": "0.36.0"
|
||||
"version": "0.40.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playlet-lib",
|
||||
"version": "0.36.0",
|
||||
"version": "0.40.0",
|
||||
"description": "Unofficial YouTube client for Roku",
|
||||
"scripts": {
|
||||
"prebuild": "rm -rf ../build/playlet-lib",
|
||||
|
||||
@@ -92,18 +92,25 @@ function OnContentSet() as void
|
||||
if (authorId <> m.authorId or author <> m.author) and IsArray(content.tabs)
|
||||
m.authorId = authorId
|
||||
m.author = author
|
||||
m.rowList.feeds = CreateChannelFeeds(m.authorId, author, content.tabs, content.tabsParams)
|
||||
m.rowList.feeds = CreateChannelFeeds(m.authorId, author, content.tabs, content.tabsParams, content.tabsTitles)
|
||||
end if
|
||||
end function
|
||||
|
||||
function CreateChannelFeeds(authorId as string, author as string, tabs as object, tabsParams as object) as object
|
||||
function CreateChannelFeeds(authorId as string, author as string, tabs as object, tabsParams as object, tabsTitles as object) as object
|
||||
if authorId = ""
|
||||
return invalid
|
||||
end if
|
||||
|
||||
disableShorts = m.preferences["content_feed.disable_shorts"]
|
||||
|
||||
feeds = []
|
||||
for i = 0 to tabs.count() - 1
|
||||
tabName = tabs[i]
|
||||
if tabName = "shorts" and disableShorts
|
||||
LogInfo(`Skipping "Shorts" tab based on user settings`)
|
||||
continue for
|
||||
end if
|
||||
|
||||
if m.tabs.DoesExist(tabName)
|
||||
if tabsParams <> invalid and tabsParams.DoesExist(tabName)
|
||||
params = tabsParams[tabName]
|
||||
@@ -111,7 +118,13 @@ function CreateChannelFeeds(authorId as string, author as string, tabs as object
|
||||
params = ""
|
||||
end if
|
||||
|
||||
feeds.Push(m.tabs[tabName](authorId, author, params))
|
||||
if tabsTitles <> invalid and tabsTitles.DoesExist(tabName)
|
||||
title = tabsTitles[tabName]
|
||||
else
|
||||
title = ""
|
||||
end if
|
||||
|
||||
feeds.Push(m.tabs[tabName](authorId, author, title, params))
|
||||
end if
|
||||
end for
|
||||
|
||||
@@ -153,18 +166,25 @@ function OnDispose()
|
||||
m.subscribeTask.cancel = true
|
||||
m.subscribeTask = invalid
|
||||
end if
|
||||
if m.fetchSubscriptionStatusTask <> invalid
|
||||
m.fetchSubscriptionStatusTask.cancel = true
|
||||
m.fetchSubscriptionStatusTask = invalid
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnSubscribeButtonSelected()
|
||||
if m.subscribeTask <> invalid
|
||||
m.subscribeTask.cancel = true
|
||||
end if
|
||||
if m.fetchSubscriptionStatusTask <> invalid
|
||||
m.fetchSubscriptionStatusTask.cancel = true
|
||||
end if
|
||||
|
||||
isSubbed = IsSubscribed()
|
||||
m.subscribeTask = AsyncTask.Start(Tasks.SubscribeTask, {
|
||||
channelView: m.top
|
||||
invidious: m.invidious
|
||||
ucid: m.authorId
|
||||
subscribe: not isSubbed
|
||||
subscribe: not m.top.isSubscribed
|
||||
})
|
||||
end function
|
||||
|
||||
@@ -197,26 +217,47 @@ end function
|
||||
|
||||
function InitializeTabs()
|
||||
m.tabs = {
|
||||
"videos": function(authorId as string, author as string, params as string) as object
|
||||
return CreateChannelFeed("Videos", "channel_videos", authorId, author, params)
|
||||
"videos": function(authorId as string, author as string, title as string, params as string) as object
|
||||
if StringUtils.IsNullOrEmpty(title)
|
||||
title = "Videos"
|
||||
end if
|
||||
return CreateChannelFeed(title, "channel_videos", authorId, author, params)
|
||||
end function
|
||||
"shorts": function(authorId as string, author as string, params as string) as object
|
||||
return CreateChannelFeed("Shorts", "channel_shorts", authorId, author, params)
|
||||
"shorts": function(authorId as string, author as string, title as string, params as string) as object
|
||||
if StringUtils.IsNullOrEmpty(title)
|
||||
title = "Shorts"
|
||||
end if
|
||||
return CreateChannelFeed(title, "channel_shorts", authorId, author, params)
|
||||
end function
|
||||
"streams": function(authorId as string, author as string, params as string) as object
|
||||
return CreateChannelFeed("Live", "channel_streams", authorId, author, params)
|
||||
"streams": function(authorId as string, author as string, title as string, params as string) as object
|
||||
if StringUtils.IsNullOrEmpty(title)
|
||||
title = "Live"
|
||||
end if
|
||||
return CreateChannelFeed(title, "channel_streams", authorId, author, params)
|
||||
end function
|
||||
"releases": function(authorId as string, author as string, params as string) as object
|
||||
return CreateChannelFeed("Releases", "channel_releases", authorId, author, params)
|
||||
"releases": function(authorId as string, author as string, title as string, params as string) as object
|
||||
if StringUtils.IsNullOrEmpty(title)
|
||||
title = "Releases"
|
||||
end if
|
||||
return CreateChannelFeed(title, "channel_releases", authorId, author, params)
|
||||
end function
|
||||
"podcasts": function(authorId as string, author as string, params as string) as object
|
||||
return CreateChannelFeed("Podcasts", "channel_podcasts", authorId, author, params)
|
||||
"podcasts": function(authorId as string, author as string, title as string, params as string) as object
|
||||
if StringUtils.IsNullOrEmpty(title)
|
||||
title = "Podcasts"
|
||||
end if
|
||||
return CreateChannelFeed(title, "channel_podcasts", authorId, author, params)
|
||||
end function
|
||||
"playlists": function(authorId as string, author as string, params as string) as object
|
||||
return CreateChannelFeed("Playlists", "channel_playlists", authorId, author, params)
|
||||
"playlists": function(authorId as string, author as string, title as string, params as string) as object
|
||||
if StringUtils.IsNullOrEmpty(title)
|
||||
title = "Playlists"
|
||||
end if
|
||||
return CreateChannelFeed(title, "channel_playlists", authorId, author, params)
|
||||
end function
|
||||
"courses": function(authorId as string, author as string, params as string) as object
|
||||
return CreateChannelFeed("Courses", "channel_courses", authorId, author, params)
|
||||
"courses": function(authorId as string, author as string, title as string, params as string) as object
|
||||
if StringUtils.IsNullOrEmpty(title)
|
||||
title = "Courses"
|
||||
end if
|
||||
return CreateChannelFeed(title, "channel_courses", authorId, author, params)
|
||||
end function
|
||||
}
|
||||
end function
|
||||
@@ -323,25 +364,10 @@ function IsLoggedIn() as boolean
|
||||
return m.invidious.authToken <> invalid
|
||||
end function
|
||||
|
||||
function IsSubscribed() as boolean
|
||||
authorId = m.top.authorId
|
||||
if StringUtils.IsNullOrEmpty(authorId)
|
||||
return false
|
||||
end if
|
||||
|
||||
subscriptions = m.invidious.subscriptions
|
||||
if subscriptions = invalid
|
||||
return false
|
||||
end if
|
||||
if not subscriptions.DoesExist(authorId)
|
||||
return false
|
||||
end if
|
||||
return subscriptions[authorId]
|
||||
end function
|
||||
|
||||
function OnAuthorIdChange()
|
||||
SetSubscribeButtonVisibility()
|
||||
OnSubscriptionChanged()
|
||||
FetchSubscriptionStatus()
|
||||
end function
|
||||
|
||||
function SetSubscribeButtonVisibility()
|
||||
@@ -353,9 +379,34 @@ function SetSubscribeButtonVisibility()
|
||||
end if
|
||||
end function
|
||||
|
||||
function FetchSubscriptionStatus() as void
|
||||
if not IsLoggedIn()
|
||||
return
|
||||
end if
|
||||
|
||||
authorId = m.top.authorId
|
||||
if StringUtils.IsNullOrEmpty(authorId)
|
||||
return
|
||||
end if
|
||||
|
||||
if m.fetchSubscriptionStatusTask <> invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.fetchSubscriptionStatusTask = AsyncTask.Start(Tasks.FetchSubscriptionStatusTask, {
|
||||
channelView: m.top
|
||||
ucid: authorId
|
||||
authToken: m.invidious.authToken
|
||||
invidious: m.invidious
|
||||
})
|
||||
end function
|
||||
|
||||
function OnFetchSubscriptionStatusResult(result as object) as void
|
||||
m.fetchSubscriptionStatusTask = invalid
|
||||
end function
|
||||
|
||||
function OnSubscriptionChanged()
|
||||
isSubbed = IsSubscribed()
|
||||
if isSubbed
|
||||
if m.top.isSubscribed
|
||||
m.subscribeButton.text = Tr(Locale.Buttons.Unsubscribe)
|
||||
else
|
||||
m.subscribeButton.text = Tr(Locale.Buttons.Subscribe)
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
<interface>
|
||||
<field id="content" type="node" onChange="OnContentSet" />
|
||||
<field id="authorId" type="string" onChange="OnAuthorIdChange" />
|
||||
<field id="isSubscribed" type="boolean" onChange="OnSubscriptionChanged" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
<field id="invidious" type="node" bind="/Invidious" />
|
||||
<field id="preferences" type="node" bind="/Preferences" />
|
||||
<field id="bookmarksService" type="node" bind="/BookmarksService" />
|
||||
<function name="ShowSortDialog" />
|
||||
</interface>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import "pkg:/components/Services/Innertube/InnertubeService.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||
|
||||
@asynctask
|
||||
function FetchSubscriptionStatusTask(input as object) as object
|
||||
channelView = input.channelView
|
||||
ucid = input.ucid
|
||||
invidiousNode = input.invidious
|
||||
authToken = input.authToken
|
||||
|
||||
if m.top.cancel
|
||||
return invalid
|
||||
end if
|
||||
|
||||
isInnertubeProfile = authToken.profileNode.type = "youtube"
|
||||
if isInnertubeProfile
|
||||
subscriptionStatus = InnertubeService.GetSubscriptionStatusForChannel(ucid, {
|
||||
cancellation: m.top.cancellation
|
||||
accessToken: authToken.token
|
||||
onBehalfOfUser: authToken.activeIdentifyToken
|
||||
})
|
||||
|
||||
if subscriptionStatus.error <> invalid
|
||||
LogError("Failed to fetch subscription status:", subscriptionStatus.error)
|
||||
return invalid
|
||||
end if
|
||||
channelView.isSubscribed = subscriptionStatus.isSubscribed
|
||||
else
|
||||
service = new Invidious.InvidiousService(invidiousNode)
|
||||
subscriptionsRequest = service.GetSubscriptions(m.top.cancellation)
|
||||
if not subscriptionsRequest.IsSuccess()
|
||||
error = subscriptionsRequest.ErrorMessage()
|
||||
LogError("Failed to fetch subscriptions:", error)
|
||||
return invalid
|
||||
end if
|
||||
subscriptions = subscriptionsRequest.Json()
|
||||
|
||||
isSubscribed = false
|
||||
for each subscription in subscriptions
|
||||
if subscription.authorId = ucid
|
||||
isSubscribed = true
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
channelView.isSubscribed = isSubscribed
|
||||
end if
|
||||
|
||||
return invalid
|
||||
end function
|
||||
@@ -2,6 +2,7 @@ import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||
|
||||
@asynctask
|
||||
function SubscribeTask(input as object) as object
|
||||
channelView = input.channelView
|
||||
invidiousNode = input.invidious
|
||||
ucid = input.ucid
|
||||
subscribe = input.subscribe
|
||||
@@ -13,23 +14,17 @@ function SubscribeTask(input as object) as object
|
||||
service = new Invidious.InvidiousService(invidiousNode)
|
||||
|
||||
if subscribe
|
||||
response = service.Subscribe(ucid)
|
||||
response = service.Subscribe(ucid, m.top.cancellation)
|
||||
else
|
||||
response = service.Unsubscribe(ucid)
|
||||
response = service.Unsubscribe(ucid, m.top.cancellation)
|
||||
end if
|
||||
|
||||
if not response.IsSuccess()
|
||||
error = response.ErrorMessage()
|
||||
LogError("Failed to subscribe/unsubscribe to channel:", error)
|
||||
return {
|
||||
success: false
|
||||
error: error
|
||||
}
|
||||
return invalid
|
||||
end if
|
||||
|
||||
invidiousNode.refreshSubscribtions = true
|
||||
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
channelView.isSubscribed = subscribe
|
||||
return invalid
|
||||
end function
|
||||
@@ -9,6 +9,7 @@
|
||||
<field id="loadingBitmapUri" type="uri" alias="Poster.loadingBitmapUri" />
|
||||
<field id="failedBitmapUri" type="uri" alias="Poster.failedBitmapUri" />
|
||||
<field id="loadStatus" type="string" alias="Poster.loadStatus" />
|
||||
<field id="blendColor" type="color" alias="Poster.blendColor" />
|
||||
|
||||
<field id="maskUri" type="uri" value="pkg:/images/white-circle.png" alias="MaskGroup.maskuri" />
|
||||
<field id="maskSize" type="vector2d" alias="MaskGroup.maskSize" />
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<component name="BackendTypeContentNode" extends="ContentNode">
|
||||
<interface>
|
||||
<field id="backendLogoUri" type="uri" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -18,6 +18,7 @@
|
||||
<field id="subCountText" type="string" />
|
||||
<field id="tabs" type="array" />
|
||||
<field id="tabsParams" type="assocarray" />
|
||||
<field id="tabsTitles" type="assocarray" />
|
||||
<field id="thumbnail" type="string" />
|
||||
<field id="videoCount" type="integer" />
|
||||
<field id="videoCountText" type="string" />
|
||||
|
||||
@@ -43,5 +43,6 @@
|
||||
<field id="statsText" type="string" />
|
||||
<!-- videoId is Mix continuation (playlistId starts with "RD") -->
|
||||
<field id="videoId" type="string" />
|
||||
<field id="lines" type="stringarray" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -54,24 +54,19 @@ function PlaylistContentTask(input as object) as object
|
||||
}
|
||||
end if
|
||||
|
||||
' TODO:P2 To remove after https://github.com/iv-org/invidious/pull/5116
|
||||
if IsString(metadata["mixId"]) and IsArray(metadata["videos"])
|
||||
videos = metadata["videos"]
|
||||
for i = 0 to videos.Count() - 1
|
||||
thumbnails = videos[i].videoThumbnails
|
||||
if thumbnails.Count() = 1 and IsArray(thumbnails[0])
|
||||
videos[i].videoThumbnails = thumbnails[0]
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
beforeChildCount = contentNode.getChildCount()
|
||||
InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance)
|
||||
childCount = contentNode.getChildCount()
|
||||
afterChildCount = contentNode.getChildCount()
|
||||
|
||||
videoCount = ValidInt(metadata.videoCount)
|
||||
|
||||
hasContinuation = not StringUtils.IsNullOrEmpty(metadata.continuation)
|
||||
if (hadContinuation and not hasContinuation) or (metadata.videos.Count() = 0 or childCount >= videoCount)
|
||||
|
||||
noMoreContinuation = hadContinuation and not hasContinuation
|
||||
noVideosAdded = afterChildCount = beforeChildCount
|
||||
reachedVideoCount = videoCount <> -1 and afterChildCount >= videoCount
|
||||
|
||||
if noMoreContinuation or noVideosAdded or reachedVideoCount
|
||||
contentNode.loadState = FeedLoadState.Loaded
|
||||
return {
|
||||
success: true
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/TimeUtils.bs"
|
||||
|
||||
function HasValidAccessToken(_unused as dynamic) as boolean
|
||||
serverType = m.top.type
|
||||
accessToken = m.top.accessToken
|
||||
if StringUtils.IsNullOrEmpty(accessToken)
|
||||
return false
|
||||
end if
|
||||
|
||||
if serverType = "invidious"
|
||||
return true
|
||||
end if
|
||||
|
||||
nowSeconds = TimeUtils.Now().AsSeconds()
|
||||
expiresTimestamp = m.top.expiresTimestamp
|
||||
|
||||
' We should refresh the token if it's about to expire in 30 minutes
|
||||
' Although the current token might be valid, we can let current request
|
||||
' wait for the new token
|
||||
shouldRefreshToken = expiresTimestamp < nowSeconds + 60 * 30
|
||||
|
||||
if shouldRefreshToken
|
||||
RefreshAccessToken()
|
||||
end if
|
||||
|
||||
return not shouldRefreshToken
|
||||
end function
|
||||
|
||||
function RefreshAccessToken() as void
|
||||
if m.refreshTokenTask <> invalid
|
||||
return
|
||||
end if
|
||||
|
||||
if m.profilesService = invalid
|
||||
m.profilesService = m.top.getScene().findNode("ProfilesService")
|
||||
end if
|
||||
|
||||
LogInfo("Refreshing access token for profile:", m.top.username)
|
||||
m.refreshTokenTask = AsyncTask.Start(Tasks.ProfileRefreshTokenTask, {
|
||||
profile: m.top
|
||||
profilesService: m.profilesService
|
||||
accessTokenObject: {
|
||||
clientId: m.top.clientId
|
||||
clientSecret: m.top.clientSecret
|
||||
refreshToken: m.top.refreshToken
|
||||
}
|
||||
}, OnProfileRefreshTokenTaskResult)
|
||||
end function
|
||||
|
||||
function OnProfileRefreshTokenTaskResult(output as object) as void
|
||||
m.refreshTokenTask = invalid
|
||||
end function
|
||||
@@ -8,6 +8,8 @@
|
||||
<field id="accessToken" type="string" />
|
||||
|
||||
<!-- Innertube fields -->
|
||||
<field id="activeIdentifyToken" type="string" />
|
||||
<field id="thumbnail" type="uri" />
|
||||
<field id="refreshToken" type="string" />
|
||||
<field id="scope" type="string" />
|
||||
<field id="tokenType" type="string" />
|
||||
@@ -17,5 +19,7 @@
|
||||
<field id="clientSecret" type="string" />
|
||||
|
||||
<field id="color" type="color" />
|
||||
|
||||
<function name="HasValidAccessToken" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -0,0 +1,25 @@
|
||||
import "pkg:/components/Services/Innertube/InnertubeService.bs"
|
||||
import "pkg:/source/utils/ErrorUtils.bs"
|
||||
|
||||
@asynctask
|
||||
function ProfileRefreshTokenTask(input as object) as object
|
||||
profileNode = input.profile
|
||||
accessTokenObject = input.accessTokenObject
|
||||
profilesService = input.profilesService
|
||||
try
|
||||
if InnertubeService.AuthRefreshAccessToken(accessTokenObject)
|
||||
profileNode.expiresIn = accessTokenObject.expiresIn
|
||||
profileNode.expiresTimestamp = accessTokenObject.expiresTimestamp
|
||||
profileNode.accessToken = accessTokenObject.accessToken
|
||||
profilesService@.SaveUserProfilesToRegistry()
|
||||
else
|
||||
LogError("Failed to refresh access token")
|
||||
profileNode.accessToken = invalid
|
||||
end if
|
||||
catch error
|
||||
LogError("Failed to refresh access token:", ErrorUtils.Format(error))
|
||||
profileNode.accessToken = invalid
|
||||
end try
|
||||
|
||||
return invalid
|
||||
end function
|
||||
@@ -22,5 +22,10 @@
|
||||
<field id="title" type="string" />
|
||||
<field id="videoId" type="string" />
|
||||
<field id="viewCountText" type="string" />
|
||||
<!-- lines is from the tv client (author name + video info) -->
|
||||
<field id="lines" type="stringarray" />
|
||||
<!-- videoInfo is from web client -->
|
||||
<field id="videoInfo" type="string" />
|
||||
<field id="percentDurationWatched" type="float" />
|
||||
</interface>
|
||||
</component>
|
||||
File renamed without changes.
+2
-2
@@ -1,4 +1,4 @@
|
||||
<component name="LoginDialog" extends="StandardDialog" initialFocus="buttonArea" includes="AutoBind">
|
||||
<component name="InvidiousLoginDialog" extends="StandardDialog" initialFocus="buttonArea" includes="AutoBind">
|
||||
<interface>
|
||||
<field id="webServer" type="node" bind="/WebServer" />
|
||||
<field id="invidious" type="node" bind="/Invidious" />
|
||||
@@ -22,7 +22,7 @@
|
||||
showDivider="false">
|
||||
<Label
|
||||
id="scanLabel"
|
||||
text="Scan the QR Code"
|
||||
text="Scan the QR code"
|
||||
horizAlign="center"
|
||||
wrap="true" width="400">
|
||||
<Font role="font" uri="font:SystemFontFile" size="24" />
|
||||
@@ -0,0 +1,27 @@
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
namespace YouTubeLoginAccountItemUtils
|
||||
|
||||
function CreateProfileContentNode(accountItem as object, accessToken as object) as object
|
||||
profile = CreateObject("roSGNode", "ProfileContentNode")
|
||||
profile.type = "youtube"
|
||||
profile.serverUrl = "http://127.0.0.1:8888/playlet-invidious-backend"
|
||||
username = accountItem.channelHandle
|
||||
if StringUtils.IsNullOrEmpty(username)
|
||||
username = accountItem.accountByline
|
||||
end if
|
||||
profile.username = username
|
||||
profile.activeIdentifyToken = accountItem.activeIdentifyToken
|
||||
profile.thumbnail = accountItem.accountPhoto
|
||||
profile.accessToken = accessToken.accessToken
|
||||
profile.refreshToken = accessToken.refreshToken
|
||||
profile.scope = accessToken.scope
|
||||
profile.tokenType = accessToken.tokenType
|
||||
profile.expiresIn = accessToken.expiresIn
|
||||
profile.expiresTimestamp = accessToken.expiresTimestamp
|
||||
profile.clientId = accessToken.clientId
|
||||
profile.clientSecret = accessToken.clientSecret
|
||||
|
||||
return profile
|
||||
end function
|
||||
end namespace
|
||||
@@ -0,0 +1,96 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Screens/ProfileScreen/YouTubeAccountSelectionView/YouTubeAccountSelectionViewUtils.bs"
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/source/utils/ErrorUtils.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.qrCode = m.top.findNode("QrCodePoster")
|
||||
|
||||
codeLabel = m.top.findNode("codeLabel")
|
||||
if codeLabel <> invalid
|
||||
codeLabel = codeLabel.getChild(0)
|
||||
if codeLabel <> invalid
|
||||
codeFont = m.top.findNode("codeFont")
|
||||
codeLabel.font = codeFont
|
||||
end if
|
||||
end if
|
||||
|
||||
m.top.width = "920"
|
||||
m.top.observeFieldScoped("buttonSelected", FuncName(Close))
|
||||
m.top.observeFieldScoped("wasClosed", FuncName(OnWasClosed))
|
||||
scanLabel = m.top.findNode("scanLabel")
|
||||
scanLabel.text = Tr(Locale.Dialogs.ScanTheQrCode)
|
||||
linkInstructionLabel = m.top.findNode("linkInstructionLabel")
|
||||
linkInstructionLabel.text = Tr(Locale.Dialogs.OpenLinkAndEnterFollowingCode).replace("%1", `'https://yt.be/activate'`)
|
||||
end function
|
||||
|
||||
function OnNodeReady()
|
||||
m.task = AsyncTask.Start(Tasks.YouTubeLoginTask, {
|
||||
dialog: m.top
|
||||
profilesService: m.top.profilesService
|
||||
}, OnYouTubeLoginTaskResult)
|
||||
end function
|
||||
|
||||
function OnYouTubeLoginTaskResult(output as object) as void
|
||||
m.task = invalid
|
||||
|
||||
if output.cancelled
|
||||
Close()
|
||||
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)
|
||||
DialogUtils.ShowDialogEx({
|
||||
message: error
|
||||
title: Tr(Locale.Generic.Error)
|
||||
large: true
|
||||
})
|
||||
return
|
||||
end if
|
||||
|
||||
accounts = output.result.accounts
|
||||
accessToken = output.result.accessToken
|
||||
' if accounts is invalid, we're going to assume a profile is already created.
|
||||
if accounts = invalid or accessToken = invalid
|
||||
Close()
|
||||
return
|
||||
end if
|
||||
|
||||
' The accountSelectionView will take over the creation of the profile.
|
||||
accountSelectionView = YouTubeAccountSelectionViewUtils.Open(m.top.appController)
|
||||
accountSelectionView.accessToken = accessToken
|
||||
accountSelectionView.accounts = accounts
|
||||
Close()
|
||||
end function
|
||||
|
||||
function OnCodeSet(event as object)
|
||||
code = event.getData()
|
||||
m.qrCode.text = code
|
||||
end function
|
||||
|
||||
function Close()
|
||||
m.top.close = true
|
||||
end function
|
||||
|
||||
function OnWasClosed()
|
||||
if m.task <> invalid
|
||||
m.task.cancel = true
|
||||
m.task = invalid
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnUrlSet()
|
||||
m.qrCode.text = m.top.url
|
||||
end function
|
||||
@@ -0,0 +1,51 @@
|
||||
<component name="YouTubeLoginDialog" extends="StandardDialog" initialFocus="buttonArea" includes="AutoBind">
|
||||
<interface>
|
||||
<field id="profilesService" type="node" bind="/ProfilesService" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
<field id="code" type="string" alias="codeLabel.text" />
|
||||
<field id="url" type="string" onChange="OnUrlSet" />
|
||||
<field id="alwaysOnTop" type="boolean" />
|
||||
</interface>
|
||||
<children>
|
||||
<Font id="codeFont" uri="font:MediumSystemFontFile" size="36" />
|
||||
|
||||
<StdDlgTitleArea primaryTitle="Login to YouTube" />
|
||||
<StdDlgContentArea>
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<StdDlgTextItem id="linkInstructionLabel" text="Open the link 'https://yt.be/activate' and enter the following code:" />
|
||||
<StdDlgTextItem id="codeLabel" text="Loading..." />
|
||||
</StdDlgContentArea>
|
||||
<StdDlgButtonArea id="buttonArea">
|
||||
<StdDlgButton text="OK" />
|
||||
</StdDlgButtonArea>
|
||||
<StdDlgSideCardArea
|
||||
id="sideCarArea"
|
||||
horizAlign="right"
|
||||
width="400"
|
||||
extendToDialogEdge="false"
|
||||
showDivider="false">
|
||||
<Label
|
||||
id="scanLabel"
|
||||
text="Scan the QR code"
|
||||
horizAlign="center"
|
||||
wrap="true" width="400">
|
||||
<Font role="font" uri="font:SystemFontFile" size="24" />
|
||||
</Label>
|
||||
<QrCodePoster
|
||||
id="QrCodePoster"
|
||||
width="300"
|
||||
height="300"
|
||||
loadWidth="300"
|
||||
loadHeight="300"
|
||||
padding="10"
|
||||
translation="[50, 50]" />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<Label text="https://yt.be/activate"
|
||||
horizAlign="center"
|
||||
width="400"
|
||||
translation="[0, 380]">
|
||||
<Font role="font" uri="font:MediumSystemFontFile" size="18" />
|
||||
</Label>
|
||||
</StdDlgSideCardArea>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,83 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Dialog/YouTubeLoginAccountItemUtils.bs"
|
||||
import "pkg:/components/Services/Innertube/InnertubeService.bs"
|
||||
import "pkg:/source/utils/CancellationUtils.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
|
||||
@asynctask
|
||||
function YouTubeLoginTask(input as object) as object
|
||||
profilesNode = input.profilesService
|
||||
dialogNode = input.dialog
|
||||
|
||||
cancellation = m.top.cancellation
|
||||
' TODO:P2 cache client identity
|
||||
authCode = InnertubeService.AuthGetCode(cancellation)
|
||||
|
||||
if CancellationUtils.IsCancelled(cancellation)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if authCode.error <> invalid
|
||||
return {
|
||||
success: false
|
||||
error: authCode.error
|
||||
}
|
||||
end if
|
||||
|
||||
url = InnertubeService.AuthGetActivationUrl(authCode)
|
||||
|
||||
LogInfo("Login url:", url)
|
||||
|
||||
dialogNode.url = url
|
||||
dialogNode.code = authCode.userCode
|
||||
|
||||
accessToken = InnertubeService.AuthPollForAccessToken(authCode, cancellation)
|
||||
|
||||
if CancellationUtils.IsCancelled(cancellation)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if accessToken.error <> invalid
|
||||
return {
|
||||
success: false
|
||||
error: accessToken.error
|
||||
}
|
||||
end if
|
||||
|
||||
accounts = InnertubeService.AuthListAccounts(accessToken.accessToken, cancellation)
|
||||
|
||||
if CancellationUtils.IsCancelled(cancellation)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if IsAssociativeArray(accounts) and accounts.error <> invalid
|
||||
return {
|
||||
success: false
|
||||
error: accounts.error
|
||||
}
|
||||
end if
|
||||
|
||||
if not IsArray(accounts) or accounts.Count() = 0
|
||||
return {
|
||||
success: false
|
||||
error: Tr(Locale.Dialogs.NoValidAccountsFound)
|
||||
}
|
||||
end if
|
||||
|
||||
' If there is only one account, we can skip the selection screen
|
||||
' and just create a profile
|
||||
if accounts.Count() = 1
|
||||
profile = YouTubeLoginAccountItemUtils.CreateProfileContentNode(accounts[0], accessToken)
|
||||
profilesNode@.LoginWithProfile(profile)
|
||||
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
end if
|
||||
|
||||
return {
|
||||
success: true
|
||||
accounts: accounts
|
||||
accessToken: accessToken
|
||||
}
|
||||
end function
|
||||
@@ -54,18 +54,29 @@ function StartWebServer()
|
||||
m.dialServer@.StartServer()
|
||||
end function
|
||||
|
||||
function ShowAnnouncement()
|
||||
DialogUtils.ShowDialogOnce({
|
||||
messageId: "1736288537"
|
||||
title: "Announcement - Playlet backend"
|
||||
function ShowAnnouncement() as void
|
||||
dialog = DialogUtils.ShowDialogOnce({
|
||||
messageId: "1747362859"
|
||||
title: "Announcement - YouTube account support"
|
||||
message: [
|
||||
"An experimental built-in backend has been added to Playlet."
|
||||
"This allows you to access YouTube content without the need for an Invidious instance."
|
||||
"To use it, go to the Settings > Invidious > Instance and set the field to empty (Edit, and delete the url)."
|
||||
"Please note that it's missing some features and may not work as expected."
|
||||
"Thank you for using Playlet!"
|
||||
"YouTube account support is now available in Playlet!"
|
||||
`Subscriptions, playlists, watch history and "Recommended" are now available in the app.`
|
||||
"If you encounter any issues, please report them on GitHub."
|
||||
"https://github.com/iBicha/playlet/issues"
|
||||
"Thank you."
|
||||
]
|
||||
alwaysOnTop: true
|
||||
marginWidth: 180
|
||||
})
|
||||
|
||||
if dialog = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.scene.signalBeacon("AppDialogInitiate")
|
||||
m.top.observeField("wasClosed", FuncName(OnAnnouncementDialogClosed))
|
||||
end function
|
||||
|
||||
function OnAnnouncementDialogClosed()
|
||||
m.scene.signalBeacon("AppDialogComplete")
|
||||
end function
|
||||
@@ -51,19 +51,28 @@ function StartWebServer()
|
||||
m.dialServer.callfunc("StartServer", invalid)
|
||||
end function
|
||||
|
||||
function ShowAnnouncement()
|
||||
DialogUtils_ShowDialogOnce({
|
||||
messageId: "1736288537"
|
||||
title: "Announcement - Playlet backend"
|
||||
function ShowAnnouncement() as void
|
||||
dialog = DialogUtils_ShowDialogOnce({
|
||||
messageId: "1747362859"
|
||||
title: "Announcement - YouTube account support"
|
||||
message: [
|
||||
"An experimental built-in backend has been added to Playlet."
|
||||
"This allows you to access YouTube content without the need for an Invidious instance."
|
||||
"To use it, go to the Settings > Invidious > Instance and set the field to empty (Edit, and delete the url)."
|
||||
"Please note that it's missing some features and may not work as expected."
|
||||
"Thank you for using Playlet!"
|
||||
"YouTube account support is now available in Playlet!"
|
||||
"Subscriptions, playlists, watch history and " + chr(34) + "Recommended" + chr(34) + " are now available in the app."
|
||||
"If you encounter any issues, please report them on GitHub."
|
||||
"https://github.com/iBicha/playlet/issues"
|
||||
"Thank you."
|
||||
]
|
||||
alwaysOnTop: true
|
||||
marginWidth: 180
|
||||
})
|
||||
if dialog = invalid
|
||||
return
|
||||
end if
|
||||
m.scene.signalBeacon("AppDialogInitiate")
|
||||
m.top.observeField("wasClosed", FuncName(OnAnnouncementDialogClosed))
|
||||
end function
|
||||
|
||||
function OnAnnouncementDialogClosed()
|
||||
m.scene.signalBeacon("AppDialogComplete")
|
||||
end function
|
||||
'//# sourceMappingURL=./MainScene.brs.map
|
||||
@@ -47,6 +47,7 @@
|
||||
<BookmarksService id="BookmarksService" />
|
||||
<SearchHistory id="SearchHistory" />
|
||||
<ProfilesService id="ProfilesService" />
|
||||
<Innertube id="Innertube" />
|
||||
<Invidious id="Invidious" />
|
||||
<PlayletWebServer id="WebServer" port="8888" />
|
||||
<DialServer id="DialServer" />
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
<VideoQueue id="VideoQueue"
|
||||
appController="bind:/AppController"
|
||||
videoContainer="bind:../VideoContainer"
|
||||
innertube="bind:../Innertube"
|
||||
invidious="bind:../Invidious"
|
||||
notifications="bind:../Notifications"
|
||||
preferences="bind:../Preferences"
|
||||
@@ -70,6 +71,7 @@
|
||||
<ProfilesService id="ProfilesService"
|
||||
invidious="bind:../Invidious" />
|
||||
|
||||
<Innertube id="Innertube" />
|
||||
<Invidious id="Invidious"
|
||||
webServer="bind:../WebServer"
|
||||
applicationInfo="bind:../ApplicationInfo"
|
||||
@@ -81,6 +83,7 @@
|
||||
port="8888"
|
||||
appController="bind:/AppController"
|
||||
applicationInfo="bind:../ApplicationInfo"
|
||||
innertube="bind:../Innertube"
|
||||
invidious="bind:../Invidious"
|
||||
profilesService="bind:../ProfilesService"
|
||||
preferences="bind:../Preferences"
|
||||
|
||||
@@ -18,6 +18,7 @@ function InitializeBindings()
|
||||
"VideoQueue": {
|
||||
"appController": "/AppController",
|
||||
"videoContainer": "../VideoContainer",
|
||||
"innertube": "../Innertube",
|
||||
"invidious": "../Invidious",
|
||||
"notifications": "../Notifications",
|
||||
"preferences": "../Preferences",
|
||||
@@ -38,6 +39,7 @@ function InitializeBindings()
|
||||
"WebServer": {
|
||||
"appController": "/AppController",
|
||||
"applicationInfo": "../ApplicationInfo",
|
||||
"innertube": "../Innertube",
|
||||
"invidious": "../Invidious",
|
||||
"profilesService": "../ProfilesService",
|
||||
"preferences": "../Preferences",
|
||||
|
||||
@@ -42,8 +42,7 @@
|
||||
<AppVersionLabel
|
||||
fontUri="font:BoldSystemFontFile"
|
||||
fontSize="16"
|
||||
translation="[0, 48]"
|
||||
/>
|
||||
translation="[0, 48]" />
|
||||
</Poster>
|
||||
|
||||
<MarkupList
|
||||
|
||||
@@ -23,13 +23,28 @@ function OnCurrentProfile() as void
|
||||
return
|
||||
end if
|
||||
|
||||
username = currentProfile.username
|
||||
if not StringUtils.IsNullOrEmpty(username)
|
||||
m.letterLabel.text = UCase(username.Left(1))
|
||||
else
|
||||
thumbnail = currentProfile.thumbnail
|
||||
if not StringUtils.IsNullOrEmpty(thumbnail)
|
||||
m.circlePosterInner.uri = thumbnail
|
||||
' bs:disable-next-line LINT3023
|
||||
m.circlePosterInner.blendColor = "#FFFFFFFF"
|
||||
m.letterLabel.text = ""
|
||||
else
|
||||
m.circlePosterInner.uri = "pkg:/images/white-circle.png"
|
||||
m.circlePosterInner.blendColor = currentProfile.color
|
||||
|
||||
username = currentProfile.username
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(username)
|
||||
letter = username.Left(1)
|
||||
if letter = "@" and Len(username) > 1
|
||||
letter = username.Mid(1, 1)
|
||||
end if
|
||||
m.letterLabel.text = UCase(letter)
|
||||
else
|
||||
m.letterLabel.text = ""
|
||||
end if
|
||||
end if
|
||||
m.circlePosterInner.blendColor = currentProfile.color
|
||||
|
||||
m.circlePoster.visible = true
|
||||
m.buttonIcon.visible = false
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
height="40"
|
||||
blendColor="#DDDDDDFF"
|
||||
uri="pkg:/images/white-circle.png">
|
||||
<Poster
|
||||
<CirclePoster
|
||||
id="circlePosterInner"
|
||||
width="36"
|
||||
height="36"
|
||||
@@ -27,7 +27,7 @@
|
||||
horizAlign="center">
|
||||
<Font role="font" uri="font:SystemFontFile" size="24" />
|
||||
</Label>
|
||||
</Poster>
|
||||
</CirclePoster>
|
||||
</Poster>
|
||||
</children>
|
||||
</component>
|
||||
@@ -1,9 +1,12 @@
|
||||
import "pkg:/source/utils/MathUtils.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/TimeUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.durationRect = m.top.FindNode("durationRect")
|
||||
m.durationLabel = m.top.FindNode("durationLabel")
|
||||
m.progressRect = m.top.FindNode("progressRect")
|
||||
end function
|
||||
|
||||
function OnContentSet() as void
|
||||
@@ -15,9 +18,27 @@ function OnContentSet() as void
|
||||
|
||||
m.top.title = content.title
|
||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||
m.top.author = content._author
|
||||
author = content._author
|
||||
if not StringUtils.IsNullOrEmpty(author)
|
||||
videoInfo = content.videoInfo
|
||||
if not StringUtils.IsNullOrEmpty(videoInfo)
|
||||
author += `\n` + videoInfo
|
||||
end if
|
||||
else
|
||||
lines = content.lines
|
||||
if IsArray(lines) and lines.Count() > 0
|
||||
author = lines[0]
|
||||
if lines.Count() > 1
|
||||
author += `\n` + lines[1]
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
m.top.author = author
|
||||
|
||||
m.top.thumbnailUri = content.thumbnail
|
||||
|
||||
m.top.percentDurationWatched = content.percentDurationWatched
|
||||
|
||||
SetDurationText(content.lengthText)
|
||||
end function
|
||||
|
||||
@@ -43,3 +64,12 @@ function SetDurationText(text as string) as void
|
||||
rect.width = size.width + 16
|
||||
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
|
||||
end function
|
||||
|
||||
function OnPercentDurationWatched() as void
|
||||
if m.progressRect = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
percent = MathUtils.Clamp(m.top.percentDurationWatched, 0, 100) / 100.0
|
||||
m.progressRect.scale = [percent, 1]
|
||||
end function
|
||||
@@ -6,6 +6,7 @@
|
||||
<field id="thumbnailUri" type="uri" alias="thumbnailPoster.uri" />
|
||||
<field id="duration" type="string" alias="durationLabel.text" />
|
||||
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
|
||||
<field id="percentDurationWatched" type="float" onChange="OnPercentDurationWatched" />
|
||||
</interface>
|
||||
<children>
|
||||
<Poster
|
||||
@@ -29,6 +30,14 @@
|
||||
font="font:SmallestSystemFont"
|
||||
translation="[8, 0]" />
|
||||
</Rectangle>
|
||||
<Rectangle
|
||||
id="progressRect"
|
||||
width="190"
|
||||
height="5"
|
||||
color="#FF0000"
|
||||
translation="[0, 102]"
|
||||
scale="[0, 1]">
|
||||
</Rectangle>
|
||||
|
||||
</Poster>
|
||||
|
||||
@@ -44,8 +53,9 @@
|
||||
<Label
|
||||
id="authorLabel"
|
||||
width="350"
|
||||
height="25"
|
||||
font="font:SmallestSystemFont" />
|
||||
font="font:SmallestSystemFont"
|
||||
maxLines="2"
|
||||
wrap="true" />
|
||||
</LayoutGroup>
|
||||
</children>
|
||||
|
||||
|
||||
@@ -43,8 +43,7 @@
|
||||
showRowLabel="[true]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
variableWidthItems="true"
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png"
|
||||
/>
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" />
|
||||
</Group>
|
||||
</children>
|
||||
</component>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
function OnContentSet() as void
|
||||
content = m.top.itemContent
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.backendName = content.title
|
||||
m.top.backendLogoUri = content.backendLogoUri
|
||||
end function
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<component name="BackendTypeRowListCell" extends="Group">
|
||||
<interface>
|
||||
<field id="itemContent" type="node" onChange="OnContentSet" />
|
||||
<field id="backendName" type="string" alias="BackendNameLabel.text" />
|
||||
<field id="backendLogoUri" type="uri" alias="BackendLogoPoster.uri" />
|
||||
</interface>
|
||||
|
||||
<children>
|
||||
<Group translation="[20,20]">
|
||||
<Poster
|
||||
id="BackendLogoPoster"
|
||||
width="160"
|
||||
height="160"
|
||||
translation="[20,20]">
|
||||
</Poster>
|
||||
<Label
|
||||
id="BackendNameLabel"
|
||||
width="200"
|
||||
horizAlign="center"
|
||||
translation="[0,240]">
|
||||
</Label>
|
||||
</Group>
|
||||
</children>
|
||||
</component>
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.rowList = m.top.FindNode("BackendRowList")
|
||||
m.rowList.ObserveField("rowItemSelected", FuncName(OnRowItemSelected))
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
|
||||
NodeSetFocus(m.rowList, true)
|
||||
end function
|
||||
|
||||
function OnKeyEvent(key as string, press as boolean) as boolean
|
||||
if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly
|
||||
' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play
|
||||
return false
|
||||
end if
|
||||
|
||||
if key = RemoteKeys.Back and press
|
||||
Close()
|
||||
return true
|
||||
end if
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
function Close()
|
||||
m.top.appController@.PopScreen()
|
||||
end function
|
||||
|
||||
function OnRowItemSelected(event as object) as void
|
||||
index = event.GetData()
|
||||
if index = invalid or index.count() <> 2
|
||||
LogWarn("Invalid index:", index)
|
||||
return
|
||||
end if
|
||||
|
||||
Close()
|
||||
|
||||
content = m.rowList.content
|
||||
|
||||
rowIndex = index[0]
|
||||
rowItemIndex = index[1]
|
||||
|
||||
row = content.GetChild(rowIndex)
|
||||
rowItem = row.GetChild(rowItemIndex)
|
||||
|
||||
m.top.selectedBackendType = rowItem.id
|
||||
end function
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<component name="BackendTypeSelectionView" extends="Group" includes="AutoBind,Focus">
|
||||
<interface>
|
||||
<field id="selectedBackendType" type="string" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
width="1280"
|
||||
height="720"
|
||||
color="#000000"
|
||||
opacity="0.5">
|
||||
</Rectangle>
|
||||
|
||||
<Rectangle
|
||||
width="720"
|
||||
height="420"
|
||||
translation="[280,150]"
|
||||
color="#242424">
|
||||
<Label
|
||||
width="720"
|
||||
horizAlign="center"
|
||||
translation="[0,38]"
|
||||
text="Select a service to login">
|
||||
<Font role="font" uri="font:SystemFontFile" size="24" />
|
||||
</Label>
|
||||
|
||||
<RowList
|
||||
id="BackendRowList"
|
||||
translation="[120,100]"
|
||||
numRows="2"
|
||||
rowitemSize="[[240,240]]"
|
||||
rowItemSpacing="[[0,0]]"
|
||||
itemSize="[500,500]"
|
||||
itemComponentName="BackendTypeRowListCell"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png">
|
||||
<ContentNode role="content">
|
||||
<ContentNode>
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<BackendTypeContentNode id="BackendTypeYouTube" title="YouTube" backendLogoUri="pkg:/images/youtube-logo.png" />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<BackendTypeContentNode id="BackendTypeInvidious" title="Invidious" backendLogoUri="pkg:/images/invidious-logo.png" />
|
||||
</ContentNode>
|
||||
</ContentNode>
|
||||
</RowList>
|
||||
</Rectangle>
|
||||
</children>
|
||||
</component>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
namespace BackendTypeSelectionViewUtils
|
||||
|
||||
function Open(appController as object) as object
|
||||
backendTypeSelectionView = CreateObject("roSGNode", "BackendTypeSelectionView")
|
||||
|
||||
appController@.PushScreen(backendTypeSelectionView)
|
||||
backendTypeSelectionView@.BindNode()
|
||||
return backendTypeSelectionView
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -1,2 +0,0 @@
|
||||
<component name="ProfileRowList" extends="RowList">
|
||||
</component>
|
||||
+33
-6
@@ -14,6 +14,7 @@ function OnContentSet() as void
|
||||
|
||||
if content.type = "login"
|
||||
m.top.circlePosterInnerUri = "pkg:/images/icons/user-200.png"
|
||||
m.top.backendTypePosterUri = ""
|
||||
' bs:disable-next-line LINT3023
|
||||
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
|
||||
m.top.letter = ""
|
||||
@@ -23,17 +24,43 @@ function OnContentSet() as void
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
|
||||
m.top.circlePosterInnerBlendColor = content.color
|
||||
username = content.username
|
||||
m.top.username = username
|
||||
if not StringUtils.IsNullOrEmpty(username)
|
||||
m.top.letter = UCase(username.Left(1))
|
||||
else
|
||||
|
||||
thumbnail = content.thumbnail
|
||||
if not StringUtils.IsNullOrEmpty(thumbnail)
|
||||
m.top.circlePosterInnerUri = thumbnail
|
||||
' bs:disable-next-line LINT3023
|
||||
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
|
||||
m.top.letter = ""
|
||||
else
|
||||
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
|
||||
m.top.circlePosterInnerBlendColor = content.color
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(username)
|
||||
letter = username.Left(1)
|
||||
if letter = "@" and Len(username) > 1
|
||||
letter = username.Mid(1, 1)
|
||||
end if
|
||||
m.top.letter = UCase(letter)
|
||||
else
|
||||
m.top.letter = ""
|
||||
end if
|
||||
end if
|
||||
m.top.serverUrl = content.serverUrl
|
||||
|
||||
m.top.crownVisible = content.isSelected
|
||||
|
||||
backendType = content.type
|
||||
if backendType = "invidious"
|
||||
m.top.serverUrl = content.serverUrl
|
||||
m.top.backendTypePosterUri = "pkg:/images/invidious-logo.png"
|
||||
else if backendType = "youtube"
|
||||
m.top.serverUrl = "YouTube"
|
||||
m.top.backendTypePosterUri = "pkg:/images/youtube-logo.png"
|
||||
else
|
||||
m.top.serverUrl = ""
|
||||
m.top.backendTypePosterUri = ""
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnRowListHasFocus()
|
||||
|
||||
+10
-4
@@ -6,6 +6,7 @@
|
||||
<field id="serverUrl" type="string" alias="ServerLabel.text" />
|
||||
<field id="circlePosterInnerUri" type="uri" alias="circlePosterInner.uri" />
|
||||
<field id="circlePosterInnerBlendColor" type="uri" alias="circlePosterInner.blendColor" />
|
||||
<field id="backendTypePosterUri" type="uri" alias="backendTypePoster.uri" />
|
||||
<field id="UsernameLabelFont" type="boolean" alias="UsernameLabel.font" />
|
||||
<field id="rowListHasFocus" type="boolean" onChange="OnRowListHasFocus" />
|
||||
<field id="itemHasFocus" type="boolean" onChange="OnItemHasFocus" />
|
||||
@@ -45,7 +46,7 @@
|
||||
translation="[20,20]"
|
||||
blendColor="#DDDDDDFF"
|
||||
uri="pkg:/images/white-circle.png">
|
||||
<Poster
|
||||
<CirclePoster
|
||||
id="circlePosterInner"
|
||||
width="152"
|
||||
height="152"
|
||||
@@ -60,7 +61,12 @@
|
||||
horizAlign="center">
|
||||
<Font role="font" uri="font:SystemFontFile" size="120" />
|
||||
</Label>
|
||||
</Poster>
|
||||
<Poster
|
||||
id="backendTypePoster"
|
||||
width="60"
|
||||
height="60"
|
||||
translation="[110,110]" />
|
||||
</CirclePoster>
|
||||
<Poster
|
||||
id="CrownPoster"
|
||||
width="60"
|
||||
@@ -72,9 +78,9 @@
|
||||
</Poster>
|
||||
<Label
|
||||
id="UsernameLabel"
|
||||
width="200"
|
||||
width="300"
|
||||
horizAlign="center"
|
||||
translation="[0,250]">
|
||||
translation="[-50,250]">
|
||||
</Label>
|
||||
<Label
|
||||
id="ServerLabel"
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/components/ProfileView/ProfileViewUtils.bs"
|
||||
import "pkg:/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionViewUtils.bs"
|
||||
import "pkg:/components/Screens/ProfileScreen/ProfileView/ProfileViewUtils.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
@@ -38,26 +40,78 @@ function OnRowItemSelected() as void
|
||||
row = m.profileRowList.content.GetChild(0)
|
||||
selectedProfile = row.GetChild(index)
|
||||
if selectedProfile.type = "login"
|
||||
invidiousInstance = m.preferences["invidious.instance"]
|
||||
if StringUtils.IsNullOrEmpty(invidiousInstance)
|
||||
DialogUtils.ShowDialogEx({
|
||||
title: "No Invidious Instance"
|
||||
message: [
|
||||
"Playlet built-in backend does not support login yet.",
|
||||
"Can only login if an Invidious instance is set in the settings."
|
||||
]
|
||||
})
|
||||
return
|
||||
end if
|
||||
dialog = CreateObject("roSGNode", "LoginDialog")
|
||||
dialog@.BindNode()
|
||||
m.top.getScene().dialog = dialog
|
||||
backendTypeSelectionView = BackendTypeSelectionViewUtils.Open(m.appController)
|
||||
backendTypeSelectionView.observeFieldScoped("selectedBackendType", FuncName(OnBackEndSelected))
|
||||
return
|
||||
end if
|
||||
|
||||
ProfileViewUtils.Open(selectedProfile, m.appController)
|
||||
end function
|
||||
|
||||
function OnBackEndSelected(event as object) as void
|
||||
backendTypeSelectionView = event.GetRoSGNode()
|
||||
backendTypeSelectionView.unobserveFieldScoped("selectedBackendType")
|
||||
|
||||
selectedBackendType = event.getData()
|
||||
if selectedBackendType = "BackendTypeInvidious"
|
||||
LoginWithInvidious()
|
||||
else if selectedBackendType = "BackendTypeYouTube"
|
||||
ShowLoginWithYouTubeDialog()
|
||||
else
|
||||
LogError("Unknown backend type:", selectedBackendType)
|
||||
end if
|
||||
end function
|
||||
|
||||
function LoginWithInvidious() as void
|
||||
invidiousInstance = m.preferences["invidious.instance"]
|
||||
if StringUtils.IsNullOrEmpty(invidiousInstance)
|
||||
DialogUtils.ShowDialogEx({
|
||||
title: "No Invidious Instance"
|
||||
message: [
|
||||
"Playlet built-in backend does not support login yet.",
|
||||
"Can only login if an Invidious instance is set in the settings."
|
||||
]
|
||||
})
|
||||
return
|
||||
end if
|
||||
|
||||
dialog = CreateObject("roSGNode", "InvidiousLoginDialog")
|
||||
dialog@.BindNode()
|
||||
m.top.getScene().dialog = dialog
|
||||
end function
|
||||
|
||||
function ShowLoginWithYouTubeDialog() as void
|
||||
dialog = DialogUtils.ShowDialogEx({
|
||||
title: Tr(Locale.Dialogs.Disclaimer)
|
||||
message: [
|
||||
Tr(Locale.Dialogs.YouTubeLoginDisclaimer1)
|
||||
Tr(Locale.Dialogs.YouTubeLoginDisclaimer2)
|
||||
Tr(Locale.Dialogs.YouTubeLoginDisclaimer3)
|
||||
]
|
||||
large: true
|
||||
buttons: [
|
||||
Tr(Locale.Buttons.OK)
|
||||
Tr(Locale.Buttons.Cancel)
|
||||
]
|
||||
})
|
||||
dialog.ObserveField("buttonSelected", FuncName(OnLoginWithYouTubeDialogButtonSelected))
|
||||
end function
|
||||
|
||||
function OnLoginWithYouTubeDialogButtonSelected(event as object) as void
|
||||
buttonSelected = event.getData()
|
||||
if buttonSelected <> 0
|
||||
return
|
||||
end if
|
||||
|
||||
LoginWithYouTube()
|
||||
end function
|
||||
|
||||
function LoginWithYouTube() as void
|
||||
dialog = CreateObject("roSGNode", "YouTubeLoginDialog")
|
||||
dialog@.BindNode()
|
||||
m.top.getScene().dialog = dialog
|
||||
end function
|
||||
|
||||
function OnCurrentProfileChanged() as void
|
||||
currentProfile = m.profilesService.currentProfile
|
||||
if currentProfile = invalid
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</interface>
|
||||
|
||||
<children>
|
||||
<ProfileRowList
|
||||
<RowList
|
||||
id="ProfileRowList"
|
||||
translation="[0,160]"
|
||||
numRows="2"
|
||||
|
||||
+33
-6
@@ -32,17 +32,44 @@ function OnContentSet() as void
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
|
||||
m.top.circlePosterInnerBlendColor = content.color
|
||||
username = content.username
|
||||
m.top.username = username
|
||||
if not StringUtils.IsNullOrEmpty(username)
|
||||
m.top.letter = UCase(username.Left(1))
|
||||
else
|
||||
|
||||
thumbnail = content.thumbnail
|
||||
if not StringUtils.IsNullOrEmpty(thumbnail)
|
||||
m.top.circlePosterInnerUri = thumbnail
|
||||
' bs:disable-next-line LINT3023
|
||||
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
|
||||
m.top.letter = ""
|
||||
else
|
||||
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
|
||||
m.top.circlePosterInnerBlendColor = content.color
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(username)
|
||||
letter = username.Left(1)
|
||||
if letter = "@" and Len(username) > 1
|
||||
letter = username.Mid(1, 1)
|
||||
end if
|
||||
m.top.letter = UCase(letter)
|
||||
else
|
||||
m.top.letter = ""
|
||||
end if
|
||||
end if
|
||||
m.top.serverUrl = content.serverUrl
|
||||
|
||||
m.top.crownVisible = content.isSelected
|
||||
|
||||
backendType = content.type
|
||||
if backendType = "invidious"
|
||||
m.top.serverUrl = content.serverUrl
|
||||
m.top.backendTypePosterUri = "pkg:/images/invidious-logo.png"
|
||||
else if backendType = "youtube"
|
||||
m.top.serverUrl = "YouTube"
|
||||
m.top.backendTypePosterUri = "pkg:/images/youtube-logo.png"
|
||||
else
|
||||
m.top.serverUrl = ""
|
||||
m.top.backendTypePosterUri = ""
|
||||
end if
|
||||
|
||||
UpdateActivateButton()
|
||||
end function
|
||||
|
||||
+10
-4
@@ -5,6 +5,7 @@
|
||||
<field id="username" type="string" alias="UsernameLabel.text" />
|
||||
<field id="serverUrl" type="string" alias="ServerLabel.text" />
|
||||
<field id="circlePosterInnerUri" type="uri" alias="circlePosterInner.uri" />
|
||||
<field id="backendTypePosterUri" type="uri" alias="backendTypePoster.uri" />
|
||||
<field id="circlePosterInnerBlendColor" type="uri" alias="circlePosterInner.blendColor" />
|
||||
<field id="crownVisible" type="boolean" alias="CrownPoster.visible" />
|
||||
|
||||
@@ -32,7 +33,7 @@
|
||||
translation="[20,20]"
|
||||
blendColor="#DDDDDDFF"
|
||||
uri="pkg:/images/white-circle.png">
|
||||
<Poster
|
||||
<CirclePoster
|
||||
id="circlePosterInner"
|
||||
width="152"
|
||||
height="152"
|
||||
@@ -47,7 +48,12 @@
|
||||
horizAlign="center">
|
||||
<Font role="font" uri="font:SystemFontFile" size="120" />
|
||||
</Label>
|
||||
</Poster>
|
||||
<Poster
|
||||
id="backendTypePoster"
|
||||
width="60"
|
||||
height="60"
|
||||
translation="[110,110]" />
|
||||
</CirclePoster>
|
||||
<Poster
|
||||
id="CrownPoster"
|
||||
width="60"
|
||||
@@ -59,9 +65,9 @@
|
||||
</Poster>
|
||||
<Label
|
||||
id="UsernameLabel"
|
||||
width="200"
|
||||
width="400"
|
||||
horizAlign="center"
|
||||
translation="[0,210]">
|
||||
translation="[-100,210]">
|
||||
<Font role="font" uri="font:MediumSystemFontFile" size="26" />
|
||||
</Label>
|
||||
<Label
|
||||
File renamed without changes.
+17
@@ -0,0 +1,17 @@
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function OnContentSet() as void
|
||||
content = m.top.itemContent
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
accountItem = content.accountItem
|
||||
if not IsAssociativeArray(accountItem)
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.accountPhoto = accountItem.accountPhoto
|
||||
m.top.text1 = accountItem.accountName
|
||||
m.top.text2 = accountItem.channelHandle
|
||||
end function
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<component name="YouTubeAccountListItem" extends="Group">
|
||||
<interface>
|
||||
<field id="itemContent" type="node" onChange="OnContentSet" />
|
||||
|
||||
<field id="accountPhoto" type="uri" alias="accountPhoto.uri" />
|
||||
<field id="text1" type="string" alias="text1Label.text" />
|
||||
<field id="text2" type="string" alias="text2Label.text" />
|
||||
</interface>
|
||||
<children>
|
||||
<LayoutGroup layoutDirection="horiz" translation="[0, 2]" itemSpacings="[10]">
|
||||
<Poster
|
||||
width="64"
|
||||
height="64"
|
||||
blendColor="#DDDDDDFF"
|
||||
uri="pkg:/images/white-circle.png">
|
||||
|
||||
<CirclePoster
|
||||
id="accountPhoto"
|
||||
width="60"
|
||||
height="60"
|
||||
translation="[2,2]"
|
||||
failedBitmapUri="pkg:/images/thumbnail-missing.jpg" />
|
||||
</Poster>
|
||||
|
||||
<LayoutGroup layoutDirection="vert" translation="[8, 0]" itemSpacings="[10]">
|
||||
<Label id="text1Label" font="font:SmallestBoldSystemFont" />
|
||||
<Label id="text2Label" font="font:SmallestSystemFont" />
|
||||
</LayoutGroup>
|
||||
</LayoutGroup>
|
||||
</children>
|
||||
</component>
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
import "pkg:/components/Dialog/YouTubeLoginAccountItemUtils.bs"
|
||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.accountList = m.top.FindNode("accountList")
|
||||
m.accountList.ObserveField("itemSelected", FuncName(OnAccountSelected))
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
|
||||
NodeSetFocus(m.accountList, true)
|
||||
end function
|
||||
|
||||
function OnKeyEvent(key as string, press as boolean) as boolean
|
||||
if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly
|
||||
' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play
|
||||
return false
|
||||
end if
|
||||
|
||||
if key = RemoteKeys.Back and press
|
||||
Close()
|
||||
return true
|
||||
end if
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
function Close()
|
||||
m.top.appController@.PopScreen()
|
||||
end function
|
||||
|
||||
function OnAccountsChanged() as void
|
||||
accounts = m.top.accounts
|
||||
if not IsArray(accounts) or accounts.Count() = 0
|
||||
m.accountList.content = invalid
|
||||
LogError(Tr(Locale.Dialogs.NoValidAccountsFound))
|
||||
Close()
|
||||
return
|
||||
end if
|
||||
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
accountNodes = []
|
||||
for each accountItem in accounts
|
||||
if not IsAssociativeArray(accountItem)
|
||||
continue for
|
||||
end if
|
||||
|
||||
accountNode = CreateObject("roSGNode", "ContentNode")
|
||||
accountNode.addField("accountItem", "assocarray", false)
|
||||
accountNode.accountItem = accountItem
|
||||
accountNodes.Push(accountNode)
|
||||
end for
|
||||
|
||||
if accountNodes.Count() = 0
|
||||
m.accountList.content = invalid
|
||||
LogError(Tr(Locale.Dialogs.NoValidAccountsFound))
|
||||
Close()
|
||||
return
|
||||
end if
|
||||
|
||||
content.appendChildren(accountNodes)
|
||||
m.accountList.content = content
|
||||
end function
|
||||
|
||||
function OnAccountSelected(event as object) as void
|
||||
itemSelected = m.accountList.itemSelected
|
||||
itemNode = m.accountList.content.GetChild(itemSelected)
|
||||
if itemNode = invalid
|
||||
LogError("Invalid item selected:", itemSelected)
|
||||
Close()
|
||||
return
|
||||
end if
|
||||
|
||||
accountItem = itemNode.accountItem
|
||||
if not IsAssociativeArray(accountItem)
|
||||
LogError("Invalid account item selected:", accountItem)
|
||||
Close()
|
||||
return
|
||||
end if
|
||||
|
||||
accessToken = m.top.accessToken
|
||||
if accessToken = invalid or not IsAssociativeArray(accessToken)
|
||||
LogError("No valid access token available for YouTube login.")
|
||||
Close()
|
||||
return
|
||||
end if
|
||||
|
||||
profileNode = YouTubeLoginAccountItemUtils.CreateProfileContentNode(accountItem, accessToken)
|
||||
m.top.profilesService@.LoginWithProfile(profileNode)
|
||||
|
||||
Close()
|
||||
end function
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<component name="YouTubeAccountSelectionView" extends="Group" includes="AutoBind,Focus">
|
||||
<interface>
|
||||
<field id="accessToken" type="assocarray" />
|
||||
<field id="accounts" type="array" onChange="OnAccountsChanged" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
<field id="profilesService" type="node" bind="/ProfilesService" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
width="1280"
|
||||
height="720"
|
||||
color="#000000"
|
||||
opacity="0.5">
|
||||
</Rectangle>
|
||||
|
||||
<Rectangle
|
||||
width="720"
|
||||
height="520"
|
||||
translation="[280,100]"
|
||||
color="#242424">
|
||||
<Label
|
||||
width="720"
|
||||
horizAlign="center"
|
||||
translation="[0,45]"
|
||||
text="Who's watching?">
|
||||
<Font role="font" uri="font:SystemFontFile" size="24" />
|
||||
</Label>
|
||||
|
||||
<MarkupGrid
|
||||
id="accountList"
|
||||
itemComponentName="YouTubeAccountListItem"
|
||||
itemSize="[640,70]"
|
||||
itemSpacing="[0,20]"
|
||||
numColumns="1"
|
||||
numRows="4"
|
||||
vertFocusAnimationStyle="floatingFocus"
|
||||
translation="[40,120]"
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-27.9.png" />
|
||||
</Rectangle>
|
||||
</children>
|
||||
</component>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
namespace YouTubeAccountSelectionViewUtils
|
||||
|
||||
function Open(appController as object) as object
|
||||
youTubeAccountSelectionView = CreateObject("roSGNode", "YouTubeAccountSelectionView")
|
||||
|
||||
appController@.PushScreen(youTubeAccountSelectionView)
|
||||
youTubeAccountSelectionView@.BindNode()
|
||||
return youTubeAccountSelectionView
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -16,8 +16,7 @@
|
||||
vertAlign="center"
|
||||
text="Could not get IP address: are we connected to the internet?"
|
||||
wrap="true"
|
||||
translation="[145,0]"
|
||||
/>
|
||||
translation="[145,0]" />
|
||||
</Group>
|
||||
<Group id="yesInternet" visible="false">
|
||||
<LayoutGroup
|
||||
@@ -83,9 +82,9 @@
|
||||
vertAlignment="center"
|
||||
translation="[0,245]">
|
||||
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
text="1." />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<Label text="1."
|
||||
font="font:SmallSystemFont" />
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
width="380"
|
||||
@@ -93,9 +92,9 @@
|
||||
text="On your phone, connect to the same Wi-Fi network as this device." />
|
||||
</LayoutGroup>
|
||||
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
text="2." />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<Label text="2."
|
||||
font="font:SmallSystemFont" />
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
width="380"
|
||||
@@ -103,14 +102,14 @@
|
||||
text="Open the YouTube app on your phone." />
|
||||
</LayoutGroup>
|
||||
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
text="3." />
|
||||
<MultiStyleLabel
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<Label text="3."
|
||||
font="font:SmallSystemFont" />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<MultiStyleLabel text="Tap the cast icon and select this device."
|
||||
id="WifiInstructionWithDeviceNameLabel"
|
||||
width="380"
|
||||
wrap="true"
|
||||
text="Tap the cast icon and select this device." />
|
||||
wrap="true" />
|
||||
</LayoutGroup>
|
||||
<Label
|
||||
text="Roku connected to:"
|
||||
@@ -131,9 +130,9 @@
|
||||
vertAlignment="center"
|
||||
translation="[0,245]">
|
||||
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
text="1." />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<Label text="1."
|
||||
font="font:SmallSystemFont" />
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
width="380"
|
||||
@@ -141,9 +140,9 @@
|
||||
text="On your phone, open the YouTube app." />
|
||||
</LayoutGroup>
|
||||
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
text="2." />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<Label text="2."
|
||||
font="font:SmallSystemFont" />
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
width="380"
|
||||
@@ -151,9 +150,9 @@
|
||||
text="Tap the cast icon." />
|
||||
</LayoutGroup>
|
||||
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
text="3." />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<Label text="3."
|
||||
font="font:SmallSystemFont" />
|
||||
<Label
|
||||
font="font:SmallSystemFont"
|
||||
width="380"
|
||||
|
||||
@@ -18,16 +18,14 @@
|
||||
|
||||
<DynamicMiniKeyboard
|
||||
id="keyboard"
|
||||
translation="[695,110]"
|
||||
/>
|
||||
translation="[695,110]" />
|
||||
<ButtonGroup
|
||||
id="suggestions"
|
||||
focusable="false"
|
||||
minWidth="400"
|
||||
maxWidth="480"
|
||||
buttonHeight="50"
|
||||
translation="[125,100]"
|
||||
/>
|
||||
translation="[125,100]" />
|
||||
<VideoRowList
|
||||
itemComponentName="RowCell"
|
||||
id="rowList"
|
||||
@@ -43,8 +41,7 @@
|
||||
showRowLabel="[true]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
variableWidthItems="true"
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png"
|
||||
/>
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" />
|
||||
<Animation
|
||||
id="scrollAnimation"
|
||||
duration="0.3">
|
||||
|
||||
@@ -17,7 +17,7 @@ function SearchSuggestionsTask(input as object) as object
|
||||
suggestions: []
|
||||
}
|
||||
else
|
||||
backend = preferencesNode["playback.backend"]
|
||||
backend = preferencesNode["backend.selected"]
|
||||
if backend = "playlet"
|
||||
searchSuggestsions = InnertubeService.SearchSuggestions(q, m.top.cancellation)
|
||||
else
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
<CheckList
|
||||
id="checkList"
|
||||
vertFocusAnimationStyle="floatingFocus"
|
||||
translation="[164,70]">
|
||||
translation="[164,40]">
|
||||
|
||||
<ContentNode role="content" />
|
||||
</CheckList>
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
@@ -9,7 +10,7 @@ function Init()
|
||||
m.top.itemSpacings = [8]
|
||||
|
||||
m.button = m.top.findNode("button")
|
||||
m.button.text = Invidious.DEFAULT_INSTANCE_NAME
|
||||
m.button.text = Tr(Locale.Settings.PlayletBuiltinBackend)
|
||||
AdjustButtonLabel(m.button)
|
||||
|
||||
m.button.observeField("buttonSelected", FuncName(OpenInvidiousInstanceSettings))
|
||||
@@ -81,7 +82,7 @@ function OnValueChange() as void
|
||||
m.preferences[m.key] = value
|
||||
|
||||
if StringUtils.IsNullOrEmpty(value)
|
||||
m.button.text = Invidious.DEFAULT_INSTANCE_NAME
|
||||
m.button.text = Tr(Locale.Settings.PlayletBuiltinBackend)
|
||||
else
|
||||
m.button.text = value
|
||||
end if
|
||||
|
||||
-2
@@ -24,8 +24,6 @@ end function
|
||||
|
||||
function PrepareTests() as object
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
' TODO:P2 test if video data is reachable (head?)
|
||||
' TODO:P2 test if video data is reachable in proxy mode (local=true)
|
||||
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.ValidUrl), IsValidUrl))
|
||||
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.InstanceReachable), IsReachable))
|
||||
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoDetails), CanFetchVideoDetails))
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
translation="[380,96]" />
|
||||
<Label
|
||||
id="failedLabel"
|
||||
text="Failed to load Invidious public instances."
|
||||
text="Failed to load Invidious public instances"
|
||||
horizAlign="center"
|
||||
translation="[0,60]"
|
||||
width="960" />
|
||||
|
||||
@@ -16,29 +16,29 @@
|
||||
<Font role="font" uri="font:SystemFontFile" size="18" />
|
||||
</Label>
|
||||
<LayoutGroup layoutDirection="horiz">
|
||||
<Button
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<Button text="-"
|
||||
id="MinusButton"
|
||||
iconUri=""
|
||||
focusedIconUri=""
|
||||
minWidth="64"
|
||||
maxWidth="64"
|
||||
showFocusFootprint="true"
|
||||
text="-" />
|
||||
<Button
|
||||
showFocusFootprint="true" />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<Button text="0"
|
||||
id="NumberButton"
|
||||
iconUri=""
|
||||
focusedIconUri=""
|
||||
minWidth="150"
|
||||
showFocusFootprint="true"
|
||||
text="0" />
|
||||
<Button
|
||||
showFocusFootprint="true" />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<Button text="+"
|
||||
id="PlusButton"
|
||||
iconUri=""
|
||||
focusedIconUri=""
|
||||
minWidth="64"
|
||||
maxWidth="64"
|
||||
showFocusFootprint="true"
|
||||
text="+" />
|
||||
showFocusFootprint="true" />
|
||||
</LayoutGroup>
|
||||
</children>
|
||||
</component>
|
||||
@@ -23,11 +23,17 @@
|
||||
|
||||
<ContentNode role="content">
|
||||
<ContentNode id="auto" title="Auto" />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<ContentNode id="1080p" title="1080p" />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<ContentNode id="720p" title="720p" />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<ContentNode id="480p" title="480p" />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<ContentNode id="360p" title="360p" />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<ContentNode id="240p" title="240p" />
|
||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||
<ContentNode id="144p" title="144p" />
|
||||
</ContentNode>
|
||||
</CheckList>
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.top.focusable = true
|
||||
m.top.itemSpacings = [8]
|
||||
|
||||
m.button = m.top.findNode("button")
|
||||
m.button.observeField("buttonSelected", FuncName(OpenSponsorBlockCategories))
|
||||
AdjustButtonLabel(m.button)
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
|
||||
NodeSetFocus(m.button, true)
|
||||
end function
|
||||
|
||||
function AdjustButtonLabel(button as object) as void
|
||||
children = button.getChildren(-1, 0)
|
||||
for each child in children
|
||||
if child.isSubtype("Label") and child.hasField("horizAlign")
|
||||
child.observeField("horizAlign", FuncName(OnButtonLabelHorizAlignChanged))
|
||||
child.horizAlign = "left"
|
||||
return
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
|
||||
function OnButtonLabelHorizAlignChanged(event as object)
|
||||
label = event.getRoSGNode()
|
||||
if label.horizAlign <> "left"
|
||||
label.horizAlign = "left"
|
||||
end if
|
||||
end function
|
||||
|
||||
function BindPreference(preferences as object, key as string)
|
||||
if m.preferences <> invalid and m.key <> invalid
|
||||
m.preferences.unobserveFieldScoped(m.key)
|
||||
end if
|
||||
|
||||
m.preferences = preferences
|
||||
m.key = key
|
||||
|
||||
if preferences <> invalid and key <> invalid
|
||||
preferences.observeFieldScoped(key, FuncName(OnPreferenceChange))
|
||||
OnPreferenceChange()
|
||||
end if
|
||||
end function
|
||||
|
||||
function OpenSponsorBlockCategories()
|
||||
categoriesPrefs = CreateObject("roSGNode", "SponsorBlockCategoriesPreferences")
|
||||
m.appController@.PushScreen(categoriesPrefs)
|
||||
categoriesPrefs@.BindNode()
|
||||
categoriesPrefs.value = m.top.value
|
||||
categoriesPrefs.observeField("save", FuncName(OnSaveCategoriesPreferences))
|
||||
end function
|
||||
|
||||
function OnSaveCategoriesPreferences(event as object)
|
||||
categoriesPrefs = event.GetRoSGNode()
|
||||
m.top.value = categoriesPrefs.value
|
||||
end function
|
||||
|
||||
function OnPreferenceChange()
|
||||
m.top.value = m.preferences[m.key]
|
||||
end function
|
||||
|
||||
function OnValueChange() as void
|
||||
if m.preferences = invalid or m.key = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.preferences[m.key] = m.top.value
|
||||
end function
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<component name="SponsorBlockCategoriesControl" extends="LayoutGroup" includes="AutoBind,Focus">
|
||||
<interface>
|
||||
<field id="displayText" type="string" alias="Button.text" />
|
||||
<field id="description" type="string" alias="DescriptionLabel.text" />
|
||||
<field id="value" type="assocarray" onChange="OnValueChange" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
<function name="BindPreference" />
|
||||
</interface>
|
||||
<children>
|
||||
<Button
|
||||
id="button"
|
||||
minWidth="300"
|
||||
showFocusFootprint="true" />
|
||||
<Label id="DescriptionLabel"
|
||||
width="450"
|
||||
color="0xb4b4b4ff"
|
||||
wrap="true">
|
||||
<Font role="font" uri="font:SystemFontFile" size="18" />
|
||||
</Label>
|
||||
</children>
|
||||
</component>
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||
import "pkg:/components/Services/SponsorBlock/SponsorBlockService.bs"
|
||||
import "pkg:/components/VideoPlayer/SponsorBlockSegmentAction.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.categoryList = m.top.findNode("categoryList")
|
||||
m.categoryList.ObserveField("itemSelected", FuncName(OnCategorySelected))
|
||||
m.service = new SponsorBlock.SponsorBlockService()
|
||||
|
||||
optionTitles = {}
|
||||
optionTitles[SponsorBlock.SegmentAction.Disable] = Tr(Locale.SponsorBlock.Disable)
|
||||
optionTitles[SponsorBlock.SegmentAction.AutoSkip] = Tr(Locale.SponsorBlock.AutoSkip)
|
||||
optionTitles[SponsorBlock.SegmentAction.ManualSkip] = Tr(Locale.SponsorBlock.ManualSkip)
|
||||
optionTitles[SponsorBlock.SegmentAction.ShowInSeekbar] = Tr(Locale.SponsorBlock.ShowInSeekbar)
|
||||
m.optionTitles = optionTitles
|
||||
|
||||
SetupCategoriesUi()
|
||||
|
||||
m.closeButton = m.top.findNode("closeButton")
|
||||
m.saveButton = m.top.findNode("saveButton")
|
||||
SetButtonPositions()
|
||||
|
||||
SetNavigation(m.saveButton, RemoteKeys.Right, m.closeButton)
|
||||
SetNavigation(m.closeButton, RemoteKeys.Left, m.saveButton)
|
||||
SetNavigation(m.saveButton, RemoteKeys.Up, m.categoryList)
|
||||
SetNavigation(m.closeButton, RemoteKeys.Up, m.categoryList)
|
||||
SetNavigation(m.categoryList, RemoteKeys.Down, m.saveButton)
|
||||
|
||||
m.saveButton.observeField("buttonSelected", FuncName(OnSaveButtonSelected))
|
||||
m.closeButton.observeField("buttonSelected", FuncName(Close))
|
||||
end function
|
||||
|
||||
function SetupCategoriesUi() as void
|
||||
categories = m.service.GetCategories()
|
||||
if categories.Count() = 0
|
||||
return
|
||||
end if
|
||||
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
categoryContentNodes = []
|
||||
|
||||
for each category in categories
|
||||
categoryNode = CreateObject("roSGNode", "SponsorBlockCategoryContent")
|
||||
categoryNode.category = category
|
||||
categoryNode.categoryTitle = Tr(m.service.SegmentTitle(category))
|
||||
categoryNode.selectedOption = SponsorBlock.SegmentAction.Disable
|
||||
categoryNode.options = m.service.GetOptionsForCategory(category)
|
||||
categoryNode.optionTitles = m.optionTitles
|
||||
categoryNode.color = m.service.SegmentColor(category)
|
||||
categoryContentNodes.push(categoryNode)
|
||||
end for
|
||||
|
||||
content.appendChildren(categoryContentNodes)
|
||||
m.categoryList.content = content
|
||||
end function
|
||||
|
||||
function SetButtonPositions()
|
||||
saveButtonWidth = m.saveButton.width
|
||||
closeButtonWidth = m.closeButton.width
|
||||
buttonsWith = closeButtonWidth + saveButtonWidth + 20
|
||||
m.saveButton.translation = [720 / 2 - buttonsWith / 2, m.saveButton.translation[1]]
|
||||
m.closeButton.translation = [720 / 2 + buttonsWith / 2 - closeButtonWidth, m.closeButton.translation[1]]
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
|
||||
NodeSetFocus(m.categoryList, true)
|
||||
end function
|
||||
|
||||
function OnKeyEvent(key as string, press as boolean) as boolean
|
||||
if NavigationKeyHandler(key, press).handled
|
||||
return true
|
||||
end if
|
||||
|
||||
if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly
|
||||
' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play
|
||||
return false
|
||||
end if
|
||||
|
||||
if key = RemoteKeys.Back and press
|
||||
Close()
|
||||
return true
|
||||
end if
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
function OnValueChange() as void
|
||||
content = m.categoryList.content
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
value = m.top.value
|
||||
if not IsAssociativeArray(value)
|
||||
return
|
||||
end if
|
||||
|
||||
categoryContentNodes = content.getChildren(-1, 0)
|
||||
categoryNodeMap = {}
|
||||
for each categoryContentNode in categoryContentNodes
|
||||
categoryNodeMap[categoryContentNode.category] = categoryContentNode
|
||||
end for
|
||||
|
||||
for each category in value
|
||||
if not categoryNodeMap.DoesExist(category)
|
||||
continue for
|
||||
end if
|
||||
categoryNode = categoryNodeMap[category]
|
||||
if categoryNode = invalid
|
||||
continue for
|
||||
end if
|
||||
categoryNode.selectedOption = value[category].option
|
||||
end for
|
||||
end function
|
||||
|
||||
function OnSaveButtonSelected()
|
||||
m.top.save = true
|
||||
Close()
|
||||
end function
|
||||
|
||||
function Close()
|
||||
m.appController@.PopScreen()
|
||||
end function
|
||||
|
||||
function OnCategorySelected(event as object) as void
|
||||
itemSelected = m.categoryList.itemSelected
|
||||
itemNode = m.categoryList.content.GetChild(itemSelected)
|
||||
if itemNode = invalid
|
||||
LogError("Invalid item selected:", itemSelected)
|
||||
return
|
||||
end if
|
||||
|
||||
options = itemNode.options
|
||||
optionTitles = itemNode.optionTitles
|
||||
optionTitlesArray = []
|
||||
for each option in options
|
||||
optionTitlesArray.push(optionTitles[option])
|
||||
end for
|
||||
|
||||
dialog = DialogUtils.ShowDialogEx({
|
||||
title: itemNode.categoryTitle
|
||||
message: Tr(Locale.Settings.SelectOptionFor).Replace("%1", itemNode.categoryTitle)
|
||||
buttons: optionTitlesArray
|
||||
})
|
||||
if dialog = invalid
|
||||
return
|
||||
end if
|
||||
dialog.addFields({
|
||||
"categoryContentNode": itemNode
|
||||
"options": options
|
||||
})
|
||||
dialog.observeField("buttonSelected", FuncName(OnCategoryDialogResult), ["buttonSelected"])
|
||||
end function
|
||||
|
||||
function OnCategoryDialogResult(event as object) as void
|
||||
dialog = event.getRoSGNode()
|
||||
options = dialog.options
|
||||
buttonIndex = event.GetData()
|
||||
|
||||
if not IsInt(buttonIndex) or buttonIndex < 0 or buttonIndex >= options.Count()
|
||||
return
|
||||
end if
|
||||
|
||||
selectedOption = options[buttonIndex]
|
||||
category = dialog.categoryContentNode.category
|
||||
|
||||
value = m.top.value
|
||||
value[category].option = selectedOption
|
||||
m.top.value = value
|
||||
|
||||
LogInfo("SponsorBlock category", category, "set to", selectedOption)
|
||||
end function
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<component name="SponsorBlockCategoriesPreferences" extends="Group" includes="AutoBind,Focus">
|
||||
<interface>
|
||||
<field id="value" type="assocarray" onChange="OnValueChange" />
|
||||
<field id="save" type="boolean" alwaysNotify="true" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
width="1280"
|
||||
height="720"
|
||||
color="#000000"
|
||||
opacity="0.5">
|
||||
</Rectangle>
|
||||
<Rectangle
|
||||
width="720"
|
||||
height="600"
|
||||
translation="[300,60]"
|
||||
color="#242424">
|
||||
<Label
|
||||
width="720"
|
||||
horizAlign="center"
|
||||
translation="[0,38]"
|
||||
text="Categories">
|
||||
<Font role="font" uri="font:SystemFontFile" size="24" />
|
||||
</Label>
|
||||
|
||||
<MarkupGrid
|
||||
id="categoryList"
|
||||
itemComponentName="SponsorBlockCategoryListItem"
|
||||
itemSize="[640,32]"
|
||||
itemSpacing="[0,10]"
|
||||
numColumns="1"
|
||||
numRows="10"
|
||||
vertFocusAnimationStyle="floatingFocus"
|
||||
translation="[40,100]"
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" />
|
||||
|
||||
<ButtonEx
|
||||
id="saveButton"
|
||||
iconVisible="false"
|
||||
text="Save"
|
||||
padding="[30,30]"
|
||||
translation="[340,500]" />
|
||||
<ButtonEx
|
||||
id="closeButton"
|
||||
iconVisible="false"
|
||||
text="Close"
|
||||
padding="[30,30]"
|
||||
translation="[496,500]" />
|
||||
</Rectangle>
|
||||
</children>
|
||||
</component>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<component name="SponsorBlockCategoryContent" extends="ContentNode">
|
||||
<interface>
|
||||
<field id="category" type="string" />
|
||||
<field id="categoryTitle" type="string" />
|
||||
<field id="selectedOption" type="string" />
|
||||
<field id="options" type="stringarray" />
|
||||
<field id="optionTitles" type="assocarray" />
|
||||
<field id="color" type="color" />
|
||||
</interface>
|
||||
</component>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function OnContentSet() as void
|
||||
content = m.top.itemContent
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.categoryTitle = content.categoryTitle
|
||||
optionTitles = content.optionTitles
|
||||
m.top.optionTitle = optionTitles[content.selectedOption]
|
||||
m.top.color = content.color
|
||||
end function
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<component name="SponsorBlockCategoryListItem" extends="Group">
|
||||
<interface>
|
||||
<field id="itemContent" type="node" onChange="OnContentSet" />
|
||||
|
||||
<field id="categoryTitle" type="string" alias="categoryLabel.text" />
|
||||
<field id="optionTitle" type="string" alias="optionLabel.text" />
|
||||
<field id="color" type="color" alias="colorRect.color" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle id="colorRect"
|
||||
width="52"
|
||||
height="28"
|
||||
translation="[10, 2]" />
|
||||
|
||||
<Label id="categoryLabel"
|
||||
font="font:SmallestSystemFont"
|
||||
width="320"
|
||||
height="32"
|
||||
vertAlign="center"
|
||||
horizAlign="left"
|
||||
translation="[80, 0]" />
|
||||
<Label id="optionLabel"
|
||||
width="320"
|
||||
height="32"
|
||||
font="font:SmallestSystemFont"
|
||||
vertAlign="center"
|
||||
horizAlign="right"
|
||||
translation="[310, 0]" />
|
||||
</children>
|
||||
</component>
|
||||
@@ -12,7 +12,6 @@ class DashManifest
|
||||
m.invidiousInstance = invidiousInstance
|
||||
|
||||
m.utils = new Http.Utils()
|
||||
m.urlRegex = /https?:\/\/\S+(\/\S+)/i
|
||||
|
||||
' https://github.com/LuanRT/YouTube.js/blob/6082b4a52ee07a622735e6e9128a0531a5ae3bfb/src/utils/StreamingInfo.ts#L332-L349
|
||||
m.colorInfo = {
|
||||
@@ -38,8 +37,11 @@ class DashManifest
|
||||
adaptiveFormats.Append(metadata.adaptiveFormats)
|
||||
|
||||
if local
|
||||
parsedInvidiousUrl = UrlUtils.ParseUrl(m.invidiousInstance)
|
||||
for i = 0 to adaptiveFormats.Count() - 1
|
||||
adaptiveFormats[i].url = m.urlRegex.replace(adaptiveFormats[i].url, m.invidiousInstance + "\1")
|
||||
parsedUrl = UrlUtils.ParseUrl(adaptiveFormats[i].url)
|
||||
parsedInvidiousUrl.path = UrlUtils.AppendQueryParams(parsedUrl.path, { host: parsedUrl.host })
|
||||
adaptiveFormats[i].url = UrlUtils.BuildUrlFromParts(parsedInvidiousUrl)
|
||||
end for
|
||||
end if
|
||||
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import "pkg:/components/Services/Innertube/Context.bs"
|
||||
import "pkg:/source/services/HttpClient.bs"
|
||||
import "pkg:/source/utils/OptionUtils.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
namespace Innertube
|
||||
|
||||
function CreateBrowseRequest(browseId as string, clienType as Innertube.ClientType, params = "" as string, continuation = "" as string) as object
|
||||
function CreateBrowseRequest(browseId as string, clienType as Innertube.ClientType, options = invalid as object) as object
|
||||
params = OptionUtils.GetOrDefault(options, "params", "")
|
||||
continuation = OptionUtils.GetOrDefault(options, "continuation", "")
|
||||
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
payload = {
|
||||
"context": Innertube.CreateContext(clienType, deviceInfo, "")
|
||||
"context": Innertube.CreateContext(clienType, deviceInfo, options)
|
||||
}
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(continuation)
|
||||
@@ -21,12 +25,7 @@ namespace Innertube
|
||||
end if
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/browse?prettyPrint=false&alt=json", payload)
|
||||
headers = {
|
||||
"accept": "*/*"
|
||||
"accept-language": "*"
|
||||
}
|
||||
headers.Append(Innertube.CreateHeaders(clienType))
|
||||
request.Headers(headers)
|
||||
request.Headers(Innertube.CreateHeaders(clienType))
|
||||
|
||||
return request
|
||||
end function
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
const INNERTUBE_IOS_CLIENT_NAME = "5"
|
||||
const INNERTUBE_IOS_CLIENT_VERSION = "19.49.7"
|
||||
const INNERTUBE_IOS_OS_VERSION = "15.6"
|
||||
const INNERTUBE_IOS_USER_AGENT = "com.google.ios.youtube/19.49.7 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)"
|
||||
const INNERTUBE_IOS_CLIENT_VERSION = "20.20.5"
|
||||
const INNERTUBE_IOS_DEVICE_MODEL = "iPhone16,2"
|
||||
const INNERTUBE_IOS_OS_VERSION = "18.1"
|
||||
const INNERTUBE_IOS_USER_AGENT = "com.google.ios.youtube/20.20.5 (iPhone16,2; U; CPU iOS 18_1_0 like Mac OS X)"
|
||||
|
||||
const INNERTUBE_WEB_CLIENT_NAME = "1"
|
||||
const INNERTUBE_WEB_CLIENT_VERSION = "2.20241230.09.00"
|
||||
const INNERTUBE_WEB_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0"
|
||||
const INNERTUBE_WEB_BROWSER_NAME = "Chrome"
|
||||
const INNERTUBE_WEB_BROWSER_VERSION = "131.0.0.0"
|
||||
const INNERTUBE_WEB_BROWSER_VERSION = "136.0.0.0"
|
||||
const INNERTUBE_WEB_CLIENT_NAME = "1"
|
||||
const INNERTUBE_WEB_CLIENT_VERSION = "2.20250520.05.00"
|
||||
const INNERTUBE_WEB_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0"
|
||||
|
||||
const INNERTUBE_TV_BROWSER_NAME = "LG Browser"
|
||||
const INNERTUBE_TV_BROWSER_VERSION = "7.00.00"
|
||||
const INNERTUBE_TV_CLIENT_NAME = "2"
|
||||
const INNERTUBE_TV_CLIENT_VERSION = "7.20241211.14.01"
|
||||
const INNERTUBE_TV_USER_AGENT = "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/538.2 (KHTML, like Gecko) Large Screen Safari/538.2 LG Browser/7.00.00(LGE; 24LF4820-BU; 03.20.14; 1; DTV_W15L); webOS.TV-2015; LG NetCast.TV-2013 Compatible (LGE, 24LF4820-BU, wireless)"
|
||||
const INNERTUBE_TV_CLIENT_VERSION = "7.20250519.12.01"
|
||||
const INNERTUBE_TV_DEVICE_MAKE = "LGE"
|
||||
const INNERTUBE_TV_DEVICE_MODEL = "24LF4820-BU"
|
||||
const INNERTUBE_TV_OS_NAME = "webOS"
|
||||
const INNERTUBE_TV_OS_VERSION = "2015"
|
||||
const INNERTUBE_TV_BROWSER_NAME = "LG Browser"
|
||||
const INNERTUBE_TV_BROWSER_VERSION = "7.00.00"
|
||||
const INNERTUBE_TV_USER_AGENT = "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/538.2 (KHTML, like Gecko) Large Screen Safari/538.2 LG Browser/7.00.00(LGE; 24LF4820-BU; 03.20.14; 1; DTV_W15L); webOS.TV-2015; LG NetCast.TV-2013 Compatible (LGE, 24LF4820-BU, wireless)"
|
||||
@@ -1,4 +1,5 @@
|
||||
import "pkg:/components/Services/Innertube/Constants.bs"
|
||||
import "pkg:/source/utils/OptionUtils.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
namespace Innertube
|
||||
@@ -12,18 +13,24 @@ namespace Innertube
|
||||
function CreateHeaders(clienType as Innertube.ClientType) as object
|
||||
if clienType = ClientType.Web
|
||||
return {
|
||||
"accept": "*/*"
|
||||
"accept-language": "*"
|
||||
"user-agent": INNERTUBE_WEB_USER_AGENT
|
||||
"x-youtube-client-name": INNERTUBE_WEB_CLIENT_NAME
|
||||
"x-youtube-client-version": INNERTUBE_WEB_CLIENT_VERSION
|
||||
}
|
||||
else if clienType = ClientType.IOS
|
||||
return {
|
||||
"accept": "*/*"
|
||||
"accept-language": "*"
|
||||
"user-agent": INNERTUBE_IOS_USER_AGENT
|
||||
"x-youtube-client-name": INNERTUBE_IOS_CLIENT_NAME
|
||||
"x-youtube-client-version": INNERTUBE_IOS_CLIENT_VERSION
|
||||
}
|
||||
else if clienType = ClientType.Tv
|
||||
return {
|
||||
"accept": "*/*"
|
||||
"accept-language": "*"
|
||||
"user-agent": INNERTUBE_TV_USER_AGENT
|
||||
"x-youtube-client-name": INNERTUBE_TV_CLIENT_NAME
|
||||
"x-youtube-client-version": INNERTUBE_TV_CLIENT_VERSION
|
||||
@@ -33,7 +40,7 @@ namespace Innertube
|
||||
end if
|
||||
end function
|
||||
|
||||
function CreateContext(clienType as Innertube.ClientType, deviceInfo as object, ctt as string) as object
|
||||
function CreateContext(clienType as Innertube.ClientType, deviceInfo as object, options = invalid as object) as object
|
||||
client = invalid
|
||||
if clienType = ClientType.Web
|
||||
client = CreateContextClientWeb(deviceInfo)
|
||||
@@ -45,6 +52,10 @@ namespace Innertube
|
||||
throw "Invalid client type"
|
||||
end if
|
||||
|
||||
credentialTransferToken = OptionUtils.Get(options, "credentialTransferToken")
|
||||
visitorData = OptionUtils.Get(options, "visitorData")
|
||||
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
|
||||
|
||||
context = {
|
||||
"client": client
|
||||
"user": {
|
||||
@@ -57,26 +68,33 @@ namespace Innertube
|
||||
}
|
||||
}
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(ctt)
|
||||
if not StringUtils.IsNullOrEmpty(credentialTransferToken)
|
||||
context["user"]["credentialTransferTokens"] = [{
|
||||
"token": ctt
|
||||
"token": credentialTransferToken
|
||||
"scope": "VIDEO"
|
||||
}]
|
||||
end if
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(visitorData)
|
||||
context["client"]["visitorData"] = visitorData
|
||||
end if
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(onBehalfOfUser)
|
||||
context["user"]["onBehalfOfUser"] = onBehalfOfUser
|
||||
end if
|
||||
|
||||
return context
|
||||
end function
|
||||
|
||||
function CreateContextClientWeb(deviceInfo as object) as object
|
||||
return {
|
||||
"hl": deviceInfo.GetCurrentLocale()
|
||||
"hl": GetCurrentLocale(deviceInfo)
|
||||
"gl": GetContentRegion(deviceInfo)
|
||||
"remoteHost": ""
|
||||
"screenDensityFloat": 1
|
||||
"screenHeightPoints": 1440
|
||||
"screenPixelDensity": 1
|
||||
"screenWidthPoints": 2560
|
||||
"visitorData": ""
|
||||
"clientName": "WEB"
|
||||
"clientVersion": INNERTUBE_WEB_CLIENT_VERSION
|
||||
"osName": "Windows"
|
||||
@@ -103,14 +121,13 @@ namespace Innertube
|
||||
|
||||
function CreateContextClientIOS(deviceInfo as object) as object
|
||||
return {
|
||||
"hl": deviceInfo.GetCurrentLocale()
|
||||
"hl": GetCurrentLocale(deviceInfo)
|
||||
"gl": GetContentRegion(deviceInfo)
|
||||
"remoteHost": ""
|
||||
"screenDensityFloat": 1
|
||||
"screenHeightPoints": 1440
|
||||
"screenPixelDensity": 1
|
||||
"screenWidthPoints": 2560
|
||||
"visitorData": ""
|
||||
"clientName": "iOS"
|
||||
"clientVersion": INNERTUBE_IOS_CLIENT_VERSION
|
||||
"osName": "iOS"
|
||||
@@ -121,7 +138,7 @@ namespace Innertube
|
||||
"timeZone": deviceInfo.GetTimeZone()
|
||||
"originalUrl": "https://www.youtube.com"
|
||||
"deviceMake": "Apple"
|
||||
"deviceModel": "iPhone10,6"
|
||||
"deviceModel": INNERTUBE_IOS_DEVICE_MODEL
|
||||
"utcOffsetMinutes": -240
|
||||
"memoryTotalKbytes": "8000000"
|
||||
}
|
||||
@@ -129,7 +146,7 @@ namespace Innertube
|
||||
|
||||
function CreateContextClientTv(deviceInfo as object) as object
|
||||
return {
|
||||
"hl": deviceInfo.GetCurrentLocale()
|
||||
"hl": GetCurrentLocale(deviceInfo)
|
||||
"gl": GetContentRegion(deviceInfo)
|
||||
"remoteHost": ""
|
||||
"deviceMake": INNERTUBE_TV_DEVICE_MAKE
|
||||
@@ -145,6 +162,7 @@ namespace Innertube
|
||||
"clientFormFactor": "UNKNOWN_FORM_FACTOR"
|
||||
"webpSupport": false
|
||||
"tvAppInfo": {
|
||||
' "appQuality": "TV_APP_QUALITY_FULL_ANIMATION"
|
||||
"appQuality": "TV_APP_QUALITY_LIMITED_MEMORY"
|
||||
"useStartPlaybackPreviewCommand": false
|
||||
"supportsNativeScrolling": false
|
||||
@@ -159,6 +177,15 @@ namespace Innertube
|
||||
}
|
||||
end function
|
||||
|
||||
function GetCurrentLocale(deviceInfo as object) as string
|
||||
currentLocale = deviceInfo.GetCurrentLocale()
|
||||
' en_CA is not a valid locale for Innertube
|
||||
if currentLocale = "en_CA"
|
||||
currentLocale = "en_US"
|
||||
end if
|
||||
return currentLocale
|
||||
end function
|
||||
|
||||
function GetContentRegion(deviceInfo as object) as string
|
||||
region = deviceInfo.GetUserCountryCode()
|
||||
if region.len() <> 2 or region = "OT"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import "pkg:/components/Services/Innertube/Constants.bs"
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
|
||||
function Init()
|
||||
AsyncTask.Start(Tasks.InnertubeInitTask, {
|
||||
innertube: m.top
|
||||
})
|
||||
end function
|
||||
@@ -0,0 +1,5 @@
|
||||
<component name="Innertube" extends="Node">
|
||||
<interface>
|
||||
<field id="visitorData" type="string" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -0,0 +1,15 @@
|
||||
import "pkg:/components/Services/Innertube/SessionData.bs"
|
||||
|
||||
@asynctask
|
||||
function InnertubeInitTask(input as object) as object
|
||||
innertubeNode = input.innertube
|
||||
|
||||
sessionData = Innertube.GetSessionData()
|
||||
if sessionData = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
innertubeNode.visitorData = sessionData.visitorData
|
||||
|
||||
return invalid
|
||||
end function
|
||||
@@ -7,39 +7,37 @@ import "pkg:/components/Services/Innertube/PlayerEndpoint.bs"
|
||||
import "pkg:/components/Services/Innertube/ResolveUrlEndpoint.bs"
|
||||
import "pkg:/components/Services/Innertube/SearchEndpoint.bs"
|
||||
import "pkg:/components/Services/Innertube/SearchFilters.bs"
|
||||
import "pkg:/components/Services/Innertube/SubscriptionEndpoint.bs"
|
||||
import "pkg:/source/services/HttpClient.bs"
|
||||
import "pkg:/source/utils/CancellationUtils.bs"
|
||||
import "pkg:/source/utils/ObjectUtils.bs"
|
||||
import "pkg:/source/utils/OptionUtils.bs"
|
||||
import "pkg:/source/utils/TimeUtils.bs"
|
||||
|
||||
namespace InnertubeService
|
||||
|
||||
function GetVideoMetadata(videoId as string, options = invalid as object) as object
|
||||
cancellation = invalid
|
||||
fetchNext = true
|
||||
ctt = ""
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
fetchNext = OptionUtils.GetOrDefault(options, "fetchNext", true)
|
||||
raw = OptionUtils.GetOrDefault(options, "raw", false)
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
if options.DoesExist("fetchNext")
|
||||
fetchNext = options.fetchNext
|
||||
end if
|
||||
if options.DoesExist("ctt")
|
||||
ctt = options.ctt
|
||||
end if
|
||||
end if
|
||||
|
||||
playerRequest = Innertube.CreatePlayerRequest(videoId, ctt)
|
||||
playerRequest = Innertube.CreatePlayerRequest(videoId, Innertube.ClientType.IOS, options)
|
||||
playerRequest.Cancellation(cancellation)
|
||||
if raw
|
||||
playerRequest.LogCurlCommand()
|
||||
playerRequest.NoCache()
|
||||
end if
|
||||
playerRequest.Send()
|
||||
|
||||
nextRequest = invalid
|
||||
nextResponse = invalid
|
||||
if fetchNext
|
||||
nextRequest = Innertube.CreateNextRequest({ "videoId": videoId }, ctt)
|
||||
nextRequest = Innertube.CreateNextRequest({ "videoId": videoId }, options)
|
||||
nextRequest.Cancellation(cancellation)
|
||||
if raw
|
||||
nextRequest.LogCurlCommand()
|
||||
nextRequest.NoCache()
|
||||
end if
|
||||
nextRequest.Send()
|
||||
end if
|
||||
|
||||
@@ -60,6 +58,16 @@ namespace InnertubeService
|
||||
nextResponse = nextRequest.Await()
|
||||
end if
|
||||
|
||||
if raw
|
||||
rawResponse = {
|
||||
"playerResponse": playerResponse.Json()
|
||||
}
|
||||
if fetchNext
|
||||
rawResponse["nextResponse"] = nextResponse.Json()
|
||||
end if
|
||||
return rawResponse
|
||||
end if
|
||||
|
||||
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerResponse.Json())
|
||||
if parsedResponse.error <> invalid
|
||||
return parsedResponse
|
||||
@@ -84,20 +92,11 @@ namespace InnertubeService
|
||||
}
|
||||
end if
|
||||
|
||||
cancellation = invalid
|
||||
retry = true
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
if options.DoesExist("retry")
|
||||
retry = options.retry
|
||||
end if
|
||||
end if
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
retry = OptionUtils.GetOrDefault(options, "retry", true)
|
||||
|
||||
params = Innertube.GetEncodedNextParams(videoIds)
|
||||
request = Innertube.CreateNextRequest({ "params": params }, "")
|
||||
request = Innertube.CreateNextRequest({ "params": params })
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
response = request.Await()
|
||||
@@ -155,56 +154,50 @@ namespace InnertubeService
|
||||
end function
|
||||
|
||||
function Search(query as string, options = invalid as object) as object
|
||||
searchFilters = invalid
|
||||
continuation = ""
|
||||
cancellation = invalid
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("searchFilters")
|
||||
searchFilters = options.searchFilters
|
||||
end if
|
||||
if options.DoesExist("continuation")
|
||||
continuation = options.continuation
|
||||
end if
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
end if
|
||||
|
||||
return Innertube.Search(query, searchFilters, continuation, cancellation)
|
||||
return Innertube.Search(query, options)
|
||||
end function
|
||||
|
||||
function GetTrending(options = invalid as object) as object
|
||||
cancellation = invalid
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
trendingType = LCase(OptionUtils.GetOrDefault(options, "type", ""))
|
||||
disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
|
||||
raw = OptionUtils.GetOrDefault(options, "raw", false)
|
||||
|
||||
params = ""
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
if options.DoesExist("type")
|
||||
trendingType = LCase(ValidString(options.type))
|
||||
|
||||
if trendingType = "music"
|
||||
params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
|
||||
else if trendingType = "gaming"
|
||||
params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
|
||||
else if trendingType = "movies"
|
||||
params = "4gIKGgh0cmFpbGVycw%3D%3D"
|
||||
end if
|
||||
end if
|
||||
if trendingType = "music"
|
||||
' {"44:proto": {"3:string": "ytma_charts"}}
|
||||
params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
|
||||
else if trendingType = "gaming"
|
||||
' {"44:proto": {"3:string": "gaming_corpus_most_popular"}}
|
||||
params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
|
||||
else if trendingType = "movies"
|
||||
' {"44:proto": {"3:string": "trailers"}}
|
||||
params = "4gIKGgh0cmFpbGVycw%3D%3D"
|
||||
end if
|
||||
|
||||
request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, params)
|
||||
request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, { params: params })
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
if raw
|
||||
request.LogCurlCommand()
|
||||
request.NoCache()
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
return invalid
|
||||
return {
|
||||
error: response.ErrorMessage()
|
||||
}
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
feeds = Innertube.ParseResponseDataForFeeds(json, { skipCreatorOnTheRise: true })
|
||||
if raw
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
feeds = Innertube.ParseResponseDataForFeeds(response.Json(), {
|
||||
disableCreatorOnTheRise: true
|
||||
disableShorts: disableShorts
|
||||
})
|
||||
|
||||
result = {
|
||||
feeds: feeds
|
||||
@@ -235,57 +228,17 @@ namespace InnertubeService
|
||||
end function
|
||||
|
||||
function GetBrowseAuthenticatedPage(browserId as string, options = invalid as object) as object
|
||||
cancellation = invalid
|
||||
accessToken = invalid
|
||||
continuation = ""
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
if options.DoesExist("accessToken")
|
||||
accessToken = options.accessToken
|
||||
end if
|
||||
if options.DoesExist("continuation")
|
||||
continuation = options.continuation
|
||||
end if
|
||||
end if
|
||||
request = Innertube.CreateBrowseRequest(browserId, Innertube.ClientType.Tv, options)
|
||||
|
||||
request = Innertube.CreateBrowseRequest(browserId, Innertube.ClientType.Tv, "", continuation)
|
||||
if accessToken <> invalid
|
||||
request.Header("Authorization", "Bearer " + accessToken)
|
||||
end if
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
return invalid
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
return Innertube.ParseResponseDataForFeeds(json)
|
||||
end function
|
||||
|
||||
function GetChannel(channelId as string, options = invalid as object) as object
|
||||
continuation = ""
|
||||
params = ""
|
||||
cancellation = invalid
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("continuation")
|
||||
continuation = options.continuation
|
||||
end if
|
||||
if options.DoesExist("params")
|
||||
params = options.params
|
||||
end if
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
end if
|
||||
|
||||
request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Web, params, continuation)
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
return {
|
||||
@@ -293,8 +246,11 @@ namespace InnertubeService
|
||||
}
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
result = Innertube.ParseChannelPageResponseData(json)
|
||||
feeds = Innertube.ParseResponseDataForFeeds(response.Json(), { disableShorts: disableShorts })
|
||||
|
||||
result = {
|
||||
feeds: feeds
|
||||
}
|
||||
|
||||
cacheControl = Innertube.ParseResponseForCacheControl(response)
|
||||
if cacheControl <> invalid
|
||||
@@ -304,25 +260,140 @@ namespace InnertubeService
|
||||
return result
|
||||
end function
|
||||
|
||||
function GetPlaylist(playlistId as string, options = invalid as object) as object
|
||||
continuation = ""
|
||||
function AuthGetPlaybackTrackingUrls(videoId as string, options as object) as object
|
||||
cancellation = invalid
|
||||
accessToken = options.accessToken
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("continuation")
|
||||
continuation = options.continuation
|
||||
end if
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
|
||||
if not playlistId.StartsWith("VL")
|
||||
playlistId = "VL" + playlistId
|
||||
playerRequest = Innertube.CreatePlayerRequest(videoId, Innertube.ClientType.Tv, options)
|
||||
playerRequest.Cancellation(cancellation)
|
||||
playerRequest.Header("Authorization", "Bearer " + accessToken)
|
||||
|
||||
playerResponse = playerRequest.Await()
|
||||
if not playerResponse.IsSuccess()
|
||||
return {
|
||||
error: playerResponse.ErrorMessage()
|
||||
}
|
||||
end if
|
||||
|
||||
request = Innertube.CreateBrowseRequest(playlistId, Innertube.ClientType.Web, "", continuation)
|
||||
json = playerResponse.Json()
|
||||
|
||||
error = Innertube.ParsePlayerResponseForError(json)
|
||||
if error <> ""
|
||||
return {
|
||||
error: error
|
||||
}
|
||||
end if
|
||||
|
||||
videostatsPlaybackUrl = ObjectUtils.Dig(json, ["playbackTracking", "videostatsPlaybackUrl", "baseUrl"])
|
||||
videostatsWatchtimeUrl = ObjectUtils.Dig(json, ["playbackTracking", "videostatsWatchtimeUrl", "baseUrl"])
|
||||
|
||||
return {
|
||||
videostatsPlaybackUrl: videostatsPlaybackUrl
|
||||
videostatsWatchtimeUrl: videostatsWatchtimeUrl
|
||||
}
|
||||
end function
|
||||
|
||||
function AuthMarkVideoWatched(videostatsPlaybackUrl as string, options as object) as boolean
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
|
||||
|
||||
videostatsPlaybackUrl = videostatsPlaybackUrl.replace("https://s.", "https://www.")
|
||||
queryParams = UrlUtils.ParseQueryComponents(videostatsPlaybackUrl)
|
||||
queryParams["c"] = "TVHTML5"
|
||||
queryParams["cbrver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||
queryParams["cver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||
queryParams["ver"] = "2"
|
||||
queryParams["cpn"] = InnertubeService.CreateClientPlaybackNonce()
|
||||
queryParams["cmt"] = 0
|
||||
queryParams["final"] = "1"
|
||||
videostatsPlaybackUrl = UrlUtils.SetQueryParams(videostatsPlaybackUrl, queryParams)
|
||||
|
||||
request = HttpClient.Get(videostatsPlaybackUrl)
|
||||
request.Cancellation(cancellation)
|
||||
request.NoCache()
|
||||
request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Tv))
|
||||
request.Header("Authorization", "Bearer " + accessToken)
|
||||
if not StringUtils.IsNullOrEmpty(onBehalfOfUser)
|
||||
request.Header("X-Goog-Pageid", onBehalfOfUser)
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
LogError("Error marking video as watched:", response.ErrorMessage())
|
||||
return false
|
||||
end if
|
||||
|
||||
LogDebug("Marked video as watched")
|
||||
return true
|
||||
end function
|
||||
|
||||
function AuthMarkVideoWatchTime(time as float, videostatsWatchtimeUrl as string, options = invalid as object) as boolean
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
|
||||
|
||||
timeStr = time.ToStr("%.3f")
|
||||
|
||||
videostatsWatchtimeUrl = videostatsWatchtimeUrl.replace("https://s.", "https://www.")
|
||||
queryParams = UrlUtils.ParseQueryComponents(videostatsWatchtimeUrl)
|
||||
queryParams["c"] = "TVHTML5"
|
||||
queryParams["cbrver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||
queryParams["cver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||
queryParams["ver"] = "2"
|
||||
queryParams["cpn"] = InnertubeService.CreateClientPlaybackNonce()
|
||||
queryParams["cmt"] = 0
|
||||
queryParams["final"] = "1"
|
||||
queryParams["st"] = timeStr
|
||||
queryParams["et"] = timeStr
|
||||
videostatsWatchtimeUrl = UrlUtils.SetQueryParams(videostatsWatchtimeUrl, queryParams)
|
||||
|
||||
request = HttpClient.Get(videostatsWatchtimeUrl)
|
||||
request.Cancellation(cancellation)
|
||||
request.NoCache()
|
||||
request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Tv))
|
||||
request.Header("Authorization", "Bearer " + accessToken)
|
||||
if not StringUtils.IsNullOrEmpty(onBehalfOfUser)
|
||||
request.Header("X-Goog-Pageid", onBehalfOfUser)
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
LogError("Error marking video watch time:", response.ErrorMessage())
|
||||
return false
|
||||
end if
|
||||
|
||||
LogDebug("Marked video watch time:", timeStr)
|
||||
return true
|
||||
end function
|
||||
|
||||
function CreateClientPlaybackNonce() as string
|
||||
length = 16
|
||||
result = []
|
||||
|
||||
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
alphabetLen = alphabet.len()
|
||||
for i = 1 to length
|
||||
result.push(alphabet.mid(Rnd(alphabetLen - 1), 1))
|
||||
end for
|
||||
|
||||
return result.join("")
|
||||
end function
|
||||
|
||||
function GetChannel(channelId as string, options = invalid as object) as object
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
raw = OptionUtils.GetOrDefault(options, "raw", false)
|
||||
|
||||
request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Web, options)
|
||||
request.Cancellation(cancellation)
|
||||
if raw
|
||||
request.LogCurlCommand()
|
||||
request.NoCache()
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
@@ -331,8 +402,157 @@ namespace InnertubeService
|
||||
}
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
result = Innertube.ParsePlaylistPageResponseData(json)
|
||||
if raw
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
result = Innertube.ParseChannelPageResponseData(response.Json())
|
||||
if result.authorId = invalid and result.error = invalid
|
||||
result["authorId"] = channelId
|
||||
end if
|
||||
|
||||
cacheControl = Innertube.ParseResponseForCacheControl(response)
|
||||
if cacheControl <> invalid
|
||||
result["cache-control"] = cacheControl
|
||||
end if
|
||||
|
||||
return result
|
||||
end function
|
||||
|
||||
function GetSubscriptionStatusForChannel(channelId as string, options = invalid as object) as object
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
|
||||
request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Tv, options)
|
||||
request.Cancellation(cancellation)
|
||||
if accessToken <> invalid
|
||||
request.Header("Authorization", "Bearer " + accessToken)
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
return {
|
||||
error: response.ErrorMessage()
|
||||
}
|
||||
end if
|
||||
|
||||
responseData = response.Json()
|
||||
error = Innertube.ParseResponseDataForError(responseData)
|
||||
|
||||
if error <> ""
|
||||
return {
|
||||
error: error
|
||||
}
|
||||
end if
|
||||
|
||||
channelHeaderButtons = ObjectUtils.Dig(responseData, ["contents", "tvBrowseRenderer", "content", "tvSurfaceContentRenderer", "header", "channelHeaderRenderer", "buttons"])
|
||||
if not IsArray(channelHeaderButtons)
|
||||
return {
|
||||
error: "Node 'contents.tvBrowseRenderer.content.tvSurfaceContentRenderer.header.channelHeaderRenderer.buttons' not found"
|
||||
}
|
||||
end if
|
||||
|
||||
subscribeButtonRenderer = invalid
|
||||
for each button in channelHeaderButtons
|
||||
if not IsAssociativeArray(button) or not button.DoesExist("subscribeButtonRenderer")
|
||||
continue for
|
||||
end if
|
||||
subscribeButtonRenderer = button.subscribeButtonRenderer
|
||||
exit for
|
||||
end for
|
||||
|
||||
if subscribeButtonRenderer = invalid
|
||||
return {
|
||||
error: "no 'subscribeButtonRenderer' found under 'buttons'"
|
||||
}
|
||||
end if
|
||||
|
||||
if not IsBool(subscribeButtonRenderer["subscribed"])
|
||||
return {
|
||||
error: "no 'subscribed' status found under 'subscribeButtonRenderer'"
|
||||
}
|
||||
end if
|
||||
|
||||
return {
|
||||
success: true
|
||||
isSubscribed: subscribeButtonRenderer["subscribed"]
|
||||
}
|
||||
end function
|
||||
|
||||
function SubscribeToChannel(channelId as string, options = invalid as object) as object
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
|
||||
request = Innertube.CreateSubscribeRequest(channelId, options)
|
||||
request.Cancellation(cancellation)
|
||||
if accessToken <> invalid
|
||||
request.Header("Authorization", "Bearer " + accessToken)
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
return {
|
||||
success: response.IsSuccess()
|
||||
error: response.ErrorMessage()
|
||||
}
|
||||
end function
|
||||
|
||||
function UnsubscribeFromChannel(channelId as string, options = invalid as object) as object
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
|
||||
request = Innertube.CreateUnsubscribeRequest(channelId, options)
|
||||
request.Cancellation(cancellation)
|
||||
if accessToken <> invalid
|
||||
request.Header("Authorization", "Bearer " + accessToken)
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
return {
|
||||
success: response.IsSuccess()
|
||||
error: response.ErrorMessage()
|
||||
}
|
||||
end function
|
||||
|
||||
function GetPlaylist(playlistId as string, options = invalid as object) as object
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
raw = OptionUtils.GetOrDefault(options, "raw", false)
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
|
||||
if not playlistId.StartsWith("VL")
|
||||
playlistId = "VL" + playlistId
|
||||
end if
|
||||
|
||||
client = Innertube.ClientType.Web
|
||||
if accessToken <> invalid
|
||||
client = Innertube.ClientType.Tv
|
||||
end if
|
||||
|
||||
request = Innertube.CreateBrowseRequest(playlistId, client, options)
|
||||
request.Cancellation(cancellation)
|
||||
if accessToken <> invalid
|
||||
request.Header("Authorization", "Bearer " + accessToken)
|
||||
end if
|
||||
if raw
|
||||
request.LogCurlCommand()
|
||||
request.NoCache()
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
return {
|
||||
error: response.ErrorMessage()
|
||||
}
|
||||
end if
|
||||
|
||||
if raw
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
result = Innertube.ParsePlaylistPageResponseData(response.Json())
|
||||
|
||||
if result.playlistId = invalid and result.error = invalid
|
||||
result["playlistId"] = playlistId
|
||||
end if
|
||||
|
||||
cacheControl = Innertube.ParseResponseForCacheControl(response)
|
||||
if cacheControl <> invalid
|
||||
@@ -343,24 +563,20 @@ namespace InnertubeService
|
||||
end function
|
||||
|
||||
function GetMix(mixId as string, options = invalid as object) as object
|
||||
videoId = ""
|
||||
cancellation = invalid
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("videoId")
|
||||
videoId = options.videoId
|
||||
end if
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
end if
|
||||
videoId = OptionUtils.Get(options, "videoId")
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
raw = OptionUtils.GetOrDefault(options, "raw", false)
|
||||
|
||||
args = { "playlistId": mixId }
|
||||
if videoId <> ""
|
||||
if not StringUtils.IsNullOrEmpty(videoId)
|
||||
args["videoId"] = videoId
|
||||
end if
|
||||
request = Innertube.CreateNextRequest(args, "")
|
||||
request = Innertube.CreateNextRequest(args)
|
||||
request.Cancellation(cancellation)
|
||||
if raw
|
||||
request.LogCurlCommand()
|
||||
request.NoCache()
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
@@ -369,18 +585,22 @@ namespace InnertubeService
|
||||
}
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
return Innertube.ParseMixPageResponseData(json)
|
||||
if raw
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
result = Innertube.ParseMixPageResponseData(response.Json())
|
||||
|
||||
cacheControl = Innertube.ParseResponseForCacheControl(response)
|
||||
if cacheControl <> invalid
|
||||
result["cache-control"] = cacheControl
|
||||
end if
|
||||
|
||||
return result
|
||||
end function
|
||||
|
||||
function ResolveUrl(url as string, options = invalid as object) as object
|
||||
cancellation = invalid
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
end if
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
|
||||
request = Innertube.CreateResolveUrlRequest(url)
|
||||
request.Cancellation(cancellation)
|
||||
@@ -399,14 +619,14 @@ namespace InnertubeService
|
||||
function AuthGetCode(cancellation = invalid as object) as object
|
||||
result = Innertube.GetClientIdentity(cancellation)
|
||||
|
||||
if CancellationUtils.IsCancelled(cancellation)
|
||||
return invalid
|
||||
if CancellationUtils.IsCancelled(cancellation) or result.error <> invalid
|
||||
return result
|
||||
end if
|
||||
|
||||
result2 = Innertube.GetDeviceAndUserCode(result.clientId, cancellation)
|
||||
|
||||
if CancellationUtils.IsCancelled(cancellation)
|
||||
return invalid
|
||||
if CancellationUtils.IsCancelled(cancellation) or result2.error <> invalid
|
||||
return result2
|
||||
end if
|
||||
|
||||
result.Append(result2)
|
||||
@@ -421,24 +641,19 @@ namespace InnertubeService
|
||||
return Innertube.PollForAccessToken(code, code, cancellation)
|
||||
end function
|
||||
|
||||
function AuthRefreshAccessTokenIfNeeded(accessToken as object, cancellation = invalid as object) as boolean
|
||||
function AuthRefreshAccessToken(accessToken as object, cancellation = invalid as object) as boolean
|
||||
if not IsAssociativeArray(accessToken)
|
||||
return false
|
||||
end if
|
||||
|
||||
nowSeconds = TimeUtils.Now().AsSeconds()
|
||||
expiresTimestamp = accessToken["expires_timestamp"]
|
||||
refreshed = Innertube.RefreshAccessToken(accessToken, cancellation)
|
||||
|
||||
if expiresTimestamp = invalid or expiresTimestamp < nowSeconds
|
||||
refreshed = Innertube.RefreshAccessToken(accessToken, cancellation)
|
||||
|
||||
if IsAssociativeArray(refreshed) and refreshed.DoesExist("accessToken")
|
||||
accessToken.Append(refreshed)
|
||||
if accessToken.DoesExist("expiresIn")
|
||||
accessToken["expiresTimestamp"] = TimeUtils.Now().AsSeconds() + accessToken["expiresIn"]
|
||||
end if
|
||||
return true
|
||||
if IsAssociativeArray(refreshed) and refreshed.DoesExist("accessToken")
|
||||
accessToken.Append(refreshed)
|
||||
if accessToken.DoesExist("expiresIn")
|
||||
accessToken["expiresTimestamp"] = TimeUtils.Now().AsSeconds() + accessToken["expiresIn"]
|
||||
end if
|
||||
return true
|
||||
end if
|
||||
|
||||
return false
|
||||
@@ -452,4 +667,7 @@ namespace InnertubeService
|
||||
return Innertube.RevokeAccessToken(accessToken["accessToken"], cancellation)
|
||||
end function
|
||||
|
||||
function AuthListAccounts(accessToken as string, cancellation = invalid as object) as object
|
||||
return Innertube.ListAccounts(accessToken, cancellation)
|
||||
end function
|
||||
end namespace
|
||||
@@ -8,21 +8,18 @@ import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace Innertube
|
||||
|
||||
function CreateNextRequest(payloadArgs as object, ctt as string) as object
|
||||
function CreateNextRequest(payloadArgs as object, options = invalid as object) as object
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
context = Innertube.CreateContext(Innertube.ClientType.Web, deviceInfo, options)
|
||||
|
||||
payload = {
|
||||
"context": Innertube.CreateContext(Innertube.ClientType.Web, deviceInfo, ctt)
|
||||
"context": context
|
||||
}
|
||||
payload.Append(payloadArgs)
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/next?prettyPrint=false&alt=json", payload)
|
||||
headers = {
|
||||
"accept": "*/*"
|
||||
"accept-language": "*"
|
||||
}
|
||||
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.Web))
|
||||
request.Headers(headers)
|
||||
request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Web))
|
||||
|
||||
return request
|
||||
end function
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
' Throw an error if an unknown node is encountered.
|
||||
' Only used in debug mode.
|
||||
#const THROW_ON_UNKNOWN_NODES = true
|
||||
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/ObjectUtils.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
@@ -21,7 +25,12 @@ namespace Innertube
|
||||
for each key in nodeData
|
||||
directive = directives[key]
|
||||
if directive = invalid
|
||||
LogWarn("Unknown node", key)
|
||||
LogWarn("Unknown node", key, `\n`, FormatJson(nodeData[key]))
|
||||
#if THROW_ON_UNKNOWN_NODES
|
||||
#if DEBUG
|
||||
throw "Unknown node: " + key
|
||||
#end if
|
||||
#end if
|
||||
continue for
|
||||
end if
|
||||
|
||||
@@ -33,18 +42,23 @@ namespace Innertube
|
||||
function GetParsingDirectives() as object
|
||||
return {
|
||||
"twoColumnSearchResultsRenderer": ParseTwoColumnSearchResultsRenderer
|
||||
"singleColumnBrowseResultsRenderer": ParseSingleColumnBrowseResultsRenderer
|
||||
"twoColumnBrowseResultsRenderer": ParseTwoColumnBrowseResultsRenderer
|
||||
"watchNextEndScreenRenderer": ParseWatchNextEndScreenRenderer
|
||||
"tabRenderer": ParseTabRenderer
|
||||
"sectionListRenderer": ParseSectionListRenderer
|
||||
"richSectionRenderer": ParseRichSectionRenderer
|
||||
"itemSectionRenderer": ParseItemSectionRenderer
|
||||
"shelfRenderer": ParseShelfRenderer
|
||||
"richShelfRenderer": ParseRichShelfRenderer
|
||||
"reelShelfRenderer": ParseReelShelfRenderer
|
||||
"verticalListRenderer": ParseVerticalListRenderer
|
||||
"horizontalListRenderer": ParseHorizontalListRenderer
|
||||
"horizontalListContinuation": ParseHorizontalListContinuation
|
||||
"expandedShelfContentsRenderer": ParseExpandedShelfContentsRenderer
|
||||
"channelFeaturedContentRenderer": ParseChannelFeaturedContentRenderer
|
||||
"playlistVideoListRenderer": ParsePlaylistVideoListRenderer
|
||||
"playlistVideoListContinuation": ParsePlaylistVideoListContinuation
|
||||
"videoRenderer": ParseVideoRenderer
|
||||
"gridVideoRenderer": ParseGridVideoRenderer
|
||||
"channelVideoPlayerRenderer": ParseChannelVideoPlayerRenderer
|
||||
@@ -55,12 +69,14 @@ namespace Innertube
|
||||
"gridChannelRenderer": ParseGridChannelRenderer
|
||||
"playlistRenderer": ParsePlaylistRenderer
|
||||
"gridPlaylistRenderer": ParseGridPlaylistRenderer
|
||||
"gridShelfViewModel": ParseGridShelfViewModel
|
||||
"lockupViewModel": ParseLockupViewModel
|
||||
"shortsLockupViewModel": ParseShortsLockupViewModel
|
||||
"tvBrowseRenderer": ParseTvBrowseRenderer
|
||||
"tvSurfaceContentRenderer": ParseTvSurfaceContentRenderer
|
||||
"tvSecondaryNavRenderer": ParseTvSecondaryNavRenderer
|
||||
"tvSecondaryNavSectionRenderer": ParseTvSecondaryNavSectionRenderer
|
||||
"twoColumnRenderer": ParseTwoColumnRenderer
|
||||
"tileRenderer": ParseTileRenderer
|
||||
"gridRenderer": ParseGridRenderer
|
||||
"richGridRenderer": ParseRichGridRenderer
|
||||
@@ -70,6 +86,8 @@ namespace Innertube
|
||||
"gridContinuation": ParseGridContinuation
|
||||
"tvSurfaceContentContinuation": ParseTvSurfaceContentContinuation
|
||||
' Ignored nodes:
|
||||
' A playlist at the end of a video. We don't need that for now.
|
||||
"endScreenPlaylistRenderer": ParseNotImplemented
|
||||
' Posts not yet supported
|
||||
"postRenderer": ParseNotImplemented
|
||||
' a "View all posts" button
|
||||
@@ -78,10 +96,25 @@ namespace Innertube
|
||||
"horizontalCardListRenderer": ParseNotImplemented
|
||||
' expandableTabRenderer contains the search tab with a channel. Ignored.
|
||||
"expandableTabRenderer": ParseNotImplemented
|
||||
' Shows a view of an official channel (like an artist) with tracks or albums.
|
||||
' Shows up in search results. Safe to ignore since the channel itself will also
|
||||
' be shown in the search results, so this is kind of a duplicate.
|
||||
"officialCardViewModel": ParseNotImplemented
|
||||
' Usually contains a "X unavailable video(s) are hidden" message. Ignored.
|
||||
"messageRenderer": ParseNotImplemented
|
||||
' Messages like "Videos you watch will be saved here"
|
||||
"genericPromoRenderer": ParseNotImplemented
|
||||
' "Sign in to see the latest videos tailored to your interests"
|
||||
"feedNudgeRenderer": ParseNotImplemented
|
||||
' "No results found, Try different keywords or remove search filters"
|
||||
"backgroundPromoRenderer": ParseNotImplemented
|
||||
"videoSurveyShelfRenderer": ParseNotImplemented
|
||||
"searchBarRenderer": ParseNotImplemented
|
||||
"clickTrackingParams": ParseNotImplemented
|
||||
"promoShelfRenderer": ParseNotImplemented
|
||||
"statementBannerRenderer": ParseNotImplemented
|
||||
"adSlotRenderer": ParseNotImplemented
|
||||
"adsControlFlowOpportunityReceivedCommand": ParseNotImplemented
|
||||
}
|
||||
end function
|
||||
|
||||
@@ -89,6 +122,10 @@ namespace Innertube
|
||||
return nodeData["primaryContents"]
|
||||
end function
|
||||
|
||||
function ParseSingleColumnBrowseResultsRenderer(nodeData as object, _context as object) as object
|
||||
return nodeData["tabs"]
|
||||
end function
|
||||
|
||||
function ParseTwoColumnBrowseResultsRenderer(nodeData as object, _context as object) as object
|
||||
return nodeData["tabs"]
|
||||
end function
|
||||
@@ -111,18 +148,22 @@ namespace Innertube
|
||||
return nodeData["contents"]
|
||||
end function
|
||||
|
||||
function ParseRichSectionRenderer(nodeData as object, _context as object) as object
|
||||
return nodeData["content"]
|
||||
end function
|
||||
|
||||
function ParseItemSectionRenderer(nodeData as object, _context as object) as object
|
||||
return nodeData["contents"]
|
||||
end function
|
||||
|
||||
function ParseShelfRenderer(nodeData as object, context as object) as object
|
||||
if context.skipCreatorOnTheRise = true
|
||||
if context.disableCreatorOnTheRise = true
|
||||
badges = nodeData["badges"]
|
||||
if IsArray(badges)
|
||||
for each badge in badges
|
||||
if ValidString(ObjectUtils.Dig(badge, ["metadataBadgeRenderer", "style"])) = "BADGE_STYLE_TYPE_FEATURED"
|
||||
label = ParseText(ObjectUtils.Dig(badge, ["metadataBadgeRenderer", "label"]))
|
||||
LogInfo(`Skipping 'Create on the Rise' shelf (${label})`)
|
||||
LogInfo(`Skipping 'Creator on the Rise' shelf (${label})`)
|
||||
return invalid
|
||||
end if
|
||||
end for
|
||||
@@ -134,7 +175,16 @@ namespace Innertube
|
||||
return nodeData["content"]
|
||||
end function
|
||||
|
||||
function ParseReelShelfRenderer(nodeData as object, _context as object) as object
|
||||
function ParseRichShelfRenderer(nodeData as object, _context as object) as object
|
||||
' TODO: handle richShelfRenderer.title
|
||||
return nodeData["contents"]
|
||||
end function
|
||||
|
||||
function ParseReelShelfRenderer(nodeData as object, context as object) as object
|
||||
if context.disableShorts = true
|
||||
LogInfo("Skipping ReelShelfRenderer based on user settings")
|
||||
return invalid
|
||||
end if
|
||||
' TODO: handle reelShelfRenderer.title
|
||||
return nodeData["items"]
|
||||
end function
|
||||
@@ -143,8 +193,25 @@ namespace Innertube
|
||||
return nodeData["items"]
|
||||
end function
|
||||
|
||||
function ParseHorizontalListRenderer(nodeData as object, _context as object) as object
|
||||
' TODO: handle continuations
|
||||
function ParseHorizontalListRenderer(nodeData as object, context as object) as object
|
||||
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
|
||||
if IsString(continuation)
|
||||
if not StringUtils.IsNullOrEmpty(context.currentFeed.continuation)
|
||||
StartNewFeed("", context)
|
||||
end if
|
||||
context.currentFeed.continuation = continuation
|
||||
end if
|
||||
return nodeData["items"]
|
||||
end function
|
||||
|
||||
function ParseHorizontalListContinuation(nodeData as object, context as object) as object
|
||||
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
|
||||
if IsString(continuation)
|
||||
if not StringUtils.IsNullOrEmpty(context.currentFeed.continuation)
|
||||
StartNewFeed("", context)
|
||||
end if
|
||||
context.currentFeed.continuation = continuation
|
||||
end if
|
||||
return nodeData["items"]
|
||||
end function
|
||||
|
||||
@@ -156,7 +223,19 @@ namespace Innertube
|
||||
return nodeData["items"]
|
||||
end function
|
||||
|
||||
function ParsePlaylistVideoListRenderer(nodeData as object, _context as object) as object
|
||||
function ParsePlaylistVideoListRenderer(nodeData as object, context as object) as object
|
||||
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
|
||||
if IsString(continuation)
|
||||
context.currentFeed.continuation = continuation
|
||||
end if
|
||||
return nodeData["contents"]
|
||||
end function
|
||||
|
||||
function ParsePlaylistVideoListContinuation(nodeData as object, context as object) as object
|
||||
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
|
||||
if IsString(continuation)
|
||||
context.currentFeed.continuation = continuation
|
||||
end if
|
||||
return nodeData["contents"]
|
||||
end function
|
||||
|
||||
@@ -202,20 +281,31 @@ namespace Innertube
|
||||
end if
|
||||
end if
|
||||
|
||||
liveNow = ValidString(ObjectUtils.Dig(nodeData, ["badges", 0, "metadataBadgeRenderer", "icon", "iconType"])) = "LIVE"
|
||||
if not liveNow
|
||||
thumbnailOverlays = nodeData["thumbnailOverlays"]
|
||||
if IsArray(thumbnailOverlays)
|
||||
for each overlay in thumbnailOverlays
|
||||
if ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "LIVE"
|
||||
liveNow = true
|
||||
exit for
|
||||
isUpcoming = false
|
||||
liveNow = false
|
||||
|
||||
thumbnailOverlays = nodeData["thumbnailOverlays"]
|
||||
if IsArray(thumbnailOverlays)
|
||||
for each overlay in thumbnailOverlays
|
||||
parsedTimeStatusRenderer = ParseThumbnailOverlayTimeStatusRenderer(overlay)
|
||||
if parsedTimeStatusRenderer <> invalid
|
||||
if parsedTimeStatusRenderer.isShort
|
||||
if context.disableShorts = true
|
||||
LogInfo("Skipping Short based on user settings")
|
||||
return invalid
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
liveNow = liveNow or parsedTimeStatusRenderer.isLive
|
||||
isUpcoming = isUpcoming or parsedTimeStatusRenderer.isUpcoming
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
if ValidString(ObjectUtils.Dig(nodeData, ["badges", 0, "metadataBadgeRenderer", "icon", "iconType"])) = "LIVE"
|
||||
liveNow = true
|
||||
end if
|
||||
|
||||
isUpcoming = false
|
||||
premiereTimestamp = ObjectUtils.Dig(nodeData, ["upcomingEventData", "startTime"])
|
||||
if IsString(premiereTimestamp)
|
||||
premiereTimestamp = premiereTimestamp.ToInt()
|
||||
@@ -288,9 +378,12 @@ namespace Innertube
|
||||
thumbnailOverlays = nodeData["thumbnailOverlays"]
|
||||
if IsArray(thumbnailOverlays)
|
||||
for each overlay in thumbnailOverlays
|
||||
lengthText = ParseText(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "text"]))
|
||||
if lengthText <> ""
|
||||
exit for
|
||||
parsedTimeStatusRenderer = ParseThumbnailOverlayTimeStatusRenderer(overlay)
|
||||
if parsedTimeStatusRenderer <> invalid
|
||||
lengthText = parsedTimeStatusRenderer.text
|
||||
if lengthText <> ""
|
||||
exit for
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
@@ -371,6 +464,7 @@ namespace Innertube
|
||||
|
||||
lengthText = ParseText(nodeData["lengthText"])
|
||||
lengthSeconds = ValidString(nodeData["lengthSeconds"]).ToInt()
|
||||
videoInfo = ParseText(nodeData["videoInfo"])
|
||||
|
||||
author = invalid
|
||||
authorId = invalid
|
||||
@@ -403,6 +497,7 @@ namespace Innertube
|
||||
"index": ParseText(nodeData["index"]).ToInt()
|
||||
"lengthText": lengthText
|
||||
"lengthSeconds": lengthSeconds
|
||||
"videoInfo": videoInfo
|
||||
}
|
||||
|
||||
PushFeedItem(video, context)
|
||||
@@ -442,8 +537,18 @@ namespace Innertube
|
||||
thumbnailOverlays = nodeData["thumbnailOverlays"]
|
||||
if IsArray(thumbnailOverlays)
|
||||
for each overlay in thumbnailOverlays
|
||||
liveNow = liveNow or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "LIVE")
|
||||
isUpcoming = isUpcoming or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "UPCOMING")
|
||||
parsedTimeStatusRenderer = ParseThumbnailOverlayTimeStatusRenderer(overlay)
|
||||
if parsedTimeStatusRenderer <> invalid
|
||||
if parsedTimeStatusRenderer.isShort
|
||||
if context.disableShorts = true
|
||||
LogInfo("Skipping Short based on user settings")
|
||||
return invalid
|
||||
end if
|
||||
end if
|
||||
|
||||
liveNow = liveNow or parsedTimeStatusRenderer.isLive
|
||||
isUpcoming = isUpcoming or parsedTimeStatusRenderer.isUpcoming
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
@@ -650,6 +755,10 @@ namespace Innertube
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function ParseGridShelfViewModel(nodeData as object, _context as object) as object
|
||||
return nodeData["contents"]
|
||||
end function
|
||||
|
||||
function ParseLockupViewModel(nodeData as object, context as object) as object
|
||||
contentType = ValidString(nodeData["contentType"])
|
||||
if contentType = "LOCKUP_CONTENT_TYPE_PLAYLIST"
|
||||
@@ -660,7 +769,12 @@ namespace Innertube
|
||||
return LockupViewModelTypeAlbum(nodeData, context)
|
||||
end if
|
||||
|
||||
LogWarn("Unknown content type:", contentType, `\n`, nodeData)
|
||||
LogWarn("Unknown content type:", contentType, `\n`, FormatJson(nodeData))
|
||||
#if THROW_ON_UNKNOWN_NODES
|
||||
#if DEBUG
|
||||
throw "Unknown content type: " + contentType
|
||||
#end if
|
||||
#end if
|
||||
return invalid
|
||||
end function
|
||||
|
||||
@@ -784,6 +898,11 @@ namespace Innertube
|
||||
end function
|
||||
|
||||
function ParseShortsLockupViewModel(nodeData as object, context as object) as object
|
||||
if context.disableShorts = true
|
||||
LogInfo("Skipping Short based on user settings")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
videoId = ObjectUtils.Dig(nodeData, ["onTap", "innertubeCommand", "reelWatchEndpoint", "videoId"])
|
||||
if not IsString(videoId)
|
||||
LogWarn("Invalid video ID", nodeData)
|
||||
@@ -837,15 +956,36 @@ namespace Innertube
|
||||
return nodeData["tabs"]
|
||||
end function
|
||||
|
||||
function ParseTwoColumnRenderer(nodeData as object, context as object) as object
|
||||
' twoColumnRenderer is used for Playlists on TV.
|
||||
' The right column has the videos (and continuation)
|
||||
' The left column has the playlist info (title, description, etc) which was already parsed
|
||||
return nodeData["rightColumn"]
|
||||
end function
|
||||
|
||||
function ParseTileRenderer(nodeData as object, context as object) as object
|
||||
contentType = ValidString(nodeData["contentType"])
|
||||
' A tileRenderer can be without a contentType, such as a
|
||||
' button that says "Open YouTube Kids" or similar CTAs
|
||||
if contentType = ""
|
||||
LogWarn(`TileRenderer without contentType:\n`, nodeData)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if contentType = "TILE_CONTENT_TYPE_VIDEO"
|
||||
return TileRendererTypeVideo(nodeData, context)
|
||||
else if contentType = "TILE_CONTENT_TYPE_SHORTS"
|
||||
return TileRendererTypeShorts(nodeData, context)
|
||||
else if contentType = "TILE_CONTENT_TYPE_PLAYLIST"
|
||||
return TileRendererTypePlaylist(nodeData, context)
|
||||
end if
|
||||
|
||||
LogWarn("Unknown content type:", contentType, `\n`, nodeData)
|
||||
LogWarn("Unknown content type:", contentType, `\n`, FormatJson(nodeData))
|
||||
#if THROW_ON_UNKNOWN_NODES
|
||||
#if DEBUG
|
||||
throw "Unknown content type: " + contentType
|
||||
#end if
|
||||
#end if
|
||||
return invalid
|
||||
end function
|
||||
|
||||
@@ -868,21 +1008,50 @@ namespace Innertube
|
||||
lengthText = ""
|
||||
isUpcoming = false
|
||||
liveNow = false
|
||||
percentDurationWatched = 0
|
||||
thumbnailOverlays = ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnailOverlays"])
|
||||
if IsArray(thumbnailOverlays)
|
||||
for each overlay in thumbnailOverlays
|
||||
maybeLengthText = ParseText(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "text"]))
|
||||
if maybeLengthText <> ""
|
||||
lengthText = maybeLengthText
|
||||
parsedTimeStatusRenderer = ParseThumbnailOverlayTimeStatusRenderer(overlay)
|
||||
if parsedTimeStatusRenderer <> invalid
|
||||
if parsedTimeStatusRenderer.isShort
|
||||
if context.disableShorts = true
|
||||
LogInfo("Skipping Short based on user settings")
|
||||
return invalid
|
||||
end if
|
||||
end if
|
||||
|
||||
maybeLengthText = parsedTimeStatusRenderer.text
|
||||
if maybeLengthText <> ""
|
||||
lengthText = maybeLengthText
|
||||
end if
|
||||
|
||||
liveNow = liveNow or parsedTimeStatusRenderer.isLive
|
||||
isUpcoming = isUpcoming or parsedTimeStatusRenderer.isUpcoming
|
||||
end if
|
||||
|
||||
maybePercentDurationWatched = ObjectUtils.Dig(overlay, ["thumbnailOverlayResumePlaybackRenderer", "percentDurationWatched"])
|
||||
if maybePercentDurationWatched <> invalid
|
||||
percentDurationWatched = maybePercentDurationWatched
|
||||
end if
|
||||
liveNow = liveNow or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "LIVE")
|
||||
isUpcoming = isUpcoming or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "UPCOMING")
|
||||
end for
|
||||
|
||||
if liveNow or isUpcoming
|
||||
lengthText = ""
|
||||
end if
|
||||
end if
|
||||
|
||||
renderedLines = []
|
||||
lines = ObjectUtils.Dig(nodeData, ["metadata", "tileMetadataRenderer", "lines"])
|
||||
if IsArray(lines)
|
||||
for each line in lines
|
||||
if not IsAssociativeArray(line)
|
||||
continue for
|
||||
end if
|
||||
renderedLines.Push(ParseLineRenderer(line["lineRenderer"]))
|
||||
end for
|
||||
end if
|
||||
|
||||
video = {
|
||||
"type": "video"
|
||||
"videoId": videoId
|
||||
@@ -891,6 +1060,51 @@ namespace Innertube
|
||||
"lengthText": lengthText
|
||||
"liveNow": liveNow
|
||||
"isUpcoming": isUpcoming
|
||||
"lines": renderedLines
|
||||
"percentDurationWatched": percentDurationWatched
|
||||
}
|
||||
|
||||
PushFeedItem(video, context)
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function TileRendererTypeShorts(nodeData as object, context as object) as object
|
||||
if context.disableShorts = true
|
||||
LogInfo("Skipping Short based on user settings")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
videoId = nodeData["contentId"]
|
||||
if not IsString(videoId)
|
||||
LogWarn("Invalid video ID", nodeData)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if context.generateVideoThumbnails = true
|
||||
videoThumbnails = GenerateVideoThumbnails(videoId)
|
||||
else
|
||||
videoThumbnails = ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnail", "thumbnails"])
|
||||
if videoThumbnails = invalid
|
||||
videoThumbnails = GenerateVideoThumbnails(videoId)
|
||||
end if
|
||||
end if
|
||||
|
||||
title = ""
|
||||
thumbnailOverlays = ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnailOverlays"])
|
||||
if IsArray(thumbnailOverlays)
|
||||
for each overlay in thumbnailOverlays
|
||||
title = ParseText(ObjectUtils.Dig(overlay, ["tileMetadataRenderer", "title"]))
|
||||
if title <> ""
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
video = {
|
||||
"type": "video"
|
||||
"videoId": videoId
|
||||
"title": title
|
||||
"videoThumbnails": videoThumbnails
|
||||
}
|
||||
|
||||
PushFeedItem(video, context)
|
||||
@@ -915,12 +1129,24 @@ namespace Innertube
|
||||
end for
|
||||
end if
|
||||
|
||||
renderedLines = []
|
||||
lines = ObjectUtils.Dig(nodeData, ["metadata", "tileMetadataRenderer", "lines"])
|
||||
if IsArray(lines)
|
||||
for each line in lines
|
||||
if not IsAssociativeArray(line)
|
||||
continue for
|
||||
end if
|
||||
renderedLines.Push(ParseLineRenderer(line["lineRenderer"]))
|
||||
end for
|
||||
end if
|
||||
|
||||
playlist = {
|
||||
"type": "playlist"
|
||||
"playlistId": playlistId
|
||||
"title": ParseText(ObjectUtils.Dig(nodeData, ["metadata", "tileMetadataRenderer", "title"]))
|
||||
"playlistThumbnail": ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnail", "thumbnails", 0, "url"])
|
||||
"videoCountText": videoCountText
|
||||
"lines": renderedLines
|
||||
}
|
||||
|
||||
PushFeedItem(playlist, context)
|
||||
@@ -967,7 +1193,7 @@ namespace Innertube
|
||||
return nodeData["items"]
|
||||
end function
|
||||
|
||||
function ParseTvSurfaceContentContinuation(nodeData as object, context as object) as object
|
||||
function ParseTvSurfaceContentContinuation(nodeData as object, _context as object) as object
|
||||
' title = ParseText(ObjectUtils.Dig(nodeData, ["header", "tvSurfaceHeaderRenderer", "title"]))
|
||||
return nodeData["content"]
|
||||
end function
|
||||
@@ -992,6 +1218,72 @@ namespace Innertube
|
||||
return ""
|
||||
end function
|
||||
|
||||
function ParseLineRenderer(data as object) as string
|
||||
if data = invalid
|
||||
return ""
|
||||
end if
|
||||
if IsString(data)
|
||||
return data
|
||||
end if
|
||||
if not IsAssociativeArray(data) or not data.DoesExist("items")
|
||||
return ""
|
||||
end if
|
||||
items = data["items"]
|
||||
if not IsArray(items)
|
||||
return ""
|
||||
end if
|
||||
texts = []
|
||||
for each item in items
|
||||
if IsString(item)
|
||||
texts.Push(item)
|
||||
else if IsAssociativeArray(item) and item.DoesExist("lineItemRenderer")
|
||||
texts.Push(ParseLineItemRenderer(item["lineItemRenderer"]))
|
||||
end if
|
||||
end for
|
||||
return texts.Join(" ")
|
||||
end function
|
||||
|
||||
function ParseLineItemRenderer(data as object) as string
|
||||
if data = invalid
|
||||
return ""
|
||||
end if
|
||||
if IsString(data)
|
||||
return data
|
||||
end if
|
||||
if not IsAssociativeArray(data) or not data.DoesExist("text")
|
||||
return ""
|
||||
end if
|
||||
return ParseText(data["text"])
|
||||
end function
|
||||
|
||||
function ParseThumbnailOverlayTimeStatusRenderer(data as object) as object
|
||||
if data = invalid
|
||||
return invalid
|
||||
end if
|
||||
if not IsAssociativeArray(data) or not data.DoesExist("thumbnailOverlayTimeStatusRenderer")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
renderer = data["thumbnailOverlayTimeStatusRenderer"]
|
||||
if not IsAssociativeArray(renderer)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
text = ParseText(renderer["text"])
|
||||
|
||||
overlayStyle = ValidString(renderer["style"])
|
||||
isLive = overlayStyle = "LIVE"
|
||||
isUpcoming = overlayStyle = "UPCOMING"
|
||||
isShort = overlayStyle = "SHORTS"
|
||||
|
||||
return {
|
||||
"text": text
|
||||
"isLive": isLive
|
||||
"isUpcoming": isUpcoming
|
||||
"isShort": isShort
|
||||
}
|
||||
end function
|
||||
|
||||
function StartNewFeed(title as string, context as object) as void
|
||||
if context.currentFeed <> invalid
|
||||
if context.currentFeed.items.Count() = 0 and context.currentFeed.title = ""
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import "pkg:/source/services/HttpClient.bs"
|
||||
import "pkg:/source/utils/ObjectUtils.bs"
|
||||
import "pkg:/source/utils/TimeUtils.bs"
|
||||
|
||||
namespace Innertube
|
||||
@@ -14,7 +15,9 @@ namespace Innertube
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
throw `Failed to get client id: ${response.ErrorMessage()}`
|
||||
return {
|
||||
"error": `Failed to get client id: ${response.ErrorMessage()}`
|
||||
}
|
||||
end if
|
||||
|
||||
text = response.Text()
|
||||
@@ -23,7 +26,9 @@ namespace Innertube
|
||||
|
||||
match = scriptRegex.Match(text)
|
||||
if match.Count() < 2
|
||||
throw "Could not find base-js script"
|
||||
return {
|
||||
"error": "Could not find base-js script"
|
||||
}
|
||||
end if
|
||||
|
||||
baseJsUrl = "https://www.youtube.com" + match[1]
|
||||
@@ -33,7 +38,9 @@ namespace Innertube
|
||||
response = request.Await()
|
||||
|
||||
if not response.IsSuccess()
|
||||
throw `Failed to get base js: ${response.ErrorMessage()}`
|
||||
return {
|
||||
"error": `Failed to get base js: ${response.ErrorMessage()}`
|
||||
}
|
||||
end if
|
||||
|
||||
text = response.Text()
|
||||
@@ -42,7 +49,9 @@ namespace Innertube
|
||||
|
||||
match = clientIdRegex.Match(text)
|
||||
if match.Count() < 3
|
||||
throw "Could not find client id"
|
||||
return {
|
||||
"error": "Could not find client id and secret"
|
||||
}
|
||||
end if
|
||||
|
||||
return {
|
||||
@@ -66,13 +75,17 @@ namespace Innertube
|
||||
response = request.Await()
|
||||
|
||||
if not response.IsSuccess()
|
||||
throw `Failed to get device code: ${response.ErrorMessage()}`
|
||||
return {
|
||||
"error": `Failed to get device code: ${response.ErrorMessage()}`
|
||||
}
|
||||
end if
|
||||
|
||||
responseData = ToCamelCase(response.Json())
|
||||
|
||||
if responseData.DoesExist("errorCode")
|
||||
throw "Failed to get device code: " + ToString(responseData)
|
||||
return {
|
||||
"error": "Failed to get device code: " + ToString(responseData)
|
||||
}
|
||||
end if
|
||||
|
||||
if responseData.DoesExist("expiresIn")
|
||||
@@ -130,11 +143,13 @@ namespace Innertube
|
||||
end if
|
||||
continue while
|
||||
else if responseData.error = "expired_token"
|
||||
throw "Failed to get access token: " + ToString(responseData)
|
||||
return responseData
|
||||
else if responseData.error = "access_denied"
|
||||
throw "Failed to get access token: " + ToString(responseData)
|
||||
return responseData
|
||||
else
|
||||
throw "Failed to get access token: " + ToString(responseData)
|
||||
return {
|
||||
"error": "Failed to get access token: " + ToString(responseData)
|
||||
}
|
||||
end if
|
||||
end while
|
||||
|
||||
@@ -171,12 +186,113 @@ namespace Innertube
|
||||
request.Cancellation(cancellation)
|
||||
response = request.Await()
|
||||
success = response.IsSuccess()
|
||||
if success
|
||||
if not success
|
||||
LogError(`Failed to revoke token: ${response.ErrorMessage()}`)
|
||||
end if
|
||||
return success
|
||||
end function
|
||||
|
||||
function ListAccounts(accessToken as string, cancellation = invalid as dynamic) as object
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
payload = {
|
||||
"context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo)
|
||||
"accountReadMask": {
|
||||
"returnOwner": true
|
||||
"returnBrandAccounts": true
|
||||
"returnPersonaAccounts": true
|
||||
"returnFamilyChildAccounts": true
|
||||
}
|
||||
}
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/account/accounts_list", payload)
|
||||
headers = {
|
||||
"Authorization": `Bearer ${accessToken}`
|
||||
}
|
||||
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.Tv))
|
||||
request.Headers(headers)
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
response = request.Await()
|
||||
|
||||
if not response.IsSuccess()
|
||||
return {
|
||||
"error": `Failed to list accounts: ${response.ErrorMessage()}`
|
||||
}
|
||||
end if
|
||||
|
||||
accounts = ObjectUtils.Dig(response.Json(), ["contents", 0, "accountSectionListRenderer", "contents", 0, "accountItemSectionRenderer", "contents"])
|
||||
if not IsArray(accounts)
|
||||
return {
|
||||
"error": "Could not parse accounts"
|
||||
}
|
||||
end if
|
||||
|
||||
parsedAccounts = []
|
||||
for each account in accounts
|
||||
accountItem = account["accountItem"]
|
||||
if not IsAssociativeArray(accountItem)
|
||||
continue for
|
||||
end if
|
||||
|
||||
parsedAccount = {
|
||||
"accountName": ParseText(accountItem["accountName"])
|
||||
"accountPhoto": ObjectUtils.Dig(accountItem, ["accountPhoto", "thumbnails", 0, "url"])
|
||||
"isSelected": ValidBool(accountItem["isSelected"])
|
||||
"isDisabled": ValidBool(accountItem["isDisabled"])
|
||||
"hasChannel": ValidBool(accountItem["hasChannel"])
|
||||
"accountByline": ParseText(accountItem["accountByline"])
|
||||
"channelHandle": ParseText(accountItem["channelHandle"])
|
||||
"activeIdentifyToken": ParseAccountItemIdentityToken(accountItem)
|
||||
}
|
||||
parsedAccounts.Push(parsedAccount)
|
||||
end for
|
||||
|
||||
return parsedAccounts
|
||||
end function
|
||||
|
||||
function ParseAccountItemIdentityToken(accountItem as object) as string
|
||||
' Although selected (default) account would have a token, we usually don't
|
||||
' need it, since we don't need to pass the "onBehalfOfUser" argument
|
||||
' when using selected account.
|
||||
if ValidBool(accountItem.isSelected)
|
||||
return ""
|
||||
end if
|
||||
|
||||
supportedTokens = ObjectUtils.Dig(accountItem, ["serviceEndpoint", "selectActiveIdentityEndpoint", "supportedTokens"])
|
||||
if not IsArray(supportedTokens) or supportedTokens.Count() = 0
|
||||
return ""
|
||||
end if
|
||||
|
||||
for each supportedToken in supportedTokens
|
||||
if not IsAssociativeArray(supportedToken)
|
||||
continue for
|
||||
end if
|
||||
|
||||
' TODO:P2 should we stick with pageId, and ignore the rest?
|
||||
pageId = ObjectUtils.Dig(supportedToken, ["pageIdToken", "pageId"])
|
||||
if not StringUtils.IsNullOrEmpty(pageId)
|
||||
return pageId
|
||||
end if
|
||||
|
||||
obfuscatedGaiaId = ObjectUtils.Dig(supportedToken, ["accountStateToken", "obfuscatedGaiaId"])
|
||||
if not StringUtils.IsNullOrEmpty(obfuscatedGaiaId)
|
||||
return obfuscatedGaiaId
|
||||
end if
|
||||
|
||||
datasyncIdToken = ObjectUtils.Dig(supportedToken, ["datasyncIdToken", "datasyncIdToken"])
|
||||
if not StringUtils.IsNullOrEmpty(datasyncIdToken)
|
||||
' "datasyncIdToken": "123456789012345678901||123456789012345678901"
|
||||
match = /(\d+)\|\|(\d+)/.match(datasyncIdToken)
|
||||
if match.Count() = 3
|
||||
return match[1]
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
|
||||
return ""
|
||||
end function
|
||||
|
||||
function ToCamelCase(obj as object) as object
|
||||
if not IsAssociativeArray(obj)
|
||||
return obj
|
||||
|
||||
@@ -10,9 +10,7 @@ namespace Innertube
|
||||
return []
|
||||
end if
|
||||
|
||||
if context = invalid
|
||||
context = {}
|
||||
end if
|
||||
context = ValidAssociativeArray(context)
|
||||
|
||||
if not ValidBool(context.noContainers)
|
||||
containers = GetContainers(responseData)
|
||||
@@ -58,6 +56,9 @@ namespace Innertube
|
||||
end if
|
||||
|
||||
author = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "title"])
|
||||
if author = invalid
|
||||
author = ObjectUtils.Dig(responseData, ["header", "pageHeaderRenderer", "pageTitle"])
|
||||
end if
|
||||
authorId = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "externalId"])
|
||||
|
||||
thumbnails = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "avatar", "thumbnails"])
|
||||
@@ -103,6 +104,7 @@ namespace Innertube
|
||||
|
||||
tabsNames = []
|
||||
tabsParams = {}
|
||||
tabsTitles = {}
|
||||
|
||||
tabs = ObjectUtils.Dig(responseData, ["contents", "twoColumnBrowseResultsRenderer", "tabs"])
|
||||
if tabs <> invalid
|
||||
@@ -123,13 +125,17 @@ namespace Innertube
|
||||
continue for
|
||||
end if
|
||||
|
||||
tabParams = ObjectUtils.Dig(tabRenderer, ["endpoint", "browseEndpoint", "params"])
|
||||
if tabParams = invalid
|
||||
continue for
|
||||
tabsNames.Push(tabName)
|
||||
|
||||
tabTitle = tabRenderer["title"]
|
||||
if IsString(tabTitle)
|
||||
tabsTitles[tabName] = tabTitle
|
||||
end if
|
||||
|
||||
tabsNames.Push(tabName)
|
||||
tabsParams[tabName] = tabParams
|
||||
tabParams = ObjectUtils.Dig(tabRenderer, ["endpoint", "browseEndpoint", "params"])
|
||||
if IsString(tabParams)
|
||||
tabsParams[tabName] = tabParams
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
@@ -151,6 +157,7 @@ namespace Innertube
|
||||
"authorSubTitle": authorSubTitle
|
||||
"tabs": tabsNames
|
||||
"tabsParams": tabsParams
|
||||
"tabsTitles": tabsTitles
|
||||
"items": items
|
||||
}
|
||||
|
||||
@@ -175,44 +182,85 @@ namespace Innertube
|
||||
}
|
||||
end if
|
||||
|
||||
playlistId = invalid
|
||||
title = invalid
|
||||
author = invalid
|
||||
authorId = invalid
|
||||
description = invalid
|
||||
videoCount = -1
|
||||
thumbnail = invalid
|
||||
statsText = invalid
|
||||
|
||||
playlistSidebarRendererItems = ObjectUtils.Dig(responseData, ["sidebar", "playlistSidebarRenderer", "items"])
|
||||
if playlistSidebarRendererItems <> invalid
|
||||
primaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [0, "playlistSidebarPrimaryInfoRenderer"])
|
||||
secondaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [1, "playlistSidebarSecondaryInfoRenderer"])
|
||||
|
||||
primaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [0, "playlistSidebarPrimaryInfoRenderer"])
|
||||
secondaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [1, "playlistSidebarSecondaryInfoRenderer"])
|
||||
playlistId = ObjectUtils.Dig(primaryInfo, ["navigationEndpoint", "watchEndpoint", "playlistId"])
|
||||
title = ParseText(ObjectUtils.Dig(primaryInfo, ["title"]))
|
||||
description = ParseText(ObjectUtils.Dig(primaryInfo, ["description"]))
|
||||
videoCount = ParseText(ObjectUtils.Dig(primaryInfo, ["stats", 0, "runs", 0, "text"])).ToInt()
|
||||
thumbnail = ObjectUtils.Dig(primaryInfo, ["thumbnailRenderer", "playlistVideoThumbnailRenderer", "thumbnail", "thumbnails", 0, "url"])
|
||||
|
||||
playlistId = ObjectUtils.Dig(primaryInfo, ["navigationEndpoint", "watchEndpoint", "playlistId"])
|
||||
title = ParseText(ObjectUtils.Dig(primaryInfo, ["title"]))
|
||||
description = ParseText(ObjectUtils.Dig(primaryInfo, ["description"]))
|
||||
videoCount = ParseText(ObjectUtils.Dig(primaryInfo, ["stats", 0, "runs", 0, "text"])).ToInt()
|
||||
thumbnail = ObjectUtils.Dig(primaryInfo, ["thumbnailRenderer", "playlistVideoThumbnailRenderer", "thumbnail", "thumbnails", 0, "url"])
|
||||
author = ParseText(ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "title"]))
|
||||
authorId = ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "navigationEndpoint", "browseEndpoint", "browseId"])
|
||||
stats = ObjectUtils.Dig(primaryInfo, ["stats"])
|
||||
if IsArray(stats)
|
||||
statsTexts = []
|
||||
for each stat in stats
|
||||
statText = ParseText(stat)
|
||||
if statText <> ""
|
||||
statsTexts.Push(statText)
|
||||
end if
|
||||
end for
|
||||
statsText = statsTexts.Join(" • ")
|
||||
end if
|
||||
end if
|
||||
|
||||
author = ParseText(ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "title"]))
|
||||
authorId = ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "navigationEndpoint", "browseEndpoint", "browseId"])
|
||||
|
||||
statsText = ""
|
||||
stats = ObjectUtils.Dig(primaryInfo, ["stats"])
|
||||
if IsArray(stats)
|
||||
statsTexts = []
|
||||
for each stat in stats
|
||||
statText = ParseText(stat)
|
||||
if statText <> ""
|
||||
statsTexts.Push(statText)
|
||||
twoColumnRenderer = ObjectUtils.Dig(responseData, ["contents", "tvBrowseRenderer", "content", "tvSurfaceContentRenderer", "content", "twoColumnRenderer"])
|
||||
if twoColumnRenderer <> invalid
|
||||
entityMetadataRenderer = ObjectUtils.Dig(twoColumnRenderer, ["leftColumn", "entityMetadataRenderer"])
|
||||
if entityMetadataRenderer <> invalid
|
||||
if title = invalid
|
||||
title = ParseText(entityMetadataRenderer["title"])
|
||||
end if
|
||||
end for
|
||||
statsText = statsTexts.Join(" • ")
|
||||
if statsText = invalid
|
||||
statsText = ParseLineRenderer(ObjectUtils.Dig(entityMetadataRenderer, ["bylines", 0, "lineRenderer"]))
|
||||
end if
|
||||
if description = invalid
|
||||
description = ParseText(entityMetadataRenderer["description"])
|
||||
end if
|
||||
if playlistId = invalid
|
||||
playlistId = ObjectUtils.Dig(twoColumnRenderer, ["rightColumn", "playlistVideoListRenderer", "playlistId"])
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
playlist = {
|
||||
"playlistId": playlistId
|
||||
"title": title
|
||||
"author": author
|
||||
"authorId": authorId
|
||||
"description": description
|
||||
"videoCount": videoCount
|
||||
"thumbnail": thumbnail
|
||||
"videos": []
|
||||
"statsText": statsText
|
||||
}
|
||||
if playlistId <> invalid
|
||||
playlist["playlistId"] = playlistId
|
||||
end if
|
||||
if title <> invalid
|
||||
playlist["title"] = title
|
||||
end if
|
||||
if author <> invalid
|
||||
playlist["author"] = author
|
||||
end if
|
||||
if authorId <> invalid
|
||||
playlist["authorId"] = authorId
|
||||
end if
|
||||
if description <> invalid
|
||||
playlist["description"] = description
|
||||
end if
|
||||
if thumbnail <> invalid
|
||||
playlist["thumbnail"] = thumbnail
|
||||
end if
|
||||
if statsText <> invalid
|
||||
playlist["statsText"] = statsText
|
||||
end if
|
||||
|
||||
feeds = ParseResponseDataForFeeds(responseData)
|
||||
if feeds.Count() > 0
|
||||
@@ -222,6 +270,10 @@ namespace Innertube
|
||||
end if
|
||||
end if
|
||||
|
||||
if playlist["thumbnail"] = invalid and playlist["videos"].Count() > 0
|
||||
playlist["thumbnail"] = ObjectUtils.Dig(playlist, ["videos", 0, "thumbnails", 0, "url"])
|
||||
end if
|
||||
|
||||
return playlist
|
||||
end function
|
||||
|
||||
@@ -279,16 +331,37 @@ namespace Innertube
|
||||
end function
|
||||
|
||||
function ParseResponseDataForError(responseData as object) as string
|
||||
error = ""
|
||||
if responseData = invalid
|
||||
return ""
|
||||
return error
|
||||
end if
|
||||
|
||||
alert = ObjectUtils.Dig(responseData, ["alerts", 0, "alertRenderer"])
|
||||
if IsAssociativeArray(alert) and alert.type = "ERROR"
|
||||
return ParseText(alert.text)
|
||||
alerts = responseData["alerts"]
|
||||
if not IsArray(alerts) or alerts.Count() = 0
|
||||
return error
|
||||
end if
|
||||
|
||||
return ""
|
||||
for each alert in alerts
|
||||
if not IsAssociativeArray(alert)
|
||||
continue for
|
||||
end if
|
||||
|
||||
alertRenderer = alert["alertRenderer"]
|
||||
if alertRenderer = invalid
|
||||
alertRenderer = alert["alertWithButtonRenderer"]
|
||||
end if
|
||||
if not IsAssociativeArray(alertRenderer)
|
||||
continue for
|
||||
end if
|
||||
|
||||
alertText = ParseText(alertRenderer.text)
|
||||
LogWarn("Innertube Alert:", `[${alertRenderer.type}]`, alertText)
|
||||
if alertRenderer.type = "ERROR"
|
||||
error += alertText
|
||||
end if
|
||||
end for
|
||||
|
||||
return error
|
||||
end function
|
||||
|
||||
function ParseResponseForCacheControl(response as object) as dynamic
|
||||
|
||||
@@ -6,12 +6,16 @@ import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace Innertube
|
||||
|
||||
function CreatePlayerRequest(videoId as string, ctt as string) as object
|
||||
function CreatePlayerRequest(videoId as string, client as Innertube.ClientType, options = invalid as object) as object
|
||||
visitorData = OptionUtils.Get(options, "visitorData")
|
||||
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
context = Innertube.CreateContext(client, deviceInfo, options)
|
||||
|
||||
payload = {
|
||||
"videoId": videoId
|
||||
"context": Innertube.CreateContext(Innertube.ClientType.IOS, deviceInfo, ctt)
|
||||
"context": context
|
||||
"playbackContext": {
|
||||
"contentPlaybackContext": {
|
||||
"vis": 0
|
||||
@@ -32,48 +36,19 @@ namespace Innertube
|
||||
}
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/player?prettyPrint=false&alt=json", payload)
|
||||
headers = {
|
||||
"accept": "*/*"
|
||||
"accept-language": "*"
|
||||
}
|
||||
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.IOS))
|
||||
request.Headers(headers)
|
||||
request.Headers(Innertube.CreateHeaders(client))
|
||||
if not StringUtils.IsNullOrEmpty(visitorData)
|
||||
request.Header("x-goog-visitor-id", visitorData)
|
||||
end if
|
||||
|
||||
return request
|
||||
end function
|
||||
|
||||
function ParseInnertubePlayerResponse(payload as object) as object
|
||||
if not IsAssociativeArray(payload)
|
||||
error = ParsePlayerResponseForError(payload)
|
||||
if error <> ""
|
||||
return {
|
||||
error: "Invalid payload"
|
||||
}
|
||||
end if
|
||||
|
||||
playabilityStatus = payload["playabilityStatus"]
|
||||
if not IsAssociativeArray(playabilityStatus)
|
||||
return {
|
||||
error: "Invalid playability status"
|
||||
}
|
||||
end if
|
||||
|
||||
if playabilityStatus["status"] <> "OK"
|
||||
errorMessage = ""
|
||||
if IsString(playabilityStatus["reason"])
|
||||
errorMessage = playabilityStatus["reason"]
|
||||
end if
|
||||
|
||||
subreason = ParseText(ObjectUtils.Dig(playabilityStatus, ["errorScreen", "playerErrorMessageRenderer", "subreason"]))
|
||||
|
||||
if subreason <> ""
|
||||
errorMessage += `\n` + subreason
|
||||
end if
|
||||
|
||||
if errorMessage = ""
|
||||
errorMessage = "Video not available"
|
||||
end if
|
||||
|
||||
return {
|
||||
error: errorMessage
|
||||
error: error
|
||||
}
|
||||
end if
|
||||
|
||||
@@ -92,6 +67,7 @@ namespace Innertube
|
||||
end if
|
||||
|
||||
lengthSeconds = videoDetails["lengthSeconds"].ToInt()
|
||||
|
||||
videoInfo = {
|
||||
"type": "video"
|
||||
"title": videoDetails["title"]
|
||||
@@ -113,6 +89,38 @@ namespace Innertube
|
||||
return videoInfo
|
||||
end function
|
||||
|
||||
function ParsePlayerResponseForError(payload as object) as string
|
||||
if not IsAssociativeArray(payload)
|
||||
return "Invalid payload"
|
||||
end if
|
||||
|
||||
playabilityStatus = payload["playabilityStatus"]
|
||||
if not IsAssociativeArray(playabilityStatus)
|
||||
return "Invalid playability status"
|
||||
end if
|
||||
|
||||
if playabilityStatus["status"] = "OK"
|
||||
return ""
|
||||
end if
|
||||
|
||||
errorMessage = ""
|
||||
if IsString(playabilityStatus["reason"])
|
||||
errorMessage = playabilityStatus["reason"]
|
||||
end if
|
||||
|
||||
subreason = ParseText(ObjectUtils.Dig(playabilityStatus, ["errorScreen", "playerErrorMessageRenderer", "subreason"]))
|
||||
|
||||
if subreason <> ""
|
||||
errorMessage += `\n` + subreason
|
||||
end if
|
||||
|
||||
if errorMessage = ""
|
||||
errorMessage = "Video not available"
|
||||
end if
|
||||
|
||||
return errorMessage
|
||||
end function
|
||||
|
||||
function ParseStoryboards(payload as object, lengthSeconds as integer) as object
|
||||
storyboard = ObjectUtils.Dig(payload, ["storyboards", "playerLiveStoryboardSpecRenderer", "spec"])
|
||||
if IsString(storyboard)
|
||||
|
||||
@@ -6,17 +6,12 @@ namespace Innertube
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
payload = {
|
||||
"context": CreateContext(ClientType.Web, deviceInfo, "")
|
||||
"context": CreateContext(ClientType.Web, deviceInfo)
|
||||
"url": url
|
||||
}
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/navigation/resolve_url?prettyPrint=false&alt=json", payload)
|
||||
headers = {
|
||||
"accept": "*/*"
|
||||
"accept-language": "*"
|
||||
}
|
||||
headers.Append(CreateHeaders(ClientType.Web))
|
||||
request.Headers(headers)
|
||||
request.Headers(Innertube.CreateHeaders(ClientType.Web))
|
||||
|
||||
return request
|
||||
end function
|
||||
|
||||
@@ -2,18 +2,25 @@ import "pkg:/components/Services/Innertube/Context.bs"
|
||||
import "pkg:/components/Services/Innertube/Parser.bs"
|
||||
import "pkg:/components/Services/Innertube/SearchFilters.bs"
|
||||
import "pkg:/source/services/HttpClient.bs"
|
||||
import "pkg:/source/utils/OptionUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace Innertube
|
||||
|
||||
function Search(query as string, searchFilters as object, continuation = "" as string, cancellation = invalid as object) as object
|
||||
function Search(query as string, options = invalid as object) as object
|
||||
searchFilters = OptionUtils.Get(options, "searchFilters")
|
||||
continuation = OptionUtils.Get(options, "continuation")
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
|
||||
raw = OptionUtils.GetOrDefault(options, "raw", false)
|
||||
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
payload = {
|
||||
context: Innertube.CreateContext(Innertube.ClientType.WEB, deviceInfo, "")
|
||||
context: Innertube.CreateContext(Innertube.ClientType.WEB, deviceInfo)
|
||||
}
|
||||
|
||||
if continuation <> ""
|
||||
if not StringUtils.IsNullOrEmpty(continuation)
|
||||
payload["continuation"] = continuation
|
||||
else
|
||||
payload["query"] = query
|
||||
@@ -26,15 +33,13 @@ namespace Innertube
|
||||
end if
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/search?prettyPrint=false&alt=json", payload)
|
||||
request.Headers({
|
||||
"accept": "*/*"
|
||||
"accept-language": "*"
|
||||
"user-agent": INNERTUBE_WEB_USER_AGENT
|
||||
"x-youtube-client-name": INNERTUBE_WEB_CLIENT_NAME
|
||||
"x-youtube-client-version": INNERTUBE_WEB_CLIENT_VERSION
|
||||
})
|
||||
request.Headers(Innertube.CreateHeaders(ClientType.Web))
|
||||
|
||||
request.Cancellation(cancellation)
|
||||
if raw
|
||||
request.NoCache()
|
||||
request.LogCurlCommand()
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
@@ -43,7 +48,11 @@ namespace Innertube
|
||||
}
|
||||
end if
|
||||
|
||||
feeds = ParseResponseDataForFeeds(response.Json())
|
||||
if raw
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
feeds = ParseResponseDataForFeeds(response.Json(), { disableShorts: disableShorts })
|
||||
|
||||
result = {
|
||||
feeds: feeds
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import "pkg:/components/Services/Innertube/Constants.bs"
|
||||
import "pkg:/source/services/HttpClient.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/ObjectUtils.bs"
|
||||
import "pkg:/source/utils/RegistryUtils.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/TimeUtils.bs"
|
||||
|
||||
namespace Innertube
|
||||
|
||||
const SESSION_DATA_VERSION = 1
|
||||
const INNERTUBE_VISITOR_DATA_LIFESPAN_SECONDS = 60 * 60 * 24
|
||||
|
||||
function GetSessionData() as object
|
||||
sessionData = ReadSessionDataFromRegistry()
|
||||
if sessionData <> invalid
|
||||
return sessionData
|
||||
end if
|
||||
|
||||
sessionData = RequestSessionData()
|
||||
if sessionData = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
RegistryUtils.Write(RegistryUtils.INNERTUBE_SESSION_DATA, FormatJson(sessionData))
|
||||
return sessionData
|
||||
end function
|
||||
|
||||
function RequestSessionData() as object
|
||||
request = HttpClient.Get("https://www.youtube.com/sw.js_data")
|
||||
request.Headers({
|
||||
"Accept-Language": "en-US,en;q=0.9"
|
||||
"User-Agent": INNERTUBE_WEB_USER_AGENT
|
||||
"Accept": "*/*"
|
||||
"Referer": "https://www.youtube.com/sw.js"
|
||||
})
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
LogError("Failed to fetch session data", response.ErrorMessage())
|
||||
return invalid
|
||||
end if
|
||||
|
||||
text = ValidString(response.Text())
|
||||
if not text.StartsWith(")]}'")
|
||||
LogError("Invalid session data response", text)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
text = text.Replace(")]}'", "")
|
||||
json = ParseJson(text)
|
||||
if json = invalid
|
||||
LogError("Failed to parse session data", text)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
visitorData = ObjectUtils.Dig(json, [0, 2, 0, 0, 13])
|
||||
if StringUtils.IsNullOrEmpty(visitorData)
|
||||
LogError("Visitor data not found", text)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
return {
|
||||
"__version": SESSION_DATA_VERSION
|
||||
"timestamp": TimeUtils.Now().AsSeconds()
|
||||
"visitorData": visitorData
|
||||
}
|
||||
end function
|
||||
|
||||
function ReadSessionDataFromRegistry() as object
|
||||
sessionData = RegistryUtils.Read(RegistryUtils.INNERTUBE_SESSION_DATA)
|
||||
if StringUtils.IsNullOrEmpty(sessionData)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
sessionData = ParseJson(sessionData)
|
||||
if sessionData = invalid
|
||||
RegistryUtils.Delete(RegistryUtils.INNERTUBE_SESSION_DATA)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
timestamp = sessionData.timestamp
|
||||
nowSeconds = TimeUtils.Now().AsSeconds()
|
||||
if nowSeconds - timestamp > INNERTUBE_VISITOR_DATA_LIFESPAN_SECONDS
|
||||
RegistryUtils.Delete(RegistryUtils.INNERTUBE_SESSION_DATA)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
return sessionData
|
||||
end function
|
||||
end namespace
|
||||
@@ -0,0 +1,42 @@
|
||||
import "pkg:/components/Services/Innertube/Context.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace Innertube
|
||||
|
||||
function CreateSubscribeRequest(channelIds as dynamic, options = invalid as object) as object
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
payload = {
|
||||
"context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo, options)
|
||||
}
|
||||
|
||||
if IsString(channelIds)
|
||||
channelIds = [channelIds]
|
||||
end if
|
||||
payload["channelIds"] = channelIds
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/subscription/subscribe?prettyPrint=false&alt=json", payload)
|
||||
request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Tv))
|
||||
|
||||
return request
|
||||
end function
|
||||
|
||||
function CreateUnsubscribeRequest(channelIds as dynamic, options = invalid as object) as object
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
payload = {
|
||||
"context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo, options)
|
||||
}
|
||||
|
||||
if IsString(channelIds)
|
||||
channelIds = [channelIds]
|
||||
end if
|
||||
payload["channelIds"] = channelIds
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/subscription/unsubscribe?prettyPrint=false&alt=json", payload)
|
||||
request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Tv))
|
||||
|
||||
return request
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -7,25 +7,14 @@ function Init()
|
||||
m.service = new Invidious.InvidiousService(m.top)
|
||||
end function
|
||||
|
||||
function GetCurrentInstance(_unused as dynamic) as string
|
||||
function GetInstance(_unused as dynamic) as string
|
||||
return m.service.GetInstance()
|
||||
end function
|
||||
|
||||
function GetInvidiousInstance(_unused as dynamic) as string
|
||||
return m.service.GetInvidiousInstance()
|
||||
end function
|
||||
|
||||
function GetAuthorizeTokenLink(_unused as dynamic) as dynamic
|
||||
return m.service.GetAuthorizeTokenLink()
|
||||
end function
|
||||
|
||||
function OnAuthTokenChange() as void
|
||||
m.top.refreshSubscribtions = true
|
||||
end function
|
||||
|
||||
function GetSubscriptions() as void
|
||||
if m.subscriptionsTask <> invalid
|
||||
m.subscriptionsTask.cancel = true
|
||||
end if
|
||||
if m.top.authToken = invalid
|
||||
m.top.subscriptions = invalid
|
||||
return
|
||||
end if
|
||||
m.subscriptionsTask = AsyncTask.Start(Tasks.InvidiousSubscriptionsTask, { invidious: m.top })
|
||||
end function
|
||||
Loaded 100 of 207 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user