Compare commits

..
19 Commits
Author SHA1 Message Date
Brahim Hadriche 8051458df7 Release v0.40.2 (#650) 2025-06-11 21:47:03 -04:00
Brahim Hadriche 4dae928a03 [skip ci] remove no-op call for no caching 2025-06-10 13:43:53 -04:00
Brahim Hadriche d054dd64a5 Playlet backend channel sort options (#649)
* Playlet backend channel sort options

* tweak
2025-06-10 09:29:55 -04:00
Brahim Hadriche 68aeec3d6f Parse authorId from authenticated feeds (#648) 2025-06-09 19:38:51 -04:00
Brahim Hadriche fc2ffd8c23 Revert "[skip ci][perf] do not listen on tasks that have no callbacks" (#647)
* Revert "[skip ci][perf] do not listen on tasks that have no callbacks"

This reverts commit 0bc5ab6117.

* changelog
2025-06-09 16:25:27 -04:00
Brahim Hadriche 4906b69f4a [skip ci] small refactor 2025-06-09 16:19:47 -04:00
Brahim Hadriche 2c513afafd Release v0.40.1 (#646) 2025-06-07 15:13:48 -04:00
Brahim Hadriche 8e156b27f9 update dependencies (#643) 2025-06-07 15:04:45 -04:00
Brahim Hadriche 58e2b48409 Fix a bug where searching in web app using iOS causes page to reload (#645)
* Fix a bug where searching in web app using iOS causes page to reload

* Add cors handler in prod
2025-06-07 10:55:07 -04:00
Brahim Hadriche 06326d084e Refactor potoken 2025-06-05 20:48:23 -04:00
Brahim Hadriche 0b5bed45cf changelog 2025-06-04 17:39:44 -04:00
Weblate (bot)andLacey Anaya 957ac66d70 Translated using Weblate (German) (#639)
Currently translated at 99.4% (344 of 346 strings)

Translation: Playlet/Playlet
Translate-URL: https://hosted.weblate.org/projects/playlet/playlet/de/

Co-authored-by: Lacey Anaya <yecakeh263@anawalls.com>
2025-06-04 17:39:29 -04:00
Brahim Hadriche 03679b781c [Spike] ytjs and botguard in web app (#638)
* [Spike] ytjs and boguard in web app

* storyboards and captions

* cache potoken

* captions fix

* Increase session data to 7 days

* changelog

* Fix missing timestamp issue
2025-06-04 17:34:56 -04:00
Brahim Hadriche 002307c45b Small fix on http request hanging 2025-06-03 22:06:37 -04:00
Brahim Hadriche fcfda78f2c update node version 2025-06-03 22:05:38 -04:00
Brahim Hadriche 384f41ba99 [skip ci] update user agent, small locale fix 2025-06-03 11:29:52 -04:00
Brahim Hadriche e070fc2df1 Refactor inital seeking 2025-06-02 13:34:53 -04:00
Brahim Hadriche 51d63d2019 Fix small bug with sponsorblock task 2025-06-02 13:32:58 -04:00
Brahim Hadriche 1eeaced04b Fix a bug where it says "(Failed to load)" when switching profiles 2025-06-01 17:53:27 -04:00
48 changed files with 1266 additions and 327 deletions

No files matched your search

+2 -2
View File
@@ -24,10 +24,10 @@ jobs:
git config --local user.email "githubaction@githubaction.com"
git config --local user.name "github-action linter"
- name: Use Node.js 20.x
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
cache: "npm"
- name: Install dependencies
+2 -2
View File
@@ -19,10 +19,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js 20.x
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
cache: "npm"
- name: Install dependencies
+2 -2
View File
@@ -17,10 +17,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js 20.x
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
cache: "npm"
- name: Install dependencies
+2 -2
View File
@@ -24,10 +24,10 @@ jobs:
git config --local user.name "github-action wiki updater"
working-directory: ./playlet.wiki
- name: Use Node.js 20.x
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
cache: "npm"
- name: Install dependencies
+2 -2
View File
@@ -12,10 +12,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js 20.x
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
cache: "npm"
- name: Install dependencies
+27
View File
@@ -5,6 +5,33 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.40.2] - 2025-06-12
### Added
- Channel sort options in Playlet backend (sort videos by Newest, Oldest, Popular)
### Fixed
- [Perf] reverted a perf fix that wasn't helping
- A bug where "Open channel" didn't show up in videos and playlists from logged user
## [0.40.1] - 2025-06-07
### Added
- A way to play longer videos using the web app (Play using ytjs)
- German translations
### Fixed
- A bug where it says "(Failed to load)" when switching profiles
- A bug where searching in web app using iOS causes page to reload
### Changed
- Session data duration: increased to 7 days, to avoid Innertube errors
## [0.40.0] - 2025-06-01
### Added
+28 -28
View File
@@ -1,22 +1,22 @@
{
"name": "playlet",
"version": "0.40.0",
"version": "0.40.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet",
"version": "0.40.0",
"version": "0.40.2",
"hasInstallScript": true,
"devDependencies": {
"@rokucommunity/bslint": "^0.8.31",
"@rokucommunity/bslint": "^0.8.32",
"@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4",
"@types/node": "^22.15.29",
"@types/node": "^22.15.30",
"@types/xml2js": "^0.4.14",
"argparse": "^2.0.1",
"brighterscript": "0.68.5",
"brighterscript-formatter": "^1.7.14",
"brighterscript-formatter": "^1.7.15",
"cheerio": "1.0.0-rc.11",
"convert-svg-to-png": "^0.6.4",
"crypto-js": "^4.2.0",
@@ -28,7 +28,7 @@
"json5": "^2.2.3",
"mailparser": "^3.7.3",
"protocol-buffers-schema": "^3.6.0",
"roku-deploy": "^3.12.5",
"roku-deploy": "^3.12.6",
"roku-test-automation": "^2.0.13",
"rooibos-roku": "5.15.7",
"rounded-rect-9patch": "^1.1.2",
@@ -40,10 +40,10 @@
"yaml": "^2.8.0"
},
"engines": {
"node": "20"
"node": "22"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "^4.41.1"
"@rollup/rollup-linux-x64-gnu": "^4.42.0"
}
},
"node_modules/@babel/code-frame": {
@@ -438,9 +438,9 @@
"dev": true
},
"node_modules/@rokucommunity/bslint": {
"version": "0.8.31",
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.31.tgz",
"integrity": "sha512-/VsycIH2OiEoNe7fCLqbQrDnX/JoKUV3Nufg0+auCM/DhCYzL4iM965VkSBebWzwUsnQXjILaKC4fRcMjpSBPQ==",
"version": "0.8.32",
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.32.tgz",
"integrity": "sha512-wwoRpXYGEC9VMrWdrvL0wm67+R21VtwVVWtD9k6+O5f3p64uCwymr28n1C7BNIEj/+wHzkDhSGvzxZRC2QjWWg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -597,9 +597,9 @@
}
},
"node_modules/@rollup/rollup-linux-x64-gnu": {
"version": "4.41.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.41.1.tgz",
"integrity": "sha512-cWBOvayNvA+SyeQMp79BHPK8ws6sHSsYnK5zDcsC3Hsxr1dgTABKjMnMslPq1DvZIp6uO7kIWhiGwaTdR4Og9A==",
"version": "4.42.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.42.0.tgz",
"integrity": "sha512-Gfm6cV6mj3hCUY8TqWa63DB8Mx3NADoFwiJrMpoZ1uESbK8FQV3LXkhfry+8bOniq9pqY1OdsjFWNsSbfjPugw==",
"cpu": [
"x64"
],
@@ -760,9 +760,9 @@
"license": "MIT"
},
"node_modules/@types/node": {
"version": "22.15.29",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.29.tgz",
"integrity": "sha512-LNdjOkUDlU1RZb8e1kOIUpN1qQUlzGkEtbVNo53vbrwDg5om6oduhm4SiUaPW5ASTXhAiP0jInWG8Qx9fVlOeQ==",
"version": "22.15.30",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.30.tgz",
"integrity": "sha512-6Q7lr06bEHdlfplU6YRbgG1SFBdlsfNC4/lX+SkhiTs0cpJkOElmWls8PxDFv4yY/xKb8Y6SO0OmSX4wgqTZbA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -1360,13 +1360,13 @@
}
},
"node_modules/brighterscript-formatter": {
"version": "1.7.14",
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.7.14.tgz",
"integrity": "sha512-rbK5lT2UZ/yD/JLryIsZC9Kng1vh4xFf9CO1tp8nMRaOTncscuD1mtMsmJXq0uQusxoRNBXB/tvSZQPKR9+SXQ==",
"version": "1.7.15",
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.7.15.tgz",
"integrity": "sha512-cEmAbHWWwxuk8M+z35Y8hzy8IPrKzrlhdgBOyF1EK/c1rvcaBC+Z+Rb+tRCjMFjryrrFFwFauUwPmM+E+QcK6g==",
"dev": true,
"license": "MIT",
"dependencies": {
"brighterscript": "^0.69.9",
"brighterscript": "^0.69.10",
"glob-all": "^3.3.0",
"jsonc-parser": "^3.0.0",
"source-map": "^0.7.3",
@@ -1402,9 +1402,9 @@
}
},
"node_modules/brighterscript-formatter/node_modules/brighterscript": {
"version": "0.69.9",
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.69.9.tgz",
"integrity": "sha512-IZ3q29gVZ/9Z8ZqBVDVmT5mqhf8/gyF2WxzxV2oHT3SoZyKPe9JpbOvjDqUwd51HoYI55eJWiY3TTG94CPAxXA==",
"version": "0.69.10",
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.69.10.tgz",
"integrity": "sha512-E8QCzN5bueG+SYJUdQ+1vw/frIV3WrpvoLgbNkAhYLOC6bSwoqmETwmgaiXpnY66Qe2zeAapXCbBcWVVIA7AQA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -1434,7 +1434,7 @@
"parse-ms": "^2.1.0",
"readline": "^1.3.0",
"require-relative": "^0.8.7",
"roku-deploy": "^3.12.5",
"roku-deploy": "^3.12.6",
"safe-json-stringify": "^1.2.0",
"serialize-error": "^7.0.1",
"source-map": "^0.7.4",
@@ -6220,9 +6220,9 @@
}
},
"node_modules/roku-deploy": {
"version": "3.12.5",
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.12.5.tgz",
"integrity": "sha512-ulPePpNtS29ePMc15Qk/XrEW8uFfhfKrFvKtV4jiifOuyESCqvBbGvt1EOuIMAaq2rA+5q/lWL7LkVKgyQz0QA==",
"version": "3.12.6",
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.12.6.tgz",
"integrity": "sha512-3qne2rwD0Yt4VMGUpiV75UHiarQYSgrQh5DtwpHjUVu0ozAzUw6psa46wA/jMbJgSNIDgKi4JsvdXkiAcE6P+g==",
"dev": true,
"license": "MIT",
"dependencies": {
+7 -7
View File
@@ -1,16 +1,16 @@
{
"name": "playlet",
"version": "0.40.0",
"version": "0.40.2",
"description": "Unofficial YouTube client for Roku",
"devDependencies": {
"@rokucommunity/bslint": "^0.8.31",
"@rokucommunity/bslint": "^0.8.32",
"@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4",
"@types/node": "^22.15.29",
"@types/node": "^22.15.30",
"@types/xml2js": "^0.4.14",
"argparse": "^2.0.1",
"brighterscript": "0.68.5",
"brighterscript-formatter": "^1.7.14",
"brighterscript-formatter": "^1.7.15",
"cheerio": "1.0.0-rc.11",
"convert-svg-to-png": "^0.6.4",
"crypto-js": "^4.2.0",
@@ -22,7 +22,7 @@
"json5": "^2.2.3",
"mailparser": "^3.7.3",
"protocol-buffers-schema": "^3.6.0",
"roku-deploy": "^3.12.5",
"roku-deploy": "^3.12.6",
"roku-test-automation": "^2.0.13",
"rooibos-roku": "5.15.7",
"rounded-rect-9patch": "^1.1.2",
@@ -34,7 +34,7 @@
"yaml": "^2.8.0"
},
"engines": {
"node": "20"
"node": "22"
},
"scripts": {
"dev:web": "cd playlet-web && npm run dev",
@@ -74,6 +74,6 @@
"shutdown": "node tools/shutdown.js"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "^4.41.1"
"@rollup/rollup-linux-x64-gnu": "^4.42.0"
}
}
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-app",
"version": "0.40.0",
"version": "0.40.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-app",
"version": "0.40.0"
"version": "0.40.2"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-app",
"version": "0.40.0",
"version": "0.40.2",
"description": "Unofficial YouTube client for Roku",
"scripts": {
"prebuild": "rm -rf ../build/playlet-app",
+1 -1
View File
@@ -3,7 +3,7 @@ title=Playlet
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=40
build_version=00000
build_version=00002
ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-lib",
"version": "0.40.0",
"version": "0.40.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-lib",
"version": "0.40.0"
"version": "0.40.2"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-lib",
"version": "0.40.0",
"version": "0.40.2",
"description": "Unofficial YouTube client for Roku",
"scripts": {
"prebuild": "rm -rf ../build/playlet-lib",
@@ -349,14 +349,17 @@ function GetSortingContextMenuOptionsForItem(video as object) as object
end if
feedSource = feedSources[0]
endpoint = feedSource.endpoint
if not m.sortOptions.DoesExist(endpoint)
return []
sortOptions = feedSource.state.sortOptions
if not IsArray(sortOptions)
endpoint = feedSource.endpoint
if not m.sortOptions.DoesExist(endpoint)
return []
end if
sortOptions = m.sortOptions[endpoint]
end if
title = Tr(Locale.Dialogs.SortFeedBy).replace("%1", `"${feedSource.title}"`)
sortOptions = m.sortOptions[endpoint]
return [ContextMenuUtils.CreateOption(title + "...", m.top, "ShowSortDialog", [title, sortOptions, feedContentNode])]
end function
+3 -11
View File
@@ -44,19 +44,11 @@ function Update()
end if
if hours > 12
hours = hours - 12
hours -= 12
end if
hoursStr = hours.ToStr()
minutesStr = minutes.ToStr()
if hours < 10
hoursStr = "0" + hoursStr
end if
if minutes < 10
minutesStr = "0" + minutesStr
end if
hoursStr = hours.ToStr("%02d")
minutesStr = minutes.ToStr("%02d")
m.top.text = hoursStr + ":" + minutesStr + " " + ampm
end function
+4 -21
View File
@@ -143,27 +143,10 @@ function FormatTime(dateTime as object) as string
dateTime.Mark()
dateTime.ToLocalTime()
hours = dateTime.GetHours().ToStr()
if hours.Len() = 1
hours = "0" + hours
end if
minutes = dateTime.GetMinutes().ToStr()
if minutes.Len() = 1
minutes = "0" + minutes
end if
seconds = dateTime.GetSeconds().ToStr()
if seconds.Len() = 1
seconds = "0" + seconds
end if
milliseconds = dateTime.GetMilliseconds().ToStr()
if milliseconds.Len() = 1
milliseconds = "00" + milliseconds
else if milliseconds.Len() = 2
milliseconds = "0" + milliseconds
end if
hours = dateTime.GetHours().ToStr("%02d")
minutes = dateTime.GetMinutes().ToStr("%02d")
seconds = dateTime.GetSeconds().ToStr("%02d")
milliseconds = dateTime.GetMilliseconds().ToStr("%03d")
return "[" + hours + ":" + minutes + ":" + seconds + "." + milliseconds + "]"
end function
@@ -77,8 +77,8 @@ function ShowTestDetails() as void
state = itemContent.state
displayStates = {
"passed": Locale.InvidiousTesting.Passed
"failed": Locale.InvidiousTesting.Failed
"passed": Tr(Locale.InvidiousTesting.Passed)
"failed": Tr(Locale.InvidiousTesting.Failed)
}
message = Tr(Locale.InvidiousTesting.Status) + ": " + Tr(ValidString(displayStates[state])) + `\n`
@@ -1,3 +1,5 @@
const VIDEO_PLAYER_USER_AGENT = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0"
const INNERTUBE_IOS_CLIENT_NAME = "5"
const INNERTUBE_IOS_CLIENT_VERSION = "20.20.5"
const INNERTUBE_IOS_DEVICE_MODEL = "iPhone16,2"
@@ -10,12 +12,12 @@ const INNERTUBE_WEB_CLIENT_NAME = "1"
const INNERTUBE_WEB_CLIENT_VERSION = "2.20250520.05.00"
const INNERTUBE_WEB_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0"
const INNERTUBE_TV_BROWSER_NAME = "LG Browser"
const INNERTUBE_TV_BROWSER_VERSION = "7.00.00"
const INNERTUBE_TV_BROWSER_NAME = "SamsungBrowser"
const INNERTUBE_TV_BROWSER_VERSION = "9.2"
const INNERTUBE_TV_CLIENT_NAME = "2"
const INNERTUBE_TV_CLIENT_VERSION = "7.20250519.12.01"
const INNERTUBE_TV_DEVICE_MAKE = "LGE"
const INNERTUBE_TV_DEVICE_MODEL = "24LF4820-BU"
const INNERTUBE_TV_OS_NAME = "webOS"
const INNERTUBE_TV_OS_VERSION = "2015"
const INNERTUBE_TV_USER_AGENT = "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/538.2 (KHTML, like Gecko) Large Screen Safari/538.2 LG Browser/7.00.00(LGE; 24LF4820-BU; 03.20.14; 1; DTV_W15L); webOS.TV-2015; LG NetCast.TV-2013 Compatible (LGE, 24LF4820-BU, wireless)"
const INNERTUBE_TV_DEVICE_MAKE = "Samsung"
const INNERTUBE_TV_DEVICE_MODEL = "SmartTV"
const INNERTUBE_TV_OS_NAME = "Tizen"
const INNERTUBE_TV_OS_VERSION = "4.0.0.2"
const INNERTUBE_TV_USER_AGENT = "Mozilla/5.0(SMART-TV; Linux; Tizen 4.0.0.2) AppleWebkit/605.1.15 (KHTML, like Gecko) SamsungBrowser/9.2 TV Safari/605.1.15"
@@ -1,5 +1,7 @@
<component name="Innertube" extends="Node">
<interface>
<field id="timestamp" type="int" />
<field id="visitorData" type="string" />
<field id="poToken" type="string" />
</interface>
</component>
@@ -9,7 +9,17 @@ function InnertubeInitTask(input as object) as object
return invalid
end if
innertubeNode.visitorData = sessionData.visitorData
if IsInt(sessionData.timestamp)
innertubeNode.timestamp = sessionData.timestamp
end if
if not StringUtils.IsNullOrEmpty(sessionData.visitorData)
innertubeNode.visitorData = sessionData.visitorData
end if
if not StringUtils.IsNullOrEmpty(sessionData.poToken)
innertubeNode.poToken = sessionData.poToken
end if
return invalid
end function
@@ -25,7 +25,6 @@ namespace InnertubeService
playerRequest.Cancellation(cancellation)
if raw
playerRequest.LogCurlCommand()
playerRequest.NoCache()
end if
playerRequest.Send()
@@ -36,7 +35,6 @@ namespace InnertubeService
nextRequest.Cancellation(cancellation)
if raw
nextRequest.LogCurlCommand()
nextRequest.NoCache()
end if
nextRequest.Send()
end if
@@ -81,8 +81,10 @@ namespace Innertube
"gridRenderer": ParseGridRenderer
"richGridRenderer": ParseRichGridRenderer
"richItemRenderer": ParseRichItemRenderer
"feedFilterChipBarRenderer": ParseFeedFilterChipBarRenderer
"continuationItemRenderer": ParseContinuationItemRenderer
"appendContinuationItemsAction": ParseAppendContinuationItemsAction
"reloadContinuationItemsCommand": ParseReloadContinuationItemsCommand
"gridContinuation": ParseGridContinuation
"tvSurfaceContentContinuation": ParseTvSurfaceContentContinuation
' Ignored nodes:
@@ -144,7 +146,26 @@ namespace Innertube
return nodeData["content"]
end function
function ParseSectionListRenderer(nodeData as object, _context as object) as object
function ParseSectionListRenderer(nodeData as object, context as object) as object
sortSubMenuItems = ObjectUtils.Dig(nodeData, ["subMenu", "channelSubMenuRenderer", "sortSetting", "sortFilterSubMenuRenderer", "subMenuItems"])
if IsArray(sortSubMenuItems)
sortOptions = []
for each item in sortSubMenuItems
params = ValidString(ObjectUtils.Dig(item, ["navigationEndpoint", "browseEndpoint", "params"]))
title = ParseText(item["title"])
isSelected = ValidBool(item["selected"])
if params <> "" and title <> ""
sortOptions.Push({
"title": title
"params": params
"isSelected": isSelected
})
end if
end for
if sortOptions.Count() > 0
context.currentFeed.sortOptions = sortOptions
end if
end if
return nodeData["contents"]
end function
@@ -1064,6 +1085,11 @@ namespace Innertube
"percentDurationWatched": percentDurationWatched
}
authorId = ParseTileRendererAuthorId(nodeData, context)
if authorId <> invalid
video["authorId"] = authorId
end if
PushFeedItem(video, context)
return invalid
end function
@@ -1107,6 +1133,11 @@ namespace Innertube
"videoThumbnails": videoThumbnails
}
authorId = ParseTileRendererAuthorId(nodeData, context)
if authorId <> invalid
video["authorId"] = authorId
end if
PushFeedItem(video, context)
return invalid
end function
@@ -1149,10 +1180,37 @@ namespace Innertube
"lines": renderedLines
}
authorId = ParseTileRendererAuthorId(nodeData, context)
if authorId <> invalid
playlist["authorId"] = authorId
end if
PushFeedItem(playlist, context)
return invalid
end function
function ParseTileRendererAuthorId(nodeData as object, context as object) as dynamic
' We're checking in the long press menu if there's a browseId that starts with "UC".
' This is usually the the id of the channel.
menuItems = ObjectUtils.Dig(nodeData, ["onLongPressCommand", "showMenuCommand", "menu", "menuRenderer", "items"])
if not IsArray(menuItems)
return invalid
end if
for each item in menuItems
if not IsAssociativeArray(item) or not item.DoesExist("menuNavigationItemRenderer")
continue for
end if
menuNavigationItemRenderer = item["menuNavigationItemRenderer"]
browseId = ObjectUtils.Dig(menuNavigationItemRenderer, ["navigationEndpoint", "browseEndpoint", "browseId"])
if not IsString(browseId) or not browseId.StartsWith("UC")
continue for
end if
return browseId
end for
return invalid
end function
function ParseGridRenderer(nodeData as object, context as object) as object
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
if IsString(continuation)
@@ -1161,7 +1219,11 @@ namespace Innertube
return nodeData["items"]
end function
function ParseRichGridRenderer(nodeData as object, _context as object) as object
function ParseRichGridRenderer(nodeData as object, context as object) as object
feedFilterChipBarRenderer = ObjectUtils.Dig(nodeData, ["header", "feedFilterChipBarRenderer"])
if feedFilterChipBarRenderer <> invalid
ParseFeedFilterChipBarRenderer(feedFilterChipBarRenderer, context)
end if
return nodeData["contents"]
end function
@@ -1169,6 +1231,47 @@ namespace Innertube
return nodeData["content"]
end function
function ParseFeedFilterChipBarRenderer(nodeData as object, context as object) as object
contents = ObjectUtils.Dig(nodeData, ["contents"])
if not IsArray(contents)
return invalid
end if
sortOptions = []
for each item in contents
if not IsAssociativeArray(item) or not item.DoesExist("chipCloudChipRenderer")
continue for
end if
chipCloudChipRenderer = item["chipCloudChipRenderer"]
if not IsAssociativeArray(chipCloudChipRenderer)
continue for
end if
continuationCommand = ObjectUtils.Dig(chipCloudChipRenderer, ["navigationEndpoint", "continuationCommand"])
if not IsAssociativeArray(continuationCommand) or ValidString(continuationCommand["request"]) <> "CONTINUATION_REQUEST_TYPE_BROWSE"
continue for
end if
title = ParseText(chipCloudChipRenderer["text"])
token = ValidString(continuationCommand["token"])
isSelected = ValidBool(chipCloudChipRenderer["isSelected"])
if title = "" or token = ""
continue for
end if
sortOptions.Push({
"title": title
"continuation": token
"isSelected": isSelected
})
end for
if sortOptions.Count() > 0
context.currentFeed.sortOptions = sortOptions
end if
return invalid
end function
function ParseContinuationItemRenderer(nodeData as object, context as object) as object
continuation = ObjectUtils.Dig(nodeData, ["continuationEndpoint", "continuationCommand", "token"])
if IsString(continuation)
@@ -1185,6 +1288,10 @@ namespace Innertube
return nodeData["continuationItems"]
end function
function ParseReloadContinuationItemsCommand(nodeData as object, _context as object) as object
return nodeData["continuationItems"]
end function
function ParseGridContinuation(nodeData as object, context as object) as object
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
if IsString(continuation)
@@ -7,7 +7,7 @@ namespace Innertube
function GetClientIdentity(cancellation = invalid as dynamic) as object
request = HttpClient.Get("https://www.youtube.com/tv")
request.Headers({
"User-Agent": "Mozilla/5.0 (ChromiumStylePlatform) Cobalt/Version"
"User-Agent": INNERTUBE_TV_USER_AGENT
"Referer": "https://www.youtube.com/tv"
"Accept-Language": "en-US"
})
@@ -141,12 +141,16 @@ namespace Innertube
items = []
continuation = invalid
sortOptions = invalid
feeds = ParseResponseDataForFeeds(responseData, { "currentAuthor": author, "currentAuthorId": authorId })
if feeds.Count() > 0
items = ValidArray(feeds[0].items)
if feeds[0].DoesExist("continuation")
continuation = feeds[0].continuation
end if
if feeds[0].DoesExist("sortOptions")
sortOptions = feeds[0].sortOptions
end if
end if
channel = {
@@ -161,9 +165,13 @@ namespace Innertube
"items": items
}
' continuation and sort options are specific to certain tabs of the channel
if continuation <> invalid
channel["continuation"] = continuation
end if
if sortOptions <> invalid
channel["sortOptions"] = sortOptions
end if
return channel
end function
@@ -9,7 +9,7 @@ import "pkg:/source/utils/TimeUtils.bs"
namespace Innertube
const SESSION_DATA_VERSION = 1
const INNERTUBE_VISITOR_DATA_LIFESPAN_SECONDS = 60 * 60 * 24
const INNERTUBE_VISITOR_DATA_LIFESPAN_SECONDS = 60 * 60 * 24 * 7 ' 7 days
function GetSessionData() as object
sessionData = ReadSessionDataFromRegistry()
@@ -18,11 +18,7 @@ namespace Innertube
end if
sessionData = RequestSessionData()
if sessionData = invalid
return invalid
end if
RegistryUtils.Write(RegistryUtils.INNERTUBE_SESSION_DATA, FormatJson(sessionData))
SaveSessionDataToRegistry(sessionData)
return sessionData
end function
@@ -61,12 +57,21 @@ namespace Innertube
end if
return {
"__version": SESSION_DATA_VERSION
"timestamp": TimeUtils.Now().AsSeconds()
"visitorData": visitorData
}
end function
function SaveSessionDataToRegistry(sessionData as object) as void
if sessionData = invalid
return
end if
sessionData.__version = SESSION_DATA_VERSION
RegistryUtils.Write(RegistryUtils.INNERTUBE_SESSION_DATA, FormatJson(sessionData))
end function
function ReadSessionDataFromRegistry() as object
sessionData = RegistryUtils.Read(RegistryUtils.INNERTUBE_SESSION_DATA)
if StringUtils.IsNullOrEmpty(sessionData)
@@ -487,6 +487,7 @@ namespace Invidious
return {
items: json.videos
continuation: json.continuation
sortOptions: json.sortOptions
}
end if
return invalid
@@ -510,6 +511,7 @@ namespace Invidious
return {
items: json.playlists
continuation: json.continuation
sortOptions: json.sortOptions
}
end if
return invalid
@@ -105,8 +105,12 @@ function ShouldShowNotification(segment as object, categories as object) as bool
return option = SponsorBlock.SegmentAction.AutoSkip or option = SponsorBlock.SegmentAction.ManualSkip
end function
function PadHightlightSegment(segments as object, lengthSeconds as integer) as object
for each segment in segments
function PadHightlightSegment(skipSegments as object, lengthSeconds as integer) as object
if skipSegments = invalid
return invalid
end if
for each segment in skipSegments
if not segment.category = "poi_highlight"
continue for
end if
@@ -131,5 +135,5 @@ function PadHightlightSegment(segments as object, lengthSeconds as integer) as o
segment.end = segment.end + padding
end for
return segments
return skipSegments
end function
@@ -92,11 +92,13 @@ function VideoRowListRowContentTask(input as object) as object
feedSources[feedSourcesIndex] = feedSource
feedContentNode.feedSources = feedSources
if feedContentNode.title.instr(" (Failed to load)") = -1
feedContentNode.title += " (Failed to load)"
isCancelled = response.cancelled = true
if not isCancelled
if feedContentNode.title.instr(" (Failed to load)") = -1
feedContentNode.title += " (Failed to load)"
end if
end if
isCancelled = response.cancelled = true
HandleFeedLoadErrorDialog(response.error, isCancelled, rowList)
continue while
end if
@@ -127,6 +129,10 @@ function VideoRowListRowContentTask(input as object) as object
hasContinuation = not StringUtils.IsNullOrEmpty(response.result.continuation)
feedSource.state.continuation = ValidString(response.result.continuation)
if response.result.sortOptions <> invalid
feedSource.state.sortOptions = response.result.sortOptions
end if
if addedItemCount > 0
pageType = feedSource.state.paginationType
if response.result.isLastPage = true or (hadContinuation and not hasContinuation)
@@ -19,16 +19,19 @@ function VideoContentTask(input as object) as object
end if
service = new Invidious.InvidiousService(invidiousNode)
backend = preferencesNode["backend.selected"]
if backend = "playlet"
metadata = InnertubeService.GetVideoMetadata(contentNode.videoId, {
"cancellation": m.top.cancellation
"credentialTransferToken": loungeServiceNode.credentialTransferToken
"visitorData": innertubeNode.visitorData
})
else
metadata = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
metadata = contentNode.metadata
if not IsAssociativeArray(metadata)
if backend = "playlet"
metadata = InnertubeService.GetVideoMetadata(contentNode.videoId, {
"cancellation": m.top.cancellation
"credentialTransferToken": loungeServiceNode.credentialTransferToken
"visitorData": innertubeNode.visitorData
})
else
metadata = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
end if
end if
if metadata = invalid
@@ -140,7 +143,11 @@ end function
function AddDashUrls(streamUrls as object, metadata as object, preferredQuality as string, backend as string, proxyVideos as string, playletServerPort as integer) as void
' Redirect to Playet's local web server, where will will be
' dynamically generating the DASH manifest, and filter quality
dashUrl = UrlUtils.AppendQueryParams(`http://127.0.0.1:${playletServerPort}/api/dash`, { v: metadata.videoId })
dashUrl = UrlUtils.AppendQueryParams(`http://127.0.0.1:${playletServerPort}/api/dash`, {
v: metadata.videoId
ytjs: ValidBool(metadata.ytjs)
})
dashUrlLocal = invalid
dashUrlFiltered = invalid
dashUrlFilteredLocal = invalid
@@ -1,6 +1,7 @@
#const DEBUG_LOG_VIDEO_QUALITY = false
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Services/Innertube/Constants.bs"
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
import "pkg:/components/VideoPlayer/Lounge.bs"
import "pkg:/components/VideoPlayer/SponsorBlock.bs"
@@ -52,7 +53,7 @@ function Init()
end if
httpAgent = m.top.getHttpAgent()
httpAgent.AddHeader("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0")
httpAgent.AddHeader("User-Agent", VIDEO_PLAYER_USER_AGENT)
#if DEBUG_LOG_VIDEO_QUALITY
m.top.addFields({
@@ -137,6 +138,10 @@ function PlayWithContent(contentNode as object)
if not StringUtils.IsNullOrEmpty(contentNode._author)
videoContentNode.secondaryTitle = contentNode._author
end if
metadata = contentNode.metadata
if IsAssociativeArray(metadata)
videoContentNode.AddFields({ metadata: metadata })
end if
StartVideoContentTask(videoContentNode)
Lounge.SendNowPlayingLoading(contentNode.videoId)
@@ -194,28 +199,70 @@ function OnVideoContentTaskResults(output as object) as void
content = m.top.content
SponsorBlock.FetchSponsorBlock(content.metadata)
timestamp = content.timestamp
percentDurationWatched = content.percentDurationWatched
hasTimestamp = IsInt(timestamp)
hasPercentDurationWatched = IsFloat(percentDurationWatched)
if IsLiveVideo() and not hasTimestamp and not hasPercentDurationWatched
' If live, seek to end of stream
m.seekToPercent = 100.0
SeekToPercentOfDuration()
else
if hasTimestamp and timestamp > 0
m.top.seek = content.timestamp
else if hasPercentDurationWatched
m.seekToPercent = percentDurationWatched
SeekToPercentOfDuration()
end if
end if
SeekToInitialPosition(content)
PlayAfterPreviousPlayerHasStopped()
MarkVideoWatched(content.videoId)
end function
function SeekToInitialPosition(content as object) as void
if content = invalid
return
end if
' For trickplay of live streams, apps should seek to a position of
' 999,999 seconds (for both DASH and HLS streams). The Roku media
' player clips that position to the current availability window and
' provides a robust buffer.
' https://developer.roku.com/en-ca/docs/specs/media/streaming-specifications.md
if content.Live = true
LogInfo("Seeking to enge of live stream")
m.top.seek = 999999
return
end if
timestamp = ValidInt(content.timestamp)
if timestamp > 0
LogInfo("Seeking to timestamp:", timestamp)
m.top.seek = content.timestamp
return
end if
percentDurationWatched = ValidFloat(content.percentDurationWatched)
if percentDurationWatched > 0
m.seekToPercent = percentDurationWatched
SeekToPercentOfDuration()
end if
end function
function SeekToPercentOfDuration() as void
m.top.UnobserveField("duration")
seekToPercent = m.seekToPercent
if seekToPercent = invalid
return
end if
duration = m.top.duration
if duration = 0
' If the duration is not available, wait for it to be set
m.top.ObserveField("duration", FuncName(SeekToPercentOfDuration))
return
end if
' If the stream is less than 30 seconds, it's not worth seeking
if duration < 30
return
end if
m.seekToPercent = invalid
seek = (MathUtils.Clamp(seekToPercent, 0, 100) / 100.0) * duration
if seek > 0
LogInfo("Seeking to percent duration watched", seek)
m.top.seek = seek
end if
end function
function PlayAfterPreviousPlayerHasStopped() as void
previousPlayer = m.top.previousPlayer
m.top.previousPlayer = invalid
@@ -393,10 +440,10 @@ function OnVideoPlayerStateChange() as void
nextUrl = playletStreamUrls[playletStreamUrlIndex]
LogError(`Stream ${currentUrl} failed to play. Trying next stream ${nextUrl}`)
' TODO:P2 handle SeekToEndOfStream for live videos on error
m.top.UnobserveField("duration")
content.url = nextUrl
SeekToInitialPosition(content)
' This video errored, and is about to finish, so don't close the video yet
' That's why we should ignore the next "finished" event
m.ignoreNextFinishedState = true
@@ -452,46 +499,6 @@ function OnVideoPlayerStateChange() as void
end if
end function
function SeekToEndOfStream() as void
m.top.UnobserveField("duration")
duration = m.top.duration
' If the stream is less than 30 seconds, it's not worth seeking
if duration < 30
return
end if
LogInfo("Seeking to end of live stream", duration)
m.top.seek = duration
end function
function SeekToPercentOfDuration() as void
m.top.UnobserveField("duration")
seekToPercent = m.seekToPercent
if seekToPercent = invalid
return
end if
duration = m.top.duration
if duration = 0
' If the duration is not available, wait for it to be set
m.top.ObserveField("duration", FuncName(SeekToPercentOfDuration))
return
end if
' If the stream is less than 30 seconds, it's not worth seeking
if duration < 30
return
end if
m.seekToPercent = invalid
seek = (MathUtils.Clamp(seekToPercent, 0, 100) / 100.0) * duration
if seek > 0
LogInfo("Seeking to percent duration watched", seek)
m.top.seek = seek
end if
end function
function OnVideoFinished() as void
if not VideoQueueUtils.PlayNext(m.videoQueue, m.invidious, m.preferences)
m.videoQueue.closePlayer = true
@@ -1,4 +1,5 @@
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/Services/Innertube/Constants.bs"
import "pkg:/components/VideoPlayerDev/PictureInPicture.bs"
import "pkg:/components/VideoPlayerDev/PlayerUi.bs"
import "pkg:/components/VideoQueue/VideoQueueUtils.bs"
@@ -15,9 +16,8 @@ import "pkg:/source/utils/Types.bs"
function Init()
InitializePlayerUi()
httpAgent = m.top.getHttpAgent()
httpAgent.AddHeader("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0")
httpAgent.AddHeader("User-Agent", VIDEO_PLAYER_USER_AGENT)
end function
function OnNodeReady()
@@ -10,7 +10,9 @@ namespace Http
function new(server as object)
super()
m.invidiousNode = server.task.invidious
task = server.task
m.videoQueueNode = task.videoQueue
m.invidiousNode = task.invidious
m.invidiousService = new Invidious.InvidiousService(m.invidiousNode)
' No need to pass the invidious instance here, we will refresh it for
' each request to make sure we are using the latest one
@@ -25,16 +27,39 @@ namespace Http
v = request.query.v
local = request.query.local
quality = request.query.quality
ytjs = request.query.ytjs
if StringUtils.IsNullOrEmpty(v)
response.Default(400, "Missing video id")
return true
end if
metadata = m.invidiousService.GetVideoMetadata(v)
if metadata.error <> invalid
response.Default(500, metadata.error)
return true
if ValidString(ytjs) = "true"
player = m.videoQueueNode.player
if player = invalid
response.Default(500, "videoQueue.player is invalid")
return true
end if
content = player.content
if content = invalid
response.Default(500, "videoQueue.player.content is invalid")
return true
end if
metadata = content.metadata
if not IsAssociativeArray(metadata)
response.Default(500, "videoQueue.player.content.metadata is invalid")
return true
end if
if metadata.videoId <> v
response.Default(400, "videoQueue.playVideo.metadata.videoId does not match the requested video id")
return true
end if
else
metadata = m.invidiousService.GetVideoMetadata(v)
if metadata.error <> invalid
response.Default(500, metadata.error)
return true
end if
end if
m.dashManifest.invidiousInstance = m.invidiousService.GetInstance()
@@ -0,0 +1,91 @@
import "pkg:/components/Services/Innertube/SessionData.bs"
import "pkg:/source/services/HttpClient.bs"
namespace Http
class InnertubeRouter extends HttpRouter
function new(server as object)
super()
m.innertube = server.task.innertube
end function
@get("/api/innertube/session")
function GetSessionData(context as object) as object
response = context.response
sessionData = {
"timestamp": m.innertube.timestamp
"visitorData": m.innertube.visitorData
"poToken": m.innertube.poToken
}
response.Json(sessionData)
return true
end function
@post("/api/innertube/session")
function SetSessionData(context as object) as object
request = context.request
response = context.response
payload = request.Json()
if payload = invalid or not IsAssociativeArray(payload)
response.Default(400, "Invalid payload")
return true
end if
if not IsInt(payload.timestamp)
response.Default(400, "Invalid timestamp")
return true
end if
if StringUtils.IsNullOrEmpty(payload.visitorData)
response.Default(400, "Invalid visitorData")
return true
end if
if StringUtils.IsNullOrEmpty(payload.poToken)
response.Default(400, "Invalid poToken")
return true
end if
Innertube.SaveSessionDataToRegistry({
"timestamp": payload.timestamp
"visitorData": payload.visitorData
"poToken": payload.poToken
})
m.innertube.timestamp = payload.timestamp
m.innertube.visitorData = payload.visitorData
m.innertube.poToken = payload.poToken
response.Default(204, "Session data updated successfully")
return true
end function
@post("/api/innertube/proxy")
function ProxyRequest(context as object) as boolean
request = context.request
response = context.response
requestArgs = request.Json()
if requestArgs = invalid
response.Default(400, "Invalid request body")
return true
end if
httpReq = HttpClient.FromObject(requestArgs)
httpRes = httpReq.Await()
result = {
"status": httpRes.StatusCode()
"headers": httpRes.Headers()
"body": httpRes.Text()
}
response.Json(result)
return true
end function
end class
end namespace
@@ -735,6 +735,24 @@ namespace Http
options.params = params
end if
' sort by is a special sorting argument handled by Playlet backend.
' It's a JSON object that could have the "params" key or "continuation"
' key. In this case, we will override these options with the values
' from the "sort_by" query parameter. If we do get an Invidious "sort_by"
' (such as "newest", "oldest", etc.), we'll ignore it, as it is not supported.
sortBy = request.query.sort_by
if not StringUtils.IsNullOrEmpty(sortBy) and sortBy.StartsWith("{")
sortBy = ParseJson(sortBy)
if IsAssociativeArray(sortBy)
if sortBy.DoesExist("params")
options.params = sortBy.params
end if
if sortBy.DoesExist("continuation")
options.continuation = sortBy.continuation
end if
end if
end if
channel = InnertubeService.GetChannel(channelId, options)
if raw
response.Json(channel)
@@ -747,28 +765,52 @@ namespace Http
return true
end if
result = {}
if _tab = "playlists" or _tab = "podcasts" or _tab = "releases" or _tab = "courses"
result = {
"playlists": channel.items
}
if channel.DoesExist("continuation")
result.continuation = channel.continuation
end if
response.Json(result)
if channel.DoesExist("cache-control")
response.headers["cache-control"] = channel["cache-control"]
end if
result ["playlists"] = channel.items
else
result = {
"videos": channel.items
}
if channel.DoesExist("continuation")
result.continuation = channel.continuation
end if
response.Json(result)
if channel.DoesExist("cache-control")
response.headers["cache-control"] = channel["cache-control"]
result ["videos"] = channel.items
end if
if channel.DoesExist("continuation")
result.continuation = channel.continuation
end if
if channel.DoesExist("sortOptions")
' Transform sort options from:
' [{
' "title": "string",
' "isSelected": "boolean"
' "params?": "string",
' "continuation?": "string"
' }]
' to:
' [{
' "title": "string",
' "isSelected": "boolean"
' "params?": "string",
' "continuation?": "string"
' "id": "{ \"params\": \"string\", \"continuation\": \"string\" }"
' }]
' This so sorting doesn't interfere with actual params or continuation.
' Sort options are later parsed by Playlet backend.
sortOptions = channel.sortOptions
if IsArray(sortOptions) and sortOptions.Count() > 0
for i = 0 to sortOptions.Count() - 1
sortOption = sortOptions[i]
sortOptionId = {}
if sortOption.DoesExist("params")
sortOptionId["params"] = sortOption.params
end if
if sortOption.DoesExist("continuation")
sortOptionId["continuation"] = sortOption.continuation
end if
sortOption.id = FormatJson(sortOptionId)
end for
end if
result["sortOptions"] = sortOptions
end if
response.Json(result)
if channel.DoesExist("cache-control")
response.headers["cache-control"] = channel["cache-control"]
end if
return true
@@ -92,6 +92,10 @@ namespace Http
instance = m.invidiousService.GetInstance()
contentNode = InvidiousContent.ToRowCellContentNode(payload, instance)
if IsAssociativeArray(payload.metadata)
contentNode.addFields({ metadata: payload.metadata })
end if
nodeType = contentNode.type
if nodeType = "playlist"
@@ -6,6 +6,7 @@ import "pkg:/components/Web/PlayletWebServer/Middleware/DialRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/HlsRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/HomeLayoutRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/HomeRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/InnertubeRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/InvidiousRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayletLibUrlsRouter.bs"
@@ -39,6 +40,8 @@ function SetupRoutes(server as object)
#if DEBUG
'CORS is mostly for developing the web app
server.UseRouter(new Http.CorsMiddleware())
#else
server.UseRouter(new Http.CorsMiddleware(""))
#end if
if server.settings.WebSocketsEnabled
server.UseRouter(new Http.WebSocketMiddleware())
@@ -60,6 +63,7 @@ function SetupRoutes(server as object)
server.UseRouter(new Http.CacheRouter())
server.UseRouter(new Http.RegistryRouter(server))
server.UseRouter(new Http.PlayletInvidiousBackendRouter(server))
server.UseRouter(new Http.InnertubeRouter(server))
etags = new Http.EtagUtils()
server.UseRouter(new Http.HttpStaticFilesRouter("/", "libpkg:/www", etags, { staticFiles: true, staticCompressed: true }))
@@ -46,10 +46,11 @@ namespace Http
function Add(incoming as string, maybeUnicode as boolean)
if IsString(m.buffer)
m.buffer = m.buffer + incoming
m.maybe_unicode = m.maybe_unicode or maybeUnicode
else
m.buffer = incoming
m.maybe_unicode = maybeUnicode
end if
m.maybe_unicode = maybeUnicode
end function
function ProcessNext(connection as HttpConnection) as boolean
@@ -20,9 +20,17 @@ namespace Http
request = context.request
response = context.response
response.headers["Access-Control-Allow-Origin"] = m.origin
response.headers["Access-Control-Allow-Headers"] = m.headers
response.headers["Access-Control-Allow-Methods"] = m.methods
if not StringUtils.IsNullOrEmpty(m.origin)
response.headers["Access-Control-Allow-Origin"] = m.origin
end if
if not StringUtils.IsNullOrEmpty(m.headers)
response.headers["Access-Control-Allow-Headers"] = m.headers
end if
if not StringUtils.IsNullOrEmpty(m.methods)
response.headers["Access-Control-Allow-Methods"] = m.methods
end if
if request.method = "OPTIONS"
response.header_only = true
@@ -1328,5 +1328,65 @@
<source>Login to YouTube</source>
<translation>Bei YouTube anmelden</translation>
</message>
<message>
<source>Select a service to login</source>
<translation>Einen Dienst zum Anmelden auswählen</translation>
</message>
<message>
<source>Open the link %1 and enter the following code:</source>
<translation>Den Link %1 öffnen und diesen Code eingeben:</translation>
</message>
<message>
<source>Use responsibly, especially if your YouTube account is tied to business or monetization.</source>
<translation>Handeln Sie verantwortungsbewusst, besonders wenn Ihr YouTube-Benutzerkonto mit einem Gewerbe oder Monetarisierung zusammenhängt.</translation>
</message>
<message>
<source>Who&apos;s watching?</source>
<translation>Wer guckt gerade?</translation>
</message>
<message>
<source>No valid accounts found for YouTube login.</source>
<translation>Keine gültigen Benutzerkonten zum Anmelden auf YouTube gefunden.</translation>
</message>
<message>
<source>Configure which segments to skip</source>
<translation>Das Überspringen von Abschnitten konfigurieren</translation>
</message>
<message>
<source>Press OK to skip</source>
<translation>OK drücken, um zu überspringen</translation>
</message>
<message>
<source>Auto Skip</source>
<translation>Auto-Überspringen</translation>
</message>
<message>
<source>Manual Skip</source>
<translation>Manuelles Überspringen</translation>
</message>
<message>
<source>Show in Seekbar</source>
<translation>In der Suchleiste anzeigen</translation>
</message>
<message>
<source>Categories</source>
<translation>Kategorien</translation>
</message>
<message>
<source>Playlet is a third-party app and is not affiliated with, endorsed by, or sponsored by YouTube or Google. All trademarks and registered trademarks mentioned are the property of their respective owners and are used only for identification purposes.</source>
<translation type="unfinished">Playlet ist eine Drittanbieter-App, wird weder von YouTube noch von Google unterstützt oder gesponsert und steht in keiner Verbindung zu diesen. Alle hier erwähnten (eingetragenen) Marken sind geistiges Eigentum ihrer jeweiligen Besitzer und werden nur zu Identifikationszwecken genutzt.</translation>
</message>
<message>
<source>By using Playlet and signing in with your YouTube account, you acknowledge that you do so at your own risk. The developers of Playlet are not liable for any harm, including but not limited to data loss, account suspension or ban, hacking, or loss of content.</source>
<translation type="unfinished">Die Benutzung von Playlet und das Anmelden mit einem YouTube-Benutzerkonto erfolgt auf Ihr eigenes Risiko hin. Die Entwickler von Playlet sind für jedwegen Schaden, inklusive, aber nicht ausschließlich dem Verlust von Daten, der Sperrung/ Inaktivierung von Benutzerkonten und Hacking, nicht haftbar oder verantwortlich.</translation>
</message>
<message>
<source>Select option for %1</source>
<translation>Option für %1 auswählen</translation>
</message>
<message>
<source>Disable</source>
<translation>Deaktivieren</translation>
</message>
</context>
</TS>
+1 -1
View File
@@ -3,7 +3,7 @@ title=PlayletLib
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=40
build_version=00000
build_version=00002
ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p
@@ -14,10 +14,9 @@ namespace AsyncTask
task.id = id
task.input = input
if callback <> invalid
m[`asynctask_${id}_callback`] = callback
task.ObserveFieldScoped("state", FuncName(internal_OnTaskState))
end if
m[`asynctask_${id}`] = task
m[`asynctask_${id}_callback`] = callback
task.ObserveFieldScoped("state", FuncName(internal_OnTaskState))
return task
end function
@@ -40,6 +39,9 @@ namespace AsyncTask
end if
end if
task.input = invalid
task.output = invalid
m.delete(`asynctask_${id}`)
m.delete(`asynctask_${id}_callback`)
end function
@@ -719,10 +719,10 @@ namespace HttpClient
else
if m.request._sent <> true
m._errorMessage = Tr(Locale.HttpClient.RequestNotSent)
else if m.IsTimedOut()
m._errorMessage = Tr(Locale.HttpClient.RequestTimedOut)
else if m.IsCancelled()
m._errorMessage = Tr(Locale.HttpClient.RequestCancelled)
else if m.IsTimedOut()
m._errorMessage = Tr(Locale.HttpClient.RequestTimedOut)
else if type(m.event) = "roUrlEvent"
m._errorMessage = `${Tr(Locale.HttpClient.Reason)}:${m.event.GetFailureReason() }\nStatusCode: ${m.StatusCode()}\nRequestId: ${m.event.GetSourceIdentity()}`
if includeBody
+3 -7
View File
@@ -13,14 +13,10 @@ namespace TimeUtils
minutes = (length \ 60) mod 60
seconds = length mod 60
if seconds < 10
seconds = "0" + seconds.ToStr()
else
seconds = seconds.ToStr()
end if
seconds = seconds.ToStr("%02d")
if minutes < 10 and hours > 0
minutes = "0" + minutes.ToStr()
if hours > 0
minutes = minutes.ToStr("%02d")
else
minutes = minutes.ToStr()
end if
+98 -24
View File
@@ -1,32 +1,34 @@
{
"name": "playlet-web",
"version": "0.40.0",
"version": "0.40.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet-web",
"version": "0.40.0",
"version": "0.40.2",
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^5.0.3",
"@sveltejs/vite-plugin-svelte": "^5.1.0",
"@tailwindcss/typography": "^0.5.16",
"@tsconfig/svelte": "^5.0.4",
"@vitejs/plugin-legacy": "^6.1.1",
"autoprefixer": "^10.4.21",
"bgutils-js": "^3.2.0",
"daisyui": "^4.12.23",
"dotenv": "^16.5.0",
"ip": "^2.0.1",
"postcss": "^8.5.4",
"svelte": "^5.33.10",
"svelte": "^5.33.15",
"svelte-check": "^4.2.1",
"svelte-preprocess": "^6.0.3",
"tailwindcss": "^3.4.17",
"terser": "^5.40.0",
"terser": "^5.41.0",
"tslib": "^2.8.1",
"typescript": "^5.8.3",
"vite": "^6.3.5",
"vite-plugin-compression": "^0.5.1",
"vite-tsconfig-paths": "^5.1.4"
"vite-tsconfig-paths": "^5.1.4",
"youtubei.js": "^13.4.0"
}
},
"node_modules/@alloc/quick-lru": {
@@ -1546,6 +1548,13 @@
"node": ">=6.9.0"
}
},
"node_modules/@bufbuild/protobuf": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-2.5.1.tgz",
"integrity": "sha512-lut4UTvKL8tqtend0UDu7R79/n9jA7Jtxf77RNPbxtmWqfWI4qQ9bTjf7KCS4vfqLmpQbuHr1ciqJumAgJODdw==",
"dev": true,
"license": "(Apache-2.0 AND BSD-3-Clause)"
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.25.0",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.0.tgz",
@@ -1971,6 +1980,16 @@
"node": ">=18"
}
},
"node_modules/@fastify/busboy": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=14"
}
},
"node_modules/@isaacs/cliui": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
@@ -2382,17 +2401,18 @@
}
},
"node_modules/@sveltejs/vite-plugin-svelte": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-5.0.3.tgz",
"integrity": "sha512-MCFS6CrQDu1yGwspm4qtli0e63vaPCehf6V7pIMP15AsWgMKrqDGCPFF/0kn4SP0ii4aySu4Pa62+fIRGFMjgw==",
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-5.1.0.tgz",
"integrity": "sha512-wojIS/7GYnJDYIg1higWj2ROA6sSRWvcR1PO/bqEyFr/5UZah26c8Cz4u0NaqjPeVltzsVpt2Tm8d2io0V+4Tw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@sveltejs/vite-plugin-svelte-inspector": "^4.0.1",
"debug": "^4.4.0",
"debug": "^4.4.1",
"deepmerge": "^4.3.1",
"kleur": "^4.1.5",
"magic-string": "^0.30.15",
"vitefu": "^1.0.4"
"magic-string": "^0.30.17",
"vitefu": "^1.0.6"
},
"engines": {
"node": "^18.0.0 || ^20.0.0 || >=22"
@@ -2654,6 +2674,16 @@
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true
},
"node_modules/bgutils-js": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/bgutils-js/-/bgutils-js-3.2.0.tgz",
"integrity": "sha512-CacO15JvxbclbLeCAAm9DETGlLuisRGWpPigoRvNsccSCPEC4pwYwA2g2x/pv7Om/sk79d4ib35V5HHmxPBpDg==",
"dev": true,
"funding": [
"https://github.com/sponsors/LuanRT"
],
"license": "MIT"
},
"node_modules/binary-extensions": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
@@ -2937,10 +2967,11 @@
}
},
"node_modules/debug": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
"integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
"integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
@@ -3402,6 +3433,19 @@
"@pkgjs/parseargs": "^0.11.0"
}
},
"node_modules/jintr": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/jintr/-/jintr-3.3.1.tgz",
"integrity": "sha512-nnOzyhf0SLpbWuZ270Omwbj5LcXUkTcZkVnK8/veJXtSZOiATM5gMZMdmzN75FmTyj+NVgrGaPdH12zIJ24oIA==",
"dev": true,
"funding": [
"https://github.com/sponsors/LuanRT"
],
"license": "MIT",
"dependencies": {
"acorn": "^8.8.0"
}
},
"node_modules/jiti": {
"version": "1.21.7",
"resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.7.tgz",
@@ -4372,9 +4416,9 @@
}
},
"node_modules/svelte": {
"version": "5.33.10",
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.33.10.tgz",
"integrity": "sha512-/yArPQIBoQS2p86LKnvJywOXkVHeEXnFgrDPSxkEfIAEkykopYuy2bF6UUqHG4IbZlJD6OurLxJT8Kn7kTk9WA==",
"version": "5.33.15",
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.33.15.tgz",
"integrity": "sha512-068mFjz25qg+UTaWlnGEUfCX3VtypcODx3SbRUBvMfAnVim0jGs5q7M50SFKeI4EPvTe87cB1GJgMZhXAAc6OQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -4593,9 +4637,9 @@
}
},
"node_modules/terser": {
"version": "5.40.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.40.0.tgz",
"integrity": "sha512-cfeKl/jjwSR5ar7d0FGmave9hFGJT8obyo0z+CrQOylLDbk7X81nPU6vq9VORa5jU30SkDnT2FXjLbR8HLP+xA==",
"version": "5.41.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.41.0.tgz",
"integrity": "sha512-H406eLPXpZbAX14+B8psIuvIr8+3c+2hkuYzpMkoE0ij+NdsVATbA78vb8neA/eqrj7rywa2pIkdmWRsXW6wmw==",
"dev": true,
"license": "BSD-2-Clause",
"dependencies": {
@@ -4713,6 +4757,19 @@
"node": ">=14.17"
}
},
"node_modules/undici": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz",
"integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@fastify/busboy": "^2.0.0"
},
"engines": {
"node": ">=14.0"
}
},
"node_modules/unicode-canonical-property-names-ecmascript": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz",
@@ -4911,10 +4968,11 @@
}
},
"node_modules/vitefu": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.0.5.tgz",
"integrity": "sha512-h4Vflt9gxODPFNGPwp4zAMZRpZR7eslzwH2c5hn5kNZ5rhnKyRJ50U+yGCdc2IRaBs8O4haIgLNGrV5CrpMsCA==",
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.0.6.tgz",
"integrity": "sha512-+Rex1GlappUyNN6UfwbVZne/9cYC4+R2XDk9xkNXBKMw6HQagdX9PgZ8V2v1WUSK1wfBLp7qbI1+XSNIlB1xmA==",
"dev": true,
"license": "MIT",
"workspaces": [
"tests/deps/*",
"tests/projects/*"
@@ -5050,6 +5108,22 @@
"node": ">= 14"
}
},
"node_modules/youtubei.js": {
"version": "13.4.0",
"resolved": "https://registry.npmjs.org/youtubei.js/-/youtubei.js-13.4.0.tgz",
"integrity": "sha512-+fmIZU/dWAjsROONrASy1REwVpy6umAPVuoNLr/4iNmZXl84LyBef0n3hrd1Vn9035EuINToGyQcBmifwUEemA==",
"dev": true,
"funding": [
"https://github.com/sponsors/LuanRT"
],
"license": "MIT",
"dependencies": {
"@bufbuild/protobuf": "^2.0.0",
"jintr": "^3.3.1",
"tslib": "^2.5.0",
"undici": "^5.19.1"
}
},
"node_modules/zimmerframe": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.2.tgz",
+7 -5
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-web",
"version": "0.40.0",
"version": "0.40.2",
"type": "module",
"scripts": {
"dev": "vite",
@@ -9,24 +9,26 @@
"lint": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^5.0.3",
"@sveltejs/vite-plugin-svelte": "^5.1.0",
"@tailwindcss/typography": "^0.5.16",
"@tsconfig/svelte": "^5.0.4",
"@vitejs/plugin-legacy": "^6.1.1",
"autoprefixer": "^10.4.21",
"bgutils-js": "^3.2.0",
"daisyui": "^4.12.23",
"dotenv": "^16.5.0",
"ip": "^2.0.1",
"postcss": "^8.5.4",
"svelte": "^5.33.10",
"svelte": "^5.33.15",
"svelte-check": "^4.2.1",
"svelte-preprocess": "^6.0.3",
"tailwindcss": "^3.4.17",
"terser": "^5.40.0",
"terser": "^5.41.0",
"tslib": "^2.8.1",
"typescript": "^5.8.3",
"vite": "^6.3.5",
"vite-plugin-compression": "^0.5.1",
"vite-tsconfig-paths": "^5.1.4"
"vite-tsconfig-paths": "^5.1.4",
"youtubei.js": "^13.4.0"
}
}
+440
View File
@@ -0,0 +1,440 @@
import { Innertube, UniversalCache } from 'youtubei.js/web';
import { getHost } from "lib/Api/Host";
import { BG } from "bgutils-js";
import { type BgConfig } from "bgutils-js";
import type { VideoInfo } from 'node_modules/youtubei.js/dist/src/parser/youtube';
import type { StoryboardData } from 'node_modules/youtubei.js/dist/src/parser/classes/PlayerStoryboardSpec';
import type { PlayerLiveStoryboardSpec, PlayerStoryboardSpec } from 'node_modules/youtubei.js/dist/src/parser/nodes';
// https://github.com/iv-org/invidious/blob/a021b93063f3956fc9bb3cce0fb56ea252422738/src/invidious/videos/formats.cr#L7
const FORMATS = {
"5": { ext: "flv", width: 400, height: 240, acodec: "mp3", abr: 64, vcodec: "h263" },
"6": { ext: "flv", width: 450, height: 270, acodec: "mp3", abr: 64, vcodec: "h263" },
"13": { ext: "3gp", acodec: "aac", vcodec: "mp4v" },
"17": { ext: "3gp", width: 176, height: 144, acodec: "aac", abr: 24, vcodec: "mp4v" },
"18": { ext: "mp4", width: 640, height: 360, acodec: "aac", abr: 96, vcodec: "h264" },
"22": { ext: "mp4", width: 1280, height: 720, acodec: "aac", abr: 192, vcodec: "h264" },
"34": { ext: "flv", width: 640, height: 360, acodec: "aac", abr: 128, vcodec: "h264" },
"35": { ext: "flv", width: 854, height: 480, acodec: "aac", abr: 128, vcodec: "h264" },
"36": { ext: "3gp", width: 320, acodec: "aac", vcodec: "mp4v" },
"37": { ext: "mp4", width: 1920, height: 1080, acodec: "aac", abr: 192, vcodec: "h264" },
"38": { ext: "mp4", width: 4096, height: 3072, acodec: "aac", abr: 192, vcodec: "h264" },
"43": { ext: "webm", width: 640, height: 360, acodec: "vorbis", abr: 128, vcodec: "vp8" },
"44": { ext: "webm", width: 854, height: 480, acodec: "vorbis", abr: 128, vcodec: "vp8" },
"45": { ext: "webm", width: 1280, height: 720, acodec: "vorbis", abr: 192, vcodec: "vp8" },
"46": { ext: "webm", width: 1920, height: 1080, acodec: "vorbis", abr: 192, vcodec: "vp8" },
"59": { ext: "mp4", width: 854, height: 480, acodec: "aac", abr: 128, vcodec: "h264" },
"78": { ext: "mp4", width: 854, height: 480, acodec: "aac", abr: 128, vcodec: "h264" },
"82": { ext: "mp4", height: 360, format: "3D", acodec: "aac", abr: 128, vcodec: "h264" },
"83": { ext: "mp4", height: 480, format: "3D", acodec: "aac", abr: 128, vcodec: "h264" },
"84": { ext: "mp4", height: 720, format: "3D", acodec: "aac", abr: 192, vcodec: "h264" },
"85": { ext: "mp4", height: 1080, format: "3D", acodec: "aac", abr: 192, vcodec: "h264" },
"100": { ext: "webm", height: 360, format: "3D", acodec: "vorbis", abr: 128, vcodec: "vp8" },
"101": { ext: "webm", height: 480, format: "3D", acodec: "vorbis", abr: 192, vcodec: "vp8" },
"102": { ext: "webm", height: 720, format: "3D", acodec: "vorbis", abr: 192, vcodec: "vp8" },
"91": { ext: "mp4", height: 144, format: "HLS", acodec: "aac", abr: 48, vcodec: "h264" },
"92": { ext: "mp4", height: 240, format: "HLS", acodec: "aac", abr: 48, vcodec: "h264" },
"93": { ext: "mp4", height: 360, format: "HLS", acodec: "aac", abr: 128, vcodec: "h264" },
"94": { ext: "mp4", height: 480, format: "HLS", acodec: "aac", abr: 128, vcodec: "h264" },
"95": { ext: "mp4", height: 720, format: "HLS", acodec: "aac", abr: 256, vcodec: "h264" },
"96": { ext: "mp4", height: 1080, format: "HLS", acodec: "aac", abr: 256, vcodec: "h264" },
"132": { ext: "mp4", height: 240, format: "HLS", acodec: "aac", abr: 48, vcodec: "h264" },
"151": { ext: "mp4", height: 72, format: "HLS", acodec: "aac", abr: 24, vcodec: "h264" },
"133": { ext: "mp4", height: 240, format: "DASH video", vcodec: "h264" },
"134": { ext: "mp4", height: 360, format: "DASH video", vcodec: "h264" },
"135": { ext: "mp4", height: 480, format: "DASH video", vcodec: "h264" },
"136": { ext: "mp4", height: 720, format: "DASH video", vcodec: "h264" },
"137": { ext: "mp4", height: 1080, format: "DASH video", vcodec: "h264" },
"138": { ext: "mp4", format: "DASH video", vcodec: "h264" },
"160": { ext: "mp4", height: 144, format: "DASH video", vcodec: "h264" },
"212": { ext: "mp4", height: 480, format: "DASH video", vcodec: "h264" },
"264": { ext: "mp4", height: 1440, format: "DASH video", vcodec: "h264" },
"298": { ext: "mp4", height: 720, format: "DASH video", vcodec: "h264", fps: 60 },
"299": { ext: "mp4", height: 1080, format: "DASH video", vcodec: "h264", fps: 60 },
"266": { ext: "mp4", height: 2160, format: "DASH video", vcodec: "h264" },
"139": { ext: "m4a", format: "DASH audio", acodec: "aac", abr: 48, container: "m4a_dash" },
"140": { ext: "m4a", format: "DASH audio", acodec: "aac", abr: 128, container: "m4a_dash" },
"141": { ext: "m4a", format: "DASH audio", acodec: "aac", abr: 256, container: "m4a_dash" },
"256": { ext: "m4a", format: "DASH audio", acodec: "aac", container: "m4a_dash" },
"258": { ext: "m4a", format: "DASH audio", acodec: "aac", container: "m4a_dash" },
"325": { ext: "m4a", format: "DASH audio", acodec: "dtse", container: "m4a_dash" },
"328": { ext: "m4a", format: "DASH audio", acodec: "ec-3", container: "m4a_dash" },
"167": { ext: "webm", height: 360, width: 640, format: "DASH video", container: "webm", vcodec: "vp8" },
"168": { ext: "webm", height: 480, width: 854, format: "DASH video", container: "webm", vcodec: "vp8" },
"169": { ext: "webm", height: 720, width: 1280, format: "DASH video", container: "webm", vcodec: "vp8" },
"170": { ext: "webm", height: 1080, width: 1920, format: "DASH video", container: "webm", vcodec: "vp8" },
"218": { ext: "webm", height: 480, width: 854, format: "DASH video", container: "webm", vcodec: "vp8" },
"219": { ext: "webm", height: 480, width: 854, format: "DASH video", container: "webm", vcodec: "vp8" },
"278": { ext: "webm", height: 144, format: "DASH video", container: "webm", vcodec: "vp9" },
"242": { ext: "webm", height: 240, format: "DASH video", vcodec: "vp9" },
"243": { ext: "webm", height: 360, format: "DASH video", vcodec: "vp9" },
"244": { ext: "webm", height: 480, format: "DASH video", vcodec: "vp9" },
"245": { ext: "webm", height: 480, format: "DASH video", vcodec: "vp9" },
"246": { ext: "webm", height: 480, format: "DASH video", vcodec: "vp9" },
"247": { ext: "webm", height: 720, format: "DASH video", vcodec: "vp9" },
"248": { ext: "webm", height: 1080, format: "DASH video", vcodec: "vp9" },
"271": { ext: "webm", height: 1440, format: "DASH video", vcodec: "vp9" },
"272": { ext: "webm", height: 2160, format: "DASH video", vcodec: "vp9" },
"302": { ext: "webm", height: 720, format: "DASH video", vcodec: "vp9", fps: 60 },
"303": { ext: "webm", height: 1080, format: "DASH video", vcodec: "vp9", fps: 60 },
"308": { ext: "webm", height: 1440, format: "DASH video", vcodec: "vp9", fps: 60 },
"313": { ext: "webm", height: 2160, format: "DASH video", vcodec: "vp9" },
"315": { ext: "webm", height: 2160, format: "DASH video", vcodec: "vp9", fps: 60 },
"330": { ext: "webm", height: 144, format: "DASH video", vcodec: "vp9", fps: 60 },
"331": { ext: "webm", height: 240, format: "DASH video", vcodec: "vp9", fps: 60 },
"332": { ext: "webm", height: 360, format: "DASH video", vcodec: "vp9", fps: 60 },
"333": { ext: "webm", height: 480, format: "DASH video", vcodec: "vp9", fps: 60 },
"334": { ext: "webm", height: 720, format: "DASH video", vcodec: "vp9", fps: 60 },
"335": { ext: "webm", height: 1080, format: "DASH video", vcodec: "vp9", fps: 60 },
"336": { ext: "webm", height: 1440, format: "DASH video", vcodec: "vp9", fps: 60 },
"337": { ext: "webm", height: 2160, format: "DASH video", vcodec: "vp9", fps: 60 },
"171": { ext: "webm", acodec: "vorbis", format: "DASH audio", abr: 128 },
"172": { ext: "webm", acodec: "vorbis", format: "DASH audio", abr: 256 },
"249": { ext: "webm", format: "DASH audio", acodec: "opus", abr: 50 },
"250": { ext: "webm", format: "DASH audio", acodec: "opus", abr: 70 },
"251": { ext: "webm", format: "DASH audio", acodec: "opus", abr: 160 },
"394": { ext: "mp4", height: 144, vcodec: "av01.0.05M.08" },
"395": { ext: "mp4", height: 240, vcodec: "av01.0.05M.08" },
"396": { ext: "mp4", height: 360, vcodec: "av01.0.05M.08" },
"397": { ext: "mp4", height: 480, vcodec: "av01.0.05M.08" }
}
export class YoutubeJs {
static host = () => `http://${getHost()}`
static innerTube: Innertube;
static innerTubePromise: Promise<void>;
static poToken?: string = undefined;
static visitorData?: string = undefined;
static async fetch(input: RequestInfo | URL, init?: RequestInit) {
const method = init?.method
? init.method
: input instanceof Request
? input.method
: 'GET';
const url = typeof input === 'string'
? new URL(input)
: input instanceof URL
? input
: new URL(input.url);
const headers = init?.headers
? new Headers(init.headers)
: input instanceof Request
? input.headers
: new Headers();
const headersObject = {};
headers.forEach((value, key) => {
headersObject[key] = value;
});
let body = init?.body
const args = {
Method: method,
Url: url,
Headers: headersObject,
Body: body,
CacheSeconds: -1,
};
const response = await fetch(`http://${getHost()}/api/innertube/proxy`, {
headers: {
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(args)
})
const responseData = await response.json();
return new Response(responseData.body, {
status: responseData.status,
statusText: `${responseData.status}`,
headers: responseData.headers,
});
}
static async initSessionData() {
if (YoutubeJs.visitorData && YoutubeJs.poToken) {
return Promise.resolve();
}
const sessionData = await YoutubeJs.getSessionData();
if (sessionData.visitorData) {
YoutubeJs.visitorData = sessionData.visitorData;
if (sessionData.poToken) {
YoutubeJs.poToken = sessionData.poToken;
return;
}
}
if (!YoutubeJs.visitorData) {
YoutubeJs.visitorData = await YoutubeJs.generateVisitorData();
}
YoutubeJs.poToken = await YoutubeJs.generatePoToken(YoutubeJs.visitorData);
await YoutubeJs.setSessionData({
visitorData: YoutubeJs.visitorData,
poToken: YoutubeJs.poToken,
timestamp: Math.floor(Date.now() / 1000)
});
}
static async getSessionData() {
const response = await fetch(`http://${getHost()}/api/innertube/session`)
return await response.json();
}
static async setSessionData(sessionData: any) {
await fetch(`http://${getHost()}/api/innertube/session`, {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(sessionData)
});
}
static async getInnertube() {
await YoutubeJs.initInnertube();
return YoutubeJs.innerTube;
}
static async initInnertube() {
if (YoutubeJs.innerTube) {
return Promise.resolve();
}
if (YoutubeJs.innerTubePromise) {
return YoutubeJs.innerTubePromise;
}
YoutubeJs.innerTubePromise = new Promise(async (resolve, reject) => {
try {
await YoutubeJs.initSessionData()
YoutubeJs.innerTube = await Innertube.create({
fetch: YoutubeJs.fetch,
cache: new UniversalCache(true),
po_token: YoutubeJs.poToken,
visitor_data: YoutubeJs.visitorData,
});
YoutubeJs.innerTubePromise = null;
resolve();
} catch (error) {
console.error(error);
YoutubeJs.innerTube = null;
reject(error);
}
})
return YoutubeJs.innerTubePromise;
}
static async generateVisitorData() {
const innertube = await Innertube.create({ retrieve_player: false });
const visitorData = innertube.session.context.client.visitorData;
if (!visitorData) {
throw new Error('Could not get visitor data');
}
return visitorData;
}
static async generatePoToken(visitorData: string) {
const requestKey = 'O43z0dpjhgX20SCx4KAo';
const bgConfig: BgConfig = {
fetch: (input: string | URL | globalThis.Request, init?: RequestInit) => YoutubeJs.fetch(input, init),
globalObj: globalThis,
identifier: visitorData,
requestKey
};
const bgChallenge = await BG.Challenge.create(bgConfig);
if (!bgChallenge) {
throw new Error('Could not get challenge');
}
const interpreterJavascript = bgChallenge.interpreterJavascript.privateDoNotAccessOrElseSafeScriptWrappedValue;
if (interpreterJavascript) {
new Function(interpreterJavascript)();
} else {
throw new Error('Could not load VM');
}
const poTokenResult = await BG.PoToken.generate({
program: bgChallenge.program,
globalName: bgChallenge.globalName,
bgConfig
});
if (!poTokenResult || !poTokenResult.poToken) {
throw new Error('Could not generate poToken');
}
return poTokenResult.poToken;
}
static async getVideoInfo(videoId: string) {
await YoutubeJs.initInnertube();
const info = await YoutubeJs.innerTube.getBasicInfo(videoId, 'TV');
// We can't generate a proper dash from live videos.
// By returning null, we're telling Playlet to fetch video info itself.
if (info.basic_info.is_live) {
return null;
}
// Populate a video object that is similar to Invidious format.
// Mostly populate only fields we care about, enough to make it work.
return {
type: "video",
ytjs: true,
title: info.basic_info.title,
videoId: info.basic_info.id,
videoThumbnails: [],
storyboards: YoutubeJs.getStoryboards(info),
description: "",
published: 0,
publishedText: "",
keywords: [],
viewCount: 0,
likeCount: 0,
dislikeCount: 0,
paid: false,
premium: false,
isFamilyFriendly: true,
allowedRegions: [],
genre: "",
genreUrl: null,
author: info.basic_info.author,
authorId: info.basic_info.channel_id,
authorUrl: "",
authorVerified: false,
authorThumbnails: [],
subCountText: "",
lengthSeconds: info.basic_info.duration,
allowRatings: true,
rating: 0,
isListed: true,
liveNow: info.basic_info.is_live,
isPostLiveDvr: info.basic_info.is_post_live_dvr,
isUpcoming: info.basic_info.is_upcoming,
dashUrl: info.streaming_data.dash_manifest_url || "",
hlsUrl: info.streaming_data.hls_manifest_url,
adaptiveFormats: YoutubeJs.getAdaptiveFormats(info),
formatStreams: [],
captions: YoutubeJs.getCaptions(info),
recommendedVideos: [],
}
}
static getAdaptiveFormats(videoInfo: VideoInfo) {
if (!videoInfo.streaming_data.adaptive_formats) {
return [];
}
return videoInfo.streaming_data.adaptive_formats.map(format => {
const formatInfo = FORMATS[format.itag];
const result: any = {
init: format.init_range ? `${format.init_range.start}-${format.init_range.end}` : "",
index: format.index_range ? `${format.index_range.start}-${format.index_range.end}` : "",
bitrate: `${format.bitrate}`,
url: format.decipher(YoutubeJs.innerTube.session.player),
itag: `${format.itag}`,
type: format.mime_type,
clen: `${format.approx_duration_ms}`,
lmt: `${format.last_modified}`,
container: formatInfo?.ext,
encoding: formatInfo?.acodec ?? formatInfo?.vcodec,
};
if (format.audio_quality) {
result.audioQuality = format.audio_quality;
}
if (format.audio_sample_rate) {
result.audioSampleRate = format.audio_sample_rate;
}
if (format.audio_channels) {
result.audioChannels = format.audio_channels;
}
if (format.quality_label) {
result.qualityLabel = format.quality_label;
}
if (format.fps) {
result.fps = format.fps;
}
if (format.height && format.width) {
result.size = `${format.width}x${format.height}`;
result.resolution = `${format.height}p`;
} else if (formatInfo?.height && formatInfo?.width) {
result.size = `${formatInfo.width}x${formatInfo.height}`;
result.resolution = `${formatInfo.height}p`;
}
return result;
});
}
static getStoryboards(videoInfo: VideoInfo) {
if (!videoInfo.storyboards) {
return [];
}
if (videoInfo.storyboards.type === 'PlayerLiveStoryboardSpec') {
const board = (videoInfo.storyboards as PlayerLiveStoryboardSpec).board
return [{
templateUrl: board.template_url,
width: board.thumbnail_width,
height: board.thumbnail_height,
count: -1,
interval: 5000,
storyboardWidth: board.columns,
storyboardHeight: board.rows,
}];
}
const storyboards = (videoInfo.storyboards as PlayerStoryboardSpec).boards;
return storyboards.map((board: StoryboardData) => {
return {
templateUrl: board.template_url,
width: board.thumbnail_width,
height: board.thumbnail_height,
count: board.thumbnail_count,
interval: board.interval,
storyboardWidth: board.columns,
storyboardHeight: board.rows,
storyboardCount: board.storyboard_count
};
});
}
static getCaptions(videoInfo: VideoInfo) {
if (!videoInfo.captions?.caption_tracks) {
return [];
}
return videoInfo.captions.caption_tracks.map(track => {
const baseUrl = track.base_url;
if (!baseUrl) {
return null;
}
const queryComponents = new URLSearchParams(baseUrl.split('?')[1]);
queryComponents.set('fmt', 'vtt');
const modifiedBaseUrl = `${baseUrl.split('?')[0]}?${queryComponents.toString()}`;
return {
label: track.name.toString(),
language_code: track.language_code || '',
url: modifiedBaseUrl
};
}).filter(caption => !!caption);
}
}
+70 -64
View File
@@ -99,6 +99,8 @@
try {
isLoading = true;
// blur to hide the keyboard on mobile
searchBox.blur();
const response = await invidiousApi.search(
searchBoxText,
searchFilters,
@@ -120,73 +122,76 @@
<div class={visibility ? "" : "hidden"}>
<div class="m-4">
<!-- TODO:P2 use search HTML element -->
<form
on:submit={async (e) => {
e.preventDefault();
page = 1;
videos = [];
await searchVideos("");
}}
>
<div class="join w-full border border-neutral rounded-full">
<input
type="search"
dir="auto"
placeholder="{$translate('Search')}..."
class="join-item input w-full border border-neutral rounded-full"
bind:this={searchBox}
bind:value={searchBoxText}
on:input={searchSuggestions}
on:focus={searchSuggestions}
on:blur={() => {
// A delay before clearing the suggestions allows the user to click on a suggestion
// Clicking the suggestion will trigger the blur event immediately, and the search won't happen
setTimeout(() => {
suggestions = { suggestions: [] };
}, 200);
}}
/>
<button
class="join-item btn w-16"
on:click={async () => {
page = 1;
videos = [];
await searchVideos("");
}}
>
<div class="h-6">
<SearchThinIcon />
</div>
</button>
</div>
<button
class="btn border border-neutral rounded-full mt-1"
on:click={searchFiltersComponent.show()}
<search>
<form
on:submit={async (e) => {
e.preventDefault();
page = 1;
videos = [];
await searchVideos("");
}}
>
<div class="h-6 w-8">
<FiltersIcon />
<div class="join w-full border border-neutral rounded-full">
<input
type="search"
dir="auto"
placeholder="{$translate('Search')}..."
class="join-item input w-full border border-neutral rounded-full"
bind:this={searchBox}
bind:value={searchBoxText}
on:input={searchSuggestions}
on:focus={searchSuggestions}
on:blur={() => {
// A delay before clearing the suggestions allows the user to click on a suggestion
// Clicking the suggestion will trigger the blur event immediately, and the search won't happen
setTimeout(() => {
suggestions = { suggestions: [] };
}, 200);
}}
/>
<button
type="button"
class="join-item btn w-16"
on:click={async () => {
page = 1;
videos = [];
await searchVideos("");
}}
>
<div class="h-6">
<SearchThinIcon />
</div>
</button>
</div>
{searchFiltersLabel}
</button>
{#if suggestions.suggestions.length > 0}
<ul
class="dropdown-content menu z-10 p-2 shadow-xl bg-base-200 rounded-box"
<button
type="button"
class="btn border border-neutral rounded-full mt-1"
on:click={searchFiltersComponent.show()}
>
{#each suggestions.suggestions as suggestion}
<li class="p-1">
<button
type="button"
on:click={async (e) => {
await suggestionClicked(e.currentTarget.innerText);
}}>{@html suggestion}</button
>
</li>
{/each}
</ul>
{/if}
</form>
<div class="h-6 w-8">
<FiltersIcon />
</div>
{searchFiltersLabel}
</button>
{#if suggestions.suggestions.length > 0}
<ul
class="dropdown-content menu z-10 p-2 shadow-xl bg-base-200 rounded-box"
>
{#each suggestions.suggestions as suggestion}
<li class="p-1">
<button
type="button"
on:click={async (e) => {
await suggestionClicked(e.currentTarget.innerText);
}}>{@html suggestion}</button
>
</li>
{/each}
</ul>
{/if}
</form>
</search>
</div>
<div>
@@ -207,6 +212,7 @@
{#if !isLoading && videos.length > 0 && searchBoxText}
<div class="flex justify-center items-center">
<button
type="button"
class="btn w-1/2"
on:click={async () => {
page++;
@@ -3,6 +3,7 @@
import { playletStateStore, translate } from "lib/Stores";
import VideoStartAt from "./VideoStartAt.svelte";
import VideoThumbnail from "./VideoThumbnail.svelte";
import { YoutubeJs } from "lib/Api/YoutubeJs";
export let videoId: string | undefined = undefined;
export let title: string | undefined = undefined;
@@ -42,11 +43,28 @@
});
async function playOnTv() {
await PlayletApi.playVideo(getVideoInfo());
const videoInfo = getVideoInfo();
await PlayletApi.playVideo(videoInfo);
}
async function playOnTvYtjs() {
const videoInfo = getVideoInfo() as any;
// measure length of time it takes to get video info
const start = performance.now();
const metadata = await YoutubeJs.getVideoInfo(videoId);
const end = performance.now();
console.log(`Time to get video info: ${end - start}ms`);
if (metadata) {
videoInfo.metadata = metadata;
}
await PlayletApi.playVideo(videoInfo);
}
async function queueOnTv() {
await PlayletApi.queueVideo(getVideoInfo());
const videoInfo = getVideoInfo();
await PlayletApi.queueVideo(videoInfo);
}
function openInvidious() {
@@ -121,6 +139,9 @@
<button class="btn join-item hover:btn-accent" on:click={playOnTv}>
{$translate("Play on %1").replace("%1", tvName)}
</button>
<button class="btn join-item hover:btn-accent" on:click={playOnTvYtjs}>
{$translate("Play on %1").replace("%1", tvName)} (ytjs)
</button>
<button class="btn join-item hover:btn-accent" on:click={queueOnTv}>
{$translate("Queue on %1").replace("%1", tvName)}
</button>