Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7577f89df6 | ||
|
|
b7183f3603 | ||
|
|
acd745c671 | ||
|
|
2ffbbe9361 | ||
|
|
ba5da82c55 | ||
|
|
61abc7c0b9 | ||
|
|
fde5eb53fa | ||
|
|
b5a921f206 | ||
|
|
bc8e70788b | ||
|
|
2401522aa6 | ||
|
|
e52f24c2b6 | ||
|
|
611e5fd373 | ||
|
|
fcd21e72e5 | ||
|
|
da85f182bb | ||
|
|
a79e820f2d | ||
|
|
89502757f0 | ||
|
|
40140e7e29 | ||
|
|
58c11ea07b | ||
|
|
be8c79c3d1 | ||
|
|
a30bf73d0f | ||
|
|
ee36c76e8f | ||
|
|
4bd5c11f42 | ||
|
|
669d4d2d8b | ||
|
|
f5297ac582 | ||
|
|
f2412a99ee | ||
|
|
c96f4605d7 | ||
|
|
56351035c6 | ||
|
|
12d9b25762 | ||
|
|
a049147149 | ||
|
|
317025087d | ||
|
|
ccad3705ac | ||
|
|
5b204f2095 | ||
|
|
7dd7c0a93b | ||
|
|
0c31ee1354 | ||
|
|
6822f12336 | ||
|
|
d6c776fbd5 |
No files matched your search
@@ -5,13 +5,16 @@ on:
|
|||||||
branches: ["main"]
|
branches: ["main"]
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: [self-hosted, roku]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -28,25 +31,41 @@ jobs:
|
|||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: npm run test
|
run: npm run test
|
||||||
env:
|
|
||||||
ROKU_DEV_TARGET: ${{ secrets.ROKU_DEV_TARGET }}
|
|
||||||
ROKU_DEV_TARGET_PORT: ${{ secrets.ROKU_DEV_TARGET_PORT }}
|
|
||||||
ROKU_DEVPASSWORD: ${{ secrets.ROKU_DEVPASSWORD }}
|
|
||||||
ROKU_DEV_TARGET_TELNET_PORT: ${{ secrets.ROKU_DEV_TARGET_TELNET_PORT }}
|
|
||||||
|
|
||||||
- name: Build Playlet for release
|
- name: Build Playlet for release
|
||||||
run: npm run build:release
|
run: npm run build:release
|
||||||
env:
|
|
||||||
ROKU_DEV_TARGET: ${{ secrets.ROKU_DEV_TARGET }}
|
|
||||||
ROKU_DEV_TARGET_PORT: ${{ secrets.ROKU_DEV_TARGET_PORT }}
|
|
||||||
ROKU_DEVPASSWORD: ${{ secrets.ROKU_DEVPASSWORD }}
|
|
||||||
ROKU_SIGN_PASSWORD: ${{ secrets.ROKU_SIGN_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Use Java 21
|
- name: Upload release
|
||||||
uses: actions/setup-java@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: release
|
||||||
|
path: |
|
||||||
|
release/playlet.zip
|
||||||
|
release/playlet.squashfs.pkg
|
||||||
|
release/playlet-lib.zip
|
||||||
|
release/playlet-lib.squashfs.pkg
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
publish:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Download release
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: release
|
||||||
|
path: release
|
||||||
|
|
||||||
|
- name: Use Java 25
|
||||||
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
java-version: "21"
|
java-version: "25"
|
||||||
|
|
||||||
- name: Download the Static Channel Analysis CLI
|
- name: Download the Static Channel Analysis CLI
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -5,6 +5,15 @@ 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.48.11] - 2026-11-21
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- DRM playback errors on certain TVs, by filtering out FairPlay-only streams
|
||||||
|
- Player seek bar and backdrop missing on some devices
|
||||||
|
- Missing titles in shorts
|
||||||
|
- Always set seek mode to `accurate`
|
||||||
|
|
||||||
## [0.48.10] - 2026-10-17
|
## [0.48.10] - 2026-10-17
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.48.10",
|
"version": "0.48.11",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.48.10",
|
"version": "0.48.11",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rokucommunity/bslint": "^0.8.46",
|
"@rokucommunity/bslint": "^0.8.46",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.48.10",
|
"version": "0.48.11",
|
||||||
"description": "Unofficial YouTube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rokucommunity/bslint": "^0.8.46",
|
"@rokucommunity/bslint": "^0.8.46",
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.48.10",
|
"version": "0.48.11",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.48.10"
|
"version": "0.48.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.48.10",
|
"version": "0.48.11",
|
||||||
"description": "Unofficial YouTube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "node ../tools/rm.js ../build/playlet-app",
|
"prebuild": "node ../tools/rm.js ../build/playlet-app",
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ function GetPlayletLibUrls() as object
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function LoadPlayletLib() as void
|
function LoadPlayletLib() as void
|
||||||
|
RemoveComponentLibrary()
|
||||||
|
|
||||||
if m.playletLibUrlIndex >= m.playletLibUrls.Count()
|
if m.playletLibUrlIndex >= m.playletLibUrls.Count()
|
||||||
m.loadingIndicator.visible = false
|
m.loadingIndicator.visible = false
|
||||||
if m.shouldClearRegistryOnLoadFail = true
|
if m.shouldClearRegistryOnLoadFail = true
|
||||||
@@ -56,7 +58,6 @@ function LoadPlayletLib() as void
|
|||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
RemoveComponentLibrary()
|
|
||||||
uri = m.playletLibUrls[m.playletLibUrlIndex].link
|
uri = m.playletLibUrls[m.playletLibUrlIndex].link
|
||||||
LoadComponentLibrary(uri)
|
LoadComponentLibrary(uri)
|
||||||
end function
|
end function
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ 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=48
|
minor_version=48
|
||||||
build_version=00010
|
build_version=00018
|
||||||
|
|
||||||
rsg_version=1.3
|
rsg_version=1.3
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ requires_widevine_version=1.0
|
|||||||
playlet_lib_squashfs_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.squashfs.pkg
|
playlet_lib_squashfs_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.squashfs.pkg
|
||||||
playlet_lib_zip_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.zip
|
playlet_lib_zip_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.zip
|
||||||
playlet_lib_zip_embedded_url=pkg:/lib/playlet-lib.zip
|
playlet_lib_zip_embedded_url=pkg:/lib/playlet-lib.zip
|
||||||
playlet_lib_zip_debug_url=http://DEBUG_HOST_IP_ADDRESS:8086/playlet-lib.zip
|
playlet_lib_zip_debug_url=https://gitea.spaghet.io/spaghet/playlet-piped/raw/branch/piped-features/piped/playlet-lib-1795574696.zip
|
||||||
|
|
||||||
git_commit_sha=unknown
|
git_commit_sha=unknown
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.48.10",
|
"version": "0.48.11",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.48.10"
|
"version": "0.48.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.48.10",
|
"version": "0.48.11",
|
||||||
"description": "Unofficial YouTube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "node ../tools/rm.js ../build/playlet-lib",
|
"prebuild": "node ../tools/rm.js ../build/playlet-lib",
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ function Init()
|
|||||||
m.urlLabel = m.top.findNode("urlLabel")
|
m.urlLabel = m.top.findNode("urlLabel")
|
||||||
m.qrCode = m.top.findNode("QrCodePoster")
|
m.qrCode = m.top.findNode("QrCodePoster")
|
||||||
|
|
||||||
|
' loginKind is assigned by the caller AFTER CreateObject returns, so any
|
||||||
|
' relabeling based on it must live in OnNodeReady, never here.
|
||||||
|
|
||||||
m.top.width = "920"
|
m.top.width = "920"
|
||||||
m.top.observeFieldScoped("buttonSelected", FuncName(Close))
|
m.top.observeFieldScoped("buttonSelected", FuncName(Close))
|
||||||
|
|
||||||
@@ -15,10 +18,21 @@ function Init()
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function OnNodeReady()
|
function OnNodeReady()
|
||||||
|
if ValidString(m.top.loginKind) = "piped"
|
||||||
|
m.top.findNode("dlgTitle").primaryTitle = "Login to Piped"
|
||||||
|
m.top.findNode("bodyLine1").text = "Login to Piped in order to view Subscriptions and Playlists."
|
||||||
|
m.top.findNode("bodyLine2").text = "Sign in from your phone with SSO, or with a Piped username and password."
|
||||||
|
end if
|
||||||
|
|
||||||
address = m.webserver@.GetServerAddress()
|
address = m.webserver@.GetServerAddress()
|
||||||
isValidAddress = not StringUtils.IsNullOrEmpty(address)
|
isValidAddress = not StringUtils.IsNullOrEmpty(address)
|
||||||
if isValidAddress
|
if isValidAddress
|
||||||
url = `${address}/invidious/login`
|
loginKind = ValidString(m.top.loginKind)
|
||||||
|
if loginKind = "piped"
|
||||||
|
url = `${address}/piped/login`
|
||||||
|
else
|
||||||
|
url = `${address}/invidious/login`
|
||||||
|
end if
|
||||||
profileId = m.top.profileId
|
profileId = m.top.profileId
|
||||||
if not StringUtils.IsNullOrEmpty(profileId)
|
if not StringUtils.IsNullOrEmpty(profileId)
|
||||||
url = UrlUtils.AppendQueryParams(url, { profile: profileId })
|
url = UrlUtils.AppendQueryParams(url, { profile: profileId })
|
||||||
|
|||||||
@@ -4,13 +4,14 @@
|
|||||||
<field id="profilesService" type="node" bind="/ProfilesService" />
|
<field id="profilesService" type="node" bind="/ProfilesService" />
|
||||||
<field id="url" type="string" onChange="OnUrlSet" />
|
<field id="url" type="string" onChange="OnUrlSet" />
|
||||||
<field id="profileId" type="string" />
|
<field id="profileId" type="string" />
|
||||||
|
<field id="loginKind" type="string" value="invidious" />
|
||||||
<field id="alwaysOnTop" type="boolean" />
|
<field id="alwaysOnTop" type="boolean" />
|
||||||
</interface>
|
</interface>
|
||||||
<children>
|
<children>
|
||||||
<StdDlgTitleArea primaryTitle="Login to Invidious" />
|
<StdDlgTitleArea id="dlgTitle" primaryTitle="Login to Invidious" />
|
||||||
<StdDlgContentArea>
|
<StdDlgContentArea>
|
||||||
<StdDlgTextItem text="Login to Invidious in order to view Subscriptions, Playlists, and use the Watch history." />
|
<StdDlgTextItem id="bodyLine1" text="Login to Invidious in order to view Subscriptions, Playlists, and use the Watch history." />
|
||||||
<StdDlgTextItem text="Please note that an Invidious account is different from a YouTube account." />
|
<StdDlgTextItem id="bodyLine2" text="Please note that an Invidious account is different from a YouTube account." />
|
||||||
</StdDlgContentArea>
|
</StdDlgContentArea>
|
||||||
<StdDlgButtonArea id="buttonArea">
|
<StdDlgButtonArea id="buttonArea">
|
||||||
<StdDlgButton text="OK" />
|
<StdDlgButton text="OK" />
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
|
import "pkg:/components/JobSystem/Jobs.bs"
|
||||||
|
import "pkg:/components/JobSystem/JobSystem.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.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"
|
||||||
import "TransportEvents.types.bs"
|
import "TransportEvents.types.bs"
|
||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
m.appManager = CreateObject("roAppManager")
|
scene = m.top.getScene()
|
||||||
m.videoQueue = m.top.getScene().findNode("VideoQueue")
|
m.videoQueue = scene.findNode("VideoQueue")
|
||||||
|
m.jobQueue = scene.findNode("JobQueue")
|
||||||
|
|
||||||
' TODO:P2 ok, forward, rewind, replay, next and skip need support in the player or the queue. Until then they
|
' TODO:P2 ok, forward, rewind, replay, next and skip need support in the player or the queue. Until then they
|
||||||
' have no entry here, and answer unhandled.
|
' have no entry here, and answer unhandled.
|
||||||
@@ -102,20 +105,25 @@ end function
|
|||||||
function NowPlayingCommand(_event as object) as string
|
function NowPlayingCommand(_event as object) as string
|
||||||
player = m.videoQueue.player
|
player = m.videoQueue.player
|
||||||
if player = invalid
|
if player = invalid
|
||||||
m.appManager.SetNowPlayingContentMetaData(invalid)
|
SetNowPlayingMetadata(invalid)
|
||||||
return TransportStatus.Success
|
return TransportStatus.Success
|
||||||
end if
|
end if
|
||||||
|
|
||||||
content = player.content
|
content = player.content
|
||||||
if content = invalid or StringUtils.IsNullOrEmpty(content.title)
|
if content = invalid or StringUtils.IsNullOrEmpty(content.title)
|
||||||
m.appManager.SetNowPlayingContentMetaData(invalid)
|
SetNowPlayingMetadata(invalid)
|
||||||
return TransportStatus.ErrorGeneric
|
return TransportStatus.ErrorGeneric
|
||||||
end if
|
end if
|
||||||
|
|
||||||
m.appManager.SetNowPlayingContentMetaData({ title: content.title, contentType: "movie" })
|
SetNowPlayingMetadata({ title: content.title, contentType: "movie" })
|
||||||
return TransportStatus.Success
|
return TransportStatus.Success
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
' roAppManager is MAIN|TASK-only
|
||||||
|
function SetNowPlayingMetadata(metadata as dynamic) as void
|
||||||
|
JobSystem.QueueJob(m.jobQueue, Jobs.SetNowPlayingMetadataJob, { metadata: metadata })
|
||||||
|
end function
|
||||||
|
|
||||||
function NotSupportedCommand(_event as object) as string
|
function NotSupportedCommand(_event as object) as string
|
||||||
return TransportStatus.ErrorChannel
|
return TransportStatus.ErrorChannel
|
||||||
end function
|
end function
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@job("SetNowPlayingMetadataJob")
|
||||||
|
function ExecuteJob() as void
|
||||||
|
appManager = CreateObject("roAppManager")
|
||||||
|
if appManager = invalid
|
||||||
|
JobError("Failed to create roAppManager object")
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
input = JobGetInput()
|
||||||
|
appManager.SetNowPlayingContentMetaData(input.metadata)
|
||||||
|
end function
|
||||||
@@ -40,6 +40,8 @@
|
|||||||
<BackendTypeContentNode id="BackendTypeYouTube" title="YouTube" backendLogoUri="pkg:/images/youtube-logo.png" />
|
<BackendTypeContentNode id="BackendTypeYouTube" title="YouTube" backendLogoUri="pkg:/images/youtube-logo.png" />
|
||||||
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||||
<BackendTypeContentNode id="BackendTypeInvidious" title="Invidious" backendLogoUri="pkg:/images/invidious-logo.png" />
|
<BackendTypeContentNode id="BackendTypeInvidious" title="Invidious" backendLogoUri="pkg:/images/invidious-logo.png" />
|
||||||
|
<!-- bs:disable-next-line LOCALE_MISSING_TRANSLATIONS -->
|
||||||
|
<BackendTypeContentNode id="BackendTypePiped" title="Piped" backendLogoUri="pkg:/images/piped-logo.png" />
|
||||||
</ContentNode>
|
</ContentNode>
|
||||||
</ContentNode>
|
</ContentNode>
|
||||||
</RowList>
|
</RowList>
|
||||||
|
|||||||
@@ -11,6 +11,14 @@ namespace LoginUtils
|
|||||||
m.top.getScene().dialog = dialog
|
m.top.getScene().dialog = dialog
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function ShowPipedLoginDialog(profileId = "" as string) as void
|
||||||
|
dialog = CreateObject("roSGNode", "InvidiousLoginDialog")
|
||||||
|
dialog.profileId = profileId
|
||||||
|
dialog.loginKind = "piped"
|
||||||
|
dialog@.BindNode()
|
||||||
|
m.top.getScene().dialog = dialog
|
||||||
|
end function
|
||||||
|
|
||||||
function ShowLoginWithYouTubeDisclaimerDialog() as void
|
function ShowLoginWithYouTubeDisclaimerDialog() as void
|
||||||
dialog = DialogUtils.ShowDialogEx({
|
dialog = DialogUtils.ShowDialogEx({
|
||||||
title: Tr(Locale.Dialogs.Disclaimer)
|
title: Tr(Locale.Dialogs.Disclaimer)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
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"
|
||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
m.normalFont = m.top.findNode("normalFont")
|
m.normalFont = m.top.findNode("normalFont")
|
||||||
@@ -53,7 +54,13 @@ function OnContentSet() as void
|
|||||||
backendType = content.type
|
backendType = content.type
|
||||||
if backendType = "invidious"
|
if backendType = "invidious"
|
||||||
m.top.serverUrl = content.serverUrl
|
m.top.serverUrl = content.serverUrl
|
||||||
m.top.backendTypePosterUri = "pkg:/images/invidious-logo.png"
|
' A Piped-backed profile is stored as an invidious profile (token
|
||||||
|
' shape + auth machinery reuse); the local router URL is the tell.
|
||||||
|
if InStr(LCase(ValidString(content.serverUrl)), "piped") > 0
|
||||||
|
m.top.backendTypePosterUri = "pkg:/images/piped-logo.png"
|
||||||
|
else
|
||||||
|
m.top.backendTypePosterUri = "pkg:/images/invidious-logo.png"
|
||||||
|
end if
|
||||||
else if backendType = "youtube"
|
else if backendType = "youtube"
|
||||||
m.top.serverUrl = "YouTube"
|
m.top.serverUrl = "YouTube"
|
||||||
m.top.backendTypePosterUri = "pkg:/images/youtube-logo.png"
|
m.top.backendTypePosterUri = "pkg:/images/youtube-logo.png"
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ function OnBackEndSelected(event as object) as void
|
|||||||
selectedBackendType = event.getData()
|
selectedBackendType = event.getData()
|
||||||
if selectedBackendType = "BackendTypeInvidious"
|
if selectedBackendType = "BackendTypeInvidious"
|
||||||
OnLoginWithInvidiousSelected()
|
OnLoginWithInvidiousSelected()
|
||||||
|
else if selectedBackendType = "BackendTypePiped"
|
||||||
|
LoginUtils.ShowPipedLoginDialog()
|
||||||
else if selectedBackendType = "BackendTypeYouTube"
|
else if selectedBackendType = "BackendTypeYouTube"
|
||||||
LoginUtils.ShowLoginWithYouTubeDisclaimerDialog()
|
LoginUtils.ShowLoginWithYouTubeDisclaimerDialog()
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -78,7 +78,13 @@ function OnContentSet() as void
|
|||||||
backendType = content.type
|
backendType = content.type
|
||||||
if backendType = "invidious"
|
if backendType = "invidious"
|
||||||
m.top.serverUrl = content.serverUrl
|
m.top.serverUrl = content.serverUrl
|
||||||
m.top.backendTypePosterUri = "pkg:/images/invidious-logo.png"
|
' A Piped-backed profile is stored as an invidious profile (token
|
||||||
|
' shape + auth machinery reuse); the local router URL is the tell.
|
||||||
|
if InStr(LCase(ValidString(content.serverUrl)), "piped") > 0
|
||||||
|
m.top.backendTypePosterUri = "pkg:/images/piped-logo.png"
|
||||||
|
else
|
||||||
|
m.top.backendTypePosterUri = "pkg:/images/invidious-logo.png"
|
||||||
|
end if
|
||||||
else if backendType = "youtube"
|
else if backendType = "youtube"
|
||||||
m.top.serverUrl = "YouTube"
|
m.top.serverUrl = "YouTube"
|
||||||
m.top.backendTypePosterUri = "pkg:/images/youtube-logo.png"
|
m.top.backendTypePosterUri = "pkg:/images/youtube-logo.png"
|
||||||
|
|||||||
@@ -267,6 +267,10 @@ class DashManifest
|
|||||||
continue for
|
continue for
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
if m.HasOnlyUnsupportedDrm(format)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
|
||||||
if (format.width = invalid or format.height = invalid) and not StringUtils.IsNullOrEmpty(format.size)
|
if (format.width = invalid or format.height = invalid) and not StringUtils.IsNullOrEmpty(format.size)
|
||||||
if format.size.instr("x") > 0
|
if format.size.instr("x") > 0
|
||||||
parts = format.size.Tokenize("x")
|
parts = format.size.Tokenize("x")
|
||||||
@@ -323,7 +327,12 @@ class DashManifest
|
|||||||
audioTrackId = format.audioTrack.id
|
audioTrackId = format.audioTrack.id
|
||||||
end if
|
end if
|
||||||
|
|
||||||
groupId = `${mimeType}-${justCodec}-${colorInfo}-${audioTrackId}${m.GetAudioVariantSuffix(format)}`
|
drmFamilies = ""
|
||||||
|
if IsArray(format.drmFamilies)
|
||||||
|
drmFamilies = format.drmFamilies.Join("+")
|
||||||
|
end if
|
||||||
|
|
||||||
|
groupId = `${mimeType}-${justCodec}-${colorInfo}-${audioTrackId}${m.GetAudioVariantSuffix(format)}-${drmFamilies}`
|
||||||
|
|
||||||
if groupInfo[groupId] = invalid
|
if groupInfo[groupId] = invalid
|
||||||
groupInfo[groupId] = []
|
groupInfo[groupId] = []
|
||||||
@@ -473,14 +482,7 @@ class DashManifest
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
||||||
if IsArray(firstFormat.drmFamilies)
|
m.AddContentProtection(xml, firstFormat)
|
||||||
for each drmFamily in firstFormat.drmFamilies
|
|
||||||
systemId = m.GetDrmSystemId(drmFamily)
|
|
||||||
if IsString(systemId)
|
|
||||||
xml.EmptyNode("ContentProtection", { "schemeIdUri": `urn:uuid:${systemId}` })
|
|
||||||
end if
|
|
||||||
end for
|
|
||||||
end if
|
|
||||||
|
|
||||||
if IsAssociativeArray(firstFormat.audioTrack) or firstFormat.isDrc = true or firstFormat.isVoiceBoost = true
|
if IsAssociativeArray(firstFormat.audioTrack) or firstFormat.isDrc = true or firstFormat.isVoiceBoost = true
|
||||||
' Roles
|
' Roles
|
||||||
@@ -574,14 +576,7 @@ class DashManifest
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
||||||
if IsArray(firstFormat.drmFamilies)
|
m.AddContentProtection(xml, firstFormat)
|
||||||
for each drmFamily in firstFormat.drmFamilies
|
|
||||||
systemId = m.GetDrmSystemId(drmFamily)
|
|
||||||
if IsString(systemId)
|
|
||||||
xml.EmptyNode("ContentProtection", { "schemeIdUri": `urn:uuid:${systemId}` })
|
|
||||||
end if
|
|
||||||
end for
|
|
||||||
end if
|
|
||||||
|
|
||||||
m.AddColorInfo(firstFormat, xml)
|
m.AddColorInfo(firstFormat, xml)
|
||||||
|
|
||||||
@@ -1015,6 +1010,32 @@ class DashManifest
|
|||||||
}
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
' DRM movies have formats whose only DRM family is FAIRPLAY, which no ContentProtection Roku supports can declare.
|
||||||
|
function HasOnlyUnsupportedDrm(format as object) as boolean
|
||||||
|
if not IsArray(format.drmFamilies) or format.drmFamilies.Count() = 0
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
for each drmFamily in format.drmFamilies
|
||||||
|
if IsString(m.GetDrmSystemId(drmFamily))
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
' A set's formats share their drmFamilies: CreateFormatGroupings keys groups on them.
|
||||||
|
function AddContentProtection(xml as object, format as object) as void
|
||||||
|
if not IsArray(format.drmFamilies)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
for each drmFamily in format.drmFamilies
|
||||||
|
systemId = m.GetDrmSystemId(drmFamily)
|
||||||
|
if IsString(systemId)
|
||||||
|
xml.EmptyNode("ContentProtection", { "schemeIdUri": `urn:uuid:${systemId}` })
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
end function
|
||||||
|
|
||||||
function GetDrmSystemId(drmFamily as dynamic) as dynamic
|
function GetDrmSystemId(drmFamily as dynamic) as dynamic
|
||||||
if not IsString(drmFamily)
|
if not IsString(drmFamily)
|
||||||
return invalid
|
return invalid
|
||||||
|
|||||||
@@ -1611,15 +1611,17 @@ namespace Innertube
|
|||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
title = ""
|
title = ParseText(ObjectUtils.Dig(nodeData, ["metadata", "tileMetadataRenderer", "title"]))
|
||||||
thumbnailOverlays = ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnailOverlays"])
|
if title = ""
|
||||||
if IsArray(thumbnailOverlays)
|
thumbnailOverlays = ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnailOverlays"])
|
||||||
for each overlay in thumbnailOverlays
|
if IsArray(thumbnailOverlays)
|
||||||
title = ParseText(ObjectUtils.Dig(overlay, ["tileMetadataRenderer", "title"]))
|
for each overlay in thumbnailOverlays
|
||||||
if title <> ""
|
title = ParseText(ObjectUtils.Dig(overlay, ["tileMetadataRenderer", "title"]))
|
||||||
exit for
|
if title <> ""
|
||||||
end if
|
exit for
|
||||||
end for
|
end if
|
||||||
|
end for
|
||||||
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
video = {
|
video = {
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
import "pkg:/source/services/HttpClient.bs"
|
|
||||||
import "pkg:/source/utils/UrlUtils.bs"
|
|
||||||
|
|
||||||
namespace Innertube
|
|
||||||
|
|
||||||
const DRM_PROBE_TIMEOUT_SECONDS = 15
|
|
||||||
const DRM_PROBE_DIR = "tmp:/drm_probe"
|
|
||||||
|
|
||||||
' Transport matrix against an OTF+DRM format whose segment-info fetch failed.
|
|
||||||
' Every variant returns 2xx on healthy googlevideo URLs, so any non-2xx is
|
|
||||||
' specific to this shape, and any 2xx is an escape to build playback on.
|
|
||||||
function ProbeOTFDrmFormat(format as object, requestHeaders as object, cancellation as object) as string
|
|
||||||
url = ValidString(format.url)
|
|
||||||
if url = ""
|
|
||||||
return "drm probe skipped: format has no url"
|
|
||||||
end if
|
|
||||||
|
|
||||||
rangeUrl = DrmProbeUrlWithParams(url, { range: "0-16383" })
|
|
||||||
sqUrl = DrmProbeUrlWithParams(url, { sq: "0", rn: "0" })
|
|
||||||
|
|
||||||
fs = CreateObject("roFileSystem")
|
|
||||||
fs.Delete(Innertube.DRM_PROBE_DIR)
|
|
||||||
fs.CreateDirectory(Innertube.DRM_PROBE_DIR)
|
|
||||||
|
|
||||||
postBody = CreateObject("roByteArray")
|
|
||||||
postBody.FromHexString("7800")
|
|
||||||
postBody.WriteFile(`${Innertube.DRM_PROBE_DIR}/post_body.bin`)
|
|
||||||
|
|
||||||
' Bare and sq responses are full media on a healthy URL — stream those to files
|
|
||||||
' instead of buffering them into strings.
|
|
||||||
variants = [
|
|
||||||
{ name: "GET bare", request: HttpClient.Get(url).SaveBodyToFile(`${Innertube.DRM_PROBE_DIR}/bare.bin`) }
|
|
||||||
{ name: "GET Range header", request: HttpClient.Get(url).Header("Range", "bytes=0-16383") }
|
|
||||||
{ name: "GET range param", request: HttpClient.Get(rangeUrl) }
|
|
||||||
{ name: "GET sq=0", request: HttpClient.Get(sqUrl).SaveBodyToFile(`${Innertube.DRM_PROBE_DIR}/sq.bin`) }
|
|
||||||
{ name: "POST empty range param", request: HttpClient.Post(rangeUrl) }
|
|
||||||
{ name: "POST {15:0} range param", request: HttpClient.Post(rangeUrl).FileBody(`${Innertube.DRM_PROBE_DIR}/post_body.bin`) }
|
|
||||||
]
|
|
||||||
|
|
||||||
for each variant in variants
|
|
||||||
variant.request.Headers(requestHeaders)
|
|
||||||
variant.request.AttemptTimeoutMs(Innertube.DRM_PROBE_TIMEOUT_SECONDS * 1000)
|
|
||||||
variant.request.Cancellation(cancellation)
|
|
||||||
variant.request.NoCache()
|
|
||||||
variant.pending = variant.request.Send()
|
|
||||||
end for
|
|
||||||
|
|
||||||
lines = [`drm probe itag=${format.itag} drmFamilies=${ValidArray(format.drmFamilies).Join(",")}`]
|
|
||||||
for each variant in variants
|
|
||||||
lines.Push(DrmProbeCollect(variant))
|
|
||||||
end for
|
|
||||||
|
|
||||||
fs.Delete(Innertube.DRM_PROBE_DIR)
|
|
||||||
|
|
||||||
return lines.Join(`\n`)
|
|
||||||
end function
|
|
||||||
|
|
||||||
function DrmProbeUrlWithParams(url as string, params as object) as string
|
|
||||||
queryComponents = UrlUtils.ParseQueryComponents(url)
|
|
||||||
queryComponents.Append(params)
|
|
||||||
return UrlUtils.SetQueryParams(url, queryComponents)
|
|
||||||
end function
|
|
||||||
|
|
||||||
function DrmProbeCollect(variant as object) as string
|
|
||||||
name = variant.name
|
|
||||||
response = variant.pending.Await()
|
|
||||||
|
|
||||||
if response.IsCancelled()
|
|
||||||
return `${name} -> cancelled`
|
|
||||||
end if
|
|
||||||
|
|
||||||
if response.IsTimedOut()
|
|
||||||
return `${name} -> timed out after ${Innertube.DRM_PROBE_TIMEOUT_SECONDS}s`
|
|
||||||
end if
|
|
||||||
|
|
||||||
return `${name} -> ${response.StatusCode()} headers=${ToString(response.Headers())}`
|
|
||||||
end function
|
|
||||||
|
|
||||||
end namespace
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import "pkg:/components/Services/Innertube/Context.bs"
|
import "pkg:/components/Services/Innertube/Context.bs"
|
||||||
import "pkg:/components/Services/Innertube/OTFDrmProbe.bs"
|
import "pkg:/source/services/HttpClient.bs"
|
||||||
|
import "pkg:/source/utils/UrlUtils.bs"
|
||||||
|
|
||||||
namespace Innertube
|
namespace Innertube
|
||||||
|
|
||||||
@@ -18,11 +19,10 @@ namespace Innertube
|
|||||||
|
|
||||||
const OTF_MAX_REQUEST_COUNT = 8
|
const OTF_MAX_REQUEST_COUNT = 8
|
||||||
|
|
||||||
function OTFGetSegmentInfo(adaptiveFormats as object, client as Innertube.ClientType, cancellation as object, playerResponseText as string) as void
|
function OTFGetSegmentInfo(adaptiveFormats as object, client as Innertube.ClientType, cancellation as object) as void
|
||||||
errors = {
|
errors = {
|
||||||
message: ""
|
message: ""
|
||||||
attachments: []
|
attachments: []
|
||||||
drmProbed: false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
formatsToProcess = []
|
formatsToProcess = []
|
||||||
@@ -62,7 +62,7 @@ namespace Innertube
|
|||||||
|
|
||||||
pendingFormat = pendingFormats.Shift()
|
pendingFormat = pendingFormats.Shift()
|
||||||
' returns false if processing should stop (e.g., cancelled)
|
' returns false if processing should stop (e.g., cancelled)
|
||||||
if not OTFProcessPendingFormat(pendingFormat.format, pendingFormat.pending, pendingFormat.filePath, segmentDurationsRegex, errors, requestHeaders, cancellation)
|
if not OTFProcessPendingFormat(pendingFormat.format, pendingFormat.pending, pendingFormat.filePath, segmentDurationsRegex, errors)
|
||||||
exit while
|
exit while
|
||||||
end if
|
end if
|
||||||
end while
|
end while
|
||||||
@@ -72,14 +72,6 @@ namespace Innertube
|
|||||||
|
|
||||||
fs.Delete("tmp:/otf_segments")
|
fs.Delete("tmp:/otf_segments")
|
||||||
|
|
||||||
if errors.drmProbed
|
|
||||||
errors.attachments.Push({
|
|
||||||
filename: "player_response.json"
|
|
||||||
content_type: "application/json"
|
|
||||||
data: playerResponseText
|
|
||||||
})
|
|
||||||
end if
|
|
||||||
|
|
||||||
if not StringUtils.IsNullOrEmpty(errors.message) or errors.attachments.Count() > 0
|
if not StringUtils.IsNullOrEmpty(errors.message) or errors.attachments.Count() > 0
|
||||||
LogTelemetryEvent({
|
LogTelemetryEvent({
|
||||||
level: "error"
|
level: "error"
|
||||||
@@ -110,7 +102,7 @@ namespace Innertube
|
|||||||
return request.Send()
|
return request.Send()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OTFProcessPendingFormat(format as object, pending as HttpClient.PendingResponse, filePath as string, segmentDurationsRegex as object, errors as object, requestHeaders as object, cancellation as object) as boolean
|
function OTFProcessPendingFormat(format as object, pending as HttpClient.PendingResponse, filePath as string, segmentDurationsRegex as object, errors as object) as boolean
|
||||||
response = pending.Await()
|
response = pending.Await()
|
||||||
|
|
||||||
if response.IsCancelled()
|
if response.IsCancelled()
|
||||||
@@ -119,10 +111,6 @@ namespace Innertube
|
|||||||
|
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
errors.message += `Failed to get segment info for itag ${format.itag}: ${response.ErrorMessage()}\n`
|
errors.message += `Failed to get segment info for itag ${format.itag}: ${response.ErrorMessage()}\n`
|
||||||
if IsArray(format.drmFamilies) and not errors.drmProbed
|
|
||||||
errors.drmProbed = true
|
|
||||||
errors.message += Innertube.ProbeOTFDrmFormat(format, requestHeaders, cancellation) + `\n`
|
|
||||||
end if
|
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ namespace Innertube
|
|||||||
|
|
||||||
if isOTF
|
if isOTF
|
||||||
LogDebug("Fetching OTF segment info")
|
LogDebug("Fetching OTF segment info")
|
||||||
OTFGetSegmentInfo(adaptiveFormats, client, cancellation, playerResponse.Text())
|
OTFGetSegmentInfo(adaptiveFormats, client, cancellation)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if isLive
|
if isLive
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace Invidious
|
|||||||
const INSTANCES_API = "https://api.invidious.io/instances.json?sort_by=type,users"
|
const INSTANCES_API = "https://api.invidious.io/instances.json?sort_by=type,users"
|
||||||
|
|
||||||
const PLAYLET_BUILT_IN_INSTANCE = "http://127.0.0.1:8888/playlet-invidious-backend"
|
const PLAYLET_BUILT_IN_INSTANCE = "http://127.0.0.1:8888/playlet-invidious-backend"
|
||||||
|
const PLAYLET_PIPED_BUILT_IN_INSTANCE = "http://127.0.0.1:8888/playlet-piped-backend"
|
||||||
const INSTANCE_EXAMPLE = "https://invidious.example.com"
|
const INSTANCE_EXAMPLE = "https://invidious.example.com"
|
||||||
|
|
||||||
const TOKEN_CALLBACK = "/invidious/token_callback"
|
const TOKEN_CALLBACK = "/invidious/token_callback"
|
||||||
@@ -82,6 +83,11 @@ namespace Invidious
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
backend = m.preferences["backend.selected"]
|
backend = m.preferences["backend.selected"]
|
||||||
|
if backend = "piped"
|
||||||
|
' Piped speaks its own API, not Invidious's; route through the
|
||||||
|
' local translation router that presents an Invidious-shaped facade.
|
||||||
|
return PLAYLET_PIPED_BUILT_IN_INSTANCE
|
||||||
|
end if
|
||||||
if backend = "invidious"
|
if backend = "invidious"
|
||||||
instance = m.GetInvidiousInstance()
|
instance = m.GetInvidiousInstance()
|
||||||
if not StringUtils.IsNullOrEmpty(instance)
|
if not StringUtils.IsNullOrEmpty(instance)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import "pkg:/components/Services/LoungeService/LoungeFraming.bs"
|
|
||||||
import "pkg:/components/Services/LoungeService/LoungeService.types.bs"
|
import "pkg:/components/Services/LoungeService/LoungeService.types.bs"
|
||||||
import "pkg:/source/services/HttpClient.bs"
|
import "pkg:/source/services/HttpClient.bs"
|
||||||
|
import "pkg:/source/utils/ByteArrayUtils.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.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"
|
||||||
@@ -71,10 +71,6 @@ class LoungeBackchannel
|
|||||||
m.closeReason = LoungeCloseReason.NotSent
|
m.closeReason = LoungeCloseReason.NotSent
|
||||||
return []
|
return []
|
||||||
end if
|
end if
|
||||||
if m.statusCode < 0
|
|
||||||
m.closeReason = LoungeCloseReason.Curl
|
|
||||||
return []
|
|
||||||
end if
|
|
||||||
if m.statusCode < 200 or m.statusCode >= 300
|
if m.statusCode < 200 or m.statusCode >= 300
|
||||||
m.closeReason = LoungeCloseReason.Http
|
m.closeReason = LoungeCloseReason.Http
|
||||||
return []
|
return []
|
||||||
@@ -97,25 +93,42 @@ class LoungeBackchannel
|
|||||||
return commands
|
return commands
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function CloseLabel() as string
|
' Frame = `<byteLength>\n<json>`, the length counted in BYTES. The answer is complete, so a malformed or cut-off
|
||||||
if m.closeReason = LoungeCloseReason.Curl or m.closeReason = LoungeCloseReason.Http
|
' frame ends the extraction: no later read can complete it.
|
||||||
return `${m.closeReason}_${Abs(m.statusCode)}`
|
|
||||||
end if
|
|
||||||
return m.closeReason
|
|
||||||
end function
|
|
||||||
|
|
||||||
private function ExtractFrames(text as string) as object
|
private function ExtractFrames(text as string) as object
|
||||||
body = CreateObject("roByteArray")
|
body = CreateObject("roByteArray")
|
||||||
body.FromAsciiString(text)
|
body.FromAsciiString(text)
|
||||||
result = LoungeFraming.Extract(body, 0)
|
frames = []
|
||||||
if result.nextPos < body.Count()
|
count = body.Count()
|
||||||
LogTelemetryEvent({
|
cursor = 0
|
||||||
level: "warning"
|
while cursor < count
|
||||||
message: `Lounge answer ended mid-frame, ${body.Count() - result.nextPos} bytes left: ${text}`
|
if body[cursor] = 10 or body[cursor] = 13
|
||||||
fingerprint: "lounge-partial-frame"
|
cursor += 1
|
||||||
})
|
continue while
|
||||||
end if
|
end if
|
||||||
return result.frames
|
frameStart = cursor
|
||||||
|
frameLength = 0
|
||||||
|
' Stops once the length exceeds the body: a frame that long can't be whole, and the integer can't overflow.
|
||||||
|
while cursor < count and body[cursor] >= 48 and body[cursor] <= 57 and frameLength <= count
|
||||||
|
frameLength = frameLength * 10 + body[cursor] - 48
|
||||||
|
cursor += 1
|
||||||
|
end while
|
||||||
|
if cursor < count and body[cursor] = 13
|
||||||
|
cursor += 1
|
||||||
|
end if
|
||||||
|
if cursor >= count or body[cursor] <> 10 or frameLength = 0 or count - cursor - 1 < frameLength
|
||||||
|
LogTelemetryEvent({
|
||||||
|
level: "warning"
|
||||||
|
message: `Lounge answer has a malformed or cut-off frame at byte ${frameStart} of ${count}: ${text}`
|
||||||
|
fingerprint: "lounge-partial-frame"
|
||||||
|
})
|
||||||
|
exit while
|
||||||
|
end if
|
||||||
|
dataStart = cursor + 1
|
||||||
|
frames.Push(ByteArrayUtils.Slice(body, dataStart, dataStart + frameLength).ToAsciiString())
|
||||||
|
cursor = dataStart + frameLength
|
||||||
|
end while
|
||||||
|
return frames
|
||||||
end function
|
end function
|
||||||
|
|
||||||
private function Receive(frames as object) as LoungeCommand[]
|
private function Receive(frames as object) as LoungeCommand[]
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
import "pkg:/source/utils/ByteArrayUtils.bs"
|
|
||||||
|
|
||||||
namespace LoungeBytes
|
|
||||||
|
|
||||||
function RangeToString(bytes as object, fromIndex as integer, toIndex as integer) as string
|
|
||||||
return ByteArrayUtils.Slice(bytes, fromIndex, toIndex).ToAsciiString()
|
|
||||||
end function
|
|
||||||
|
|
||||||
function IndexOfByte(bytes as object, fromIndex as integer, value as integer) as integer
|
|
||||||
last = bytes.Count() - 1
|
|
||||||
for i = fromIndex to last
|
|
||||||
if bytes[i] = value
|
|
||||||
return i
|
|
||||||
end if
|
|
||||||
end for
|
|
||||||
return -1
|
|
||||||
end function
|
|
||||||
|
|
||||||
end namespace
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
import "pkg:/components/Services/LoungeService/LoungeBytes.bs"
|
|
||||||
|
|
||||||
namespace LoungeFraming
|
|
||||||
|
|
||||||
' Frame = `<byteLength>\n<json>`, the length counted in BYTES. An incomplete trailing frame
|
|
||||||
' is left unconsumed (nextPos marks its start).
|
|
||||||
function Extract(body as object, startPos as integer) as object
|
|
||||||
frames = []
|
|
||||||
cursor = startPos
|
|
||||||
count = body.Count()
|
|
||||||
|
|
||||||
while true
|
|
||||||
while cursor < count and (body[cursor] = 13 or body[cursor] = 10)
|
|
||||||
cursor += 1
|
|
||||||
end while
|
|
||||||
if cursor >= count
|
|
||||||
exit while
|
|
||||||
end if
|
|
||||||
|
|
||||||
lf = LoungeBytes.IndexOfByte(body, cursor, 10)
|
|
||||||
if lf = -1
|
|
||||||
exit while
|
|
||||||
end if
|
|
||||||
|
|
||||||
frameLength = Int(Val(LoungeBytes.RangeToString(body, cursor, lf).Trim(), 10))
|
|
||||||
if frameLength <= 0
|
|
||||||
cursor = lf + 1
|
|
||||||
continue while
|
|
||||||
end if
|
|
||||||
|
|
||||||
dataStart = lf + 1
|
|
||||||
if count - dataStart < frameLength
|
|
||||||
exit while
|
|
||||||
end if
|
|
||||||
|
|
||||||
frames.Push(LoungeBytes.RangeToString(body, dataStart, dataStart + frameLength))
|
|
||||||
cursor = dataStart + frameLength
|
|
||||||
end while
|
|
||||||
|
|
||||||
return { frames: frames, nextPos: cursor }
|
|
||||||
end function
|
|
||||||
|
|
||||||
end namespace
|
|
||||||
@@ -151,21 +151,20 @@ function RunSession(api as LoungeApi, messagePort as object) as boolean
|
|||||||
continue while
|
continue while
|
||||||
end if
|
end if
|
||||||
|
|
||||||
closeLabel = backchannel.CloseLabel()
|
LogDebug("Backchannel closed:", backchannel.closeReason, backchannel.statusCode, "next:", nextStep)
|
||||||
LogDebug("Backchannel closed:", closeLabel, "next:", nextStep)
|
|
||||||
if nextStep = LoungeSessionStep.Drop
|
if nextStep = LoungeSessionStep.Drop
|
||||||
LogTelemetryEvent({
|
LogTelemetryEvent({
|
||||||
level: "error"
|
level: "error"
|
||||||
message: `Lounge session dropped: no poll delivered for ${sinceDelivered.TotalSeconds()} s, last close: ${closeLabel}`
|
message: `Lounge session dropped: no poll delivered for ${sinceDelivered.TotalSeconds()} s, last close: ${backchannel.closeReason} ${backchannel.statusCode}`
|
||||||
fingerprint: ["lounge-session-dropped", closeLabel]
|
fingerprint: ["lounge-session-dropped", backchannel.closeReason, backchannel.statusCode]
|
||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
end if
|
end if
|
||||||
if nextStep = LoungeSessionStep.Retry and backchannel.closeReason <> LoungeCloseReason.Timeout
|
if nextStep = LoungeSessionStep.Retry and backchannel.closeReason <> LoungeCloseReason.Timeout
|
||||||
LogTelemetryEvent({
|
LogTelemetryEvent({
|
||||||
level: "warning"
|
level: "warning"
|
||||||
message: "Lounge backchannel failure: " + closeLabel
|
message: `Lounge backchannel failure: ${backchannel.closeReason} ${backchannel.statusCode}`
|
||||||
fingerprint: "lounge-backchannel-" + closeLabel
|
fingerprint: ["lounge-backchannel", backchannel.closeReason, backchannel.statusCode]
|
||||||
})
|
})
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ enum LoungeCloseReason
|
|||||||
Stalled = "stalled"
|
Stalled = "stalled"
|
||||||
Timeout = "timeout"
|
Timeout = "timeout"
|
||||||
NotSent = "not_sent"
|
NotSent = "not_sent"
|
||||||
Curl = "curl"
|
|
||||||
Http = "http"
|
Http = "http"
|
||||||
end enum
|
end enum
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,810 @@
|
|||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
import "pkg:/source/utils/TimeUtils.bs"
|
||||||
|
|
||||||
|
' Converts Piped API responses (https://github.com/TeamPiped/Piped) into
|
||||||
|
' the JSON shapes Playlet expects from an Invidious /api/v1 backend.
|
||||||
|
' Piped serves its REST API at the instance root (no /api/v1 prefix).
|
||||||
|
namespace PipedToInvidious
|
||||||
|
|
||||||
|
function VideoFromPiped(item as object, index = invalid as dynamic) as object
|
||||||
|
videoId = ExtractVideoId(ValidString(item.url))
|
||||||
|
video = {
|
||||||
|
"videoId": videoId
|
||||||
|
"title": ValidString(item.title)
|
||||||
|
"author": ValidString(item.uploaderName)
|
||||||
|
"authorId": ExtractChannelId(ValidString(item.uploaderUrl))
|
||||||
|
"lengthSeconds": ValidInt(item.duration)
|
||||||
|
"viewCount": ValidInt(item.views)
|
||||||
|
"published": MillisToSeconds(item.uploaded)
|
||||||
|
"publishedText": ValidString(item.uploadedDate)
|
||||||
|
"videoThumbnails": ThumbnailsFromProxy(ValidString(item.thumbnail), videoId)
|
||||||
|
"type": "video"
|
||||||
|
"genre": []
|
||||||
|
}
|
||||||
|
if not StringUtils.IsNullOrEmpty(ValidString(item.uploaderAvatar))
|
||||||
|
video["authorThumbnails"] = [{ url: item.uploaderAvatar, width: 88, height: 88 }]
|
||||||
|
end if
|
||||||
|
if index <> invalid
|
||||||
|
video["index"] = index
|
||||||
|
end if
|
||||||
|
if item.isShort = true
|
||||||
|
video["isShort"] = true
|
||||||
|
end if
|
||||||
|
return video
|
||||||
|
end function
|
||||||
|
|
||||||
|
function VideosFromPiped(list as dynamic) as object
|
||||||
|
videos = []
|
||||||
|
if not IsArray(list)
|
||||||
|
return videos
|
||||||
|
end if
|
||||||
|
for each item in list
|
||||||
|
if type(item) = "roAssociativeArray" and item.type <> "channel" and item.type <> "playlist"
|
||||||
|
videos.push(VideoFromPiped(item))
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
return videos
|
||||||
|
end function
|
||||||
|
|
||||||
|
function PlaylistsFromPiped(list as dynamic) as object
|
||||||
|
playlists = []
|
||||||
|
if not IsArray(list)
|
||||||
|
return playlists
|
||||||
|
end if
|
||||||
|
for each item in list
|
||||||
|
if type(item) = "roAssociativeArray" and item.type = "playlist"
|
||||||
|
playlists.push({
|
||||||
|
"playlistId": ExtractPlaylistId(ValidString(item.url))
|
||||||
|
"title": ValidString(item.title)
|
||||||
|
"videoCount": ValidInt(item.videosCount)
|
||||||
|
"playlistThumbnail": ValidString(item.thumbnail)
|
||||||
|
"author": ValidString(item.uploaderName)
|
||||||
|
"authorId": ExtractChannelId(ValidString(item.uploaderUrl))
|
||||||
|
"type": "playlist"
|
||||||
|
})
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
return playlists
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ChannelsFromPiped(list as dynamic) as object
|
||||||
|
channels = []
|
||||||
|
if not IsArray(list)
|
||||||
|
return channels
|
||||||
|
end if
|
||||||
|
for each item in list
|
||||||
|
if type(item) = "roAssociativeArray" and item.type = "channel"
|
||||||
|
channels.push({
|
||||||
|
"authorId": ExtractChannelId(ValidString(item.url))
|
||||||
|
"author": ValidString(item.title)
|
||||||
|
"authorThumbnail": ValidString(item.avatar)
|
||||||
|
"authorThumbnails": [{ url: ValidString(item.avatar), width: 88, height: 88 }]
|
||||||
|
"description": ValidString(item.description)
|
||||||
|
"subCount": ValidInt(item.subscribers)
|
||||||
|
"handle": ValidString(item.handle)
|
||||||
|
"verified": item.verified = true
|
||||||
|
"type": "channel"
|
||||||
|
})
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
return channels
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetFirstNonEmpty(first as string, second as string) as string
|
||||||
|
if first <> ""
|
||||||
|
return first
|
||||||
|
end if
|
||||||
|
return second
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ChannelFromPiped(data as object, channelId as string) as object
|
||||||
|
' Piped /channel/{id} -> Invidious /api/v1/channels/{ucid}
|
||||||
|
result = {
|
||||||
|
"author": ValidString(data.name)
|
||||||
|
"authorId": GetFirstNonEmpty(ValidString(data.id), channelId)
|
||||||
|
"bannerUrl": ValidString(data.bannerUrl)
|
||||||
|
"description": ValidString(data.description)
|
||||||
|
"subCount": ValidInt(data.subscriberCount)
|
||||||
|
"relatedStreams": VideosFromPiped(data.relatedStreams)
|
||||||
|
"videos": VideosFromPiped(data.relatedStreams)
|
||||||
|
"tabs": ["videos"]
|
||||||
|
"tabsParams": { videos: "" }
|
||||||
|
"tabsTitles": {}
|
||||||
|
"authorBanners": []
|
||||||
|
}
|
||||||
|
nextpage = ValidString(data.nextpage)
|
||||||
|
if nextpage <> ""
|
||||||
|
result["continuation"] = Base64Encode(nextpage)
|
||||||
|
end if
|
||||||
|
if not StringUtils.IsNullOrEmpty(ValidString(data.bannerUrl))
|
||||||
|
result["authorBanners"] = [{ url: data.bannerUrl, width: 1060, height: 175 }]
|
||||||
|
end if
|
||||||
|
avatar = ValidString(data.avatarUrl)
|
||||||
|
if not StringUtils.IsNullOrEmpty(avatar)
|
||||||
|
result["authorThumbnails"] = [{ url: avatar, width: 88, height: 88 }, { url: avatar, width: 176, height: 176 }]
|
||||||
|
end if
|
||||||
|
return result
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ChannelTabFromPiped(data as object) as object
|
||||||
|
' Piped /channel/{id}?tabs=x or /nextpage/channel/{id} -> Invidious channel tab feed
|
||||||
|
videos = VideosFromPiped(data.relatedStreams)
|
||||||
|
result = { videos: videos }
|
||||||
|
nextpage = ValidString(data.nextpage)
|
||||||
|
if nextpage <> ""
|
||||||
|
result["continuation"] = Base64Encode(nextpage)
|
||||||
|
end if
|
||||||
|
return result
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ChannelPlaylistsFromPiped(data as object) as object
|
||||||
|
playlists = []
|
||||||
|
for each item in EnsureArray(data.relatedStreams)
|
||||||
|
if type(item) = "roAssociativeArray"
|
||||||
|
playlists.push({
|
||||||
|
"playlistId": ExtractPlaylistId(ValidString(item.url))
|
||||||
|
"title": ValidString(item.title)
|
||||||
|
"videoCount": ValidInt(item.videosCount)
|
||||||
|
"playlistThumbnail": ValidString(item.thumbnail)
|
||||||
|
"type": "playlist"
|
||||||
|
})
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
result = { playlists: playlists }
|
||||||
|
nextpage = ValidString(data.nextpage)
|
||||||
|
if nextpage <> ""
|
||||||
|
result["continuation"] = Base64Encode(nextpage)
|
||||||
|
end if
|
||||||
|
return result
|
||||||
|
end function
|
||||||
|
|
||||||
|
function PlaylistFromPiped(data as object, playlistId as string) as object
|
||||||
|
' Piped /playlists/{id} -> Invidious /api/v1/playlists/{plid}
|
||||||
|
videos = []
|
||||||
|
index = 0
|
||||||
|
for each item in EnsureArray(data.relatedStreams)
|
||||||
|
if type(item) = "roAssociativeArray"
|
||||||
|
videos.push(VideoFromPiped(item, index))
|
||||||
|
index += 1
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
result = {
|
||||||
|
"title": ValidString(data.name)
|
||||||
|
"playlistId": playlistId
|
||||||
|
"videoCount": ValidInt(data.videos)
|
||||||
|
"description": ValidString(data.description)
|
||||||
|
"author": ValidString(data.uploader)
|
||||||
|
"authorId": ExtractChannelId(ValidString(data.uploaderUrl))
|
||||||
|
"videos": videos
|
||||||
|
}
|
||||||
|
thumb = ValidString(data.thumbnailUrl)
|
||||||
|
if thumb <> ""
|
||||||
|
result["playlistThumbnail"] = thumb
|
||||||
|
end if
|
||||||
|
nextpage = ValidString(data.nextpage)
|
||||||
|
if nextpage <> ""
|
||||||
|
result["continuation"] = Base64Encode(nextpage)
|
||||||
|
end if
|
||||||
|
return result
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SearchFromPiped(data as object) as object
|
||||||
|
' Piped /search -> Invidious /api/v1/search
|
||||||
|
items = EnsureArray(data.items)
|
||||||
|
videos = []
|
||||||
|
playlists = []
|
||||||
|
channels = []
|
||||||
|
for each item in items
|
||||||
|
t = ValidString(item.type)
|
||||||
|
if t = "stream" or t = "video" or t = "shortVideo"
|
||||||
|
videos.push(VideoFromPiped(item))
|
||||||
|
else if t = "playlist"
|
||||||
|
playlists.push({
|
||||||
|
"playlistId": ExtractPlaylistId(ValidString(item.url))
|
||||||
|
"title": ValidString(item.title)
|
||||||
|
"videoCount": ValidInt(item.videosCount)
|
||||||
|
"playlistThumbnail": ValidString(item.thumbnail)
|
||||||
|
"author": ValidString(item.uploaderName)
|
||||||
|
"type": "playlist"
|
||||||
|
})
|
||||||
|
else if t = "channel"
|
||||||
|
channels.push({
|
||||||
|
"authorId": ExtractChannelId(ValidString(item.url))
|
||||||
|
"author": ValidString(item.title)
|
||||||
|
"authorThumbnail": ValidString(item.avatar)
|
||||||
|
"authorThumbnails": [{ url: ValidString(item.avatar), width: 88, height: 88 }]
|
||||||
|
"description": ValidString(item.description)
|
||||||
|
"subCount": ValidInt(item.subscribers)
|
||||||
|
"handle": ValidString(item.handle)
|
||||||
|
"verified": item.verified = true
|
||||||
|
"type": "channel"
|
||||||
|
})
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
' VideoRowList consumes result.items; interleave converted entries in
|
||||||
|
' relevance order (videos first, then channels, then playlists).
|
||||||
|
merged = []
|
||||||
|
for each v in videos
|
||||||
|
merged.push(v)
|
||||||
|
end for
|
||||||
|
for each c in channels
|
||||||
|
merged.push(c)
|
||||||
|
end for
|
||||||
|
for each pl in playlists
|
||||||
|
merged.push(pl)
|
||||||
|
end for
|
||||||
|
result = {
|
||||||
|
"items": merged
|
||||||
|
"videos": videos
|
||||||
|
"playlists": playlists
|
||||||
|
"channels": channels
|
||||||
|
}
|
||||||
|
nextpage = ValidString(data.nextpage)
|
||||||
|
if nextpage <> ""
|
||||||
|
result["continuation"] = Base64Encode(nextpage)
|
||||||
|
end if
|
||||||
|
return result
|
||||||
|
end function
|
||||||
|
|
||||||
|
function VideoMetadataFromPiped(data as object, videoId as string) as object
|
||||||
|
' Piped /streams/{id} -> Invidious /api/v1/videos/:id (plus Playlet's
|
||||||
|
' innertube-ish playback fields: adaptiveFormats/formatStreams/hlsUrl/captions)
|
||||||
|
meta = {
|
||||||
|
"videoId": videoId
|
||||||
|
"title": ValidString(data.title)
|
||||||
|
"author": ValidString(data.uploader)
|
||||||
|
"authorId": ExtractChannelId(ValidString(data.uploaderUrl))
|
||||||
|
"lengthSeconds": ValidInt(data.duration)
|
||||||
|
"viewCount": ValidInt(data.views)
|
||||||
|
"published": MillisToSeconds(data.uploaded)
|
||||||
|
"description": ValidString(data.description)
|
||||||
|
"genre": EnsureArray(data.tags)
|
||||||
|
"videoThumbnails": ThumbnailsFromProxy(ValidString(data.thumbnailUrl), videoId)
|
||||||
|
"adaptiveFormats": []
|
||||||
|
"formatStreams": []
|
||||||
|
"captions": []
|
||||||
|
"qualityLevels": []
|
||||||
|
"relatedVideos": VideosFromPiped(data.relatedStreams)
|
||||||
|
"recommendedVideos": VideosFromPiped(data.relatedStreams)
|
||||||
|
"storyboards": []
|
||||||
|
"type": "video"
|
||||||
|
' Mark as our own parser shape so nothing tries innertube-only paths
|
||||||
|
"parser": "piped"
|
||||||
|
' Piped proxies signed googlevideo URLs already; Playlet can use them directly
|
||||||
|
"hlsUrl": ValidString(data.hls)
|
||||||
|
"dashUrl": ValidString(data.dash)
|
||||||
|
}
|
||||||
|
avatar = ValidString(data.uploaderAvatar)
|
||||||
|
if avatar <> ""
|
||||||
|
meta["authorThumbnails"] = [{ url: avatar, width: 88, height: 88 }]
|
||||||
|
end if
|
||||||
|
if data.livestream = true
|
||||||
|
meta["liveNow"] = true
|
||||||
|
end if
|
||||||
|
|
||||||
|
' Stream selection: prefer the HLS master (Piped's `hls` - AVC + fMP4
|
||||||
|
' up to 1080p, handled by Playlet's HlsRouter: segment rewriting,
|
||||||
|
' storyboards, quality filter, optional proxying). Only fall back to
|
||||||
|
' muxed progressive mp4 when there is no HLS master at all.
|
||||||
|
' adaptiveFormats stays empty on purpose: Piped reports fMP4 byte
|
||||||
|
' ranges (initStart/indexStart ints), not the init/index URLs that
|
||||||
|
' Playlet's DASH generator expects.
|
||||||
|
if StringUtils.IsNullOrEmpty(ValidString(data.hls))
|
||||||
|
for each stream in EnsureArray(data.videoStreams)
|
||||||
|
if type(stream) <> "roAssociativeArray"
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
if stream.videoOnly = false and stream.format = "MP4"
|
||||||
|
meta.formatStreams.push(MuxedFromPiped(stream))
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
end if
|
||||||
|
|
||||||
|
' Quality ladder for the player's quality control: the heights the
|
||||||
|
' backend actually serves, highest first, deduplicated.
|
||||||
|
' (The router fills this from the HLS master manifest - videoStreams
|
||||||
|
' is unreliable: often empty or short of the master's top rungs.)
|
||||||
|
|
||||||
|
for each caption in EnsureArray(data.subtitles)
|
||||||
|
if type(caption) <> "roAssociativeArray"
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
url = ValidString(caption.url)
|
||||||
|
if url.StartsWith("//")
|
||||||
|
url = "https:" + url
|
||||||
|
end if
|
||||||
|
label = ValidString(caption.name)
|
||||||
|
if label = ""
|
||||||
|
label = ValidString(caption.code)
|
||||||
|
end if
|
||||||
|
meta.captions.push({
|
||||||
|
"url": url
|
||||||
|
language_code: ValidString(caption.code)
|
||||||
|
"label": label
|
||||||
|
auto_generated: caption.autoGenerated = true
|
||||||
|
})
|
||||||
|
end for
|
||||||
|
|
||||||
|
' Piped previewFrames -> Playlet's storyboard shape (see
|
||||||
|
' Innertube PlayerEndpoint.ParseStoryboards): templateUrl/width/height/
|
||||||
|
' count/interval/storyboardWidth/storyboardHeight/storyboardCount.
|
||||||
|
for each pf in EnsureArray(data.previewFrames)
|
||||||
|
if type(pf) <> "roAssociativeArray"
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
urls = EnsureArray(pf.urls)
|
||||||
|
if urls.Count() > 0
|
||||||
|
frameW = ValidInt(pf.frameWidth)
|
||||||
|
frameH = ValidInt(pf.frameHeight)
|
||||||
|
cols = ValidInt(pf.framesPerPageX)
|
||||||
|
rows = ValidInt(pf.framesPerPageY)
|
||||||
|
total = ValidInt(pf.totalCount)
|
||||||
|
interval = ValidInt(pf.durationPerFrame)
|
||||||
|
perImage = cols * rows
|
||||||
|
imagesCount = 0
|
||||||
|
if perImage > 0
|
||||||
|
imagesCount = total \ perImage
|
||||||
|
if total mod perImage > 0
|
||||||
|
imagesCount += 1
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
' Playlet's storyboard manifest substitutes $M with the page
|
||||||
|
' index; Piped hands us the first page as ".../M0.jpg".
|
||||||
|
templateUrl = ValidString(urls[0])
|
||||||
|
if templateUrl.InStr("M0.") > 0
|
||||||
|
templateUrl = templateUrl.Replace("M0.", "$M.")
|
||||||
|
end if
|
||||||
|
meta.storyboards.push({
|
||||||
|
"templateUrl": templateUrl
|
||||||
|
"width": frameW
|
||||||
|
"height": frameH
|
||||||
|
"count": total
|
||||||
|
"interval": interval
|
||||||
|
"storyboardWidth": cols
|
||||||
|
"storyboardHeight": rows
|
||||||
|
"storyboardCount": imagesCount
|
||||||
|
})
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
return meta
|
||||||
|
end function
|
||||||
|
|
||||||
|
function FormatFromPiped(stream as object) as object
|
||||||
|
codec = CodecId(ValidString(stream.codec))
|
||||||
|
mime = ValidString(stream.mimeType)
|
||||||
|
container = ContainerFromMime(mime)
|
||||||
|
isVideo = ValidInt(stream.height) > 0
|
||||||
|
format = {
|
||||||
|
"url": ValidString(stream.url)
|
||||||
|
"itag": ValidInt(stream.itag)
|
||||||
|
"container": container
|
||||||
|
"codec": codec
|
||||||
|
mime_type: mime
|
||||||
|
"bitrate": ValidInt(stream.bitrate)
|
||||||
|
"contentLength": ValidInt(stream.contentLength)
|
||||||
|
"quality": QualityLabel(stream.quality)
|
||||||
|
"qualityLabel": QualityLabel(stream.quality)
|
||||||
|
"fps": ValidInt(stream.fps)
|
||||||
|
"width": ValidInt(stream.width)
|
||||||
|
"height": ValidInt(stream.height)
|
||||||
|
"init": ""
|
||||||
|
"index": ""
|
||||||
|
"approxDurationMs": ""
|
||||||
|
"audioSampleRate": ""
|
||||||
|
"aspectRatio": ""
|
||||||
|
"projectionType": ""
|
||||||
|
"averageBitrate": ValidInt(stream.bitrate)
|
||||||
|
}
|
||||||
|
if isVideo
|
||||||
|
format["type"] = `video; codecs="` + codec + `"`
|
||||||
|
else
|
||||||
|
format["type"] = `audio; codecs="` + codec + `"`
|
||||||
|
end if
|
||||||
|
' fMP4 segment ranges (Piped exposes them; Invidious uses init/index URLs).
|
||||||
|
' YouTube googlevideo URLs support #offset syntax via initStart/initEnd params,
|
||||||
|
' but Playlet's DASH generator only needs init/index to be present or absent
|
||||||
|
' consistently: absent means "progressive bytes with byte ranges".
|
||||||
|
return format
|
||||||
|
end function
|
||||||
|
|
||||||
|
function MuxedFromPiped(stream as object) as object
|
||||||
|
format = FormatFromPiped(stream)
|
||||||
|
format["quality"] = QualityLabel(stream.quality)
|
||||||
|
return format
|
||||||
|
end function
|
||||||
|
|
||||||
|
function CommentsFromPiped(data as object) as object
|
||||||
|
' Piped /comments/{id} -> Invidious /api/v1/comments/:id
|
||||||
|
comments = []
|
||||||
|
for each item in EnsureArray(data.comments)
|
||||||
|
if type(item) <> "roAssociativeArray"
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
comment = {
|
||||||
|
"content": ValidString(item.commentText)
|
||||||
|
"author": ValidString(item.author)
|
||||||
|
"id": ValidString(item.commentId)
|
||||||
|
"published": ValidString(item.commentedTime)
|
||||||
|
"publishedText": ValidString(item.commentedTime)
|
||||||
|
"likeCount": ValidInt(item.likeCount)
|
||||||
|
"isPinned": item.pinned = true
|
||||||
|
"authorThumbnails": [{ url: ValidString(item.thumbnail), width: 88, height: 88 }]
|
||||||
|
"commentorUrl": ValidString(item.commentorUrl)
|
||||||
|
}
|
||||||
|
if item.hearted = true
|
||||||
|
comment["heart"] = true
|
||||||
|
end if
|
||||||
|
if item.creatorReplied = true
|
||||||
|
comment["creatorReplied"] = true
|
||||||
|
end if
|
||||||
|
if ValidInt(item.replyCount) > 0
|
||||||
|
replies = {
|
||||||
|
"replyCount": ValidInt(item.replyCount)
|
||||||
|
}
|
||||||
|
rp = ValidString(item.repliesPage)
|
||||||
|
if rp <> ""
|
||||||
|
replies["continuation"] = Base64Encode(rp)
|
||||||
|
end if
|
||||||
|
comment["replies"] = replies
|
||||||
|
end if
|
||||||
|
comments.push(comment)
|
||||||
|
end for
|
||||||
|
result = {
|
||||||
|
"commentCount": ValidInt(data.commentCount)
|
||||||
|
"comments": comments
|
||||||
|
"internalContinuation": ""
|
||||||
|
}
|
||||||
|
np = ValidString(data.nextpage)
|
||||||
|
if np <> ""
|
||||||
|
result["continuation"] = Base64Encode(np)
|
||||||
|
end if
|
||||||
|
return result
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- helpers ----------------
|
||||||
|
|
||||||
|
function ExtractVideoId(url as string) as string
|
||||||
|
if url.InStr("v=") > 0
|
||||||
|
id = url.Mid(url.InStr("v=") + 2)
|
||||||
|
amp = id.InStr("&")
|
||||||
|
if amp > 0
|
||||||
|
id = id.Left(amp - 1)
|
||||||
|
end if
|
||||||
|
if id.Len() >= 11
|
||||||
|
return id.Left(11)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
return ""
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ExtractPlaylistId(url as string) as string
|
||||||
|
if url.InStr("list=") > 0
|
||||||
|
id = url.Mid(url.InStr("list=") + 5)
|
||||||
|
amp = id.InStr("&")
|
||||||
|
if amp > 0
|
||||||
|
id = id.Left(amp - 1)
|
||||||
|
end if
|
||||||
|
return id
|
||||||
|
end if
|
||||||
|
return ""
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ExtractChannelId(url as string) as string
|
||||||
|
if url.InStr("/channel/") > 0
|
||||||
|
id = url.Mid(url.InStr("/channel/") + 9)
|
||||||
|
q = id.InStr("?")
|
||||||
|
if q > 0
|
||||||
|
id = id.Left(q - 1)
|
||||||
|
end if
|
||||||
|
return id
|
||||||
|
end if
|
||||||
|
if url.InStr("/c/") > 0
|
||||||
|
return url.Mid(url.InStr("/c/") + 3)
|
||||||
|
end if
|
||||||
|
if url.InStr("/user/") > 0
|
||||||
|
return url.Mid(url.InStr("/user/") + 6)
|
||||||
|
end if
|
||||||
|
return ""
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ThumbnailsFromProxy(url as string, videoId as string) as object
|
||||||
|
thumbs = []
|
||||||
|
if not StringUtils.IsNullOrEmpty(url)
|
||||||
|
thumbs.push({ url: url, width: 320, height: 180, quality: "medium" })
|
||||||
|
thumbs.push({ url: url, width: 720, height: 404, quality: "high" })
|
||||||
|
thumbs.push({ url: url, width: 1280, height: 720, quality: "maxresdefault" })
|
||||||
|
end if
|
||||||
|
if thumbs.Count() = 0 and not StringUtils.IsNullOrEmpty(videoId)
|
||||||
|
thumbs.push({ url: `https://i.ytimg.com/vi/${videoId}/mqdefault.jpg`, width: 320, height: 180, quality: "medium" })
|
||||||
|
end if
|
||||||
|
return thumbs
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ContainerFromMime(mime as string) as string
|
||||||
|
mime = LCase(mime)
|
||||||
|
if mime.InStr("mp4") > 0
|
||||||
|
return "mp4"
|
||||||
|
end if
|
||||||
|
if mime.InStr("webm") > 0
|
||||||
|
return "webm"
|
||||||
|
end if
|
||||||
|
if mime.InStr("3gpp") > 0 or mime.InStr("3gp") > 0
|
||||||
|
return "3gp"
|
||||||
|
end if
|
||||||
|
return ""
|
||||||
|
end function
|
||||||
|
|
||||||
|
function CodecId(codec as string) as string
|
||||||
|
' Piped gives "vp9", "av01.0.05M.08", "avc1.4d001f", "opus", "mp4a.40.2"
|
||||||
|
c = LCase(codec)
|
||||||
|
if c = "opus"
|
||||||
|
return "opus"
|
||||||
|
end if
|
||||||
|
if c = "vorbis"
|
||||||
|
return "vorbis"
|
||||||
|
end if
|
||||||
|
if c.startsWith("mp4a")
|
||||||
|
return c
|
||||||
|
end if
|
||||||
|
if c.startsWith("avc1") or c.startsWith("av01") or c.startsWith("vp8") or c.startsWith("vp9")
|
||||||
|
return c
|
||||||
|
end if
|
||||||
|
if c = "h264"
|
||||||
|
return "avc1.4d001f"
|
||||||
|
end if
|
||||||
|
if c = "av1"
|
||||||
|
return "av01.0.05M.08"
|
||||||
|
end if
|
||||||
|
if c = ""
|
||||||
|
return "vp9"
|
||||||
|
end if
|
||||||
|
return c
|
||||||
|
end function
|
||||||
|
|
||||||
|
function QualityLabel(quality as dynamic) as string
|
||||||
|
q = UCase(ValidString(quality))
|
||||||
|
if q = ""
|
||||||
|
return "unknown"
|
||||||
|
end if
|
||||||
|
if q = "LBRY"
|
||||||
|
return "unknown"
|
||||||
|
end if
|
||||||
|
if q.Right(1) <> "P"
|
||||||
|
return q + "p"
|
||||||
|
end if
|
||||||
|
return LCase(q)
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Lowercase "1080p"-style ladder parsed from an HLS master manifest:
|
||||||
|
' every #EXT-X-STREAM-INF RESOLUTION= height, deduplicated, highest
|
||||||
|
' first. This is the ladder the /api/hls quality filter actually slices,
|
||||||
|
' so it is the only honest source for the picker.
|
||||||
|
function QualityLevelsFromHlsMaster(manifest as dynamic) as object
|
||||||
|
if not IsString(manifest) or manifest = ""
|
||||||
|
return []
|
||||||
|
end if
|
||||||
|
|
||||||
|
' Piped masters use CR-only line endings; normalize before splitting.
|
||||||
|
manifest = manifest.Replace(chr(13) + chr(10), chr(10))
|
||||||
|
manifest = manifest.Replace(chr(13), chr(10))
|
||||||
|
|
||||||
|
seen = {}
|
||||||
|
entries = []
|
||||||
|
for each line in manifest.Split(chr(10))
|
||||||
|
if not line.Trim().StartsWith("#EXT-X-STREAM-INF:")
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
resolution = StringUtils.GetBetween(line, "RESOLUTION=", ",")
|
||||||
|
if StringUtils.IsNullOrEmpty(resolution)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
parts = resolution.Split("x")
|
||||||
|
if parts.Count() <> 2
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
height = Val(parts[1])
|
||||||
|
if height <= 0
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
label = `${height}p`
|
||||||
|
if seen.DoesExist(label)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
seen[label] = true
|
||||||
|
entries.push({ "label": label, "height": height })
|
||||||
|
end for
|
||||||
|
|
||||||
|
' Insertion sort by descending height (ladders are tiny)
|
||||||
|
for i = 1 to entries.Count() - 1
|
||||||
|
entry = entries[i]
|
||||||
|
j = i - 1
|
||||||
|
while j >= 0
|
||||||
|
if entries[j].height >= entry.height
|
||||||
|
exit while
|
||||||
|
end if
|
||||||
|
entries[j + 1] = entries[j]
|
||||||
|
j = j - 1
|
||||||
|
end while
|
||||||
|
entries[j + 1] = entry
|
||||||
|
end for
|
||||||
|
|
||||||
|
labels = []
|
||||||
|
for each entry in entries
|
||||||
|
labels.push(entry.label)
|
||||||
|
end for
|
||||||
|
return labels
|
||||||
|
end function
|
||||||
|
|
||||||
|
function MillisToSeconds(millis as dynamic) as integer
|
||||||
|
' NOTE: on this device CDbl() of a boxed roLongInt behaves like a
|
||||||
|
' SINGLE-precision float: 1256453853000 -> truncates to low 32 bits,
|
||||||
|
' then rounds (2323402568 -> 2323402624 -> negative int). So never
|
||||||
|
' convert the full epoch-millis to float; do string arithmetic:
|
||||||
|
' seconds = int(str[:-3]) when the value looks like epoch millis,
|
||||||
|
' keeping every intermediate inside int32.
|
||||||
|
if millis = invalid
|
||||||
|
return 0
|
||||||
|
end if
|
||||||
|
|
||||||
|
s = ""
|
||||||
|
if getInterface(millis, "ifString") <> invalid
|
||||||
|
s = ValidString(millis)
|
||||||
|
else if getInterface(millis, "ifToStr") <> invalid
|
||||||
|
' boxed roInt/roLongInt/roDouble from roJSONParser: CDbl() on a
|
||||||
|
' roLongInt silently truncates to 32 bits on this firmware, so
|
||||||
|
' go through the decimal string instead
|
||||||
|
s = millis.ToStr()
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end if
|
||||||
|
s = s.Replace(" ", "")
|
||||||
|
|
||||||
|
' strip sign/decimals
|
||||||
|
if Left(s, 1) = "-"
|
||||||
|
s = s.Mid(2)
|
||||||
|
end if
|
||||||
|
dotIdx = InStr(s, ".")
|
||||||
|
if dotIdx > 0
|
||||||
|
s = s.Left(dotIdx - 1)
|
||||||
|
end if
|
||||||
|
|
||||||
|
if s = "" or s.Len() > 19
|
||||||
|
return 0
|
||||||
|
end if
|
||||||
|
|
||||||
|
for each c in s
|
||||||
|
if c < "0" or c > "9"
|
||||||
|
return 0
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
' epoch millis are 13 digits (2001-2286); 12 digits start 2001 too.
|
||||||
|
if s.Len() >= 12
|
||||||
|
' dropping the last 3 digits of epoch-millis yields epoch-seconds
|
||||||
|
' directly, and that value fits int32 until 2038
|
||||||
|
return Val(s.Left(s.Len() - 3))
|
||||||
|
end if
|
||||||
|
|
||||||
|
' already seconds (10 digits) or smaller
|
||||||
|
if s.Len() = 10
|
||||||
|
return Val(s)
|
||||||
|
end if
|
||||||
|
value = Val(s)
|
||||||
|
if value > 1000000000
|
||||||
|
return value
|
||||||
|
end if
|
||||||
|
return value / 1000
|
||||||
|
end function
|
||||||
|
|
||||||
|
function EnsureArray(value as dynamic) as object
|
||||||
|
if IsArray(value)
|
||||||
|
return value
|
||||||
|
end if
|
||||||
|
return []
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Base64Encode(text as string) as string
|
||||||
|
bytes = CreateObject("roByteArray")
|
||||||
|
bytes.FromAsciiString(text)
|
||||||
|
return bytes.ToBase64String()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Base64Decode(text as string) as string
|
||||||
|
bytes = CreateObject("roByteArray")
|
||||||
|
bytes.FromBase64String(text)
|
||||||
|
return bytes.ToAsciiString()
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- auth/profile token shapes ----------------
|
||||||
|
|
||||||
|
' Playlet stores invidious profile tokens as signed JSON and validates the
|
||||||
|
' scopes array + expire field client-side (VerifyTokenScope /
|
||||||
|
' DeriveAuthState). Piped's credential is a bare session UUID, so we wrap
|
||||||
|
' it in the same JSON shape here; the TV-side router unwraps it again
|
||||||
|
' before talking to Piped. The client only ever sends this blob to the
|
||||||
|
' local router, never to Piped itself.
|
||||||
|
function MakePipedTokenJson(username as string, sessionUuid as string, instance as string) as string
|
||||||
|
nowSeconds = TimeUtils.Now().AsSeconds()
|
||||||
|
expire = nowSeconds + 60 * 60 * 24 * 365 * 2
|
||||||
|
token = {
|
||||||
|
"token": sessionUuid
|
||||||
|
"user": ValidString(username)
|
||||||
|
"scopes": ["GET:feed", "GET:playlists*", "POST:tokens/*", ":history*", ":subscriptions*"]
|
||||||
|
"expire": expire
|
||||||
|
"lastUsed": nowSeconds * 1000
|
||||||
|
"createdAt": nowSeconds * 1000
|
||||||
|
}
|
||||||
|
return FormatJson(token)
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Accepts either the wrapped JSON or a bare UUID (defensive: manual seeding).
|
||||||
|
function ExtractPipedSession(accessToken as dynamic) as string
|
||||||
|
token = StringUtils.ParseJsonSafe(ValidString(accessToken))
|
||||||
|
if IsAssociativeArray(token) and not StringUtils.IsNullOrEmpty(ValidString(token.token))
|
||||||
|
return ValidString(token.token)
|
||||||
|
end if
|
||||||
|
s = ValidString(accessToken)
|
||||||
|
if not StringUtils.IsNullOrEmpty(s) and InStr(s, "{") = 0
|
||||||
|
return s
|
||||||
|
end if
|
||||||
|
return ""
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ExtractPipedUsername(accessToken as dynamic) as string
|
||||||
|
token = StringUtils.ParseJsonSafe(ValidString(accessToken))
|
||||||
|
if IsAssociativeArray(token)
|
||||||
|
return ValidString(token.user)
|
||||||
|
end if
|
||||||
|
return ""
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Piped /subscriptions item {url:/channel/UC.., name, avatar, verified}
|
||||||
|
' -> Invidious subscription {author, authorId, url, avatarURL, ...}
|
||||||
|
function SubscriptionsFromPiped(list as dynamic) as object
|
||||||
|
out = []
|
||||||
|
for each item in EnsureArray(list)
|
||||||
|
if not IsAssociativeArray(item)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
channelId = ExtractChannelId(ValidString(item.url))
|
||||||
|
out.push({
|
||||||
|
"author": ValidString(item.name)
|
||||||
|
"authorId": channelId
|
||||||
|
"url": `/api/v1/channels/${channelId}`
|
||||||
|
"avatarURL": ValidString(item.avatar)
|
||||||
|
"notifications": false
|
||||||
|
"playlistID": ""
|
||||||
|
})
|
||||||
|
end for
|
||||||
|
return out
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Piped /user/playlists item {id, name, thumbnail, videos?, updated?}
|
||||||
|
' -> Invidious playlist list item
|
||||||
|
function AuthPlaylistsFromPiped(list as dynamic) as object
|
||||||
|
out = []
|
||||||
|
for each item in EnsureArray(list)
|
||||||
|
if not IsAssociativeArray(item)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
updated = ValidInt(item.updated)
|
||||||
|
out.push({
|
||||||
|
"id": ValidString(item.id)
|
||||||
|
"type": "invidiousPlaylist"
|
||||||
|
"title": ValidString(item.name)
|
||||||
|
"url": `/playlist?list=${ValidString(item.id)}`
|
||||||
|
"author": ""
|
||||||
|
"authorId": ""
|
||||||
|
"description": ValidString(item.shortDescription)
|
||||||
|
"thumbnail": ValidString(item.thumbnail)
|
||||||
|
"videos": ValidInt(item.videos)
|
||||||
|
"updated": updated
|
||||||
|
"viewCount": 0
|
||||||
|
})
|
||||||
|
end for
|
||||||
|
return out
|
||||||
|
end function
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -49,7 +49,6 @@ namespace SponsorBlock
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
m.skipSegments = skipSegments
|
m.skipSegments = skipSegments
|
||||||
m.top.seekMode = "accurate"
|
|
||||||
|
|
||||||
barPath = info.data.barPath
|
barPath = info.data.barPath
|
||||||
if barPath <> invalid
|
if barPath <> invalid
|
||||||
|
|||||||
@@ -264,6 +264,9 @@ function ResolveBackendId(backend as string, service as Invidious.InvidiousServi
|
|||||||
if backend = "playlet"
|
if backend = "playlet"
|
||||||
return "playlet"
|
return "playlet"
|
||||||
end if
|
end if
|
||||||
|
if backend = "piped"
|
||||||
|
return "piped"
|
||||||
|
end if
|
||||||
if service.GetInstance() = Invidious.PLAYLET_BUILT_IN_INSTANCE
|
if service.GetInstance() = Invidious.PLAYLET_BUILT_IN_INSTANCE
|
||||||
return "built-in"
|
return "built-in"
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ function Init()
|
|||||||
m.trickplayUITimer = m.top.findNode("trickplayUITimer")
|
m.trickplayUITimer = m.top.findNode("trickplayUITimer")
|
||||||
m.trickplayUITimer.ObserveField("fire", FuncName(OnTrickplayUITimer))
|
m.trickplayUITimer.ObserveField("fire", FuncName(OnTrickplayUITimer))
|
||||||
m.top.notificationInterval = 1
|
m.top.notificationInterval = 1
|
||||||
|
m.top.seekMode = "accurate"
|
||||||
|
|
||||||
' videoPlayingSuccess indicates if we started playing a video successfully
|
' videoPlayingSuccess indicates if we started playing a video successfully
|
||||||
' We use it to detect if we should try another link for a video, or if another error
|
' We use it to detect if we should try another link for a video, or if another error
|
||||||
|
|||||||
@@ -19,13 +19,13 @@
|
|||||||
<!-- Dim side panels paint first (behind the tiles): VOD storyboard tiles cover them; on live (empty
|
<!-- Dim side panels paint first (behind the tiles): VOD storyboard tiles cover them; on live (empty
|
||||||
tiles) they show through as the filmstrip structure. -->
|
tiles) they show through as the filmstrip structure. -->
|
||||||
<Poster id="bifSideL2" translation="[-36, 42]" width="250" height="141" opacity="0.15"
|
<Poster id="bifSideL2" translation="[-36, 42]" width="250" height="141" opacity="0.15"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/GenevaTheme/Base/FHD/imageFootprint.9.png" loadDisplayMode="noScale" />
|
uri="pkg:/images/player/imageFootprint.9.png" loadDisplayMode="noScale" />
|
||||||
<Poster id="bifSideL1" translation="[226, 42]" width="250" height="141" opacity="0.15"
|
<Poster id="bifSideL1" translation="[226, 42]" width="250" height="141" opacity="0.15"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/GenevaTheme/Base/FHD/imageFootprint.9.png" loadDisplayMode="noScale" />
|
uri="pkg:/images/player/imageFootprint.9.png" loadDisplayMode="noScale" />
|
||||||
<Poster id="bifSideR1" translation="[804, 42]" width="250" height="141" opacity="0.15"
|
<Poster id="bifSideR1" translation="[804, 42]" width="250" height="141" opacity="0.15"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/GenevaTheme/Base/FHD/imageFootprint.9.png" loadDisplayMode="noScale" />
|
uri="pkg:/images/player/imageFootprint.9.png" loadDisplayMode="noScale" />
|
||||||
<Poster id="bifSideR2" translation="[1066, 42]" width="250" height="141" opacity="0.15"
|
<Poster id="bifSideR2" translation="[1066, 42]" width="250" height="141" opacity="0.15"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/GenevaTheme/Base/FHD/imageFootprint.9.png" loadDisplayMode="noScale" />
|
uri="pkg:/images/player/imageFootprint.9.png" loadDisplayMode="noScale" />
|
||||||
<!-- Storyboard tiles, oversized + clippingRect picks the cell; center has a gradient overlay + frame. -->
|
<!-- Storyboard tiles, oversized + clippingRect picks the cell; center has a gradient overlay + frame. -->
|
||||||
<Poster id="bifTileL2" loadDisplayMode="scaleToFill" />
|
<Poster id="bifTileL2" loadDisplayMode="scaleToFill" />
|
||||||
<Poster id="bifTileL1" loadDisplayMode="scaleToFill" />
|
<Poster id="bifTileL1" loadDisplayMode="scaleToFill" />
|
||||||
@@ -33,9 +33,9 @@
|
|||||||
<!-- ABOVE the center tile (the stock layering): keeps the white scan glyph legible over a bright
|
<!-- ABOVE the center tile (the stock layering): keeps the white scan glyph legible over a bright
|
||||||
frame. The glyph itself rides the TrickPlayBar handle, a later Chrome sibling. -->
|
frame. The glyph itself rides the TrickPlayBar handle, a later Chrome sibling. -->
|
||||||
<Poster id="bifCenterGradient" translation="[488, 12]" width="304" height="171"
|
<Poster id="bifCenterGradient" translation="[488, 12]" width="304" height="171"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/PauseGradientThumbnail.9.png" loadDisplayMode="noScale" />
|
uri="pkg:/images/player/PauseGradientThumbnail.png" loadDisplayMode="noScale" />
|
||||||
<Poster id="bifFrame" translation="[476, 0]" width="328" height="196"
|
<Poster id="bifFrame" translation="[476, 0]" width="328" height="196"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/GenevaTheme/Base/FHD/focus_grid.9.png" loadDisplayMode="noScale" />
|
uri="pkg:/images/player/focus_grid.$$RES$$.9.png" loadDisplayMode="noScale" />
|
||||||
<Poster id="bifTileR1" loadDisplayMode="scaleToFill" />
|
<Poster id="bifTileR1" loadDisplayMode="scaleToFill" />
|
||||||
<Poster id="bifTileR2" loadDisplayMode="scaleToFill" />
|
<Poster id="bifTileR2" loadDisplayMode="scaleToFill" />
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
@@ -9,9 +9,11 @@ const SCREEN_CENTER_X = 640
|
|||||||
const TRACKBAR_RIGHT_X = 1212
|
const TRACKBAR_RIGHT_X = 1212
|
||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
' Focus order MUST match PlayerCoordinatorLogic.PlayerButton (playPause=0, minimize=1).
|
' Focus order MUST match PlayerCoordinatorLogic.PlayerButton (playPause=0, quality=1, captions=2, minimize=3).
|
||||||
m.buttons = [
|
m.buttons = [
|
||||||
m.top.findNode("PlayPauseButton")
|
m.top.findNode("PlayPauseButton")
|
||||||
|
m.top.findNode("QualityButton")
|
||||||
|
m.top.findNode("CaptionsButton")
|
||||||
m.top.findNode("MinimizeButton")
|
m.top.findNode("MinimizeButton")
|
||||||
]
|
]
|
||||||
m.centerCluster = m.top.findNode("CenterCluster")
|
m.centerCluster = m.top.findNode("CenterCluster")
|
||||||
@@ -19,7 +21,7 @@ function Init()
|
|||||||
LayoutClusters()
|
LayoutClusters()
|
||||||
m.top.buttonCount = m.buttons.Count() ' coordinator reads this to clamp focus
|
m.top.buttonCount = m.buttons.Count() ' coordinator reads this to clamp focus
|
||||||
|
|
||||||
for each field in ["transportMode", "rowFocused", "focusedIndex", "playing"]
|
for each field in ["transportMode", "rowFocused", "focusedIndex", "playing", "statusText"]
|
||||||
m.top.ObserveField(field, FuncName(Repaint))
|
m.top.ObserveField(field, FuncName(Repaint))
|
||||||
end for
|
end for
|
||||||
m.top.ObserveField("nudge", FuncName(OnNudge))
|
m.top.ObserveField("nudge", FuncName(OnNudge))
|
||||||
|
|||||||
@@ -30,11 +30,12 @@ namespace Tests
|
|||||||
|
|
||||||
@it("exposes its button count and auto-positions the clusters (centered + right-aligned)")
|
@it("exposes its button count and auto-positions the clusters (centered + right-aligned)")
|
||||||
function _()
|
function _()
|
||||||
m.assertEqual(m.top.buttonCount, 2)
|
m.assertEqual(m.top.buttonCount, 4)
|
||||||
' one 42px button per cluster: centered on 640 -> x=619; right-aligned to 1212 -> x=1170. Pins the
|
' one 42px button in the center cluster (centered on 640 -> x=619); three in the right cluster
|
||||||
' ClusterWidth math so a drift in BUTTON_WIDTH/itemSpacings can't silently de-center.
|
' (3*42 + 2*20 = 166 wide, right-aligned to 1212 -> x=1046). Pins the ClusterWidth math so a
|
||||||
|
' drift in BUTTON_WIDTH/itemSpacings can't silently de-center.
|
||||||
m.assertEqual(m.top.findNode("CenterCluster").translation[0], 619.0)
|
m.assertEqual(m.top.findNode("CenterCluster").translation[0], 619.0)
|
||||||
m.assertEqual(m.top.findNode("RightCluster").translation[0], 1170.0)
|
m.assertEqual(m.top.findNode("RightCluster").translation[0], 1046.0)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@describe("virtual-focus highlight")
|
@describe("virtual-focus highlight")
|
||||||
@@ -52,7 +53,7 @@ namespace Tests
|
|||||||
m.top.focusedIndex = 0
|
m.top.focusedIndex = 0
|
||||||
m.assertTrue(m.top.findNode("PlayPauseButton").focused)
|
m.assertTrue(m.top.findNode("PlayPauseButton").focused)
|
||||||
m.assertFalse(m.top.findNode("MinimizeButton").focused)
|
m.assertFalse(m.top.findNode("MinimizeButton").focused)
|
||||||
m.top.focusedIndex = 1
|
m.top.focusedIndex = 3
|
||||||
m.assertFalse(m.top.findNode("PlayPauseButton").focused)
|
m.assertFalse(m.top.findNode("PlayPauseButton").focused)
|
||||||
m.assertTrue(m.top.findNode("MinimizeButton").focused)
|
m.assertTrue(m.top.findNode("MinimizeButton").focused)
|
||||||
end function
|
end function
|
||||||
@@ -62,7 +63,7 @@ namespace Tests
|
|||||||
@it("nudge pulses the focused button's animation")
|
@it("nudge pulses the focused button's animation")
|
||||||
function _()
|
function _()
|
||||||
m.top.rowFocused = true
|
m.top.rowFocused = true
|
||||||
m.top.focusedIndex = 1
|
m.top.focusedIndex = 3
|
||||||
anim = m.top.findNode("MinimizeButton").findNode("nudgeAnim")
|
anim = m.top.findNode("MinimizeButton").findNode("nudgeAnim")
|
||||||
anim.control = "stop"
|
anim.control = "stop"
|
||||||
m.top.nudge = true
|
m.top.nudge = true
|
||||||
|
|||||||
@@ -18,8 +18,10 @@
|
|||||||
<field id="focusedIndex" type="integer" value="0" />
|
<field id="focusedIndex" type="integer" value="0" />
|
||||||
<field id="playing" type="boolean" value="true" /> <!-- selects the play vs pause icon -->
|
<field id="playing" type="boolean" value="true" /> <!-- selects the play vs pause icon -->
|
||||||
<field id="buttonCount" type="integer" value="0" /> <!-- read-only: set in Init from m.buttons -->
|
<field id="buttonCount" type="integer" value="0" /> <!-- read-only: set in Init from m.buttons -->
|
||||||
<!-- pulse the focused button's scale nudge (a press that couldn't move focus: Left/Right clamped at
|
<!-- current quality + captions state, shown above the clusters (fed by the coordinator). -->
|
||||||
the row's ends, Up at the top tier). -->
|
<field id="statusText" type="string" alias="statusLabel.text" />
|
||||||
|
<!-- pulse the focused button's scale nudge: confirms a press that couldn't move focus (Left/Right at the row's end,
|
||||||
|
Up at the top tier). -->
|
||||||
<field id="nudge" type="boolean" alwaysNotify="true" />
|
<field id="nudge" type="boolean" alwaysNotify="true" />
|
||||||
</interface>
|
</interface>
|
||||||
<children>
|
<children>
|
||||||
@@ -29,10 +31,18 @@
|
|||||||
iconUri="pkg:/images/icons/player/play.png"
|
iconUri="pkg:/images/icons/player/play.png"
|
||||||
iconUri2="pkg:/images/icons/player/pause.png" />
|
iconUri2="pkg:/images/icons/player/pause.png" />
|
||||||
</Group>
|
</Group>
|
||||||
<!-- minimize, right-aligned to the trackbar's right edge (x=1212). -->
|
<!-- quality, captions, minimize, right-aligned to the trackbar's right edge (x=1212). -->
|
||||||
<Group id="RightCluster">
|
<Group id="RightCluster">
|
||||||
|
<VideoPlayerButton id="QualityButton"
|
||||||
|
iconUri="pkg:/images/icons/player/quality.png" />
|
||||||
|
<VideoPlayerButton id="CaptionsButton"
|
||||||
|
iconUri="pkg:/images/icons/player/captions.png" />
|
||||||
<VideoPlayerButton id="MinimizeButton"
|
<VideoPlayerButton id="MinimizeButton"
|
||||||
iconUri="pkg:/images/icons/player/minimize.png" />
|
iconUri="pkg:/images/icons/player/minimize.png" />
|
||||||
</Group>
|
</Group>
|
||||||
|
<Label id="statusLabel" translation="[68,522]" width="700" height="28"
|
||||||
|
color="0xFEFEFEFF" horizAlign="left" vertAlign="bottom" wrap="false">
|
||||||
|
<Font role="font" uri="font:SystemFontFile" size="22" />
|
||||||
|
</Label>
|
||||||
</children>
|
</children>
|
||||||
</component>
|
</component>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
<Timer id="hold" duration="1.0" repeat="false" />
|
<Timer id="hold" duration="1.0" repeat="false" />
|
||||||
|
|
||||||
<Poster id="poster" visible="false" opacity="0"
|
<Poster id="poster" visible="false" opacity="0"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/LargePause.png"
|
uri="pkg:/images/icons/player/LargePause.png"
|
||||||
width="80" height="80" translation="[600, 320]" scaleRotateCenter="[40, 40]"
|
width="80" height="80" translation="[600, 320]" scaleRotateCenter="[40, 40]"
|
||||||
scale="[0.75, 0.75]" blendColor="0xFFFFFFFF" loadDisplayMode="noScale" />
|
scale="[0.75, 0.75]" blendColor="0xFFFFFFFF" loadDisplayMode="noScale" />
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
@@ -14,9 +14,12 @@ end enum
|
|||||||
function Init()
|
function Init()
|
||||||
m.loadingGroup = m.top.findNode("loadingTitleArea")
|
m.loadingGroup = m.top.findNode("loadingTitleArea")
|
||||||
m.spinner = m.top.findNode("spinner")
|
m.spinner = m.top.findNode("spinner")
|
||||||
' blendColor lives on the BusySpinner's poster child, not the spinner node.
|
' blendColor and size live on the BusySpinner's poster child, not the spinner node. Sized explicitly: the
|
||||||
|
' bitmap's size in design units varies with the device's UI resolution.
|
||||||
if m.spinner <> invalid and m.spinner.poster <> invalid
|
if m.spinner <> invalid and m.spinner.poster <> invalid
|
||||||
m.spinner.poster.blendColor = "#FF1C30FF"
|
m.spinner.poster.blendColor = "#FF1C30FF"
|
||||||
|
m.spinner.poster.width = 80
|
||||||
|
m.spinner.poster.height = 80
|
||||||
end if
|
end if
|
||||||
m.top.ObserveField("mode", FuncName(OnMode))
|
m.top.ObserveField("mode", FuncName(OnMode))
|
||||||
OnMode()
|
OnMode()
|
||||||
|
|||||||
@@ -21,6 +21,6 @@
|
|||||||
</LayoutGroup>
|
</LayoutGroup>
|
||||||
<!-- Shared by both modes; translation centers the 80x80 spinner. -->
|
<!-- Shared by both modes; translation centers the 80x80 spinner. -->
|
||||||
<BusySpinner id="spinner" translation="[600, 320]" visible="false" spinInterval="1"
|
<BusySpinner id="spinner" translation="[600, 320]" visible="false" spinInterval="1"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/Spinner_MH.webp" />
|
uri="pkg:/images/icons/player/Spinner_MH.png" />
|
||||||
</children>
|
</children>
|
||||||
</component>
|
</component>
|
||||||
@@ -0,0 +1,337 @@
|
|||||||
|
import "pkg:/source/utils/CodecCapabilities.bs"
|
||||||
|
import "pkg:/source/utils/Locale.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
|
' Quality + captions control for the custom player (VideoPlayerDev). A plain
|
||||||
|
' .bs module like SponsorBlockController/TransportController - the coordinator
|
||||||
|
' owns the node and calls into this. Quality switching rebuilds the /api/hls
|
||||||
|
' proxy URL with a different `quality` filter (HlsRouter serves the filtered
|
||||||
|
' ladder) and restarts playback at the saved position; the selection persists
|
||||||
|
' to playback.preferred_quality so the next video starts the same way.
|
||||||
|
' Captions toggle the device's globalCaptionMode and pick a track when the OS
|
||||||
|
' language match finds none.
|
||||||
|
namespace PlaybackControls
|
||||||
|
|
||||||
|
class Controller
|
||||||
|
private top as object
|
||||||
|
private preferences as object
|
||||||
|
' cycle order: auto first, then the backend's ladder high -> low.
|
||||||
|
private qualityCycle as object = ["auto", "1080p", "720p", "480p", "360p", "240p", "144p"]
|
||||||
|
private captionsAvailable as boolean = false
|
||||||
|
' live height of the segment being streamed ("1080p"), shown next to Auto.
|
||||||
|
private liveHeightLabel as string = ""
|
||||||
|
' a quality switch in flight: the URL to swap in once the stop completes.
|
||||||
|
private pendingSwitchUrl as object = invalid
|
||||||
|
private pendingSeekSeconds as float = 0
|
||||||
|
private pendingWasPaused as boolean = false
|
||||||
|
' the picker's virtual cursor while open (-1 = closed)
|
||||||
|
private pickerFocusIndex as integer = -1
|
||||||
|
|
||||||
|
function new(deps as object)
|
||||||
|
m.top = deps.top
|
||||||
|
m.preferences = deps.preferences
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Content-job success: rebuild the cycle from the backend's ladder and
|
||||||
|
' note whether this video has captions at all.
|
||||||
|
function OnContentReady(metadata as object) as void
|
||||||
|
m.liveHeightLabel = ""
|
||||||
|
m.pendingSwitchUrl = invalid
|
||||||
|
|
||||||
|
m.captionsAvailable = false
|
||||||
|
if IsAssociativeArray(metadata)
|
||||||
|
captions = metadata.captions
|
||||||
|
m.captionsAvailable = IsArray(captions) and captions.Count() > 0
|
||||||
|
end if
|
||||||
|
|
||||||
|
levels = invalid
|
||||||
|
if IsAssociativeArray(metadata)
|
||||||
|
levels = metadata.qualityLevels
|
||||||
|
end if
|
||||||
|
|
||||||
|
known = {}
|
||||||
|
for each level in ["2160p", "1440p", "1080p", "720p", "480p", "360p", "240p", "144p"]
|
||||||
|
known[level] = true
|
||||||
|
end for
|
||||||
|
|
||||||
|
cycle = ["auto"]
|
||||||
|
if IsArray(levels) and levels.Count() > 0
|
||||||
|
seen = {}
|
||||||
|
for each level in levels
|
||||||
|
if known.DoesExist(level) and not seen.DoesExist(level)
|
||||||
|
' 1440p/2160p are AV1/VP9-only on YouTube-style backends
|
||||||
|
' (same decoder gate as the Settings QualitySelector).
|
||||||
|
if (level = "1440p" or level = "2160p") and not CodecCapabilities.CanDecodeAv1()
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
seen[level] = true
|
||||||
|
cycle.push(level)
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
else
|
||||||
|
for each level in ["1080p", "720p", "480p", "360p", "240p", "144p"]
|
||||||
|
cycle.push(level)
|
||||||
|
end for
|
||||||
|
end if
|
||||||
|
m.qualityCycle = cycle
|
||||||
|
end function
|
||||||
|
|
||||||
|
' streamingSegment edge: remember the height the player actually chose
|
||||||
|
' so "Auto" can show what it resolved to. Returns true when the label
|
||||||
|
' changed (the coordinator then refreshes the status line).
|
||||||
|
function OnStreamingSegment(segment as object) as boolean
|
||||||
|
if not IsAssociativeArray(segment)
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
height = 0
|
||||||
|
if IsInt(segment.height)
|
||||||
|
height = segment.height
|
||||||
|
end if
|
||||||
|
if height <= 0
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
label = `${height}p`
|
||||||
|
if label = m.liveHeightLabel
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
m.liveHeightLabel = label
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function CurrentQuality() as string
|
||||||
|
if m.preferences = invalid
|
||||||
|
return "auto"
|
||||||
|
end if
|
||||||
|
value = ValidString(m.preferences["playback.preferred_quality"])
|
||||||
|
if StringUtils.IsNullOrEmpty(value)
|
||||||
|
return "auto"
|
||||||
|
end if
|
||||||
|
return value
|
||||||
|
end function
|
||||||
|
|
||||||
|
function CaptionsOn() as boolean
|
||||||
|
if not m.top.hasField("globalCaptionMode")
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
return m.top.globalCaptionMode = "On"
|
||||||
|
end function
|
||||||
|
|
||||||
|
function QualityStatus() as string
|
||||||
|
quality = m.CurrentQuality()
|
||||||
|
display = quality
|
||||||
|
if quality = "auto"
|
||||||
|
display = Tr(Locale.Settings.AutoQuality)
|
||||||
|
if not StringUtils.IsNullOrEmpty(m.liveHeightLabel)
|
||||||
|
display = `${display} (${m.liveHeightLabel})`
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
return Tr(Locale.VideoPlayer.QualityButton).Replace("%1", display)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function CaptionsStatus() as string
|
||||||
|
if not m.captionsAvailable
|
||||||
|
return Tr(Locale.VideoPlayer.CaptionsUnavailableButton)
|
||||||
|
end if
|
||||||
|
if m.CaptionsOn()
|
||||||
|
return Tr(Locale.VideoPlayer.CaptionsOnButton)
|
||||||
|
end if
|
||||||
|
return Tr(Locale.VideoPlayer.CaptionsOffButton)
|
||||||
|
end function
|
||||||
|
|
||||||
|
' One line for the button-row status label.
|
||||||
|
function StatusSummary() as string
|
||||||
|
return m.QualityStatus() + " | " + m.CaptionsStatus()
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Quality button: open the picker list (the coordinator renders it; this holds the cursor).
|
||||||
|
function ActivateQuality() as void
|
||||||
|
m.pickerFocusIndex = m.AppliedIndex()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function EndPicker() as void
|
||||||
|
m.pickerFocusIndex = -1
|
||||||
|
end function
|
||||||
|
|
||||||
|
function PickerOpen() as boolean
|
||||||
|
return m.pickerFocusIndex >= 0
|
||||||
|
end function
|
||||||
|
|
||||||
|
function PickerCycle() as object
|
||||||
|
return m.qualityCycle
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Index of the rung matching the applied preference (auto = 0; a multi-quality value that is not a
|
||||||
|
' single rung shows no applied mark).
|
||||||
|
function AppliedIndex() as integer
|
||||||
|
current = m.CurrentQuality()
|
||||||
|
cycle = m.qualityCycle
|
||||||
|
for i = 0 to cycle.Count() - 1
|
||||||
|
if cycle[i] = current
|
||||||
|
return i
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
return 0
|
||||||
|
end function
|
||||||
|
|
||||||
|
function PickerFocusedIndex() as integer
|
||||||
|
if m.pickerFocusIndex < 0
|
||||||
|
return 0
|
||||||
|
end if
|
||||||
|
return m.pickerFocusIndex
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Move the virtual cursor; clamped at both ends (a list, not a cycle).
|
||||||
|
function MovePickerFocus(delta as integer) as void
|
||||||
|
if m.pickerFocusIndex < 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
nextIndex = m.pickerFocusIndex + delta
|
||||||
|
last = m.qualityCycle.Count() - 1
|
||||||
|
if nextIndex < 0
|
||||||
|
nextIndex = 0
|
||||||
|
else if nextIndex > last
|
||||||
|
nextIndex = last
|
||||||
|
end if
|
||||||
|
m.pickerFocusIndex = nextIndex
|
||||||
|
end function
|
||||||
|
|
||||||
|
' OK on an open picker: returns the rung under the cursor ("" = not open).
|
||||||
|
function ConfirmPicker() as string
|
||||||
|
if m.pickerFocusIndex < 0
|
||||||
|
return ""
|
||||||
|
end if
|
||||||
|
return ValidString(m.qualityCycle[m.pickerFocusIndex])
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ApplyQuality(quality as string) as void
|
||||||
|
content = m.top.content
|
||||||
|
if content = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
' The quality filter is always the last query param (VideoContentJob
|
||||||
|
' appends it); strip it from the current URL, then re-apply the pick.
|
||||||
|
urlParts = ValidString(content.url).Split("&quality=")
|
||||||
|
baseUrl = urlParts[0]
|
||||||
|
targetUrl = baseUrl
|
||||||
|
if quality <> "auto"
|
||||||
|
targetUrl = baseUrl + "&quality=" + quality
|
||||||
|
end if
|
||||||
|
|
||||||
|
' Keep the retry-fallback list consistent: register the new URL and
|
||||||
|
' point the index at it, so a later error walks off the end instead
|
||||||
|
' of replaying stale quality variants. (Field reads return a copy of
|
||||||
|
' the array, so the whole list is written back.)
|
||||||
|
urls = content.playletStreamUrls
|
||||||
|
if IsArray(urls)
|
||||||
|
foundIndex = -1
|
||||||
|
for i = 0 to urls.Count() - 1
|
||||||
|
if urls[i] = targetUrl
|
||||||
|
foundIndex = i
|
||||||
|
exit for
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
if foundIndex = -1
|
||||||
|
urls.push(targetUrl)
|
||||||
|
foundIndex = urls.Count() - 1
|
||||||
|
content.playletStreamUrls = urls
|
||||||
|
end if
|
||||||
|
content.playletStreamUrlIndex = foundIndex
|
||||||
|
end if
|
||||||
|
|
||||||
|
' Persist so the next video starts at this quality.
|
||||||
|
if m.preferences <> invalid
|
||||||
|
m.preferences["playback.preferred_quality"] = quality
|
||||||
|
end if
|
||||||
|
|
||||||
|
state = m.top.state
|
||||||
|
position = m.top.position
|
||||||
|
if state = "playing" or state = "buffering" or state = "paused"
|
||||||
|
m.pendingSwitchUrl = targetUrl
|
||||||
|
m.pendingSeekSeconds = position
|
||||||
|
m.pendingWasPaused = state = "paused"
|
||||||
|
' asyncStopSemantics: the swap happens on the "stopped" edge
|
||||||
|
' (ResumeIfPending, called by the coordinator).
|
||||||
|
m.top.control = "stop"
|
||||||
|
else
|
||||||
|
' idle device: swap directly. A seek written before control=play is
|
||||||
|
' the start position (see the error-retry path).
|
||||||
|
m.pendingWasPaused = false
|
||||||
|
content.url = targetUrl
|
||||||
|
m.SeekForResume(content, position)
|
||||||
|
m.top.control = "play"
|
||||||
|
end if
|
||||||
|
|
||||||
|
LogInfo("Quality switch ->", quality, "url=", targetUrl)
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Called from the coordinator's state handler on the "stopped" edge of a
|
||||||
|
' pending switch. Returns true when it resumed (the coordinator then
|
||||||
|
' restores the paused state via WasPaused()).
|
||||||
|
function ResumeIfPending() as boolean
|
||||||
|
if m.pendingSwitchUrl = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
content = m.top.content
|
||||||
|
content.url = m.pendingSwitchUrl
|
||||||
|
m.pendingSwitchUrl = invalid
|
||||||
|
|
||||||
|
m.SeekForResume(content, m.pendingSeekSeconds)
|
||||||
|
m.top.control = "play"
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SeekForResume(content as object, positionSeconds as float) as void
|
||||||
|
if content <> invalid and content.Live = true
|
||||||
|
m.top.seek = 999999
|
||||||
|
else if positionSeconds > 0
|
||||||
|
m.top.seek = positionSeconds
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SwitchPending() as boolean
|
||||||
|
return m.pendingSwitchUrl <> invalid
|
||||||
|
end function
|
||||||
|
|
||||||
|
' True when the switch started from a paused video: the coordinator sets
|
||||||
|
' repauseAfterSeek so the resumed playback re-pauses on its first edge.
|
||||||
|
function WasPaused() as boolean
|
||||||
|
return m.pendingWasPaused
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Captions button: toggle the device caption mode. When turning on and
|
||||||
|
' the OS language preference matched no track, fall back to the first
|
||||||
|
' track the backend offered.
|
||||||
|
function ActivateCaptions() as void
|
||||||
|
if not m.captionsAvailable or not m.top.hasField("globalCaptionMode")
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
if m.CaptionsOn()
|
||||||
|
m.top.globalCaptionMode = "Off"
|
||||||
|
else
|
||||||
|
m.top.globalCaptionMode = "On"
|
||||||
|
|
||||||
|
current = ""
|
||||||
|
if m.top.hasField("currentSubtitleTrack")
|
||||||
|
current = ValidString(m.top.currentSubtitleTrack)
|
||||||
|
end if
|
||||||
|
if StringUtils.IsNullOrEmpty(current) and m.top.hasField("availableSubtitleTracks")
|
||||||
|
tracks = m.top.availableSubtitleTracks
|
||||||
|
if IsArray(tracks) and tracks.Count() > 0
|
||||||
|
firstTrack = ValidString(tracks[0].TrackName)
|
||||||
|
if firstTrack <> ""
|
||||||
|
m.top.subtitleTrack = firstTrack
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
LogInfo("Captions ->", m.top.globalCaptionMode)
|
||||||
|
end function
|
||||||
|
|
||||||
|
end class
|
||||||
|
end namespace
|
||||||
@@ -233,9 +233,8 @@ namespace PlaybackTelemetry
|
|||||||
|
|
||||||
function ReportVideoError(errorData as object, errorInfo as object, url as dynamic, urlIndex as dynamic, shownInDialog as boolean) as void
|
function ReportVideoError(errorData as object, errorInfo as object, url as dynamic, urlIndex as dynamic, shownInDialog as boolean) as void
|
||||||
m.errorCount += 1
|
m.errorCount += 1
|
||||||
' malformed data: the last generated DASH/HLS manifest and player response diagnose it from the report.
|
|
||||||
attachments = invalid
|
attachments = invalid
|
||||||
if errorData.body.Instr("malformed data") <> -1 or errorData.body.Instr("invalid pathname") <> -1
|
if errorData.body.Instr("malformed data") <> -1 or errorData.body.Instr("invalid pathname") <> -1 or ((errorInfo = invalid or errorInfo.category <> "http") and errorData.body.Instr("last_err:") = -1)
|
||||||
attachments = [{
|
attachments = [{
|
||||||
filename: "last_generated_dash.xml"
|
filename: "last_generated_dash.xml"
|
||||||
content_type: "plain/text"
|
content_type: "plain/text"
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ namespace PlayerCoordinatorLogic
|
|||||||
' (m.buttons / its buttonCount field) — there is no separate count constant to keep in sync.
|
' (m.buttons / its buttonCount field) — there is no separate count constant to keep in sync.
|
||||||
enum PlayerButton
|
enum PlayerButton
|
||||||
PlayPause = 0
|
PlayPause = 0
|
||||||
Minimize = 1
|
Quality = 1
|
||||||
|
Captions = 2
|
||||||
|
Minimize = 3
|
||||||
end enum
|
end enum
|
||||||
|
|
||||||
' The two focus targets above/at the trackbar: the bar itself (Left/Right scrub, the cursor grows) and the
|
' The two focus targets above/at the trackbar: the bar itself (Left/Right scrub, the cursor grows) and the
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import "pkg:/source/utils/Locale.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
|
' Pure projection of the picker's input fields (no keys, no focus: the coordinator owns both, same
|
||||||
|
' contract as ButtonRow). Rebuilds the row Labels when `qualities` changes; slides the focus bar and
|
||||||
|
' repaints the row colors/bullets on every focusedIndex/appliedIndex edge.
|
||||||
|
|
||||||
|
const ROW_HEIGHT = 46
|
||||||
|
const PANEL_X = 420 ' (1280 - 440) / 2
|
||||||
|
const PANEL_HEADER_HEIGHT = 82 ' panel top -> first row (header label + gap)
|
||||||
|
const PANEL_BOTTOM_PADDING = 24
|
||||||
|
const BULLET_APPLIED = Chr(9679) + " " ' filled circle (same glyph the live badge uses)
|
||||||
|
const BULLET_NONE = " "
|
||||||
|
|
||||||
|
function Init()
|
||||||
|
m.rows = m.top.findNode("rows")
|
||||||
|
m.focusBar = m.top.findNode("focusBar")
|
||||||
|
m.rowLabels = []
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnQualitiesChange() as void
|
||||||
|
while m.rows.getChildCount() > 1
|
||||||
|
m.rows.removeChildIndex(m.rows.getChildCount() - 1)
|
||||||
|
end while
|
||||||
|
|
||||||
|
m.rowLabels = []
|
||||||
|
for each quality in ValidArray(m.top.qualities)
|
||||||
|
label = m.rows.CreateChild("Label")
|
||||||
|
label.width = 368
|
||||||
|
label.height = ROW_HEIGHT
|
||||||
|
label.vertAlign = "center"
|
||||||
|
label.horizAlign = "left"
|
||||||
|
label.translation = [0, (m.rowLabels.Count() + 1) * ROW_HEIGHT - ROW_HEIGHT]
|
||||||
|
m.rowLabels.push(label)
|
||||||
|
end for
|
||||||
|
|
||||||
|
' grow the panel to the row count (the 9-rung AV1 ladder would overflow a fixed height)
|
||||||
|
' and re-center it on screen.
|
||||||
|
panel = m.top.findNode("panel")
|
||||||
|
panelHeight = PANEL_HEADER_HEIGHT + m.rowLabels.Count() * ROW_HEIGHT + PANEL_BOTTOM_PADDING
|
||||||
|
panel.height = panelHeight
|
||||||
|
panel.translation = [PANEL_X, (720 - panelHeight) / 2]
|
||||||
|
|
||||||
|
OnRedraw()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnRedraw() as void
|
||||||
|
focusedIndex = ValidInt(m.top.focusedIndex)
|
||||||
|
appliedIndex = ValidInt(m.top.appliedIndex)
|
||||||
|
count = m.rowLabels.Count()
|
||||||
|
if count = 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.focusBar.translation = [0, focusedIndex * ROW_HEIGHT]
|
||||||
|
m.focusBar.visible = focusedIndex >= 0 and focusedIndex < count
|
||||||
|
|
||||||
|
for i = 0 to count - 1
|
||||||
|
label = m.rowLabels[i]
|
||||||
|
text = ValidString(m.top.qualities[i])
|
||||||
|
if text = "auto"
|
||||||
|
text = Tr(Locale.Settings.AutoQuality)
|
||||||
|
end if
|
||||||
|
if i = appliedIndex
|
||||||
|
text = BULLET_APPLIED + text
|
||||||
|
else
|
||||||
|
text = BULLET_NONE + text
|
||||||
|
end if
|
||||||
|
|
||||||
|
label.text = text
|
||||||
|
if i = focusedIndex
|
||||||
|
label.color = "#181818FF"
|
||||||
|
label.font = "font:SmallestBoldSystemFont"
|
||||||
|
else
|
||||||
|
label.color = "#EBEBEBFF"
|
||||||
|
label.font = "font:SmallestSystemFont"
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
end function
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<component name="QualityPicker" extends="Group">
|
||||||
|
<!-- Modal quality list drawn over the video (sibling of Chrome, so the chrome fade never hides it and
|
||||||
|
it paints above the video). Virtual focus like ButtonRow: real focus stays on the Video node, the
|
||||||
|
coordinator routes keys and drives focusedIndex; this node is a pure projection of
|
||||||
|
qualities/appliedIndex/focusedIndex. -->
|
||||||
|
<interface>
|
||||||
|
<field id="qualities" type="array" onChange="OnQualitiesChange" />
|
||||||
|
<field id="headerText" type="string" alias="headerLabel.text" />
|
||||||
|
<field id="appliedIndex" type="integer" value="-1" onChange="OnRedraw" alwaysNotify="true" />
|
||||||
|
<field id="focusedIndex" type="integer" value="0" onChange="OnRedraw" alwaysNotify="true" />
|
||||||
|
</interface>
|
||||||
|
<children>
|
||||||
|
<Rectangle id="scrim" width="1280" height="720" color="#000000" opacity="0.55" />
|
||||||
|
<Rectangle id="panel" width="440" height="472" translation="[420,124]" color="#242424">
|
||||||
|
<Label id="headerLabel" translation="[36,24]" width="368" height="34"
|
||||||
|
color="#FEFEFEFF" horizAlign="left" vertAlign="top">
|
||||||
|
<Font role="font" uri="font:BoldSystemFontFile" size="26" />
|
||||||
|
</Label>
|
||||||
|
<Group id="rows" translation="[36,82]">
|
||||||
|
<!-- slides under the focused row; painted first, the Labels are its siblings after -->
|
||||||
|
<Poster id="focusBar" width="368" height="46"
|
||||||
|
uri="pkg:/images/white.$$RES$$.9.png" opacity="0.92" visible="false" />
|
||||||
|
</Group>
|
||||||
|
</Rectangle>
|
||||||
|
</children>
|
||||||
|
</component>
|
||||||
@@ -26,7 +26,7 @@ namespace SponsorBlockController
|
|||||||
const SEEK_ECHO_SLACK_MS = 100
|
const SEEK_ECHO_SLACK_MS = 100
|
||||||
|
|
||||||
class Controller
|
class Controller
|
||||||
' deps the coordinator owns; top = the Video node (seekMode + duration).
|
' deps the coordinator owns; top = the Video node (duration).
|
||||||
private jobQueue as object = invalid
|
private jobQueue as object = invalid
|
||||||
private preferences as object = invalid
|
private preferences as object = invalid
|
||||||
private notifications as object = invalid
|
private notifications as object = invalid
|
||||||
@@ -77,7 +77,7 @@ namespace SponsorBlockController
|
|||||||
}
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
' Store the segments and set seekMode=accurate on the Video node.
|
' Store the segments.
|
||||||
function OnSegmentsJobDone(event as object) as void
|
function OnSegmentsJobDone(event as object) as void
|
||||||
info = event.getInfo()
|
info = event.getInfo()
|
||||||
if not info.success
|
if not info.success
|
||||||
@@ -89,9 +89,6 @@ namespace SponsorBlockController
|
|||||||
end if
|
end if
|
||||||
m.segments = segments
|
m.segments = segments
|
||||||
m.timeline = info.data.timeline
|
m.timeline = info.data.timeline
|
||||||
if m.top <> invalid
|
|
||||||
m.top.seekMode = "accurate"
|
|
||||||
end if
|
|
||||||
LogDebug("segments ready:", segments.Count())
|
LogDebug("segments ready:", segments.Count())
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import "pkg:/source/utils/Types.bs"
|
|||||||
' Every input field is observed in Init and repaints on change, except glyph, focused and the SponsorBlock
|
' Every input field is observed in Init and repaints on change, except glyph, focused and the SponsorBlock
|
||||||
' tint, which update only their own piece.
|
' tint, which update only their own piece.
|
||||||
|
|
||||||
const GLYPH_ASSET_BASE = "/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/"
|
const GLYPH_ASSET_BASE = "pkg:/images/icons/player/"
|
||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
m.trackFill = m.top.findNode("trackFill")
|
m.trackFill = m.top.findNode("trackFill")
|
||||||
|
|||||||
@@ -131,6 +131,23 @@ namespace Tests
|
|||||||
m.assertEqual(handle.translation[1], 22.0)
|
m.assertEqual(handle.translation[1], 22.0)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
@it("points every glyph, the handle, the track and the LIVE bullet at a bundled file")
|
||||||
|
function _()
|
||||||
|
file = CreateObject("roByteArray")
|
||||||
|
sg = m.top.findNode("scanGlyph")
|
||||||
|
for glyph = TransportController.Glyph.SkipBack to TransportController.Glyph.Replay
|
||||||
|
m.top.glyph = glyph
|
||||||
|
m.assertTrue(file.ReadFile(sg.uri), sg.uri)
|
||||||
|
end for
|
||||||
|
m.top.glyph = TransportController.Glyph.None
|
||||||
|
track = m.top.findNode("trackBg").uri
|
||||||
|
for each res in ["480p", "720p", "1080p"]
|
||||||
|
m.assertTrue(file.ReadFile(track.Replace("$$RES$$", res)), track)
|
||||||
|
end for
|
||||||
|
m.assertTrue(file.ReadFile(m.top.findNode("handle").uri))
|
||||||
|
m.assertTrue(file.ReadFile(m.top.findNode("bullet").uri))
|
||||||
|
end function
|
||||||
|
|
||||||
@describe("TrickPlayBar — LIVE projection")
|
@describe("TrickPlayBar — LIVE projection")
|
||||||
|
|
||||||
@it("BEHIND the edge: fill/playhead are PROPORTIONAL to cursor within the DVR window + offset label")
|
@it("BEHIND the edge: fill/playhead are PROPORTIONAL to cursor within the DVR window + offset label")
|
||||||
|
|||||||
@@ -24,11 +24,11 @@
|
|||||||
</interface>
|
</interface>
|
||||||
<children>
|
<children>
|
||||||
<Poster id="trackBg"
|
<Poster id="trackBg"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/osd_sliderControl_small.9.png"
|
uri="pkg:/images/player/osd_sliderControl_small.$$RES$$.9.png"
|
||||||
width="1144" height="12" opacity="0.3" loadDisplayMode="noScale" />
|
width="1144" height="12" opacity="0.3" loadDisplayMode="noScale" />
|
||||||
<!-- same asset tinted red, clipped to progress width in code. -->
|
<!-- same asset tinted red, clipped to progress width in code. -->
|
||||||
<Poster id="trackFill"
|
<Poster id="trackFill"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/osd_sliderControl_small.9.png"
|
uri="pkg:/images/player/osd_sliderControl_small.$$RES$$.9.png"
|
||||||
width="1144" height="12" blendColor="0xFF1C30FF" clippingRect="[0,0,0,12]" loadDisplayMode="noScale" />
|
width="1144" height="12" blendColor="0xFF1C30FF" clippingRect="[0,0,0,12]" loadDisplayMode="noScale" />
|
||||||
<!-- the cursor: a 12px dot that swells half-again while the bar tier holds focus. PositionPlayhead
|
<!-- the cursor: a 12px dot that swells half-again while the bar tier holds focus. PositionPlayhead
|
||||||
moves it; the grow/shrink animations scale it about its center. -->
|
moves it; the grow/shrink animations scale it about its center. -->
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
</Animation>
|
</Animation>
|
||||||
<!-- handle: pinned at bar-center. {547,22} rest, {547,-54} active. -->
|
<!-- handle: pinned at bar-center. {547,22} rest, {547,-54} active. -->
|
||||||
<Poster id="handle"
|
<Poster id="handle"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/videoProgressBarHandle.9.png"
|
uri="pkg:/images/player/videoProgressBarHandle.9.png"
|
||||||
translation="[547, 22]" width="50" height="30" loadDisplayMode="noScale">
|
translation="[547, 22]" width="50" height="30" loadDisplayMode="noScale">
|
||||||
<Poster id="scanGlyph" visible="false" width="50" height="30" loadDisplayMode="noScale" />
|
<Poster id="scanGlyph" visible="false" width="50" height="30" loadDisplayMode="noScale" />
|
||||||
</Poster>
|
</Poster>
|
||||||
@@ -61,8 +61,8 @@
|
|||||||
</Label>
|
</Label>
|
||||||
<!-- LIVE bullet: shown only at the edge. -->
|
<!-- LIVE bullet: shown only at the edge. -->
|
||||||
<Poster id="bullet" visible="false"
|
<Poster id="bullet" visible="false"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/icon_inline_unselected_bullet.webp"
|
uri="pkg:/images/icons/player/icon_inline_unselected_bullet.png"
|
||||||
translation="[1056, 24]" blendColor="0xD53E5AFF" loadDisplayMode="noScale" />
|
translation="[1056, 24]" width="24" height="24" blendColor="0xD53E5AFF" loadDisplayMode="noScale" />
|
||||||
<!-- LIVE badge: shown only at the edge. -->
|
<!-- LIVE badge: shown only at the edge. -->
|
||||||
<Label id="liveLabel" visible="false" translation="[1080, 24]" height="30"
|
<Label id="liveLabel" visible="false" translation="[1080, 24]" height="30"
|
||||||
text="LIVE" color="0xFEFEFEFF" horizAlign="left" vertAlign="top">
|
text="LIVE" color="0xFEFEFEFF" horizAlign="left" vertAlign="top">
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import "pkg:/components/JobSystem/JobSystem.bs"
|
|||||||
import "pkg:/components/Services/Innertube/Constants.bs"
|
import "pkg:/components/Services/Innertube/Constants.bs"
|
||||||
import "pkg:/components/VideoPlayer/Lounge.bs"
|
import "pkg:/components/VideoPlayer/Lounge.bs"
|
||||||
import "pkg:/components/VideoPlayerDev/ErrorDialogController.bs"
|
import "pkg:/components/VideoPlayerDev/ErrorDialogController.bs"
|
||||||
|
import "pkg:/components/VideoPlayerDev/PlaybackControls.bs"
|
||||||
import "pkg:/components/VideoPlayerDev/PlaybackTelemetry.bs"
|
import "pkg:/components/VideoPlayerDev/PlaybackTelemetry.bs"
|
||||||
import "pkg:/components/VideoPlayerDev/PlayerCoordinatorLogic.bs"
|
import "pkg:/components/VideoPlayerDev/PlayerCoordinatorLogic.bs"
|
||||||
import "pkg:/components/VideoPlayerDev/SponsorBlockController.bs"
|
import "pkg:/components/VideoPlayerDev/SponsorBlockController.bs"
|
||||||
@@ -40,6 +41,7 @@ end enum
|
|||||||
' one component scope; this file is shared with the test mock (tests/VideoPlayerDevMock).
|
' one component scope; this file is shared with the test mock (tests/VideoPlayerDevMock).
|
||||||
function Initialize()
|
function Initialize()
|
||||||
m.top.notificationInterval = 1
|
m.top.notificationInterval = 1
|
||||||
|
m.top.seekMode = "accurate"
|
||||||
|
|
||||||
m.transport = new TransportController.Controller()
|
m.transport = new TransportController.Controller()
|
||||||
m.playbackTelemetry = new PlaybackTelemetry.Recorder({
|
m.playbackTelemetry = new PlaybackTelemetry.Recorder({
|
||||||
@@ -67,6 +69,8 @@ function Initialize()
|
|||||||
m.showFullScreenHint = false
|
m.showFullScreenHint = false
|
||||||
m.focusTarget = PlayerCoordinatorLogic.FocusTarget.Bar
|
m.focusTarget = PlayerCoordinatorLogic.FocusTarget.Bar
|
||||||
m.focusedButton = 0
|
m.focusedButton = 0
|
||||||
|
' telemetry's streamingSegment one-shot consumed (we re-arm the observer for the quality label).
|
||||||
|
m.streamingSegmentTelemetryDone = false
|
||||||
m.armedTimerId = TransportController.Timer.None ' which module timer the single transportTimer holds
|
m.armedTimerId = TransportController.Timer.None ' which module timer the single transportTimer holds
|
||||||
m.lastCommitSeq = 0
|
m.lastCommitSeq = 0
|
||||||
m.lastFinishSeq = 0
|
m.lastFinishSeq = 0
|
||||||
@@ -92,6 +96,7 @@ function Initialize()
|
|||||||
m.spinner = m.top.findNode("spinner")
|
m.spinner = m.top.findNode("spinner")
|
||||||
m.largePause = m.top.findNode("largePause")
|
m.largePause = m.top.findNode("largePause")
|
||||||
m.buttonRow = m.top.findNode("buttonRow")
|
m.buttonRow = m.top.findNode("buttonRow")
|
||||||
|
m.qualityPicker = m.top.findNode("qualityPicker")
|
||||||
m.fullScreenHint = m.top.findNode("fullScreenHint")
|
m.fullScreenHint = m.top.findNode("fullScreenHint")
|
||||||
|
|
||||||
m.autoHide = m.top.findNode("autoHide")
|
m.autoHide = m.top.findNode("autoHide")
|
||||||
@@ -136,6 +141,12 @@ function OnNodeReady()
|
|||||||
top: m.top
|
top: m.top
|
||||||
})
|
})
|
||||||
|
|
||||||
|
' Quality + captions buttons in the chrome (same module pattern; reads preferences lazily).
|
||||||
|
m.playbackControls = new PlaybackControls.Controller({
|
||||||
|
preferences: m.top.preferences
|
||||||
|
top: m.top
|
||||||
|
})
|
||||||
|
|
||||||
' enableUI=false: the OS draws no chrome; we draw it all from the renderers.
|
' enableUI=false: the OS draws no chrome; we draw it all from the renderers.
|
||||||
m.top.enableUI = false
|
m.top.enableUI = false
|
||||||
|
|
||||||
@@ -324,6 +335,16 @@ end function
|
|||||||
' Key router — route intent, hold no behavior.
|
' Key router — route intent, hold no behavior.
|
||||||
'===============================================================================
|
'===============================================================================
|
||||||
function OnKeyEvent(key as string, press as boolean) as boolean
|
function OnKeyEvent(key as string, press as boolean) as boolean
|
||||||
|
' The quality picker is modal: while it is open it owns every key (Up/Down move the cursor, OK
|
||||||
|
' selects, Back cancels, the rest are swallowed) and the SponsorBlock skip notice must not steal OK.
|
||||||
|
' Releases are swallowed too: a Left/Right up with no down-scrub in flight must not reach the transport.
|
||||||
|
if m.playbackControls.PickerOpen()
|
||||||
|
if press
|
||||||
|
return HandleQualityPickerKey(key)
|
||||||
|
end if
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
' The SponsorBlock manual-skip notice outranks the focus tiers: while it is armed and on screen, OK does
|
' The SponsorBlock manual-skip notice outranks the focus tiers: while it is armed and on screen, OK does
|
||||||
' what the notice says (skip) no matter which tier holds focus, and Back dismisses the notice (the escape
|
' what the notice says (skip) no matter which tier holds focus, and Back dismisses the notice (the escape
|
||||||
' hatch for "I don't want to skip") instead of acting on the player.
|
' hatch for "I don't want to skip") instead of acting on the player.
|
||||||
@@ -548,6 +569,12 @@ end function
|
|||||||
function ActivateButton(index as integer) as void
|
function ActivateButton(index as integer) as void
|
||||||
if index = PlayerCoordinatorLogic.PlayerButton.PlayPause
|
if index = PlayerCoordinatorLogic.PlayerButton.PlayPause
|
||||||
TogglePlayPause()
|
TogglePlayPause()
|
||||||
|
else if index = PlayerCoordinatorLogic.PlayerButton.Quality
|
||||||
|
OpenQualityPicker()
|
||||||
|
else if index = PlayerCoordinatorLogic.PlayerButton.Captions
|
||||||
|
m.playbackControls.ActivateCaptions()
|
||||||
|
RefreshPlaybackStatus()
|
||||||
|
ShowChrome() ' the label changed under the user's finger; keep the HUD up (re-arms auto-hide)
|
||||||
else if index = PlayerCoordinatorLogic.PlayerButton.Minimize
|
else if index = PlayerCoordinatorLogic.PlayerButton.Minimize
|
||||||
MinimizeReset()
|
MinimizeReset()
|
||||||
VideoQueueUtils.ToggleVideoPictureInPicture(m.videoQueue)
|
VideoQueueUtils.ToggleVideoPictureInPicture(m.videoQueue)
|
||||||
@@ -555,6 +582,58 @@ function ActivateButton(index as integer) as void
|
|||||||
SyncFocus()
|
SyncFocus()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
'-------------------------------------------------------------------------------
|
||||||
|
' Quality picker — modal list over the video (virtual focus: this router owns the
|
||||||
|
' keys; QualityPicker is a pure projection of focusedIndex/appliedIndex/qualities).
|
||||||
|
'-------------------------------------------------------------------------------
|
||||||
|
function OpenQualityPicker() as void
|
||||||
|
m.playbackControls.ActivateQuality()
|
||||||
|
|
||||||
|
m.qualityPicker.qualities = m.playbackControls.PickerCycle()
|
||||||
|
m.qualityPicker.headerText = Tr(Locale.VideoPlayer.QualityPickerTitle)
|
||||||
|
PushQualityPickerView()
|
||||||
|
m.qualityPicker.visible = true
|
||||||
|
' modal look: the HUD goes away under the picker, and auto-hide stays off while it is up.
|
||||||
|
HideChromeNow()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function CloseQualityPicker() as void
|
||||||
|
m.playbackControls.EndPicker()
|
||||||
|
m.qualityPicker.visible = false
|
||||||
|
ShowChrome()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function PushQualityPickerView() as void
|
||||||
|
m.qualityPicker.focusedIndex = m.playbackControls.PickerFocusedIndex()
|
||||||
|
m.qualityPicker.appliedIndex = m.playbackControls.AppliedIndex()
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Keys while the picker is open: the list owns navigation + select, Back cancels,
|
||||||
|
' everything else is swallowed (the video must not scrub under the modal).
|
||||||
|
function HandleQualityPickerKey(key as string) as boolean
|
||||||
|
if key = RemoteKeys.Up
|
||||||
|
m.playbackControls.MovePickerFocus(-1)
|
||||||
|
PushQualityPickerView()
|
||||||
|
return true
|
||||||
|
else if key = RemoteKeys.Down
|
||||||
|
m.playbackControls.MovePickerFocus(1)
|
||||||
|
PushQualityPickerView()
|
||||||
|
return true
|
||||||
|
else if key = RemoteKeys.Ok
|
||||||
|
chosen = m.playbackControls.ConfirmPicker()
|
||||||
|
CloseQualityPicker()
|
||||||
|
if not StringUtils.IsNullOrEmpty(chosen)
|
||||||
|
m.playbackControls.ApplyQuality(chosen)
|
||||||
|
RefreshPlaybackStatus()
|
||||||
|
end if
|
||||||
|
return true
|
||||||
|
else if key = RemoteKeys.Back
|
||||||
|
CloseQualityPicker()
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
return true ' modal: consume Left/Right/Play/Rev/Fwd/... so nothing leaks to the transport
|
||||||
|
end function
|
||||||
|
|
||||||
' Push the focus state to the renderers. The button row highlights its focused button while the BUTTON tier
|
' Push the focus state to the renderers. The button row highlights its focused button while the BUTTON tier
|
||||||
' holds focus; the trackbar's cursor grows while the BAR tier holds focus. Both are gated on the chrome being
|
' holds focus; the trackbar's cursor grows while the BAR tier holds focus. Both are gated on the chrome being
|
||||||
' up, so nothing reads as focused while the chrome is hidden.
|
' up, so nothing reads as focused while the chrome is hidden.
|
||||||
@@ -778,6 +857,11 @@ function OnVideoState(event as object) as void
|
|||||||
if PlayerCoordinatorLogic.ShouldShowBuffering(m.firstFrameSeen, m.transport.transportMode, m.container.fullscreen)
|
if PlayerCoordinatorLogic.ShouldShowBuffering(m.firstFrameSeen, m.transport.transportMode, m.container.fullscreen)
|
||||||
m.spinner.mode = SpinMode.Buffering
|
m.spinner.mode = SpinMode.Buffering
|
||||||
end if
|
end if
|
||||||
|
else if state = VideoState.Stopped
|
||||||
|
' a quality switch stopped the stream first; swap in the new URL and replay now.
|
||||||
|
if m.playbackControls.ResumeIfPending()
|
||||||
|
m.repauseAfterSeek = m.playbackControls.WasPaused()
|
||||||
|
end if
|
||||||
else if state = VideoState.Finished
|
else if state = VideoState.Finished
|
||||||
' a retry replay (error -> next stream URL) ends with a "finished" edge we must swallow.
|
' a retry replay (error -> next stream URL) ends with a "finished" edge we must swallow.
|
||||||
if m.ignoreNextFinished
|
if m.ignoreNextFinished
|
||||||
@@ -809,8 +893,19 @@ function OnStreamingSegment(event as object) as void
|
|||||||
if m.onCloseCalled = true
|
if m.onCloseCalled = true
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
if m.playbackTelemetry.OnStreamingSegment(event.getData())
|
segment = event.getData()
|
||||||
|
|
||||||
|
' the quality label tracks the ladder the player actually chose (auto ramps up over time)
|
||||||
|
if m.playbackControls.OnStreamingSegment(segment)
|
||||||
|
RefreshPlaybackStatus()
|
||||||
|
end if
|
||||||
|
|
||||||
|
if not m.streamingSegmentTelemetryDone and m.playbackTelemetry.OnStreamingSegment(segment)
|
||||||
|
m.streamingSegmentTelemetryDone = true
|
||||||
|
' telemetry only wants the first video segment, then unobserves; re-arm so the
|
||||||
|
' quality label keeps seeing edges (telemetry's own call is gated off above).
|
||||||
m.top.unobserveField("streamingSegment")
|
m.top.unobserveField("streamingSegment")
|
||||||
|
m.top.ObserveField("streamingSegment", FuncName(OnStreamingSegment))
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -1217,14 +1312,18 @@ function OnVideoContentJobDone(event as object) as void
|
|||||||
LogDebug("queued SponsorBlockSegmentsJob")
|
LogDebug("queued SponsorBlockSegmentsJob")
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
' quality ladder + captions availability for the player's Quality/Captions buttons
|
||||||
|
m.playbackControls.OnContentReady(metadata)
|
||||||
|
RefreshPlaybackStatus()
|
||||||
|
|
||||||
UpdateOverlayMeta()
|
UpdateOverlayMeta()
|
||||||
SeekToInitialPosition(content)
|
SeekToInitialPosition(content)
|
||||||
PlayAfterPreviousPlayerHasStopped()
|
PlayAfterPreviousPlayerHasStopped()
|
||||||
MarkVideoWatched(content.videoId, metadata.playbackTrackingUrls, metadata.cpn)
|
MarkVideoWatched(content.videoId, metadata.playbackTrackingUrls, metadata.cpn)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
' The coordinator-owned SB job callback (node scope). Hands the result to the controller (it stores segments +
|
' The coordinator-owned SB job callback (node scope). Hands the result to the controller (it stores segments),
|
||||||
' sets seekMode), then pushes the bar tint fields when segments exist.
|
' then pushes the bar tint fields when segments exist.
|
||||||
function OnSponsorBlockSegmentsJobDone(event as object) as void
|
function OnSponsorBlockSegmentsJobDone(event as object) as void
|
||||||
JobSystem.UnobserveCallback(event.getRoSGNode())
|
JobSystem.UnobserveCallback(event.getRoSGNode())
|
||||||
m.sponsorBlockSegmentsJob = invalid
|
m.sponsorBlockSegmentsJob = invalid
|
||||||
@@ -1379,6 +1478,11 @@ function UpdateOverlayMeta() as void
|
|||||||
m.spinner.secondaryTitle = secondaryTitle
|
m.spinner.secondaryTitle = secondaryTitle
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
' Push the current quality/captions readout onto the button row's status label.
|
||||||
|
function RefreshPlaybackStatus() as void
|
||||||
|
m.buttonRow.statusText = m.playbackControls.StatusSummary()
|
||||||
|
end function
|
||||||
|
|
||||||
'-------------------------------------------------------------------------------
|
'-------------------------------------------------------------------------------
|
||||||
' Storyboards — sourced from the native Video.thumbnailTiles field (the OS populates it from the DASH image
|
' Storyboards — sourced from the native Video.thumbnailTiles field (the OS populates it from the DASH image
|
||||||
' AdaptationSet; the DASH builder equalizes @bandwidth across levels and orders sharpest-first so the OS
|
' AdaptationSet; the DASH builder equalizes @bandwidth across levels and orders sharpest-first so the OS
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
<Group id="Chrome" opacity="0" visible="false">
|
<Group id="Chrome" opacity="0" visible="false">
|
||||||
<!-- Full-screen darkening scrim, chrome-gated (rides the fade), not pause-gated. -->
|
<!-- Full-screen darkening scrim, chrome-gated (rides the fade), not pause-gated. -->
|
||||||
<Poster id="pauseGradient"
|
<Poster id="pauseGradient"
|
||||||
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/PauseGradient.9.png"
|
uri="pkg:/images/player/PauseGradient.png"
|
||||||
width="1280" height="720" />
|
width="1280" height="720" />
|
||||||
|
|
||||||
<!-- First content sibling: its full-screen black backdrop must paint UNDER the title/bar/buttons
|
<!-- First content sibling: its full-screen black backdrop must paint UNDER the title/bar/buttons
|
||||||
@@ -121,5 +121,9 @@
|
|||||||
<!-- Coordinator pulses `trigger` only on an explicit pause-from-playing, `cancel` on resume. Not chrome-gated. -->
|
<!-- Coordinator pulses `trigger` only on an explicit pause-from-playing, `cancel` on resume. Not chrome-gated. -->
|
||||||
<LargePause id="largePause" />
|
<LargePause id="largePause" />
|
||||||
|
|
||||||
|
<!-- ===================== QualityPicker (modal; OUTSIDE Chrome, top of the z-order) ===================== -->
|
||||||
|
<!-- Opened by the Quality button; virtual focus driven by the coordinator (see OpenQualityPicker). -->
|
||||||
|
<QualityPicker id="qualityPicker" visible="false" />
|
||||||
|
|
||||||
</children>
|
</children>
|
||||||
</component>
|
</component>
|
||||||
@@ -56,6 +56,9 @@ function TestSetup() as void
|
|||||||
m.top.appController = createObject("roSGNode", "Node")
|
m.top.appController = createObject("roSGNode", "Node")
|
||||||
m.top.webServer = createObject("roSGNode", "Node")
|
m.top.webServer = createObject("roSGNode", "Node")
|
||||||
m.top.innertube = createObject("roSGNode", "Node")
|
m.top.innertube = createObject("roSGNode", "Node")
|
||||||
|
' the quality switch persists its pick here; the stub needs the field to exist (Node drops writes to
|
||||||
|
' unknown fields, which would make CurrentQuality permanently "auto" in tests).
|
||||||
|
m.top.preferences.addField("playback.preferred_quality", "string", false)
|
||||||
|
|
||||||
' AutoBind aliases bound interface fields onto m.<name>; do it manually here (coordinator + Lounge read m.*).
|
' AutoBind aliases bound interface fields onto m.<name>; do it manually here (coordinator + Lounge read m.*).
|
||||||
m.container = m.top.container
|
m.container = m.top.container
|
||||||
@@ -237,6 +240,38 @@ function TestPlaybackErrorDialog(errorFields as object) as object
|
|||||||
return result
|
return result
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
' TestSeedPlaybackContent — content + metadata for the quality/captions seam tests: what
|
||||||
|
' OnVideoContentJobDone leaves behind (a loaded content node with the Piped-shaped metadata),
|
||||||
|
' minus the job. Then runs the REAL OnContentReady hook + status refresh.
|
||||||
|
function TestSeedPlaybackContent(qualityLevels as object, captionCount as integer) as void
|
||||||
|
content = CreateObject("roSGNode", "ContentNode")
|
||||||
|
content.addField("videoId", "string", false)
|
||||||
|
content.addField("playletStreamUrls", "array", false)
|
||||||
|
content.addField("playletStreamUrlIndex", "integer", false)
|
||||||
|
content.addField("metadata", "assocarray", false)
|
||||||
|
captions = []
|
||||||
|
for i = 0 to captionCount - 1
|
||||||
|
captions.push({ language_code: "en", label: "English", url: `http://cc/${i}` })
|
||||||
|
end for
|
||||||
|
content.setFields({
|
||||||
|
videoId: "testvideo01"
|
||||||
|
url: "http://127.0.0.1:8888/api/hls?url=http%3A%2F%2Fup%2Fmaster.m3u8&v=testvideo01"
|
||||||
|
playletStreamUrls: ["http://127.0.0.1:8888/api/hls?url=http%3A%2F%2Fup%2Fmaster.m3u8&v=testvideo01"]
|
||||||
|
playletStreamUrlIndex: 0
|
||||||
|
metadata: { videoId: "testvideo01", lengthSeconds: 600, captions: captions, qualityLevels: qualityLevels }
|
||||||
|
})
|
||||||
|
m.top.content = content
|
||||||
|
' the device-side track list the OS would report after the manifest loads; the captions fallback
|
||||||
|
' (no OS language match) picks from here.
|
||||||
|
tracks = []
|
||||||
|
for i = 0 to captionCount - 1
|
||||||
|
tracks.push({ Description: "English", Language: "eng", TrackName: `http://cc/${i}` })
|
||||||
|
end for
|
||||||
|
m.top.availableSubtitleTracks = tracks
|
||||||
|
m.playbackControls.OnContentReady(content.metadata)
|
||||||
|
RefreshPlaybackStatus()
|
||||||
|
end function
|
||||||
|
|
||||||
' TestContentJobFailed — the VideoContentJob's failure result, minus the job: runs the REAL OnVideoContentJobDone.
|
' TestContentJobFailed — the VideoContentJob's failure result, minus the job: runs the REAL OnVideoContentJobDone.
|
||||||
function TestContentJobFailed(errorMessage as string) as void
|
function TestContentJobFailed(errorMessage as string) as void
|
||||||
OnVideoContentJobDone({
|
OnVideoContentJobDone({
|
||||||
@@ -268,6 +303,11 @@ end function
|
|||||||
|
|
||||||
' TestSnapshot — read the seam state the spec asserts on (brain + the device control the coordinator wrote).
|
' TestSnapshot — read the seam state the spec asserts on (brain + the device control the coordinator wrote).
|
||||||
function TestSnapshot() as object
|
function TestSnapshot() as object
|
||||||
|
content = m.top.content
|
||||||
|
contentUrl = ""
|
||||||
|
if content <> invalid
|
||||||
|
contentUrl = ValidString(content.url)
|
||||||
|
end if
|
||||||
return {
|
return {
|
||||||
transportMode: m.transport.transportMode
|
transportMode: m.transport.transportMode
|
||||||
seekSettling: m.transport.seekSettling
|
seekSettling: m.transport.seekSettling
|
||||||
@@ -290,6 +330,14 @@ function TestSnapshot() as object
|
|||||||
replayPending: m.transport.replayPending
|
replayPending: m.transport.replayPending
|
||||||
transportTimerControl: m.transportTimer.control
|
transportTimerControl: m.transportTimer.control
|
||||||
buttonRowVisible: m.buttonRow.visible
|
buttonRowVisible: m.buttonRow.visible
|
||||||
|
buttonRowStatusText: m.buttonRow.statusText
|
||||||
|
captionMode: m.top.globalCaptionMode
|
||||||
|
qualitySwitchPending: m.playbackControls.SwitchPending()
|
||||||
|
pickerVisible: m.qualityPicker.visible
|
||||||
|
pickerFocusedIndex: m.qualityPicker.focusedIndex
|
||||||
|
pickerAppliedIndex: m.qualityPicker.appliedIndex
|
||||||
|
pickerRowCount: m.qualityPicker.findNode("rows").getChildCount() - 1
|
||||||
|
contentUrl: contentUrl
|
||||||
barPositionMs: m.trickPlayBar.positionMs
|
barPositionMs: m.trickPlayBar.positionMs
|
||||||
spinnerMode: m.spinner.mode
|
spinnerMode: m.spinner.mode
|
||||||
brain: TestBrainSnapshot()
|
brain: TestBrainSnapshot()
|
||||||
|
|||||||
@@ -13,11 +13,16 @@
|
|||||||
<field id="position" type="float" alwaysNotify="true" />
|
<field id="position" type="float" alwaysNotify="true" />
|
||||||
<field id="duration" type="float" />
|
<field id="duration" type="float" />
|
||||||
<field id="autoplayAfterSeek" type="boolean" value="true" />
|
<field id="autoplayAfterSeek" type="boolean" value="true" />
|
||||||
|
<field id="seekMode" type="string" value="default" />
|
||||||
<field id="content" type="node" />
|
<field id="content" type="node" />
|
||||||
<field id="thumbnailTiles" type="assocarray" />
|
<field id="thumbnailTiles" type="assocarray" />
|
||||||
<field id="playbackSpeed" type="float" value="1.0" />
|
<field id="playbackSpeed" type="float" value="1.0" />
|
||||||
<field id="enableUI" type="boolean" value="true" />
|
<field id="enableUI" type="boolean" value="true" />
|
||||||
<field id="suppressCaptions" type="boolean" />
|
<field id="suppressCaptions" type="boolean" />
|
||||||
|
<field id="globalCaptionMode" type="string" value="Off" />
|
||||||
|
<field id="subtitleTrack" type="string" />
|
||||||
|
<field id="currentSubtitleTrack" type="string" />
|
||||||
|
<field id="availableSubtitleTracks" type="array" value="[]" />
|
||||||
<field id="asyncStopSemantics" type="boolean" />
|
<field id="asyncStopSemantics" type="boolean" />
|
||||||
<field id="notificationInterval" type="float" />
|
<field id="notificationInterval" type="float" />
|
||||||
<field id="width" type="float" />
|
<field id="width" type="float" />
|
||||||
@@ -63,6 +68,7 @@
|
|||||||
<function name="TestSetControl" />
|
<function name="TestSetControl" />
|
||||||
<function name="TestSetLive" />
|
<function name="TestSetLive" />
|
||||||
<function name="TestSeedSponsorBlock" />
|
<function name="TestSeedSponsorBlock" />
|
||||||
|
<function name="TestSeedPlaybackContent" />
|
||||||
<function name="TestSeekToInitialPosition" />
|
<function name="TestSeekToInitialPosition" />
|
||||||
<function name="TestErrorRetry" />
|
<function name="TestErrorRetry" />
|
||||||
<function name="TestSetContentLoading" />
|
<function name="TestSetContentLoading" />
|
||||||
@@ -109,5 +115,6 @@
|
|||||||
</Group>
|
</Group>
|
||||||
<LoadBufferSpinner id="spinner" />
|
<LoadBufferSpinner id="spinner" />
|
||||||
<LargePause id="largePause" />
|
<LargePause id="largePause" />
|
||||||
|
<QualityPicker id="qualityPicker" visible="false" />
|
||||||
</children>
|
</children>
|
||||||
</component>
|
</component>
|
||||||
@@ -946,11 +946,13 @@ namespace Tests
|
|||||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' bar -> buttons tier, play/pause (leftmost)
|
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' bar -> buttons tier, play/pause (leftmost)
|
||||||
m.top.callFunc("TestKey", RemoteKeys.Left, true) ' clamped at the left end
|
m.top.callFunc("TestKey", RemoteKeys.Left, true) ' clamped at the left end
|
||||||
m.assertEqual(m.Snap().nudgeCount, 1)
|
m.assertEqual(m.Snap().nudgeCount, 1)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' -> quality
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' -> captions
|
||||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' -> minimize (rightmost)
|
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' -> minimize (rightmost)
|
||||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' clamped at the right end
|
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' clamped at the right end
|
||||||
snap = m.Snap()
|
snap = m.Snap()
|
||||||
m.assertEqual(snap.nudgeCount, 2)
|
m.assertEqual(snap.nudgeCount, 2)
|
||||||
m.assertEqual(snap.focusedButton, 1, "the clamp held the highlight at the end")
|
m.assertEqual(snap.focusedButton, 3, "the clamp held the highlight at the end")
|
||||||
end function
|
end function
|
||||||
|
|
||||||
' Down at the bar tier (the bottom, and the default on reveal) is a no-op: consumed, no nudge.
|
' Down at the bar tier (the bottom, and the default on reveal) is a no-op: consumed, no nudge.
|
||||||
@@ -1005,14 +1007,143 @@ namespace Tests
|
|||||||
function _()
|
function _()
|
||||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> bar tier (default)
|
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> bar tier (default)
|
||||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' bar -> buttons tier
|
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' bar -> buttons tier
|
||||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' highlight minimize
|
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' highlight quality
|
||||||
m.assertEqual(m.Snap().focusedButton, 1)
|
m.assertEqual(m.Snap().focusedButton, 1)
|
||||||
m.top.callFunc("TestKey", RemoteKeys.Play, true) ' must pause, not minimize
|
m.top.callFunc("TestKey", RemoteKeys.Play, true) ' must pause, not activate quality
|
||||||
snap = m.Snap()
|
snap = m.Snap()
|
||||||
m.assertEqual(snap.control, VideoControl.Pause, "Play paused the (playing) video")
|
m.assertEqual(snap.control, VideoControl.Pause, "Play paused the (playing) video")
|
||||||
m.assertEqual(snap.focusedButton, 1, "the highlight is untouched")
|
m.assertEqual(snap.focusedButton, 1, "the highlight is untouched")
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
' The quality button opens a modal picker over the video (virtual cursor, list not cycle):
|
||||||
|
' the seed's ladder [1080p,720p,480p] renders as auto/1080p/720p/480p rows, cursor starts on the
|
||||||
|
' applied rung (auto), Down moves it, OK applies + arms the stop->play switch, Back cancels.
|
||||||
|
@it("the quality button opens the picker and OK applies the highlighted rung")
|
||||||
|
function _()
|
||||||
|
m.top.callFunc("TestSeedPlaybackContent", ["1080p", "720p", "480p"], 1)
|
||||||
|
m.top.position = 42.0
|
||||||
|
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> bar tier
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' bar -> buttons tier
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' highlight quality
|
||||||
|
m.assertEqual(m.Snap().focusedButton, 1)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Ok, true) ' open the picker
|
||||||
|
|
||||||
|
open = m.Snap()
|
||||||
|
m.assertTrue(open.pickerVisible, "the picker opened")
|
||||||
|
m.assertEqual(open.pickerRowCount, 4, "auto + the three seeded rungs")
|
||||||
|
m.assertEqual(open.pickerFocusedIndex, 0, "cursor starts on Auto (the applied rung)")
|
||||||
|
m.assertEqual(open.pickerAppliedIndex, 0, "Auto is marked applied")
|
||||||
|
m.assertFalse(open.chromeShown, "the HUD hides under the modal")
|
||||||
|
|
||||||
|
' the modal swallows transport keys: Left must not scrub
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||||
|
m.assertEqual(m.Snap().transportMode, TransportController.Mode.Idle, "Left swallowed")
|
||||||
|
|
||||||
|
' Down -> 1080p, OK applies: the switch arms (stop first) and the pick persists
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Down, true)
|
||||||
|
m.assertEqual(m.Snap().pickerFocusedIndex, 1, "cursor moved to 1080p")
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Ok, true)
|
||||||
|
|
||||||
|
snap = m.Snap()
|
||||||
|
m.assertFalse(snap.pickerVisible, "the picker closed")
|
||||||
|
m.assertTrue(snap.qualitySwitchPending, "the switch armed")
|
||||||
|
m.assertEqual(snap.control, VideoControl.Stop, "the switch stopped the player")
|
||||||
|
m.assertEqual(m.top.preferences["playback.preferred_quality"], "1080p", "the pick persisted")
|
||||||
|
m.assertTrue(InStr(snap.buttonRowStatusText, "1080p") > 0, "the status line shows the new quality")
|
||||||
|
|
||||||
|
' the device completes the async stop -> the coordinator swaps the url and replays at position
|
||||||
|
m.top.callFunc("TestSetState", VideoState.Stopped)
|
||||||
|
after = m.Snap()
|
||||||
|
m.assertFalse(after.qualitySwitchPending, "the switch drained")
|
||||||
|
m.assertEqual(after.control, VideoControl.Play, "playback resumed on the new url")
|
||||||
|
m.assertTrue(InStr(after.contentUrl, "&quality=1080p") > 0, "the url carries the quality filter")
|
||||||
|
m.assertEqual(m.top.seek, 42.0, "resumed at the saved position")
|
||||||
|
|
||||||
|
' reopen: the cursor lands on the applied rung; Back cancels without switching
|
||||||
|
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Right, true)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Ok, true)
|
||||||
|
reopen = m.Snap()
|
||||||
|
m.assertTrue(reopen.pickerVisible)
|
||||||
|
m.assertEqual(reopen.pickerFocusedIndex, 1, "cursor reopens on 1080p")
|
||||||
|
m.assertEqual(reopen.pickerAppliedIndex, 1, "1080p is marked applied")
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Back, true)
|
||||||
|
cancelled = m.Snap()
|
||||||
|
m.assertFalse(cancelled.pickerVisible, "Back closed the picker")
|
||||||
|
m.assertFalse(cancelled.qualitySwitchPending, "Back applied nothing")
|
||||||
|
m.assertEqual(m.top.preferences["playback.preferred_quality"], "1080p", "the pick unchanged")
|
||||||
|
|
||||||
|
' clamps: Up at the top rung stays on Auto (index 0), not a wrap
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Right, true)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Ok, true)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' 1080p -> auto
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' clamped at auto
|
||||||
|
m.assertEqual(m.Snap().pickerFocusedIndex, 0, "the cursor clamps at the top")
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Back, true)
|
||||||
|
end function
|
||||||
|
|
||||||
|
' The captions button (index 2): toggles globalCaptionMode; it is reported unavailable when the
|
||||||
|
' video has no captions (the coordinator still routes the press; the module no-ops).
|
||||||
|
@it("the captions button toggles the device caption mode")
|
||||||
|
function _()
|
||||||
|
m.top.callFunc("TestSeedPlaybackContent", ["1080p"], 2)
|
||||||
|
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||||
|
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> bar tier
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' bar -> buttons tier
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' quality
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' captions
|
||||||
|
m.assertEqual(m.Snap().focusedButton, 2)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Ok, true)
|
||||||
|
|
||||||
|
snap = m.Snap()
|
||||||
|
m.assertEqual(snap.captionMode, "On", "captions turned on")
|
||||||
|
m.assertTrue(InStr(snap.buttonRowStatusText, "On") > 0, "the status line shows Captions: On")
|
||||||
|
|
||||||
|
' the OS language pref matched nothing -> the module fell back to the first offered track.
|
||||||
|
m.assertEqual(m.top.subtitleTrack, "http://cc/0", "fell back to the first track")
|
||||||
|
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Ok, true) ' toggle again
|
||||||
|
m.assertEqual(m.Snap().captionMode, "Off", "captions turned off")
|
||||||
|
end function
|
||||||
|
|
||||||
|
' No captions on this video: the toggle is inert and the status line says N/A.
|
||||||
|
@it("the captions button is a no-op when the video has no captions")
|
||||||
|
function _()
|
||||||
|
m.top.callFunc("TestSeedPlaybackContent", ["1080p"], 0)
|
||||||
|
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||||
|
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Right, true)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Right, true)
|
||||||
|
m.top.callFunc("TestKey", RemoteKeys.Ok, true)
|
||||||
|
|
||||||
|
snap = m.Snap()
|
||||||
|
m.assertEqual(snap.captionMode, "Off", "the mode never moved")
|
||||||
|
m.assertTrue(InStr(snap.buttonRowStatusText, "N/A") > 0, "the status line reports N/A")
|
||||||
|
end function
|
||||||
|
|
||||||
|
' The status line reflects the live ladder while Auto is selected: a streamingSegment edge updates
|
||||||
|
' the parenthetical (the auto-ramp readout the user asked for).
|
||||||
|
@it("the status line shows the auto-resolved height from streamingSegment")
|
||||||
|
function _()
|
||||||
|
m.top.callFunc("TestSeedPlaybackContent", ["1080p", "720p"], 0)
|
||||||
|
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||||
|
|
||||||
|
m.top.streamingSegment = { segType: 0, height: 720, width: 1280 }
|
||||||
|
snap = m.Snap()
|
||||||
|
m.assertTrue(InStr(snap.buttonRowStatusText, "Auto (720p)") > 0, "the auto ramp shows in the status line")
|
||||||
|
|
||||||
|
m.top.streamingSegment = { segType: 0, height: 1080, width: 1920 }
|
||||||
|
m.assertTrue(InStr(m.Snap().buttonRowStatusText, "Auto (1080p)") > 0, "it tracks the ramp up")
|
||||||
|
end function
|
||||||
|
|
||||||
' Each arm is asserted: a state that silently failed to arm makes every row that follows vacuous.
|
' Each arm is asserted: a state that silently failed to arm makes every row that follows vacuous.
|
||||||
function ArmRouterState(state as string) as void
|
function ArmRouterState(state as string) as void
|
||||||
m.top.callFunc("TestSetup")
|
m.top.callFunc("TestSetup")
|
||||||
@@ -1079,11 +1210,11 @@ namespace Tests
|
|||||||
classified[name] = "dep"
|
classified[name] = "dep"
|
||||||
end for
|
end for
|
||||||
' controllers (plain .bs class instances).
|
' controllers (plain .bs class instances).
|
||||||
for each name in ["transport", "sponsorblock", "playbackTelemetry"]
|
for each name in ["transport", "sponsorblock", "playbackTelemetry", "playbackControls"]
|
||||||
classified[name] = "controller"
|
classified[name] = "controller"
|
||||||
end for
|
end for
|
||||||
' cached child nodes / timers / animations / reusable helpers (structure, not state).
|
' cached child nodes / timers / animations / reusable helpers (structure, not state).
|
||||||
for each name in ["chrome", "titleLabel", "secondaryTitleLabel", "clock", "bifDisplay", "trickPlayBar", "spinner", "largePause", "buttonRow", "fullScreenHint", "autoHide", "transportTimer", "liveBadgeHold", "liveEdgeClock", "fullScreenHintTimer", "chromeFadeIn", "chromeFadeOut", "minimize", "nowDateTime"]
|
for each name in ["chrome", "titleLabel", "secondaryTitleLabel", "clock", "bifDisplay", "trickPlayBar", "spinner", "largePause", "buttonRow", "qualityPicker", "fullScreenHint", "autoHide", "transportTimer", "liveBadgeHold", "liveEdgeClock", "fullScreenHintTimer", "chromeFadeIn", "chromeFadeOut", "minimize", "nowDateTime"]
|
||||||
classified[name] = "node"
|
classified[name] = "node"
|
||||||
end for
|
end for
|
||||||
' in-flight job handles.
|
' in-flight job handles.
|
||||||
@@ -1095,7 +1226,7 @@ namespace Tests
|
|||||||
classified[name] = "axis"
|
classified[name] = "axis"
|
||||||
end for
|
end for
|
||||||
' flags / scratch — one-shot latches and counters with a single consuming path.
|
' flags / scratch — one-shot latches and counters with a single consuming path.
|
||||||
for each name in ["onCloseCalled", "ignoreNextFinished", "videoPlayedSuccessfully", "firstFrameSeen", "showFullScreenHint", "repauseAfterSeek", "loadingSetSeekMs", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds", "liveBadgeHoldActive"]
|
for each name in ["onCloseCalled", "ignoreNextFinished", "videoPlayedSuccessfully", "firstFrameSeen", "showFullScreenHint", "repauseAfterSeek", "loadingSetSeekMs", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds", "liveBadgeHoldActive", "streamingSegmentTelemetryDone"]
|
||||||
classified[name] = "flag"
|
classified[name] = "flag"
|
||||||
end for
|
end for
|
||||||
' NOT coordinator state — node-scope + test-environment entries, pinned EXPLICITLY (no hidden
|
' NOT coordinator state — node-scope + test-environment entries, pinned EXPLICITLY (no hidden
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ namespace Http
|
|||||||
|
|
||||||
hlsManifest = hlsResponse.Text()
|
hlsManifest = hlsResponse.Text()
|
||||||
|
|
||||||
|
' Some backends (Piped) return master manifests with relative
|
||||||
|
' variant URIs; since we serve the manifest from 127.0.0.1, the
|
||||||
|
' player would resolve them against the local server and 404.
|
||||||
|
' Make them absolute against the original manifest URL.
|
||||||
|
hlsManifest = m.MakeRelativeUrisAbsolute(hlsManifest, url)
|
||||||
|
|
||||||
hlsManifest = m.PrependManifestHeader(hlsManifest, v, url)
|
hlsManifest = m.PrependManifestHeader(hlsManifest, v, url)
|
||||||
|
|
||||||
qualityFilter = m.CreateQualityFilter(quality)
|
qualityFilter = m.CreateQualityFilter(quality)
|
||||||
@@ -253,6 +259,54 @@ ${storyboard.templateUrl.replace("$M", `${i}`)}
|
|||||||
return hlsManifest
|
return hlsManifest
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function MakeRelativeUrisAbsolute(manifest as string, baseUrl as string) as string
|
||||||
|
if manifest = invalid or manifest = "" or baseUrl = invalid or baseUrl = ""
|
||||||
|
return manifest
|
||||||
|
end if
|
||||||
|
|
||||||
|
parsedUrl = UrlUtils.ParseUrl(baseUrl)
|
||||||
|
if parsedUrl = invalid or parsedUrl.host = invalid
|
||||||
|
return manifest
|
||||||
|
end if
|
||||||
|
|
||||||
|
protocol = parsedUrl.protocol
|
||||||
|
if protocol = invalid or protocol = ""
|
||||||
|
protocol = "https"
|
||||||
|
end if
|
||||||
|
origin = protocol + "://" + parsedUrl.host
|
||||||
|
if parsedUrl.port <> invalid and parsedUrl.port <> "" and parsedUrl.port <> "80" and parsedUrl.port <> "443"
|
||||||
|
origin = origin + ":" + parsedUrl.port
|
||||||
|
end if
|
||||||
|
|
||||||
|
' normalize line endings (CR-only manifests would be one line)
|
||||||
|
manifest = manifest.Replace(chr(13) + chr(10), chr(10))
|
||||||
|
manifest = manifest.Replace(chr(13), chr(10))
|
||||||
|
|
||||||
|
lines = manifest.Split(chr(10))
|
||||||
|
for i = 0 to lines.Count() - 1
|
||||||
|
line = lines[i]
|
||||||
|
trimmed = line.Trim()
|
||||||
|
|
||||||
|
if Left(trimmed, 1) = "/"
|
||||||
|
' bare relative URI line (variant/media playlist)
|
||||||
|
lines[i] = origin + trimmed
|
||||||
|
else if Left(trimmed, 1) = "#" and InStr(UCase(trimmed), "URI=" + chr(34) + "/") > 0
|
||||||
|
' attribute form: #EXT-X-MEDIA:...URI="/..." etc.
|
||||||
|
' split on double quotes; rewrite any segment that starts
|
||||||
|
' with a bare slash. no index math needed.
|
||||||
|
parts = trimmed.Split(chr(34))
|
||||||
|
for p = 0 to parts.Count() - 1
|
||||||
|
if Left(parts[p], 1) = "/"
|
||||||
|
parts[p] = origin + parts[p]
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
lines[i] = parts.Join(chr(34))
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
return lines.Join(chr(10))
|
||||||
|
end function
|
||||||
|
|
||||||
function GetPlayerMetadata() as object
|
function GetPlayerMetadata() as object
|
||||||
player = m.videoQueue.player
|
player = m.videoQueue.player
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,780 @@
|
|||||||
|
import "pkg:/components/Services/Piped/PipedToInvidious.bs"
|
||||||
|
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||||
|
import "pkg:/source/services/HttpClient.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
import "pkg:/source/utils/UrlUtils.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
import "pkg:/components/Web/WebServer/Http/HttpRouter.bs"
|
||||||
|
|
||||||
|
' Serves the Invidious /api/v1 JSON shapes that Playlet's client expects,
|
||||||
|
' translated from a real Piped instance (https://github.com/TeamPiped/Piped).
|
||||||
|
' Mounted on Playlet's local web server, the client talks to:
|
||||||
|
' http://127.0.0.1:8888/playlet-piped-backend/api/v1/...
|
||||||
|
' and this router fetches:
|
||||||
|
' {piped.instance}/trending, /search, /streams/{id}, /channel/{id}, ...
|
||||||
|
' (Piped serves its REST API at the instance root, no /api/v1 prefix.)
|
||||||
|
namespace Http
|
||||||
|
|
||||||
|
class PipedBackendRouter extends HttpRouter
|
||||||
|
|
||||||
|
function new(server as object)
|
||||||
|
super()
|
||||||
|
|
||||||
|
m.preferences = server.sceneNodes.preferences
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetBaseUrl() as string
|
||||||
|
instance = ValidString(m.preferences["piped.instance"])
|
||||||
|
if StringUtils.IsNullOrEmpty(instance)
|
||||||
|
instance = "https://api.piped.spaghet.io"
|
||||||
|
end if
|
||||||
|
if instance.Right(1) = "/"
|
||||||
|
instance = instance.Left(instance.Len() - 1)
|
||||||
|
end if
|
||||||
|
v1 = instance.InStr("/api/v1")
|
||||||
|
if v1 > 0
|
||||||
|
instance = instance.Left(v1)
|
||||||
|
end if
|
||||||
|
return instance
|
||||||
|
end function
|
||||||
|
|
||||||
|
' GET /playlet-piped-backend/api/v1/manifest?url=<piped hls master>
|
||||||
|
' Fetches the Piped HLS master and rewrites its relative variant and
|
||||||
|
' media URIs to absolute proxy URLs, so Playlet's /api/hls proxy and
|
||||||
|
' the Roku player resolve them against the Piped instance, not 127.0.0.1.
|
||||||
|
function GetRewrittenHlsManifest(context as object) as boolean
|
||||||
|
request = context.request
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
url = request.query.url
|
||||||
|
if StringUtils.IsNullOrEmpty(url)
|
||||||
|
response.Default(400, "Missing url")
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
hlsResponse = HttpClient.Get(url).Await()
|
||||||
|
if not hlsResponse.IsSuccess()
|
||||||
|
LogWarn("Piped backend: manifest fetch failed", url, hlsResponse.StatusCode())
|
||||||
|
response.Redirect(url)
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
manifest = m.MakeRelativeUrisAbsolute(hlsResponse.Text(), url)
|
||||||
|
|
||||||
|
response.http_code = 200
|
||||||
|
response.headers["Content-Type"] = "application/x-mpegURL"
|
||||||
|
response.headers["Cache-Control"] = "no-cache, must-revalidate"
|
||||||
|
response.SetBodyDataString(manifest)
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function MakeRelativeUrisAbsolute(manifest as string, baseUrl as string) as string
|
||||||
|
if manifest = invalid or manifest = "" or baseUrl = invalid or baseUrl = ""
|
||||||
|
return manifest
|
||||||
|
end if
|
||||||
|
|
||||||
|
parsedUrl = UrlUtils.ParseUrl(baseUrl)
|
||||||
|
if parsedUrl = invalid or parsedUrl.host = invalid
|
||||||
|
return manifest
|
||||||
|
end if
|
||||||
|
|
||||||
|
protocol = ValidString(parsedUrl.protocol)
|
||||||
|
if protocol = ""
|
||||||
|
protocol = "https"
|
||||||
|
end if
|
||||||
|
origin = protocol + "://" + parsedUrl.host
|
||||||
|
port = ValidString(parsedUrl.port)
|
||||||
|
if port <> "" and port <> "80" and port <> "443"
|
||||||
|
origin = origin + ":" + port
|
||||||
|
end if
|
||||||
|
|
||||||
|
bareCount = 0
|
||||||
|
attrCount = 0
|
||||||
|
' normalize line endings: some hosts serve manifests with CR-only
|
||||||
|
' line terminators, which Split("\n") would leave as one line
|
||||||
|
manifest = manifest.Replace(chr(13) + chr(10), chr(10))
|
||||||
|
manifest = manifest.Replace(chr(13), chr(10))
|
||||||
|
|
||||||
|
lines = manifest.Split(chr(10))
|
||||||
|
for i = 0 to lines.Count() - 1
|
||||||
|
trimmed = lines[i].Trim()
|
||||||
|
|
||||||
|
if Left(trimmed, 1) = "/"
|
||||||
|
' bare relative URI line (variant/media playlist)
|
||||||
|
lines[i] = origin + trimmed
|
||||||
|
bareCount = bareCount + 1
|
||||||
|
else if Left(trimmed, 1) = "#" and InStr(UCase(trimmed), "URI=" + chr(34) + "/") > 0
|
||||||
|
' attribute form: #EXT-X-MEDIA:...URI="/..." etc.
|
||||||
|
parts = trimmed.Split(chr(34))
|
||||||
|
for q = 0 to parts.Count() - 1
|
||||||
|
if Left(parts[q], 1) = "/"
|
||||||
|
parts[q] = origin + parts[q]
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
lines[i] = parts.Join(chr(34))
|
||||||
|
attrCount = attrCount + 1
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
result = lines.Join("\n")
|
||||||
|
return result
|
||||||
|
end function
|
||||||
|
|
||||||
|
function AuthLogSnapshot() as object
|
||||||
|
if m.authLog = invalid
|
||||||
|
return []
|
||||||
|
end if
|
||||||
|
return m.authLog
|
||||||
|
end function
|
||||||
|
|
||||||
|
function LibBuildTag() as string
|
||||||
|
return "PIPED-LIB-26"
|
||||||
|
end function
|
||||||
|
|
||||||
|
function FetchJson(path as string, params = invalid as object) as dynamic
|
||||||
|
url = m.GetBaseUrl() + path
|
||||||
|
|
||||||
|
request = HttpClient.Get(url)
|
||||||
|
if params <> invalid
|
||||||
|
for each key in params
|
||||||
|
value = params[key]
|
||||||
|
if value <> invalid and value <> ""
|
||||||
|
request.QueryParam(key, value)
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
end if
|
||||||
|
|
||||||
|
response = request.Await()
|
||||||
|
if not response.IsSuccess()
|
||||||
|
LogWarn("Piped backend: failed", path, response.StatusCode(), response.ErrorMessage())
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
|
return response.Json()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SendJson(response as object, body as object, httpCode = 200 as integer) as void
|
||||||
|
response.Json(body)
|
||||||
|
if httpCode <> 200
|
||||||
|
response.http_code = httpCode
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SendError(response as object, message as string) as void
|
||||||
|
m.SendJson(response, { error: message }, 500)
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- GET dispatch ----------------
|
||||||
|
|
||||||
|
@get("*")
|
||||||
|
function GetAll(context as object) as boolean
|
||||||
|
route = context.request.route
|
||||||
|
|
||||||
|
prefix = "/playlet-piped-backend/api/v1/"
|
||||||
|
if not route.StartsWith(prefix)
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
tail = route.Mid(prefix.Len())
|
||||||
|
q = tail.InStr("?")
|
||||||
|
if q > 0
|
||||||
|
tail = tail.Left(q - 1)
|
||||||
|
end if
|
||||||
|
parts = tail.Split("/")
|
||||||
|
head = ""
|
||||||
|
if parts.Count() > 0
|
||||||
|
head = parts[0]
|
||||||
|
end if
|
||||||
|
|
||||||
|
if tail = "manifest"
|
||||||
|
return m.GetRewrittenHlsManifest(context)
|
||||||
|
else if head = "stats"
|
||||||
|
return m.GetStats(context)
|
||||||
|
else if head = "trending"
|
||||||
|
return m.GetTrending(context)
|
||||||
|
else if head = "popular"
|
||||||
|
' Piped has no "popular" feed; trending is the closest match
|
||||||
|
return m.GetTrending(context)
|
||||||
|
else if tail = "search/suggestions"
|
||||||
|
return m.GetSearchSuggestions(context)
|
||||||
|
else if head = "search"
|
||||||
|
return m.GetSearch(context)
|
||||||
|
else if head = "videos" and parts.Count() >= 2
|
||||||
|
context.videoId = parts[1]
|
||||||
|
return m.GetVideo(context)
|
||||||
|
else if head = "comments" and parts.Count() >= 2
|
||||||
|
context.videoId = parts[1]
|
||||||
|
return m.GetComments(context)
|
||||||
|
else if head = "channels" and parts.Count() >= 2
|
||||||
|
context.channelId = parts[1]
|
||||||
|
return m.GetChannel(context)
|
||||||
|
else if head = "playlists" and parts.Count() >= 2
|
||||||
|
context.playlistId = parts[1]
|
||||||
|
return m.GetPlaylist(context)
|
||||||
|
else if head = "auth"
|
||||||
|
return m.GetAuth(context)
|
||||||
|
end if
|
||||||
|
|
||||||
|
return false
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- POST/DELETE dispatch (auth) ----------------
|
||||||
|
|
||||||
|
@post("*")
|
||||||
|
function PostAll(context as object) as boolean
|
||||||
|
if context.request.route.StartsWith("/playlet-piped-backend/api/v1/auth/")
|
||||||
|
return m.PostAuth(context)
|
||||||
|
end if
|
||||||
|
return false
|
||||||
|
end function
|
||||||
|
|
||||||
|
@delete("*")
|
||||||
|
function DeleteAll(context as object) as boolean
|
||||||
|
if context.request.route.StartsWith("/playlet-piped-backend/api/v1/auth/")
|
||||||
|
return m.DeleteAuth(context)
|
||||||
|
end if
|
||||||
|
return false
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- auth: token plumbing ----------------
|
||||||
|
|
||||||
|
' The client sends the profile accessToken as our wrapped JSON
|
||||||
|
' (PipedToInvidious.MakePipedTokenJson); Piped itself wants the bare
|
||||||
|
' session UUID in a raw Authorization header (no Bearer prefix -
|
||||||
|
' verified against api.piped.spaghet.io), or ?authToken= for /feed.
|
||||||
|
function GetAccessToken(request as object) as dynamic
|
||||||
|
header = ValidString(request.headers["Authorization"])
|
||||||
|
if StringUtils.IsNullOrEmpty(header)
|
||||||
|
header = ValidString(request.headers["authorization"])
|
||||||
|
end if
|
||||||
|
if StringUtils.IsNullOrEmpty(header)
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
if header.StartsWith("Bearer ")
|
||||||
|
header = header.Mid(7)
|
||||||
|
end if
|
||||||
|
session = PipedToInvidious.ExtractPipedSession(header)
|
||||||
|
if StringUtils.IsNullOrEmpty(session)
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
return session
|
||||||
|
end function
|
||||||
|
|
||||||
|
function RequireAccessToken(context as object) as dynamic
|
||||||
|
request = context.request
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
token = m.GetAccessToken(request)
|
||||||
|
m.LogAuthRequest(request.route, "tok-" + Left(ValidString(token), 9))
|
||||||
|
if token = invalid
|
||||||
|
m.LogAuthRequest(request.route, "403-no-token")
|
||||||
|
response.Json({ "error": Invidious.ERROR_NOT_AUTHENTICATED })
|
||||||
|
response.http_code = 403
|
||||||
|
end if
|
||||||
|
return token
|
||||||
|
end function
|
||||||
|
|
||||||
|
' rolling window of auth calls for field debugging (exposed via stats)
|
||||||
|
function LogAuthRequest(route as string, outcome as string) as void
|
||||||
|
if m.authLog = invalid
|
||||||
|
m.authLog = []
|
||||||
|
end if
|
||||||
|
m.authLog.push(ValidString(route) + " => " + outcome)
|
||||||
|
if m.authLog.Count() > 12
|
||||||
|
trimmed = []
|
||||||
|
for t = m.authLog.Count() - 12 to m.authLog.Count() - 1
|
||||||
|
trimmed.push(m.authLog[t])
|
||||||
|
end for
|
||||||
|
m.authLog = trimmed
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function PipedAuthGet(path as string, session as dynamic, params = invalid as object) as dynamic
|
||||||
|
request = HttpClient.Get(m.GetBaseUrl() + path)
|
||||||
|
if session <> invalid
|
||||||
|
if path = "/feed"
|
||||||
|
request.QueryParam("authToken", session)
|
||||||
|
else
|
||||||
|
request.Header("Authorization", session)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
' Piped's ThrottlingCache keys on path+query and replays cached
|
||||||
|
' error responses (re-seeding them on every hit), so one genuine
|
||||||
|
' 401 - e.g. right after the broker rotates a session - poisons
|
||||||
|
' this exact URL for the TV for as long as it keeps polling. A
|
||||||
|
' per-call nonce makes every authenticated upstream GET a fresh
|
||||||
|
' key and a real lookup; the fork's handlers ignore unknown params.
|
||||||
|
request.QueryParam("pb", CreateObject("roDeviceInfo").GetRandomUUID())
|
||||||
|
if params <> invalid
|
||||||
|
for each key in params
|
||||||
|
value = params[key]
|
||||||
|
if value <> invalid and value <> ""
|
||||||
|
request.QueryParam(key, value)
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
end if
|
||||||
|
return request.Await()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function PipedAuthPost(path as string, body as object, session as dynamic) as dynamic
|
||||||
|
request = HttpClient.Post(m.GetBaseUrl() + path)
|
||||||
|
request.Header("Content-Type", "application/json")
|
||||||
|
if session <> invalid
|
||||||
|
request.Header("Authorization", session)
|
||||||
|
end if
|
||||||
|
request.JsonBody(body)
|
||||||
|
return request.Await()
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- auth handlers ----------------
|
||||||
|
|
||||||
|
' GET /api/v1/auth/<what>
|
||||||
|
function GetAuth(context as object) as boolean
|
||||||
|
route = context.request.route
|
||||||
|
tail = route.Mid("/playlet-piped-backend/api/v1/auth/".Len())
|
||||||
|
parts = tail.Split("/")
|
||||||
|
head = ""
|
||||||
|
if parts.Count() > 0
|
||||||
|
head = parts[0]
|
||||||
|
end if
|
||||||
|
|
||||||
|
if head = "feed"
|
||||||
|
return m.GetAuthFeed(context)
|
||||||
|
else if head = "subscriptions"
|
||||||
|
return m.GetAuthSubscriptions(context)
|
||||||
|
else if head = "playlists"
|
||||||
|
if parts.Count() >= 2
|
||||||
|
context.playlistId = parts[1]
|
||||||
|
return m.GetAuthPlaylist(context)
|
||||||
|
end if
|
||||||
|
return m.GetAuthPlaylists(context)
|
||||||
|
else if head = "history"
|
||||||
|
' Piped (this fork) has no server-side watch history; the
|
||||||
|
' browser keeps it in IndexedDB. Return empty, not an error.
|
||||||
|
m.SendJson(context.response, { "items": [], "continuation": "" })
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
return m.UnsupportedAuth(context)
|
||||||
|
end function
|
||||||
|
|
||||||
|
' POST /api/v1/auth/history (mark watched) + /auth/subscriptions/<id> (subscribe)
|
||||||
|
function PostAuth(context as object) as boolean
|
||||||
|
route = context.request.route
|
||||||
|
tail = route.Mid("/playlet-piped-backend/api/v1/auth/".Len())
|
||||||
|
|
||||||
|
session = m.RequireAccessToken(context)
|
||||||
|
if session = invalid
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
if tail = "history" or Left(tail, 8) = "history/"
|
||||||
|
' no server-side history on this Piped fork: accept silently
|
||||||
|
m.SendJson(context.response, { "status": "ok" })
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
if tail = "subscriptions" or Left(tail, 14) = "subscriptions/"
|
||||||
|
' Playlet's Subscribe posts to /auth/subscriptions/<channelId>
|
||||||
|
channelId = ""
|
||||||
|
if tail.Len() > 14
|
||||||
|
channelId = tail.Mid(14)
|
||||||
|
end if
|
||||||
|
if StringUtils.IsNullOrEmpty(channelId)
|
||||||
|
m.SendJson(context.response, { "error": "Missing channelId" }, 400)
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
res = m.PipedAuthPost("/subscribe", { channelId: channelId }, session)
|
||||||
|
if not res.IsSuccess()
|
||||||
|
LogWarn("Piped backend: subscribe failed", res.StatusCode())
|
||||||
|
m.SendJson(context.response, { "error": "Subscribe failed" }, 502)
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
m.SendJson(context.response, { "status": "ok" })
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
' tokens/register etc. - accept, Piped sessions need no registration
|
||||||
|
m.SendJson(context.response, { "status": "ok" })
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
' DELETE /api/v1/auth/subscriptions/<channelId>
|
||||||
|
function DeleteAuth(context as object) as boolean
|
||||||
|
route = context.request.route
|
||||||
|
tail = route.Mid("/playlet-piped-backend/api/v1/auth/".Len())
|
||||||
|
|
||||||
|
session = m.RequireAccessToken(context)
|
||||||
|
if session = invalid
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
if Left(tail, 14) = "subscriptions/"
|
||||||
|
channelId = tail.Mid(14)
|
||||||
|
res = m.PipedAuthPost("/unsubscribe", { channelId: channelId }, session)
|
||||||
|
if not res.IsSuccess()
|
||||||
|
LogWarn("Piped backend: unsubscribe failed", res.StatusCode())
|
||||||
|
m.SendJson(context.response, { "error": "Unsubscribe failed" }, 502)
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
m.SendJson(context.response, { "status": "ok" })
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
' logout/unregister: do NOT call Piped /logout - the same session
|
||||||
|
' is in use by the user's browser, and logging out would kill it.
|
||||||
|
m.SendJson(context.response, { "status": "ok" })
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetAuthFeed(context as object) as boolean
|
||||||
|
session = m.RequireAccessToken(context)
|
||||||
|
if session = invalid
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
res = m.PipedAuthGet("/feed", session)
|
||||||
|
if not res.IsSuccess()
|
||||||
|
m.LogAuthRequest(context.request.route, `feed-upstream-${res.StatusCode()}`)
|
||||||
|
LogWarn("Piped backend: auth feed failed", res.StatusCode())
|
||||||
|
if m.IsSessionRejected(res, session)
|
||||||
|
m.SendSessionRejected(context.response)
|
||||||
|
else
|
||||||
|
m.SendJson(context.response, { "error": "Feed unavailable" }, 502)
|
||||||
|
end if
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.LogAuthRequest(context.request.route, "feed-ok")
|
||||||
|
items = PipedToInvidious.VideosFromPiped(res.Json())
|
||||||
|
m.SendJson(context.response, { "videos": items })
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetAuthSubscriptions(context as object) as boolean
|
||||||
|
session = m.RequireAccessToken(context)
|
||||||
|
if session = invalid
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
res = m.PipedAuthGet("/subscriptions", session)
|
||||||
|
if not res.IsSuccess()
|
||||||
|
m.LogAuthRequest(context.request.route, `subs-upstream-${res.StatusCode()}`)
|
||||||
|
LogWarn("Piped backend: subscriptions failed", res.StatusCode())
|
||||||
|
if m.IsSessionRejected(res, session)
|
||||||
|
m.SendSessionRejected(context.response)
|
||||||
|
else
|
||||||
|
m.SendJson(context.response, { "error": "Subscriptions unavailable" }, 502)
|
||||||
|
end if
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
subsData = res.Json()
|
||||||
|
subsCount = 0
|
||||||
|
if IsArray(subsData)
|
||||||
|
subsCount = subsData.Count()
|
||||||
|
end if
|
||||||
|
m.LogAuthRequest(context.request.route, `subs-ok-${subsCount}`)
|
||||||
|
m.SendJson(context.response, PipedToInvidious.SubscriptionsFromPiped(res.Json()))
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetAuthPlaylists(context as object) as boolean
|
||||||
|
session = m.RequireAccessToken(context)
|
||||||
|
if session = invalid
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
res = m.PipedAuthGet("/user/playlists", session)
|
||||||
|
if not res.IsSuccess()
|
||||||
|
m.LogAuthRequest(context.request.route, `playlists-upstream-${res.StatusCode()}`)
|
||||||
|
LogWarn("Piped backend: playlists failed", res.StatusCode())
|
||||||
|
if m.IsSessionRejected(res, session)
|
||||||
|
m.SendSessionRejected(context.response)
|
||||||
|
else
|
||||||
|
m.SendJson(context.response, { "error": "Playlists unavailable" }, 502)
|
||||||
|
end if
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.SendJson(context.response, PipedToInvidious.AuthPlaylistsFromPiped(res.Json()))
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetAuthPlaylist(context as object) as boolean
|
||||||
|
session = m.RequireAccessToken(context)
|
||||||
|
if session = invalid
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
playlistId = ValidString(context.playlistId)
|
||||||
|
res = m.PipedAuthGet(`/playlists/${playlistId}`, session)
|
||||||
|
if not res.IsSuccess()
|
||||||
|
m.SendJson(context.response, { "error": "Playlist unavailable" }, 502)
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.SendJson(context.response, PipedToInvidious.PlaylistFromPiped(res.Json(), playlistId))
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Piped rejects a rotated/dead session with 401 "An invalid Session ID
|
||||||
|
' was provided." Playlet's MarkNeedsReauthIfCredentialsRejected only
|
||||||
|
' fires on a 403 whose body contains this exact Invidious phrasing,
|
||||||
|
' so translate: broker rotation then cleanly re-arms the TV login.
|
||||||
|
function SendSessionRejected(response as object) as void
|
||||||
|
response.Json({ "error": "Request must be authenticated" })
|
||||||
|
response.http_code = 403
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Piped's ThrottlingCache replays error responses per path (and can
|
||||||
|
' answer a live session with a stale 401 for minutes), so a 401 here
|
||||||
|
' is NOT proof of death. Confirm against two independent endpoints;
|
||||||
|
' only if BOTH also reject is the session truly gone. When the picture
|
||||||
|
' stays ambiguous, callers get a 502 instead: the row shows "failed to
|
||||||
|
' load" and retries on the next refresh, but the stored profile - and
|
||||||
|
' its token - survive, instead of MarkNeedsReauth wiping a live login.
|
||||||
|
function IsSessionRejected(res as object, session as dynamic) as boolean
|
||||||
|
if res.StatusCode() <> 401 and not (res.StatusCode() = 400 and res.Text().InStr("session is a required parameter") > 0)
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
if session = invalid
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
probe1 = m.PipedAuthGet("/subscriptions", session)
|
||||||
|
m.LogAuthRequest("probe1", `subs-${probe1.StatusCode()}`)
|
||||||
|
if probe1.IsSuccess()
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
probe2 = m.PipedAuthGet("/user/playlists", session)
|
||||||
|
m.LogAuthRequest("probe2", `playlists-${probe2.StatusCode()}`)
|
||||||
|
if probe2.IsSuccess()
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
' Both probes rejected too - but they can replay throttle 401s as
|
||||||
|
' well. One last delay-and-retry on the primary probe distinguishes
|
||||||
|
' a throttle window (persists ~minutes) from... nothing; if the
|
||||||
|
' retry still 401s we accept the verdict and ask for re-login.
|
||||||
|
wait(3000, CreateObject("roMessagePort"))
|
||||||
|
probe3 = m.PipedAuthGet("/subscriptions", session)
|
||||||
|
m.LogAuthRequest("probe3", `subs-retry-${probe3.StatusCode()}`)
|
||||||
|
return not probe3.IsSuccess()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function UnsupportedAuth(context as object) as boolean
|
||||||
|
m.SendJson(context.response, {
|
||||||
|
"error": "Piped backend accounts are not supported yet. Browse anonymously, or log in to your Piped instance in a browser."
|
||||||
|
}, 400)
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- handlers ----------------
|
||||||
|
|
||||||
|
function GetStats(context as object) as boolean
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
stats = m.FetchJson("/stats")
|
||||||
|
if not IsAssociativeArray(stats)
|
||||||
|
stats = {}
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.SendJson(response, {
|
||||||
|
"buildTag": m.LibBuildTag()
|
||||||
|
"authLog": m.AuthLogSnapshot()
|
||||||
|
|
||||||
|
"software": "piped"
|
||||||
|
"version": ValidString(stats.version)
|
||||||
|
"userCount": ValidInt(stats.userCount)
|
||||||
|
"lastStreamed": ""
|
||||||
|
"videoCountPlaylists": 0
|
||||||
|
"videoCount": 0
|
||||||
|
"usage": {}
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetTrending(context as object) as boolean
|
||||||
|
request = context.request
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
region = ValidString(request.query.region)
|
||||||
|
if StringUtils.IsNullOrEmpty(region)
|
||||||
|
region = "US"
|
||||||
|
end if
|
||||||
|
|
||||||
|
items = m.FetchJson("/trending", { region: region })
|
||||||
|
if not IsArray(items)
|
||||||
|
m.SendError(response, "Failed to get trending feed")
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
videos = PipedToInvidious.VideosFromPiped(items)
|
||||||
|
if videos.Count() = 0
|
||||||
|
m.SendError(response, "Failed to get trending feed")
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
' Invidious /api/v1/trending returns a bare array; DefaultHandler
|
||||||
|
' wraps it as {items: [...]}.
|
||||||
|
response.Json(videos)
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetSearchSuggestions(context as object) as boolean
|
||||||
|
request = context.request
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
query = ValidString(request.query.q)
|
||||||
|
|
||||||
|
items = m.FetchJson("/suggestions", { query: query })
|
||||||
|
suggestions = []
|
||||||
|
if IsArray(items)
|
||||||
|
for each item in items
|
||||||
|
suggestions.push(ValidString(item))
|
||||||
|
end for
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.SendJson(response, {
|
||||||
|
"suggestions": suggestions
|
||||||
|
"params": ""
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetSearch(context as object) as boolean
|
||||||
|
request = context.request
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
query = ValidString(request.query.q)
|
||||||
|
continuation = ValidString(request.query.continuation)
|
||||||
|
|
||||||
|
if StringUtils.IsNullOrEmpty(continuation)
|
||||||
|
params = { q: query, filter: "all" }
|
||||||
|
page = ValidString(request.query.page)
|
||||||
|
if not StringUtils.IsNullOrEmpty(page)
|
||||||
|
params.page = page
|
||||||
|
end if
|
||||||
|
data = m.FetchJson("/search", params)
|
||||||
|
else
|
||||||
|
nextpage = PipedToInvidious.Base64Decode(continuation)
|
||||||
|
data = m.FetchJson("/nextpage/search", { q: query, filter: "all", nextpage: nextpage })
|
||||||
|
end if
|
||||||
|
|
||||||
|
if not IsAssociativeArray(data) or not IsArray(data.items)
|
||||||
|
m.SendError(response, "Failed to search: no results found")
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.SendJson(response, PipedToInvidious.SearchFromPiped(data))
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetVideo(context as object) as boolean
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
data = m.FetchJson("/streams/" + context.videoId)
|
||||||
|
if not IsAssociativeArray(data) or StringUtils.IsNullOrEmpty(ValidString(data.title))
|
||||||
|
m.SendError(response, "Failed to get video info")
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
metadata = PipedToInvidious.VideoMetadataFromPiped(data, ValidString(context.videoId))
|
||||||
|
m.FillQualityLadder(metadata, ValidString(data.hls))
|
||||||
|
m.SendJson(response, metadata)
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
' The picker's ladder must mirror the HLS master's variants (that is what
|
||||||
|
' the /api/hls quality filter slices). videoStreams is unreliable: often
|
||||||
|
' empty or missing the master's top rungs. One extra small-text fetch per
|
||||||
|
' video; on failure the ladder stays empty and the player falls back to
|
||||||
|
' the standard rung list.
|
||||||
|
function FillQualityLadder(metadata as object, masterUrl as string) as void
|
||||||
|
if StringUtils.IsNullOrEmpty(masterUrl) or not IsAssociativeArray(metadata)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
response = HttpClient.Get(masterUrl).Await()
|
||||||
|
if not response.IsSuccess()
|
||||||
|
LogWarn("Piped backend: HLS master fetch failed", response.StatusCode())
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
levels = PipedToInvidious.QualityLevelsFromHlsMaster(response.Text())
|
||||||
|
if levels.Count() > 0
|
||||||
|
metadata["qualityLevels"] = levels
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetComments(context as object) as boolean
|
||||||
|
request = context.request
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
videoId = ValidString(context.videoId)
|
||||||
|
continuation = ValidString(request.query.continuation)
|
||||||
|
|
||||||
|
if StringUtils.IsNullOrEmpty(continuation)
|
||||||
|
data = m.FetchJson("/comments/" + videoId)
|
||||||
|
else
|
||||||
|
nextpage = PipedToInvidious.Base64Decode(continuation)
|
||||||
|
data = m.FetchJson("/nextpage/comments/" + videoId, { nextpage: nextpage })
|
||||||
|
end if
|
||||||
|
|
||||||
|
if not IsAssociativeArray(data)
|
||||||
|
m.SendError(response, "Failed to get comments")
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.SendJson(response, PipedToInvidious.CommentsFromPiped(data))
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetChannel(context as object) as boolean
|
||||||
|
request = context.request
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
channelId = ValidString(context.channelId)
|
||||||
|
continuation = ValidString(request.query.continuation)
|
||||||
|
|
||||||
|
if StringUtils.IsNullOrEmpty(continuation)
|
||||||
|
data = m.FetchJson("/channel/" + channelId)
|
||||||
|
else
|
||||||
|
nextpage = PipedToInvidious.Base64Decode(continuation)
|
||||||
|
data = m.FetchJson("/nextpage/channel/" + channelId, { nextpage: nextpage })
|
||||||
|
end if
|
||||||
|
|
||||||
|
if not IsAssociativeArray(data)
|
||||||
|
m.SendError(response, "Failed to get channel")
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.SendJson(response, PipedToInvidious.ChannelFromPiped(data, channelId))
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetPlaylist(context as object) as boolean
|
||||||
|
request = context.request
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
playlistId = ValidString(context.playlistId)
|
||||||
|
params = {}
|
||||||
|
continuation = ValidString(request.query.continuation)
|
||||||
|
if not StringUtils.IsNullOrEmpty(continuation)
|
||||||
|
params.nextpage = PipedToInvidious.Base64Decode(continuation)
|
||||||
|
end if
|
||||||
|
|
||||||
|
data = m.FetchJson("/playlists/" + playlistId, params)
|
||||||
|
if not IsAssociativeArray(data) or StringUtils.IsNullOrEmpty(ValidString(data.name))
|
||||||
|
m.SendError(response, "Failed to get playlist")
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.SendJson(response, PipedToInvidious.PlaylistFromPiped(data, playlistId))
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
end class
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -0,0 +1,526 @@
|
|||||||
|
import "pkg:/components/Services/Piped/PipedToInvidious.bs"
|
||||||
|
import "pkg:/source/services/HttpClient.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
import "pkg:/source/utils/UrlUtils.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
import "pkg:/components/Web/WebServer/Http/HttpRouter.bs"
|
||||||
|
|
||||||
|
namespace Http
|
||||||
|
' Phone-side login page for the Piped backend, mirroring InvidiousRouter's
|
||||||
|
' QR login flow. Served on the TV's local web server:
|
||||||
|
' GET /piped/login -> HTML page (SSO link + user/pass form)
|
||||||
|
' POST /piped/login -> {username,password} form -> Piped /login
|
||||||
|
' GET /piped/login/sso -> 302 to the instance's SSO broker (?next=/sso-tv...)
|
||||||
|
' GET /piped/token_callback -> ?token=<uuid>&nonce=<n> -> stores profile
|
||||||
|
' GET /piped/login/status -> JSON {waiting, username} for polling
|
||||||
|
' The login dialog on the TV closes itself when currentProfileChanged fires;
|
||||||
|
' this router only needs to create the profile via profilesService.
|
||||||
|
class PipedLoginRouter extends HttpRouter
|
||||||
|
function new(server as object)
|
||||||
|
super()
|
||||||
|
|
||||||
|
m.server = server
|
||||||
|
m.profilesNode = server.sceneNodes.profilesService
|
||||||
|
m.preferences = server.sceneNodes.preferences
|
||||||
|
|
||||||
|
m.routes.push({ method: "GET", path: "/piped/login", router: m, func: "LoginPage" })
|
||||||
|
m.routes.push({ method: "POST", path: "/piped/login", router: m, func: "SubmitPassword" })
|
||||||
|
m.routes.push({ method: "GET", path: "/piped/login/sso", router: m, func: "RedirectToSso" })
|
||||||
|
m.routes.push({ method: "GET", path: "/piped/token_callback", router: m, func: "TokenCallback" })
|
||||||
|
m.routes.push({ method: "GET", path: "/piped/login/status", router: m, func: "LoginStatus" })
|
||||||
|
m.routes.push({ method: "GET", path: "/piped/login/debug", router: m, func: "DebugToken" })
|
||||||
|
m.routes.push({ method: "GET", path: "/piped/login/verify", router: m, func: "VerifyProbe" })
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- shared ----------------
|
||||||
|
|
||||||
|
function Xml(text as string) as string
|
||||||
|
out = text.Replace("&", "&")
|
||||||
|
out = out.Replace("<", "<")
|
||||||
|
out = out.Replace(">", ">")
|
||||||
|
out = out.Replace(chr(34), """)
|
||||||
|
return out
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetInstance() as string
|
||||||
|
return ValidString(m.preferences["piped.instance"])
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetTvBaseUrl() as dynamic
|
||||||
|
' m.server is the HttpServer class; its .task is the PlayletWebServer
|
||||||
|
' SGTask which owns GetServerAddress (DialRouter uses the same task).
|
||||||
|
if m.server.task = invalid
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
return m.server.task@.GetServerAddress()
|
||||||
|
end function
|
||||||
|
|
||||||
|
' A small rolling window of issued nonces: the page may be reloaded,
|
||||||
|
' the QR rescanned, or a second phone pointed at the same dialog. A
|
||||||
|
' single-slot nonce made any of those (or a health probe) race the
|
||||||
|
' real login out of existence.
|
||||||
|
' Every page request issues a fresh nonce and keeps the three most
|
||||||
|
' recent valid, so whichever link/QR the phone actually holds still
|
||||||
|
' works - and a cached page response can never hand out a stale,
|
||||||
|
' already-consumed nonce.
|
||||||
|
' Every page request issues a fresh nonce. Nonces live in a fixed
|
||||||
|
' 4-slot ring so no roArray resize methods (removeIdx/deleteIdx/
|
||||||
|
' subArray, which vary by firmware) are ever needed - only plain
|
||||||
|
' index assignment. The three most recent nonces stay valid, so a
|
||||||
|
' reloaded page, a rescanned QR, or a health probe can never race
|
||||||
|
' the real login out of existence; older ones fall out of the ring.
|
||||||
|
' The ring lives in the registry so an app restart (or a redeploy)
|
||||||
|
' mid-login cannot 403 a callback whose nonce was issued before it:
|
||||||
|
' the phone may sit on the SSO provider's page for minutes while the
|
||||||
|
' TV side churns. Load once, save on every mutation.
|
||||||
|
function LoadNonceRing() as void
|
||||||
|
if m.loginNonces <> invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
m.loginNonces = ["", "", "", ""]
|
||||||
|
m.loginNonceSlot = 0
|
||||||
|
reg = CreateObject("roRegistrySection", "piped_login")
|
||||||
|
if reg.Exists("nonces")
|
||||||
|
stored = reg.Read("nonces").Split("|")
|
||||||
|
slot = Val(ValidString(reg.Read("slot")))
|
||||||
|
if slot >= 0 and slot < 4
|
||||||
|
m.loginNonceSlot = slot
|
||||||
|
end if
|
||||||
|
for i = 0 to 3
|
||||||
|
if i < stored.Count() and stored[i] <> invalid
|
||||||
|
m.loginNonces[i] = ValidString(stored[i])
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SaveNonceRing() as void
|
||||||
|
reg = CreateObject("roRegistrySection", "piped_login")
|
||||||
|
reg.Write("nonces", m.loginNonces[0] + "|" + m.loginNonces[1] + "|" + m.loginNonces[2] + "|" + m.loginNonces[3])
|
||||||
|
reg.Write("slot", Str(m.loginNonceSlot).Replace(" ", ""))
|
||||||
|
reg.Flush()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ClearNonceRing() as void
|
||||||
|
m.loginNonces = ["", "", "", ""]
|
||||||
|
m.loginNonceSlot = 0
|
||||||
|
m.SaveNonceRing()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function EnsureLoginNonce() as string
|
||||||
|
m.LoadNonceRing()
|
||||||
|
nonce = CreateObject("roDeviceInfo").GetRandomUUID()
|
||||||
|
m.loginNonces[m.loginNonceSlot] = nonce
|
||||||
|
m.loginNonceSlot = (m.loginNonceSlot + 1) mod 4
|
||||||
|
m.SaveNonceRing()
|
||||||
|
return nonce
|
||||||
|
end function
|
||||||
|
|
||||||
|
function KnownNonceIdx(nonce as string) as integer
|
||||||
|
m.LoadNonceRing()
|
||||||
|
if nonce = ""
|
||||||
|
return -1
|
||||||
|
end if
|
||||||
|
for i = 0 to 3
|
||||||
|
if m.loginNonces[i] = nonce
|
||||||
|
return i
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
return -1
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Put a nonce into the ring (no-op if already present). The SSO
|
||||||
|
' redirect re-registers the nonce its URL carries so a login that
|
||||||
|
' started before an app restart - which wipes the in-memory ring -
|
||||||
|
' can still complete its callback instead of 403ing.
|
||||||
|
function RegisterNonce(nonce as string) as void
|
||||||
|
m.LoadNonceRing()
|
||||||
|
for i = 0 to 3
|
||||||
|
if m.loginNonces[i] = nonce
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
m.loginNonces[m.loginNonceSlot] = nonce
|
||||||
|
m.loginNonceSlot = (m.loginNonceSlot + 1) mod 4
|
||||||
|
end function
|
||||||
|
|
||||||
|
' The gate script appends token+nonce to the cb URL while the cb
|
||||||
|
' template already carries a nonce, so the callback can arrive with
|
||||||
|
' the key twice; Playlet's query parser turns duplicate keys into an
|
||||||
|
' ARRAY and ValidString(array) is "" -> the nonce looked unknown.
|
||||||
|
function FirstStr(v as dynamic) as string
|
||||||
|
if GetInterface(v, "ifArray") <> invalid
|
||||||
|
if v.Count() > 0
|
||||||
|
return ValidString(v[0])
|
||||||
|
end if
|
||||||
|
return ""
|
||||||
|
end if
|
||||||
|
return ValidString(v)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ReadLastSession() as string
|
||||||
|
reg = CreateObject("roRegistrySection", "piped_login")
|
||||||
|
if reg.Exists("current")
|
||||||
|
return reg.Read("current")
|
||||||
|
end if
|
||||||
|
return ""
|
||||||
|
end function
|
||||||
|
|
||||||
|
function WriteLastSession(sessionUuid as string) as void
|
||||||
|
reg = CreateObject("roRegistrySection", "piped_login")
|
||||||
|
reg.Write("current", sessionUuid)
|
||||||
|
reg.Flush()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SetLoggedInProfile(username as string, sessionUuid as string) as void
|
||||||
|
instance = m.GetInstance()
|
||||||
|
port = Str(m.server.task.port).Replace(" ", "")
|
||||||
|
serverUrl = "http://127.0.0.1:" + port + "/playlet-piped-backend"
|
||||||
|
tokenJson = PipedToInvidious.MakePipedTokenJson(username, sessionUuid, instance)
|
||||||
|
|
||||||
|
profile = CreateObject("roSGNode", "ProfileContentNode")
|
||||||
|
profile.type = "invidious"
|
||||||
|
profile.username = username
|
||||||
|
profile.accessToken = tokenJson
|
||||||
|
profile.serverUrl = serverUrl
|
||||||
|
m.profilesNode@.LoginWithProfile(profile)
|
||||||
|
|
||||||
|
m.loggedInUsername = username
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- GET /piped/login ----------------
|
||||||
|
|
||||||
|
function LoginPage(context as object) as boolean
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
nonce = m.EnsureLoginNonce()
|
||||||
|
instance = m.GetInstance()
|
||||||
|
|
||||||
|
html = m.PageShell("Sign in to Piped", m.Body(instance, nonce))
|
||||||
|
response.http_code = 200
|
||||||
|
response.headers["Cache-Control"] = "no-store, max-age=0"
|
||||||
|
response.ContentType("text/html")
|
||||||
|
response.SetBodyDataString(html)
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Body(instance as string, nonce as string) as string
|
||||||
|
ssoLink = "/piped/login/sso?nonce=" + nonce
|
||||||
|
return `
|
||||||
|
<div class="card">
|
||||||
|
<h1>Piped</h1>
|
||||||
|
<p class="muted">Instance: ${m.Xml(instance)}</p>
|
||||||
|
<a class="btn primary" href="${ssoLink}">Sign in with SSO (Authentik)</a>
|
||||||
|
<div class="sep">or use a Piped account</div>
|
||||||
|
<form method="POST" action="/piped/login">
|
||||||
|
<input name="username" type="text" placeholder="username" autocomplete="username" required>
|
||||||
|
<input name="password" type="password" placeholder="password" autocomplete="current-password" required>
|
||||||
|
<input type="hidden" name="nonce" value="${nonce}">
|
||||||
|
<button class="btn" type="submit">Sign in</button>
|
||||||
|
</form>
|
||||||
|
<p class="muted small">This signs in the TV only. Your phone browser session is untouched. SSO accounts have no password; use the SSO button.</p>
|
||||||
|
</div>`
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- GET /piped/login/sso ----------------
|
||||||
|
|
||||||
|
function RedirectToSso(context as object) as boolean
|
||||||
|
request = context.request
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
reqNonce = m.FirstStr(request.query.nonce)
|
||||||
|
if reqNonce <> ""
|
||||||
|
' The phone clicked the link the login page handed out; keep
|
||||||
|
' that nonce valid for the callback this redirect starts,
|
||||||
|
' even if the app restarted (ring wiped) in between.
|
||||||
|
nonce = reqNonce
|
||||||
|
m.RegisterNonce(reqNonce)
|
||||||
|
else
|
||||||
|
nonce = m.EnsureLoginNonce()
|
||||||
|
end if
|
||||||
|
|
||||||
|
instance = m.GetInstance()
|
||||||
|
if StringUtils.IsNullOrEmpty(instance)
|
||||||
|
response.Default(503, "Piped instance not configured")
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
tv = m.GetTvBaseUrl()
|
||||||
|
if tv = invalid
|
||||||
|
response.Default(503, "TV address not available")
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
callback = `${tv}/piped/token_callback?nonce=${nonce}`
|
||||||
|
' The SSO broker lives on the API origin (SSO_PUBLIC_ORIGIN) under /sso
|
||||||
|
broker = instance
|
||||||
|
if Right(broker, 1) = "/"
|
||||||
|
broker = broker.Left(broker.Len() - 1)
|
||||||
|
end if
|
||||||
|
' next must be a same-origin path on the Piped frontend; the gate
|
||||||
|
' script special-cases the /sso-tv path and bounces the phone here.
|
||||||
|
nextPath = "/sso-tv?cb=" + callback.EncodeUriComponent() + "&nonce=" + nonce.EncodeUriComponent()
|
||||||
|
ssoUrl = `${broker}/sso/?next=${nextPath.EncodeUriComponent()}`
|
||||||
|
|
||||||
|
response.Redirect(ssoUrl, 302)
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- POST /piped/login (username/password) ----------------
|
||||||
|
|
||||||
|
function SubmitPassword(context as object) as boolean
|
||||||
|
request = context.request
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
fields = m.ParseFormBody(ValidString(request.BodyText()))
|
||||||
|
username = ValidString(fields.username)
|
||||||
|
password = ValidString(fields.password)
|
||||||
|
nonce = m.FirstStr(fields.nonce)
|
||||||
|
|
||||||
|
if nonce <> "" and m.KnownNonceIdx(nonce) < 0
|
||||||
|
response.Default(400, m.ErrorPage(`Stale login page. <a href="/piped/login">Start again</a>`))
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
if StringUtils.IsNullOrEmpty(username) or StringUtils.IsNullOrEmpty(password)
|
||||||
|
response.Default(400, m.ErrorPage("Username and password are required."))
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
instance = m.GetInstance()
|
||||||
|
if StringUtils.IsNullOrEmpty(instance)
|
||||||
|
response.Default(503, m.ErrorPage("Piped instance not configured on the TV."))
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
body = FormatJson({ username: username, password: password })
|
||||||
|
httpRequest = HttpClient.Post(`${instance}/login`)
|
||||||
|
httpRequest.Header("Content-Type", "application/json")
|
||||||
|
res = httpRequest.TextBody(body).Await()
|
||||||
|
|
||||||
|
data = res.Json()
|
||||||
|
if not res.IsSuccess() or not IsAssociativeArray(data) or StringUtils.IsNullOrEmpty(ValidString(data.token))
|
||||||
|
detail = "Login failed."
|
||||||
|
if IsAssociativeArray(data) and not StringUtils.IsNullOrEmpty(ValidString(data.error))
|
||||||
|
detail = ValidString(data.error)
|
||||||
|
end if
|
||||||
|
response.http_code = 200
|
||||||
|
response.headers["Cache-Control"] = "no-store, max-age=0"
|
||||||
|
response.ContentType("text/html")
|
||||||
|
response.SetBodyDataString(m.ErrorPage(detail + " <a href='/piped/login'>Try again</a>"))
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.SetLoggedInProfile(username, ValidString(data.token))
|
||||||
|
|
||||||
|
response.http_code = 200
|
||||||
|
response.headers["Cache-Control"] = "no-store, max-age=0"
|
||||||
|
response.ContentType("text/html")
|
||||||
|
response.SetBodyDataString(m.PageShell("Signed in", m.SuccessBody(username)))
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ParseFormBody(form as string) as object
|
||||||
|
fields = {}
|
||||||
|
for each pair in form.Split("&")
|
||||||
|
eq = pair.InStr("=")
|
||||||
|
if eq <= 1
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
key = pair.Left(eq - 1).DecodeUriComponent()
|
||||||
|
value = pair.Mid(eq + 1).DecodeUriComponent()
|
||||||
|
fields[key] = value
|
||||||
|
end for
|
||||||
|
return fields
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- GET /piped/token_callback (SSO handoff) ----------------
|
||||||
|
|
||||||
|
function TokenCallback(context as object) as boolean
|
||||||
|
request = context.request
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
token = m.FirstStr(request.query.token)
|
||||||
|
nonce = m.FirstStr(request.query.nonce)
|
||||||
|
|
||||||
|
if StringUtils.IsNullOrEmpty(token)
|
||||||
|
response.Default(400, m.ErrorPage("Missing token."))
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
' Only accept a login this device handed out (a nonce from the
|
||||||
|
' rolling window above). Consume it so each link is single-use.
|
||||||
|
idx = m.KnownNonceIdx(nonce)
|
||||||
|
if idx < 0
|
||||||
|
' A consumed nonce arriving with the SAME session we just
|
||||||
|
' installed is a retry/replay of a login that already
|
||||||
|
' succeeded (the gate script can bounce the phone twice) -
|
||||||
|
' show success, not an error the user cannot act on.
|
||||||
|
if nonce <> "" and token = m.ReadLastSession()
|
||||||
|
response.http_code = 200
|
||||||
|
response.headers["Cache-Control"] = "no-store, max-age=0"
|
||||||
|
response.ContentType("text/html")
|
||||||
|
response.SetBodyDataString(m.PageShell("Signed in", m.SuccessBody(m.LookupUsername(token))))
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
response.Default(403, m.ErrorPage(`Login link expired or already used. <a href="/piped/login">Start again</a>`))
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
' consume: blank the slot (roArray splice ops vary by firmware)
|
||||||
|
m.loginNonces[idx] = ""
|
||||||
|
m.SaveNonceRing()
|
||||||
|
|
||||||
|
' Resolve the username for the session, best effort.
|
||||||
|
username = m.LookupUsername(token)
|
||||||
|
|
||||||
|
m.SetLoggedInProfile(username, token)
|
||||||
|
m.WriteLastSession(token)
|
||||||
|
|
||||||
|
response.http_code = 200
|
||||||
|
response.headers["Cache-Control"] = "no-store, max-age=0"
|
||||||
|
response.ContentType("text/html")
|
||||||
|
response.SetBodyDataString(m.PageShell("Signed in", m.SuccessBody(username)))
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
' The fork has no /user endpoint, but the authenticated RSS feed names
|
||||||
|
' the account: its <subtitle> is "Piped's RSS subscription feed for
|
||||||
|
' <username>.". Read the username from there; fall back to a stable
|
||||||
|
' uuid label if the shape ever changes. (The profile name is cosmetic.)
|
||||||
|
function LookupUsername(sessionUuid as string) as string
|
||||||
|
instance = m.GetInstance()
|
||||||
|
if StringUtils.IsNullOrEmpty(instance)
|
||||||
|
return "piped"
|
||||||
|
end if
|
||||||
|
|
||||||
|
' /feed/rss authenticates via ?authToken= (same contract as /feed).
|
||||||
|
' The pb nonce keeps this off Piped's ThrottlingCache replay keys.
|
||||||
|
nonce = CreateObject("roDeviceInfo").GetRandomUUID()
|
||||||
|
url = `${instance}/feed/rss?authToken=${sessionUuid}&pb=${nonce}`
|
||||||
|
res = HttpClient.Get(url).Await()
|
||||||
|
xml = ""
|
||||||
|
if res.IsSuccess()
|
||||||
|
xml = res.Text()
|
||||||
|
end if
|
||||||
|
if not StringUtils.IsNullOrEmpty(xml)
|
||||||
|
' Split instead of Mid/InStr: substring indexing disagreed with
|
||||||
|
' the docs on this firmware (both off-by-one directions shipped
|
||||||
|
' wrong results); Split boundaries are unambiguous.
|
||||||
|
marker = "feed for "
|
||||||
|
parts = xml.Split(marker)
|
||||||
|
if parts.Count() > 1
|
||||||
|
tail = ValidString(parts[1])
|
||||||
|
name = ValidString(tail.Split(".")[0])
|
||||||
|
if name.Len() > 0 and name.Len() < 25
|
||||||
|
return name
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
return "piped-" + Left(sessionUuid, 8)
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- GET /piped/login/status ----------------
|
||||||
|
|
||||||
|
function LoginStatus(context as object) as boolean
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
response.Json({
|
||||||
|
"waiting": m.loginNonces <> invalid and m.loginNonces.Count() > 0
|
||||||
|
"username": ValidString(m.loggedInUsername)
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function DebugToken(context as object) as boolean
|
||||||
|
tj = PipedToInvidious.MakePipedTokenJson("u1", "abc-def", "https://api.piped.spaghet.io")
|
||||||
|
parsed = StringUtils.ParseJsonSafe(tj)
|
||||||
|
extracted = PipedToInvidious.ExtractPipedSession(tj)
|
||||||
|
context.response.http_code = 200
|
||||||
|
context.response.Json({
|
||||||
|
"tokenJsonType": type(tj)
|
||||||
|
"tokenJsonLen": Str(tj.Len())
|
||||||
|
"tokenJson": tj
|
||||||
|
"parsedOk": IsAssociativeArray(parsed)
|
||||||
|
"extracted": extracted
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Replays the two boot-time checks Playlet applies to a stored
|
||||||
|
' invidious profile token (DeriveAuthState + VerifyTokenScope) and
|
||||||
|
' reports each step, to find why a freshly stored Piped token gets
|
||||||
|
' marked NeedsReauth after an app restart.
|
||||||
|
function VerifyProbe(context as object) as boolean
|
||||||
|
response = context.response
|
||||||
|
|
||||||
|
profiles = m.profilesNode@.GetProfilesDto(true)
|
||||||
|
out = { "steps": [] }
|
||||||
|
for each profile in profiles.profiles
|
||||||
|
tok = ValidString(profile.accessToken)
|
||||||
|
s = {
|
||||||
|
"username": ValidString(profile.username)
|
||||||
|
"tokLen": Len(tok)
|
||||||
|
"tokHead": Left(tok, 40)
|
||||||
|
}
|
||||||
|
parsed = StringUtils.ParseJsonSafe(tok)
|
||||||
|
s["parsed"] = IsAssociativeArray(parsed)
|
||||||
|
if IsAssociativeArray(parsed)
|
||||||
|
scopes = parsed.scopes
|
||||||
|
s["scopesIsArray"] = IsArray(scopes)
|
||||||
|
if IsArray(scopes)
|
||||||
|
joined = scopes.Join(",")
|
||||||
|
s["scopesMatch"] = (joined = "GET:feed,GET:playlists*,POST:tokens/*,:history*,:subscriptions*")
|
||||||
|
s["scopesJoined"] = joined
|
||||||
|
end if
|
||||||
|
s["expireType"] = type(parsed.expire)
|
||||||
|
s["expireIsNumber"] = IsNumber(parsed.expire)
|
||||||
|
nowS = TimeUtils.Now().AsSeconds()
|
||||||
|
s["expireVal"] = Str(parsed.expire)
|
||||||
|
s["nowVal"] = Str(nowS)
|
||||||
|
s["expired"] = (IsNumber(parsed.expire) and parsed.expire <= nowS)
|
||||||
|
end if
|
||||||
|
out.steps.push(s)
|
||||||
|
end for
|
||||||
|
|
||||||
|
response.http_code = 200
|
||||||
|
response.Json(out)
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
' ---------------- HTML ----------------
|
||||||
|
|
||||||
|
function PageShell(title as string, body as string) as string
|
||||||
|
return `<!doctype html><html lang="en"><head>
|
||||||
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>${m.Xml(title)} - Piped on TV</title>
|
||||||
|
<style>
|
||||||
|
body{font:16px/1.5 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:#0f1115;color:#e6e8eb;display:flex;min-height:100vh;align-items:center;justify-content:center;margin:0;padding:16px}
|
||||||
|
.card{width:min(420px,100%);background:#171a21;border:1px solid #262b36;border-radius:14px;padding:28px;text-align:center}
|
||||||
|
h1{margin:0 0 4px;font-size:1.4rem;color:#38bdf8}
|
||||||
|
.muted{color:#98a2b3}.small{font-size:.85rem}
|
||||||
|
.btn{display:block;width:100%;box-sizing:border-box;margin:10px 0;padding:12px;border-radius:10px;border:1px solid #3b4353;background:#232833;color:#e6e8eb;font-size:1rem;text-decoration:none;cursor:pointer}
|
||||||
|
.btn.primary{background:#0ea5e9;border-color:#0ea5e9;color:#04121d;font-weight:600}
|
||||||
|
input{display:block;width:100%;box-sizing:border-box;margin:10px 0;padding:12px;border-radius:10px;border:1px solid #3b4353;background:#0f1115;color:#e6e8eb;font-size:1rem}
|
||||||
|
.sep{color:#67707f;font-size:.85rem;margin:18px 0 4px;text-transform:uppercase;letter-spacing:.06em}
|
||||||
|
.ok{font-size:2.2rem;color:#34d399;margin:0}
|
||||||
|
a{color:#38bdf8}
|
||||||
|
</style></head><body>${body}</body></html>`
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SuccessBody(username as string) as string
|
||||||
|
return `
|
||||||
|
<div class="card">
|
||||||
|
<p class="ok">✓</p>
|
||||||
|
<h1>Signed in to the TV</h1>
|
||||||
|
<p class="muted">Account: ${m.Xml(username)}</p>
|
||||||
|
<p class="muted small">You can close this page and grab the remote. The Piped app on your TV now has your subscriptions, playlists and recommended feed.</p>
|
||||||
|
</div>`
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ErrorPage(message as string) as string
|
||||||
|
return `<div class="card"><h1>Not signed in</h1><p>${message}</p></div>`
|
||||||
|
end function
|
||||||
|
|
||||||
|
end class
|
||||||
|
end namespace
|
||||||
@@ -8,6 +8,8 @@ import "pkg:/components/Web/PlayletWebServer/Middleware/HomeRouter.bs"
|
|||||||
import "pkg:/components/Web/PlayletWebServer/Middleware/InnertubeRouter.bs"
|
import "pkg:/components/Web/PlayletWebServer/Middleware/InnertubeRouter.bs"
|
||||||
import "pkg:/components/Web/PlayletWebServer/Middleware/InvidiousRouter.bs"
|
import "pkg:/components/Web/PlayletWebServer/Middleware/InvidiousRouter.bs"
|
||||||
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs"
|
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs"
|
||||||
|
import "pkg:/components/Web/PlayletWebServer/Middleware/PipedBackendRouter.bs"
|
||||||
|
import "pkg:/components/Web/PlayletWebServer/Middleware/PipedLoginRouter.bs"
|
||||||
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayletLibUrlsRouter.bs"
|
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayletLibUrlsRouter.bs"
|
||||||
import "pkg:/components/Web/PlayletWebServer/Middleware/PreferencesRouter.bs"
|
import "pkg:/components/Web/PlayletWebServer/Middleware/PreferencesRouter.bs"
|
||||||
import "pkg:/components/Web/PlayletWebServer/Middleware/ProfilesRouter.bs"
|
import "pkg:/components/Web/PlayletWebServer/Middleware/ProfilesRouter.bs"
|
||||||
@@ -65,6 +67,9 @@ function SetupRoutes(server as object)
|
|||||||
"/api/innertube/get_drm_license"
|
"/api/innertube/get_drm_license"
|
||||||
' Every write needs the caller's bearer token.
|
' Every write needs the caller's bearer token.
|
||||||
"/playlet-invidious-backend/"
|
"/playlet-invidious-backend/"
|
||||||
|
"/playlet-piped-backend/"
|
||||||
|
' The Piped phone login page posts a plain HTML form.
|
||||||
|
"/piped/"
|
||||||
]))
|
]))
|
||||||
if server.settings.WebSocketsEnabled
|
if server.settings.WebSocketsEnabled
|
||||||
server.UseRouter(new Http.WebSocketMiddleware())
|
server.UseRouter(new Http.WebSocketMiddleware())
|
||||||
@@ -86,6 +91,8 @@ function SetupRoutes(server as object)
|
|||||||
server.UseRouter(new Http.CacheRouter(server))
|
server.UseRouter(new Http.CacheRouter(server))
|
||||||
server.UseRouter(new Http.RegistryRouter())
|
server.UseRouter(new Http.RegistryRouter())
|
||||||
server.UseRouter(new Http.PlayletInvidiousBackendRouter(server))
|
server.UseRouter(new Http.PlayletInvidiousBackendRouter(server))
|
||||||
|
server.UseRouter(new Http.PipedLoginRouter(server))
|
||||||
|
server.UseRouter(new Http.PipedBackendRouter(server))
|
||||||
server.UseRouter(new Http.InnertubeRouter(server))
|
server.UseRouter(new Http.InnertubeRouter(server))
|
||||||
|
|
||||||
etags = new Http.EtagUtils()
|
etags = new Http.EtagUtils()
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
key: "backend.selected",
|
key: "backend.selected",
|
||||||
description: "The backend used for browsing and playing videos.",
|
description: "The backend used for browsing and playing videos.",
|
||||||
type: "radio",
|
type: "radio",
|
||||||
defaultValue: "playlet",
|
defaultValue: "piped",
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
displayText: "Playlet (local)",
|
displayText: "Playlet (local)",
|
||||||
@@ -56,10 +56,28 @@
|
|||||||
displayText: "Invidious",
|
displayText: "Invidious",
|
||||||
value: "invidious",
|
value: "invidious",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayText: "Piped",
|
||||||
|
value: "piped",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayText: "Piped",
|
||||||
|
key: "piped",
|
||||||
|
description: "Piped backend preferences",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
displayText: "Instance",
|
||||||
|
key: "piped.instance",
|
||||||
|
description: "Piped API instance to use. Example: https://api.piped.spaghet.io",
|
||||||
|
type: "string",
|
||||||
|
defaultValue: "https://api.piped.spaghet.io",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayText: "Content Feed",
|
displayText: "Content Feed",
|
||||||
key: "content_feed",
|
key: "content_feed",
|
||||||
|
|||||||
|
After Width: | Height: | Size: 729 B |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120">
|
||||||
|
<g fill="#FFF" stroke="#000" stroke-opacity="0.12" stroke-width="3" paint-order="stroke"><rect x="3" y="3" width="48" height="114" rx="4"/><rect x="69" y="3" width="48" height="114" rx="4"/></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 290 B |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
inputHash: '365d573b68143d3d9833785535315f05',
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
outputFilePath: 'images/icons/player/LargePause.png',
|
||||||
|
outputHash: 'e5d6bcc5e4d32775aa355aed829d6786',
|
||||||
|
width: 120,
|
||||||
|
height: 120,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120">
|
||||||
|
<foreignObject width="120" height="120"><div xmlns="http://www.w3.org/1999/xhtml" style="width:120px;height:120px;border-radius:50%;background:conic-gradient(rgba(255,255,255,0) 10deg,#FFF 360deg);-webkit-mask:radial-gradient(closest-side,transparent calc(100% - 7.5px),#000 calc(100% - 6.5px));mask:radial-gradient(closest-side,transparent calc(100% - 7.5px),#000 calc(100% - 6.5px))"/></foreignObject><circle cx="60" cy="3.5" r="3.5" fill="#FFF"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 545 B |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
inputHash: '05e22fbe084aba15195e28fed76638d3',
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
outputFilePath: 'images/icons/player/Spinner_MH.png',
|
||||||
|
outputHash: '11ace03cf9aeab9866ffdde4a78345d9',
|
||||||
|
width: 120,
|
||||||
|
height: 120,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
|
||||||
|
<g fill="#EFEFEF" stroke="#EFEFEF" stroke-width="2" stroke-linejoin="round"><g opacity="0.2"><path d="M25 3.5 L48 22.5 L25 41.5 Z"/><path d="M45 3.5 L68 22.5 L45 41.5 Z"/></g><path d="M5 3.5 L28 22.5 L5 41.5 Z"/></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 308 B |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
inputHash: '0986e8af2b2ff759cba17d83ef63c2fd',
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
outputFilePath: 'images/icons/player/icon_FFx1.png',
|
||||||
|
outputHash: '0977d7dd03d3bd50c6c17a24977e78f1',
|
||||||
|
width: 75,
|
||||||
|
height: 45,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
|
||||||
|
<g fill="#EFEFEF" stroke="#EFEFEF" stroke-width="2" stroke-linejoin="round"><g opacity="0.2"><path d="M45 3.5 L68 22.5 L45 41.5 Z"/></g><path d="M5 3.5 L28 22.5 L5 41.5 Z"/><path d="M25 3.5 L48 22.5 L25 41.5 Z"/></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 308 B |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
inputHash: '469eb45aa9d725130b41ea54bd193270',
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
outputFilePath: 'images/icons/player/icon_FFx2.png',
|
||||||
|
outputHash: 'eba816c002bd6fc834ef956681fb2dc0',
|
||||||
|
width: 75,
|
||||||
|
height: 45,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 767 B |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
|
||||||
|
<g fill="#EFEFEF" stroke="#EFEFEF" stroke-width="2" stroke-linejoin="round"><path d="M5 3.5 L28 22.5 L5 41.5 Z"/><path d="M25 3.5 L48 22.5 L25 41.5 Z"/><path d="M45 3.5 L68 22.5 L45 41.5 Z"/></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 287 B |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
inputHash: '980f9d24e3a1cb5c63b20009d9a16133',
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
outputFilePath: 'images/icons/player/icon_FFx3.png',
|
||||||
|
outputHash: '251be69bc462cd2e0f757c57eb24ad2c',
|
||||||
|
width: 75,
|
||||||
|
height: 45,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
|
||||||
|
<g transform="translate(75 0) scale(-1 1)"><g fill="#EFEFEF" stroke="#EFEFEF" stroke-width="2" stroke-linejoin="round"><g opacity="0.2"><path d="M25 3.5 L48 22.5 L25 41.5 Z"/><path d="M45 3.5 L68 22.5 L45 41.5 Z"/></g><path d="M5 3.5 L28 22.5 L5 41.5 Z"/></g></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 355 B |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
inputHash: 'fe8c1802a9432a779db5b47a8aee3cf2',
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
outputFilePath: 'images/icons/player/icon_RWx1.png',
|
||||||
|
outputHash: '69d38e14fa66c0fd8132b4baf6d5b2e4',
|
||||||
|
width: 75,
|
||||||
|
height: 45,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
|
||||||
|
<g transform="translate(75 0) scale(-1 1)"><g fill="#EFEFEF" stroke="#EFEFEF" stroke-width="2" stroke-linejoin="round"><g opacity="0.2"><path d="M45 3.5 L68 22.5 L45 41.5 Z"/></g><path d="M5 3.5 L28 22.5 L5 41.5 Z"/><path d="M25 3.5 L48 22.5 L25 41.5 Z"/></g></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 355 B |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
inputHash: '8008033b27507ebaee97e12b928037cc',
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
outputFilePath: 'images/icons/player/icon_RWx2.png',
|
||||||
|
outputHash: '5a65af95686da53580b631d54d2b85cc',
|
||||||
|
width: 75,
|
||||||
|
height: 45,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 817 B |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
|
||||||
|
<g transform="translate(75 0) scale(-1 1)"><g fill="#EFEFEF" stroke="#EFEFEF" stroke-width="2" stroke-linejoin="round"><path d="M5 3.5 L28 22.5 L5 41.5 Z"/><path d="M25 3.5 L48 22.5 L25 41.5 Z"/><path d="M45 3.5 L68 22.5 L45 41.5 Z"/></g></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 334 B |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
inputHash: '56cd45de7037c14773f5491e19998fce',
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
outputFilePath: 'images/icons/player/icon_RWx3.png',
|
||||||
|
outputHash: 'df054ef7dbdcf7f72ea68ff411d5fba1',
|
||||||
|
width: 75,
|
||||||
|
height: 45,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 315 B |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36">
|
||||||
|
<circle cx="18" cy="18" r="8" fill="#ABABAB"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 138 B |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
inputHash: 'fc641b4b8ae0068b538a47f8e9651e5f',
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
outputFilePath: 'images/icons/player/icon_inline_unselected_bullet.png',
|
||||||
|
outputHash: '44c1d2244a8107af370b49e0fc3675e1',
|
||||||
|
width: 36,
|
||||||
|
height: 36,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
|
||||||
|
<path d="M20 21.5 A17.5 17.5 0 1 1 25.13 34.87" fill="none" stroke="#EFEFEF" stroke-width="5.5" stroke-linecap="round"/><path d="M14.5 20.5 L27.5 20.5 L21 29.5 Z" fill="#EFEFEF" stroke="#EFEFEF" stroke-width="1.5" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 331 B |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
inputHash: '1cffb669ee3c117ac532eda41ec434fe',
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
outputFilePath: 'images/icons/player/icon_replay.png',
|
||||||
|
outputHash: 'daa27ea7c4054f8b136858e6493d8659',
|
||||||
|
width: 75,
|
||||||
|
height: 45,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 596 B |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
|
||||||
|
<g fill="#EFEFEF"><rect x="24" y="4" width="12" height="37" rx="2"/><rect x="43" y="4" width="12" height="37" rx="2"/><path d="M61 13.5 L72 22.5 L61 31.5 Z" stroke="#EFEFEF" stroke-width="1.5" stroke-linejoin="round"/></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 314 B |