Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
No files matched your search
+87
-1
@@ -5,6 +5,92 @@ 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.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
|
||||
@@ -13,7 +99,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- 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
|
||||
### 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.
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -2,7 +2,7 @@ openapi: 3.0.0
|
||||
|
||||
info:
|
||||
title: Playlet Web API
|
||||
version: 0.36.1
|
||||
version: 0.38.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
|
||||
|
||||
@@ -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
+717
-466
File diff suppressed because it is too large.
Load diff
+21
-17
@@ -1,36 +1,37 @@
|
||||
{
|
||||
"name": "playlet",
|
||||
"version": "0.36.1",
|
||||
"version": "0.38.0",
|
||||
"description": "Unofficial YouTube client for Roku",
|
||||
"devDependencies": {
|
||||
"@rokucommunity/bslint": "^0.8.28",
|
||||
"@rokucommunity/bslint": "^0.8.31",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/node": "^22.10.7",
|
||||
"@types/node": "^22.15.18",
|
||||
"@types/xml2js": "^0.4.14",
|
||||
"argparse": "^2.0.1",
|
||||
"brighterscript": "0.68.3",
|
||||
"brighterscript-formatter": "^1.7.8",
|
||||
"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",
|
||||
"dotenv": "^16.5.0",
|
||||
"fs-extra": "^11.3.0",
|
||||
"glob": "^11.0.1",
|
||||
"glob": "^11.0.2",
|
||||
"imap": "^0.8.19",
|
||||
"ip": "^2.0.1",
|
||||
"json5": "^2.2.3",
|
||||
"mailparser": "^3.7.2",
|
||||
"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"
|
||||
@@ -62,15 +63,18 @@
|
||||
"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.40.2"
|
||||
}
|
||||
}
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "playlet-app",
|
||||
"version": "0.36.1",
|
||||
"version": "0.38.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playlet-app",
|
||||
"version": "0.36.1"
|
||||
"version": "0.38.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playlet-app",
|
||||
"version": "0.36.1",
|
||||
"version": "0.38.0",
|
||||
"description": "Unofficial YouTube client for Roku",
|
||||
"scripts": {
|
||||
"prebuild": "rm -rf ../build/playlet-app",
|
||||
|
||||
@@ -2,8 +2,8 @@ title=Playlet
|
||||
|
||||
# Do not update version manually, it is auto updated from package.json
|
||||
major_version=0
|
||||
minor_version=36
|
||||
build_version=00001
|
||||
minor_version=38
|
||||
build_version=00000
|
||||
|
||||
ui_resolutions=hd
|
||||
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "playlet-lib",
|
||||
"version": "0.36.1",
|
||||
"version": "0.38.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playlet-lib",
|
||||
"version": "0.36.1"
|
||||
"version": "0.38.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playlet-lib",
|
||||
"version": "0.36.1",
|
||||
"version": "0.38.0",
|
||||
"description": "Unofficial YouTube client for Roku",
|
||||
"scripts": {
|
||||
"prebuild": "rm -rf ../build/playlet-lib",
|
||||
|
||||
@@ -159,18 +159,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
|
||||
|
||||
@@ -350,25 +357,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()
|
||||
@@ -380,9 +372,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,6 +2,7 @@
|
||||
<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="bookmarksService" type="node" bind="/BookmarksService" />
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
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
|
||||
})
|
||||
|
||||
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>
|
||||
@@ -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,7 @@
|
||||
<field id="accessToken" type="string" />
|
||||
|
||||
<!-- Innertube fields -->
|
||||
<field id="thumbnail" type="uri" />
|
||||
<field id="refreshToken" type="string" />
|
||||
<field id="scope" type="string" />
|
||||
<field id="tokenType" type="string" />
|
||||
@@ -17,5 +18,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,7 @@
|
||||
<field id="title" type="string" />
|
||||
<field id="videoId" type="string" />
|
||||
<field id="viewCountText" type="string" />
|
||||
<field id="lines" type="stringarray" />
|
||||
<field id="percentDurationWatched" type="float" />
|
||||
</interface>
|
||||
</component>
|
||||
File renamed without changes.
+1
-1
@@ -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" />
|
||||
@@ -0,0 +1,51 @@
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/source/utils/Locale.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")
|
||||
' TODO:P2 localize all dialog items
|
||||
scanLabel.text = Tr(Locale.Dialogs.ScanTheQrCode)
|
||||
end function
|
||||
|
||||
function OnNodeReady()
|
||||
m.task = AsyncTask.Start(Tasks.YouTubeLoginTask, {
|
||||
dialog: m.top
|
||||
profilesService: m.top.profilesService
|
||||
})
|
||||
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,49 @@
|
||||
<component name="YouTubeLoginDialog" extends="StandardDialog" initialFocus="buttonArea" includes="AutoBind">
|
||||
<interface>
|
||||
<field id="profilesService" type="node" bind="/ProfilesService" />
|
||||
<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>
|
||||
<StdDlgTextItem 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]" />
|
||||
<Label
|
||||
horizAlign="center"
|
||||
width="400"
|
||||
translation="[0, 380]"
|
||||
text="https://yt.be/activate">
|
||||
<Font role="font" uri="font:MediumSystemFontFile" size="18" />
|
||||
</Label>
|
||||
</StdDlgSideCardArea>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,118 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.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
|
||||
LogError(authCode.error)
|
||||
DialogUtils.ShowDialogEx({
|
||||
title: "Error"
|
||||
message: authCode.error
|
||||
large: true
|
||||
})
|
||||
return invalid
|
||||
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
|
||||
LogError(accessToken.error)
|
||||
DialogUtils.ShowDialogEx({
|
||||
title: "Error"
|
||||
message: accessToken.error
|
||||
large: true
|
||||
})
|
||||
return invalid
|
||||
end if
|
||||
|
||||
accounts = InnertubeService.AuthListAccounts(accessToken.accessToken, cancellation)
|
||||
|
||||
if CancellationUtils.IsCancelled(cancellation)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if IsAssociativeArray(accounts) and accounts.error <> invalid
|
||||
LogError(accounts.error)
|
||||
DialogUtils.ShowDialogEx({
|
||||
title: "Error"
|
||||
message: accounts.error
|
||||
large: true
|
||||
})
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if not IsArray(accounts) or accounts.Count() = 0
|
||||
LogError("No accounts found")
|
||||
DialogUtils.ShowDialogEx({
|
||||
title: "Error"
|
||||
message: "No accounts found"
|
||||
large: true
|
||||
})
|
||||
return invalid
|
||||
end if
|
||||
|
||||
selectedAccount = invalid
|
||||
for each account in accounts
|
||||
if ValidBool(account.isSelected)
|
||||
selectedAccount = account
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
|
||||
if selectedAccount = invalid
|
||||
selectedAccount = accounts[0]
|
||||
end if
|
||||
|
||||
profile = CreateProfileContentNode(selectedAccount, accessToken)
|
||||
profilesNode@.LoginWithProfile(profile)
|
||||
|
||||
dialogNode.close = true
|
||||
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function CreateProfileContentNode(account 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 = account.channelHandle
|
||||
if StringUtils.IsNullOrEmpty(username)
|
||||
username = account.accountByline
|
||||
end if
|
||||
profile.username = username
|
||||
profile.thumbnail = account.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
|
||||
@@ -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
|
||||
@@ -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>
|
||||
+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
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<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>
|
||||
<BackendTypeContentNode id="BackendTypeYouTube" title="YouTube" backendLogoUri="pkg:/images/youtube-logo.png" />
|
||||
<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()
|
||||
|
||||
+11
-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,13 @@
|
||||
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 +79,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,79 @@ 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
|
||||
' TODO:P2 localize
|
||||
dialog = DialogUtils.ShowDialogEx({
|
||||
title: "Disclaimer"
|
||||
message: [
|
||||
"Playlet is a third-party app and is not affiliated with, endorsed by, or sponsored by YouTube or Google. All trademarks and registered trademarks mentioned are the property of their respective owners and are used only for identification purposes."
|
||||
"By using Playlet and signing in with your YouTube account, you acknowledge that you do so at your own risk. The developers of Playlet are not liable for any harm, including but not limited to data loss, account suspension or ban, hacking, or loss of content."
|
||||
"Use responsibly, especially if your YouTube account is tied to business or monetization."
|
||||
]
|
||||
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
|
||||
|
||||
+11
-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,13 @@
|
||||
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 +66,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.
+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
|
||||
|
||||
@@ -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,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_DEVICE_MODEL = "iPhone16,2"
|
||||
const INNERTUBE_IOS_OS_VERSION = "18.1"
|
||||
const INNERTUBE_IOS_USER_AGENT = "com.google.ios.youtube/19.49.7 (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 = "135.0.0.0"
|
||||
const INNERTUBE_WEB_CLIENT_NAME = "1"
|
||||
const INNERTUBE_WEB_CLIENT_VERSION = "2.20250502.01.00"
|
||||
const INNERTUBE_WEB_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.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_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)"
|
||||
@@ -123,7 +123,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"
|
||||
}
|
||||
@@ -162,7 +162,12 @@ namespace Innertube
|
||||
end function
|
||||
|
||||
function GetCurrentLocale(deviceInfo as object) as string
|
||||
return deviceInfo.GetCurrentLocale()
|
||||
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
|
||||
|
||||
@@ -7,6 +7,7 @@ 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"
|
||||
@@ -39,8 +40,12 @@ namespace InnertubeService
|
||||
end if
|
||||
end if
|
||||
|
||||
playerRequest = Innertube.CreatePlayerRequest(videoId, ctt, visitorData)
|
||||
playerRequest = Innertube.CreatePlayerRequest(videoId, ctt, visitorData, Innertube.ClientType.IOS)
|
||||
playerRequest.Cancellation(cancellation)
|
||||
if raw
|
||||
playerRequest.LogCurlCommand()
|
||||
playerRequest.NoCache()
|
||||
end if
|
||||
playerRequest.Send()
|
||||
|
||||
nextRequest = invalid
|
||||
@@ -48,6 +53,10 @@ namespace InnertubeService
|
||||
if fetchNext
|
||||
nextRequest = Innertube.CreateNextRequest({ "videoId": videoId }, ctt)
|
||||
nextRequest.Cancellation(cancellation)
|
||||
if raw
|
||||
nextRequest.LogCurlCommand()
|
||||
nextRequest.NoCache()
|
||||
end if
|
||||
nextRequest.Send()
|
||||
end if
|
||||
|
||||
@@ -209,10 +218,13 @@ namespace InnertubeService
|
||||
trendingType = LCase(ValidString(options.type))
|
||||
|
||||
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
|
||||
end if
|
||||
@@ -224,9 +236,16 @@ namespace InnertubeService
|
||||
request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, 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
|
||||
|
||||
if raw
|
||||
@@ -288,11 +307,142 @@ namespace InnertubeService
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
return invalid
|
||||
return {
|
||||
error: response.ErrorMessage()
|
||||
}
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
return Innertube.ParseResponseDataForFeeds(json)
|
||||
feeds = Innertube.ParseResponseDataForFeeds(response.Json())
|
||||
|
||||
result = {
|
||||
feeds: feeds
|
||||
}
|
||||
|
||||
cacheControl = Innertube.ParseResponseForCacheControl(response)
|
||||
if cacheControl <> invalid
|
||||
result["cache-control"] = cacheControl
|
||||
end if
|
||||
|
||||
return result
|
||||
end function
|
||||
|
||||
function AuthGetPlaybackTrackingUrls(videoId as string, options as object) as object
|
||||
cancellation = invalid
|
||||
accessToken = options.accessToken
|
||||
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
|
||||
playerRequest = Innertube.CreatePlayerRequest(videoId, "", "", Innertube.ClientType.Tv)
|
||||
playerRequest.Cancellation(cancellation)
|
||||
playerRequest.Header("Authorization", "Bearer " + accessToken)
|
||||
|
||||
playerResponse = playerRequest.Await()
|
||||
if not playerResponse.IsSuccess()
|
||||
return {
|
||||
error: playerResponse.ErrorMessage()
|
||||
}
|
||||
end if
|
||||
|
||||
json = playerResponse.Json()
|
||||
|
||||
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 = invalid
|
||||
accessToken = options.accessToken
|
||||
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
|
||||
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)
|
||||
|
||||
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 = invalid
|
||||
accessToken = options.accessToken
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
end if
|
||||
|
||||
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)
|
||||
|
||||
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
|
||||
@@ -318,6 +468,10 @@ namespace InnertubeService
|
||||
|
||||
request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Web, params, continuation)
|
||||
request.Cancellation(cancellation)
|
||||
if raw
|
||||
request.LogCurlCommand()
|
||||
request.NoCache()
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
@@ -343,10 +497,123 @@ namespace InnertubeService
|
||||
return result
|
||||
end function
|
||||
|
||||
function GetSubscriptionStatusForChannel(channelId as string, options = invalid as object) as object
|
||||
cancellation = invalid
|
||||
accessToken = options.accessToken
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
end if
|
||||
|
||||
request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Tv, "", "")
|
||||
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 = invalid
|
||||
accessToken = options.accessToken
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
end if
|
||||
|
||||
request = Innertube.CreateSubscribeRequest(channelId, "")
|
||||
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 = invalid
|
||||
accessToken = options.accessToken
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
end if
|
||||
|
||||
request = Innertube.CreateUnsubscribeRequest(channelId, "")
|
||||
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
|
||||
continuation = ""
|
||||
cancellation = invalid
|
||||
raw = false
|
||||
accessToken = invalid
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("continuation")
|
||||
@@ -358,14 +625,29 @@ namespace InnertubeService
|
||||
if options.DoesExist("raw")
|
||||
raw = options.raw
|
||||
end if
|
||||
if options.DoesExist("accessToken")
|
||||
accessToken = options.accessToken
|
||||
end if
|
||||
end if
|
||||
|
||||
if not playlistId.StartsWith("VL")
|
||||
playlistId = "VL" + playlistId
|
||||
end if
|
||||
|
||||
request = Innertube.CreateBrowseRequest(playlistId, Innertube.ClientType.Web, "", continuation)
|
||||
client = Innertube.ClientType.Web
|
||||
if accessToken <> invalid
|
||||
client = Innertube.ClientType.Tv
|
||||
end if
|
||||
|
||||
request = Innertube.CreateBrowseRequest(playlistId, client, "", continuation)
|
||||
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()
|
||||
@@ -380,6 +662,10 @@ namespace InnertubeService
|
||||
|
||||
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
|
||||
result["cache-control"] = cacheControl
|
||||
@@ -411,6 +697,10 @@ namespace InnertubeService
|
||||
end if
|
||||
request = Innertube.CreateNextRequest(args, "")
|
||||
request.Cancellation(cancellation)
|
||||
if raw
|
||||
request.LogCurlCommand()
|
||||
request.NoCache()
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
@@ -423,7 +713,14 @@ namespace InnertubeService
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
return Innertube.ParseMixPageResponseData(response.Json())
|
||||
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
|
||||
@@ -452,14 +749,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)
|
||||
@@ -474,24 +771,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
|
||||
@@ -505,4 +797,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
|
||||
@@ -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,6 +42,7 @@ namespace Innertube
|
||||
function GetParsingDirectives() as object
|
||||
return {
|
||||
"twoColumnSearchResultsRenderer": ParseTwoColumnSearchResultsRenderer
|
||||
"singleColumnBrowseResultsRenderer": ParseSingleColumnBrowseResultsRenderer
|
||||
"twoColumnBrowseResultsRenderer": ParseTwoColumnBrowseResultsRenderer
|
||||
"watchNextEndScreenRenderer": ParseWatchNextEndScreenRenderer
|
||||
"tabRenderer": ParseTabRenderer
|
||||
@@ -44,9 +54,11 @@ namespace Innertube
|
||||
"reelShelfRenderer": ParseReelShelfRenderer
|
||||
"verticalListRenderer": ParseVerticalListRenderer
|
||||
"horizontalListRenderer": ParseHorizontalListRenderer
|
||||
"horizontalListContinuation": ParseHorizontalListContinuation
|
||||
"expandedShelfContentsRenderer": ParseExpandedShelfContentsRenderer
|
||||
"channelFeaturedContentRenderer": ParseChannelFeaturedContentRenderer
|
||||
"playlistVideoListRenderer": ParsePlaylistVideoListRenderer
|
||||
"playlistVideoListContinuation": ParsePlaylistVideoListContinuation
|
||||
"videoRenderer": ParseVideoRenderer
|
||||
"gridVideoRenderer": ParseGridVideoRenderer
|
||||
"channelVideoPlayerRenderer": ParseChannelVideoPlayerRenderer
|
||||
@@ -57,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
|
||||
@@ -72,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
|
||||
@@ -80,10 +96,24 @@ 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
|
||||
"adSlotRenderer": ParseNotImplemented
|
||||
"adsControlFlowOpportunityReceivedCommand": ParseNotImplemented
|
||||
}
|
||||
end function
|
||||
|
||||
@@ -91,6 +121,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
|
||||
@@ -140,7 +174,7 @@ namespace Innertube
|
||||
return nodeData["content"]
|
||||
end function
|
||||
|
||||
function ParseRichShelfRenderer(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
|
||||
@@ -154,8 +188,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
|
||||
|
||||
@@ -167,7 +218,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
|
||||
|
||||
@@ -661,6 +724,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"
|
||||
@@ -671,7 +738,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
|
||||
|
||||
@@ -848,15 +920,34 @@ 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_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
|
||||
|
||||
@@ -879,6 +970,7 @@ namespace Innertube
|
||||
lengthText = ""
|
||||
isUpcoming = false
|
||||
liveNow = false
|
||||
percentDurationWatched = 0
|
||||
thumbnailOverlays = ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnailOverlays"])
|
||||
if IsArray(thumbnailOverlays)
|
||||
for each overlay in thumbnailOverlays
|
||||
@@ -886,6 +978,10 @@ namespace Innertube
|
||||
if maybeLengthText <> ""
|
||||
lengthText = maybeLengthText
|
||||
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
|
||||
@@ -894,6 +990,17 @@ namespace Innertube
|
||||
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
|
||||
@@ -902,6 +1009,8 @@ namespace Innertube
|
||||
"lengthText": lengthText
|
||||
"liveNow": liveNow
|
||||
"isUpcoming": isUpcoming
|
||||
"lines": renderedLines
|
||||
"percentDurationWatched": percentDurationWatched
|
||||
}
|
||||
|
||||
PushFeedItem(video, context)
|
||||
@@ -926,12 +1035,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)
|
||||
@@ -978,7 +1099,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
|
||||
@@ -1003,6 +1124,44 @@ 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 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,70 @@ 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"])
|
||||
}
|
||||
parsedAccounts.Push(parsedAccount)
|
||||
end for
|
||||
|
||||
return parsedAccounts
|
||||
end function
|
||||
|
||||
function ToCamelCase(obj as object) as object
|
||||
if not IsAssociativeArray(obj)
|
||||
return obj
|
||||
|
||||
@@ -184,44 +184,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
|
||||
@@ -231,6 +272,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
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace Innertube
|
||||
|
||||
function CreatePlayerRequest(videoId as string, ctt as string, visitorData as string) as object
|
||||
function CreatePlayerRequest(videoId as string, ctt as string, visitorData as string, client as Innertube.ClientType) as object
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
payload = {
|
||||
"videoId": videoId
|
||||
"context": Innertube.CreateContext(Innertube.ClientType.IOS, deviceInfo, ctt, visitorData)
|
||||
"context": Innertube.CreateContext(client, deviceInfo, ctt, visitorData)
|
||||
"playbackContext": {
|
||||
"contentPlaybackContext": {
|
||||
"vis": 0
|
||||
@@ -36,7 +36,7 @@ namespace Innertube
|
||||
"accept": "*/*"
|
||||
"accept-language": "*"
|
||||
}
|
||||
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.IOS))
|
||||
headers.Append(Innertube.CreateHeaders(client))
|
||||
request.Headers(headers)
|
||||
|
||||
return request
|
||||
@@ -92,6 +92,7 @@ namespace Innertube
|
||||
end if
|
||||
|
||||
lengthSeconds = videoDetails["lengthSeconds"].ToInt()
|
||||
|
||||
videoInfo = {
|
||||
"type": "video"
|
||||
"title": videoDetails["title"]
|
||||
|
||||
@@ -35,6 +35,10 @@ namespace Innertube
|
||||
})
|
||||
|
||||
request.Cancellation(cancellation)
|
||||
if raw
|
||||
request.NoCache()
|
||||
request.LogCurlCommand()
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
|
||||
@@ -9,7 +9,7 @@ import "pkg:/source/utils/TimeUtils.bs"
|
||||
namespace Innertube
|
||||
|
||||
const SESSION_DATA_VERSION = 1
|
||||
const INNERTUBE_VISITOR_DATA_LIFESPAN = 1000 * 60 * 60 * 24
|
||||
const INNERTUBE_VISITOR_DATA_LIFESPAN_SECONDS = 60 * 60 * 24
|
||||
|
||||
function GetSessionData() as object
|
||||
sessionData = ReadSessionDataFromRegistry()
|
||||
@@ -81,7 +81,7 @@ namespace Innertube
|
||||
|
||||
timestamp = sessionData.timestamp
|
||||
nowSeconds = TimeUtils.Now().AsSeconds()
|
||||
if nowSeconds - timestamp > INNERTUBE_VISITOR_DATA_LIFESPAN
|
||||
if nowSeconds - timestamp > INNERTUBE_VISITOR_DATA_LIFESPAN_SECONDS
|
||||
RegistryUtils.Delete(RegistryUtils.INNERTUBE_SESSION_DATA)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import "pkg:/components/Services/Innertube/Context.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace Innertube
|
||||
|
||||
function CreateSubscribeRequest(channelIds as dynamic, params as string) as object
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
payload = {
|
||||
"context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo, "", "")
|
||||
}
|
||||
|
||||
if IsString(channelIds)
|
||||
channelIds = [channelIds]
|
||||
end if
|
||||
payload["channelIds"] = channelIds
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(params)
|
||||
payload["params"] = params
|
||||
end if
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/subscription/subscribe?prettyPrint=false&alt=json", payload)
|
||||
headers = {
|
||||
"accept": "*/*"
|
||||
"accept-language": "*"
|
||||
}
|
||||
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.Tv))
|
||||
request.Headers(headers)
|
||||
|
||||
return request
|
||||
end function
|
||||
|
||||
function CreateUnsubscribeRequest(channelIds as dynamic, params as string) as object
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
payload = {
|
||||
"context": Innertube.CreateContext(Innertube.ClientType.Tv, deviceInfo, "", "")
|
||||
}
|
||||
|
||||
if IsString(channelIds)
|
||||
channelIds = [channelIds]
|
||||
end if
|
||||
payload["channelIds"] = channelIds
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(params)
|
||||
payload["params"] = params
|
||||
end if
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/subscription/unsubscribe?prettyPrint=false&alt=json", payload)
|
||||
headers = {
|
||||
"accept": "*/*"
|
||||
"accept-language": "*"
|
||||
}
|
||||
headers.Append(Innertube.CreateHeaders(Innertube.ClientType.Tv))
|
||||
request.Headers(headers)
|
||||
|
||||
return request
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -14,18 +14,3 @@ 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
|
||||
@@ -5,10 +5,8 @@
|
||||
<field id="webServer" type="node" />
|
||||
<field id="profilesService" type="node" />
|
||||
|
||||
<field id="authToken" type="assocarray" onChange="OnAuthTokenChange" />
|
||||
<field id="authToken" type="assocarray" />
|
||||
<field id="apiDefinitions" type="assocarray" />
|
||||
<field id="refreshSubscribtions" type="boolean" alwaysNotify="true" onChange="GetSubscriptions" />
|
||||
<field id="subscriptions" type="assocarray" />
|
||||
|
||||
<function name="GetCurrentInstance" />
|
||||
<function name="GetAuthorizeTokenLink" />
|
||||
|
||||
@@ -6,6 +6,8 @@ import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/source/services/HttpClient.bs"
|
||||
import "pkg:/source/utils/CryptoUtils.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/MessagePortUtils.bs"
|
||||
import "pkg:/source/utils/OptionUtils.bs"
|
||||
import "pkg:/source/utils/RegistryUtils.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/TimeUtils.bs"
|
||||
@@ -14,7 +16,6 @@ namespace Invidious
|
||||
const INSTANCES_API = "https://api.invidious.io/instances.json?sort_by=type,users"
|
||||
|
||||
const DEFAULT_INSTANCE = "http://127.0.0.1:8888/playlet-invidious-backend"
|
||||
const DEFAULT_INSTANCE_NAME = "Playlet built-in backend"
|
||||
const INSTANCE_EXAMPLE = "https://invidious.example.com"
|
||||
|
||||
const TOKEN_CALLBACK = "/invidious/token_callback"
|
||||
@@ -70,6 +71,7 @@ namespace Invidious
|
||||
m.preferences = m.invidiousNode.preferences
|
||||
end if
|
||||
instance = m.preferences["invidious.instance"]
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(instance)
|
||||
return instance
|
||||
end if
|
||||
@@ -83,7 +85,7 @@ namespace Invidious
|
||||
return instance
|
||||
end function
|
||||
|
||||
function MarkVideoWatched(videoId as dynamic) as void
|
||||
function MarkVideoWatched(videoId as dynamic, cancellation = invalid as object) as void
|
||||
if StringUtils.IsNullOrEmpty(videoId)
|
||||
return
|
||||
end if
|
||||
@@ -96,6 +98,7 @@ namespace Invidious
|
||||
url = `${authToken.instance}${Invidious.HISTORY_ENDPOINT}/${videoId}`
|
||||
request = HttpClient.Post(url, "")
|
||||
request.Headers(m.GetAuthenticationHeaders(authToken.token))
|
||||
request.Cancellation(cancellation)
|
||||
request.Await()
|
||||
end function
|
||||
|
||||
@@ -178,9 +181,7 @@ namespace Invidious
|
||||
|
||||
function GetPlaylist(playlistId as string, index = 0 as integer, continuation = "" as string, cancellation = invalid as object) as object
|
||||
authToken = m.invidiousNode.authToken
|
||||
' There's no need to use auth, unless the playlist is from Invidious
|
||||
' (starts with "IV") because it can be a private playlist from logged user.
|
||||
if playlistId.StartsWith("IV") and authToken <> invalid
|
||||
if authToken <> invalid
|
||||
url = `${authToken.instance}${Invidious.AUTH_PLAYLISTS}/${playlistId}`
|
||||
request = HttpClient.Get(url)
|
||||
request.Headers(m.GetAuthenticationHeaders(authToken.token))
|
||||
@@ -259,7 +260,11 @@ namespace Invidious
|
||||
return feedSource
|
||||
end function
|
||||
|
||||
function MakeRequest(feedSource as object, additionalQueryParams = invalid as object, cancellation = invalid as object) as object
|
||||
function MakeRequest(feedSource as object, options = invalid as dynamic) as object
|
||||
additionalQueryParams = OptionUtils.Get(options, "additionalQueryParams")
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
httpServer = OptionUtils.Get(options, "httpServer")
|
||||
|
||||
if m.endpoints = invalid
|
||||
m.endpoints = m.invidiousNode.apiDefinitions
|
||||
end if
|
||||
@@ -286,6 +291,20 @@ namespace Invidious
|
||||
error: ERROR_NOT_AUTHENTICATED
|
||||
}
|
||||
end if
|
||||
profileNode = authToken.profileNode
|
||||
' This is not the right place for a token refresh,
|
||||
' but it needs a refactor to be done properly.
|
||||
if not profileNode@.HasValidAccessToken()
|
||||
messagePort = CreateObject("roMessagePort")
|
||||
MessagePortUtils.ObserveFieldScopedExSafe(profileNode, "accessToken", messagePort)
|
||||
msg = wait(10000, messagePort)
|
||||
profileNode.unobserveFieldScoped("accessToken")
|
||||
if msg <> invalid
|
||||
authToken.token = profileNode.accessToken
|
||||
m.invidiousNode.authToken = authToken
|
||||
end if
|
||||
end if
|
||||
|
||||
request.Url(authToken.instance + endpoint.url)
|
||||
request.Headers(m.GetAuthenticationHeaders(authToken.token))
|
||||
end if
|
||||
@@ -335,7 +354,7 @@ namespace Invidious
|
||||
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
response = request.Await()
|
||||
response = m.SendRequest(request, httpServer)
|
||||
|
||||
responseHandler = invalid
|
||||
if IsString(endpoint.responseHandler) and m.DoesExist(endpoint.responseHandler)
|
||||
@@ -359,10 +378,39 @@ namespace Invidious
|
||||
return {
|
||||
success: false
|
||||
error: response.ErrorMessage()
|
||||
cancelled: response.IsCancelled()
|
||||
}
|
||||
end if
|
||||
end function
|
||||
|
||||
function SendRequest(request as HttpClient.HttpRequest, httpServer as dynamic) as dynamic
|
||||
if httpServer = invalid
|
||||
return request.Await()
|
||||
end if
|
||||
|
||||
url = request.BuildUrl()
|
||||
isUrlToLocalServer = url.StartsWith("http://127.0.0.1:8888") or url.StartsWith(m.invidiousNode.webServer@.GetServerAddress())
|
||||
if not isUrlToLocalServer
|
||||
return request.Await()
|
||||
end if
|
||||
|
||||
parsedUrl = UrlUtils.ParseUrl(url)
|
||||
method = request.GetMethod()
|
||||
uri = parsedUrl.path
|
||||
headers = request.GetHeaders()
|
||||
body = ValidString(request.GetBody())
|
||||
responseObj = httpServer.ProcessRequestLocal(method, uri, headers, body)
|
||||
response = new HttpClient.HttpResponse(request, invalid)
|
||||
response.OverrideStatusCode(responseObj.http_code)
|
||||
response.OverrideHeaders(responseObj.headers)
|
||||
body = ""
|
||||
if responseObj.body <> invalid
|
||||
body = responseObj.body.ToAsciiString()
|
||||
end if
|
||||
response.OverrideText(body)
|
||||
return response
|
||||
end function
|
||||
|
||||
function DefaultHandler(context as object) as object
|
||||
response = context.response
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import "InvidiousService.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
|
||||
@asynctask
|
||||
function InvidiousSubscriptionsTask(input as object) as object
|
||||
invidiousNode = input.invidious
|
||||
|
||||
service = new Invidious.InvidiousService(invidiousNode)
|
||||
|
||||
response = service.GetSubscriptions(m.top.cancellation)
|
||||
|
||||
if m.top.cancel
|
||||
return invalid
|
||||
end if
|
||||
|
||||
subscriptions = response.Json()
|
||||
|
||||
if not response.IsSuccess() or subscriptions = invalid
|
||||
error = response.ErrorMessage()
|
||||
LogError("Error getting subscriptions:", error)
|
||||
|
||||
return {
|
||||
success: false
|
||||
error: response.ErrorMessage()
|
||||
}
|
||||
end if
|
||||
|
||||
if m.top.cancel
|
||||
return invalid
|
||||
end if
|
||||
|
||||
subscriptionsDict = {}
|
||||
for each subscription in subscriptions
|
||||
subscriptionsDict[subscription.authorId] = true
|
||||
end for
|
||||
|
||||
invidiousNode.subscriptions = subscriptionsDict
|
||||
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
end function
|
||||
@@ -51,6 +51,8 @@ namespace InvidiousContent
|
||||
SetIfExists(node, "videoId", item, "videoId")
|
||||
node.viewCountText = VideoGetViewCountText(item)
|
||||
SetIfExists(node, "index", item, "index")
|
||||
SetIfExists(node, "lines", item, "lines")
|
||||
SetIfExists(node, "percentDurationWatched", item, "percentDurationWatched")
|
||||
|
||||
return node
|
||||
end function
|
||||
@@ -77,20 +79,40 @@ namespace InvidiousContent
|
||||
SetIfExists(node, "updated", item, "updated")
|
||||
node.updatedText = PlaylistGetUpdatedText(item)
|
||||
SetIfExists(node, "statsText", item, "statsText")
|
||||
SetIfExists(node, "lines", item, "lines")
|
||||
|
||||
if item.videos <> invalid
|
||||
if IsArray(item.videos) and item.videos.Count() > 0
|
||||
childCount = node.getChildCount()
|
||||
|
||||
' Innertube's TV client doesn't return the index for videos in playlists.
|
||||
' So we rely on video ids to detect duplicates.
|
||||
videosHasIndex = IsInt(item.videos[0].index)
|
||||
|
||||
videoIds = invalid
|
||||
if not videosHasIndex
|
||||
videoIds = {}
|
||||
childVideos = node.getChildren(-1, 0)
|
||||
for each child in childVideos
|
||||
videoIds[child.videoId] = true
|
||||
end for
|
||||
end if
|
||||
|
||||
newNodes = []
|
||||
for each video in item.videos
|
||||
' TODO:P1 sometimes we're parsing "recommended playlists" that
|
||||
' show up in the end of the playlist. We should ignore them,
|
||||
' until the parsing is fixed.
|
||||
' Sometimes we're parsing "recommended playlists" that show up
|
||||
' in the end of the playlist. In this context they are ignored.
|
||||
if ValidString(video.type) = "playlist"
|
||||
continue for
|
||||
end if
|
||||
video.type = "video"
|
||||
videoNode = ToVideoContentNode(invalid, video, instance)
|
||||
if videoNode <> invalid
|
||||
if not videosHasIndex
|
||||
if videoIds[video.videoId] = true
|
||||
continue for
|
||||
end if
|
||||
end if
|
||||
|
||||
index = video.index
|
||||
if index <> invalid and index > -1 and index < childCount
|
||||
node.replaceChild(videoNode, index)
|
||||
@@ -99,6 +121,7 @@ namespace InvidiousContent
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
|
||||
if newNodes.Count() > 0
|
||||
node.appendChildren(newNodes)
|
||||
end if
|
||||
@@ -307,6 +330,10 @@ namespace InvidiousContent
|
||||
node.videoCountText = videoCountText
|
||||
return
|
||||
end if
|
||||
' If we already have this information, we should not override it.
|
||||
if not StringUtils.IsNullOrEmpty(node.videoCountText)
|
||||
return
|
||||
end if
|
||||
videoCount = ValidInt(item.videoCount)
|
||||
if videoCount = -1
|
||||
return
|
||||
|
||||
@@ -49,7 +49,7 @@ class LongPoller
|
||||
LogInfo(`Sending long polling GET ${url}`, "ID:", socket.GetID())
|
||||
|
||||
#if DEBUG
|
||||
? `════════ curl command ════════\n${m.ToCurlCommand()}\n══════════════════════════════`
|
||||
? `======== curl command ========\n${m.ToCurlCommand()}\n==============================`
|
||||
#end if
|
||||
|
||||
message = `GET ${urlObject.path} HTTP/1.1\r\n`
|
||||
|
||||
@@ -122,6 +122,27 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
|
||||
isDirty = true
|
||||
end if
|
||||
|
||||
if userPrefs.__version = 2
|
||||
if IsArray(userPrefs["misc.home_screen_layout"])
|
||||
homeScreenLayout = userPrefs["misc.home_screen_layout"]
|
||||
hasRecommended = false
|
||||
for each item in homeScreenLayout
|
||||
if item.id = "recommended"
|
||||
hasRecommended = true
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
if not hasRecommended
|
||||
homeScreenLayout.Unshift({
|
||||
id: "recommended"
|
||||
enabled: true
|
||||
})
|
||||
end if
|
||||
end if
|
||||
userPrefs.__version = 3
|
||||
isDirty = true
|
||||
end if
|
||||
|
||||
' TODO:P2 handle case where saved preferences version is higher than current version (e.g. user downgraded)
|
||||
return isDirty
|
||||
end function
|
||||
|
||||
@@ -39,7 +39,7 @@ function LoadProfilesFromRegistry()
|
||||
|
||||
' Step 3: Save user preferences (if needed)
|
||||
if isDirty
|
||||
SaveUserProfilesToRegistry()
|
||||
SaveUserProfilesToRegistry(invalid)
|
||||
end if
|
||||
|
||||
' Step 4: Load user profiles into content nodes
|
||||
@@ -50,6 +50,7 @@ function LoadProfilesFromRegistry()
|
||||
profileNode.type = profile.type
|
||||
profileNode.username = profile.username
|
||||
profileNode.serverUrl = profile.serverUrl
|
||||
profileNode.thumbnail = profile.thumbnail
|
||||
profileNode.accessToken = profile.accessToken
|
||||
|
||||
profileNode.refreshToken = profile.refreshToken
|
||||
@@ -126,7 +127,7 @@ function MigrateExistingProfiles(userProfiles as object) as boolean
|
||||
return true
|
||||
end function
|
||||
|
||||
function SaveUserProfilesToRegistry() as void
|
||||
function SaveUserProfilesToRegistry(_unused as dynamic) as void
|
||||
if m.disableSavingToRegistry
|
||||
return
|
||||
end if
|
||||
@@ -161,6 +162,7 @@ function GetProfilesDto(includeAccessToken as boolean) as object
|
||||
"type": profileNode.type
|
||||
"username": profileNode.username
|
||||
"serverUrl": profileNode.serverUrl
|
||||
"thumbnail": profileNode.thumbnail
|
||||
"color": color
|
||||
}
|
||||
|
||||
@@ -203,8 +205,17 @@ function LoginWithProfile(newProfile as object)
|
||||
end for
|
||||
|
||||
if not isNewProfile
|
||||
' Refresh token of existing profile
|
||||
existingProfile.username = newProfile.username
|
||||
existingProfile.thumbnail = newProfile.thumbnail
|
||||
existingProfile.accessToken = newProfile.accessToken
|
||||
existingProfile.refreshToken = newProfile.refreshToken
|
||||
existingProfile.scope = newProfile.scope
|
||||
existingProfile.tokenType = newProfile.tokenType
|
||||
existingProfile.expiresIn = newProfile.expiresIn
|
||||
existingProfile.expiresTimestamp = newProfile.expiresTimestamp
|
||||
existingProfile.clientId = newProfile.clientId
|
||||
existingProfile.clientSecret = newProfile.clientSecret
|
||||
|
||||
newProfile = existingProfile
|
||||
end if
|
||||
|
||||
@@ -311,7 +322,7 @@ function SetCurrentProfile(newActiveProfile as object) as void
|
||||
m.top.currentProfile = invalid
|
||||
m.invidious.authToken = invalid
|
||||
LogInfo("Current profile set to <invalid>")
|
||||
SaveUserProfilesToRegistry()
|
||||
SaveUserProfilesToRegistry(invalid)
|
||||
return
|
||||
end if
|
||||
|
||||
@@ -322,9 +333,10 @@ function SetCurrentProfile(newActiveProfile as object) as void
|
||||
token: newActiveProfile.accessToken
|
||||
instance: newActiveProfile.serverUrl
|
||||
username: newActiveProfile.username
|
||||
profileNode: newActiveProfile
|
||||
}
|
||||
LogInfo("Current profile set to", newActiveProfile.username, "@", newActiveProfile.serverUrl)
|
||||
SaveUserProfilesToRegistry()
|
||||
SaveUserProfilesToRegistry(invalid)
|
||||
end function
|
||||
|
||||
function RefreshActiveProfileState(activeProfile as object) as void
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<function name="LogoutWithProfiles" />
|
||||
<function name="LogoutWithAccessToken" />
|
||||
<function name="SetCurrentProfile" />
|
||||
<function name="SaveUserProfilesToRegistry" />
|
||||
</interface>
|
||||
<children>
|
||||
<!-- Note: two content nodes because we're rendering profiles in a RowList on the ProfilesScreen -->
|
||||
|
||||
@@ -54,7 +54,13 @@ namespace SearchHistoryUtils
|
||||
if history = invalid
|
||||
return []
|
||||
end if
|
||||
return ParseJson(history)
|
||||
|
||||
history = ParseJson(history)
|
||||
if not IsArray(history)
|
||||
return []
|
||||
end if
|
||||
|
||||
return history
|
||||
end function
|
||||
|
||||
function Clear()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
@@ -13,9 +14,24 @@ function OnContentSet() as void
|
||||
end if
|
||||
|
||||
m.top.title = content.title
|
||||
lines = content.lines
|
||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||
m.top.author = content._author
|
||||
m.top.updated = content.updatedText
|
||||
author = content._author
|
||||
if StringUtils.IsNullOrEmpty(author)
|
||||
if IsArray(lines) and lines.Count() > 0
|
||||
author = lines[0]
|
||||
end if
|
||||
end if
|
||||
m.top.author = author
|
||||
|
||||
updatedText = content.updatedText
|
||||
if StringUtils.IsNullOrEmpty(updatedText)
|
||||
if IsArray(lines) and lines.Count() > 1
|
||||
updatedText = lines[1]
|
||||
end if
|
||||
end if
|
||||
m.top.updated = updatedText
|
||||
|
||||
|
||||
m.top.thumbnailUri = content.thumbnail
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/MathUtils.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/TimeUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
@@ -8,6 +9,7 @@ function Init()
|
||||
m.durationLabel = m.top.FindNode("durationLabel")
|
||||
m.smallestSystemFont = m.top.FindNode("smallestSystemFont")
|
||||
m.smallestBoldSystemFont = m.top.FindNode("smallestBoldSystemFont")
|
||||
m.progressRect = m.top.FindNode("progressRect")
|
||||
end function
|
||||
|
||||
function OnContentSet() as void
|
||||
@@ -18,11 +20,20 @@ function OnContentSet() as void
|
||||
end if
|
||||
|
||||
m.top.title = content.title
|
||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||
m.top.author = content._author
|
||||
lines = content.lines
|
||||
|
||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||
author = content._author
|
||||
if StringUtils.IsNullOrEmpty(author)
|
||||
if IsArray(lines) and lines.Count() > 0
|
||||
author = lines[0]
|
||||
end if
|
||||
end if
|
||||
m.top.author = author
|
||||
|
||||
viewCountDate = ""
|
||||
if content.isUpcoming = true
|
||||
m.top.viewCountDate = content.premiereTimestampText
|
||||
viewCountDate = content.premiereTimestampText
|
||||
else
|
||||
publishedText = content.publishedText
|
||||
viewCountText = content.viewCountText
|
||||
@@ -33,11 +44,19 @@ function OnContentSet() as void
|
||||
end if
|
||||
label += viewCountText
|
||||
|
||||
m.top.viewCountDate = label
|
||||
viewCountDate = label
|
||||
end if
|
||||
if StringUtils.IsNullOrEmpty(viewCountDate)
|
||||
if IsArray(lines) and lines.Count() > 1
|
||||
viewCountDate = lines[1]
|
||||
end if
|
||||
end if
|
||||
m.top.viewCountDate = viewCountDate
|
||||
|
||||
m.top.thumbnailUri = content.thumbnail
|
||||
|
||||
m.top.percentDurationWatched = content.percentDurationWatched
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(content.lengthText)
|
||||
SetDurationLabel(content.lengthText, "#161616FF", 0.8, m.smallestSystemFont)
|
||||
m.top.durationRectVisible = true
|
||||
@@ -75,3 +94,11 @@ function SetDurationLabel(text as string, bgColor as string, bgOpacity as float,
|
||||
rect.opacity = bgOpacity
|
||||
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
|
||||
@@ -8,6 +8,7 @@
|
||||
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
|
||||
<field id="duration" type="string" alias="durationLabel.text" />
|
||||
<field id="thumbnailUri" type="string" alias="thumbnail.uri" />
|
||||
<field id="percentDurationWatched" type="float" onChange="OnPercentDurationWatched" />
|
||||
</interface>
|
||||
<children>
|
||||
<Font id="smallestSystemFont" uri="font:SystemFontFile" size="18" />
|
||||
@@ -36,6 +37,14 @@
|
||||
font="font:SmallestSystemFont"
|
||||
translation="[8, 0]" />
|
||||
</Rectangle>
|
||||
<Rectangle
|
||||
id="progressRect"
|
||||
width="350"
|
||||
height="5"
|
||||
color="#FF0000"
|
||||
translation="[0, 192]"
|
||||
scale="[0, 1]">
|
||||
</Rectangle>
|
||||
</Poster>
|
||||
<Label
|
||||
id="titleLabel"
|
||||
|
||||
@@ -57,7 +57,10 @@ function VideoRowListRowContentTask(input as object) as object
|
||||
feedSource = service.MarkFeedPagination(feedContentNode)
|
||||
hadContinuation = not StringUtils.IsNullOrEmpty(feedSource.state.continuation)
|
||||
|
||||
response = service.MakeRequest(feedSource, feedSource.state.queryParams, m.top.cancellation)
|
||||
response = service.MakeRequest(feedSource, {
|
||||
additionalQueryParams: feedSource.state.queryParams
|
||||
cancellation: m.top.cancellation
|
||||
})
|
||||
|
||||
if not response.success
|
||||
if response.error = Invidious.ERROR_NOT_AUTHENTICATED
|
||||
@@ -93,7 +96,8 @@ function VideoRowListRowContentTask(input as object) as object
|
||||
feedContentNode.title += " (Failed to load)"
|
||||
end if
|
||||
|
||||
HandleFeedLoadErrorDialog(response.error, rowList)
|
||||
isCancelled = response.cancelled = true
|
||||
HandleFeedLoadErrorDialog(response.error, isCancelled, rowList)
|
||||
continue while
|
||||
end if
|
||||
|
||||
@@ -107,12 +111,23 @@ function VideoRowListRowContentTask(input as object) as object
|
||||
end for
|
||||
|
||||
RemovePlaceHolderItems(feedContentNode)
|
||||
feedContentNode.appendChildren(itemNodes)
|
||||
|
||||
addedItemCount = 0
|
||||
' For some reason, Innertube's "FEplaylist_aggregation" (which maps to "inv_auth_playlists"
|
||||
' aka Authenticated user playlists) returns continuation for the next page, but returns
|
||||
' items from the first page. So we deduplicate to avoid loading this feed infnitely,
|
||||
' with the same items repeating.
|
||||
if feedSource.id = "inv_auth_playlists"
|
||||
addedItemCount = DeduplicateAppendAuthPlaylists(feedContentNode, itemNodes)
|
||||
else
|
||||
feedContentNode.appendChildren(itemNodes)
|
||||
addedItemCount = itemNodes.Count()
|
||||
end if
|
||||
|
||||
hasContinuation = not StringUtils.IsNullOrEmpty(response.result.continuation)
|
||||
feedSource.state.continuation = ValidString(response.result.continuation)
|
||||
|
||||
if response.result.items.Count() > 0
|
||||
if addedItemCount > 0
|
||||
pageType = feedSource.state.paginationType
|
||||
if response.result.isLastPage = true or (hadContinuation and not hasContinuation)
|
||||
feedSource.state.loadState = FeedLoadState.Loaded
|
||||
@@ -136,19 +151,19 @@ function VideoRowListRowContentTask(input as object) as object
|
||||
feedContentNode.loadState = FeedLoadState.LoadedPage
|
||||
end if
|
||||
|
||||
if itemNodes.Count() > 0 and not someContentReadySet
|
||||
if addedItemCount > 0 and not someContentReadySet
|
||||
someContentReadySet = true
|
||||
rowList.someContentReady = true
|
||||
end if
|
||||
|
||||
totalfetchedItems += response.result.items.Count()
|
||||
totalfetchedItems += addedItemCount
|
||||
if totalfetchedItems > 3
|
||||
exit while
|
||||
end if
|
||||
end while
|
||||
|
||||
catch error
|
||||
HandleFeedLoadErrorDialog(error, rowList)
|
||||
HandleFeedLoadErrorDialog(error, false, rowList)
|
||||
return {
|
||||
success: false
|
||||
error: error
|
||||
@@ -183,13 +198,57 @@ function RemovePlaceHolderItems(contentNode as object)
|
||||
end if
|
||||
end function
|
||||
|
||||
function HandleFeedLoadErrorDialog(error as object, rowList as object) as void
|
||||
function DeduplicateAppendAuthPlaylists(feedContentNode as object, itemNodes as object) as integer
|
||||
if itemNodes.Count() = 0
|
||||
return 0
|
||||
end if
|
||||
|
||||
currentChildCount = feedContentNode.getChildCount()
|
||||
if currentChildCount = 0
|
||||
feedContentNode.appendChildren(itemNodes)
|
||||
return itemNodes.Count()
|
||||
end if
|
||||
|
||||
currentChildren = feedContentNode.getChildren(-1, 0)
|
||||
currentChildrenMap = {}
|
||||
for i = 0 to currentChildCount - 1
|
||||
playlistId = currentChildren[i].playlistId
|
||||
if StringUtils.IsNullOrEmpty(playlistId)
|
||||
continue for
|
||||
end if
|
||||
currentChildrenMap[playlistId] = true
|
||||
end for
|
||||
|
||||
nodesToAdd = []
|
||||
for i = 0 to itemNodes.Count() - 1
|
||||
itemNode = itemNodes[i]
|
||||
playlistId = itemNode.playlistId
|
||||
if StringUtils.IsNullOrEmpty(playlistId)
|
||||
continue for
|
||||
end if
|
||||
if currentChildrenMap[playlistId] = true
|
||||
continue for
|
||||
end if
|
||||
currentChildrenMap[playlistId] = true
|
||||
nodesToAdd.Push(itemNode)
|
||||
end for
|
||||
if nodesToAdd.Count() = 0
|
||||
return 0
|
||||
end if
|
||||
feedContentNode.appendChildren(nodesToAdd)
|
||||
return nodesToAdd.Count()
|
||||
end function
|
||||
|
||||
function HandleFeedLoadErrorDialog(error as object, isCancelled as boolean, rowList as object) as void
|
||||
error = ErrorUtils.Format(error)
|
||||
LogError(error)
|
||||
rowList.onError = error
|
||||
if rowList.hasField("dispose") and rowList.dispose
|
||||
return
|
||||
end if
|
||||
if isCancelled
|
||||
return
|
||||
end if
|
||||
DialogUtils.ShowDialogEx({
|
||||
message: error
|
||||
title: "Failed to load feed"
|
||||
|
||||
@@ -1,12 +1,74 @@
|
||||
import "pkg:/components/Services/Innertube/InnertubeService.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||
import "pkg:/source/utils/MessagePortUtils.bs"
|
||||
|
||||
@asynctask
|
||||
function MarkVideoWatchedTask(input as object) as object
|
||||
videoId = input.videoId
|
||||
invidiousNode = input.invidious
|
||||
authToken = input.authToken
|
||||
profileType = input.profileType
|
||||
cancellation = m.top.cancellation
|
||||
|
||||
service = new Invidious.InvidiousService(invidiousNode)
|
||||
service.MarkVideoWatched(videoId)
|
||||
if profileType = "invidious"
|
||||
service = new Invidious.InvidiousService(invidiousNode)
|
||||
service.MarkVideoWatched(videoId, cancellation)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if profileType <> "youtube"
|
||||
LogError("MarkVideoWatchedTask: Unsupported profile type:", profileType)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
playbackTrackingUrls = InnertubeService.AuthGetPlaybackTrackingUrls(videoId, {
|
||||
accessToken: authToken.token
|
||||
cancellation: cancellation
|
||||
})
|
||||
|
||||
if playbackTrackingUrls.error <> invalid
|
||||
LogError("MarkVideoWatchedTask: Failed to get playback tracking URLs:", playbackTrackingUrls.error)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if StringUtils.IsNullOrEmpty(playbackTrackingUrls.videostatsPlaybackUrl)
|
||||
LogError("MarkVideoWatchedTask: videostatsPlaybackUrl is empty")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
markedAsWatched = InnertubeService.AuthMarkVideoWatched(playbackTrackingUrls.videostatsPlaybackUrl, {
|
||||
accessToken: authToken.token
|
||||
cancellation: cancellation
|
||||
})
|
||||
if not markedAsWatched
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if StringUtils.IsNullOrEmpty(playbackTrackingUrls.videostatsWatchtimeUrl)
|
||||
LogError("MarkVideoWatchedTask: videostatsWatchtimeUrl is empty")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
if CancellationUtils.IsCancelled(cancellation)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
port = CreateObject("roMessagePort")
|
||||
MessagePortUtils.ObserveFieldScopedExSafe(m.top, "watchTime", port)
|
||||
CancellationUtils.ObserveCancellationScoped(cancellation, port)
|
||||
while true
|
||||
message = wait(60000, port)
|
||||
if CancellationUtils.IsCancellationEvent(cancellation, message)
|
||||
return invalid
|
||||
end if
|
||||
if message = invalid
|
||||
continue while
|
||||
end if
|
||||
watchTime = message.getData()
|
||||
InnertubeService.AuthMarkVideoWatchTime(watchTime, playbackTrackingUrls.videostatsWatchtimeUrl, {
|
||||
accessToken: authToken.token
|
||||
cancellation: cancellation
|
||||
})
|
||||
end while
|
||||
return invalid
|
||||
end function
|
||||
@@ -140,7 +140,6 @@ namespace SponsorBlock
|
||||
m.top.trickPlayBar.filledBarBlendColor = "#FF000080"
|
||||
end if
|
||||
|
||||
m.top.UnobserveFieldScoped("position")
|
||||
m.top.ObserveFieldScoped("position", FuncName(OnPositionChangeSkipSponsorBlockSections))
|
||||
end function
|
||||
|
||||
|
||||
@@ -31,6 +31,13 @@ function VideoContentTask(input as object) as object
|
||||
metadata = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
|
||||
end if
|
||||
|
||||
if metadata = invalid
|
||||
return {
|
||||
success: false
|
||||
error: "Failed to get video metadata"
|
||||
}
|
||||
end if
|
||||
|
||||
if m.top.cancel
|
||||
return invalid
|
||||
end if
|
||||
@@ -92,6 +99,8 @@ function CreateStreamUrls(metadata as object, service as Invidious.InvidiousServ
|
||||
metadata.hlsUrl = AddInstanceToUrlIfNeeded(metadata.hlsUrl, instance)
|
||||
AddHlsUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
|
||||
else
|
||||
' Not that we're using dashUrl, but why not, it useful when testing it
|
||||
metadata.dashUrl = AddInstanceToUrlIfNeeded(metadata.dashUrl, instance)
|
||||
AddDashUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
|
||||
end if
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ function Init()
|
||||
m.fullScreenHintTimer.ObserveField("fire", FuncName(OnFullScreenHintTimer))
|
||||
m.trickplayUITimer = m.top.findNode("trickplayUITimer")
|
||||
m.trickplayUITimer.ObserveField("fire", FuncName(OnTrickplayUITimer))
|
||||
m.top.notificationInterval = 1
|
||||
|
||||
' videoPlayingSuccess indicates if we started playing a video successfully
|
||||
' We use it to detect if we should try another link for a video, or if another error
|
||||
@@ -126,6 +127,8 @@ function PlayWithContent(contentNode as object)
|
||||
end if
|
||||
if ValidInt(contentNode.timestamp) <> -1
|
||||
videoContentNode.AddFields({ timestamp: contentNode.timestamp })
|
||||
else if contentNode.percentDurationWatched > 0 and contentNode.percentDurationWatched < 100
|
||||
videoContentNode.AddFields({ percentDurationWatched: contentNode.percentDurationWatched })
|
||||
end if
|
||||
if not StringUtils.IsNullOrEmpty(contentNode.title)
|
||||
videoContentNode.title = contentNode.title
|
||||
@@ -144,8 +147,6 @@ function StartVideoContentTask(videoContentNode as object)
|
||||
m.videoContentTask.cancel = true
|
||||
end if
|
||||
|
||||
MarkVideoWatched(videoContentNode.videoId)
|
||||
|
||||
m.top.content = videoContentNode
|
||||
|
||||
m.videoContentTask = AsyncTask.Start(Tasks.VideoContentTask, {
|
||||
@@ -194,22 +195,25 @@ function OnVideoContentTaskResults(output as object) as void
|
||||
SponsorBlock.FetchSponsorBlock(content.metadata)
|
||||
|
||||
timestamp = content.timestamp
|
||||
percentDurationWatched = content.percentDurationWatched
|
||||
hasTimestamp = IsInt(timestamp)
|
||||
hasPercentDurationWatched = IsFloat(percentDurationWatched)
|
||||
|
||||
if IsLiveVideo() and not hasTimestamp
|
||||
duration = m.top.duration
|
||||
if duration > 0
|
||||
SeekToEndOfStream()
|
||||
else
|
||||
m.top.ObserveField("duration", FuncName(SeekToEndOfStream))
|
||||
if IsLiveVideo() and not hasTimestamp and not hasPercentDurationWatched
|
||||
' If live, seek to end of stream
|
||||
m.seekToPercent = 100.0
|
||||
SeekToPercentOfDuration()
|
||||
else
|
||||
if hasTimestamp and timestamp > 0
|
||||
m.top.seek = content.timestamp
|
||||
else if hasPercentDurationWatched
|
||||
m.seekToPercent = percentDurationWatched
|
||||
SeekToPercentOfDuration()
|
||||
end if
|
||||
end if
|
||||
|
||||
PlayAfterPreviousPlayerHasStopped()
|
||||
|
||||
if hasTimestamp and timestamp > 0
|
||||
m.top.seek = content.timestamp
|
||||
end if
|
||||
MarkVideoWatched(content.videoId)
|
||||
end function
|
||||
|
||||
function PlayAfterPreviousPlayerHasStopped() as void
|
||||
@@ -272,12 +276,48 @@ function MarkVideoWatched(videoId as dynamic) as void
|
||||
return
|
||||
end if
|
||||
|
||||
if m.top.invidious.authToken <> invalid
|
||||
AsyncTask.Start(Tasks.MarkVideoWatchedTask, {
|
||||
videoId: videoId
|
||||
invidious: m.top.invidious
|
||||
})
|
||||
invidious = m.top.invidious
|
||||
authToken = invidious.authToken
|
||||
if authToken = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
if m.markVideoWatchedTask <> invalid
|
||||
m.markVideoWatchedTask.cancel = true
|
||||
end if
|
||||
|
||||
profileType = authToken.profileNode.type
|
||||
m.markVideoWatchedTask = AsyncTask.Create(Tasks.MarkVideoWatchedTask, {
|
||||
videoId: videoId
|
||||
invidious: invidious
|
||||
authToken: authToken
|
||||
profileType: profileType
|
||||
})
|
||||
m.markVideoWatchedTask.addField("watchTime", "float", false)
|
||||
m.markVideoWatchedTask.control = "RUN"
|
||||
|
||||
if profileType <> "youtube"
|
||||
return
|
||||
end if
|
||||
|
||||
' Progress reported to Innertube. It is the position in seconds,
|
||||
' with 20 second steps.
|
||||
m.watchTimeMarker = -1
|
||||
m.top.ObserveFieldScoped("position", FuncName(OnPositionChangeMarkWatchTime))
|
||||
end function
|
||||
|
||||
function OnPositionChangeMarkWatchTime() as void
|
||||
if m.markVideoWatchedTask = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
currentPosition = m.top.position
|
||||
currentWatchTimeMarker = m.watchTimeMarker
|
||||
m.watchTimeMarker = (currentPosition \ 20) * 20
|
||||
if currentWatchTimeMarker = currentPosition
|
||||
return
|
||||
end if
|
||||
m.markVideoWatchedTask.watchTime = m.watchTimeMarker
|
||||
end function
|
||||
|
||||
function OnClose()
|
||||
@@ -285,6 +325,10 @@ function OnClose()
|
||||
|
||||
m.top.previousPlayer = invalid
|
||||
|
||||
if m.markVideoWatchedTask <> invalid
|
||||
m.markVideoWatchedTask.cancel = true
|
||||
m.markVideoWatchedTask = invalid
|
||||
end if
|
||||
if m.videoContentTask <> invalid
|
||||
m.videoContentTask.cancel = true
|
||||
m.videoContentTask = invalid
|
||||
@@ -408,13 +452,43 @@ function OnVideoPlayerStateChange() as void
|
||||
end if
|
||||
end function
|
||||
|
||||
function SeekToEndOfStream()
|
||||
function SeekToEndOfStream() as void
|
||||
m.top.UnobserveField("duration")
|
||||
duration = m.top.duration
|
||||
' If the stream is less than 30 seconds, it's not worth seeking to the end
|
||||
if duration > 30
|
||||
LogInfo("Seeking to end of live stream", duration)
|
||||
m.top.seek = duration
|
||||
' If the stream is less than 30 seconds, it's not worth seeking
|
||||
if duration < 30
|
||||
return
|
||||
end if
|
||||
|
||||
LogInfo("Seeking to end of live stream", duration)
|
||||
m.top.seek = duration
|
||||
end function
|
||||
|
||||
function SeekToPercentOfDuration() as void
|
||||
m.top.UnobserveField("duration")
|
||||
|
||||
seekToPercent = m.seekToPercent
|
||||
if seekToPercent = invalid
|
||||
return
|
||||
end if
|
||||
m.seekToPercent = invalid
|
||||
|
||||
duration = m.top.duration
|
||||
if duration = 0
|
||||
' If the duration is not available, wait for it to be set
|
||||
m.top.ObserveField("duration", FuncName(SeekToPercentOfDuration))
|
||||
return
|
||||
end if
|
||||
|
||||
' If the stream is less than 30 seconds, it's not worth seeking
|
||||
if duration < 30
|
||||
return
|
||||
end if
|
||||
|
||||
seek = (MathUtils.Clamp(seekToPercent, 0, 100) / 100.0) * duration
|
||||
if seek > 0
|
||||
LogInfo("Seeking to percent duration watched", seek)
|
||||
m.top.seek = seek
|
||||
end if
|
||||
end function
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Http
|
||||
function new(server as object)
|
||||
super()
|
||||
|
||||
m.server = server
|
||||
task = server.task
|
||||
m.profilesNode = task.profilesService
|
||||
m.invidiousNode = task.invidious
|
||||
@@ -72,12 +73,15 @@ namespace Http
|
||||
return true
|
||||
end if
|
||||
|
||||
additionalQueryParams = invalid
|
||||
options = {
|
||||
httpServer: m.server
|
||||
}
|
||||
if feedSource.state <> invalid and feedSource.state.queryParams <> invalid
|
||||
additionalQueryParams = feedSource.state.queryParams
|
||||
options.additionalQueryParams = feedSource.state.queryParams
|
||||
end if
|
||||
|
||||
invResponse = m.invidiousService.MakeRequest(feedSource, additionalQueryParams)
|
||||
invResponse = m.invidiousService.MakeRequest(feedSource, options)
|
||||
|
||||
if not invResponse.success
|
||||
response.Default(500, `Failed to make request: ${invResponse.error}`)
|
||||
return true
|
||||
|
||||
+294
-42
@@ -16,12 +16,39 @@ namespace Http
|
||||
response = context.response
|
||||
|
||||
response.Json({
|
||||
"error": "Playlet built-in Invidious backend is not a real Invidious instance, and does not support accounts."
|
||||
"error": "Playlet built-in Invidious backend is not a real Invidious instance, and does not support accounts. Please use the login with YouTube option instead."
|
||||
})
|
||||
response.http_code = 400
|
||||
return true
|
||||
end function
|
||||
|
||||
@post("/playlet-invidious-backend/api/v1/auth/tokens/unregister")
|
||||
function UnregisterToken(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
accessToken = request.body
|
||||
|
||||
if StringUtils.IsNullOrEmpty(accessToken)
|
||||
response.Json({
|
||||
"error": "Missing 'accessToken' body parameter"
|
||||
})
|
||||
response.http_code = 400
|
||||
return true
|
||||
end if
|
||||
|
||||
if not InnertubeService.AuthRevokeAccessToken({ "accessToken": accessToken })
|
||||
response.Json({
|
||||
"error": "Failed to unregister token"
|
||||
})
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
end function
|
||||
|
||||
@get("/playlet-invidious-backend/api/v1/auth/feed")
|
||||
function GetAuthFeed(context as object) as boolean
|
||||
request = context.request
|
||||
@@ -44,27 +71,35 @@ namespace Http
|
||||
options.continuation = continuation
|
||||
end if
|
||||
|
||||
feeds = InnertubeService.GetSubscriptions(options)
|
||||
if feeds = invalid
|
||||
response.Json({
|
||||
"error": "Failed to get auth feed"
|
||||
})
|
||||
result = InnertubeService.GetSubscriptions(options)
|
||||
if result.error <> invalid
|
||||
response.Json(result)
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
|
||||
result = {
|
||||
"videos": []
|
||||
if not IsArray(result.feeds) or result.feeds.Count() = 0
|
||||
' Not an error, just no subscriptions
|
||||
response.Json({
|
||||
"videos": []
|
||||
})
|
||||
return true
|
||||
end if
|
||||
|
||||
responseBody = {
|
||||
"videos": ValidArray(result.feeds[0].items)
|
||||
}
|
||||
|
||||
if result.feeds[0].DoesExist("continuation")
|
||||
responseBody.continuation = result.feeds[0].continuation
|
||||
end if
|
||||
|
||||
response.Json(responseBody)
|
||||
|
||||
if feeds.Count() > 0
|
||||
result["videos"] = ValidArray(feeds[0].items)
|
||||
if feeds[0].DoesExist("continuation")
|
||||
result["continuation"] = feeds[0].continuation
|
||||
end if
|
||||
if result.DoesExist("cache-control")
|
||||
response.headers["cache-control"] = result["cache-control"]
|
||||
end if
|
||||
|
||||
response.Json(result)
|
||||
return true
|
||||
end function
|
||||
|
||||
@@ -108,8 +143,14 @@ namespace Http
|
||||
options.continuation = continuation
|
||||
end if
|
||||
|
||||
feeds = InnertubeService.GetPlaylists(options)
|
||||
if feeds = invalid
|
||||
result = InnertubeService.GetPlaylists(options)
|
||||
if result.error <> invalid
|
||||
response.Json(result)
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
|
||||
if not IsArray(result.feeds) or result.feeds.Count() = 0
|
||||
response.Json({
|
||||
"error": "Failed to get auth playlists"
|
||||
})
|
||||
@@ -117,14 +158,12 @@ namespace Http
|
||||
return true
|
||||
end if
|
||||
|
||||
if feeds.Count() > 0
|
||||
response.Json(feeds[0])
|
||||
return true
|
||||
response.Json(result.feeds[0])
|
||||
|
||||
if result.DoesExist("cache-control")
|
||||
response.headers["cache-control"] = result["cache-control"]
|
||||
end if
|
||||
|
||||
response.Json({
|
||||
"items": []
|
||||
})
|
||||
return true
|
||||
end function
|
||||
|
||||
@@ -145,28 +184,45 @@ namespace Http
|
||||
options = {
|
||||
"accessToken": accessToken.Mid("Bearer ".Len())
|
||||
}
|
||||
|
||||
continuation = request.query.continuation
|
||||
if not StringUtils.IsNullOrEmpty(continuation)
|
||||
hasContinuation = not StringUtils.IsNullOrEmpty(continuation)
|
||||
if hasContinuation
|
||||
options.continuation = continuation
|
||||
end if
|
||||
|
||||
feeds = InnertubeService.GetWatchHistory(options)
|
||||
if feeds = invalid
|
||||
response.Json({
|
||||
"error": "Failed to get auth history"
|
||||
})
|
||||
if not hasContinuation
|
||||
page = ValidString(request.query.page).ToInt()
|
||||
if page > 1
|
||||
LogError("Playlet backend does not use history pagination (use continuation instead)")
|
||||
response.Json({
|
||||
"items": []
|
||||
})
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
result = InnertubeService.GetWatchHistory(options)
|
||||
if result.error <> invalid
|
||||
response.Json(result)
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
|
||||
if feeds.Count() > 0
|
||||
response.Json(feeds[0])
|
||||
if not IsArray(result.feeds) or result.feeds.Count() = 0
|
||||
' Not an error, just no history
|
||||
response.Json({
|
||||
"items": []
|
||||
})
|
||||
return true
|
||||
end if
|
||||
|
||||
response.Json({
|
||||
"items": []
|
||||
})
|
||||
response.Json(result.feeds[0])
|
||||
|
||||
if result.DoesExist("cache-control")
|
||||
response.headers["cache-control"] = result["cache-control"]
|
||||
end if
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
@@ -187,6 +243,11 @@ namespace Http
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
isRecommended = request.query.recommended = "true"
|
||||
if isRecommended
|
||||
return m.GetAuthRecommended(context)
|
||||
end if
|
||||
|
||||
raw = request.query.raw <> invalid
|
||||
|
||||
options = {
|
||||
@@ -215,6 +276,53 @@ namespace Http
|
||||
end if
|
||||
|
||||
response.Json(ValidArray(result.feeds[0].items))
|
||||
|
||||
if result.DoesExist("cache-control")
|
||||
response.headers["cache-control"] = result["cache-control"]
|
||||
end if
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
function GetAuthRecommended(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
return true
|
||||
end if
|
||||
|
||||
options = {
|
||||
"accessToken": accessToken.Mid("Bearer ".Len())
|
||||
}
|
||||
|
||||
continuation = request.query.continuation
|
||||
if not StringUtils.IsNullOrEmpty(continuation)
|
||||
options.continuation = continuation
|
||||
end if
|
||||
|
||||
result = InnertubeService.GetHome(options)
|
||||
if result.error <> invalid
|
||||
response.Json(result)
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
|
||||
if not IsArray(result.feeds) or result.feeds.Count() = 0
|
||||
' Not an error, just no recommended videos, usually when there's no history
|
||||
response.Json({
|
||||
"items": []
|
||||
})
|
||||
return true
|
||||
end if
|
||||
|
||||
response.Json(result.feeds[0])
|
||||
|
||||
if result.DoesExist("cache-control")
|
||||
response.headers["cache-control"] = result["cache-control"]
|
||||
end if
|
||||
@@ -289,20 +397,21 @@ namespace Http
|
||||
end if
|
||||
|
||||
result = InnertubeService.Search(query, options)
|
||||
if result.error <> invalid
|
||||
response.Json(result)
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
|
||||
if raw
|
||||
response.Json(result)
|
||||
return true
|
||||
end if
|
||||
|
||||
if result.error <> invalid
|
||||
response.Json(result)
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
|
||||
if not IsArray(result.feeds) or result.feeds.Count() = 0
|
||||
response.Json({
|
||||
"error": "Failed to search"
|
||||
"error": "Failed to search: no results found"
|
||||
})
|
||||
response.http_code = 500
|
||||
return true
|
||||
@@ -407,6 +516,8 @@ namespace Http
|
||||
return m.GetVideo(context)
|
||||
else if route.StartsWith("/playlet-invidious-backend/api/v1/playlists/")
|
||||
return m.GetPlaylist(context)
|
||||
else if route.StartsWith("/playlet-invidious-backend/api/v1/auth/playlists/")
|
||||
return m.GetAuthPlaylist(context)
|
||||
else if route.StartsWith("/playlet-invidious-backend/api/v1/channels/")
|
||||
return m.GetChannel(context)
|
||||
else if route.StartsWith("/playlet-invidious-backend/channel")
|
||||
@@ -416,6 +527,18 @@ namespace Http
|
||||
return false
|
||||
end function
|
||||
|
||||
@post("*")
|
||||
function PostAll(context as object) as boolean
|
||||
request = context.request
|
||||
route = request.route
|
||||
|
||||
if route.StartsWith("/playlet-invidious-backend/api/v1/auth/subscriptions/")
|
||||
return m.SubscribeToChannel(context)
|
||||
end if
|
||||
|
||||
return false
|
||||
end function
|
||||
|
||||
function GetVideo(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
@@ -447,9 +570,12 @@ namespace Http
|
||||
response = context.response
|
||||
route = request.route
|
||||
|
||||
playlistId = route.Mid("/playlet-invidious-backend/api/v1/playlists/".Len())
|
||||
if playlistId.InStr("?") > 0
|
||||
playlistId = playlistId.Left(playlistId.InStr("?"))
|
||||
playlistId = context.playlistId
|
||||
if StringUtils.IsNullOrEmpty(playlistId)
|
||||
playlistId = route.Mid("/playlet-invidious-backend/api/v1/playlists/".Len())
|
||||
if playlistId.InStr("?") > 0
|
||||
playlistId = playlistId.Left(playlistId.InStr("?"))
|
||||
end if
|
||||
end if
|
||||
continuation = request.query.continuation
|
||||
raw = request.query.raw <> invalid
|
||||
@@ -458,6 +584,11 @@ namespace Http
|
||||
raw: raw
|
||||
}
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if not StringUtils.IsNullOrEmpty(accessToken) and accessToken.StartsWith("Bearer ")
|
||||
options["accessToken"] = accessToken.Mid("Bearer ".Len())
|
||||
end if
|
||||
|
||||
if playlistId.StartsWith("RD")
|
||||
if not StringUtils.IsNullOrEmpty(continuation)
|
||||
options.videoId = continuation
|
||||
@@ -501,6 +632,29 @@ namespace Http
|
||||
return true
|
||||
end function
|
||||
|
||||
function GetAuthPlaylist(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
route = request.route
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
return true
|
||||
end if
|
||||
|
||||
playlistId = route.Mid("/playlet-invidious-backend/api/v1/auth/playlists/".Len())
|
||||
if playlistId.InStr("?") > 0
|
||||
playlistId = playlistId.Left(playlistId.InStr("?"))
|
||||
end if
|
||||
|
||||
context.playlistId = playlistId
|
||||
return m.GetPlaylist(context)
|
||||
end function
|
||||
|
||||
function GetChannel(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
@@ -594,6 +748,104 @@ namespace Http
|
||||
return false
|
||||
end function
|
||||
|
||||
function SubscribeToChannel(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
route = request.route
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
return true
|
||||
end if
|
||||
|
||||
channelId = route.Mid("/playlet-invidious-backend/api/v1/auth/subscriptions/".Len())
|
||||
if channelId.InStr("?") > 0
|
||||
channelId = channelId.Left(channelId.InStr("?"))
|
||||
end if
|
||||
|
||||
if StringUtils.IsNullOrEmpty(channelId)
|
||||
response.Json({
|
||||
"error": "Missing 'channelId' path parameter"
|
||||
})
|
||||
response.http_code = 400
|
||||
return true
|
||||
end if
|
||||
|
||||
options = {
|
||||
"accessToken": accessToken.Mid("Bearer ".Len())
|
||||
}
|
||||
|
||||
result = InnertubeService.SubscribeToChannel(channelId, options)
|
||||
|
||||
if result.success <> true
|
||||
response.Json(result)
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
end function
|
||||
|
||||
@delete("*")
|
||||
function DeleteAll(context as object) as boolean
|
||||
request = context.request
|
||||
route = request.route
|
||||
|
||||
if route.StartsWith("/playlet-invidious-backend/api/v1/auth/subscriptions/")
|
||||
return m.UnsubscribeFromChannel(context)
|
||||
end if
|
||||
|
||||
return false
|
||||
end function
|
||||
|
||||
function UnsubscribeFromChannel(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
route = request.route
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
return true
|
||||
end if
|
||||
|
||||
channelId = route.Mid("/playlet-invidious-backend/api/v1/auth/subscriptions/".Len())
|
||||
if channelId.InStr("?") > 0
|
||||
channelId = channelId.Left(channelId.InStr("?"))
|
||||
end if
|
||||
|
||||
if StringUtils.IsNullOrEmpty(channelId)
|
||||
response.Json({
|
||||
"error": "Missing 'channelId' path parameter"
|
||||
})
|
||||
response.http_code = 400
|
||||
return true
|
||||
end if
|
||||
|
||||
options = {
|
||||
"accessToken": accessToken.Mid("Bearer ".Len())
|
||||
}
|
||||
|
||||
result = InnertubeService.UnsubscribeFromChannel(channelId, options)
|
||||
|
||||
if result.success <> true
|
||||
response.Json(result)
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
end function
|
||||
|
||||
@get("/playlet-invidious-backend/watch")
|
||||
function RedirectWatch(context as object) as boolean
|
||||
request = context.request
|
||||
|
||||
@@ -55,7 +55,12 @@ namespace Http
|
||||
end if
|
||||
|
||||
if keysDict["device"] = true
|
||||
state["device"] = m.applicationInfoNode@.GetDeviceInfo()
|
||||
deviceInfo = m.applicationInfoNode@.GetDeviceInfo()
|
||||
' We do not currently have translations for en_CA
|
||||
if deviceInfo.current_locale = "en_CA"
|
||||
deviceInfo.current_locale = "en_US"
|
||||
end if
|
||||
state["device"] = deviceInfo
|
||||
end if
|
||||
|
||||
if keysDict["invidious"] = true
|
||||
|
||||
@@ -36,7 +36,10 @@ function GetServerAddress(_unused as dynamic) as dynamic
|
||||
end function
|
||||
|
||||
function SetupRoutes(server as object)
|
||||
server.UseRouter(new Http.CorsMiddleware())
|
||||
#if DEBUG
|
||||
'CORS is mostly for developing the web app
|
||||
server.UseRouter(new Http.CorsMiddleware())
|
||||
#end if
|
||||
if server.settings.WebSocketsEnabled
|
||||
server.UseRouter(new Http.WebSocketMiddleware())
|
||||
end if
|
||||
|
||||
@@ -34,6 +34,15 @@ namespace Http
|
||||
m.headers = CreateObject("roAssociativeArray")
|
||||
end function
|
||||
|
||||
function FromParsedData(method as string, uri as string, headers as object, body as string)
|
||||
m.method = method
|
||||
m.uri = uri
|
||||
m.ProcessOperation()
|
||||
m.headers = headers
|
||||
m.body = body
|
||||
m.state = Http.HttpRequestState.DONE
|
||||
end function
|
||||
|
||||
function Add(incoming as string, maybeUnicode as boolean)
|
||||
if IsString(m.buffer)
|
||||
m.buffer = m.buffer + incoming
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Http
|
||||
m.routes = []
|
||||
end function
|
||||
|
||||
private function OnRequest(request as object, response as HttpResponse, connection as HttpConnection) as boolean
|
||||
function OnRequest(request as object, response as HttpResponse, connection as HttpConnection) as boolean
|
||||
for each route in m.routes
|
||||
if m.RouteMatchesRequest(route, request)
|
||||
try
|
||||
|
||||
@@ -195,6 +195,22 @@ namespace Http
|
||||
stats = stats + " Bytes" + Stri(m.total_in) + " in," + Stri(m.total_out) + " out"
|
||||
return stats
|
||||
end function
|
||||
|
||||
function ProcessRequestLocal(method as string, uri as string, headers as object, body as string) as object
|
||||
LogInfo(`Processing request locally ${method} ${uri}`)
|
||||
request = new HttpRequest()
|
||||
request.FromParsedData(method, uri, headers, body)
|
||||
|
||||
response = new HttpResponse(request, m, m.settings)
|
||||
response.Process({})
|
||||
|
||||
return {
|
||||
http_code: response.http_code
|
||||
headers: response.headers
|
||||
body: response.body_buffer
|
||||
}
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -6,6 +6,14 @@
|
||||
apiType: Invidious
|
||||
endpoint: auth_feed
|
||||
|
||||
- title: Recommended
|
||||
id: recommended
|
||||
feedSources:
|
||||
- id: inv_auth_recommended
|
||||
title: Recommended
|
||||
apiType: Invidious
|
||||
endpoint: auth_recommended
|
||||
|
||||
- title: Trending
|
||||
id: trending
|
||||
feedSources:
|
||||
|
||||
@@ -166,8 +166,6 @@ channel_releases:
|
||||
paginationType: Continuation
|
||||
tryCount: 3
|
||||
|
||||
# This is implemented only by Playlet backend.
|
||||
# https://github.com/iv-org/invidious/issues/5144
|
||||
channel_courses:
|
||||
title: Channel courses
|
||||
url: /api/v1/channels/{ucid}/courses
|
||||
@@ -189,3 +187,16 @@ watch_history:
|
||||
authenticated: true
|
||||
paginationType: Pages
|
||||
responseHandler: WatchHistoryHandler
|
||||
|
||||
# Recommended is not a thing for Invidious, but we can use
|
||||
# /api/v1/popular?recommended=true and handle it in Playlet
|
||||
# backend. Invidious will just ignore the query param.
|
||||
auth_recommended:
|
||||
title: Recommended
|
||||
url: /api/v1/popular
|
||||
authenticated: true
|
||||
paginationType: Continuation
|
||||
queryParams:
|
||||
recommended:
|
||||
type: boolean
|
||||
default: true
|
||||
@@ -152,6 +152,10 @@
|
||||
id: "subscriptions",
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
id: "recommended",
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
id: "trending",
|
||||
enabled: true,
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.6 KiB |
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="512pt" height="512pt" version="1.0" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
||||
<g transform="matrix(1.256 0 0 1.256 -65.668 -67.101)">
|
||||
<path d="m247.17 455.95c-19.792-0.78921-38.719-4.2564-57.154-10.47-60.968-20.55-108.68-68.579-127-127.86-7.8955-25.538-10.062-53.943-6.2586-82.067 3.7105-27.439 13.603-53.515 29.342-77.344 12.069-18.273 29.138-36.277 47.228-49.816 36.891-27.61 85.944-42.49 132.38-40.157 25.88 1.3001 49.939 6.765 73.106 16.606 8.1948 3.481 20.024 9.6845 27.696 14.525 14.15 8.9272 22.367 15.498 34.482 27.573 13.254 13.211 22.128 24.276 30.398 37.906 7.2081 11.879 14.099 27.15 18.229 40.397 1.5996 5.1305 4.442 16.456 5.6852 22.653 2.3908 11.917 2.6998 15.722 2.7049 33.312 6e-3 18.515-0.46256 24.413-2.9166 36.758-9.3274 46.92-35.58 88.167-74.872 117.64-22.814 17.112-50.027 29.535-78.547 35.858-16.714 3.7059-35.421 5.2453-54.498 4.4846zm-35.1-78.786c-5.3e-4 -0.52647-0.0741-2.0564-0.16311-3.3999l-0.16178-2.4427-4.7018-0.26271c-4.0477-0.22614-4.7968-0.33363-5.3847-0.77253-2.0235-1.5108-1.4679-6.0695 2.2494-18.457 0.8637-2.8781 3.3371-11.321 5.4966-18.762 2.1594-7.4409 5.2002-17.836 6.7573-23.101 1.5571-5.2648 4.1948-14.282 5.8615-20.038 1.6667-5.7562 3.6145-12.4 4.3284-14.764 0.71391-2.3641 3.2583-11.037 5.6542-19.272 4.9475-17.007 8.1626-27.723 8.9438-29.811 0.51852-1.3858 0.54785-1.4139 0.99761-0.95317 0.25486 0.26106 3.8462 7.3667 7.9807 15.79 4.1345 8.4236 13.089 26.573 19.898 40.331 17.188 34.73 37.849 76.578 43.261 87.622l4.5356 9.257 11.359-0.0895c6.2475-0.0492 11.615-0.19623 11.929-0.32672 0.5614-0.23385 0.54167-0.2959-1.3723-4.3176-1.068-2.2442-8.1436-16.601-15.724-31.904-48.687-98.293-61.22-123.86-67.889-138.48-4.7022-10.309-6.9031-14.807-7.7139-15.762-0.82931-0.97742-1.6319-1.0638-2.3704-0.25525-1.1993 1.313-4.1046 10.063-9.3869 28.27-2.0569 7.0899-6.5372 22.425-9.9562 34.077-6.6396 22.629-8.5182 29.037-14.33 48.883-2.0354 6.9495-4.7977 16.369-6.1385 20.931-1.3408 4.5628-4.033 13.81-5.9826 20.549-4.304 14.877-6.136 20.889-7.3886 24.25-2.1371 5.7334-2.5723 6.3292-4.9216 6.7384-0.88855 0.15472-2.4102 0.28196-3.3815 0.28275-2.1993 3e-3 -3.5494 0.36339-4.0558 1.0863-0.42176 0.60215-0.56421 4.8802-0.18251 5.4812 0.20573 0.32388 2.4672 0.37414 23.34 0.51873l8.6151 0.0597-7e-4 -0.95723zm36.751-205.59c4.3282-0.92335 8.4607-4.943 9.4374-9.1796 0.36569-1.5862 0.32543-4.9758-0.077-6.4799-0.85108-3.1813-3.2688-6.291-6.039-7.7675-3.8111-2.0313-9.456-2.0295-13.272 5e-3 -5.9828 3.1888-8.1556 11.089-4.7878 17.408 2.6995 5.0648 8.3611 7.3754 14.738 6.015z" fill="#f0f0f0" stroke-width=".025526"/>
|
||||
</g>
|
||||
<g transform="matrix(.087787 0 0 -.087787 -10.105 528.87)">
|
||||
<path d="m2787 4669c-124-65-123-255 3-319 86-44 196-16 247 62 58 87 26 211-67 258-51 26-132 26-183-1z" fill="#00b6f0" stroke="#00b6f0" stroke-width="4.25"/>
|
||||
<path d="m2882 4108c-12-16-63-166-102-303-30-104-101-350-165-565-20-69-58-199-85-290-26-91-64-221-85-290-20-69-58-199-85-290-26-91-64-221-85-290-20-69-57-195-81-280-59-207-93-299-115-310-10-6-35-10-56-10-73 0-84-8-81-54l3-41 228-3 228-2-3 47-3 48-73 3c-66 3-74 5-84 27-13 28 0 104 37 225 13 41 47 156 75 255s66 230 85 290c18 61 56 191 85 290 28 99 66 230 85 290 18 61 56 191 85 290 85 297 123 419 131 429 5 5 17-11 28-35 10-24 192-393 403-819s447-902 523-1058l139-282h168c92 0 168 4 168 8s-75 158-166 342c-588 1183-969 1958-1033 2100-29 63-69 151-89 195-44 95-58 110-80 83z" fill="#575757"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,11 @@
|
||||
{
|
||||
inputHash: 'f38944bd940b191cb7e9b1fed6e14aeb',
|
||||
outputs: [
|
||||
{
|
||||
outputFilePath: 'images/invidious-logo.png',
|
||||
outputHash: '0b593b648652e09fcf97fac09bbbf9f2',
|
||||
width: 256,
|
||||
height: 256,
|
||||
},
|
||||
],
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 300 300">
|
||||
<rect width="300" height="300" fill="red" ry="150" />
|
||||
<path fill="#fff" d="M149.93750587 79.22267364s-63.21885.000059-79.08593926 4.12304707c-8.49578714 2.37380204-15.49140825 9.36950015-17.86523429 17.99023729-4.12295306 15.86710025-4.12304706 48.72656078-4.12304706 48.72656078s.000094 32.98420052 4.12304706 48.60156077c2.37382604 8.62062014 9.24450615 15.49138025 17.86523429 17.86524029 15.99203025 4.24788007 79.08593926 4.24804007 79.08593926 4.24804007s63.34418101-.00005 79.21094127-4.12304007c8.62079014-2.37381004 15.49133025-9.11966015 17.74023028-17.86524029 4.24793007-15.74232025 4.24805007-48.60156077 4.24805007-48.60156077s.12484-32.98446053-4.24805007-48.85156078c-2.24890003-8.62073714-9.11944014-15.49133425-17.74023028-17.74023729-15.86676026-4.37284707-79.21094127-4.37304707-79.21094127-4.37304707zm-20.11523032 40.48046465 52.59961084 30.35938049-52.59961084 30.23438048v-60.59376097z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,11 @@
|
||||
{
|
||||
inputHash: 'b9448ffdbf4982eed1f4e85867a846d1',
|
||||
outputs: [
|
||||
{
|
||||
outputFilePath: 'images/youtube-logo.png',
|
||||
outputHash: '853532c887464153c4e0f924932d85fe',
|
||||
width: 256,
|
||||
height: 256,
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -1266,7 +1266,19 @@
|
||||
</message>
|
||||
<message>
|
||||
<source>Buffering</source>
|
||||
<translation type="unfinished">Puffert</translation>
|
||||
<translation>Pufferung</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do not show again</source>
|
||||
<translation>Nicht wieder anzeigen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Courses</source>
|
||||
<translation>Kurse</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Playlet built-in backend</source>
|
||||
<translation>Playlet eingebautes Backend</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="en_CA" sourcelanguage="en_US">
|
||||
<defaultcodec>UTF-8</defaultcodec>
|
||||
<context>
|
||||
<name>default</name>
|
||||
</context>
|
||||
</TS>
|
||||
@@ -76,6 +76,10 @@
|
||||
<source>Subscriptions</source>
|
||||
<translation>Subscriptions</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Recommended</source>
|
||||
<translation>Recommended</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Playlists</source>
|
||||
<translation>Playlists</translation>
|
||||
@@ -124,6 +128,10 @@
|
||||
<source>Podcasts</source>
|
||||
<translation>Podcasts</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Courses</source>
|
||||
<translation>Courses</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Edit</source>
|
||||
<translation>Edit</translation>
|
||||
@@ -752,6 +760,10 @@
|
||||
<source>Instance</source>
|
||||
<translation>Instance</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Playlet built-in backend</source>
|
||||
<translation>Playlet built-in backend</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Invidious instance to use. Example: https://example.com</source>
|
||||
<translation>Invidious instance to use. Example: https://example.com</translation>
|
||||
|
||||
Loaded 100 of 130 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user