Compare commits

...
33 Commits
Author SHA1 Message Date
Brahim Hadriche cef4679770 Release v0.36.1 (#546) 2025-01-19 11:47:22 -05:00
Brahim Hadriche fc3a9ce41f [skip ci] changelog typo 2025-01-19 11:43:05 -05:00
Brahim Hadriche dfaf3fa87e [skip ci] json bug testing update 2025-01-18 21:09:23 -05:00
Brahim Hadriche f8988e9d13 Add visitor data (#545)
* Add visitor data

* Tweak

* Changelog

* Do not load video details in video queue view
2025-01-18 18:21:23 -05:00
Brahim Hadriche 6f74ee61f6 Fix redirect missing timestamp param 2025-01-18 12:42:10 -05:00
Brahim Hadriche a598d362ba [chore] update dependencies (#544)
* update dependencies

* Strict node version
2025-01-18 12:30:05 -05:00
Brahim Hadriche 66ce75d62e Localize channel tabs from innertube 2025-01-17 16:29:36 -05:00
Brahim Hadriche 975980a3b5 Backend can return raw response 2025-01-17 16:28:16 -05:00
Brahim Hadriche 951a13be1f [skip ci] add few nodes to parser 2025-01-16 20:30:14 -05:00
Brahim Hadriche 14eba620ac [skip ci] comments 2025-01-16 18:06:36 -05:00
Brahim Hadriche 57885a4e8f Release v0.36.0 (#543) 2025-01-16 17:56:40 -05:00
Brahim Hadriche ed5ab70ceb [skip ci] comment 2025-01-16 17:54:31 -05:00
Brahim Hadriche 2f8679bc1c Support for channel "Courses" in Playlet backend 2025-01-16 17:44:56 -05:00
Brahim Hadriche 28c10022bd [skip ci] test tweak 2025-01-16 13:41:08 -05:00
Brahim Hadriche 57cdb59790 [skip ci] simple integration test 2025-01-15 21:14:03 -05:00
Brahim Hadriche f6d8afc2d9 [skip ci] copyright year 2025-01-14 09:17:26 -05:00
Brahim Hadriche 31c4d7e2a0 [skip ci] Update README.md 2025-01-12 09:51:19 -05:00
Brahim Hadriche 4dabd00b2a update dependencies (#542) 2025-01-10 19:54:44 -05:00
Brahim Hadriche 7fab7f7f39 typo 2025-01-10 17:39:30 -05:00
Brahim Hadriche d5508587d2 [skip ci] typo 2025-01-10 17:38:15 -05:00
Brahim Hadriche af4c28a411 skipCreatorOnTheRise: true 2025-01-10 17:34:58 -05:00
Brahim Hadriche 26774d5655 script tweak 2025-01-10 17:12:37 -05:00
Brahim Hadriche 3daa94dee1 A couple of fixes 2025-01-10 16:33:21 -05:00
Brahim Hadriche c95bb85c6e [skip ci] fix focus when there are no public invidious instances 2025-01-10 14:15:20 -05:00
Brahim Hadriche 4b3d1340df refactor dialog palette 2025-01-10 14:14:52 -05:00
Brahim Hadriche 68c8f12f9d Web app to Svelte5 (#541)
* Web app to Svelte5

* ignore ds store

* npm install @rollup/rollup-linux-x64-gnu --save-optional
2025-01-10 09:15:04 -05:00
Brahim Hadriche 66990cfd67 changelog 2025-01-09 21:54:51 -05:00
Brahim Hadriche aab20f2364 Revert "Web app to Svelte5 (#540)"
This reverts commit c534c27ae3.
2025-01-09 21:54:08 -05:00
Brahim Hadriche f987558884 Revert "https://github.com/vitejs/vite/discussions/15532#discussioncomment-8527272"
This reverts commit a04e853328.
2025-01-09 21:54:01 -05:00
Brahim Hadriche fcca018fe8 Revert "Lock file"
This reverts commit 96bbbd0d77.
2025-01-09 21:53:48 -05:00
Brahim Hadriche 96bbbd0d77 Lock file 2025-01-09 21:50:31 -05:00
Brahim Hadriche a04e853328 https://github.com/vitejs/vite/discussions/15532#discussioncomment-8527272 2025-01-09 21:30:43 -05:00
Brahim Hadriche c534c27ae3 Web app to Svelte5 (#540) 2025-01-09 21:22:34 -05:00
94 changed files with 3659 additions and 2470 deletions

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
.DS_Store
build/ build/
dist/ dist/
out/ out/
+1
View File
@@ -0,0 +1 @@
engine-strict=true
+32
View File
@@ -5,6 +5,38 @@ 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/), 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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.36.1] - 2025-01-19
### Fixed
- Added `Visitor Data` to payload in Playlet backend
- Session data persists for 24 hours
- It reduces the privacy of the app, but can help with `Sign in to confirm you're not a bot` errors
## Changed
- Video queue view might be missing video titles and durations
- This is done to reduce the risk of rate limiting. No video titles in the queue is better than no videos playing at all.
- Only affects casting playlists from the YouTube mobile app.
## [0.36.0] - 2025-01-16
### Added
- Support for channel "Courses" in Playlet backend
### Fixed
- Web app tech refresh
- Web app "Open in Invidious" when built-in backend is selected
- Playlist continuation showing invalid items at the end of playlists
### Changed
- Skip "Creator on the Rise" that show up in trending
- They end up hijacking the feed
- Might become a setting in the future
## [0.35.5] - 2025-01-09 ## [0.35.5] - 2025-01-09
### Added ### Added
+1 -1
View File
@@ -40,7 +40,7 @@ More under [Screenshots](./docs/screenshots/README.md)
## Installation ## Installation
[Playlet on Roku channel store](https://channelstore.roku.com/details/840aec36f51bfe6d96cf6db9055a372a/playlet) [Playlet on Roku channel store](https://channelstore.roku.com/details/840aec36f51bfe6d96cf6db9055a372a/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) Can't install from the store? See [How to install Playlet as a sideloaded/dev app](https://github.com/iBicha/playlet/discussions/371)
+1 -1
View File
@@ -2,7 +2,7 @@ openapi: 3.0.0
info: info:
title: Playlet Web API title: Playlet Web API
version: 0.35.5 version: 0.36.1
description: description:
Playlet Web API is a RESTful API for controlling the Playlet app on 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 Roku devices. The API is intended to be used by the Playlet web app, but can
+43
View File
@@ -0,0 +1,43 @@
const dotenv = require('dotenv');
const fs = require('fs');
const path = require('path');
import { utils } from 'roku-test-automation';
const envFile = path.join(__dirname, '../.env');
const config = getEnvVars(['ROKU_DEV_TARGET', 'ROKU_DEVPASSWORD']);
export function setupEnvironment() {
utils.setupEnvironmentFromConfig({
RokuDevice: {
devices: [{
host: config.ROKU_DEV_TARGET,
password: config.ROKU_DEVPASSWORD
}]
},
ECP: {
default: {
launchChannelId: 'dev'
}
},
OnDeviceComponent: {
logLevel: 'info'
}
})
}
function getEnvVars(requiredVars = undefined) {
let envVars = process.env;
if (fs.existsSync(envFile)) {
const envConfig = dotenv.parse(fs.readFileSync(envFile));
envVars = { ...envVars, ...envConfig };
}
if (requiredVars) {
const missingVars = requiredVars.filter((key) => !envVars[key]);
if (missingVars.length) {
throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
}
}
return envVars;
}
+24
View File
@@ -0,0 +1,24 @@
// 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 { Key } from 'roku-test-automation/client/dist/ECP';
setupEnvironment();
(async () => {
await ecp.sendInput({ params: { contentId: "jNQXAC9IVRw" } });
await odc.onFieldChangeOnce({
base: "scene",
keyPath: "#VideoQueue.player.state",
match: "playing",
});
console.log("Video started playing");
await ecp.sendKeypress(Key.Back);
await odc.shutdown();
})();
+2198 -1039
View File
File diff suppressed because it is too large. Load diff
+15 -10
View File
@@ -1,33 +1,34 @@
{ {
"name": "playlet", "name": "playlet",
"version": "0.35.5", "version": "0.36.1",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"devDependencies": { "devDependencies": {
"@rokucommunity/bslint": "^0.8.27", "@rokucommunity/bslint": "^0.8.28",
"@types/crypto-js": "^4.2.2", "@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/node": "^22.10.5", "@types/node": "^22.10.7",
"@types/xml2js": "^0.4.14", "@types/xml2js": "^0.4.14",
"argparse": "^2.0.1", "argparse": "^2.0.1",
"brighterscript": "0.68.2", "brighterscript": "0.68.3",
"brighterscript-formatter": "^1.7.7", "brighterscript-formatter": "^1.7.8",
"convert-svg-to-png": "^0.6.4", "convert-svg-to-png": "^0.6.4",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"dotenv": "^16.4.7", "dotenv": "^16.4.7",
"fs-extra": "^11.2.0", "fs-extra": "^11.3.0",
"glob": "^11.0.0", "glob": "^11.0.1",
"imap": "^0.8.19", "imap": "^0.8.19",
"ip": "^2.0.1", "ip": "^2.0.1",
"json5": "^2.2.3", "json5": "^2.2.3",
"mailparser": "^3.7.2", "mailparser": "^3.7.2",
"protocol-buffers-schema": "^3.6.0", "protocol-buffers-schema": "^3.6.0",
"roku-deploy": "^3.12.3", "roku-deploy": "^3.12.3",
"roku-test-automation": "^2.0.10",
"rooibos-roku": "5.14.0", "rooibos-roku": "5.14.0",
"rounded-rect-9patch": "^1.1.2", "rounded-rect-9patch": "^1.1.2",
"semver": "^7.6.3", "semver": "^7.6.3",
"shelljs": "^0.8.5", "shelljs": "^0.8.5",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "5.7.2", "typescript": "5.7.3",
"xml2js": "^0.6.2", "xml2js": "^0.6.2",
"yaml": "^2.7.0" "yaml": "^2.7.0"
}, },
@@ -55,6 +56,7 @@
"test:build:app": "cd playlet-app && npm run test:build", "test:build:app": "cd playlet-app && npm run test:build",
"test:lib": "cd playlet-lib && npm run test", "test:lib": "cd playlet-lib && npm run test",
"test:build:lib": "cd playlet-lib && npm run test:build", "test:build:lib": "cd playlet-lib && npm run test:build",
"test:integration": "npx tsx ./integration-tests/play-video.ts",
"version-sync": "node tools/version-sync.js", "version-sync": "node tools/version-sync.js",
"manifest-git-hash": "node tools/update-manifest-git-hash.js", "manifest-git-hash": "node tools/update-manifest-git-hash.js",
"sign-released-package": "node tools/sign-released-package.js", "sign-released-package": "node tools/sign-released-package.js",
@@ -62,10 +64,13 @@
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js", "generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
"update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip", "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", "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 --reject @sveltejs/vite-plugin-svelte,svelte,vite,@vitejs/plugin-legacy", "update-deps": "npx npm-check-updates --deep --upgrade --install always",
"registry:write": "node tools/registry.js --input registry.json", "registry:write": "node tools/registry.js --input registry.json",
"registry:read": "node tools/registry.js --output registry.json", "registry:read": "node tools/registry.js --output registry.json",
"registry:clear": "node tools/registry.js --clear", "registry:clear": "node tools/registry.js --clear",
"restart-app": "node tools/restart-app.js --app-id dev" "restart-app": "node tools/restart-app.js"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "^4.30.1"
} }
} }
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.35.5", "version": "0.36.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-app", "name": "playlet-app",
"version": "0.35.5" "version": "0.36.1"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.35.5", "version": "0.36.1",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"scripts": { "scripts": {
"prebuild": "rm -rf ../build/playlet-app", "prebuild": "rm -rf ../build/playlet-app",
+2 -2
View File
@@ -2,8 +2,8 @@ title=Playlet
# Do not update version manually, it is auto updated from package.json # Do not update version manually, it is auto updated from package.json
major_version=0 major_version=0
minor_version=35 minor_version=36
build_version=00005 build_version=00001
ui_resolutions=hd ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p uri_resolution_autosub=$$RES$$,480p,720p,1080p
-14
View File
@@ -1,7 +1,6 @@
function DialogShowError(message as object, bulletText as object, bottomMessage as object) function DialogShowError(message as object, bulletText as object, bottomMessage as object)
' Note: dialog can be null since StandardMessageDialog is only available on 10.0 and later ' Note: dialog can be null since StandardMessageDialog is only available on 10.0 and later
msgDialog = CreateObject("roSGNode", "StandardMessageDialog") msgDialog = CreateObject("roSGNode", "StandardMessageDialog")
DialogSetPalette(msgDialog)
msgDialog.message = message msgDialog.message = message
msgDialog.bulletText = bulletText msgDialog.bulletText = bulletText
msgDialog.bottomMessage = bottomMessage msgDialog.bottomMessage = bottomMessage
@@ -16,19 +15,6 @@ function DialogShowError(message as object, bulletText as object, bottomMessage
m.top.getScene().dialog = msgDialog m.top.getScene().dialog = msgDialog
end function end function
function DialogSetPalette(msgDialog as object)
palette = createObject("roSGNode", "RSGPalette")
palette.colors = {
DialogBackgroundColor: "#242424FF"
DialogFocusColor: "#CECECEFF"
DialogFocusItemColor: "#202020FF"
DialogSecondaryTextColor: "#EBEBEBFF"
DialogSecondaryItemColor: "#FF1C30FF"
DialogTextColor: "#EBEBEBFF"
}
msgDialog.palette = palette
end function
function DialogOnButtonSelected() function DialogOnButtonSelected()
m.top.getScene().dialog.close = true m.top.getScene().dialog.close = true
end function end function
+2 -1
View File
@@ -1,5 +1,5 @@
' Playlet (App to play videos from an Invidious server on Roku TVs) ' Playlet (App to play videos from an Invidious server on Roku TVs)
' Copyright (C) 2024 Brahim Hadriche ' Copyright (C) 2025 Brahim Hadriche
' This program is free software: you can redistribute it and/or modify ' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU Affero General Public License as published by ' it under the terms of the GNU Affero General Public License as published by
@@ -29,6 +29,7 @@ function Main(args as object) as void
scene = screen.CreateScene("BootstrapScene") scene = screen.CreateScene("BootstrapScene")
screen.show() screen.show()
SetScenePalette(scene)
scene.ObserveField("exitChannel", port) scene.ObserveField("exitChannel", port)
scene.launchArgs = args scene.launchArgs = args
@@ -1,5 +1,5 @@
function SetPalette(dialog as object) function SetScenePalette(scene as object)
palette = createObject("roSGNode", "RSGPalette") palette = CreateObject("roSGNode", "RSGPalette")
palette.colors = { palette.colors = {
DialogBackgroundColor: "#242424FF" DialogBackgroundColor: "#242424FF"
DialogFocusColor: "#CECECEFF" DialogFocusColor: "#CECECEFF"
@@ -8,5 +8,5 @@ function SetPalette(dialog as object)
DialogSecondaryItemColor: "#FF1C30FF" DialogSecondaryItemColor: "#FF1C30FF"
DialogTextColor: "#EBEBEBFF" DialogTextColor: "#EBEBEBFF"
} }
dialog.palette = palette scene.palette = palette
end function end function
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.35.5", "version": "0.36.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.35.5" "version": "0.36.1"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.35.5", "version": "0.36.1",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"scripts": { "scripts": {
"prebuild": "rm -rf ../build/playlet-lib", "prebuild": "rm -rf ../build/playlet-lib",
@@ -92,11 +92,11 @@ function OnContentSet() as void
if (authorId <> m.authorId or author <> m.author) and IsArray(content.tabs) if (authorId <> m.authorId or author <> m.author) and IsArray(content.tabs)
m.authorId = authorId m.authorId = authorId
m.author = author m.author = author
m.rowList.feeds = CreateChannelFeeds(m.authorId, author, content.tabs, content.tabsParams) m.rowList.feeds = CreateChannelFeeds(m.authorId, author, content.tabs, content.tabsParams, content.tabsTitles)
end if end if
end function end function
function CreateChannelFeeds(authorId as string, author as string, tabs as object, tabsParams as object) as object function CreateChannelFeeds(authorId as string, author as string, tabs as object, tabsParams as object, tabsTitles as object) as object
if authorId = "" if authorId = ""
return invalid return invalid
end if end if
@@ -111,7 +111,13 @@ function CreateChannelFeeds(authorId as string, author as string, tabs as object
params = "" params = ""
end if end if
feeds.Push(m.tabs[tabName](authorId, author, params)) if tabsTitles <> invalid and tabsTitles.DoesExist(tabName)
title = tabsTitles[tabName]
else
title = ""
end if
feeds.Push(m.tabs[tabName](authorId, author, title, params))
end if end if
end for end for
@@ -197,23 +203,47 @@ end function
function InitializeTabs() function InitializeTabs()
m.tabs = { m.tabs = {
"videos": function(authorId as string, author as string, params as string) as object "videos": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Videos", "channel_videos", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Videos"
end if
return CreateChannelFeed(title, "channel_videos", authorId, author, params)
end function end function
"shorts": function(authorId as string, author as string, params as string) as object "shorts": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Shorts", "channel_shorts", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Shorts"
end if
return CreateChannelFeed(title, "channel_shorts", authorId, author, params)
end function end function
"streams": function(authorId as string, author as string, params as string) as object "streams": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Live", "channel_streams", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Live"
end if
return CreateChannelFeed(title, "channel_streams", authorId, author, params)
end function end function
"releases": function(authorId as string, author as string, params as string) as object "releases": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Releases", "channel_releases", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Releases"
end if
return CreateChannelFeed(title, "channel_releases", authorId, author, params)
end function end function
"podcasts": function(authorId as string, author as string, params as string) as object "podcasts": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Podcasts", "channel_podcasts", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Podcasts"
end if
return CreateChannelFeed(title, "channel_podcasts", authorId, author, params)
end function end function
"playlists": function(authorId as string, author as string, params as string) as object "playlists": function(authorId as string, author as string, title as string, params as string) as object
return CreateChannelFeed("Playlists", "channel_playlists", authorId, author, params) if StringUtils.IsNullOrEmpty(title)
title = "Playlists"
end if
return CreateChannelFeed(title, "channel_playlists", authorId, author, params)
end function
"courses": function(authorId as string, author as string, title as string, params as string) as object
if StringUtils.IsNullOrEmpty(title)
title = "Courses"
end if
return CreateChannelFeed(title, "channel_courses", authorId, author, params)
end function end function
} }
end function end function
@@ -18,6 +18,7 @@
<field id="subCountText" type="string" /> <field id="subCountText" type="string" />
<field id="tabs" type="array" /> <field id="tabs" type="array" />
<field id="tabsParams" type="assocarray" /> <field id="tabsParams" type="assocarray" />
<field id="tabsTitles" type="assocarray" />
<field id="thumbnail" type="string" /> <field id="thumbnail" type="string" />
<field id="videoCount" type="integer" /> <field id="videoCount" type="integer" />
<field id="videoCountText" type="string" /> <field id="videoCountText" type="string" />
@@ -1,10 +1,8 @@
import "DialogPalette.bs"
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
SetPalette(m.top)
m.urlLabel = m.top.findNode("urlLabel") m.urlLabel = m.top.findNode("urlLabel")
m.qrCode = m.top.findNode("QrCodePoster") m.qrCode = m.top.findNode("QrCodePoster")
@@ -1,8 +1,6 @@
import "DialogPalette.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
SetPalette(m.top)
m.top.observeField("buttonSelected", FuncName(CloseDialog)) m.top.observeField("buttonSelected", FuncName(CloseDialog))
end function end function
@@ -1,10 +1,8 @@
import "DialogPalette.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
SetPalette(m.top)
m.top.observeField("buttonSelected", FuncName(OnButtonSelected)) m.top.observeField("buttonSelected", FuncName(OnButtonSelected))
m.top.observeField("wasClosed", FuncName(OnDialogClosed)) m.top.observeField("wasClosed", FuncName(OnDialogClosed))
end function end function
+20
View File
@@ -7,12 +7,32 @@ import "pkg:/source/utils/Locale.bs"
function Init() function Init()
m.scene = m.top.getScene() m.scene = m.top.getScene()
SetScenePalette(m.scene)
' At this point, the "MainScene" node is not yet added to the scene, and does not have a parent yet. ' At this point, the "MainScene" node is not yet added to the scene, and does not have a parent yet.
' Let's wait until it has one. ' Let's wait until it has one.
m.MainSceneContainer = m.scene.findNode("MainSceneContainer") m.MainSceneContainer = m.scene.findNode("MainSceneContainer")
m.MainSceneContainer.ObserveField("change", FuncName(MainSceneContainerChanged)) m.MainSceneContainer.ObserveField("change", FuncName(MainSceneContainerChanged))
end function end function
function SetScenePalette(scene as object) as void
palette = scene.palette
if palette <> invalid
return
end if
palette = CreateObject("roSGNode", "RSGPalette")
palette.colors = {
DialogBackgroundColor: "#242424FF"
DialogFocusColor: "#CECECEFF"
DialogFocusItemColor: "#202020FF"
DialogSecondaryTextColor: "#EBEBEBFF"
DialogSecondaryItemColor: "#FF1C30FF"
DialogTextColor: "#EBEBEBFF"
}
scene.palette = palette
end function
function MainSceneContainerChanged() function MainSceneContainerChanged()
AutoBindSceneGraph() AutoBindSceneGraph()
StartWebServer() StartWebServer()
@@ -8,12 +8,30 @@
function Init() function Init()
InitializeBindings() ' auto-generated! InitializeBindings() ' auto-generated!
m.scene = m.top.getScene() m.scene = m.top.getScene()
SetScenePalette(m.scene)
' At this point, the "MainScene" node is not yet added to the scene, and does not have a parent yet. ' At this point, the "MainScene" node is not yet added to the scene, and does not have a parent yet.
' Let's wait until it has one. ' Let's wait until it has one.
m.MainSceneContainer = m.scene.findNode("MainSceneContainer") m.MainSceneContainer = m.scene.findNode("MainSceneContainer")
m.MainSceneContainer.ObserveField("change", FuncName(MainSceneContainerChanged)) m.MainSceneContainer.ObserveField("change", FuncName(MainSceneContainerChanged))
end function end function
function SetScenePalette(scene as object) as void
palette = scene.palette
if palette <> invalid
return
end if
palette = CreateObject("roSGNode", "RSGPalette")
palette.colors = {
DialogBackgroundColor: "#242424FF"
DialogFocusColor: "#CECECEFF"
DialogFocusItemColor: "#202020FF"
DialogSecondaryTextColor: "#EBEBEBFF"
DialogSecondaryItemColor: "#FF1C30FF"
DialogTextColor: "#EBEBEBFF"
}
scene.palette = palette
end function
function MainSceneContainerChanged() function MainSceneContainerChanged()
AutoBindSceneGraph() AutoBindSceneGraph()
StartWebServer() StartWebServer()
@@ -47,6 +47,7 @@
<BookmarksService id="BookmarksService" /> <BookmarksService id="BookmarksService" />
<SearchHistory id="SearchHistory" /> <SearchHistory id="SearchHistory" />
<ProfilesService id="ProfilesService" /> <ProfilesService id="ProfilesService" />
<Innertube id="Innertube" />
<Invidious id="Invidious" /> <Invidious id="Invidious" />
<PlayletWebServer id="WebServer" port="8888" /> <PlayletWebServer id="WebServer" port="8888" />
<DialServer id="DialServer" /> <DialServer id="DialServer" />
+3
View File
@@ -56,6 +56,7 @@
<VideoQueue id="VideoQueue" <VideoQueue id="VideoQueue"
appController="bind:/AppController" appController="bind:/AppController"
videoContainer="bind:../VideoContainer" videoContainer="bind:../VideoContainer"
innertube="bind:../Innertube"
invidious="bind:../Invidious" invidious="bind:../Invidious"
notifications="bind:../Notifications" notifications="bind:../Notifications"
preferences="bind:../Preferences" preferences="bind:../Preferences"
@@ -70,6 +71,7 @@
<ProfilesService id="ProfilesService" <ProfilesService id="ProfilesService"
invidious="bind:../Invidious" /> invidious="bind:../Invidious" />
<Innertube id="Innertube" />
<Invidious id="Invidious" <Invidious id="Invidious"
webServer="bind:../WebServer" webServer="bind:../WebServer"
applicationInfo="bind:../ApplicationInfo" applicationInfo="bind:../ApplicationInfo"
@@ -81,6 +83,7 @@
port="8888" port="8888"
appController="bind:/AppController" appController="bind:/AppController"
applicationInfo="bind:../ApplicationInfo" applicationInfo="bind:../ApplicationInfo"
innertube="bind:../Innertube"
invidious="bind:../Invidious" invidious="bind:../Invidious"
profilesService="bind:../ProfilesService" profilesService="bind:../ProfilesService"
preferences="bind:../Preferences" preferences="bind:../Preferences"
@@ -18,6 +18,7 @@ function InitializeBindings()
"VideoQueue": { "VideoQueue": {
"appController": "/AppController", "appController": "/AppController",
"videoContainer": "../VideoContainer", "videoContainer": "../VideoContainer",
"innertube": "../Innertube",
"invidious": "../Invidious", "invidious": "../Invidious",
"notifications": "../Notifications", "notifications": "../Notifications",
"preferences": "../Preferences", "preferences": "../Preferences",
@@ -38,6 +39,7 @@ function InitializeBindings()
"WebServer": { "WebServer": {
"appController": "/AppController", "appController": "/AppController",
"applicationInfo": "../ApplicationInfo", "applicationInfo": "../ApplicationInfo",
"innertube": "../Innertube",
"invidious": "../Invidious", "invidious": "../Invidious",
"profilesService": "../ProfilesService", "profilesService": "../ProfilesService",
"preferences": "../Preferences", "preferences": "../Preferences",
@@ -1,4 +1,3 @@
import "pkg:/components/Dialog/DialogPalette.bs"
import "pkg:/components/Navigation/Navigation.bs" import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs" import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs" import "pkg:/components/Services/Invidious/InvidiousService.bs"
@@ -102,7 +101,6 @@ end function
function OnEditButtonSelected() function OnEditButtonSelected()
keyboardDialog = createObject("roSGNode", "StandardKeyboardDialog") keyboardDialog = createObject("roSGNode", "StandardKeyboardDialog")
SetPalette(keyboardDialog)
' TODO:P2 localize ' TODO:P2 localize
keyboardDialog.title = "Edit Instance" keyboardDialog.title = "Edit Instance"
' TODO:P2 localize ' TODO:P2 localize
@@ -102,7 +102,6 @@ function Refresh()
end function end function
function OnInvidiousPublicInstancesTaskResults(output as object) as void function OnInvidiousPublicInstancesTaskResults(output as object) as void
m.top.focusable = true
m.busySpinner.visible = false m.busySpinner.visible = false
m.busySpinner.control = "stop" m.busySpinner.control = "stop"
@@ -130,6 +129,8 @@ function OnInvidiousPublicInstancesTaskResults(output as object) as void
m.failedLabel.visible = true m.failedLabel.visible = true
m.refreshButton.visible = true m.refreshButton.visible = true
m.top.focusable = true
if m.top.IsInFocusChain() if m.top.IsInFocusChain()
NodeSetFocus(m.top, true) NodeSetFocus(m.top, true)
end if end if
@@ -138,6 +139,7 @@ function OnInvidiousPublicInstancesTaskResults(output as object) as void
m.instances.visible = true m.instances.visible = true
m.instancesHeader.visible = true m.instancesHeader.visible = true
m.top.focusable = m.instances.content.getChildCount() > 0
if m.top.IsInFocusChain() if m.top.IsInFocusChain()
NodeSetFocus(m.top, true) NodeSetFocus(m.top, true)
@@ -1,4 +1,3 @@
import "pkg:/components/Dialog/DialogPalette.bs"
import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -67,7 +66,6 @@ end function
function ShowEditKeyboard() function ShowEditKeyboard()
keyboardDialog = createObject("roSGNode", "StandardKeyboardDialog") keyboardDialog = createObject("roSGNode", "StandardKeyboardDialog")
SetPalette(keyboardDialog)
keyboardDialog.title = m.top.displayText keyboardDialog.title = m.top.displayText
keyboardDialog.message = [m.top.description] keyboardDialog.message = [m.top.description]
keyboardDialog.text = m.top.value keyboardDialog.text = m.top.value
@@ -8,7 +8,7 @@ namespace Innertube
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"context": Innertube.CreateContext(clienType, deviceInfo, "") "context": Innertube.CreateContext(clienType, deviceInfo, "", "")
} }
if not StringUtils.IsNullOrEmpty(continuation) if not StringUtils.IsNullOrEmpty(continuation)
@@ -33,7 +33,7 @@ namespace Innertube
end if end if
end function end function
function CreateContext(clienType as Innertube.ClientType, deviceInfo as object, ctt as string) as object function CreateContext(clienType as Innertube.ClientType, deviceInfo as object, ctt as string, visitorData as string) as object
client = invalid client = invalid
if clienType = ClientType.Web if clienType = ClientType.Web
client = CreateContextClientWeb(deviceInfo) client = CreateContextClientWeb(deviceInfo)
@@ -64,19 +64,22 @@ namespace Innertube
}] }]
end if end if
if not StringUtils.IsNullOrEmpty(visitorData)
context["client"]["visitorData"] = visitorData
end if
return context return context
end function end function
function CreateContextClientWeb(deviceInfo as object) as object function CreateContextClientWeb(deviceInfo as object) as object
return { return {
"hl": deviceInfo.GetCurrentLocale() "hl": GetCurrentLocale(deviceInfo)
"gl": GetContentRegion(deviceInfo) "gl": GetContentRegion(deviceInfo)
"remoteHost": "" "remoteHost": ""
"screenDensityFloat": 1 "screenDensityFloat": 1
"screenHeightPoints": 1440 "screenHeightPoints": 1440
"screenPixelDensity": 1 "screenPixelDensity": 1
"screenWidthPoints": 2560 "screenWidthPoints": 2560
"visitorData": ""
"clientName": "WEB" "clientName": "WEB"
"clientVersion": INNERTUBE_WEB_CLIENT_VERSION "clientVersion": INNERTUBE_WEB_CLIENT_VERSION
"osName": "Windows" "osName": "Windows"
@@ -103,14 +106,13 @@ namespace Innertube
function CreateContextClientIOS(deviceInfo as object) as object function CreateContextClientIOS(deviceInfo as object) as object
return { return {
"hl": deviceInfo.GetCurrentLocale() "hl": GetCurrentLocale(deviceInfo)
"gl": GetContentRegion(deviceInfo) "gl": GetContentRegion(deviceInfo)
"remoteHost": "" "remoteHost": ""
"screenDensityFloat": 1 "screenDensityFloat": 1
"screenHeightPoints": 1440 "screenHeightPoints": 1440
"screenPixelDensity": 1 "screenPixelDensity": 1
"screenWidthPoints": 2560 "screenWidthPoints": 2560
"visitorData": ""
"clientName": "iOS" "clientName": "iOS"
"clientVersion": INNERTUBE_IOS_CLIENT_VERSION "clientVersion": INNERTUBE_IOS_CLIENT_VERSION
"osName": "iOS" "osName": "iOS"
@@ -129,7 +131,7 @@ namespace Innertube
function CreateContextClientTv(deviceInfo as object) as object function CreateContextClientTv(deviceInfo as object) as object
return { return {
"hl": deviceInfo.GetCurrentLocale() "hl": GetCurrentLocale(deviceInfo)
"gl": GetContentRegion(deviceInfo) "gl": GetContentRegion(deviceInfo)
"remoteHost": "" "remoteHost": ""
"deviceMake": INNERTUBE_TV_DEVICE_MAKE "deviceMake": INNERTUBE_TV_DEVICE_MAKE
@@ -159,6 +161,10 @@ namespace Innertube
} }
end function end function
function GetCurrentLocale(deviceInfo as object) as string
return deviceInfo.GetCurrentLocale()
end function
function GetContentRegion(deviceInfo as object) as string function GetContentRegion(deviceInfo as object) as string
region = deviceInfo.GetUserCountryCode() region = deviceInfo.GetUserCountryCode()
if region.len() <> 2 or region = "OT" if region.len() <> 2 or region = "OT"
@@ -0,0 +1,9 @@
import "pkg:/components/Services/Innertube/Constants.bs"
import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs"
function Init()
AsyncTask.Start(Tasks.InnertubeInitTask, {
innertube: m.top
})
end function
@@ -0,0 +1,5 @@
<component name="Innertube" extends="Node">
<interface>
<field id="visitorData" type="string" />
</interface>
</component>
@@ -0,0 +1,15 @@
import "pkg:/components/Services/Innertube/SessionData.bs"
@asynctask
function InnertubeInitTask(input as object) as object
innertubeNode = input.innertube
sessionData = Innertube.GetSessionData()
if sessionData = invalid
return invalid
end if
innertubeNode.visitorData = sessionData.visitorData
return invalid
end function
@@ -18,6 +18,8 @@ namespace InnertubeService
cancellation = invalid cancellation = invalid
fetchNext = true fetchNext = true
ctt = "" ctt = ""
visitorData = ""
raw = false
if options <> invalid if options <> invalid
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
@@ -29,9 +31,15 @@ namespace InnertubeService
if options.DoesExist("ctt") if options.DoesExist("ctt")
ctt = options.ctt ctt = options.ctt
end if end if
if options.DoesExist("raw")
raw = options.raw
end if
if options.DoesExist("visitorData")
visitorData = options.visitorData
end if
end if end if
playerRequest = Innertube.CreatePlayerRequest(videoId, ctt) playerRequest = Innertube.CreatePlayerRequest(videoId, ctt, visitorData)
playerRequest.Cancellation(cancellation) playerRequest.Cancellation(cancellation)
playerRequest.Send() playerRequest.Send()
@@ -60,6 +68,16 @@ namespace InnertubeService
nextResponse = nextRequest.Await() nextResponse = nextRequest.Await()
end if end if
if raw
rawResponse = {
"playerResponse": playerResponse.Json()
}
if fetchNext
rawResponse["nextResponse"] = nextResponse.Json()
end if
return rawResponse
end if
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerResponse.Json()) parsedResponse = Innertube.ParseInnertubePlayerResponse(playerResponse.Json())
if parsedResponse.error <> invalid if parsedResponse.error <> invalid
return parsedResponse return parsedResponse
@@ -158,6 +176,7 @@ namespace InnertubeService
searchFilters = invalid searchFilters = invalid
continuation = "" continuation = ""
cancellation = invalid cancellation = invalid
raw = false
if options <> invalid if options <> invalid
if options.DoesExist("searchFilters") if options.DoesExist("searchFilters")
@@ -169,14 +188,18 @@ namespace InnertubeService
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
cancellation = options.cancellation cancellation = options.cancellation
end if end if
if options.DoesExist("raw")
raw = options.raw
end if
end if end if
return Innertube.Search(query, searchFilters, continuation, cancellation) return Innertube.Search(query, searchFilters, continuation, cancellation, raw)
end function end function
function GetTrending(options = invalid as object) as object function GetTrending(options = invalid as object) as object
cancellation = invalid cancellation = invalid
params = "" params = ""
raw = false
if options <> invalid if options <> invalid
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
@@ -193,6 +216,9 @@ namespace InnertubeService
params = "4gIKGgh0cmFpbGVycw%3D%3D" params = "4gIKGgh0cmFpbGVycw%3D%3D"
end if end if
end if end if
if options.DoesExist("raw")
raw = options.raw
end if
end if end if
request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, params) request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, params)
@@ -203,8 +229,11 @@ namespace InnertubeService
return invalid return invalid
end if end if
json = response.Json() if raw
feeds = Innertube.ParseResponseDataForFeeds(json) return response.Json()
end if
feeds = Innertube.ParseResponseDataForFeeds(response.Json(), { skipCreatorOnTheRise: true })
result = { result = {
feeds: feeds feeds: feeds
@@ -270,6 +299,7 @@ namespace InnertubeService
continuation = "" continuation = ""
params = "" params = ""
cancellation = invalid cancellation = invalid
raw = false
if options <> invalid if options <> invalid
if options.DoesExist("continuation") if options.DoesExist("continuation")
@@ -281,6 +311,9 @@ namespace InnertubeService
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
cancellation = options.cancellation cancellation = options.cancellation
end if end if
if options.DoesExist("raw")
raw = options.raw
end if
end if end if
request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Web, params, continuation) request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Web, params, continuation)
@@ -293,8 +326,14 @@ namespace InnertubeService
} }
end if end if
json = response.Json() if raw
result = Innertube.ParseChannelPageResponseData(json) return response.Json()
end if
result = Innertube.ParseChannelPageResponseData(response.Json())
if result.authorId = invalid and result.error = invalid
result["authorId"] = channelId
end if
cacheControl = Innertube.ParseResponseForCacheControl(response) cacheControl = Innertube.ParseResponseForCacheControl(response)
if cacheControl <> invalid if cacheControl <> invalid
@@ -307,6 +346,7 @@ namespace InnertubeService
function GetPlaylist(playlistId as string, options = invalid as object) as object function GetPlaylist(playlistId as string, options = invalid as object) as object
continuation = "" continuation = ""
cancellation = invalid cancellation = invalid
raw = false
if options <> invalid if options <> invalid
if options.DoesExist("continuation") if options.DoesExist("continuation")
@@ -315,6 +355,9 @@ namespace InnertubeService
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
cancellation = options.cancellation cancellation = options.cancellation
end if end if
if options.DoesExist("raw")
raw = options.raw
end if
end if end if
if not playlistId.StartsWith("VL") if not playlistId.StartsWith("VL")
@@ -331,8 +374,11 @@ namespace InnertubeService
} }
end if end if
json = response.Json() if raw
result = Innertube.ParsePlaylistPageResponseData(json) return response.Json()
end if
result = Innertube.ParsePlaylistPageResponseData(response.Json())
cacheControl = Innertube.ParseResponseForCacheControl(response) cacheControl = Innertube.ParseResponseForCacheControl(response)
if cacheControl <> invalid if cacheControl <> invalid
@@ -345,6 +391,7 @@ namespace InnertubeService
function GetMix(mixId as string, options = invalid as object) as object function GetMix(mixId as string, options = invalid as object) as object
videoId = "" videoId = ""
cancellation = invalid cancellation = invalid
raw = false
if options <> invalid if options <> invalid
if options.DoesExist("videoId") if options.DoesExist("videoId")
@@ -353,6 +400,9 @@ namespace InnertubeService
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
cancellation = options.cancellation cancellation = options.cancellation
end if end if
if options.DoesExist("raw")
raw = options.raw
end if
end if end if
args = { "playlistId": mixId } args = { "playlistId": mixId }
@@ -369,8 +419,11 @@ namespace InnertubeService
} }
end if end if
json = response.Json() if raw
return Innertube.ParseMixPageResponseData(json) return response.Json()
end if
return Innertube.ParseMixPageResponseData(response.Json())
end function end function
function ResolveUrl(url as string, options = invalid as object) as object function ResolveUrl(url as string, options = invalid as object) as object
@@ -12,7 +12,7 @@ namespace Innertube
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"context": Innertube.CreateContext(Innertube.ClientType.Web, deviceInfo, ctt) "context": Innertube.CreateContext(Innertube.ClientType.Web, deviceInfo, ctt, "")
} }
payload.Append(payloadArgs) payload.Append(payloadArgs)
@@ -37,8 +37,10 @@ namespace Innertube
"watchNextEndScreenRenderer": ParseWatchNextEndScreenRenderer "watchNextEndScreenRenderer": ParseWatchNextEndScreenRenderer
"tabRenderer": ParseTabRenderer "tabRenderer": ParseTabRenderer
"sectionListRenderer": ParseSectionListRenderer "sectionListRenderer": ParseSectionListRenderer
"richSectionRenderer": ParseRichSectionRenderer
"itemSectionRenderer": ParseItemSectionRenderer "itemSectionRenderer": ParseItemSectionRenderer
"shelfRenderer": ParseShelfRenderer "shelfRenderer": ParseShelfRenderer
"richShelfRenderer": ParseRichShelfRenderer
"reelShelfRenderer": ParseReelShelfRenderer "reelShelfRenderer": ParseReelShelfRenderer
"verticalListRenderer": ParseVerticalListRenderer "verticalListRenderer": ParseVerticalListRenderer
"horizontalListRenderer": ParseHorizontalListRenderer "horizontalListRenderer": ParseHorizontalListRenderer
@@ -111,16 +113,38 @@ namespace Innertube
return nodeData["contents"] return nodeData["contents"]
end function end function
function ParseRichSectionRenderer(nodeData as object, _context as object) as object
return nodeData["content"]
end function
function ParseItemSectionRenderer(nodeData as object, _context as object) as object function ParseItemSectionRenderer(nodeData as object, _context as object) as object
return nodeData["contents"] return nodeData["contents"]
end function end function
function ParseShelfRenderer(nodeData as object, _context as object) as object function ParseShelfRenderer(nodeData as object, context as object) as object
if context.skipCreatorOnTheRise = true
badges = nodeData["badges"]
if IsArray(badges)
for each badge in badges
if ValidString(ObjectUtils.Dig(badge, ["metadataBadgeRenderer", "style"])) = "BADGE_STYLE_TYPE_FEATURED"
label = ParseText(ObjectUtils.Dig(badge, ["metadataBadgeRenderer", "label"]))
LogInfo(`Skipping 'Create on the Rise' shelf (${label})`)
return invalid
end if
end for
end if
end if
' TODO: handle shelfRenderer.title ' TODO: handle shelfRenderer.title
' TODO: handle shelfRenderer.headerRenderer.shelfHeaderRenderer.avatarLockup.avatarLockupRenderer.title ' TODO: handle shelfRenderer.headerRenderer.shelfHeaderRenderer.avatarLockup.avatarLockupRenderer.title
return nodeData["content"] return nodeData["content"]
end function end function
function ParseRichShelfRenderer(nodeData as object, context as object) as object
' TODO: handle richShelfRenderer.title
return nodeData["contents"]
end function
function ParseReelShelfRenderer(nodeData as object, _context as object) as object function ParseReelShelfRenderer(nodeData as object, _context as object) as object
' TODO: handle reelShelfRenderer.title ' TODO: handle reelShelfRenderer.title
return nodeData["items"] return nodeData["items"]
@@ -58,6 +58,9 @@ namespace Innertube
end if end if
author = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "title"]) author = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "title"])
if author = invalid
author = ObjectUtils.Dig(responseData, ["header", "pageHeaderRenderer", "pageTitle"])
end if
authorId = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "externalId"]) authorId = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "externalId"])
thumbnails = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "avatar", "thumbnails"]) thumbnails = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "avatar", "thumbnails"])
@@ -103,6 +106,7 @@ namespace Innertube
tabsNames = [] tabsNames = []
tabsParams = {} tabsParams = {}
tabsTitles = {}
tabs = ObjectUtils.Dig(responseData, ["contents", "twoColumnBrowseResultsRenderer", "tabs"]) tabs = ObjectUtils.Dig(responseData, ["contents", "twoColumnBrowseResultsRenderer", "tabs"])
if tabs <> invalid if tabs <> invalid
@@ -123,13 +127,17 @@ namespace Innertube
continue for continue for
end if end if
tabParams = ObjectUtils.Dig(tabRenderer, ["endpoint", "browseEndpoint", "params"]) tabsNames.Push(tabName)
if tabParams = invalid
continue for tabTitle = tabRenderer["title"]
if IsString(tabTitle)
tabsTitles[tabName] = tabTitle
end if end if
tabsNames.Push(tabName) tabParams = ObjectUtils.Dig(tabRenderer, ["endpoint", "browseEndpoint", "params"])
tabsParams[tabName] = tabParams if IsString(tabParams)
tabsParams[tabName] = tabParams
end if
end for end for
end if end if
@@ -151,6 +159,7 @@ namespace Innertube
"authorSubTitle": authorSubTitle "authorSubTitle": authorSubTitle
"tabs": tabsNames "tabs": tabsNames
"tabsParams": tabsParams "tabsParams": tabsParams
"tabsTitles": tabsTitles
"items": items "items": items
} }
@@ -6,12 +6,12 @@ import "pkg:/source/utils/Types.bs"
namespace Innertube namespace Innertube
function CreatePlayerRequest(videoId as string, ctt as string) as object function CreatePlayerRequest(videoId as string, ctt as string, visitorData as string) as object
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"videoId": videoId "videoId": videoId
"context": Innertube.CreateContext(Innertube.ClientType.IOS, deviceInfo, ctt) "context": Innertube.CreateContext(Innertube.ClientType.IOS, deviceInfo, ctt, visitorData)
"playbackContext": { "playbackContext": {
"contentPlaybackContext": { "contentPlaybackContext": {
"vis": 0 "vis": 0
@@ -6,7 +6,7 @@ namespace Innertube
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
"context": CreateContext(ClientType.Web, deviceInfo, "") "context": CreateContext(ClientType.Web, deviceInfo, "", "")
"url": url "url": url
} }
@@ -6,11 +6,11 @@ import "pkg:/source/utils/Types.bs"
namespace Innertube namespace Innertube
function Search(query as string, searchFilters as object, continuation = "" as string, cancellation = invalid as object) as object function Search(query as string, searchFilters as object, continuation = "" as string, cancellation = invalid as object, raw = false as boolean) as object
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
context: Innertube.CreateContext(Innertube.ClientType.WEB, deviceInfo, "") context: Innertube.CreateContext(Innertube.ClientType.WEB, deviceInfo, "", "")
} }
if continuation <> "" if continuation <> ""
@@ -43,6 +43,10 @@ namespace Innertube
} }
end if end if
if raw
return response.Json()
end if
feeds = ParseResponseDataForFeeds(response.Json()) feeds = ParseResponseDataForFeeds(response.Json())
result = { result = {
@@ -0,0 +1,91 @@
import "pkg:/components/Services/Innertube/Constants.bs"
import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/ObjectUtils.bs"
import "pkg:/source/utils/RegistryUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/TimeUtils.bs"
namespace Innertube
const SESSION_DATA_VERSION = 1
const INNERTUBE_VISITOR_DATA_LIFESPAN = 1000 * 60 * 60 * 24
function GetSessionData() as object
sessionData = ReadSessionDataFromRegistry()
if sessionData <> invalid
return sessionData
end if
sessionData = RequestSessionData()
if sessionData = invalid
return invalid
end if
RegistryUtils.Write(RegistryUtils.INNERTUBE_SESSION_DATA, FormatJson(sessionData))
return sessionData
end function
function RequestSessionData() as object
request = HttpClient.Get("https://www.youtube.com/sw.js_data")
request.Headers({
"Accept-Language": "en-US,en;q=0.9"
"User-Agent": INNERTUBE_WEB_USER_AGENT
"Accept": "*/*"
"Referer": "https://www.youtube.com/sw.js"
})
response = request.Await()
if not response.IsSuccess()
LogError("Failed to fetch session data", response.ErrorMessage())
return invalid
end if
text = ValidString(response.Text())
if not text.StartsWith(")]}'")
LogError("Invalid session data response", text)
return invalid
end if
text = text.Replace(")]}'", "")
json = ParseJson(text)
if json = invalid
LogError("Failed to parse session data", text)
return invalid
end if
visitorData = ObjectUtils.Dig(json, [0, 2, 0, 0, 13])
if StringUtils.IsNullOrEmpty(visitorData)
LogError("Visitor data not found", text)
return invalid
end if
return {
"__version": SESSION_DATA_VERSION
"timestamp": TimeUtils.Now().AsSeconds()
"visitorData": visitorData
}
end function
function ReadSessionDataFromRegistry() as object
sessionData = RegistryUtils.Read(RegistryUtils.INNERTUBE_SESSION_DATA)
if StringUtils.IsNullOrEmpty(sessionData)
return invalid
end if
sessionData = ParseJson(sessionData)
if sessionData = invalid
RegistryUtils.Delete(RegistryUtils.INNERTUBE_SESSION_DATA)
return invalid
end if
timestamp = sessionData.timestamp
nowSeconds = TimeUtils.Now().AsSeconds()
if nowSeconds - timestamp > INNERTUBE_VISITOR_DATA_LIFESPAN
RegistryUtils.Delete(RegistryUtils.INNERTUBE_SESSION_DATA)
return invalid
end if
return sessionData
end function
end namespace
@@ -442,6 +442,16 @@ namespace Invidious
if response.StatusCode() = 200 if response.StatusCode() = 200
json = response.Json() json = response.Json()
' Courses are not yet implemented in Invidious.
' In this case, Invidious returns 200, but the response is empty.
' https://github.com/iv-org/invidious/issues/5088
' https://github.com/iv-org/invidious/issues/5144
if json = invalid
json = {
playlists: []
}
end if
return { return {
items: json.playlists items: json.playlists
continuation: json.continuation continuation: json.continuation
@@ -82,6 +82,12 @@ namespace InvidiousContent
childCount = node.getChildCount() childCount = node.getChildCount()
newNodes = [] newNodes = []
for each video in item.videos 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.
if ValidString(video.type) = "playlist"
continue for
end if
video.type = "video" video.type = "video"
videoNode = ToVideoContentNode(invalid, video, instance) videoNode = ToVideoContentNode(invalid, video, instance)
if videoNode <> invalid if videoNode <> invalid
@@ -128,6 +134,7 @@ namespace InvidiousContent
node.banner = GetChannelBanner(item.authorBanners) node.banner = GetChannelBanner(item.authorBanners)
' Important: tabsParams should be set first, because settings that tabs triggers the ChannelView to load feeds ' Important: tabsParams should be set first, because settings that tabs triggers the ChannelView to load feeds
SetIfExists(node, "tabsParams", item, "tabsParams") SetIfExists(node, "tabsParams", item, "tabsParams")
SetIfExists(node, "tabsTitles", item, "tabsTitles")
SetIfExists(node, "tabs", item, "tabs") SetIfExists(node, "tabs", item, "tabs")
return node return node
@@ -5,6 +5,7 @@ import "pkg:/components/Services/Invidious/InvidiousService.bs"
function VideoContentTask(input as object) as object function VideoContentTask(input as object) as object
contentNode = input.content contentNode = input.content
invidiousNode = input.invidious invidiousNode = input.invidious
innertubeNode = input.innertube
preferencesNode = input.preferences preferencesNode = input.preferences
loungeServiceNode = input.loungeService loungeServiceNode = input.loungeService
playletServerPort = input.playletServerPort playletServerPort = input.playletServerPort
@@ -22,8 +23,9 @@ function VideoContentTask(input as object) as object
backend = preferencesNode["playback.backend"] backend = preferencesNode["playback.backend"]
if backend = "playlet" if backend = "playlet"
metadata = InnertubeService.GetVideoMetadata(contentNode.videoId, { metadata = InnertubeService.GetVideoMetadata(contentNode.videoId, {
cancellation: m.top.cancellation "cancellation": m.top.cancellation
ctt: loungeServiceNode.ctt "ctt": loungeServiceNode.ctt
"visitorData": innertubeNode.visitorData
}) })
else else
metadata = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation }) metadata = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
@@ -151,6 +151,7 @@ function StartVideoContentTask(videoContentNode as object)
m.videoContentTask = AsyncTask.Start(Tasks.VideoContentTask, { m.videoContentTask = AsyncTask.Start(Tasks.VideoContentTask, {
content: videoContentNode content: videoContentNode
invidious: m.top.invidious invidious: m.top.invidious
innertube: m.top.innertube
preferences: m.top.preferences preferences: m.top.preferences
loungeService: m.top.loungeService loungeService: m.top.loungeService
playletServerPort: m.top.webServer.port playletServerPort: m.top.webServer.port
@@ -5,6 +5,7 @@
<field id="notifications" type="node" bind="../../Notifications" /> <field id="notifications" type="node" bind="../../Notifications" />
<field id="videoQueue" type="node" bind="../../VideoQueue" /> <field id="videoQueue" type="node" bind="../../VideoQueue" />
<field id="preferences" type="node" bind="../../Preferences" /> <field id="preferences" type="node" bind="../../Preferences" />
<field id="innertube" type="node" bind="../../Innertube" />
<field id="invidious" type="node" bind="../../Invidious" /> <field id="invidious" type="node" bind="../../Invidious" />
<field id="webServer" type="node" bind="../../WebServer" /> <field id="webServer" type="node" bind="../../WebServer" />
<field id="loungeService" type="node" bind="../../LoungeService" /> <field id="loungeService" type="node" bind="../../LoungeService" />
@@ -22,6 +22,7 @@
<field id="player" type="node" /> <field id="player" type="node" />
<field id="nowPlaying" type="node" /> <field id="nowPlaying" type="node" />
<field id="innertube" type="node" />
<field id="invidious" type="node" /> <field id="invidious" type="node" />
<field id="notifications" type="node" /> <field id="notifications" type="node" />
<field id="preferences" type="node" /> <field id="preferences" type="node" />
@@ -57,7 +57,11 @@ function OnContentSet() as void
end if end if
AdjustFocus(videoCount) AdjustFocus(videoCount)
LoadVideoDetailsIfNeeded() ' TODO:P1 LoadVideoDetailsIfNeeded is disabled for now.
' Trying to fetch video info (especially one by one) can lead to rate limiting.
' That would result in all videos being blocked. So for now, this is just a
' nice to have, and should not be used.
' LoadVideoDetailsIfNeeded()
end function end function
function OnKeyEvent(key as string, press as boolean) as boolean function OnKeyEvent(key as string, press as boolean) as boolean
@@ -143,6 +147,7 @@ function LoadVideoDetailsIfNeeded() as void
m.loadDetailsTask = AsyncTask.Start(Tasks.VideoQueueViewContentTask, { m.loadDetailsTask = AsyncTask.Start(Tasks.VideoQueueViewContentTask, {
videoNodes: m.videosDetailsToLoad videoNodes: m.videosDetailsToLoad
innertube: m.top.innertube
invidious: m.top.invidious invidious: m.top.invidious
preferences: m.top.preferences preferences: m.top.preferences
index: indexInLoadingArray index: indexInLoadingArray
@@ -4,6 +4,7 @@
<field id="jumpToItem" type="integer" alias="queueList.jumpToItem" /> <field id="jumpToItem" type="integer" alias="queueList.jumpToItem" />
<field id="videoQueue" type="node" /> <field id="videoQueue" type="node" />
<field id="appController" type="node" /> <field id="appController" type="node" />
<field id="innertube" type="node" />
<field id="invidious" type="node" /> <field id="invidious" type="node" />
<field id="preferences" type="node" /> <field id="preferences" type="node" />
<function name="Show" /> <function name="Show" />
@@ -7,6 +7,7 @@ import "pkg:/source/utils/MathUtils.bs"
@asynctask @asynctask
function VideoQueueViewContentTask(input as object) as object function VideoQueueViewContentTask(input as object) as object
videoNodes = input.videoNodes videoNodes = input.videoNodes
innertubeNode = input.innertube
invidiousNode = input.invidious invidiousNode = input.invidious
preferencesNode = input.preferences preferencesNode = input.preferences
service = new Invidious.InvidiousService(invidiousNode) service = new Invidious.InvidiousService(invidiousNode)
@@ -22,6 +23,7 @@ function VideoQueueViewContentTask(input as object) as object
cancellation: cancellation cancellation: cancellation
tryCount: 1 tryCount: 1
fetchNext: false fetchNext: false
visitorData: innertubeNode.visitorData
} }
' TODO:P1: Use InnertubeService.GetVideoInfoBatched instead of loading each video individually ' TODO:P1: Use InnertubeService.GetVideoInfoBatched instead of loading each video individually
@@ -6,6 +6,7 @@ namespace VideoQueueViewUtils
videoQueueView = CreateObject("roSGNode", "VideoQueueView") videoQueueView = CreateObject("roSGNode", "VideoQueueView")
videoQueueView.videoQueue = videoQueue videoQueueView.videoQueue = videoQueue
videoQueueView.appController = appController videoQueueView.appController = appController
videoQueueView.innertube = videoQueue.innertube
videoQueueView.invidious = videoQueue.invidious videoQueueView.invidious = videoQueue.invidious
videoQueueView.preferences = videoQueue.preferences videoQueueView.preferences = videoQueue.preferences
appController@.PushScreen(videoQueueView) appController@.PushScreen(videoQueueView)
@@ -5,8 +5,10 @@ namespace Http
class PlayletInvidiousBackendRouter extends HttpRouter class PlayletInvidiousBackendRouter extends HttpRouter
function new() function new(server as object)
super() super()
m.innertube = server.task.innertube
end function end function
@get("/playlet-invidious-backend/authorize_token") @get("/playlet-invidious-backend/authorize_token")
@@ -180,11 +182,24 @@ namespace Http
end function end function
@get("/playlet-invidious-backend/api/v1/trending") @get("/playlet-invidious-backend/api/v1/trending")
@get("/playlet-invidious-backend/api/v1/popular")
function GetTrending(context as object) as boolean function GetTrending(context as object) as boolean
request = context.request request = context.request
response = context.response response = context.response
result = InnertubeService.GetTrending({ type: request.query.type }) raw = request.query.raw <> invalid
options = {
raw: raw
type: request.query.type
}
result = InnertubeService.GetTrending(options)
if raw
response.Json(result)
return true
end if
if result.error <> invalid if result.error <> invalid
response.Json(result) response.Json(result)
response.http_code = 500 response.http_code = 500
@@ -207,13 +222,6 @@ namespace Http
return true return true
end function end function
@get("/playlet-invidious-backend/api/v1/popular")
function GetPopular(context as object) as boolean
response = context.response
response.Redirect("/playlet-invidious-backend/api/v1/trending")
return true
end function
@get("/playlet-invidious-backend/api/v1/search/suggestions") @get("/playlet-invidious-backend/api/v1/search/suggestions")
function GetSearchSuggestions(context as object) as boolean function GetSearchSuggestions(context as object) as boolean
request = context.request request = context.request
@@ -245,6 +253,11 @@ namespace Http
query = request.query.q query = request.query.q
continuation = request.query.continuation continuation = request.query.continuation
raw = request.query.raw <> invalid
options = {
raw: raw
}
searchFilters = {} searchFilters = {}
sort = request.query.sort sort = request.query.sort
@@ -268,7 +281,6 @@ namespace Http
searchFilters.features = features.Split(",") searchFilters.features = features.Split(",")
end if end if
options = {}
if searchFilters.Count() > 0 if searchFilters.Count() > 0
options.searchFilters = searchFilters options.searchFilters = searchFilters
end if end if
@@ -283,6 +295,11 @@ namespace Http
return true return true
end if end if
if raw
response.Json(result)
return true
end if
if not IsArray(result.feeds) or result.feeds.Count() = 0 if not IsArray(result.feeds) or result.feeds.Count() = 0
response.Json({ response.Json({
"error": "Failed to search" "error": "Failed to search"
@@ -305,6 +322,8 @@ namespace Http
response = context.response response = context.response
url = request.query.url url = request.query.url
raw = request.query.raw <> invalid
if StringUtils.IsNullOrEmpty(url) if StringUtils.IsNullOrEmpty(url)
response.Json({ response.Json({
"error": "Missing 'url' query parameter" "error": "Missing 'url' query parameter"
@@ -313,7 +332,7 @@ namespace Http
return true return true
end if end if
json = InnertubeService.ResolveUrl(url, response) json = InnertubeService.ResolveUrl(url)
if json = invalid if json = invalid
response.Json({ response.Json({
"error": "Failed to resolve URL" "error": "Failed to resolve URL"
@@ -322,6 +341,11 @@ namespace Http
return true return true
end if end if
if raw
response.Json(json)
return true
end if
endpoint = json["endpoint"] endpoint = json["endpoint"]
pageType = ValidString(ObjectUtils.Dig(endpoint, ["commandMetadata", "webCommandMetadata", "webPageType"])) pageType = ValidString(ObjectUtils.Dig(endpoint, ["commandMetadata", "webCommandMetadata", "webPageType"]))
if pageType = "WEB_PAGE_TYPE_UNKNOWN" or pageType = "" if pageType = "WEB_PAGE_TYPE_UNKNOWN" or pageType = ""
@@ -385,6 +409,8 @@ namespace Http
return m.GetPlaylist(context) return m.GetPlaylist(context)
else if route.StartsWith("/playlet-invidious-backend/api/v1/channels/") else if route.StartsWith("/playlet-invidious-backend/api/v1/channels/")
return m.GetChannel(context) return m.GetChannel(context)
else if route.StartsWith("/playlet-invidious-backend/channel")
return m.RedirectChannel(context)
end if end if
return false return false
@@ -396,8 +422,17 @@ namespace Http
route = request.route route = request.route
videoId = route.Mid("/playlet-invidious-backend/api/v1/videos/".Len()) videoId = route.Mid("/playlet-invidious-backend/api/v1/videos/".Len())
if videoId.InStr("?") > 0
videoId = videoId.Left(videoId.InStr("?"))
end if
raw = request.query.raw <> invalid
metadata = InnertubeService.GetVideoMetadata(videoId) options = {
"raw": raw
"visitorData": m.innertube.visitorData
}
metadata = InnertubeService.GetVideoMetadata(videoId, options)
response.Json(metadata) response.Json(metadata)
if metadata.error <> invalid if metadata.error <> invalid
@@ -413,9 +448,16 @@ namespace Http
route = request.route route = request.route
playlistId = route.Mid("/playlet-invidious-backend/api/v1/playlists/".Len()) playlistId = route.Mid("/playlet-invidious-backend/api/v1/playlists/".Len())
if playlistId.InStr("?") > 0
playlistId = playlistId.Left(playlistId.InStr("?"))
end if
continuation = request.query.continuation continuation = request.query.continuation
raw = request.query.raw <> invalid
options = {
raw: raw
}
options = {}
if playlistId.StartsWith("RD") if playlistId.StartsWith("RD")
if not StringUtils.IsNullOrEmpty(continuation) if not StringUtils.IsNullOrEmpty(continuation)
options.videoId = continuation options.videoId = continuation
@@ -435,6 +477,11 @@ namespace Http
playlist = InnertubeService.GetPlaylist(playlistId, options) playlist = InnertubeService.GetPlaylist(playlistId, options)
end if end if
if raw
response.Json(playlist)
return true
end if
if playlist.error <> invalid if playlist.error <> invalid
response.Json(playlist) response.Json(playlist)
response.http_code = 500 response.http_code = 500
@@ -460,10 +507,17 @@ namespace Http
route = request.route route = request.route
channelAndTab = route.Mid("/playlet-invidious-backend/api/v1/channels/".Len()) channelAndTab = route.Mid("/playlet-invidious-backend/api/v1/channels/".Len())
if channelAndTab.InStr("?") > 0
channelAndTab = channelAndTab.Left(channelAndTab.InStr("?"))
end if
channelAndTab = channelAndTab.Split("/") channelAndTab = channelAndTab.Split("/")
options = {}
continuation = request.query.continuation continuation = request.query.continuation
raw = request.query.raw <> invalid
options = {
raw: raw
}
if not StringUtils.IsNullOrEmpty(continuation) if not StringUtils.IsNullOrEmpty(continuation)
options.continuation = continuation options.continuation = continuation
@@ -472,6 +526,11 @@ namespace Http
if channelAndTab.Count() = 1 if channelAndTab.Count() = 1
channelId = channelAndTab[0] channelId = channelAndTab[0]
channel = InnertubeService.GetChannel(channelId, options) channel = InnertubeService.GetChannel(channelId, options)
if raw
response.Json(channel)
return true
end if
if channel.error <> invalid if channel.error <> invalid
response.Json(channel) response.Json(channel)
response.http_code = 500 response.http_code = 500
@@ -494,13 +553,18 @@ namespace Http
end if end if
channel = InnertubeService.GetChannel(channelId, options) channel = InnertubeService.GetChannel(channelId, options)
if raw
response.Json(channel)
return true
end if
if channel.error <> invalid if channel.error <> invalid
response.Json(channel) response.Json(channel)
response.http_code = 500 response.http_code = 500
return true return true
end if end if
if _tab = "playlists" or _tab = "podcasts" or _tab = "releases" if _tab = "playlists" or _tab = "podcasts" or _tab = "releases" or _tab = "courses"
result = { result = {
"playlists": channel.items "playlists": channel.items
} }
@@ -529,6 +593,67 @@ namespace Http
return false return false
end function end function
@get("/playlet-invidious-backend/watch")
function RedirectWatch(context as object) as boolean
request = context.request
response = context.response
videoId = request.query.v
t = request.query.t
if StringUtils.IsNullOrEmpty(videoId)
response.Json({
"error": "Missing 'v' query parameter"
})
response.http_code = 400
return true
end if
url = `https://redirect.invidious.io/watch?v=${videoId}`
if not StringUtils.IsNullOrEmpty(t)
url = `${url}&t=${t}`
end if
response.Redirect(url)
return true
end function
@get("/playlet-invidious-backend/playlist")
function RedirectPlaylist(context as object) as boolean
request = context.request
response = context.response
playlistId = request.query.list
if StringUtils.IsNullOrEmpty(playlistId)
response.Json({
"error": "Missing 'list' query parameter"
})
response.http_code = 400
return true
end if
response.Redirect(`https://redirect.invidious.io/playlist?list=${playlistId}`)
return true
end function
function RedirectChannel(context as object) as boolean
request = context.request
response = context.response
route = request.route
channelId = route.Mid("/playlet-invidious-backend/channel/".Len())
if StringUtils.IsNullOrEmpty(channelId)
response.Json({
"error": "Missing 'channelId' path parameter"
})
response.http_code = 400
return true
end if
response.Redirect(`https://redirect.invidious.io/channel/${channelId}`)
return true
end function
end class end class
end namespace end namespace
@@ -56,7 +56,7 @@ function SetupRoutes(server as object)
server.UseRouter(new Http.DialRouter(server)) server.UseRouter(new Http.DialRouter(server))
server.UseRouter(new Http.CacheRouter()) server.UseRouter(new Http.CacheRouter())
server.UseRouter(new Http.RegistryRouter(server)) server.UseRouter(new Http.RegistryRouter(server))
server.UseRouter(new Http.PlayletInvidiousBackendRouter()) server.UseRouter(new Http.PlayletInvidiousBackendRouter(server))
etags = new Http.EtagUtils() etags = new Http.EtagUtils()
server.UseRouter(new Http.HttpStaticFilesRouter("/", "libpkg:/www", etags, { staticFiles: true, staticCompressed: true })) server.UseRouter(new Http.HttpStaticFilesRouter("/", "libpkg:/www", etags, { staticFiles: true, staticCompressed: true }))
@@ -2,6 +2,7 @@
<interface> <interface>
<field id="appController" type="node" /> <field id="appController" type="node" />
<field id="preferences" type="node" /> <field id="preferences" type="node" />
<field id="innertube" type="node" />
<field id="invidious" type="node" /> <field id="invidious" type="node" />
<field id="profilesService" type="node" /> <field id="profilesService" type="node" />
<field id="applicationInfo" type="node" /> <field id="applicationInfo" type="node" />
@@ -166,6 +166,15 @@ channel_releases:
paginationType: Continuation paginationType: Continuation
tryCount: 3 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
responseHandler: ChannelPlaylistsHandler
paginationType: Continuation
tryCount: 3
# This is implemented only by Playlet backend. # This is implemented only by Playlet backend.
# Created because auto-generated channels don't have tabs except for "featured" # Created because auto-generated channels don't have tabs except for "featured"
channel_featured: channel_featured:
+2 -2
View File
@@ -2,8 +2,8 @@ title=PlayletLib
# Do not update version manually, it is auto updated from package.json # Do not update version manually, it is auto updated from package.json
major_version=0 major_version=0
minor_version=35 minor_version=36
build_version=00005 build_version=00001
ui_resolutions=hd ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p uri_resolution_autosub=$$RES$$,480p,720p,1080p
@@ -653,11 +653,12 @@ namespace HttpClient
return invalid return invalid
end if end if
m._json = ParseJson(text) m._json = ParseJson(text)
' TODO:P2 remove workaround after a fix has landed ' TODO:P2 remove workaround (fix landed, but remove after March 2025 as a precaution)
if m._json = invalid and m.IsSuccess() and not m._json_workaround_tried = true if m._json = invalid and m.IsSuccess() and not m._json_workaround_tried = true
' A bug was introduced in Roku OS 14.1 that causes ParseJson to return invalid parsing some unicode characters. ' A bug was introduced in Roku OS 14.1 that causes ParseJson to return invalid parsing some unicode characters.
' So we filter out \uXXXX characters and try to parse again. ' So we filter out \uXXXX characters and try to parse again.
' These characters are mostly emojis, and can't render anyway. ' These characters are mostly emojis, and can't render anyway.
' Update: a fix has landed in 14.1 (tested on 14.1.4.7709)
m._json_workaround_tried = true m._json_workaround_tried = true
filter = /\\u[0-9a-fA-F]{4}/ filter = /\\u[0-9a-fA-F]{4}/
text = filter.ReplaceAll(text, "") text = filter.ReplaceAll(text, "")
@@ -10,6 +10,7 @@ namespace RegistryUtils
const BOOKMARKS = "bookmarks" const BOOKMARKS = "bookmarks"
const MESSAGES = "messages" const MESSAGES = "messages"
const INNERTUBE_SESSION_DATA = "innertube_session_data"
const LAST_LOUNGE_DATA = "last_lounge_data" const LAST_LOUNGE_DATA = "last_lounge_data"
' "invidious_instances" is deprecated, but we keep for migration purposes ' "invidious_instances" is deprecated, but we keep for migration purposes
+529 -1103
View File
File diff suppressed because it is too large. Load diff
+9 -9
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-web", "name": "playlet-web",
"version": "0.35.5", "version": "0.36.1",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
@@ -9,23 +9,23 @@
"check": "svelte-check --tsconfig ./tsconfig.json" "check": "svelte-check --tsconfig ./tsconfig.json"
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/vite-plugin-svelte": "3.1.2", "@sveltejs/vite-plugin-svelte": "^5.0.3",
"@tailwindcss/typography": "^0.5.15", "@tailwindcss/typography": "^0.5.16",
"@tsconfig/svelte": "^5.0.4", "@tsconfig/svelte": "^5.0.4",
"@vitejs/plugin-legacy": "^5.4.3", "@vitejs/plugin-legacy": "^6.0.0",
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.20",
"daisyui": "^4.12.23", "daisyui": "^4.12.23",
"dotenv": "^16.4.7", "dotenv": "^16.4.7",
"ip": "^2.0.1", "ip": "^2.0.1",
"postcss": "^8.4.49", "postcss": "^8.5.1",
"svelte": "4.2.19", "svelte": "^5.19.0",
"svelte-check": "^4.1.1", "svelte-check": "^4.1.4",
"svelte-preprocess": "^6.0.3", "svelte-preprocess": "^6.0.3",
"tailwindcss": "^3.4.17", "tailwindcss": "^3.4.17",
"terser": "^5.37.0", "terser": "^5.37.0",
"tslib": "^2.8.1", "tslib": "^2.8.1",
"typescript": "^5.7.2", "typescript": "^5.7.3",
"vite": "^5.4.11", "vite": "^6.0.7",
"vite-plugin-compression": "^0.5.1", "vite-plugin-compression": "^0.5.1",
"vite-tsconfig-paths": "^5.1.4" "vite-tsconfig-paths": "^5.1.4"
} }
+4 -4
View File
@@ -1,4 +1,4 @@
import { tr } from "lib/Stores"; import { translate } from "lib/Stores";
import { PlayletApi } from "./PlayletApi"; import { PlayletApi } from "./PlayletApi";
import { get } from "svelte/store"; import { get } from "svelte/store";
@@ -31,14 +31,14 @@ export async function fetchLocale(locale: string) {
} }
translations[source[0].textContent] = translation[0].textContent; translations[source[0].textContent] = translation[0].textContent;
} }
tr.set((s) => translations[s] || s); translate.set((s) => translations[s] || s);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
} }
export function getPluralString(c: number, zeroString: string, oneString: string, pluralString: string) { export function getPluralString(c: number, zeroString: string, oneString: string, pluralString: string) {
const trFn = get(tr); const trFn = get(translate);
c = c || 0; c = c || 0;
if (c === 0) { if (c === 0) {
@@ -51,7 +51,7 @@ export function getPluralString(c: number, zeroString: string, oneString: string
} }
export function getFormattedPluralString(c: number, zeroString: string, oneString: string, pluralString: string) { export function getFormattedPluralString(c: number, zeroString: string, oneString: string, pluralString: string) {
const trFn = get(tr); const trFn = get(translate);
c = c || 0; c = c || 0;
if (c === 0) { if (c === 0) {
+7 -7
View File
@@ -6,7 +6,7 @@
import BookmarksIcon from "../assets/star-icon.svg.svelte"; import BookmarksIcon from "../assets/star-icon.svg.svelte";
import RemoteIcon from "../assets/remote-control.svg.svelte"; import RemoteIcon from "../assets/remote-control.svg.svelte";
import { appStateStore, tr } from "lib/Stores"; import { appStateStore, translate } from "lib/Stores";
import { ScreenNames, type AppState } from "lib/Types"; import { ScreenNames, type AppState } from "lib/Types";
import { onMount } from "svelte"; import { onMount } from "svelte";
@@ -57,7 +57,7 @@
<div class="h-6"> <div class="h-6">
<SearchIcon /> <SearchIcon />
</div> </div>
<span class="text-xs">{$tr("Search")}</span> <span class="text-xs">{$translate("Search")}</span>
</button> </button>
<button <button
on:click={() => setScreen("home")} on:click={() => setScreen("home")}
@@ -66,7 +66,7 @@
<div class="h-6"> <div class="h-6">
<HomeIcon /> <HomeIcon />
</div> </div>
<span class="text-xs">{$tr("Home")}</span> <span class="text-xs">{$translate("Home")}</span>
</button> </button>
<button <button
on:click={() => setScreen("bookmarks")} on:click={() => setScreen("bookmarks")}
@@ -75,7 +75,7 @@
<div class="h-6"> <div class="h-6">
<BookmarksIcon /> <BookmarksIcon />
</div> </div>
<span class="text-xs">{$tr("Bookmarks")}</span> <span class="text-xs">{$translate("Bookmarks")}</span>
</button> </button>
<button <button
on:click={() => setScreen("settings")} on:click={() => setScreen("settings")}
@@ -84,7 +84,7 @@
<div class="h-6"> <div class="h-6">
<SettingsIcon /> <SettingsIcon />
</div> </div>
<span class="text-xs">{$tr("Settings")}</span> <span class="text-xs">{$translate("Settings")}</span>
</button> </button>
<button <button
on:click={() => setScreen("remote")} on:click={() => setScreen("remote")}
@@ -93,7 +93,7 @@
<div class="h-6"> <div class="h-6">
<RemoteIcon /> <RemoteIcon />
</div> </div>
<span class="text-xs">{$tr("Remote")}</span> <span class="text-xs">{$translate("Remote")}</span>
</button> </button>
<button <button
on:click={() => setScreen("info")} on:click={() => setScreen("info")}
@@ -102,6 +102,6 @@
<div class="h-6"> <div class="h-6">
<InfoIcon /> <InfoIcon />
</div> </div>
<span class="text-xs">{$tr("Info")}</span> <span class="text-xs">{$translate("Info")}</span>
</button> </button>
</div> </div>
+5 -3
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { onDestroy, onMount } from "svelte"; import { onDestroy, onMount } from "svelte";
import { playletStateStore, tr } from "lib/Stores"; import { playletStateStore, translate } from "lib/Stores";
import { InvidiousApi } from "lib/Api/InvidiousApi"; import { InvidiousApi } from "lib/Api/InvidiousApi";
import { PlayletApi } from "./Api/PlayletApi"; import { PlayletApi } from "./Api/PlayletApi";
import VideoCastDialog from "./VideoFeed/VideoCastDialog.svelte"; import VideoCastDialog from "./VideoFeed/VideoCastDialog.svelte";
@@ -248,9 +248,11 @@
: 'hidden'} fixed w-full h-full bg-base-100/80 z-50 flex justify-center items-center" : 'hidden'} fixed w-full h-full bg-base-100/80 z-50 flex justify-center items-center"
> >
{#if isDragging} {#if isDragging}
<div class="text-2xl font-bold">{$tr("Drop a YouTube link here")}</div> <div class="text-2xl font-bold">
{$translate("Drop a YouTube link here")}
</div>
{:else if isLoading} {:else if isLoading}
<span class="loading loading-spinner loading-md" /> <span class="loading loading-spinner loading-md"></span>
{/if} {/if}
</div> </div>
+7 -7
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { playletStateStore, tr } from "lib/Stores"; import { playletStateStore, translate } from "lib/Stores";
import { PlayletApi } from "./Api/PlayletApi"; import { PlayletApi } from "./Api/PlayletApi";
import { get } from "svelte/store"; import { get } from "svelte/store";
@@ -69,7 +69,7 @@
<dialog bind:this={modal} class="modal" on:close={onClose}> <dialog bind:this={modal} class="modal" on:close={onClose}>
<form method="dialog" class="modal-box bg-base-100"> <form method="dialog" class="modal-box bg-base-100">
<div class="flex flex-col items-center"> <div class="flex flex-col items-center">
<div class="text-xl font-medium m-4">{$tr("Profiles")}</div> <div class="text-xl font-medium m-4">{$translate("Profiles")}</div>
{#each profiles as profile} {#each profiles as profile}
<div class="collapse collapse-arrow bg-base-300 m-1"> <div class="collapse collapse-arrow bg-base-300 m-1">
@@ -112,12 +112,12 @@
{#if profile.id !== currentProfile?.id} {#if profile.id !== currentProfile?.id}
<button <button
on:click={() => activate(profile.id)} on:click={() => activate(profile.id)}
class="btn btn-primary m-1">{$tr("Activate")}</button class="btn btn-primary m-1">{$translate("Activate")}</button
> >
{/if} {/if}
<button <button
on:click={() => logout(profile.id)} on:click={() => logout(profile.id)}
class="btn btn-primary m-1">{$tr("Logout")}</button class="btn btn-primary m-1">{$translate("Logout")}</button
> >
</div> </div>
</div> </div>
@@ -125,15 +125,15 @@
<div class="flex items-center"> <div class="flex items-center">
<button class="btn btn-primary" on:click={login}> <button class="btn btn-primary" on:click={login}>
<div class=""> <div class="">
<div class="text-m">{$tr("Login to Invidious")}</div> <div class="text-m">{$translate("Login to Invidious")}</div>
<div class="text-xs font-light">{currentInstance}</div> <div class="text-xs font-light">{currentInstance}</div>
</div> </div>
</button> </button>
<button class="btn m-6">{$tr("Close")}</button> <button class="btn m-6">{$translate("Close")}</button>
</div> </div>
</div> </div>
</form> </form>
<form method="dialog" class="modal-backdrop"> <form method="dialog" class="modal-backdrop">
<button>{$tr("Close")}</button> <button>{$translate("Close")}</button>
</form> </form>
</dialog> </dialog>
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import VideoListRow from "lib/VideoFeed/VideoListRow.svelte"; import VideoListRow from "lib/VideoFeed/VideoListRow.svelte";
import { bookmarksStore, tr } from "lib/Stores"; import { bookmarksStore, translate } from "lib/Stores";
export let visibility: boolean; export let visibility: boolean;
</script> </script>
@@ -10,13 +10,15 @@
<div <div
class="flex flex-col items-center justify-start h-screen w-2/3 mx-auto" class="flex flex-col items-center justify-start h-screen w-2/3 mx-auto"
> >
<div class="text-2xl font-bold text-gray-500">{$tr("No Bookmarks")}</div> <div class="text-2xl font-bold text-gray-500">
{$translate("No Bookmarks")}
</div>
<div class="text-gray-500 text-center"> <div class="text-gray-500 text-center">
{$tr("You currently have no bookmarks.")}<br /> {$translate("You currently have no bookmarks.")}<br />
{$tr( {$translate(
"To add bookmarks, select a video, playlist or channel, and add a bookmark." "To add bookmarks, select a video, playlist or channel, and add a bookmark."
)}<br /> )}<br />
{$tr("Please note that Bookmarks is an experimental feature.")} {$translate("Please note that Bookmarks is an experimental feature.")}
</div> </div>
</div> </div>
{:else} {:else}
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { getHost } from "lib/Api/Host"; import { getHost } from "lib/Api/Host";
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore, tr } from "lib/Stores"; import { playletStateStore, translate } from "lib/Stores";
export let visibility: boolean; export let visibility: boolean;
@@ -164,9 +164,9 @@ ${JSON.stringify(profilesInfo, null, 2)}
<div class={visibility ? "" : "hidden"}> <div class={visibility ? "" : "hidden"}>
<div class="text-base text-center m-8"> <div class="text-base text-center m-8">
{$tr("Thank you for using Playlet.")} {$translate("Thank you for using Playlet.")}
<br /> <br />
{@html $tr(feedbackMessageRaw) {@html $translate(feedbackMessageRaw)
.replace( .replace(
"%IssueStart%", "%IssueStart%",
`<a class="link" href="${githubUrlIssue}" target="_blank" rel="noopener noreferrer">` `<a class="link" href="${githubUrlIssue}" target="_blank" rel="noopener noreferrer">`
@@ -194,11 +194,9 @@ ${JSON.stringify(profilesInfo, null, 2)}
</tr> </tr>
{/each} {/each}
<thead> <tr>
<tr> <th>App internal state</th>
<th>App internal state</th> </tr>
</tr>
</thead>
{#each internalStateLinks as item} {#each internalStateLinks as item}
<tr> <tr>
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { tr } from "lib/Stores"; import { translate } from "lib/Stores";
let modal; let modal;
@@ -11,7 +11,7 @@
modal.close(); modal.close();
} }
export let label = $tr("Filters"); export let label = $translate("Filters");
export const filters = { export const filters = {
date: "", date: "",
@@ -38,7 +38,7 @@
count += filters.features.length; count += filters.features.length;
count += filters.sort ? 1 : 0; count += filters.sort ? 1 : 0;
label = $tr("Filters") + `${count > 0 ? ` (${count})` : ""}`; label = $translate("Filters") + `${count > 0 ? ` (${count})` : ""}`;
} }
const options = { const options = {
@@ -181,37 +181,37 @@
<h2 class="text-xl font-bold mb-4">{label}</h2> <h2 class="text-xl font-bold mb-4">{label}</h2>
<div class="mb-4"> <div class="mb-4">
<h3 class="text-lg font-bold mb-2">{$tr("Upload date")}</h3> <h3 class="text-lg font-bold mb-2">{$translate("Upload date")}</h3>
<select class="input input-bordered w-full" bind:value={filters.date}> <select class="input input-bordered w-full" bind:value={filters.date}>
{#each options.date as { title, value }} {#each options.date as { title, value }}
<option {value}>{$tr(title)}</option> <option {value}>{$translate(title)}</option>
{/each} {/each}
</select> </select>
</div> </div>
<div class="mb-4"> <div class="mb-4">
<h3 class="text-lg font-bold mb-2">{$tr("Type")}</h3> <h3 class="text-lg font-bold mb-2">{$translate("Type")}</h3>
<select class="input input-bordered w-full" bind:value={filters.type}> <select class="input input-bordered w-full" bind:value={filters.type}>
{#each options.type as { title, value }} {#each options.type as { title, value }}
<option {value}>{$tr(title)}</option> <option {value}>{$translate(title)}</option>
{/each} {/each}
</select> </select>
</div> </div>
<div class="mb-4"> <div class="mb-4">
<h3 class="text-lg font-bold mb-2">{$tr("Duration")}</h3> <h3 class="text-lg font-bold mb-2">{$translate("Duration")}</h3>
<select <select
class="input input-bordered w-full" class="input input-bordered w-full"
bind:value={filters.duration} bind:value={filters.duration}
> >
{#each options.duration as { title, value }} {#each options.duration as { title, value }}
<option {value}>{$tr(title)}</option> <option {value}>{$translate(title)}</option>
{/each} {/each}
</select> </select>
</div> </div>
<div class="mb-4"> <div class="mb-4">
<h3 class="text-lg font-bold mb-2">{$tr("Features")}</h3> <h3 class="text-lg font-bold mb-2">{$translate("Features")}</h3>
{#each options.features as { title, value }} {#each options.features as { title, value }}
<label class="flex items-center"> <label class="flex items-center">
<input <input
@@ -220,26 +220,26 @@
class="form-checkbox" class="form-checkbox"
bind:checked={features_kv[value]} bind:checked={features_kv[value]}
/> />
<span class="ml-2">{$tr(title)}</span> <span class="ml-2">{$translate(title)}</span>
</label> </label>
{/each} {/each}
</div> </div>
<div class="mb-4"> <div class="mb-4">
<h3 class="text-lg font-bold mb-2">{$tr("Sort by")}</h3> <h3 class="text-lg font-bold mb-2">{$translate("Sort by")}</h3>
<select class="input input-bordered w-full" bind:value={filters.sort}> <select class="input input-bordered w-full" bind:value={filters.sort}>
{#each options.sort as { title, value }} {#each options.sort as { title, value }}
<option {value}>{$tr(title)}</option> <option {value}>{$translate(title)}</option>
{/each} {/each}
</select> </select>
</div> </div>
<div class="flex justify-end"> <div class="flex justify-end">
<button class="btn btn-outline">{$tr("Close")}</button> <button class="btn btn-outline">{$translate("Close")}</button>
</div> </div>
</div> </div>
</form> </form>
<form method="dialog" class="modal-backdrop"> <form method="dialog" class="modal-backdrop">
<button>{$tr("Close")}</button> <button>{$translate("Close")}</button>
</form> </form>
</dialog> </dialog>
@@ -5,7 +5,7 @@
import { InvidiousApi } from "lib/Api/InvidiousApi"; import { InvidiousApi } from "lib/Api/InvidiousApi";
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore, searchHistoryStore, tr } from "lib/Stores"; import { playletStateStore, searchHistoryStore, translate } from "lib/Stores";
import VideoCell from "lib/VideoFeed/VideoCell.svelte"; import VideoCell from "lib/VideoFeed/VideoCell.svelte";
import PlaylistCell from "lib/VideoFeed/PlaylistCell.svelte"; import PlaylistCell from "lib/VideoFeed/PlaylistCell.svelte";
import ChannelCell from "lib/VideoFeed/ChannelCell.svelte"; import ChannelCell from "lib/VideoFeed/ChannelCell.svelte";
@@ -133,7 +133,7 @@
<input <input
type="search" type="search"
dir="auto" dir="auto"
placeholder="{$tr('Search')}..." placeholder="{$translate('Search')}..."
class="join-item input w-full border border-neutral rounded-full" class="join-item input w-full border border-neutral rounded-full"
bind:this={searchBox} bind:this={searchBox}
bind:value={searchBoxText} bind:value={searchBoxText}
@@ -213,14 +213,14 @@
await searchVideos(searchContinuation); await searchVideos(searchContinuation);
}} }}
> >
{$tr("Load more")} {$translate("Load more")}
</button> </button>
</div> </div>
{/if} {/if}
{#if isLoading} {#if isLoading}
<div class="w-full h-1/2 z-50 flex justify-center items-center"> <div class="w-full h-1/2 z-50 flex justify-center items-center">
<span class="loading loading-spinner loading-md" /> <span class="loading loading-spinner loading-md"></span>
</div> </div>
{/if} {/if}
</div> </div>
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { tr, userPreferencesStore } from "lib/Stores"; import { translate, userPreferencesStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"]; const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -23,7 +23,7 @@
<div class="form-control m-5"> <div class="form-control m-5">
<label class="label p-0 cursor-pointer"> <label class="label p-0 cursor-pointer">
<div class="label-text {textSizes[level]}">{$tr(displayText)}</div> <div class="label-text {textSizes[level]}">{$translate(displayText)}</div>
<input <input
type="checkbox" type="checkbox"
name={key} name={key}
@@ -32,5 +32,5 @@
class="checkbox" class="checkbox"
/> />
</label> </label>
<div class="text-xs text-gray-500">{@html $tr(description)}</div> <div class="text-xs text-gray-500">{@html $translate(description)}</div>
</div> </div>
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { InvidiousApi } from "lib/Api/InvidiousApi"; import { InvidiousApi } from "lib/Api/InvidiousApi";
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { tr } from "lib/Stores"; import { translate } from "lib/Stores";
import { get } from "svelte/store"; import { get } from "svelte/store";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"]; const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -16,12 +16,14 @@
await PlayletApi.clearCache(); await PlayletApi.clearCache();
InvidiousApi.clearCache(); InvidiousApi.clearCache();
alert(get(tr)("Cache cleared.")); alert(get(translate)("Cache cleared."));
} }
</script> </script>
<div class="m-5"> <div class="m-5">
<div class={textSizes[level]}>{$tr(displayText)}</div> <div class={textSizes[level]}>{$translate(displayText)}</div>
<div class="text-xs text-gray-500">{@html $tr(description)}</div> <div class="text-xs text-gray-500">{@html $translate(description)}</div>
<button class="btn m-1" on:click={clearCache}>{$tr("Clear cache")}</button> <button class="btn m-1" on:click={clearCache}
>{$translate("Clear cache")}</button
>
</div> </div>
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { searchHistoryStore, tr } from "lib/Stores"; import { searchHistoryStore, translate } from "lib/Stores";
import { get } from "svelte/store"; import { get } from "svelte/store";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"]; const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -15,14 +15,14 @@
await PlayletApi.clearSearchHistory(); await PlayletApi.clearSearchHistory();
searchHistoryStore.set([]); searchHistoryStore.set([]);
alert(get(tr)("Search history cleared.")); alert(get(translate)("Search history cleared."));
} }
</script> </script>
<div class="m-5"> <div class="m-5">
<div class={textSizes[level]}>{$tr(displayText)}</div> <div class={textSizes[level]}>{$translate(displayText)}</div>
<div class="text-xs text-gray-500">{@html $tr(description)}</div> <div class="text-xs text-gray-500">{@html $translate(description)}</div>
<button class="btn m-1" on:click={clearSeachHistory} <button class="btn m-1" on:click={clearSeachHistory}
>{$tr("Clear search history")}</button >{$translate("Clear search history")}</button
> >
</div> </div>
@@ -2,7 +2,7 @@
import { import {
homeLayoutFileStore, homeLayoutFileStore,
homeLayoutStore, homeLayoutStore,
tr, translate,
userPreferencesStore, userPreferencesStore,
} from "lib/Stores"; } from "lib/Stores";
import ArrowUpIcon from "assets/remote-control/arrow-up.svg.svelte"; import ArrowUpIcon from "assets/remote-control/arrow-up.svg.svelte";
@@ -89,10 +89,10 @@
</script> </script>
<div class="m-5"> <div class="m-5">
<div class={textSizes[level]}>{$tr(displayText)}</div> <div class={textSizes[level]}>{$translate(displayText)}</div>
<div class="text-xs text-gray-500">{@html $tr(description)}</div> <div class="text-xs text-gray-500">{@html $translate(description)}</div>
<button class="btn m-1" on:click={openHomeScreenEditor} <button class="btn m-1" on:click={openHomeScreenEditor}
>{$tr("Edit home screen")}</button >{$translate("Edit home screen")}</button
> >
</div> </div>
@@ -100,51 +100,57 @@
<div class="modal-box bg-base-100"> <div class="modal-box bg-base-100">
{#if value && homeLayout} {#if value && homeLayout}
<table class="w-full"> <table class="w-full">
{#each value as item, i (i)} <tbody>
<tr> {#each value as item, i (i)}
<td> <tr>
<div class="tooltip" data-tip="Move up"> <td>
<button <div class="tooltip" data-tip="Move up">
class="btn btn-outline btn-sm" <button
on:click={() => moveUp(i)} class="btn btn-outline btn-sm"
disabled={i === 0} on:click={() => moveUp(i)}
> disabled={i === 0}
<ArrowUpIcon /> >
</button> <ArrowUpIcon />
</div> </button>
</td> </div>
<td> </td>
<label class="label p-0 cursor-pointer"> <td>
<div class="label-text">{$tr(homeLayout[item.id].title)}</div> <label class="label p-0 cursor-pointer">
<input <div class="label-text">
type="checkbox" {$translate(homeLayout[item.id].title)}
name={item.id} </div>
bind:checked={item.enabled} <input
class="toggle toggle-primary" type="checkbox"
/> name={item.id}
</label> bind:checked={item.enabled}
</td> class="toggle toggle-primary"
<td class="text-right"> />
<div class="tooltip" data-tip="Move down"> </label>
<button </td>
class="btn btn-outline btn-sm m-2" <td class="text-right">
on:click={() => moveDown(i)} <div class="tooltip" data-tip="Move down">
disabled={i === value.length - 1} <button
> class="btn btn-outline btn-sm m-2"
<ArrowDownIcon /> on:click={() => moveDown(i)}
</button> disabled={i === value.length - 1}
</div> >
</td> <ArrowDownIcon />
</tr> </button>
{/each} </div>
</td>
</tr>
{/each}
</tbody>
</table> </table>
<form method="dialog" class="flex justify-center space-x-2"> <form method="dialog" class="flex justify-center space-x-2">
<button class="btn btn-primary" on:click={save}>{$tr("Save")}</button> <button class="btn btn-primary" on:click={save}
<button class="btn btn-primary">{$tr("Close")}</button> >{$translate("Save")}</button
>
<button class="btn btn-primary">{$translate("Close")}</button>
</form> </form>
{/if} {/if}
</div> </div>
<form method="dialog" class="modal-backdrop"> <form method="dialog" class="modal-backdrop">
<button>{$tr("Close")}</button> <button>{$translate("Close")}</button>
</form> </form>
</dialog> </dialog>
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { tr, userPreferencesStore } from "lib/Stores"; import { translate, userPreferencesStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"]; const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
const qualityLabels = { const qualityLabels = {
@@ -37,7 +37,7 @@
}, {}); }, {});
displayValue = originalValue displayValue = originalValue
.split(",") .split(",")
.map((item) => $tr(qualityLabels[item] || item)) .map((item) => $translate(qualityLabels[item] || item))
.join(", "); .join(", ");
} }
} }
@@ -117,38 +117,42 @@
</script> </script>
<div class="m-5"> <div class="m-5">
<div class={textSizes[level]}>{$tr(displayText)}</div> <div class={textSizes[level]}>{$translate(displayText)}</div>
<div class="text-xs text-gray-500">{@html $tr(description)}</div> <div class="text-xs text-gray-500">{@html $translate(description)}</div>
<button class="btn m-1" on:click={openQualitySelector}>{displayValue}</button> <button class="btn m-1" on:click={openQualitySelector}>{displayValue}</button>
</div> </div>
<dialog bind:this={modal} class="modal" on:close={onClose}> <dialog bind:this={modal} class="modal" on:close={onClose}>
<div class="modal-box bg-base-100"> <div class="modal-box bg-base-100">
<table class="w-full"> <table class="w-full">
{#each Object.keys(qualityLabels) as quality} <tbody>
<tr> {#each Object.keys(qualityLabels) as quality}
<td> <tr>
<label class="label p-0 cursor-pointer"> <td>
<div class="label-text text-lg"> <label class="label p-0 cursor-pointer">
{$tr(qualityLabels[quality])} <div class="label-text text-lg">
</div> {$translate(qualityLabels[quality])}
<input </div>
type="checkbox" <input
checked={valueCheckedStates[quality]} type="checkbox"
on:change={(e) => onChange(e, quality)} checked={valueCheckedStates[quality]}
class="toggle toggle-primary" on:change={(e) => onChange(e, quality)}
/> class="toggle toggle-primary"
</label> />
</td> </label>
</tr> </td>
{/each} </tr>
{/each}
</tbody>
</table> </table>
<form method="dialog" class="flex justify-center space-x-2"> <form method="dialog" class="flex justify-center space-x-2">
<button class="btn btn-primary" on:click={save}>{$tr("Save")}</button> <button class="btn btn-primary" on:click={save}
<button class="btn btn-primary">{$tr("Close")}</button> >{$translate("Save")}</button
>
<button class="btn btn-primary">{$translate("Close")}</button>
</form> </form>
</div> </div>
<form method="dialog" class="modal-backdrop"> <form method="dialog" class="modal-backdrop">
<button>{$tr("Close")}</button> <button>{$translate("Close")}</button>
</form> </form>
</dialog> </dialog>
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { tr, userPreferencesStore } from "lib/Stores"; import { translate, userPreferencesStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"]; const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
export let displayText: string = ""; export let displayText: string = "";
export let key: string = ""; export let key: string = "";
@@ -21,7 +21,7 @@
<div class="form-control m-5"> <div class="form-control m-5">
<label class="label p-0 cursor-pointer"> <label class="label p-0 cursor-pointer">
<div class="label-text {textSizes[level]}">{$tr(displayText)}</div> <div class="label-text {textSizes[level]}">{$translate(displayText)}</div>
<div class="join mt-2 mb-2"> <div class="join mt-2 mb-2">
<button <button
class="join-item btn btn-sm btn-primary" class="join-item btn btn-sm btn-primary"
@@ -52,5 +52,5 @@
</button> </button>
</div> </div>
</label> </label>
<div class="text-xs text-gray-500">{@html $tr(description)}</div> <div class="text-xs text-gray-500">{@html $translate(description)}</div>
</div> </div>
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { onMount } from "svelte"; import { onMount } from "svelte";
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore, tr } from "lib/Stores"; import { playletStateStore, translate } from "lib/Stores";
import { ExternalControlProtocol } from "lib/Api/ExternalControlProtocol"; import { ExternalControlProtocol } from "lib/Api/ExternalControlProtocol";
import { get } from "svelte/store"; import { get } from "svelte/store";
@@ -81,7 +81,7 @@
version = "latest"; version = "latest";
} }
const trFn = get(tr); const trFn = get(translate);
if ( if (
confirm( confirm(
@@ -100,9 +100,9 @@
</script> </script>
<div class="m-5"> <div class="m-5">
<div class="text-lg">{$tr("Playlet Library version")}</div> <div class="text-lg">{$translate("Playlet Library version")}</div>
<div class="text-xs text-gray-500"> <div class="text-xs text-gray-500">
{$tr( {$translate(
"The version of Playlet Lib to use. These correspond to tagged releases on Github. Releases that do not have a playlet-lib.zip file are disabled." "The version of Playlet Lib to use. These correspond to tagged releases on Github. Releases that do not have a playlet-lib.zip file are disabled."
)} )}
</div> </div>
@@ -112,13 +112,14 @@
bind:value={selectedRelease} bind:value={selectedRelease}
class="select select-bordered join-item w-full mr-1" class="select select-bordered join-item w-full mr-1"
> >
<option selected value="">{$tr("Latest (default)")}</option> <option selected value="">{$translate("Latest (default)")}</option>
{#each releases as release} {#each releases as release}
<option disabled={!release.enabled} value={release.name} <option disabled={!release.enabled} value={release.name}
>{release.name}</option >{release.name}</option
> >
{/each} {/each}
</select> </select>
<button class="join-item btn" on:click={apply}>{$tr("Apply")}</button> <button class="join-item btn" on:click={apply}>{$translate("Apply")}</button
>
</div> </div>
</div> </div>
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { tr, userPreferencesStore } from "lib/Stores"; import { translate, userPreferencesStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"]; const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -24,13 +24,13 @@
</script> </script>
<div class="m-5"> <div class="m-5">
<div class={textSizes[level]}>{$tr(displayText)}</div> <div class={textSizes[level]}>{$translate(displayText)}</div>
<div class="text-xs text-gray-500">{@html $tr(description)}</div> <div class="text-xs text-gray-500">{@html $translate(description)}</div>
{#each options as option} {#each options as option}
<div class="form-control"> <div class="form-control">
<label class="label cursor-pointer"> <label class="label cursor-pointer">
<span class="label-text">{$tr(option.displayText)}</span> <span class="label-text">{$translate(option.displayText)}</span>
<input <input
type="radio" type="radio"
name={key} name={key}
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { tr, userPreferencesStore } from "lib/Stores"; import { translate, userPreferencesStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"]; const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
const invidiousPublicInstancesLink = `<a class="link" href="https://api.invidious.io" target="_blank" rel="noopener noreferrer">https://api.invidious.io</a>`; const invidiousPublicInstancesLink = `<a class="link" href="https://api.invidious.io" target="_blank" rel="noopener noreferrer">https://api.invidious.io</a>`;
@@ -27,10 +27,10 @@
</script> </script>
<div class="m-5"> <div class="m-5">
<div class={textSizes[level]}>{$tr(displayText)}</div> <div class={textSizes[level]}>{$translate(displayText)}</div>
<div class="text-xs text-gray-500"> <div class="text-xs text-gray-500">
<!-- TODO:P2 this should not be hardcoded here --> <!-- TODO:P2 this should not be hardcoded here -->
{@html $tr(description).replace( {@html $translate(description).replace(
"%INVIDIOUS_PUBLIC_INSTANCES%", "%INVIDIOUS_PUBLIC_INSTANCES%",
invidiousPublicInstancesLink invidiousPublicInstancesLink
)} )}
@@ -45,7 +45,8 @@
class="join-item input w-full mr-1" class="join-item input w-full mr-1"
/> />
{#if inputValue !== currentValue} {#if inputValue !== currentValue}
<button class="join-item btn" on:click={save}>{$tr("Save")}</button> <button class="join-item btn" on:click={save}>{$translate("Save")}</button
>
{/if} {/if}
</div> </div>
</div> </div>
@@ -8,7 +8,7 @@
import NumberControl from "./SettingControls/NumberControl.svelte"; import NumberControl from "./SettingControls/NumberControl.svelte";
import ClearCacheControl from "./SettingControls/ClearCacheControl.svelte"; import ClearCacheControl from "./SettingControls/ClearCacheControl.svelte";
import EditQualityControl from "./SettingControls/EditQualityControl.svelte"; import EditQualityControl from "./SettingControls/EditQualityControl.svelte";
import { tr } from "lib/Stores"; import { translate } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"]; const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -58,8 +58,8 @@
/> />
{:else} {:else}
<div class="m-5"> <div class="m-5">
<div class={textSizes[level]}>{$tr(displayText)}</div> <div class={textSizes[level]}>{$translate(displayText)}</div>
<div class="text-xs text-gray-500">{$tr(description)}</div> <div class="text-xs text-gray-500">{$translate(description)}</div>
</div> </div>
{/if} {/if}
@@ -10,7 +10,7 @@
{#if pref.visibility !== "tv"} {#if pref.visibility !== "tv"}
<SettingsNode {...pref} /> <SettingsNode {...pref} />
{#if i !== $preferencesModelStore.length - 1} {#if i !== $preferencesModelStore.length - 1}
<div class="divider" /> <div class="divider"></div>
{/if} {/if}
{/if} {/if}
{/each} {/each}
+1 -1
View File
@@ -23,4 +23,4 @@ export const bookmarksStore = writable([] as any);
export const searchHistoryStore = writable([] as any); export const searchHistoryStore = writable([] as any);
export const tr = writable((s: string) => s as any); export const translate = writable((s: string) => s as any);
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore, tr } from "lib/Stores"; import { playletStateStore, translate } from "lib/Stores";
import ChannelThumbnail from "./ChannelThumbnail.svelte"; import ChannelThumbnail from "./ChannelThumbnail.svelte";
export let author: string | undefined = undefined; export let author: string | undefined = undefined;
@@ -47,16 +47,18 @@
<div class="flex flex-col"> <div class="flex flex-col">
<div class="join join-vertical m-2"> <div class="join join-vertical m-2">
<button class="btn join-item hover:btn-accent" on:click={openOnTv}> <button class="btn join-item hover:btn-accent" on:click={openOnTv}>
{$tr("Open on %1").replace("%1", tvName)} {$translate("Open on %1").replace("%1", tvName)}
</button> </button>
<button class="btn join-item hover:btn-accent" on:click={openInvidious}> <button class="btn join-item hover:btn-accent" on:click={openInvidious}>
{$tr("Open in Invidious")} {$translate("Open in Invidious")}
</button> </button>
<button class="btn join-item hover:btn-accent">{$tr("Cancel")}</button> <button class="btn join-item hover:btn-accent"
>{$translate("Cancel")}</button
>
</div> </div>
</div> </div>
</form> </form>
<form method="dialog" class="modal-backdrop"> <form method="dialog" class="modal-backdrop">
<button>{$tr("Close")}</button> <button>{$translate("Close")}</button>
</form> </form>
</dialog> </dialog>
@@ -41,7 +41,12 @@
} }
</script> </script>
<button class="w-60 p-2" on:click={modal.show()}> <button
class="w-60 p-2"
on:click={() => {
modal.show();
}}
>
<div class="card card-compact bg-base-100 shadow-xl border border-neutral"> <div class="card card-compact bg-base-100 shadow-xl border border-neutral">
<ChannelThumbnail bind:author bind:authorThumbnails /> <ChannelThumbnail bind:author bind:authorThumbnails />
<div class="card-body"> <div class="card-body">
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore, tr } from "lib/Stores"; import { playletStateStore, translate } from "lib/Stores";
import PlaylistThumbnail from "./PlaylistThumbnail.svelte"; import PlaylistThumbnail from "./PlaylistThumbnail.svelte";
export let title: string | undefined = undefined; export let title: string | undefined = undefined;
@@ -102,22 +102,24 @@
<div class="flex flex-col"> <div class="flex flex-col">
<div class="join join-vertical m-2"> <div class="join join-vertical m-2">
<button class="btn join-item hover:btn-accent" on:click={playOnTv}> <button class="btn join-item hover:btn-accent" on:click={playOnTv}>
{$tr("Play on %1").replace("%1", tvName)} {$translate("Play on %1").replace("%1", tvName)}
</button> </button>
<button class="btn join-item hover:btn-accent" on:click={queueOnTv}> <button class="btn join-item hover:btn-accent" on:click={queueOnTv}>
{$tr("Queue on %1").replace("%1", tvName)} {$translate("Queue on %1").replace("%1", tvName)}
</button> </button>
<button class="btn join-item hover:btn-accent" on:click={openOnTv}> <button class="btn join-item hover:btn-accent" on:click={openOnTv}>
{$tr("Open on %1").replace("%1", tvName)} {$translate("Open on %1").replace("%1", tvName)}
</button> </button>
<button class="btn join-item hover:btn-accent" on:click={openInvidious}> <button class="btn join-item hover:btn-accent" on:click={openInvidious}>
{$tr("Open in Invidious")} {$translate("Open in Invidious")}
</button> </button>
<button class="btn join-item hover:btn-accent">{$tr("Cancel")}</button> <button class="btn join-item hover:btn-accent"
>{$translate("Cancel")}</button
>
</div> </div>
</div> </div>
</form> </form>
<form method="dialog" class="modal-backdrop"> <form method="dialog" class="modal-backdrop">
<button>{$tr("Close")}</button> <button>{$translate("Close")}</button>
</form> </form>
</dialog> </dialog>
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { playletStateStore, tr } from "lib/Stores"; import { playletStateStore, translate } from "lib/Stores";
import PlaylistCastDialog from "./PlaylistCastDialog.svelte"; import PlaylistCastDialog from "./PlaylistCastDialog.svelte";
import PlaylistThumbnail from "./PlaylistThumbnail.svelte"; import PlaylistThumbnail from "./PlaylistThumbnail.svelte";
import { get } from "svelte/store"; import { get } from "svelte/store";
@@ -33,7 +33,7 @@
return ""; return "";
} }
const trFn = get(tr); const trFn = get(translate);
const totalDays = Math.floor(span / 86400); const totalDays = Math.floor(span / 86400);
if (totalDays > 365) { if (totalDays > 365) {
@@ -79,7 +79,12 @@
} }
</script> </script>
<button class="w-80 p-2" on:click={modal.show()}> <button
class="w-80 p-2"
on:click={() => {
modal.show();
}}
>
<div class="card card-compact bg-base-100 shadow-xl border border-neutral"> <div class="card card-compact bg-base-100 shadow-xl border border-neutral">
<PlaylistThumbnail <PlaylistThumbnail
bind:title bind:title
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi"; import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore, tr } from "lib/Stores"; import { playletStateStore, translate } from "lib/Stores";
import VideoStartAt from "./VideoStartAt.svelte"; import VideoStartAt from "./VideoStartAt.svelte";
import VideoThumbnail from "./VideoThumbnail.svelte"; import VideoThumbnail from "./VideoThumbnail.svelte";
@@ -116,19 +116,21 @@
/> />
<div class="join join-vertical m-2"> <div class="join join-vertical m-2">
<button class="btn join-item hover:btn-accent" on:click={playOnTv}> <button class="btn join-item hover:btn-accent" on:click={playOnTv}>
{$tr("Play on %1").replace("%1", tvName)} {$translate("Play on %1").replace("%1", tvName)}
</button> </button>
<button class="btn join-item hover:btn-accent" on:click={queueOnTv}> <button class="btn join-item hover:btn-accent" on:click={queueOnTv}>
{$tr("Queue on %1").replace("%1", tvName)} {$translate("Queue on %1").replace("%1", tvName)}
</button> </button>
<button class="btn join-item hover:btn-accent" on:click={openInvidious}> <button class="btn join-item hover:btn-accent" on:click={openInvidious}>
{$tr("Open in Invidious")} {$translate("Open in Invidious")}
</button> </button>
<button class="btn join-item hover:btn-accent">{$tr("Cancel")}</button> <button class="btn join-item hover:btn-accent"
>{$translate("Cancel")}</button
>
</div> </div>
</div> </div>
</form> </form>
<form method="dialog" class="modal-backdrop"> <form method="dialog" class="modal-backdrop">
<button>{$tr("Close")}</button> <button>{$translate("Close")}</button>
</form> </form>
</dialog> </dialog>
+20 -7
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { playletStateStore, tr } from "lib/Stores"; import { playletStateStore, translate } from "lib/Stores";
import VideoCastDialog from "./VideoCastDialog.svelte"; import VideoCastDialog from "./VideoCastDialog.svelte";
import VideoThumbnail from "./VideoThumbnail.svelte"; import VideoThumbnail from "./VideoThumbnail.svelte";
import ChannelCastDialog from "./ChannelCastDialog.svelte"; import ChannelCastDialog from "./ChannelCastDialog.svelte";
@@ -74,7 +74,7 @@
return ""; return "";
} }
const trFn = get(tr); const trFn = get(translate);
const currentTime = Math.floor(Date.now() / 1000); const currentTime = Math.floor(Date.now() / 1000);
let timeLeft = premiereTimestamp - currentTime; let timeLeft = premiereTimestamp - currentTime;
@@ -126,7 +126,7 @@
if (isNaN(published)) { if (isNaN(published)) {
return ""; return "";
} }
const trFn = get(tr); const trFn = get(translate);
const currentTime = Math.floor(Date.now() / 1000); const currentTime = Math.floor(Date.now() / 1000);
const span = currentTime - published; const span = currentTime - published;
if (span < 1) { if (span < 1) {
@@ -181,7 +181,12 @@
} }
</script> </script>
<button class="w-80 p-2" on:click={videoModal.show()}> <button
class="w-80 p-2"
on:click={() => {
videoModal.show();
}}
>
<div class="card card-compact bg-base-100 shadow-xl border border-neutral"> <div class="card card-compact bg-base-100 shadow-xl border border-neutral">
<VideoThumbnail <VideoThumbnail
bind:videoId bind:videoId
@@ -197,15 +202,23 @@
/> />
<div class="card-body"> <div class="card-body">
<h3 class="card-title text-base line-clamp-2 min-h-12">{title || ""}</h3> <h3 class="card-title text-base line-clamp-2 min-h-12">{title || ""}</h3>
<button <span
class="font-semibold link" class="font-semibold link cursor-pointer"
role="button"
tabindex="0"
on:click={(e) => { on:click={(e) => {
e.stopPropagation(); e.stopPropagation();
channelModal.show(); channelModal.show();
}} }}
on:keydown={(e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
channelModal.show();
}
}}
> >
{author || ""} {author || ""}
</button> </span>
<div>{getViewCountDateText()}</div> <div>{getViewCountDateText()}</div>
</div> </div>
</div> </div>
@@ -1,6 +1,10 @@
<script lang="ts"> <script lang="ts">
import { InvidiousApi } from "lib/Api/InvidiousApi"; import { InvidiousApi } from "lib/Api/InvidiousApi";
import { invidiousVideoApiStore, playletStateStore, tr } from "lib/Stores"; import {
invidiousVideoApiStore,
playletStateStore,
translate,
} from "lib/Stores";
import VideoCell from "./VideoCell.svelte"; import VideoCell from "./VideoCell.svelte";
import PlaylistCell from "./PlaylistCell.svelte"; import PlaylistCell from "./PlaylistCell.svelte";
import ChannelCell from "./ChannelCell.svelte"; import ChannelCell from "./ChannelCell.svelte";
@@ -268,7 +272,7 @@
--> -->
{#if feedLoadState !== FeedLoadState.Loaded || videos.length !== 0} {#if feedLoadState !== FeedLoadState.Loaded || videos.length !== 0}
<div class="text-lg font-semibold ml-4"> <div class="text-lg font-semibold ml-4">
{$tr(feed.title)} {$translate(feed.title)}
</div> </div>
<div <div
class="carousel carousel-center rounded-box w-full space-x-4" class="carousel carousel-center rounded-box w-full space-x-4"
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { tr } from "lib/Stores"; import { translate } from "lib/Stores";
export let checked = false; export let checked = false;
export let lengthSeconds = undefined; export let lengthSeconds = undefined;
@@ -67,7 +67,7 @@
<div class="flex flex-row items-center"> <div class="flex flex-row items-center">
<label class="label justify-start cursor-pointer"> <label class="label justify-start cursor-pointer">
<input type="checkbox" bind:checked class="checkbox" /> <input type="checkbox" bind:checked class="checkbox" />
<span class="label-text m-2">{$tr("Start at")}</span> <span class="label-text m-2">{$translate("Start at")}</span>
</label> </label>
<input <input
bind:this={textInputElemet} bind:this={textInputElemet}
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { tr } from "lib/Stores"; import { translate } from "lib/Stores";
export let videoId: string | undefined = undefined; export let videoId: string | undefined = undefined;
export let title: string | undefined = undefined; export let title: string | undefined = undefined;
@@ -77,13 +77,13 @@
<div <div
class="absolute bottom-2 right-0 bg-black/70 text-white text-sm rounded-sm font-bold pt-1 pb-1 pr-2 pl-2" class="absolute bottom-2 right-0 bg-black/70 text-white text-sm rounded-sm font-bold pt-1 pb-1 pr-2 pl-2"
> >
{$tr("UPCOMING")} {$translate("UPCOMING")}
</div> </div>
{:else if isVideoLive()} {:else if isVideoLive()}
<div <div
class="absolute bottom-2 right-0 bg-red-500 text-white text-sm rounded-sm font-bold pt-1 pb-1 pr-2 pl-2" class="absolute bottom-2 right-0 bg-red-500 text-white text-sm rounded-sm font-bold pt-1 pb-1 pr-2 pl-2"
> >
{$tr("LIVE")} {$translate("LIVE")}
</div> </div>
{:else if lengthSeconds || lengthText} {:else if lengthSeconds || lengthText}
<div <div
+4 -3
View File
@@ -1,8 +1,9 @@
import './app.css' import './app.css'
import App from './App.svelte' import App from './App.svelte'
import { mount } from 'svelte';
const app = new App({ const app = mount(App, {
target: document.getElementById('app') target: document.getElementById('app')!
}) });
export default app export default app
+14 -8
View File
@@ -72,8 +72,8 @@ export class WebServerPlugin implements CompilerPlugin {
return; return;
} }
const routeInfo = this.getRouteInfo(functionStatement); const routeInfos = this.getRouteInfos(functionStatement);
if (!routeInfo) { if (!routeInfos || routeInfos.length === 0) {
return; return;
} }
@@ -83,9 +83,12 @@ export class WebServerPlugin implements CompilerPlugin {
} }
const classConstructor = this.getClassConstructor(classStmt) as MethodStatement; const classConstructor = this.getClassConstructor(classStmt) as MethodStatement;
const method = routeInfo.method === 'ALL' ? '*' : routeInfo.method; for (let index = 0; index < routeInfos.length; index++) {
const stmt = new RawCodeStatement(`m.routes.push({ method: "${method}", path: "${routeInfo.route}", router: m, func: "${func.functionStatement?.name.text}" })`) const routeInfo = routeInfos[index];
event.editor.arrayPush(classConstructor.func.body.statements, stmt); const method = routeInfo.method === 'ALL' ? '*' : routeInfo.method;
const stmt = new RawCodeStatement(`m.routes.push({ method: "${method}", path: "${routeInfo.route}", router: m, func: "${func.functionStatement?.name.text}" })`)
event.editor.arrayPush(classConstructor.func.body.statements, stmt);
}
}, },
}), { }), {
walkMode: WalkMode.visitExpressionsRecursive walkMode: WalkMode.visitExpressionsRecursive
@@ -102,12 +105,13 @@ export class WebServerPlugin implements CompilerPlugin {
return parentClass === httpRouterBaseClass; return parentClass === httpRouterBaseClass;
} }
getRouteInfo(functionStatement: FunctionStatement | undefined) { getRouteInfos(functionStatement: FunctionStatement | undefined) {
const annotations = functionStatement?.annotations const annotations = functionStatement?.annotations
if (!annotations || annotations.length === 0) { if (!annotations || annotations.length === 0) {
return undefined return undefined
} }
const routeInfos = [];
for (let index = 0; index < annotations.length; index++) { for (let index = 0; index < annotations.length; index++) {
const annotation = annotations[index]; const annotation = annotations[index];
if (annotationNames.includes(annotation.name)) { if (annotationNames.includes(annotation.name)) {
@@ -120,12 +124,14 @@ export class WebServerPlugin implements CompilerPlugin {
throw new Error(`Expected string argument for annotation ${annotation.name}`) throw new Error(`Expected string argument for annotation ${annotation.name}`)
} }
return { routeInfos.push({
method: annotation.name.toUpperCase(), method: annotation.name.toUpperCase(),
route: args[0] route: args[0]
} });
} }
} }
return routeInfos;
} }
getClass(func: FunctionExpression) { getClass(func: FunctionExpression) {
+5 -1
View File
@@ -13,7 +13,11 @@ const config = getEnvVars(['ROKU_DEV_TARGET']);
parser.add_argument('--app-id', { help: 'App Id' }); parser.add_argument('--app-id', { help: 'App Id' });
const args = parser.parse_args(); const args = parser.parse_args();
const appId = args.app_id let appId = args.app_id || "dev";
if (appId === "prod") {
appId = "693751";
}
const url = `http://${config.ROKU_DEV_TARGET}:8060/launch/${appId}?restart=true`; const url = `http://${config.ROKU_DEV_TARGET}:8060/launch/${appId}?restart=true`;
console.log("Restarting app", appId); console.log("Restarting app", appId);