Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
1b0466ad44 | ||
|
|
9eac1aac04 | ||
|
|
555665488d | ||
|
|
ae1d2b8acf | ||
|
|
4ef84a2f1f | ||
|
|
c9dfa19a60 | ||
|
|
1f069f80c3 | ||
|
|
99fdd31c36 | ||
|
|
b7fb8614b7 | ||
|
|
aa2acc5eb8 | ||
|
|
3c107c9920 |
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,37 +31,52 @@ 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 }}
|
|
||||||
|
|
||||||
# Static Channel Analysis disabled: errors on the missing rsg_version=1.3 manifest flag.
|
- name: Upload release
|
||||||
# - name: Use Java 21
|
uses: actions/upload-artifact@v4
|
||||||
# uses: actions/setup-java@v4
|
with:
|
||||||
# with:
|
name: release
|
||||||
# distribution: "temurin"
|
path: |
|
||||||
# java-version: "21"
|
release/playlet.zip
|
||||||
|
release/playlet.squashfs.pkg
|
||||||
|
release/playlet-lib.zip
|
||||||
|
release/playlet-lib.squashfs.pkg
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
# - name: Download the Static Channel Analysis CLI
|
publish:
|
||||||
# run: |
|
needs: build
|
||||||
# curl -sSL "https://devtools.web.roku.com/static-channel-analysis/sca-cmd.zip" -o sca-cmd.zip
|
runs-on: ubuntu-latest
|
||||||
# unzip sca-cmd.zip
|
|
||||||
|
|
||||||
# - name: Run Analysis on Playlet Lib
|
steps:
|
||||||
# run: ./sca-cmd/bin/sca-cmd ./release/playlet-lib.zip --exit error
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# - name: Run Analysis on Playlet App
|
- name: Download release
|
||||||
# run: ./sca-cmd/bin/sca-cmd ./release/playlet.zip --exit error
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: release
|
||||||
|
path: release
|
||||||
|
|
||||||
|
- name: Use Java 25
|
||||||
|
uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
distribution: "temurin"
|
||||||
|
java-version: "25"
|
||||||
|
|
||||||
|
- name: Download the Static Channel Analysis CLI
|
||||||
|
run: |
|
||||||
|
curl -sSL "https://devtools.web.roku.com/static-channel-analysis/sca-cmd.zip" -o sca-cmd.zip
|
||||||
|
unzip sca-cmd.zip
|
||||||
|
|
||||||
|
- name: Run Analysis on Playlet Lib
|
||||||
|
run: ./sca-cmd/bin/sca-cmd ./release/playlet-lib.zip --exit error
|
||||||
|
|
||||||
|
- name: Run Analysis on Playlet App
|
||||||
|
run: ./sca-cmd/bin/sca-cmd ./release/playlet.zip --exit error
|
||||||
|
|
||||||
- name: Delete Canary release
|
- name: Delete Canary release
|
||||||
uses: dev-drprasad/delete-tag-and-release@v1.0
|
uses: dev-drprasad/delete-tag-and-release@v1.0
|
||||||
|
|||||||
@@ -5,6 +5,27 @@ 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
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support for base transport commands (certification)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Error message when account requires age verification
|
||||||
|
- Live stream fixes
|
||||||
|
- Capture additional fields to investigate DRM errors
|
||||||
|
|
||||||
## [0.48.9] - 2026-10-14
|
## [0.48.9] - 2026-10-14
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -12,7 +12,15 @@
|
|||||||
},
|
},
|
||||||
// 1010 - Function overrides function in ancestor scope
|
// 1010 - Function overrides function in ancestor scope
|
||||||
// These overrides are intentional
|
// These overrides are intentional
|
||||||
1010
|
1010,
|
||||||
|
{
|
||||||
|
"src": "manifest",
|
||||||
|
"codes": [
|
||||||
|
// 1151 - rsg_version=1.3 requires Roku firmware version 15.0.0 or higher
|
||||||
|
// Certification requires rsg_version=1.3; older devices still load the lib
|
||||||
|
1151
|
||||||
|
]
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"diagnosticLevel": "hint",
|
"diagnosticLevel": "hint",
|
||||||
"minFirmwareVersion": "11.5.0",
|
"minFirmwareVersion": "11.5.0",
|
||||||
|
|||||||
@@ -1,35 +1,35 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.48.9",
|
"version": "0.48.11",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.48.9",
|
"version": "0.48.11",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rokucommunity/bslint": "^0.8.46",
|
"@rokucommunity/bslint": "^0.8.46",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/node": "^26.6.3",
|
"@types/node": "^26.6.5",
|
||||||
"@types/xml2js": "^0.4.14",
|
"@types/xml2js": "^0.4.14",
|
||||||
"argparse": "^3.0.2",
|
"argparse": "^3.0.3",
|
||||||
"brighterscript": "0.73.5",
|
"brighterscript": "0.73.7",
|
||||||
"brighterscript-formatter": "^1.8.3",
|
"brighterscript-formatter": "^1.8.4",
|
||||||
"convert-svg-to-png": "^0.7.1",
|
"convert-svg-to-png": "^0.7.1",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"dotenv": "^18.0.4",
|
"dotenv": "^18.0.8",
|
||||||
"fs-extra": "^11.4.1",
|
"fs-extra": "^11.4.1",
|
||||||
"glob": "^13.0.6",
|
"glob": "^13.0.6",
|
||||||
"imap": "^0.8.19",
|
"imap": "^0.8.19",
|
||||||
"ip": "^2.0.1",
|
"ip": "^2.0.1",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"mailparser": "^3.9.28",
|
"mailparser": "^3.9.39",
|
||||||
"protocol-buffers-schema": "^3.6.1",
|
"protocol-buffers-schema": "^3.6.1",
|
||||||
"roku-deploy": "^3.18.4",
|
"roku-deploy": "^3.18.4",
|
||||||
"roku-test-automation": "^2.2.2",
|
"roku-test-automation": "^2.2.2",
|
||||||
"rooibos-roku": "5.16.5",
|
"rooibos-roku": "5.17.0",
|
||||||
"semver": "^7.8.5",
|
"semver": "^7.8.5",
|
||||||
"shelljs": "^0.10.0",
|
"shelljs": "^0.10.0",
|
||||||
"telnet-client": "^2.2.14",
|
"telnet-client": "^2.2.14",
|
||||||
@@ -447,9 +447,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "26.6.3",
|
"version": "26.6.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.5.tgz",
|
||||||
"integrity": "sha512-dsqMQQoeTLqu9wynDD00q573mNzso3IdQOAfHRJqLCcmCFPoGo9A1bDpUcv/9tnKpErQWv9uKeGfl37EIS02Yg==",
|
"integrity": "sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -551,15 +551,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@zone-eu/mailsplit": {
|
"node_modules/@zone-eu/mailsplit": {
|
||||||
"version": "5.4.17",
|
"version": "5.4.21",
|
||||||
"resolved": "https://registry.npmjs.org/@zone-eu/mailsplit/-/mailsplit-5.4.17.tgz",
|
"resolved": "https://registry.npmjs.org/@zone-eu/mailsplit/-/mailsplit-5.4.21.tgz",
|
||||||
"integrity": "sha512-LOMzdrKRVgaghLaezIPdHRhsGpfDiWNQo1RptWc84CRllI4dWLwqX/L4x1iTt1CaeyvyUfMXM/6mjIsEisT3Tg==",
|
"integrity": "sha512-a7DjD8zysu77OeLuAZRTMC6NDALc3smuKkaZv1QTJkq2kMa5CbEgVQuC7Nfd9LfMO92bkjxT41t8L3mkWDZe1Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "(MIT OR EUPL-1.1+)",
|
"license": "(MIT OR EUPL-1.1+)",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"libbase64": "1.3.0",
|
"libbase64": "1.3.3",
|
||||||
"libmime": "5.4.4",
|
"libmime": "5.4.8",
|
||||||
"libqp": "2.1.1"
|
"libqp": "2.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/accepts": {
|
"node_modules/accepts": {
|
||||||
@@ -658,9 +658,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/argparse": {
|
"node_modules/argparse": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-3.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/argparse/-/argparse-3.0.3.tgz",
|
||||||
"integrity": "sha512-mFdDM6WqWKraGLsVb+C9CahPnzTXOefAOLq3jYcca2YZ8bEWpr++Tzj+zSaKW9+X9L5uSxcm1AZ3Y6aZJ09OhQ==",
|
"integrity": "sha512-Sn98ftV3KfsO8xfLPHG6oT8y+b0yvbrLgZjgPDXsharNY15tTAjqIsIju4S32nl6/iEUNNE4v+yL2Zhm8ooP3w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -969,9 +969,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/brighterscript": {
|
"node_modules/brighterscript": {
|
||||||
"version": "0.73.5",
|
"version": "0.73.7",
|
||||||
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.73.5.tgz",
|
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.73.7.tgz",
|
||||||
"integrity": "sha512-Du94fkEPBB6q8wYPpkreZWUPgG3Jd+VndrBKtmFgeLrGZztgiKfc63irwEcET1MqM+4DfIBaMT4r85GJF4/nHA==",
|
"integrity": "sha512-hlnMsNOsb8RbY1ZHQ6MQqeV0H9oPj+5tPzmI6fssJyy9vp1XHSY9D20qAAIYWgtu69ZpXnpBtVqtF0RMJDCi5A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1008,14 +1008,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/brighterscript-formatter": {
|
"node_modules/brighterscript-formatter": {
|
||||||
"version": "1.8.3",
|
"version": "1.8.4",
|
||||||
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.8.3.tgz",
|
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.8.4.tgz",
|
||||||
"integrity": "sha512-ucwBBg3FVShkWyDzDlFTznhIAaeI0qBGcIYEjGNOLYFsXLAoT+N2yPimpMDG9pYhHiP7BdrQfdnXgHTp4gyALg==",
|
"integrity": "sha512-cuBi1iyKyg5pPEcTT2RWpVJMr6jzRKYZUYtSUHOVCLv6YFCkXoC5iPbKt3B+LWO4sqO+kByx5VJx4CIRceMglw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brighterscript": "^0.73.3",
|
"brighterscript": "^0.73.6",
|
||||||
"glob-all": "^3.3.0",
|
"fast-glob": "^3.2.12",
|
||||||
|
"fs-extra": "^10.0.0",
|
||||||
"jsonc-parser": "^3.0.0",
|
"jsonc-parser": "^3.0.0",
|
||||||
"source-map": "0.7.4",
|
"source-map": "0.7.4",
|
||||||
"yargs": "^17.2.1"
|
"yargs": "^17.2.1"
|
||||||
@@ -1039,6 +1040,21 @@
|
|||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/brighterscript-formatter/node_modules/fs-extra": {
|
||||||
|
"version": "10.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
|
||||||
|
"integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"graceful-fs": "^4.2.0",
|
||||||
|
"jsonfile": "^6.0.1",
|
||||||
|
"universalify": "^2.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/brighterscript-formatter/node_modules/jsonc-parser": {
|
"node_modules/brighterscript-formatter/node_modules/jsonc-parser": {
|
||||||
"version": "3.3.1",
|
"version": "3.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz",
|
||||||
@@ -1887,9 +1903,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/dotenv": {
|
"node_modules/dotenv": {
|
||||||
"version": "18.0.4",
|
"version": "18.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-18.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-18.0.8.tgz",
|
||||||
"integrity": "sha512-jGt9uI5BIxpVO15kvy+iEFqNAwxYClKWnkptLjSNPnFLC003Imd0ofr3aEVsbpHdSBdSsbcApNIlz4nbyGMwdA==",
|
"integrity": "sha512-2KDeoFoK/zRtcnbunCDlLG5VWVMcyqeQc6iK65o231nfNAcuGrKoqUQfJFUtBI+QlShk5HKIHxwebBtUl3rEfA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -2512,7 +2528,8 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||||
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
|
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/fsevents": {
|
"node_modules/fsevents": {
|
||||||
"version": "2.3.3",
|
"version": "2.3.3",
|
||||||
@@ -2642,40 +2659,6 @@
|
|||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/glob-all": {
|
|
||||||
"version": "3.3.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/glob-all/-/glob-all-3.3.1.tgz",
|
|
||||||
"integrity": "sha512-Y+ESjdI7ZgMwfzanHZYQ87C59jOO0i+Hd+QYtVt9PhLi6d8wlOpzQnfBxWUlaTuAoR3TkybLqqbIoWveU4Ji7Q==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"glob": "^7.2.3",
|
|
||||||
"yargs": "^15.3.1"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"glob-all": "bin/glob-all"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/glob-all/node_modules/glob": {
|
|
||||||
"version": "7.2.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
|
||||||
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
|
|
||||||
"deprecated": "Glob versions prior to v9 are no longer supported",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"fs.realpath": "^1.0.0",
|
|
||||||
"inflight": "^1.0.4",
|
|
||||||
"inherits": "2",
|
|
||||||
"minimatch": "^3.1.1",
|
|
||||||
"once": "^1.3.0",
|
|
||||||
"path-is-absolute": "^1.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "*"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/glob-parent": {
|
"node_modules/glob-parent": {
|
||||||
"version": "5.1.2",
|
"version": "5.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
|
||||||
@@ -2789,6 +2772,13 @@
|
|||||||
"he": "bin/he"
|
"he": "bin/he"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/html-escaper": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/html-to-text": {
|
"node_modules/html-to-text": {
|
||||||
"version": "10.0.1",
|
"version": "10.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-10.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-10.0.1.tgz",
|
||||||
@@ -2987,6 +2977,7 @@
|
|||||||
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
|
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
|
||||||
"deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
|
"deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"once": "^1.3.0",
|
"once": "^1.3.0",
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
@@ -3131,6 +3122,68 @@
|
|||||||
"integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==",
|
"integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/istanbul-lib-coverage": {
|
||||||
|
"version": "3.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz",
|
||||||
|
"integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/istanbul-lib-report": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"istanbul-lib-coverage": "^3.0.0",
|
||||||
|
"make-dir": "^4.0.0",
|
||||||
|
"supports-color": "^7.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/istanbul-lib-report/node_modules/has-flag": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/istanbul-lib-report/node_modules/supports-color": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"has-flag": "^4.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/istanbul-reports": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"html-escaper": "^2.0.0",
|
||||||
|
"istanbul-lib-report": "^3.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/jsbn": {
|
"node_modules/jsbn": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
|
||||||
@@ -3262,23 +3315,23 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/libbase64": {
|
"node_modules/libbase64": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/libbase64/-/libbase64-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/libbase64/-/libbase64-1.3.3.tgz",
|
||||||
"integrity": "sha512-GgOXd0Eo6phYgh0DJtjQ2tO8dc0IVINtZJeARPeiIJqge+HdsWSuaDTe8ztQ7j/cONByDZ3zeB325AHiv5O0dg==",
|
"integrity": "sha512-6n4p3TUeQPimN4ANBTYQ5P4IpFx8p6cdanknnOBfw05XGtaG/k1LAtTSu79w7S07D1esy4qUfM8G4qvQncDWcw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/libmime": {
|
"node_modules/libmime": {
|
||||||
"version": "5.4.4",
|
"version": "5.4.8",
|
||||||
"resolved": "https://registry.npmjs.org/libmime/-/libmime-5.4.4.tgz",
|
"resolved": "https://registry.npmjs.org/libmime/-/libmime-5.4.8.tgz",
|
||||||
"integrity": "sha512-d3zZ2k8s6iO+8u9Vfkl6HfhD5lSVocGcmOViTz/i0CJcwhJADyubEJ/+TkBhuLDUSIBOiG+D8G5kJKwXwKbXXA==",
|
"integrity": "sha512-nsBApAZkontkOI4Kmg/7GyctCRraQ9Yxn7vZnzpHSOfqCmkt5/WTXpu5jk7a14REzW8OghKcbTY4bxx6rR9wSQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"encoding-japanese": "2.4.0",
|
"encoding-japanese": "2.4.0",
|
||||||
"iconv-lite": "0.7.3",
|
"iconv-lite": "0.7.3",
|
||||||
"libbase64": "1.3.0",
|
"libbase64": "1.3.3",
|
||||||
"libqp": "2.1.1"
|
"libqp": "2.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/libmime/node_modules/iconv-lite": {
|
"node_modules/libmime/node_modules/iconv-lite": {
|
||||||
@@ -3299,9 +3352,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/libqp": {
|
"node_modules/libqp": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/libqp/-/libqp-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/libqp/-/libqp-2.1.2.tgz",
|
||||||
"integrity": "sha512-0Wd+GPz1O134cP62YU2GTOPNA7Qgl09XwCqM5zpBv87ERCXdfDtyKXvV7c9U22yWJh44QZqBocFnXN11K96qow==",
|
"integrity": "sha512-rp+U80tl9Os4K7GnVbPzPRmghPu6eqB8rcF+ontvNAnoga0JhMFG/bkTD/reC8yoznKMgOc5/ttZHJasiWeFPw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@@ -3365,20 +3418,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mailparser": {
|
"node_modules/mailparser": {
|
||||||
"version": "3.9.28",
|
"version": "3.9.39",
|
||||||
"resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.9.28.tgz",
|
"resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.9.39.tgz",
|
||||||
"integrity": "sha512-O7oCYzWW9YH5lHk/y3Z8R8dFnUq8wqaH146BuU2NDt/3MGjdfMLzGF2Ft7WksTCeq00covNKpwxQabcG3zJFqQ==",
|
"integrity": "sha512-tFIEhwsNR4Xs5aq/8oBtd8aQZv42oLoDGWrne6rT/b3e0hN+o/k1KjaedWLh1NydVK35FiDaOTmGg9ZFhIsfYw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@zone-eu/mailsplit": "5.4.17",
|
"@zone-eu/mailsplit": "5.4.21",
|
||||||
"encoding-japanese": "2.4.0",
|
"encoding-japanese": "2.4.0",
|
||||||
"he": "1.2.0",
|
"he": "1.2.0",
|
||||||
"html-to-text": "10.0.1",
|
"html-to-text": "10.0.1",
|
||||||
"iconv-lite": "0.7.3",
|
"iconv-lite": "0.7.3",
|
||||||
"libmime": "5.4.4",
|
"libmime": "5.4.8",
|
||||||
"linkify-it": "5.0.2",
|
"linkify-it": "5.0.2",
|
||||||
"nodemailer": "10.0.10",
|
"nodemailer": "10.1.1",
|
||||||
"punycode.js": "2.3.1",
|
"punycode.js": "2.3.1",
|
||||||
"tlds": "1.261.0"
|
"tlds": "1.261.0"
|
||||||
},
|
},
|
||||||
@@ -3403,6 +3456,22 @@
|
|||||||
"url": "https://opencollective.com/express"
|
"url": "https://opencollective.com/express"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/make-dir": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"semver": "^7.5.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/make-error": {
|
"node_modules/make-error": {
|
||||||
"version": "1.3.6",
|
"version": "1.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
|
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
|
||||||
@@ -3641,9 +3710,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nodemailer": {
|
"node_modules/nodemailer": {
|
||||||
"version": "10.0.10",
|
"version": "10.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.0.10.tgz",
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.1.1.tgz",
|
||||||
"integrity": "sha512-He9XskOFms62SyAKkLu8CcGcYHAo+BSHSsORI8s4PJH8qZgZY4L4lDfvyN0twvmbpyG+eGrxpyBlskj9d9rJ8A==",
|
"integrity": "sha512-pbqZRoeYUO+1E8TJ/11WeY4D2EVujj1hsYjz3qff/vUFDtGnmi7p3iqzTFslYOfQ6PnjVcWxx/CIUSHCSrO/QA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT-0",
|
"license": "MIT-0",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -3940,6 +4009,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||||
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
|
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
@@ -4524,16 +4594,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/roku-debug": {
|
"node_modules/roku-debug": {
|
||||||
"version": "0.24.4",
|
"version": "0.24.6",
|
||||||
"resolved": "https://registry.npmjs.org/roku-debug/-/roku-debug-0.24.4.tgz",
|
"resolved": "https://registry.npmjs.org/roku-debug/-/roku-debug-0.24.6.tgz",
|
||||||
"integrity": "sha512-HcwIZOIeLqLigObOBCLTwwi+oJOCOYgSJ5yYlCm9JdU5Mu04J2v819wJDG6IZDdARx63n404rC37YDX2JRHtKQ==",
|
"integrity": "sha512-Js0/hXAKKUAQ8jpRIg4SYgobGh9msKZBvY+KyHbgN97ehQdLGoRZ7VnDk3BnicOGDd3BrhPYvTBq4R+DE6TCKg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rokucommunity/logger": "^0.4.2",
|
"@rokucommunity/logger": "^0.4.2",
|
||||||
"@vscode/debugadapter": "^1.68.0",
|
"@vscode/debugadapter": "^1.68.0",
|
||||||
"@vscode/debugprotocol": "^1.68.0",
|
"@vscode/debugprotocol": "^1.68.0",
|
||||||
"brighterscript": "^0.73.3",
|
"brighterscript": "^0.73.5",
|
||||||
"debounce": "^1.2.1",
|
"debounce": "^1.2.1",
|
||||||
"eventemitter3": "^4.0.7",
|
"eventemitter3": "^4.0.7",
|
||||||
"fast-glob": "^3.2.11",
|
"fast-glob": "^3.2.11",
|
||||||
@@ -4543,7 +4613,7 @@
|
|||||||
"needle": "^3.5.0",
|
"needle": "^3.5.0",
|
||||||
"portfinder": "^1.0.32",
|
"portfinder": "^1.0.32",
|
||||||
"replace-in-file": "^6.3.2",
|
"replace-in-file": "^6.3.2",
|
||||||
"roku-deploy": "^4.0.0-alpha.8",
|
"roku-deploy": "4.0.0-alpha.9",
|
||||||
"semver": "^7.5.4",
|
"semver": "^7.5.4",
|
||||||
"smart-buffer": "^4.2.0",
|
"smart-buffer": "^4.2.0",
|
||||||
"source-map": "^0.7.4",
|
"source-map": "^0.7.4",
|
||||||
@@ -4608,9 +4678,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/roku-debug/node_modules/roku-deploy": {
|
"node_modules/roku-debug/node_modules/roku-deploy": {
|
||||||
"version": "4.0.0-alpha.8",
|
"version": "4.0.0-alpha.9",
|
||||||
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-4.0.0-alpha.8.tgz",
|
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-4.0.0-alpha.9.tgz",
|
||||||
"integrity": "sha512-9qz1wlixZ1eljbOqyvphbhzkjr/NfDfJ61T1ZtsmszvcHhhu41IS+jcjdjCzepu6UqAmngEt/iGMcsRF76ZkWA==",
|
"integrity": "sha512-g63xcli1F6cfeu/OOrg0WcPeTkz3HGBCq3sJ8uSaDHrhwSmkWi7IfAnBupM6sJYFCZfeC2kATUI82wFrBvNcLA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -4929,18 +4999,21 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/rooibos-roku": {
|
"node_modules/rooibos-roku": {
|
||||||
"version": "5.16.5",
|
"version": "5.17.0",
|
||||||
"resolved": "https://registry.npmjs.org/rooibos-roku/-/rooibos-roku-5.16.5.tgz",
|
"resolved": "https://registry.npmjs.org/rooibos-roku/-/rooibos-roku-5.17.0.tgz",
|
||||||
"integrity": "sha512-iQ23H8yX+DmruOB6L0az1C/4H6S73YzsEWk9QrfbxS0Kt4myeD77iHC43KeKjO9NmKae+gkTnqsgF93GN/Fonw==",
|
"integrity": "sha512-eo1l3hLrfqkG0A4Jv8KbgGFD2pArLkHQ6zJ3fI9cHRfWL78tzLwd3z5YaMZn4tVB5Ttj8YesOcbQEk1aVYpeyA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brighterscript": "^0.73.3",
|
"brighterscript": "^0.73.5",
|
||||||
"fast-glob": "^3.2.12",
|
"fast-glob": "^3.2.12",
|
||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^10.1.0",
|
||||||
|
"istanbul-lib-coverage": "^3.2.2",
|
||||||
|
"istanbul-lib-report": "^3.0.0",
|
||||||
|
"istanbul-reports": "^3.0.2",
|
||||||
"minimatch": "^3.0.4",
|
"minimatch": "^3.0.4",
|
||||||
"roku-debug": "^0.24.3",
|
"roku-debug": "^0.24.6",
|
||||||
"roku-deploy": "^4.0.0-alpha.5",
|
"roku-deploy": "^4.0.0-alpha.9",
|
||||||
"rooibos_promises": "npm:@rokucommunity/promises@^0.5.0",
|
"rooibos_promises": "npm:@rokucommunity/promises@^0.5.0",
|
||||||
"source-map": "^0.7.3",
|
"source-map": "^0.7.3",
|
||||||
"undent": "^1.0.1",
|
"undent": "^1.0.1",
|
||||||
@@ -4997,9 +5070,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/rooibos-roku/node_modules/roku-deploy": {
|
"node_modules/rooibos-roku/node_modules/roku-deploy": {
|
||||||
"version": "4.0.0-alpha.8",
|
"version": "4.0.0-alpha.9",
|
||||||
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-4.0.0-alpha.8.tgz",
|
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-4.0.0-alpha.9.tgz",
|
||||||
"integrity": "sha512-9qz1wlixZ1eljbOqyvphbhzkjr/NfDfJ61T1ZtsmszvcHhhu41IS+jcjdjCzepu6UqAmngEt/iGMcsRF76ZkWA==",
|
"integrity": "sha512-g63xcli1F6cfeu/OOrg0WcPeTkz3HGBCq3sJ8uSaDHrhwSmkWi7IfAnBupM6sJYFCZfeC2kATUI82wFrBvNcLA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.48.9",
|
"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",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/node": "^26.6.3",
|
"@types/node": "^26.6.5",
|
||||||
"@types/xml2js": "^0.4.14",
|
"@types/xml2js": "^0.4.14",
|
||||||
"argparse": "^3.0.2",
|
"argparse": "^3.0.3",
|
||||||
"brighterscript": "0.73.5",
|
"brighterscript": "0.73.7",
|
||||||
"brighterscript-formatter": "^1.8.3",
|
"brighterscript-formatter": "^1.8.4",
|
||||||
"convert-svg-to-png": "^0.7.1",
|
"convert-svg-to-png": "^0.7.1",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"dotenv": "^18.0.4",
|
"dotenv": "^18.0.8",
|
||||||
"fs-extra": "^11.4.1",
|
"fs-extra": "^11.4.1",
|
||||||
"glob": "^13.0.6",
|
"glob": "^13.0.6",
|
||||||
"imap": "^0.8.19",
|
"imap": "^0.8.19",
|
||||||
"ip": "^2.0.1",
|
"ip": "^2.0.1",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"mailparser": "^3.9.28",
|
"mailparser": "^3.9.39",
|
||||||
"protocol-buffers-schema": "^3.6.1",
|
"protocol-buffers-schema": "^3.6.1",
|
||||||
"roku-deploy": "^3.18.4",
|
"roku-deploy": "^3.18.4",
|
||||||
"roku-test-automation": "^2.2.2",
|
"roku-test-automation": "^2.2.2",
|
||||||
"rooibos-roku": "5.16.5",
|
"rooibos-roku": "5.17.0",
|
||||||
"semver": "^7.8.5",
|
"semver": "^7.8.5",
|
||||||
"shelljs": "^0.10.0",
|
"shelljs": "^0.10.0",
|
||||||
"telnet-client": "^2.2.14",
|
"telnet-client": "^2.2.14",
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ major_version=0
|
|||||||
minor_version=1
|
minor_version=1
|
||||||
build_version=00000
|
build_version=00000
|
||||||
|
|
||||||
|
rsg_version=1.3
|
||||||
|
|
||||||
ui_resolutions=hd
|
ui_resolutions=hd
|
||||||
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.48.9",
|
"version": "0.48.11",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.48.9"
|
"version": "0.48.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.48.9",
|
"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
|
||||||
@@ -70,6 +71,7 @@ function OnLoadStatusChanged() as void
|
|||||||
m.scene.playletLibLoadedUrl = libUrl
|
m.scene.playletLibLoadedUrl = libUrl
|
||||||
container = m.scene.findNode("MainSceneContainer")
|
container = m.scene.findNode("MainSceneContainer")
|
||||||
container.createChild("PlayletLib:MainScene")
|
container.createChild("PlayletLib:MainScene")
|
||||||
|
m.scene.libSceneCreated = true
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -81,6 +83,10 @@ function OnLoadStatusChanged() as void
|
|||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function CreateInputTransportEventsHandler(_unused as dynamic) as object
|
||||||
|
return CreateObject("roSGNode", "PlayletLib:InputTransportEventsHandler")
|
||||||
|
end function
|
||||||
|
|
||||||
function RemoveComponentLibrary() as void
|
function RemoveComponentLibrary() as void
|
||||||
if m.lib = invalid
|
if m.lib = invalid
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -4,9 +4,11 @@
|
|||||||
<field id="launchArgs" type="assocarray" />
|
<field id="launchArgs" type="assocarray" />
|
||||||
<field id="inputArgs" type="assocarray" alwaysNotify="true" />
|
<field id="inputArgs" type="assocarray" alwaysNotify="true" />
|
||||||
<field id="playletLibLoadedUrl" type="assocarray" />
|
<field id="playletLibLoadedUrl" type="assocarray" />
|
||||||
|
<field id="libSceneCreated" type="bool" />
|
||||||
<field id="systemLogEvent" type="assocarray" alwaysNotify="true" />
|
<field id="systemLogEvent" type="assocarray" alwaysNotify="true" />
|
||||||
<field id="enableSystemLogType" type="string" />
|
<field id="enableSystemLogType" type="string" />
|
||||||
<field id="lastExitInfo" type="assocarray" />
|
<field id="lastExitInfo" type="assocarray" />
|
||||||
|
<function name="CreateInputTransportEventsHandler" />
|
||||||
</interface>
|
</interface>
|
||||||
<script type="text/brightscript" uri="pkg:/source/Dialog.bs" />
|
<script type="text/brightscript" uri="pkg:/source/Dialog.bs" />
|
||||||
<script type="text/brightscript" uri="pkg:/source/Manifest.bs" />
|
<script type="text/brightscript" uri="pkg:/source/Manifest.bs" />
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ 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=00009
|
build_version=00013
|
||||||
|
|
||||||
|
rsg_version=1.3
|
||||||
|
|
||||||
ui_resolutions=hd
|
ui_resolutions=hd
|
||||||
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
||||||
@@ -28,13 +30,17 @@ confirm_partner_button=1
|
|||||||
|
|
||||||
supports_input_launch=1
|
supports_input_launch=1
|
||||||
|
|
||||||
|
supports_voice_roinput=1
|
||||||
|
supports_etc_seek=1
|
||||||
|
supports_etc_next=1
|
||||||
|
|
||||||
requires_widevine_drm=1
|
requires_widevine_drm=1
|
||||||
requires_widevine_version=1.0
|
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-backend/piped/playlet-lib-1795496523.zip
|
||||||
|
|
||||||
git_commit_sha=unknown
|
git_commit_sha=unknown
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ function Main(args as object) as void
|
|||||||
|
|
||||||
scene = screen.CreateScene("BootstrapScene")
|
scene = screen.CreateScene("BootstrapScene")
|
||||||
screen.show()
|
screen.show()
|
||||||
|
scene.ObserveField("libSceneCreated", port)
|
||||||
|
|
||||||
AppManager.CaptureLastExitInfo(scene)
|
AppManager.CaptureLastExitInfo(scene)
|
||||||
|
|
||||||
@@ -49,6 +50,8 @@ function Main(args as object) as void
|
|||||||
|
|
||||||
input = CreateObject("roInput")
|
input = CreateObject("roInput")
|
||||||
input.setMessagePort(port)
|
input.setMessagePort(port)
|
||||||
|
input.EnableTransportEvents()
|
||||||
|
transportEventsHandler = invalid
|
||||||
|
|
||||||
systemLog = CreateObject("roSystemLog")
|
systemLog = CreateObject("roSystemLog")
|
||||||
systemLog.SetMessagePort(port)
|
systemLog.SetMessagePort(port)
|
||||||
@@ -83,8 +86,21 @@ function Main(args as object) as void
|
|||||||
if field = "enableSystemLogType"
|
if field = "enableSystemLogType"
|
||||||
systemLog.EnableType(data)
|
systemLog.EnableType(data)
|
||||||
end if
|
end if
|
||||||
|
if field = "libSceneCreated"
|
||||||
|
scene.unobserveField("libSceneCreated")
|
||||||
|
transportEventsHandler = scene@.CreateInputTransportEventsHandler()
|
||||||
|
end if
|
||||||
else if msgType = "roInputEvent"
|
else if msgType = "roInputEvent"
|
||||||
scene.inputArgs = msg.getInfo()
|
info = msg.getInfo()
|
||||||
|
if info.type = "transport"
|
||||||
|
status = "unhandled"
|
||||||
|
if transportEventsHandler <> invalid
|
||||||
|
status = transportEventsHandler@.HandleTransportEvent(info)
|
||||||
|
end if
|
||||||
|
input.EventResponse({ id: info.id, status: status })
|
||||||
|
else
|
||||||
|
scene.inputArgs = info
|
||||||
|
end if
|
||||||
end if
|
end if
|
||||||
end while
|
end while
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.48.9",
|
"version": "0.48.11",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.48.9"
|
"version": "0.48.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.48.9",
|
"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" />
|
||||||
|
|||||||
@@ -0,0 +1,129 @@
|
|||||||
|
import "pkg:/components/JobSystem/Jobs.bs"
|
||||||
|
import "pkg:/components/JobSystem/JobSystem.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
import "TransportEvents.types.bs"
|
||||||
|
|
||||||
|
function Init()
|
||||||
|
scene = m.top.getScene()
|
||||||
|
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
|
||||||
|
' have no entry here, and answer unhandled.
|
||||||
|
m.commandHandlers = {}
|
||||||
|
m.commandHandlers[TransportCommand.Play] = PlayCommand
|
||||||
|
m.commandHandlers[TransportCommand.Pause] = PauseCommand
|
||||||
|
m.commandHandlers[TransportCommand.Stop] = PauseCommand
|
||||||
|
m.commandHandlers[TransportCommand.Seek] = SeekCommand
|
||||||
|
m.commandHandlers[TransportCommand.StartOver] = StartOverCommand
|
||||||
|
m.commandHandlers[TransportCommand.NowPlaying] = NowPlayingCommand
|
||||||
|
m.commandHandlers[TransportCommand.Like] = NotSupportedCommand
|
||||||
|
m.commandHandlers[TransportCommand.Dislike] = NotSupportedCommand
|
||||||
|
m.commandHandlers[TransportCommand.Shuffle] = NotSupportedCommand
|
||||||
|
m.commandHandlers[TransportCommand.Loop] = NotSupportedCommand
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleTransportEvent(event as object) as string
|
||||||
|
status = RouteTransportEvent(event)
|
||||||
|
LogInfo("transport event", event, "->", status)
|
||||||
|
return status
|
||||||
|
end function
|
||||||
|
|
||||||
|
function RouteTransportEvent(event as object) as string
|
||||||
|
commandHandler = m.commandHandlers[ValidString(event.command)]
|
||||||
|
if commandHandler = invalid
|
||||||
|
return TransportStatus.Unhandled
|
||||||
|
end if
|
||||||
|
return commandHandler(event)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function PlayCommand(_event as object) as string
|
||||||
|
player = m.videoQueue.player
|
||||||
|
if player = invalid
|
||||||
|
return TransportStatus.Unhandled
|
||||||
|
end if
|
||||||
|
|
||||||
|
if player.state = "paused"
|
||||||
|
m.videoQueue.play = true
|
||||||
|
end if
|
||||||
|
return TransportStatus.Success
|
||||||
|
end function
|
||||||
|
|
||||||
|
function PauseCommand(_event as object) as string
|
||||||
|
player = m.videoQueue.player
|
||||||
|
if player = invalid
|
||||||
|
return TransportStatus.Unhandled
|
||||||
|
end if
|
||||||
|
|
||||||
|
if player.state = "paused"
|
||||||
|
return TransportStatus.ErrorRedundant
|
||||||
|
end if
|
||||||
|
m.videoQueue.pause = true
|
||||||
|
return TransportStatus.Success
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SeekCommand(event as object) as string
|
||||||
|
player = m.videoQueue.player
|
||||||
|
if player = invalid
|
||||||
|
return TransportStatus.Unhandled
|
||||||
|
end if
|
||||||
|
|
||||||
|
deltaSeconds = ValidString(event.duration).ToInt()
|
||||||
|
if deltaSeconds <= 0
|
||||||
|
return TransportStatus.Error
|
||||||
|
end if
|
||||||
|
if event.direction = TransportSeekDirection.Backward
|
||||||
|
deltaSeconds = -deltaSeconds
|
||||||
|
end if
|
||||||
|
|
||||||
|
targetSeconds = player.position + deltaSeconds
|
||||||
|
status = TransportStatus.Success
|
||||||
|
if targetSeconds < 0
|
||||||
|
targetSeconds = 0
|
||||||
|
status = TransportStatus.SuccessSeekStart
|
||||||
|
else if player.duration > 0 and targetSeconds > player.duration
|
||||||
|
targetSeconds = player.duration
|
||||||
|
status = TransportStatus.SuccessSeekEnd
|
||||||
|
end if
|
||||||
|
|
||||||
|
player.setSeek = targetSeconds
|
||||||
|
return status
|
||||||
|
end function
|
||||||
|
|
||||||
|
function StartOverCommand(_event as object) as string
|
||||||
|
player = m.videoQueue.player
|
||||||
|
if player = invalid
|
||||||
|
return TransportStatus.Unhandled
|
||||||
|
end if
|
||||||
|
|
||||||
|
player.setSeek = 0
|
||||||
|
return TransportStatus.Success
|
||||||
|
end function
|
||||||
|
|
||||||
|
function NowPlayingCommand(_event as object) as string
|
||||||
|
player = m.videoQueue.player
|
||||||
|
if player = invalid
|
||||||
|
SetNowPlayingMetadata(invalid)
|
||||||
|
return TransportStatus.Success
|
||||||
|
end if
|
||||||
|
|
||||||
|
content = player.content
|
||||||
|
if content = invalid or StringUtils.IsNullOrEmpty(content.title)
|
||||||
|
SetNowPlayingMetadata(invalid)
|
||||||
|
return TransportStatus.ErrorGeneric
|
||||||
|
end if
|
||||||
|
|
||||||
|
SetNowPlayingMetadata({ title: content.title, contentType: "movie" })
|
||||||
|
return TransportStatus.Success
|
||||||
|
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
|
||||||
|
return TransportStatus.ErrorChannel
|
||||||
|
end function
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<component name="InputTransportEventsHandler" extends="Node">
|
||||||
|
<interface>
|
||||||
|
<function name="HandleTransportEvent" />
|
||||||
|
</interface>
|
||||||
|
</component>
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
' https://developer.roku.com/docs/developer/media-playback/voice-controls/transport-controls.md
|
||||||
|
enum TransportCommand
|
||||||
|
Play = "play"
|
||||||
|
Pause = "pause"
|
||||||
|
stop = "stop"
|
||||||
|
Ok = "ok"
|
||||||
|
Forward = "forward"
|
||||||
|
Rewind = "rewind"
|
||||||
|
Replay = "replay"
|
||||||
|
StartOver = "startover"
|
||||||
|
Seek = "seek"
|
||||||
|
next = "next"
|
||||||
|
Skip = "skip"
|
||||||
|
NowPlaying = "nowplaying"
|
||||||
|
Like = "like"
|
||||||
|
Dislike = "dislike"
|
||||||
|
Shuffle = "shuffle"
|
||||||
|
Loop = "loop"
|
||||||
|
end enum
|
||||||
|
|
||||||
|
enum TransportSeekDirection
|
||||||
|
Forward = "forward"
|
||||||
|
Backward = "backward"
|
||||||
|
end enum
|
||||||
|
|
||||||
|
' https://developer.roku.com/docs/references/brightscript/interfaces/ifinput.md#eventresponseroassociativearray-aa-as-boolean
|
||||||
|
enum TransportStatus
|
||||||
|
Success = "success"
|
||||||
|
SuccessSeekStart = "success.seek-start"
|
||||||
|
SuccessSeekEnd = "success.seek-end"
|
||||||
|
Unhandled = "unhandled"
|
||||||
|
Error = "error"
|
||||||
|
ErrorGeneric = "error.generic"
|
||||||
|
ErrorAd = "error.ad"
|
||||||
|
ErrorChannel = "error.channel"
|
||||||
|
ErrorLive = "error.live"
|
||||||
|
ErrorNoMedia = "error.no-media"
|
||||||
|
ErrorRedundant = "error.redundant"
|
||||||
|
end enum
|
||||||
@@ -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"
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ class DashManifest
|
|||||||
adaptiveFormats = m.ProxyFormatsThroughInvidious(adaptiveFormats)
|
adaptiveFormats = m.ProxyFormatsThroughInvidious(adaptiveFormats)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
duration = m.GetDuration(metadata)
|
|
||||||
isLive = ValidBool(metadata.liveNow)
|
isLive = ValidBool(metadata.liveNow)
|
||||||
|
|
||||||
groupings = m.CreateFormatGroupings(adaptiveFormats, metadata.isPostLiveDvr, isLive)
|
groupings = m.CreateFormatGroupings(adaptiveFormats, metadata.isPostLiveDvr, isLive)
|
||||||
@@ -119,7 +118,7 @@ class DashManifest
|
|||||||
else
|
else
|
||||||
mpdAttributes["profiles"] = "urn:mpeg:dash:profile:full:2011"
|
mpdAttributes["profiles"] = "urn:mpeg:dash:profile:full:2011"
|
||||||
mpdAttributes["type"] = "static"
|
mpdAttributes["type"] = "static"
|
||||||
mpdAttributes["mediaPresentationDuration"] = `PT${duration}S`
|
mpdAttributes["mediaPresentationDuration"] = m.FormatDuration(m.GetDurationMs(metadata))
|
||||||
end if
|
end if
|
||||||
|
|
||||||
' Live needs an explicit Period start to anchor the timeline against availabilityStartTime.
|
' Live needs an explicit Period start to anchor the timeline against availabilityStartTime.
|
||||||
@@ -169,17 +168,17 @@ class DashManifest
|
|||||||
return proxied
|
return proxied
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetDuration(metadata as object) as dynamic
|
function GetDurationMs(metadata as object) as longinteger
|
||||||
if metadata["isPostLiveDvr"] = true and IsInt(metadata["postLiveDvrDurationMs"])
|
if metadata["isPostLiveDvr"] = true and metadata["postLiveDvrDurationMs"] <> invalid
|
||||||
return metadata["postLiveDvrDurationMs"] / 1000.0
|
return metadata["postLiveDvrDurationMs"]
|
||||||
end if
|
end if
|
||||||
|
|
||||||
approxDurationMs = ValidString(ObjectUtils.Dig(metadata, ["adaptiveFormats", 0, "approxDurationMs"])).ToInt()
|
approxDurationMs = StringUtils.ParseJsonSafe(ObjectUtils.Dig(metadata, ["adaptiveFormats", 0, "approxDurationMs"]))
|
||||||
if approxDurationMs > 0
|
if IsNumber(approxDurationMs) and approxDurationMs > 0
|
||||||
return approxDurationMs / 1000.0
|
return approxDurationMs
|
||||||
end if
|
end if
|
||||||
|
|
||||||
return ValidInt(metadata["lengthSeconds"])
|
return ValidInt(metadata["lengthSeconds"]) * 1000&
|
||||||
end function
|
end function
|
||||||
|
|
||||||
' `durationRuns` ascending.
|
' `durationRuns` ascending.
|
||||||
@@ -246,7 +245,7 @@ class DashManifest
|
|||||||
return seqnum
|
return seqnum
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function FormatDuration(ms as integer) as string
|
function FormatDuration(ms as longinteger) as string
|
||||||
return `PT${ms \ 1000}.${Right("00" + (ms mod 1000).ToStr(), 3)}S`
|
return `PT${ms \ 1000}.${Right("00" + (ms mod 1000).ToStr(), 3)}S`
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -268,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")
|
||||||
@@ -324,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] = []
|
||||||
@@ -474,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
|
||||||
@@ -575,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)
|
||||||
|
|
||||||
@@ -638,8 +632,7 @@ class DashManifest
|
|||||||
if not IsInt(postLiveDvrSegmentCount)
|
if not IsInt(postLiveDvrSegmentCount)
|
||||||
xml.Comment(`[ERROR] Post-Live DVR metadata missing postLiveDvrSegmentCount for itag: ${stream.itag}`)
|
xml.Comment(`[ERROR] Post-Live DVR metadata missing postLiveDvrSegmentCount for itag: ${stream.itag}`)
|
||||||
' We're going to guess segment count from targetDurationSec and total duration
|
' We're going to guess segment count from targetDurationSec and total duration
|
||||||
totalDurationMs = m.GetDuration(metadata) * 1000.0
|
postLiveDvrSegmentCount = MathUtils.Max(Fix(m.GetDurationMs(metadata) / (stream.targetDurationSec * 1000)), 1)
|
||||||
postLiveDvrSegmentCount = MathUtils.Max(Fix(totalDurationMs / (stream.targetDurationSec * 1000)), 1)
|
|
||||||
xml.Comment(`[INFO] Guessing postLiveDvrSegmentCount as ${postLiveDvrSegmentCount} for itag: ${stream.itag}`)
|
xml.Comment(`[INFO] Guessing postLiveDvrSegmentCount as ${postLiveDvrSegmentCount} for itag: ${stream.itag}`)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -1017,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
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
' The head check counts of the latest live video load, as { video_load_id, counts }. One file,
|
|
||||||
' overwritten by each live load: tmp:/ lasts as long as the app.
|
|
||||||
const LIVE_HEAD_COUNTS_PATH = "tmp:/live_head_counts.json"
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
' The head check and timeline counts of the latest live video load, as { live_head, live_timeline }.
|
||||||
|
' One file, overwritten by each live load: tmp:/ lasts as long as the app.
|
||||||
|
const LIVE_LOAD_COUNTS_PATH = "tmp:/live_load_counts.json"
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import "pkg:/components/Services/Innertube/GetDrmLicenseEndpoint.types.bs"
|
||||||
|
import "pkg:/components/Telemetry/VideoLoadHandoff.bs"
|
||||||
|
|
||||||
|
const DRM_LICENSE_REQUESTS_PATH = "tmp:/drm_license_requests.json"
|
||||||
|
const DRM_LICENSE_RESPONSE_SAMPLE_CAP = 10
|
||||||
|
|
||||||
|
namespace DrmLicenseRequests
|
||||||
|
|
||||||
|
function RecordSent(videoLoadId as string) as void
|
||||||
|
requests = DrmLicenseRequests.Load(videoLoadId)
|
||||||
|
requests["sent"] += 1
|
||||||
|
VideoLoadHandoff.Write(DRM_LICENSE_REQUESTS_PATH, videoLoadId, requests)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function RecordResponse(videoLoadId as string, response as Innertube.DrmLicenseResponse) as void
|
||||||
|
requests = DrmLicenseRequests.Load(videoLoadId)
|
||||||
|
responses = requests["responses"]
|
||||||
|
if responses.Count() >= DRM_LICENSE_RESPONSE_SAMPLE_CAP
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
if response.payload <> invalid
|
||||||
|
responses.Push({ "payload": response.payload })
|
||||||
|
else
|
||||||
|
responses.Push({ "error": response.error })
|
||||||
|
end if
|
||||||
|
VideoLoadHandoff.Write(DRM_LICENSE_REQUESTS_PATH, videoLoadId, requests)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Load(videoLoadId as string) as object
|
||||||
|
requests = VideoLoadHandoff.Read(DRM_LICENSE_REQUESTS_PATH, videoLoadId)
|
||||||
|
if not IsAssociativeArray(requests)
|
||||||
|
return { "sent": 0, "responses": [] }
|
||||||
|
end if
|
||||||
|
return requests
|
||||||
|
end function
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import "pkg:/components/Services/Innertube/GetDrmLicenseEndpoint.types.bs"
|
||||||
|
|
||||||
namespace Innertube
|
namespace Innertube
|
||||||
|
|
||||||
function CreateGetDrmLicenceRequest(options as object) as HttpClient.Request
|
function CreateGetDrmLicenceRequest(options as object) as HttpClient.Request
|
||||||
@@ -39,7 +41,7 @@ namespace Innertube
|
|||||||
return request
|
return request
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ParseGetDrmLicenseResponse(payload as object) as dynamic
|
function ParseGetDrmLicenseResponse(payload as object) as Innertube.DrmLicenseResponse
|
||||||
if not IsAssociativeArray(payload)
|
if not IsAssociativeArray(payload)
|
||||||
return {
|
return {
|
||||||
"error": "Invalid JSON response"
|
"error": "Invalid JSON response"
|
||||||
@@ -50,6 +52,7 @@ namespace Innertube
|
|||||||
if status <> "LICENSE_STATUS_OK"
|
if status <> "LICENSE_STATUS_OK"
|
||||||
return {
|
return {
|
||||||
"error": "DRM license request failed with status: " + status
|
"error": "DRM license request failed with status: " + status
|
||||||
|
"payload": payload
|
||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -57,12 +60,24 @@ namespace Innertube
|
|||||||
if StringUtils.IsNullOrEmpty(license)
|
if StringUtils.IsNullOrEmpty(license)
|
||||||
return {
|
return {
|
||||||
"error": "DRM license is missing in the response"
|
"error": "DRM license is missing in the response"
|
||||||
|
"payload": payload
|
||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
buffer = createObject("roByteArray")
|
buffer = createObject("roByteArray")
|
||||||
buffer.FromBase64String(license.Replace("-", "+").Replace("_", "/"))
|
buffer.FromBase64String(license.Replace("-", "+").Replace("_", "/"))
|
||||||
return buffer
|
if buffer.Count() = 0
|
||||||
|
return {
|
||||||
|
"error": "DRM license decodes to no bytes"
|
||||||
|
"payload": payload
|
||||||
|
}
|
||||||
|
end if
|
||||||
|
|
||||||
|
payload.Delete("license")
|
||||||
|
return {
|
||||||
|
"license": buffer
|
||||||
|
"payload": payload
|
||||||
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GenerateDrmSessionId() as string
|
function GenerateDrmSessionId() as string
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Innertube
|
||||||
|
|
||||||
|
interface DrmLicenseResponse
|
||||||
|
optional license as roByteArray
|
||||||
|
' The response, without the license once it decoded.
|
||||||
|
optional payload as object
|
||||||
|
optional error as string
|
||||||
|
end interface
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -810,7 +810,7 @@ namespace InnertubeService
|
|||||||
return Innertube.ListAccounts(accessToken, cancellation)
|
return Innertube.ListAccounts(accessToken, cancellation)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetDrmLicense(options as object) as dynamic
|
function GetDrmLicense(options as object) as Innertube.DrmLicenseResponse
|
||||||
request = Innertube.CreateGetDrmLicenceRequest(options)
|
request = Innertube.CreateGetDrmLicenceRequest(options)
|
||||||
|
|
||||||
response = request.Await()
|
response = request.Await()
|
||||||
|
|||||||
@@ -33,33 +33,17 @@ namespace Innertube
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
headUrl = GetLiveHeadUrl(adaptiveFormats[0]["url"], cpn)
|
headUrl = GetLiveHeadUrl(adaptiveFormats[0]["url"], cpn)
|
||||||
request = CreateLiveHeadRequest(headUrl)
|
response = FetchLiveHead(headUrl, cancellation)
|
||||||
request.RetryCount(1)
|
if not HasLiveHead(response)
|
||||||
request.RetryIf(function(response as HttpClient.Response) as string
|
|
||||||
if Innertube.ReadLiveHeadSeqnum(response) < 0 or (Innertube.ReadLiveHeadTimeMs(response) = invalid and Innertube.ReadLiveHeadTimeSecAsMs(response) = invalid)
|
|
||||||
return `no X-Head-* in the response (HTTP ${response.StatusCode()})`
|
|
||||||
end if
|
|
||||||
return ""
|
|
||||||
end function)
|
|
||||||
request.Cancellation(cancellation)
|
|
||||||
response = request.Await()
|
|
||||||
|
|
||||||
headSeqnum = ReadLiveHeadSeqnum(response)
|
|
||||||
headTimeMs = ReadLiveHeadTimeMs(response)
|
|
||||||
averagedTimeMs = headTimeMs
|
|
||||||
if averagedTimeMs = invalid
|
|
||||||
averagedTimeMs = ReadLiveHeadTimeSecAsMs(response)
|
|
||||||
end if
|
|
||||||
if headSeqnum < 0 or averagedTimeMs = invalid
|
|
||||||
parsedResponse["error"] = `Live stream head check returned no X-Head-Seqnum / X-Head-Time (HTTP ${response.StatusCode()})\n${response.ErrorMessage()}`
|
parsedResponse["error"] = `Live stream head check returned no X-Head-Seqnum / X-Head-Time (HTTP ${response.StatusCode()})\n${response.ErrorMessage()}`
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
now = CreateObject("roDateTime")
|
now = CreateObject("roDateTime")
|
||||||
timeline = GetLiveTimeline(headSeqnum, averagedTimeMs, ValidInt(adaptiveFormats[0]["targetDurationSec"]), ValidInt(adaptiveFormats[0]["maxDvrDurationSec"]), chunkReadahead, now.AsSeconds(), now.GetMilliseconds())
|
timeline = GetLiveTimeline(ReadLiveHeadSeqnum(response), ReadLiveHeadAnyTimeMs(response), ValidInt(adaptiveFormats[0]["targetDurationSec"]), ValidInt(adaptiveFormats[0]["maxDvrDurationSec"]), chunkReadahead, now.AsSeconds(), now.GetMilliseconds())
|
||||||
parsedResponse.Append(timeline)
|
parsedResponse.Append(timeline)
|
||||||
parsedResponse["liveHeadUrl"] = headUrl
|
parsedResponse["liveHeadUrl"] = headUrl
|
||||||
parsedResponse["liveHeadTimeMs"] = headTimeMs
|
parsedResponse["liveHeadTimeMs"] = ReadLiveHeadTimeMs(response)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
' The live timeline fields for a stream whose head (newest segment) is
|
' The live timeline fields for a stream whose head (newest segment) is
|
||||||
@@ -148,6 +132,25 @@ namespace Innertube
|
|||||||
return request
|
return request
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
' The head check's answer, sent once more when it lacks the head (HasLiveHead), whatever its HTTP status.
|
||||||
|
function FetchLiveHead(headUrl as string, cancellation as object) as HttpClient.Response
|
||||||
|
request = CreateLiveHeadRequest(headUrl)
|
||||||
|
request.RetryCount(1)
|
||||||
|
request.RetryIf(function(response as HttpClient.Response) as string
|
||||||
|
if not Innertube.HasLiveHead(response)
|
||||||
|
return `no X-Head-* in the response (HTTP ${response.StatusCode()})`
|
||||||
|
end if
|
||||||
|
return ""
|
||||||
|
end function)
|
||||||
|
request.Cancellation(cancellation)
|
||||||
|
return request.Await()
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Whether a head check's answer carries the head's seqnum and time.
|
||||||
|
function HasLiveHead(response as HttpClient.Response) as boolean
|
||||||
|
return ReadLiveHeadSeqnum(response) >= 0 and ReadLiveHeadAnyTimeMs(response) <> invalid
|
||||||
|
end function
|
||||||
|
|
||||||
' X-Head-Seqnum of a live head response, -1 if absent. Not gated on HTTP status: a
|
' X-Head-Seqnum of a live head response, -1 if absent. Not gated on HTTP status: a
|
||||||
' head check can come back non-2xx yet still carry the X-Head-* headers
|
' head check can come back non-2xx yet still carry the X-Head-* headers
|
||||||
' (observed: one stream returns 500, another 200; both include them).
|
' (observed: one stream returns 500, another 200; both include them).
|
||||||
@@ -167,6 +170,15 @@ namespace Innertube
|
|||||||
return StringUtils.ParseJsonSafe(ValidString(response.Headers()["X-Head-Time-Millis"]))
|
return StringUtils.ParseJsonSafe(ValidString(response.Headers()["X-Head-Time-Millis"]))
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
' X-Head-Time-Millis, else X-Head-Time-Sec in ms, invalid if neither.
|
||||||
|
function ReadLiveHeadAnyTimeMs(response as HttpClient.Response) as dynamic
|
||||||
|
timeMs = ReadLiveHeadTimeMs(response)
|
||||||
|
if timeMs = invalid
|
||||||
|
timeMs = ReadLiveHeadTimeSecAsMs(response)
|
||||||
|
end if
|
||||||
|
return timeMs
|
||||||
|
end function
|
||||||
|
|
||||||
' X-Head-Time-Sec in ms, invalid if absent: whole seconds, too coarse to average a
|
' X-Head-Time-Sec in ms, invalid if absent: whole seconds, too coarse to average a
|
||||||
' young stream's few segments or to time the head between checks.
|
' young stream's few segments or to time the head between checks.
|
||||||
function ReadLiveHeadTimeSecAsMs(response as HttpClient.Response) as dynamic
|
function ReadLiveHeadTimeSecAsMs(response as HttpClient.Response) as dynamic
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -190,12 +190,12 @@ namespace Innertube
|
|||||||
|
|
||||||
if isPostLiveDvr
|
if isPostLiveDvr
|
||||||
LogDebug("Fetching Post-Live DVR info")
|
LogDebug("Fetching Post-Live DVR info")
|
||||||
GetPostLiveDvrInfo(parsedResponse, adaptiveFormats, playerRequest.cpn, client, cancellation)
|
GetPostLiveDvrInfo(parsedResponse, adaptiveFormats, playerRequest.cpn, cancellation)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
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
|
||||||
@@ -235,7 +235,13 @@ namespace Innertube
|
|||||||
errorLines.Push(subreason)
|
errorLines.Push(subreason)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
playerErrorCommand = ObjectUtils.Dig(playabilityStatus, ["errorScreen", "playerErrorCommandRenderer"])
|
||||||
|
if IsAssociativeArray(playerErrorCommand)
|
||||||
|
errorLines.Append(ParsePlayerErrorCommandRenderer(playerErrorCommand))
|
||||||
|
end if
|
||||||
|
|
||||||
if errorLines.Count() = 0
|
if errorLines.Count() = 0
|
||||||
|
Warning(`Unparsed playability status: ${status}`, playabilityStatus, { request: playerRequest })
|
||||||
errorLines.Push("Video not available (Unknown)")
|
errorLines.Push("Video not available (Unknown)")
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -258,6 +264,47 @@ namespace Innertube
|
|||||||
return errorLines.Join(`\n`)
|
return errorLines.Join(`\n`)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function ParsePlayerErrorCommandRenderer(renderer as object) as object
|
||||||
|
lines = []
|
||||||
|
errorMessage = ParseText(renderer["errorMessage"])
|
||||||
|
if errorMessage <> ""
|
||||||
|
lines.Push(errorMessage)
|
||||||
|
end if
|
||||||
|
lines.Append(ParseOpenPopupAction(ObjectUtils.Dig(renderer, ["command", "openPopupAction"])))
|
||||||
|
return lines
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ParseOpenPopupAction(openPopupAction as object) as object
|
||||||
|
lines = []
|
||||||
|
panel = ObjectUtils.Dig(openPopupAction, ["popup", "overlaySectionRenderer", "overlay", "overlayTwoPanelRenderer", "actionPanel", "overlayPanelRenderer"])
|
||||||
|
if not IsAssociativeArray(panel)
|
||||||
|
return lines
|
||||||
|
end if
|
||||||
|
|
||||||
|
header = ObjectUtils.Dig(panel, ["header", "overlayPanelHeaderRenderer"])
|
||||||
|
title = ParseText(ObjectUtils.Dig(header, ["title"]))
|
||||||
|
if title <> ""
|
||||||
|
lines.Push(title)
|
||||||
|
end if
|
||||||
|
subtitle = ParseText(ObjectUtils.Dig(header, ["subtitle"]))
|
||||||
|
if subtitle <> ""
|
||||||
|
lines.Push(subtitle)
|
||||||
|
end if
|
||||||
|
|
||||||
|
items = ObjectUtils.Dig(panel, ["content", "overlayPanelItemListRenderer", "items"])
|
||||||
|
if not IsArray(items)
|
||||||
|
return lines
|
||||||
|
end if
|
||||||
|
for each item in items
|
||||||
|
url = ParseText(ObjectUtils.Dig(item, ["secondScreenActionRenderer", "url"]))
|
||||||
|
if url <> ""
|
||||||
|
lines.Push(url)
|
||||||
|
end if
|
||||||
|
lines.Append(ParseOpenPopupAction(ObjectUtils.Dig(item, ["compactLinkRenderer", "serviceEndpoint", "openPopupAction"])))
|
||||||
|
end for
|
||||||
|
return lines
|
||||||
|
end function
|
||||||
|
|
||||||
function PlayerResponseRequiresPageReload(payload as object) as boolean
|
function PlayerResponseRequiresPageReload(payload as object) as boolean
|
||||||
signal = ObjectUtils.Dig(payload, ["playabilityStatus", "errorScreen", "playerErrorMessageRenderer", "proceedButton", "buttonRenderer", "command", "signalAction", "signal"])
|
signal = ObjectUtils.Dig(payload, ["playabilityStatus", "errorScreen", "playerErrorMessageRenderer", "proceedButton", "buttonRenderer", "command", "signalAction", "signal"])
|
||||||
return IsString(signal) and signal = "RELOAD_PAGE"
|
return IsString(signal) and signal = "RELOAD_PAGE"
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import "pkg:/components/Services/Innertube/Context.bs"
|
import "pkg:/components/Services/Innertube/LiveStreamInfo.bs"
|
||||||
import "pkg:/source/services/HttpClient.bs"
|
import "pkg:/source/services/HttpClient.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/UrlUtils.bs"
|
import "pkg:/source/utils/UrlUtils.bs"
|
||||||
|
|
||||||
namespace Innertube
|
namespace Innertube
|
||||||
|
|
||||||
function GetPostLiveDvrInfo(parsedResponse as object, adaptiveFormats as object, cpn as dynamic, client as Innertube.ClientType, cancellation as object) as void
|
function GetPostLiveDvrInfo(parsedResponse as object, adaptiveFormats as object, cpn as dynamic, cancellation as object) as void
|
||||||
if adaptiveFormats.Count() = 0
|
if adaptiveFormats.Count() = 0
|
||||||
LogWarn("GetPostLiveDvrInfo: No adaptive formats available")
|
LogWarn("GetPostLiveDvrInfo: No adaptive formats available")
|
||||||
return
|
return
|
||||||
@@ -19,25 +19,16 @@ namespace Innertube
|
|||||||
|
|
||||||
' Query the live edge (no sq): that response is Cache-Control: no-cache, always
|
' Query the live edge (no sq): that response is Cache-Control: no-cache, always
|
||||||
' served fresh, so it carries X-Head-*. A finished stream's head is its final
|
' served fresh, so it carries X-Head-*. A finished stream's head is its final
|
||||||
' segment, so X-Head-Seqnum is the total count and X-Head-Time-Millis the duration.
|
' segment, so X-Head-Seqnum is the total count and X-Head-Time-* the duration.
|
||||||
primary = FetchPostLiveDvrHead(formatUrl, invalid, cpn, client, cancellation)
|
headUrl = GetLiveHeadUrl(formatUrl, cpn)
|
||||||
headers = invalid
|
response = FetchLiveHead(headUrl, cancellation)
|
||||||
|
|
||||||
if HasPostLiveDvrHead(primary)
|
if not HasLiveHead(response)
|
||||||
headers = primary.headers
|
' sq=0 is cacheable, so an edge can return it missing X-Head-*; fall back to it
|
||||||
else
|
' only when the live-edge query misses.
|
||||||
' sq=0 is cacheable, so an edge can return it missing X-Head-* (#359); fall
|
fallback = FetchLiveHead(UrlUtils.AppendQueryParams(headUrl, { "sq": "0" }), cancellation)
|
||||||
' back to it only when the live-edge query misses.
|
diagnostics = PostLiveDvrDiagnostics(parsedResponse["videoId"], headUrl, response, fallback)
|
||||||
fallback = FetchPostLiveDvrHead(formatUrl, "0", cpn, client, cancellation)
|
if not HasLiveHead(fallback)
|
||||||
diagnostics = PostLiveDvrDiagnostics(parsedResponse["videoId"], primary, fallback)
|
|
||||||
if HasPostLiveDvrHead(fallback)
|
|
||||||
headers = fallback.headers
|
|
||||||
LogTelemetryEvent({
|
|
||||||
level: "warning"
|
|
||||||
message: `GetPostLiveDvrInfo: no-sq missing head, sq=0 fallback recovered\n${diagnostics}`
|
|
||||||
fingerprint: ["GetPostLiveDvrInfo: sq=0 fallback recovered"]
|
|
||||||
})
|
|
||||||
else
|
|
||||||
' Warning, not error: a known transport-failure tail where playback fails regardless.
|
' Warning, not error: a known transport-failure tail where playback fails regardless.
|
||||||
LogTelemetryEvent({
|
LogTelemetryEvent({
|
||||||
level: "warning"
|
level: "warning"
|
||||||
@@ -46,10 +37,16 @@ namespace Innertube
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
LogTelemetryEvent({
|
||||||
|
level: "warning"
|
||||||
|
message: `GetPostLiveDvrInfo: no-sq missing head, sq=0 fallback recovered\n${diagnostics}`
|
||||||
|
fingerprint: ["GetPostLiveDvrInfo: sq=0 fallback recovered"]
|
||||||
|
})
|
||||||
|
response = fallback
|
||||||
end if
|
end if
|
||||||
|
|
||||||
durationMs = ValidString(headers["X-Head-Time-Millis"]).ToInt()
|
durationMs = ReadLiveHeadAnyTimeMs(response)
|
||||||
segmentCount = ValidString(headers["X-Head-Seqnum"]).ToInt()
|
segmentCount = ReadLiveHeadSeqnum(response)
|
||||||
|
|
||||||
if durationMs > 0
|
if durationMs > 0
|
||||||
parsedResponse["postLiveDvrDurationMs"] = durationMs
|
parsedResponse["postLiveDvrDurationMs"] = durationMs
|
||||||
@@ -59,40 +56,8 @@ namespace Innertube
|
|||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function FetchPostLiveDvrHead(formatUrl as string, sq as dynamic, cpn as dynamic, client as Innertube.ClientType, cancellation as object) as object
|
function PostLiveDvrDiagnostics(videoId as dynamic, headUrl as string, primary as HttpClient.Response, fallback as HttpClient.Response) as string
|
||||||
queryComponents = UrlUtils.ParseQueryComponents(formatUrl)
|
return `VideoID: ${ValidString(videoId)}` + Chr(10) + `URL (no-sq; sq=0 appends &sq=0): ${headUrl}` + Chr(10) + `no-sq HEAD status: ${primary.StatusCode().ToStr()} headers: ${FormatJson(primary.Headers())}` + Chr(10) + `sq=0 HEAD status: ${fallback.StatusCode().ToStr()} headers: ${FormatJson(fallback.Headers())}`
|
||||||
queryComponents["rn"] = "0"
|
|
||||||
if sq <> invalid
|
|
||||||
queryComponents["sq"] = sq
|
|
||||||
end if
|
|
||||||
if not StringUtils.IsNullOrEmpty(cpn)
|
|
||||||
queryComponents["cpn"] = cpn
|
|
||||||
end if
|
|
||||||
url = UrlUtils.SetQueryParams(formatUrl, queryComponents)
|
|
||||||
|
|
||||||
request = HttpClient.Head(url)
|
|
||||||
requestHeaders = Innertube.CreateHeaders(client)
|
|
||||||
requestHeaders["origin"] = "https://www.youtube.com"
|
|
||||||
requestHeaders["referer"] = "https://www.youtube.com"
|
|
||||||
requestHeaders["DNT"] = "?1"
|
|
||||||
request.Headers(requestHeaders)
|
|
||||||
request.RetryCount(1)
|
|
||||||
request.Cancellation(cancellation)
|
|
||||||
response = request.Await()
|
|
||||||
|
|
||||||
return {
|
|
||||||
url: url
|
|
||||||
statusCode: response.StatusCode()
|
|
||||||
headers: response.Headers()
|
|
||||||
}
|
|
||||||
end function
|
|
||||||
|
|
||||||
function HasPostLiveDvrHead(result as object) as boolean
|
|
||||||
return IsAssociativeArray(result) and IsAssociativeArray(result.headers) and result.headers.DoesExist("X-Head-Time-Millis") and result.headers.DoesExist("X-Head-Seqnum")
|
|
||||||
end function
|
|
||||||
|
|
||||||
function PostLiveDvrDiagnostics(videoId as dynamic, primary as object, fallback as object) as string
|
|
||||||
return `VideoID: ${ValidString(videoId)}` + Chr(10) + `URL (no-sq; sq=0 appends &sq=0): ${primary.url}` + Chr(10) + `no-sq HEAD status: ${primary.statusCode.ToStr()} headers: ${FormatJson(primary.headers)}` + Chr(10) + `sq=0 HEAD status: ${fallback.statusCode.ToStr()} headers: ${FormatJson(fallback.headers)}`
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
end namespace
|
end namespace
|
||||||
@@ -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,271 +0,0 @@
|
|||||||
import "pkg:/components/Services/LoungeService/LoungeBytes.bs"
|
|
||||||
import "pkg:/source/utils/ByteArrayUtils.bs"
|
|
||||||
|
|
||||||
enum HttpDecoderState
|
|
||||||
Head
|
|
||||||
ChunkSize
|
|
||||||
ChunkData
|
|
||||||
Done
|
|
||||||
Redirect
|
|
||||||
Error
|
|
||||||
end enum
|
|
||||||
|
|
||||||
enum HttpDecoderError
|
|
||||||
None = ""
|
|
||||||
MalformedStatus = "malformed_status"
|
|
||||||
UnsupportedEncoding = "unsupported_encoding"
|
|
||||||
ChunkOverflow = "chunk_overflow"
|
|
||||||
ShortRead = "short_read"
|
|
||||||
end enum
|
|
||||||
|
|
||||||
const HTTP_DECODER_COMPACT_THRESHOLD = 32768
|
|
||||||
const HTTP_DECODER_READ_LENGTH = 65536
|
|
||||||
|
|
||||||
class HttpChunkedDecoder
|
|
||||||
|
|
||||||
public statusCode = 0
|
|
||||||
public statusText = ""
|
|
||||||
public errorReason = HttpDecoderError.None
|
|
||||||
public headers
|
|
||||||
|
|
||||||
private buffer
|
|
||||||
private cursor = 0
|
|
||||||
private state = HttpDecoderState.Head
|
|
||||||
private chunkRemaining = 0
|
|
||||||
private headCheckedSize = 0
|
|
||||||
|
|
||||||
function new()
|
|
||||||
m.buffer = CreateObject("roByteArray")
|
|
||||||
m.headers = {}
|
|
||||||
end function
|
|
||||||
|
|
||||||
function Pump(socket as object, output as object) as integer
|
|
||||||
received = m.ReceiveFrom(socket)
|
|
||||||
if received > 0
|
|
||||||
m.Process(output)
|
|
||||||
end if
|
|
||||||
return received
|
|
||||||
end function
|
|
||||||
|
|
||||||
function IsDone() as boolean
|
|
||||||
return m.state = HttpDecoderState.Done
|
|
||||||
end function
|
|
||||||
|
|
||||||
function IsError() as boolean
|
|
||||||
return m.state = HttpDecoderState.Error
|
|
||||||
end function
|
|
||||||
|
|
||||||
function IsRedirect() as boolean
|
|
||||||
return m.state = HttpDecoderState.Redirect
|
|
||||||
end function
|
|
||||||
|
|
||||||
function Location() as dynamic
|
|
||||||
return m.headers["location"]
|
|
||||||
end function
|
|
||||||
|
|
||||||
private function ReceiveFrom(socket as object) as integer
|
|
||||||
available = socket.GetCountRcvBuf()
|
|
||||||
if available <= 0
|
|
||||||
return 0
|
|
||||||
end if
|
|
||||||
|
|
||||||
lengthToRead = available
|
|
||||||
if lengthToRead > HTTP_DECODER_READ_LENGTH
|
|
||||||
lengthToRead = HTTP_DECODER_READ_LENGTH
|
|
||||||
end if
|
|
||||||
|
|
||||||
writeIndex = m.buffer.Count()
|
|
||||||
m.buffer[writeIndex + lengthToRead - 1] = 0
|
|
||||||
received = socket.Receive(m.buffer, writeIndex, lengthToRead)
|
|
||||||
if received > 0 and received < lengthToRead
|
|
||||||
' GetCountRcvBuf reported more than Receive delivered, leaving uninitialised slack.
|
|
||||||
m.errorReason = HttpDecoderError.ShortRead
|
|
||||||
m.state = HttpDecoderState.Error
|
|
||||||
end if
|
|
||||||
return received
|
|
||||||
end function
|
|
||||||
|
|
||||||
private function Process(output as object) as void
|
|
||||||
running = true
|
|
||||||
while running
|
|
||||||
if m.state = HttpDecoderState.Head
|
|
||||||
running = m.ParseHead()
|
|
||||||
else if m.state = HttpDecoderState.ChunkSize
|
|
||||||
running = m.ParseChunkSize()
|
|
||||||
else if m.state = HttpDecoderState.ChunkData
|
|
||||||
running = m.ParseChunkData(output)
|
|
||||||
else
|
|
||||||
running = false
|
|
||||||
end if
|
|
||||||
end while
|
|
||||||
|
|
||||||
m.Compact()
|
|
||||||
end function
|
|
||||||
|
|
||||||
' Status line and headers are ASCII, so they parse as a string; the chunk body that follows is
|
|
||||||
' not, so it stays in bytes.
|
|
||||||
private function ParseHead() as boolean
|
|
||||||
bufferSize = m.buffer.Count()
|
|
||||||
if bufferSize = m.headCheckedSize
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
head = m.buffer.ToAsciiString()
|
|
||||||
delimiter = head.InStr(`\r\n\r\n`)
|
|
||||||
if delimiter = -1
|
|
||||||
m.headCheckedSize = bufferSize
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
contentStart = delimiter + 4
|
|
||||||
if m.buffer[contentStart - 4] <> 13 or m.buffer[contentStart - 3] <> 10 or m.buffer[contentStart - 2] <> 13 or m.buffer[contentStart - 1] <> 10
|
|
||||||
m.statusText = "Invalid header delimiter - is there unicode text in headers?"
|
|
||||||
m.errorReason = HttpDecoderError.MalformedStatus
|
|
||||||
m.state = HttpDecoderState.Error
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
lines = head.Left(delimiter).Split(`\r\n`)
|
|
||||||
if not m.ParseStatusLine(lines[0])
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
for i = 1 to lines.Count() - 1
|
|
||||||
m.ParseHeaderLine(lines[i])
|
|
||||||
end for
|
|
||||||
|
|
||||||
m.cursor = contentStart
|
|
||||||
return m.FinishHead()
|
|
||||||
end function
|
|
||||||
|
|
||||||
private function ParseStatusLine(line as string) as boolean
|
|
||||||
if not line.StartsWith("HTTP/1.1 ") and not line.StartsWith("HTTP/1.0 ")
|
|
||||||
m.statusText = "Malformed status line"
|
|
||||||
m.errorReason = HttpDecoderError.MalformedStatus
|
|
||||||
m.state = HttpDecoderState.Error
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
rest = line.Mid(9).Trim()
|
|
||||||
spaceIndex = rest.InStr(" ")
|
|
||||||
if spaceIndex = -1
|
|
||||||
m.statusCode = Int(Val(rest, 10))
|
|
||||||
m.statusText = ""
|
|
||||||
else
|
|
||||||
m.statusCode = Int(Val(rest.Left(spaceIndex), 10))
|
|
||||||
m.statusText = rest.Mid(spaceIndex + 1)
|
|
||||||
end if
|
|
||||||
return true
|
|
||||||
end function
|
|
||||||
|
|
||||||
private function ParseHeaderLine(line as string) as void
|
|
||||||
colon = line.InStr(":")
|
|
||||||
if colon > 0
|
|
||||||
key = LCase(line.Left(colon).Trim())
|
|
||||||
m.headers[key] = line.Mid(colon + 1).Trim()
|
|
||||||
end if
|
|
||||||
end function
|
|
||||||
|
|
||||||
private function FinishHead() as boolean
|
|
||||||
if m.IsRedirectStatus(m.statusCode)
|
|
||||||
m.state = HttpDecoderState.Redirect
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
if m.statusCode <> 200
|
|
||||||
m.state = HttpDecoderState.Error
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
transferEncoding = m.headers["transfer-encoding"]
|
|
||||||
if transferEncoding = invalid or LCase(transferEncoding).InStr("chunked") = -1
|
|
||||||
m.statusText = "Unsupported transfer-encoding"
|
|
||||||
m.errorReason = HttpDecoderError.UnsupportedEncoding
|
|
||||||
m.state = HttpDecoderState.Error
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
m.state = HttpDecoderState.ChunkSize
|
|
||||||
return true
|
|
||||||
end function
|
|
||||||
|
|
||||||
private function IsRedirectStatus(code as integer) as boolean
|
|
||||||
return code = 301 or code = 302 or code = 303 or code = 307 or code = 308
|
|
||||||
end function
|
|
||||||
|
|
||||||
private function ParseChunkSize() as boolean
|
|
||||||
' Skip the CRLF trailing the previous chunk's data (and any stray newlines).
|
|
||||||
while m.cursor < m.buffer.Count() and (m.buffer[m.cursor] = 13 or m.buffer[m.cursor] = 10)
|
|
||||||
m.cursor += 1
|
|
||||||
end while
|
|
||||||
|
|
||||||
crlf = LoungeBytes.IndexOfCrlf(m.buffer, m.cursor)
|
|
||||||
if crlf = -1
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
sizeLine = LoungeBytes.RangeToString(m.buffer, m.cursor, crlf)
|
|
||||||
m.cursor = crlf + 2
|
|
||||||
|
|
||||||
' A chunk-size line may carry ';ext' extensions; the size is the leading hex token.
|
|
||||||
semicolon = sizeLine.InStr(";")
|
|
||||||
if semicolon > 0
|
|
||||||
sizeLine = sizeLine.Left(semicolon)
|
|
||||||
end if
|
|
||||||
m.chunkRemaining = Int(Val(sizeLine.Trim(), 16))
|
|
||||||
|
|
||||||
if m.chunkRemaining < 0
|
|
||||||
' A size that doesn't fit a 32-bit int is a corrupt size line or a parse desync.
|
|
||||||
m.errorReason = HttpDecoderError.ChunkOverflow
|
|
||||||
m.state = HttpDecoderState.Error
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
if m.chunkRemaining = 0
|
|
||||||
m.state = HttpDecoderState.Done
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
m.state = HttpDecoderState.ChunkData
|
|
||||||
return true
|
|
||||||
end function
|
|
||||||
|
|
||||||
private function ParseChunkData(output as object) as boolean
|
|
||||||
available = m.buffer.Count() - m.cursor
|
|
||||||
if available <= 0
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
take = available
|
|
||||||
if take > m.chunkRemaining
|
|
||||||
take = m.chunkRemaining
|
|
||||||
end if
|
|
||||||
|
|
||||||
chunk = ByteArrayUtils.Slice(m.buffer, m.cursor, m.cursor + take)
|
|
||||||
output.Append(chunk)
|
|
||||||
m.cursor += take
|
|
||||||
m.chunkRemaining -= take
|
|
||||||
|
|
||||||
if m.chunkRemaining = 0
|
|
||||||
m.state = HttpDecoderState.ChunkSize
|
|
||||||
return true
|
|
||||||
end if
|
|
||||||
return false
|
|
||||||
end function
|
|
||||||
|
|
||||||
' A fully consumed buffer Clears for free; a partial one waits until the dead prefix is worth a slice.
|
|
||||||
private function Compact() as void
|
|
||||||
if m.cursor = 0
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
if m.cursor >= m.buffer.Count()
|
|
||||||
m.buffer.Clear()
|
|
||||||
else if m.cursor >= HTTP_DECODER_COMPACT_THRESHOLD
|
|
||||||
m.buffer = LoungeBytes.Tail(m.buffer, m.cursor)
|
|
||||||
else
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
m.cursor = 0
|
|
||||||
m.headCheckedSize = 0
|
|
||||||
end function
|
|
||||||
|
|
||||||
end class
|
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
|
||||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||||
import "pkg:/components/Services/LoungeService/LoungeBackchannel.bs"
|
import "pkg:/components/Services/LoungeService/LoungeBackchannel.bs"
|
||||||
import "pkg:/components/Services/LoungeService/LoungeConstants.bs"
|
import "pkg:/components/Services/LoungeService/LoungeConstants.bs"
|
||||||
import "pkg:/components/Services/LoungeService/LoungeFraming.bs"
|
|
||||||
import "pkg:/components/Services/LoungeService/LoungeMessages.bs"
|
import "pkg:/components/Services/LoungeService/LoungeMessages.bs"
|
||||||
import "pkg:/components/Services/LoungeService/LoungeVideoQueue.bs"
|
import "pkg:/components/Services/LoungeService/LoungeVideoQueue.bs"
|
||||||
import "pkg:/components/Services/LoungeService/Notifications/DeviceConnectedNotificationUtils.bs"
|
import "pkg:/components/Services/LoungeService/Notifications/DeviceConnectedNotificationUtils.bs"
|
||||||
@@ -10,7 +8,7 @@ import "pkg:/source/services/HttpClient.bs"
|
|||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/RegistryUtils.bs"
|
import "pkg:/source/utils/RegistryUtils.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/UrlUtils.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
const COMMAND_HANDLER_PREFIX = "_Handle_"
|
const COMMAND_HANDLER_PREFIX = "_Handle_"
|
||||||
|
|
||||||
@@ -37,14 +35,14 @@ class LoungeApi
|
|||||||
' Set by a send's failure, until the next bind.
|
' Set by a send's failure, until the next bind.
|
||||||
public sessionGone = false
|
public sessionGone = false
|
||||||
public tokenExpired = false
|
public tokenExpired = false
|
||||||
|
public backchannel as LoungeBackchannel
|
||||||
|
|
||||||
private ofs
|
private ofs
|
||||||
private lastProcessedCommandIndex = -1
|
private messagePort
|
||||||
private backchannel
|
|
||||||
private pendingOutgoingMessages
|
private pendingOutgoingMessages
|
||||||
private lastLoungeDisconnect
|
private lastLoungeDisconnect
|
||||||
|
|
||||||
function new(loungeServiceNode as object, videoQueueNode as object, notificationsNode as object, invidiousNode as object)
|
function new(loungeServiceNode as object, videoQueueNode as object, notificationsNode as object, invidiousNode as object, messagePort as object)
|
||||||
m.loungeServiceNode = loungeServiceNode
|
m.loungeServiceNode = loungeServiceNode
|
||||||
m.videoQueueNode = videoQueueNode
|
m.videoQueueNode = videoQueueNode
|
||||||
m.notificationsNode = notificationsNode
|
m.notificationsNode = notificationsNode
|
||||||
@@ -55,7 +53,8 @@ class LoungeApi
|
|||||||
m.deviceName = deviceName
|
m.deviceName = deviceName
|
||||||
m.screenName = deviceName
|
m.screenName = deviceName
|
||||||
m.ofs = 0
|
m.ofs = 0
|
||||||
m.backchannel = invalid
|
m.messagePort = messagePort
|
||||||
|
m.backchannel = new LoungeBackchannel()
|
||||||
m.pendingOutgoingMessages = []
|
m.pendingOutgoingMessages = []
|
||||||
m.devices = {}
|
m.devices = {}
|
||||||
|
|
||||||
@@ -119,23 +118,13 @@ class LoungeApi
|
|||||||
|
|
||||||
response = request.Await()
|
response = request.Await()
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
error = Tr(Locale.Dialogs.LoungeFailedToGetScreenId) + `\n${response.ErrorMessage()}`
|
LogError(`Failed to get lounge screen ID\n${response.ErrorMessage()}`)
|
||||||
LogError(error)
|
|
||||||
DialogUtils.ShowDialogEx({
|
|
||||||
message: error
|
|
||||||
title: Tr(Locale.Dialogs.LoungeServiceSetupError)
|
|
||||||
})
|
|
||||||
return invalid
|
return invalid
|
||||||
end if
|
end if
|
||||||
|
|
||||||
id = response.Text()
|
id = response.Text()
|
||||||
if not IsString(id)
|
if StringUtils.IsNullOrEmpty(id)
|
||||||
error = Tr(Locale.Dialogs.LoungeFailedToGetScreenId) + `\n` = Tr(Locale.Dialogs.LoungeNotAValidScreenId).Replace("%1", `${id}`)
|
LogError("Failed to get lounge screen ID: empty response")
|
||||||
LogError(error)
|
|
||||||
DialogUtils.ShowDialogEx({
|
|
||||||
message: error
|
|
||||||
title: Tr(Locale.Dialogs.LoungeServiceSetupError)
|
|
||||||
})
|
|
||||||
return invalid
|
return invalid
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -155,24 +144,14 @@ class LoungeApi
|
|||||||
|
|
||||||
response = request.Await()
|
response = request.Await()
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
error = Tr(Locale.Dialogs.LoungeFailedToGetLoungeToken) + `\n${response.ErrorMessage()}`
|
LogError(`Failed to get lounge token\n${response.ErrorMessage()}`)
|
||||||
LogError(error)
|
|
||||||
DialogUtils.ShowDialogEx({
|
|
||||||
message: error
|
|
||||||
title: Tr(Locale.Dialogs.LoungeServiceSetupError)
|
|
||||||
})
|
|
||||||
return invalid
|
return invalid
|
||||||
end if
|
end if
|
||||||
|
|
||||||
json = response.Json()
|
json = response.Json()
|
||||||
screens = json.screens
|
screens = ValidAssociativeArray(json).screens
|
||||||
if not IsArray(screens) or screens.Count() <> 1
|
if not IsArray(screens) or screens.Count() <> 1
|
||||||
error = Tr(Locale.Dialogs.LoungeFailedToGetLoungeToken) + `\n` + Tr(Locale.Dialogs.LoungeInvalidResponse).Replace("%1", `${json}`)
|
LogError(`Failed to get lounge token: invalid response\nBody: ${response.Text()}`)
|
||||||
LogError(error)
|
|
||||||
DialogUtils.ShowDialogEx({
|
|
||||||
message: error
|
|
||||||
title: Tr(Locale.Dialogs.LoungeServiceSetupError)
|
|
||||||
})
|
|
||||||
return invalid
|
return invalid
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -181,8 +160,8 @@ class LoungeApi
|
|||||||
return m.loungeToken
|
return m.loungeToken
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetSessionData() as boolean
|
private function BindQueryParams(loungeData as object) as object
|
||||||
queryParams = {
|
return {
|
||||||
"device": "LOUNGE_SCREEN"
|
"device": "LOUNGE_SCREEN"
|
||||||
"theme": "cl"
|
"theme": "cl"
|
||||||
"capabilities": "vsp"
|
"capabilities": "vsp"
|
||||||
@@ -191,13 +170,16 @@ class LoungeApi
|
|||||||
"v": "2"
|
"v": "2"
|
||||||
"t": "1"
|
"t": "1"
|
||||||
"app": "lb-v4"
|
"app": "lb-v4"
|
||||||
"RID": "1337"
|
"name": loungeData.screenName
|
||||||
|
"id": loungeData.deviceId
|
||||||
|
"loungeIdToken": loungeData.loungeToken
|
||||||
|
"zx": m.Zx()
|
||||||
}
|
}
|
||||||
|
end function
|
||||||
|
|
||||||
queryParams["name"] = m.screenName
|
function GetSessionData() as boolean
|
||||||
queryParams["id"] = m.deviceId
|
queryParams = m.BindQueryParams(m)
|
||||||
queryParams["loungeIdToken"] = m.loungeToken
|
queryParams["RID"] = "1337"
|
||||||
queryParams["zx"] = m.Zx()
|
|
||||||
|
|
||||||
request = HttpClient.Post("https://www.youtube.com/api/lounge/bc/bind")
|
request = HttpClient.Post("https://www.youtube.com/api/lounge/bc/bind")
|
||||||
request.QueryParams(queryParams)
|
request.QueryParams(queryParams)
|
||||||
@@ -207,28 +189,16 @@ class LoungeApi
|
|||||||
|
|
||||||
response = request.Await()
|
response = request.Await()
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
error = Tr(Locale.Dialogs.LoungeFailedToGetSessionData) + `\n${response.ErrorMessage()}`
|
LogError(`Failed to get lounge session data\n${response.ErrorMessage()}`)
|
||||||
LogError(error)
|
|
||||||
DialogUtils.ShowDialogEx({
|
|
||||||
message: error
|
|
||||||
title: Tr(Locale.Dialogs.LoungeServiceSetupError)
|
|
||||||
})
|
|
||||||
return false
|
return false
|
||||||
end if
|
end if
|
||||||
|
|
||||||
body = CreateObject("roByteArray")
|
|
||||||
body.FromAsciiString(response.Text())
|
|
||||||
|
|
||||||
' A new session restarts command indices from 0; clear the high-water mark so its commands
|
|
||||||
' aren't skipped as duplicates. Its outbound offset restarts from 0 too.
|
|
||||||
m.lastProcessedCommandIndex = -1
|
|
||||||
m.ofs = 0
|
m.ofs = 0
|
||||||
m.sessionGone = false
|
m.sessionGone = false
|
||||||
m.tokenExpired = false
|
m.tokenExpired = false
|
||||||
messagesToSend = []
|
messagesToSend = []
|
||||||
result = LoungeFraming.Extract(body, 0)
|
for each command in m.backchannel.StartSession(response.Text())
|
||||||
for each frame in result.frames
|
m.ProcessCommand(command, messagesToSend)
|
||||||
m.ProcessFrame(frame, messagesToSend)
|
|
||||||
end for
|
end for
|
||||||
if StringUtils.IsNullOrEmpty(m.sessionId) or StringUtils.IsNullOrEmpty(m.gSessionId)
|
if StringUtils.IsNullOrEmpty(m.sessionId) or StringUtils.IsNullOrEmpty(m.gSessionId)
|
||||||
LogTelemetryEvent({
|
LogTelemetryEvent({
|
||||||
@@ -241,52 +211,35 @@ class LoungeApi
|
|||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function FetchCommandsRpc(messagePort as object) as void
|
function StartPoll() as void
|
||||||
' Plain HTTP: LoungeBackchannel streams this response over a raw socket, which has no TLS
|
queryParams = m.BindQueryParams(m)
|
||||||
baseUrl = "http://www.youtube.com/api/lounge/bc/bind"
|
queryParams["RID"] = "rpc"
|
||||||
queryParams = {
|
|
||||||
"device": "LOUNGE_SCREEN"
|
|
||||||
"theme": "cl"
|
|
||||||
"capabilities": "vsp"
|
|
||||||
"mdxVersion": "2"
|
|
||||||
"VER": "8"
|
|
||||||
"v": "2"
|
|
||||||
"t": "1"
|
|
||||||
"app": "lb-v4"
|
|
||||||
"RID": "rpc"
|
|
||||||
"CI": "0"
|
|
||||||
}
|
|
||||||
|
|
||||||
queryParams["name"] = m.screenName
|
|
||||||
queryParams["id"] = m.deviceId
|
|
||||||
queryParams["loungeIdToken"] = m.loungeToken
|
|
||||||
queryParams["SID"] = m.sessionId
|
queryParams["SID"] = m.sessionId
|
||||||
queryParams["gsessionid"] = m.gSessionId
|
queryParams["gsessionid"] = m.gSessionId
|
||||||
queryParams["zx"] = m.Zx()
|
queryParams["CI"] = "1"
|
||||||
|
queryParams["TYPE"] = "xmlhttp"
|
||||||
|
|
||||||
url = UrlUtils.BuildUrl(baseUrl, invalid, queryParams)
|
request = HttpClient.Get("https://www.youtube.com/api/lounge/bc/bind")
|
||||||
|
request.QueryParams(queryParams)
|
||||||
if m.backchannel = invalid
|
m.backchannel.Open(request, m.messagePort)
|
||||||
m.backchannel = new LoungeBackchannel()
|
|
||||||
end if
|
|
||||||
|
|
||||||
m.backchannel.Open(url, messagePort)
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function Poll(socketMessages as object, messagesToSend as object) as boolean
|
function HandleMessage(message as dynamic, messagesToSend as object) as void
|
||||||
frames = m.backchannel.Poll(socketMessages)
|
for each command in m.backchannel.Handle(message)
|
||||||
for each frame in frames
|
m.ProcessCommand(command, messagesToSend)
|
||||||
m.ProcessFrame(frame, messagesToSend)
|
|
||||||
end for
|
end for
|
||||||
|
m.HandleSends(message)
|
||||||
return m.backchannel.IsOpen()
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetCloseInfo() as object
|
function MaxWaitMs() as integer
|
||||||
if m.backchannel = invalid
|
waitMs = m.backchannel.MaxWaitMs()
|
||||||
return { statusCode: 0, reason: "", target: "" }
|
for each pending in m.pendingOutgoingMessages
|
||||||
end if
|
pendingWaitMs = pending.MaxWaitMs()
|
||||||
return { statusCode: m.backchannel.statusCode, reason: m.backchannel.closeReason, target: m.backchannel.redirectTarget }
|
if waitMs = 0 or pendingWaitMs < waitMs
|
||||||
|
waitMs = pendingWaitMs
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
return waitMs
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function RefreshToken() as dynamic
|
function RefreshToken() as dynamic
|
||||||
@@ -303,10 +256,7 @@ class LoungeApi
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function Rebind(withNewToken as boolean) as boolean
|
function Rebind(withNewToken as boolean) as boolean
|
||||||
for each pending in m.pendingOutgoingMessages
|
m.CancelSends()
|
||||||
pending.Cancel()
|
|
||||||
end for
|
|
||||||
m.pendingOutgoingMessages = []
|
|
||||||
|
|
||||||
if withNewToken
|
if withNewToken
|
||||||
LogWarnNoTelemetry("Lounge token expired, refreshing")
|
LogWarnNoTelemetry("Lounge token expired, refreshing")
|
||||||
@@ -319,58 +269,38 @@ class LoungeApi
|
|||||||
return m.Bind()
|
return m.Bind()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ProcessFrame(frame as string, messagesToSend as object) as void
|
function EndSession() as void
|
||||||
commands = StringUtils.ParseJsonSafe(frame)
|
m.backchannel.Close()
|
||||||
if not IsArray(commands)
|
m.CancelSends()
|
||||||
LogTelemetryEvent({
|
m.loungeToken = invalid
|
||||||
level: "error"
|
|
||||||
message: "Lounge frame did not parse to a command array: " + frame.Left(256)
|
|
||||||
fingerprint: "lounge-unparseable-frame"
|
|
||||||
})
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
m.ProcessCommands(commands, messagesToSend)
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ProcessCommands(commands as object, messagesToSend as object) as void
|
private function CancelSends() as void
|
||||||
for each command in commands
|
for each pending in m.pendingOutgoingMessages
|
||||||
if not IsArray(command) or command.Count() <> 2
|
pending.Cancel()
|
||||||
continue for
|
|
||||||
end if
|
|
||||||
|
|
||||||
commandIndex = command[0]
|
|
||||||
commandData = command[1]
|
|
||||||
commandType = commandData[0]
|
|
||||||
|
|
||||||
if commandIndex <= m.lastProcessedCommandIndex and commandType <> COMMAND_TYPE_G_SESSION_ID and commandType <> COMMAND_TYPE_SESSION_ID
|
|
||||||
LogDebug("Skipping command already processed:", command)
|
|
||||||
continue for
|
|
||||||
end if
|
|
||||||
m.lastProcessedCommandIndex = commandIndex
|
|
||||||
|
|
||||||
commandArgs = invalid
|
|
||||||
if commandData.Count() > 1
|
|
||||||
commandArgs = commandData[1]
|
|
||||||
end if
|
|
||||||
|
|
||||||
handler = COMMAND_HANDLER_PREFIX + commandType
|
|
||||||
if m.DoesExist(handler)
|
|
||||||
LogInfo(commandIndex, commandType)
|
|
||||||
m[handler](commandIndex, commandType, commandArgs, messagesToSend)
|
|
||||||
else
|
|
||||||
fingerprint = "Unknown command type:" + ToString(commandType)
|
|
||||||
message = fingerprint + " command:" + ToString(command)
|
|
||||||
LogWarnNoTelemetry(message)
|
|
||||||
LogTelemetryEvent({
|
|
||||||
level: "warning"
|
|
||||||
message: message
|
|
||||||
fingerprint: fingerprint
|
|
||||||
})
|
|
||||||
#if DEBUG
|
|
||||||
throw message
|
|
||||||
#end if
|
|
||||||
end if
|
|
||||||
end for
|
end for
|
||||||
|
m.pendingOutgoingMessages = []
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ProcessCommand(command as LoungeCommand, messagesToSend as object) as void
|
||||||
|
handler = COMMAND_HANDLER_PREFIX + command.type
|
||||||
|
if m.DoesExist(handler)
|
||||||
|
LogInfo(command.index, command.type)
|
||||||
|
m[handler](command.index, command.type, command.args, messagesToSend)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
fingerprint = "Unknown command type:" + command.type
|
||||||
|
message = fingerprint + " command:" + ToString(command)
|
||||||
|
LogWarnNoTelemetry(message)
|
||||||
|
LogTelemetryEvent({
|
||||||
|
level: "warning"
|
||||||
|
message: message
|
||||||
|
fingerprint: fingerprint
|
||||||
|
})
|
||||||
|
#if DEBUG
|
||||||
|
throw message
|
||||||
|
#end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function HandleIgnoreCommand(_commandId as integer, commandType as string, commandArgs as object, _messagesToSend as object)
|
function HandleIgnoreCommand(_commandId as integer, commandType as string, commandArgs as object, _messagesToSend as object)
|
||||||
@@ -387,20 +317,11 @@ class LoungeApi
|
|||||||
LogInfo("gSessionId:", m.gSessionId)
|
LogInfo("gSessionId:", m.gSessionId)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function HandleGetPlayingNow(commandId as integer, _commandType as string, _commandArgs as object, messagesToSend as object) as void
|
function HandleGetPlayingNow(_commandId as integer, _commandType as string, _commandArgs as object, messagesToSend as object) as void
|
||||||
player = m.videoQueueNode.player
|
player = m.videoQueueNode.player
|
||||||
|
messagesToSend.Push(LoungeMessages.OnHasPreviousNextChanged(m.videoQueueNode.hasPrevious, m.videoQueueNode.hasNext))
|
||||||
message = LoungeMessages.OnHasPreviousNextChanged(m.videoQueueNode.hasPrevious, m.videoQueueNode.hasNext)
|
messagesToSend.Push(LoungeMessages.NowPlaying(player))
|
||||||
message["commandId"] = commandId
|
messagesToSend.Push(LoungeMessages.OnStateChange(player))
|
||||||
messagesToSend.Push(message)
|
|
||||||
|
|
||||||
message = LoungeMessages.NowPlaying(player)
|
|
||||||
message["commandId"] = commandId
|
|
||||||
messagesToSend.Push(message)
|
|
||||||
|
|
||||||
message = LoungeMessages.OnStateChange(player)
|
|
||||||
message["commandId"] = commandId
|
|
||||||
messagesToSend.Push(message)
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function HandleLoungeStatus(_commandId as integer, commandType as string, commandArgs as object, _messagesToSend as object) as void
|
function HandleLoungeStatus(_commandId as integer, commandType as string, commandArgs as object, _messagesToSend as object) as void
|
||||||
@@ -556,7 +477,7 @@ class LoungeApi
|
|||||||
messagesToSend.Push(LoungeMessages.OnPlaybackSpeedChanged(speed, true))
|
messagesToSend.Push(LoungeMessages.OnPlaybackSpeedChanged(speed, true))
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function HandleGetPlaybackSpeed(commandId as integer, _commandType as string, _commandArgs as object, messagesToSend as object) as void
|
function HandleGetPlaybackSpeed(_commandId as integer, _commandType as string, _commandArgs as object, messagesToSend as object) as void
|
||||||
player = m.videoQueueNode.player
|
player = m.videoQueueNode.player
|
||||||
if player = invalid
|
if player = invalid
|
||||||
return
|
return
|
||||||
@@ -572,39 +493,23 @@ class LoungeApi
|
|||||||
speed = 1.0
|
speed = 1.0
|
||||||
end if
|
end if
|
||||||
|
|
||||||
message = LoungeMessages.OnPlaybackSpeedChanged(speed)
|
messagesToSend.Push(LoungeMessages.OnPlaybackSpeedChanged(speed))
|
||||||
message["commandId"] = commandId
|
|
||||||
messagesToSend.Push(message)
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function SendMessages(messages as object) as void
|
function SendMessages(messages as object) as void
|
||||||
if messages.Count() = 0
|
if messages.Count() = 0
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
m.pendingOutgoingMessages.Push(m.SendMessagesTo(m, messages))
|
m.pendingOutgoingMessages.Push(m.SendRequest(m, messages, m.backchannel.ackedCommandIndex).SendOn(m.messagePort))
|
||||||
end function
|
end function
|
||||||
|
|
||||||
private function SendMessagesTo(loungeData as object, messages as object) as HttpClient.PendingResponse
|
private function SendRequest(loungeData as object, messages as object, ackedCommandIndex as integer) as HttpClient.Request
|
||||||
queryParams = {
|
queryParams = m.BindQueryParams(loungeData)
|
||||||
"device": "LOUNGE_SCREEN"
|
queryParams["RID"] = "1337"
|
||||||
"theme": "cl"
|
|
||||||
"capabilities": "vsp"
|
|
||||||
"mdxVersion": "2"
|
|
||||||
"VER": "8"
|
|
||||||
"v": "2"
|
|
||||||
"t": "1"
|
|
||||||
"app": "lb-v4"
|
|
||||||
"RID": "1337"
|
|
||||||
}
|
|
||||||
|
|
||||||
queryParams["name"] = loungeData.screenName
|
|
||||||
queryParams["id"] = loungeData.deviceId
|
|
||||||
queryParams["loungeIdToken"] = loungeData.loungeToken
|
|
||||||
queryParams["SID"] = loungeData.sessionId
|
queryParams["SID"] = loungeData.sessionId
|
||||||
queryParams["gsessionid"] = loungeData.gSessionId
|
queryParams["gsessionid"] = loungeData.gSessionId
|
||||||
queryParams["zx"] = m.Zx()
|
if ackedCommandIndex >= 0
|
||||||
if messages[0].commandId <> invalid
|
queryParams["AID"] = ackedCommandIndex
|
||||||
queryParams["AID"] = messages[0].commandId
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
postData = [
|
postData = [
|
||||||
@@ -633,64 +538,51 @@ class LoungeApi
|
|||||||
request = HttpClient.Post("https://www.youtube.com/api/lounge/bc/bind")
|
request = HttpClient.Post("https://www.youtube.com/api/lounge/bc/bind")
|
||||||
request.QueryParams(queryParams)
|
request.QueryParams(queryParams)
|
||||||
request.FormBody(postData)
|
request.FormBody(postData)
|
||||||
return request.Send()
|
return request
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function HasPendingOutgoingMessages() as boolean
|
private function HandleSends(message as dynamic) as void
|
||||||
return m.pendingOutgoingMessages.Count() > 0
|
for i = m.pendingOutgoingMessages.Count() - 1 to 0 step -1
|
||||||
end function
|
response = m.pendingOutgoingMessages[i].Handle(message)
|
||||||
|
if response <> invalid
|
||||||
function ProcessPendingOutgoingMessages() as object
|
m.pendingOutgoingMessages.Delete(i)
|
||||||
results = []
|
|
||||||
stillPending = []
|
|
||||||
for each pending in m.pendingOutgoingMessages
|
|
||||||
response = pending.Poll()
|
|
||||||
if response = invalid
|
|
||||||
stillPending.Push(pending)
|
|
||||||
else
|
|
||||||
status = response.StatusCode()
|
|
||||||
error = response.ErrorMessage()
|
|
||||||
|
|
||||||
results.Push({
|
|
||||||
"status": status
|
|
||||||
"error": error
|
|
||||||
})
|
|
||||||
|
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
isGone = response.StatusCode() = 410
|
m.OnSendFailed(response)
|
||||||
unknownSid = response.StatusCode() = 400 and response.ErrorMessage().InStr("Unknown SID") <> -1
|
|
||||||
expiredToken = response.StatusCode() = 401 and response.ErrorMessage().InStr("Expired lounge id token") <> -1
|
|
||||||
isKnownError = isGone or unknownSid or expiredToken
|
|
||||||
if isGone or unknownSid
|
|
||||||
m.sessionGone = true
|
|
||||||
else if expiredToken
|
|
||||||
m.tokenExpired = true
|
|
||||||
end if
|
|
||||||
|
|
||||||
if isKnownError
|
|
||||||
' NoTelemetry: the body carries a volatile token; logging it would fragment these.
|
|
||||||
LogErrorNoTelemetry(response.ErrorMessage())
|
|
||||||
if expiredToken
|
|
||||||
LogTelemetryEvent({
|
|
||||||
level: "warning"
|
|
||||||
message: "Lounge id token expired"
|
|
||||||
fingerprint: "lounge-expired-token"
|
|
||||||
})
|
|
||||||
end if
|
|
||||||
else
|
|
||||||
LogErrorNoTelemetry(error)
|
|
||||||
LogTelemetryEvent({
|
|
||||||
level: "error"
|
|
||||||
message: error
|
|
||||||
fingerprint: ["lounge-send-failure", status]
|
|
||||||
})
|
|
||||||
end if
|
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
end for
|
end for
|
||||||
m.pendingOutgoingMessages = stillPending
|
end function
|
||||||
|
|
||||||
return results
|
private function OnSendFailed(response as HttpClient.Response) as void
|
||||||
|
status = response.StatusCode()
|
||||||
|
error = response.ErrorMessage()
|
||||||
|
isGone = status = 410
|
||||||
|
unknownSid = status = 400 and error.InStr("Unknown SID") <> -1
|
||||||
|
expiredToken = status = 401 and error.InStr("Expired lounge id token") <> -1
|
||||||
|
if isGone or unknownSid
|
||||||
|
m.sessionGone = true
|
||||||
|
else if expiredToken
|
||||||
|
m.tokenExpired = true
|
||||||
|
end if
|
||||||
|
|
||||||
|
if isGone or unknownSid or expiredToken
|
||||||
|
' NoTelemetry: the body carries a volatile token; logging it would fragment these.
|
||||||
|
LogErrorNoTelemetry(error)
|
||||||
|
if expiredToken
|
||||||
|
LogTelemetryEvent({
|
||||||
|
level: "warning"
|
||||||
|
message: "Lounge id token expired"
|
||||||
|
fingerprint: "lounge-expired-token"
|
||||||
|
})
|
||||||
|
end if
|
||||||
|
else
|
||||||
|
LogErrorNoTelemetry(error)
|
||||||
|
LogTelemetryEvent({
|
||||||
|
level: "error"
|
||||||
|
message: error
|
||||||
|
fingerprint: ["lounge-send-failure", status]
|
||||||
|
})
|
||||||
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function SaveCurrentLoungeData() as void
|
function SaveCurrentLoungeData() as void
|
||||||
@@ -750,7 +642,7 @@ class LoungeApi
|
|||||||
' This is the last message we'll be sending to this lounge.
|
' This is the last message we'll be sending to this lounge.
|
||||||
loungeData.ofs = 99999999
|
loungeData.ofs = 99999999
|
||||||
' Held: dropping it releases its transfer, which aborts the send.
|
' Held: dropping it releases its transfer, which aborts the send.
|
||||||
m.lastLoungeDisconnect = m.SendMessagesTo(loungeData, messages)
|
m.lastLoungeDisconnect = m.SendRequest(loungeData, messages, -1).Send()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
end class
|
end class
|
||||||
@@ -1,242 +1,179 @@
|
|||||||
import "pkg:/components/Services/LoungeService/HttpChunkedDecoder.bs"
|
import "pkg:/components/Services/LoungeService/LoungeService.types.bs"
|
||||||
import "pkg:/components/Services/LoungeService/LoungeBytes.bs"
|
import "pkg:/source/services/HttpClient.bs"
|
||||||
import "pkg:/components/Services/LoungeService/LoungeFraming.bs"
|
import "pkg:/source/utils/ByteArrayUtils.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/UrlUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
' Server sends periodic noop keepalives, so no data for this long means a dead connection.
|
' The server answers a poll with a noop after at most ~30 s idle, and drops a session that goes 55-60 s without a poll.
|
||||||
const LOUNGE_BACKCHANNEL_TIMEOUT_MS = 60000
|
' Giving up on a dead connection by 40 s lets the next poll, after the first backoff, land before the session is gone.
|
||||||
const LOUNGE_BACKCHANNEL_BODY_COMPACT = 32768
|
const LOUNGE_POLL_TIMEOUT_MS = 40000
|
||||||
const LOUNGE_BACKCHANNEL_MAX_REDIRECTS = 10
|
|
||||||
|
|
||||||
' Raw socket on plain HTTP: roUrlTransfer can't read a streaming body incrementally, and
|
|
||||||
' roStreamSocket has no TLS.
|
|
||||||
class LoungeBackchannel
|
class LoungeBackchannel
|
||||||
|
|
||||||
public statusCode = 0
|
public statusCode = 0
|
||||||
public closeReason = ""
|
public closeReason as LoungeCloseReason
|
||||||
public redirectTarget = ""
|
public ackedCommandIndex = -1
|
||||||
|
public stalledPolls = 0
|
||||||
|
public pollTimeoutMs = LOUNGE_POLL_TIMEOUT_MS
|
||||||
|
|
||||||
private socket
|
private pending = invalid
|
||||||
private decoder
|
private polledCommandIndex = -1
|
||||||
private body
|
|
||||||
private bodyCursor = 0
|
|
||||||
private timer
|
|
||||||
private url = ""
|
|
||||||
private messagePort
|
|
||||||
private redirectCount = 0
|
|
||||||
|
|
||||||
function new()
|
' A new session restarts command indices from 0.
|
||||||
m.timer = CreateObject("roTimespan")
|
function StartSession(bindResponseText as string) as LoungeCommand[]
|
||||||
|
m.ackedCommandIndex = -1
|
||||||
|
m.stalledPolls = 0
|
||||||
|
return m.Receive(m.ExtractFrames(bindResponseText))
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function Open(url as string, messagePort as object) as boolean
|
function Open(request as HttpClient.Request, messagePort as object) as void
|
||||||
m.messagePort = messagePort
|
|
||||||
m.redirectCount = 0
|
|
||||||
m.redirectTarget = ""
|
|
||||||
return m.Connect(url)
|
|
||||||
end function
|
|
||||||
|
|
||||||
private function Connect(url as string) as boolean
|
|
||||||
' A redirect or reconnect reuses Connect; close the previous socket so it doesn't leak.
|
|
||||||
if m.socket <> invalid
|
|
||||||
m.socket.NotifyReadable(false)
|
|
||||||
m.socket.Close()
|
|
||||||
m.socket = invalid
|
|
||||||
end if
|
|
||||||
|
|
||||||
m.url = url
|
|
||||||
m.statusCode = 0
|
m.statusCode = 0
|
||||||
m.closeReason = ""
|
m.closeReason = invalid
|
||||||
|
m.polledCommandIndex = m.ackedCommandIndex
|
||||||
urlObject = UrlUtils.ParseUrl(url)
|
m.pending = request.QueryParam("AID", m.ackedCommandIndex).NoCache().RetryCount(0).AttemptTimeoutMs(m.pollTimeoutMs).SendOn(messagePort)
|
||||||
if urlObject.protocol <> "http"
|
|
||||||
m.closeReason = "invalid_protocol"
|
|
||||||
LogError("Lounge backchannel needs http, got:", urlObject.protocol)
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
portValue = urlObject.port
|
|
||||||
if portValue = invalid or portValue = ""
|
|
||||||
portValue = "80"
|
|
||||||
end if
|
|
||||||
|
|
||||||
address = CreateObject("roSocketAddress")
|
|
||||||
address.SetAddress(urlObject.host + ":" + portValue)
|
|
||||||
|
|
||||||
socket = CreateObject("roStreamSocket")
|
|
||||||
socket.SetSendToAddress(address)
|
|
||||||
if not socket.Connect()
|
|
||||||
m.closeReason = "connect_failed"
|
|
||||||
LogWarnNoTelemetry("Lounge backchannel connect failed:", urlObject.host)
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
CRLF = Chr(13) + Chr(10)
|
|
||||||
request = "GET " + urlObject.path + " HTTP/1.1" + CRLF
|
|
||||||
request += "Host: " + urlObject.host + CRLF
|
|
||||||
request += "Connection: keep-alive" + CRLF
|
|
||||||
request += CRLF
|
|
||||||
socket.SendStr(request)
|
|
||||||
|
|
||||||
socket.NotifyReadable(true)
|
|
||||||
socket.SetMessagePort(m.messagePort)
|
|
||||||
|
|
||||||
m.socket = socket
|
|
||||||
m.decoder = new HttpChunkedDecoder()
|
|
||||||
m.body = CreateObject("roByteArray")
|
|
||||||
m.bodyCursor = 0
|
|
||||||
m.timer.Mark()
|
|
||||||
|
|
||||||
LogInfo("Lounge backchannel open, socket", socket.GetID())
|
|
||||||
return true
|
|
||||||
end function
|
|
||||||
|
|
||||||
function IsOpen() as boolean
|
|
||||||
return m.socket <> invalid and m.closeReason = ""
|
|
||||||
end function
|
|
||||||
|
|
||||||
function Poll(socketEvents as object) as object
|
|
||||||
frames = []
|
|
||||||
if m.socket = invalid
|
|
||||||
return frames
|
|
||||||
end if
|
|
||||||
|
|
||||||
if not m.socket.IsConnected()
|
|
||||||
m.CloseWith("disconnected")
|
|
||||||
return frames
|
|
||||||
end if
|
|
||||||
|
|
||||||
if m.timer.TotalMilliseconds() > LOUNGE_BACKCHANNEL_TIMEOUT_MS
|
|
||||||
m.CloseWith("timeout")
|
|
||||||
return frames
|
|
||||||
end if
|
|
||||||
|
|
||||||
if not m.HasReadableEvent(socketEvents)
|
|
||||||
return frames
|
|
||||||
end if
|
|
||||||
|
|
||||||
received = m.decoder.Pump(m.socket, m.body)
|
|
||||||
if received = 0
|
|
||||||
m.CloseWith("eof")
|
|
||||||
return frames
|
|
||||||
else if received < 0
|
|
||||||
if not m.socket.eOK()
|
|
||||||
m.CloseWith("receive_error")
|
|
||||||
end if
|
|
||||||
return frames
|
|
||||||
end if
|
|
||||||
|
|
||||||
m.timer.Mark()
|
|
||||||
|
|
||||||
if m.decoder.IsRedirect()
|
|
||||||
return m.FollowRedirect()
|
|
||||||
end if
|
|
||||||
|
|
||||||
result = LoungeFraming.Extract(m.body, m.bodyCursor)
|
|
||||||
m.bodyCursor = result.nextPos
|
|
||||||
for each frame in result.frames
|
|
||||||
frames.Push(frame)
|
|
||||||
end for
|
|
||||||
m.CompactBody()
|
|
||||||
|
|
||||||
if m.decoder.IsError()
|
|
||||||
m.statusCode = m.decoder.statusCode
|
|
||||||
if m.decoder.errorReason <> HttpDecoderError.None
|
|
||||||
m.CloseWith(m.decoder.errorReason)
|
|
||||||
else
|
|
||||||
m.CloseWith("http_" + StrI(m.statusCode).Trim())
|
|
||||||
end if
|
|
||||||
else if m.decoder.IsDone()
|
|
||||||
m.CloseWith("complete")
|
|
||||||
end if
|
|
||||||
|
|
||||||
return frames
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function Close() as void
|
function Close() as void
|
||||||
m.CloseWith("closed")
|
if m.pending <> invalid
|
||||||
end function
|
m.pending.Cancel()
|
||||||
|
m.pending = invalid
|
||||||
private function HasReadableEvent(socketEvents as object) as boolean
|
|
||||||
id = m.socket.GetID()
|
|
||||||
for each event in socketEvents
|
|
||||||
if event.GetSocketID() = id
|
|
||||||
return true
|
|
||||||
end if
|
|
||||||
end for
|
|
||||||
return false
|
|
||||||
end function
|
|
||||||
|
|
||||||
private function CloseWith(reason as string) as void
|
|
||||||
if m.socket <> invalid
|
|
||||||
m.socket.NotifyReadable(false)
|
|
||||||
m.socket.Close()
|
|
||||||
m.socket = invalid
|
|
||||||
end if
|
|
||||||
if m.closeReason = ""
|
|
||||||
m.closeReason = reason
|
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
private function CompactBody() as void
|
function IsPolling() as boolean
|
||||||
if m.bodyCursor = 0
|
return m.pending <> invalid
|
||||||
return
|
end function
|
||||||
|
|
||||||
|
function MaxWaitMs() as integer
|
||||||
|
if m.pending = invalid
|
||||||
|
return 0
|
||||||
end if
|
end if
|
||||||
if m.bodyCursor >= m.body.Count()
|
return m.pending.MaxWaitMs()
|
||||||
m.body.Clear()
|
end function
|
||||||
else if m.bodyCursor >= LOUNGE_BACKCHANNEL_BODY_COMPACT
|
|
||||||
m.body = LoungeBytes.Tail(m.body, m.bodyCursor)
|
function Handle(message as dynamic) as LoungeCommand[]
|
||||||
|
if m.pending = invalid
|
||||||
|
return []
|
||||||
|
end if
|
||||||
|
response = m.pending.Handle(message)
|
||||||
|
if response = invalid
|
||||||
|
return []
|
||||||
|
end if
|
||||||
|
m.pending = invalid
|
||||||
|
m.statusCode = response.StatusCode()
|
||||||
|
|
||||||
|
if response.IsTimedOut()
|
||||||
|
m.closeReason = LoungeCloseReason.Timeout
|
||||||
|
return []
|
||||||
|
end if
|
||||||
|
if m.statusCode = 0
|
||||||
|
m.closeReason = LoungeCloseReason.NotSent
|
||||||
|
return []
|
||||||
|
end if
|
||||||
|
if m.statusCode < 200 or m.statusCode >= 300
|
||||||
|
m.closeReason = LoungeCloseReason.Http
|
||||||
|
return []
|
||||||
|
end if
|
||||||
|
|
||||||
|
frames = m.ExtractFrames(response.Text())
|
||||||
|
if frames.Count() = 0
|
||||||
|
m.closeReason = LoungeCloseReason.Empty
|
||||||
|
return []
|
||||||
|
end if
|
||||||
|
commands = m.Receive(frames)
|
||||||
|
' Nothing acknowledged: the next poll is answered with the same frames.
|
||||||
|
if m.ackedCommandIndex = m.polledCommandIndex
|
||||||
|
m.closeReason = LoungeCloseReason.Stalled
|
||||||
|
m.stalledPolls += 1
|
||||||
else
|
else
|
||||||
return
|
m.closeReason = LoungeCloseReason.Complete
|
||||||
|
m.stalledPolls = 0
|
||||||
end if
|
end if
|
||||||
m.bodyCursor = 0
|
return commands
|
||||||
end function
|
end function
|
||||||
|
|
||||||
private function FollowRedirect() as object
|
' Frame = `<byteLength>\n<json>`, the length counted in BYTES. The answer is complete, so a malformed or cut-off
|
||||||
|
' frame ends the extraction: no later read can complete it.
|
||||||
|
private function ExtractFrames(text as string) as object
|
||||||
|
body = CreateObject("roByteArray")
|
||||||
|
body.FromAsciiString(text)
|
||||||
frames = []
|
frames = []
|
||||||
|
count = body.Count()
|
||||||
location = m.decoder.Location()
|
cursor = 0
|
||||||
if not IsString(location) or location = ""
|
while cursor < count
|
||||||
m.CloseWith("redirect_no_location")
|
if body[cursor] = 10 or body[cursor] = 13
|
||||||
return frames
|
cursor += 1
|
||||||
end if
|
continue while
|
||||||
|
end if
|
||||||
nextUrl = LoungeRedirect.Resolve(m.url, location)
|
frameStart = cursor
|
||||||
m.redirectTarget = nextUrl
|
frameLength = 0
|
||||||
|
' Stops once the length exceeds the body: a frame that long can't be whole, and the integer can't overflow.
|
||||||
m.redirectCount += 1
|
while cursor < count and body[cursor] >= 48 and body[cursor] <= 57 and frameLength <= count
|
||||||
if m.redirectCount > LOUNGE_BACKCHANNEL_MAX_REDIRECTS
|
frameLength = frameLength * 10 + body[cursor] - 48
|
||||||
m.CloseWith("redirect_limit")
|
cursor += 1
|
||||||
return frames
|
end while
|
||||||
end if
|
if cursor < count and body[cursor] = 13
|
||||||
|
cursor += 1
|
||||||
LogInfo("Lounge backchannel following redirect to", m.redirectTarget)
|
end if
|
||||||
m.Connect(nextUrl)
|
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
|
return frames
|
||||||
end function
|
end function
|
||||||
|
|
||||||
end class
|
private function Receive(frames as object) as LoungeCommand[]
|
||||||
|
commands = []
|
||||||
namespace LoungeRedirect
|
for each frame in frames
|
||||||
|
entries = StringUtils.ParseJsonSafe(frame)
|
||||||
' Force the target to plain HTTP - a raw socket has no TLS, so an https redirect is followed over http.
|
if not IsArray(entries)
|
||||||
function Resolve(currentUrl as string, location as string) as string
|
LogTelemetryEvent({
|
||||||
if location.StartsWith("http://") or location.StartsWith("https://")
|
level: "error"
|
||||||
parts = UrlUtils.ParseUrl(location)
|
message: "Lounge frame did not parse to a command array: " + frame.Left(256)
|
||||||
else
|
fingerprint: "lounge-unparseable-frame"
|
||||||
parts = UrlUtils.ParseUrl(currentUrl)
|
})
|
||||||
if not location.StartsWith("/")
|
continue for
|
||||||
location = "/" + location
|
|
||||||
end if
|
end if
|
||||||
parts.path = location
|
|
||||||
end if
|
|
||||||
|
|
||||||
parts.protocol = "http"
|
for each entry in entries
|
||||||
if parts.port = "80" or parts.port = "443"
|
if not IsArray(entry) or entry.Count() = 0 or not IsInt(entry[0])
|
||||||
parts.port = invalid
|
m.LogMalformedCommand(entry)
|
||||||
end if
|
continue for
|
||||||
return UrlUtils.BuildUrlFromParts(parts)
|
end if
|
||||||
|
index = entry[0]
|
||||||
|
if index <= m.ackedCommandIndex
|
||||||
|
LogDebug("Skipping command already received:", entry)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
' Acknowledged before validation: the server answers an unacknowledged command again, at once.
|
||||||
|
m.ackedCommandIndex = index
|
||||||
|
|
||||||
|
data = entry[1]
|
||||||
|
if not IsArray(data) or data.Count() = 0 or not IsString(data[0])
|
||||||
|
m.LogMalformedCommand(entry)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
commands.Push({ index: index, type: data[0], args: data[1] })
|
||||||
|
end for
|
||||||
|
end for
|
||||||
|
return commands
|
||||||
end function
|
end function
|
||||||
|
|
||||||
end namespace
|
private function LogMalformedCommand(entry as dynamic) as void
|
||||||
|
LogTelemetryEvent({
|
||||||
|
level: "error"
|
||||||
|
message: "Malformed lounge command: " + FormatJson(entry).Left(256)
|
||||||
|
fingerprint: "lounge-malformed-command"
|
||||||
|
})
|
||||||
|
end function
|
||||||
|
|
||||||
|
end class
|
||||||
@@ -1,33 +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 IndexOfCrlf(bytes as object, fromIndex as integer) as integer
|
|
||||||
last = bytes.Count() - 2
|
|
||||||
for i = fromIndex to last
|
|
||||||
if bytes[i] = 13 and bytes[i + 1] = 10
|
|
||||||
return i
|
|
||||||
end if
|
|
||||||
end for
|
|
||||||
return -1
|
|
||||||
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
|
|
||||||
|
|
||||||
function Tail(bytes as object, fromIndex as integer) as object
|
|
||||||
return ByteArrayUtils.Slice(bytes, fromIndex)
|
|
||||||
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
|
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||||
import "pkg:/components/Services/LoungeService/LoungeApi.bs"
|
import "pkg:/components/Services/LoungeService/LoungeApi.bs"
|
||||||
|
import "pkg:/components/Services/LoungeService/LoungeService.types.bs"
|
||||||
const IDLE_WAIT_MS = 60000
|
import "pkg:/components/Services/LoungeService/LoungeSession.bs"
|
||||||
const SENDS_IN_FLIGHT_WAIT_MS = 500
|
|
||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
m.top.functionName = "LoungeServiceLoop"
|
m.top.functionName = "LoungeServiceLoop"
|
||||||
@@ -21,6 +20,7 @@ function StartService(_unused as dynamic) as boolean
|
|||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
m.top.isRunning = true
|
||||||
m.top.control = "run"
|
m.top.control = "run"
|
||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
@@ -34,65 +34,83 @@ function StopService(_unused as dynamic) as void
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function LoungeServiceLoop() as void
|
function LoungeServiceLoop() as void
|
||||||
api = new LoungeApi(m.top, m.top.videoQueue, m.top.notifications, m.top.invidious)
|
messagePort = CreateObject("roMessagePort")
|
||||||
|
m.top.observeField("shouldQuit", messagePort)
|
||||||
|
api = new LoungeApi(m.top, m.top.videoQueue, m.top.notifications, m.top.invidious, messagePort)
|
||||||
' Mobile app can remain connected to devices even after restarts.
|
' Mobile app can remain connected to devices even after restarts.
|
||||||
' Since we create a new lounge every time, we signal to the last lounge
|
' Since we create a new lounge every time, we signal to the last lounge
|
||||||
' that we're no longer there, and we're not coming back.
|
' that we're no longer there, and we're not coming back.
|
||||||
api.DisconnectFromLastLounge()
|
api.DisconnectFromLastLounge()
|
||||||
|
|
||||||
messagePort = CreateObject("roMessagePort")
|
|
||||||
|
|
||||||
' We do not join a lounge until something asks us to like
|
' We do not join a lounge until something asks us to like
|
||||||
' - A remote connects through DIAL
|
' - A remote connects through DIAL
|
||||||
' - Generating a TV link code
|
' - Generating a TV link code
|
||||||
|
' Both join only while loungeToken is empty: a session that ends clears it.
|
||||||
|
while WaitForJoin(messagePort)
|
||||||
|
quitRequested = RunSession(api, messagePort)
|
||||||
|
api.EndSession()
|
||||||
|
m.top.unobserveField("outgoingMessages")
|
||||||
|
m.top.loungeToken = ""
|
||||||
|
if quitRequested
|
||||||
|
exit while
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
|
||||||
|
LogInfo("Lounge service stopped")
|
||||||
|
m.top.unobserveField("shouldQuit")
|
||||||
|
m.top.isRunning = false
|
||||||
|
end function
|
||||||
|
|
||||||
|
function WaitForJoin(messagePort as object) as boolean
|
||||||
m.top.observeField("join", messagePort)
|
m.top.observeField("join", messagePort)
|
||||||
wait(0, messagePort)
|
joinRequested = false
|
||||||
|
while true
|
||||||
|
message = wait(0, messagePort)
|
||||||
|
if IsQuitRequested([message])
|
||||||
|
exit while
|
||||||
|
end if
|
||||||
|
if type(message) = "roSGNodeEvent" and message.GetField() = "join"
|
||||||
|
joinRequested = true
|
||||||
|
exit while
|
||||||
|
end if
|
||||||
|
end while
|
||||||
m.top.unobserveField("join")
|
m.top.unobserveField("join")
|
||||||
|
return joinRequested
|
||||||
|
end function
|
||||||
|
|
||||||
|
function RunSession(api as LoungeApi, messagePort as object) as boolean
|
||||||
screenId = api.GetScreenId()
|
screenId = api.GetScreenId()
|
||||||
if StringUtils.IsNullOrEmpty(screenId)
|
if StringUtils.IsNullOrEmpty(screenId)
|
||||||
Shutdown("No screen ID found")
|
LogInfo("Lounge session ended: no screen ID")
|
||||||
return
|
return false
|
||||||
end if
|
end if
|
||||||
m.top.screenId = screenId
|
m.top.screenId = screenId
|
||||||
|
|
||||||
loungeToken = api.GetToken()
|
loungeToken = api.GetToken()
|
||||||
if StringUtils.IsNullOrEmpty(loungeToken)
|
if StringUtils.IsNullOrEmpty(loungeToken)
|
||||||
Shutdown("No lounge token found")
|
LogInfo("Lounge session ended: no lounge token")
|
||||||
return
|
return false
|
||||||
end if
|
end if
|
||||||
m.top.loungeToken = loungeToken
|
m.top.loungeToken = loungeToken
|
||||||
|
|
||||||
m.top.observeField("outgoingMessages", messagePort)
|
m.top.observeField("outgoingMessages", messagePort)
|
||||||
|
|
||||||
if not api.Bind()
|
if not api.Bind()
|
||||||
Shutdown("Failed to bind")
|
LogInfo("Lounge session ended: bind failed")
|
||||||
return
|
return false
|
||||||
end if
|
end if
|
||||||
|
|
||||||
api.FetchCommandsRpc(messagePort)
|
api.StartPoll()
|
||||||
|
|
||||||
m.top.shouldQuit = false
|
backchannel = api.backchannel
|
||||||
isOpen = false
|
|
||||||
reconnectAttempts = 0
|
reconnectAttempts = 0
|
||||||
|
sinceDelivered = CreateObject("roTimespan")
|
||||||
outgoingLoungeMessages = []
|
outgoingLoungeMessages = []
|
||||||
portMessages = []
|
portMessages = []
|
||||||
socketMessages = []
|
|
||||||
|
|
||||||
while true
|
while true
|
||||||
if m.top.shouldQuit = true
|
|
||||||
exit while
|
|
||||||
end if
|
|
||||||
|
|
||||||
' Sends answer on ports of their own, read only when the loop wakes.
|
|
||||||
waitMs = IDLE_WAIT_MS
|
|
||||||
if api.HasPendingOutgoingMessages()
|
|
||||||
waitMs = SENDS_IN_FLIGHT_WAIT_MS
|
|
||||||
end if
|
|
||||||
message = wait(waitMs, messagePort)
|
|
||||||
portMessages.Clear()
|
portMessages.Clear()
|
||||||
portMessages.Push(message)
|
portMessages.Push(wait(api.MaxWaitMs(), messagePort))
|
||||||
|
|
||||||
' There's a chance messages were piling up while we were sending messages to the lounge
|
' There's a chance messages were piling up while we were sending messages to the lounge
|
||||||
' This could happen if we were sending things to the lounge and the player state
|
' This could happen if we were sending things to the lounge and the player state
|
||||||
@@ -100,75 +118,80 @@ function LoungeServiceLoop() as void
|
|||||||
while messagePort.PeekMessage() <> invalid
|
while messagePort.PeekMessage() <> invalid
|
||||||
portMessages.Push(messagePort.GetMessage())
|
portMessages.Push(messagePort.GetMessage())
|
||||||
end while
|
end while
|
||||||
|
if IsQuitRequested(portMessages)
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
' At this point:
|
' At this point:
|
||||||
' - We check if we need to send messages to the lounge based on player state
|
' - We check if we need to send messages to the lounge based on player state
|
||||||
' - We check the lounge for new commands, which might need responding to
|
' - We check the lounge for new commands, which might need responding to
|
||||||
' - Finally, we send the outgoing messages to the lounge in one go
|
' - Finally, we send the outgoing messages to the lounge in one go
|
||||||
outgoingLoungeMessages.Clear()
|
outgoingLoungeMessages.Clear()
|
||||||
socketMessages.Clear()
|
|
||||||
|
|
||||||
for each portMessage in portMessages
|
for each portMessage in portMessages
|
||||||
messageType = type(portMessage)
|
if type(portMessage) = "roSGNodeEvent" and portMessage.GetField() = "outgoingMessages"
|
||||||
if messageType = "roSocketEvent"
|
outgoingLoungeMessages.Append(portMessage.GetData())
|
||||||
socketMessages.Push(portMessage)
|
|
||||||
else if messageType = "roSGNodeEvent"
|
|
||||||
field = portMessage.GetField()
|
|
||||||
if field = "outgoingMessages"
|
|
||||||
messages = portMessage.GetData()
|
|
||||||
outgoingLoungeMessages.Append(messages)
|
|
||||||
end if
|
|
||||||
end if
|
end if
|
||||||
|
api.HandleMessage(portMessage, outgoingLoungeMessages)
|
||||||
end for
|
end for
|
||||||
|
|
||||||
isOpen = api.Poll(socketMessages, outgoingLoungeMessages)
|
|
||||||
|
|
||||||
api.SendMessages(outgoingLoungeMessages)
|
api.SendMessages(outgoingLoungeMessages)
|
||||||
api.ProcessPendingOutgoingMessages()
|
|
||||||
|
|
||||||
' A send's failure is acted on once the backchannel closes, which a dead session's does too.
|
if backchannel.IsPolling()
|
||||||
if not isOpen
|
continue while
|
||||||
closeInfo = api.GetCloseInfo()
|
|
||||||
needsRebind = closeInfo.statusCode = 410 or closeInfo.statusCode = 400 or api.sessionGone
|
|
||||||
needsTokenRefresh = closeInfo.statusCode = 401 or api.tokenExpired
|
|
||||||
|
|
||||||
LogDebug("Backchannel closed:", closeInfo.reason)
|
|
||||||
if IsActionableCloseFailure(closeInfo.reason, needsRebind, needsTokenRefresh)
|
|
||||||
message = "Lounge backchannel failure: " + closeInfo.reason
|
|
||||||
if not StringUtils.IsNullOrEmpty(closeInfo.target)
|
|
||||||
message += " -> " + closeInfo.target
|
|
||||||
end if
|
|
||||||
LogTelemetryEvent({
|
|
||||||
level: "warning"
|
|
||||||
message: message
|
|
||||||
fingerprint: "lounge-backchannel-" + closeInfo.reason
|
|
||||||
})
|
|
||||||
end if
|
|
||||||
|
|
||||||
sleep(ComputeReconnectBackoffMs(reconnectAttempts))
|
|
||||||
reconnectAttempts += 1
|
|
||||||
|
|
||||||
if needsRebind or needsTokenRefresh
|
|
||||||
if not api.Rebind(needsTokenRefresh)
|
|
||||||
Shutdown("Failed to rebind")
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
m.top.loungeToken = api.loungeToken
|
|
||||||
end if
|
|
||||||
|
|
||||||
api.FetchCommandsRpc(messagePort)
|
|
||||||
else
|
|
||||||
reconnectAttempts = 0
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
if backchannel.closeReason = LoungeCloseReason.Complete
|
||||||
|
sinceDelivered.Mark()
|
||||||
|
end if
|
||||||
|
' A send's failure is acted on once the poll ends, which a dead session's does too.
|
||||||
|
nextStep = LoungeSession.StepAfterPoll(backchannel.closeReason, backchannel.statusCode, backchannel.stalledPolls, api.sessionGone, api.tokenExpired, sinceDelivered.TotalMilliseconds())
|
||||||
|
if nextStep = LoungeSessionStep.Poll
|
||||||
|
reconnectAttempts = 0
|
||||||
|
api.StartPoll()
|
||||||
|
continue while
|
||||||
|
end if
|
||||||
|
|
||||||
|
LogDebug("Backchannel closed:", backchannel.closeReason, backchannel.statusCode, "next:", nextStep)
|
||||||
|
if nextStep = LoungeSessionStep.Drop
|
||||||
|
LogTelemetryEvent({
|
||||||
|
level: "error"
|
||||||
|
message: `Lounge session dropped: no poll delivered for ${sinceDelivered.TotalSeconds()} s, last close: ${backchannel.closeReason} ${backchannel.statusCode}`
|
||||||
|
fingerprint: ["lounge-session-dropped", backchannel.closeReason, backchannel.statusCode]
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
if nextStep = LoungeSessionStep.Retry and backchannel.closeReason <> LoungeCloseReason.Timeout
|
||||||
|
LogTelemetryEvent({
|
||||||
|
level: "warning"
|
||||||
|
message: `Lounge backchannel failure: ${backchannel.closeReason} ${backchannel.statusCode}`
|
||||||
|
fingerprint: ["lounge-backchannel", backchannel.closeReason, backchannel.statusCode]
|
||||||
|
})
|
||||||
|
end if
|
||||||
|
|
||||||
|
sleep(ComputeReconnectBackoffMs(reconnectAttempts))
|
||||||
|
reconnectAttempts += 1
|
||||||
|
|
||||||
|
if nextStep <> LoungeSessionStep.Retry
|
||||||
|
if not api.Rebind(nextStep = LoungeSessionStep.RebindWithNewToken)
|
||||||
|
LogInfo("Lounge session ended: rebind failed")
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
m.top.loungeToken = api.loungeToken
|
||||||
|
end if
|
||||||
|
|
||||||
|
api.StartPoll()
|
||||||
end while
|
end while
|
||||||
|
|
||||||
Shutdown("Service stopped")
|
return false
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function Shutdown(reason as string)
|
function IsQuitRequested(portMessages as object) as boolean
|
||||||
LogInfo("Shutting down:", reason)
|
for each portMessage in portMessages
|
||||||
m.top.unobserveField("outgoingMessages")
|
if type(portMessage) = "roSGNodeEvent" and portMessage.GetField() = "shouldQuit" and portMessage.GetData() = true
|
||||||
m.top.isRunning = false
|
return true
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
return false
|
||||||
end function
|
end function
|
||||||
|
|
||||||
' Full jitter (random in [0, window)) avoids a fleet-wide thundering-herd reconnect.
|
' Full jitter (random in [0, window)) avoids a fleet-wide thundering-herd reconnect.
|
||||||
@@ -183,13 +206,3 @@ function ComputeReconnectBackoffMs(attempts as integer) as integer
|
|||||||
end if
|
end if
|
||||||
return 500 + Int(Rnd(0) * windowMs)
|
return 500 + Int(Rnd(0) * windowMs)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function IsActionableCloseFailure(reason as string, needsRebind as boolean, needsTokenRefresh as boolean) as boolean
|
|
||||||
if needsRebind or needsTokenRefresh
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
if reason = "complete" or reason = "eof" or reason = "closed" or reason = "timeout" or reason = "disconnected" or reason = ""
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
return true
|
|
||||||
end function
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
enum LoungeCloseReason
|
||||||
|
Complete = "complete"
|
||||||
|
Empty = "empty"
|
||||||
|
Stalled = "stalled"
|
||||||
|
Timeout = "timeout"
|
||||||
|
NotSent = "not_sent"
|
||||||
|
Http = "http"
|
||||||
|
end enum
|
||||||
|
|
||||||
|
enum LoungeSessionStep
|
||||||
|
Poll = "poll"
|
||||||
|
Retry = "retry"
|
||||||
|
Rebind = "rebind"
|
||||||
|
RebindWithNewToken = "rebind_with_new_token"
|
||||||
|
Drop = "drop"
|
||||||
|
end enum
|
||||||
|
|
||||||
|
interface LoungeCommand
|
||||||
|
index as integer
|
||||||
|
type as string
|
||||||
|
args as dynamic
|
||||||
|
end interface
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import "pkg:/components/Services/LoungeService/LoungeService.types.bs"
|
||||||
|
|
||||||
|
namespace LoungeSession
|
||||||
|
|
||||||
|
const GIVE_UP_MS = 300000
|
||||||
|
|
||||||
|
function StepAfterPoll(closeReason as LoungeCloseReason, statusCode as integer, stalledPolls as integer, sessionGone as boolean, tokenExpired as boolean, msSinceDelivered as integer) as LoungeSessionStep
|
||||||
|
' A new session doesn't answer the frames a stalled one keeps answering.
|
||||||
|
needsRebind = statusCode = 400 or statusCode = 410 or sessionGone or stalledPolls > 1
|
||||||
|
needsNewToken = statusCode = 401 or tokenExpired
|
||||||
|
if closeReason = LoungeCloseReason.Complete and not needsRebind and not needsNewToken
|
||||||
|
return LoungeSessionStep.Poll
|
||||||
|
end if
|
||||||
|
if msSinceDelivered >= LoungeSession.GIVE_UP_MS
|
||||||
|
return LoungeSessionStep.Drop
|
||||||
|
end if
|
||||||
|
if needsNewToken
|
||||||
|
return LoungeSessionStep.RebindWithNewToken
|
||||||
|
end if
|
||||||
|
if needsRebind
|
||||||
|
return LoungeSessionStep.Rebind
|
||||||
|
end if
|
||||||
|
return LoungeSessionStep.Retry
|
||||||
|
end function
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -0,0 +1,744 @@
|
|||||||
|
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": []
|
||||||
|
"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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
|
namespace VideoLoadHandoff
|
||||||
|
|
||||||
|
function Read(path as string, videoLoadId as string) as dynamic
|
||||||
|
handoff = StringUtils.ParseJsonSafe(ReadAsciiFile(path))
|
||||||
|
if not IsAssociativeArray(handoff) or handoff["video_load_id"] <> videoLoadId
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
return handoff["value"]
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Write(path as string, videoLoadId as string, value as dynamic) as void
|
||||||
|
WriteAsciiFile(path, FormatJson({ "video_load_id": videoLoadId, "value": value }))
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ReadAndDelete(path as string, videoLoadId as string) as dynamic
|
||||||
|
value = VideoLoadHandoff.Read(path, videoLoadId)
|
||||||
|
if value <> invalid
|
||||||
|
DeleteFile(path)
|
||||||
|
end if
|
||||||
|
return value
|
||||||
|
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
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ function ExecuteJob() as void
|
|||||||
if isDrm
|
if isDrm
|
||||||
licenseServerURL = UrlUtils.BuildUrl(`http://127.0.0.1:${playletServerPort}/api/innertube/get_drm_license`, invalid, {
|
licenseServerURL = UrlUtils.BuildUrl(`http://127.0.0.1:${playletServerPort}/api/innertube/get_drm_license`, invalid, {
|
||||||
videoId: metadata.videoId
|
videoId: metadata.videoId
|
||||||
|
videoLoadId: videoLoadId
|
||||||
drmParams: metadata.drmParams
|
drmParams: metadata.drmParams
|
||||||
drmSessionId: metadata.drmSessionId
|
drmSessionId: metadata.drmSessionId
|
||||||
cpn: metadata.cpn
|
cpn: metadata.cpn
|
||||||
@@ -263,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>
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
import "pkg:/components/Services/Dash/LiveHeadCounts.bs"
|
import "pkg:/components/Services/Dash/LiveLoadCounts.bs"
|
||||||
|
import "pkg:/components/Services/Innertube/DrmLicenseRequests.bs"
|
||||||
|
import "pkg:/components/Telemetry/VideoLoadHandoff.bs"
|
||||||
import "pkg:/components/VideoPlayerDev/VideoNode.bs"
|
import "pkg:/components/VideoPlayerDev/VideoNode.bs"
|
||||||
import "pkg:/source/utils/ErrorUtils.bs"
|
import "pkg:/source/utils/ErrorUtils.bs"
|
||||||
import "pkg:/source/utils/Locale.bs"
|
import "pkg:/source/utils/Locale.bs"
|
||||||
@@ -231,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"
|
||||||
@@ -345,11 +346,9 @@ namespace PlaybackTelemetry
|
|||||||
"tail_resolve_samples": m.tailResolveSamples
|
"tail_resolve_samples": m.tailResolveSamples
|
||||||
}
|
}
|
||||||
if m.transport.isLive
|
if m.transport.isLive
|
||||||
liveHead = StringUtils.ParseJsonSafe(ReadAsciiFile(LIVE_HEAD_COUNTS_PATH))
|
liveLoadCounts = ValidAssociativeArray(VideoLoadHandoff.ReadAndDelete(LIVE_LOAD_COUNTS_PATH, summary["video_load_id"]))
|
||||||
if liveHead <> invalid and liveHead["video_load_id"] = summary["video_load_id"]
|
summary["live_head"] = liveLoadCounts["live_head"]
|
||||||
summary["live_head"] = liveHead["counts"]
|
summary["live_timeline"] = liveLoadCounts["live_timeline"]
|
||||||
DeleteFile(LIVE_HEAD_COUNTS_PATH)
|
|
||||||
end if
|
|
||||||
summary["start_segment_bitrate_bps"] = m.startSegmentBitrateBps
|
summary["start_segment_bitrate_bps"] = m.startSegmentBitrateBps
|
||||||
summary["start_measured_bitrate_bps"] = m.startMeasuredBitrateBps
|
summary["start_measured_bitrate_bps"] = m.startMeasuredBitrateBps
|
||||||
end if
|
end if
|
||||||
@@ -358,6 +357,14 @@ namespace PlaybackTelemetry
|
|||||||
summary["stream_source"] = content.playletStreamSource
|
summary["stream_source"] = content.playletStreamSource
|
||||||
summary["drm"] = not StringUtils.IsNullOrEmpty(ValidAssociativeArray(content.drmParams).keySystem)
|
summary["drm"] = not StringUtils.IsNullOrEmpty(ValidAssociativeArray(content.drmParams).keySystem)
|
||||||
summary["stream_url_index"] = content.playletStreamUrlIndex
|
summary["stream_url_index"] = content.playletStreamUrlIndex
|
||||||
|
if summary["drm"]
|
||||||
|
summary["drm_license_requests"] = VideoLoadHandoff.ReadAndDelete(DRM_LICENSE_REQUESTS_PATH, summary["video_load_id"])
|
||||||
|
summary["widevine_security_level"] = ValidAssociativeArray(CreateObject("roDeviceInfo").GetDrmInfoEx().Widevine).securityLevel
|
||||||
|
hdmiStatus = CreateObject("roHdmiStatus")
|
||||||
|
if hdmiStatus <> invalid
|
||||||
|
summary["hdcp_version"] = hdmiStatus.GetHdcpVersion()
|
||||||
|
end if
|
||||||
|
end if
|
||||||
end if
|
end if
|
||||||
LogTelemetryEvent({
|
LogTelemetryEvent({
|
||||||
level: "info"
|
level: "info"
|
||||||
|
|||||||
@@ -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">
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import "pkg:/components/VideoPlayerDev/VideoNode.bs"
|
|||||||
import "pkg:/components/VideoQueue/VideoQueueUtils.bs"
|
import "pkg:/components/VideoQueue/VideoQueueUtils.bs"
|
||||||
import "pkg:/source/utils/Locale.bs"
|
import "pkg:/source/utils/Locale.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/MathUtils.bs"
|
|
||||||
import "pkg:/source/utils/RemoteKeys.bs"
|
import "pkg:/source/utils/RemoteKeys.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"
|
||||||
@@ -41,6 +40,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({
|
||||||
@@ -55,7 +55,6 @@ function Initialize()
|
|||||||
m.watchTimeMarker = -1
|
m.watchTimeMarker = -1
|
||||||
m.reportWatchTime = false
|
m.reportWatchTime = false
|
||||||
m.onCloseCalled = false
|
m.onCloseCalled = false
|
||||||
m.seekToPercent = invalid
|
|
||||||
' a setSeek that arrived while the content loads (ms, -1 = none): the content-load seek goes there instead.
|
' a setSeek that arrived while the content loads (ms, -1 = none): the content-load seek goes there instead.
|
||||||
m.loadingSetSeekMs = -1
|
m.loadingSetSeekMs = -1
|
||||||
|
|
||||||
@@ -869,11 +868,12 @@ function OnVideoError() as void
|
|||||||
LogInfo("error retry -> next stream url=", decision.nextUrl)
|
LogInfo("error retry -> next stream url=", decision.nextUrl)
|
||||||
m.playbackTelemetry.ReportVideoError(errorData, errorInfo, failedUrl, failedUrlIndex, false)
|
m.playbackTelemetry.ReportVideoError(errorData, errorInfo, failedUrl, failedUrlIndex, false)
|
||||||
' the controller already advanced content.url/index; replay it from the initial position (live edge /
|
' the controller already advanced content.url/index; replay it from the initial position (live edge /
|
||||||
' timestamp / percent watched). Swallow the next finished edge.
|
' timestamp / percent watched), seeked before play so it is the start position. Swallow the next
|
||||||
|
' finished edge.
|
||||||
m.ignoreNextFinished = true
|
m.ignoreNextFinished = true
|
||||||
m.repauseAfterSeek = false ' the retry plays fresh; drop any pending re-pause
|
m.repauseAfterSeek = false ' the retry plays fresh; drop any pending re-pause
|
||||||
m.top.control = VideoControl.Play
|
|
||||||
SeekToInitialPosition(content)
|
SeekToInitialPosition(content)
|
||||||
|
m.top.control = VideoControl.Play
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -931,8 +931,6 @@ function OnDuration(event as object) as void
|
|||||||
PushLiveEdge()
|
PushLiveEdge()
|
||||||
end if
|
end if
|
||||||
ApplyTransport()
|
ApplyTransport()
|
||||||
' a percent-of-duration initial seek waits on a known duration.
|
|
||||||
SeekToPercentOfDuration()
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
' Current wall-clock epoch seconds, off the cached roDateTime.
|
' Current wall-clock epoch seconds, off the cached roDateTime.
|
||||||
@@ -1078,7 +1076,6 @@ function OnSetSeek(event as object) as void
|
|||||||
m.loadingSetSeekMs = seekMs
|
m.loadingSetSeekMs = seekMs
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
m.seekToPercent = invalid
|
|
||||||
wasTransport = (m.transport.transportMode <> TransportController.Mode.Idle)
|
wasTransport = (m.transport.transportMode <> TransportController.Mode.Idle)
|
||||||
m.transport.ForceIdleSeek(seekMs, not wasTransport)
|
m.transport.ForceIdleSeek(seekMs, not wasTransport)
|
||||||
ApplyTransport()
|
ApplyTransport()
|
||||||
@@ -1227,8 +1224,8 @@ function OnVideoContentJobDone(event as object) as void
|
|||||||
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
|
||||||
@@ -1302,31 +1299,22 @@ function SeekToInitialPosition(content as object) as void
|
|||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
percentDurationWatched = ValidFloat(content.percentDurationWatched)
|
percentDurationWatched = ValidFloat(content.percentDurationWatched)
|
||||||
if percentDurationWatched > 0
|
if percentDurationWatched <= 0
|
||||||
m.seekToPercent = percentDurationWatched
|
|
||||||
SeekToPercentOfDuration()
|
|
||||||
end if
|
|
||||||
end function
|
|
||||||
|
|
||||||
function SeekToPercentOfDuration() as void
|
|
||||||
seekToPercent = m.seekToPercent
|
|
||||||
if seekToPercent = invalid
|
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
duration = m.top.duration
|
' the metadata's length, not the Video's duration (known only once playing): a seek into a started DRM play
|
||||||
if duration = 0
|
' errors on some Roku TVs.
|
||||||
return ' OnDuration re-calls this when duration arrives
|
lengthSeconds = ValidInt(ValidAssociativeArray(content.metadata).lengthSeconds)
|
||||||
end if
|
if lengthSeconds <= 0
|
||||||
if duration < 30
|
LogWarn("no lengthSeconds to resume the percent watched from; starting from the beginning. videoId:", content.videoId)
|
||||||
m.seekToPercent = invalid
|
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
m.seekToPercent = invalid
|
if lengthSeconds < 30
|
||||||
seek = (MathUtils.Clamp(seekToPercent, 0, 100) / 100.0) * duration
|
return
|
||||||
if seek > 0
|
|
||||||
LogDebug("seeking to percent watched ->", seek)
|
|
||||||
ApplySeek(Int(seek * 1000))
|
|
||||||
end if
|
end if
|
||||||
|
seekMs = Int(percentDurationWatched / 100.0 * lengthSeconds * 1000)
|
||||||
|
LogDebug("seeking to percent watched ->", seekMs)
|
||||||
|
ApplySeek(seekMs)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function PlayAfterPreviousPlayerHasStopped() as void
|
function PlayAfterPreviousPlayerHasStopped() as void
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ function TestSetup() as void
|
|||||||
|
|
||||||
OnNodeReady()
|
OnNodeReady()
|
||||||
|
|
||||||
|
' after OnNodeReady (the loop above drops it per TestSetup, along with the coordinator's control observer).
|
||||||
|
m.top.seekAtPlay = -1
|
||||||
|
m.top.ObserveField("control", FuncName(OnTestControl))
|
||||||
|
|
||||||
' the children survive across tests too: clear what a previous test's transport or live content left.
|
' the children survive across tests too: clear what a previous test's transport or live content left.
|
||||||
m.transportTimer.control = "none"
|
m.transportTimer.control = "none"
|
||||||
m.trickPlayBar.isLive = false
|
m.trickPlayBar.isLive = false
|
||||||
@@ -98,6 +102,13 @@ function OnTestNudge() as void
|
|||||||
m.top.nudgeCount += 1
|
m.top.nudgeCount += 1
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
' a seek written before control=play is the play's start position; one written after is a seek into the started play.
|
||||||
|
function OnTestControl() as void
|
||||||
|
if m.top.control = VideoControl.Play
|
||||||
|
m.top.seekAtPlay = m.top.seek
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
function OnTestJobRequest(event as object) as void
|
function OnTestJobRequest(event as object) as void
|
||||||
if event.getData().jobName = Jobs.SponsorBlockSegmentViewedJob
|
if event.getData().jobName = Jobs.SponsorBlockSegmentViewedJob
|
||||||
m.top.sponsorViewedCount += 1
|
m.top.sponsorViewedCount += 1
|
||||||
@@ -144,6 +155,16 @@ function TestSeekToInitialPosition(content as object) as void
|
|||||||
SeekToInitialPosition(content)
|
SeekToInitialPosition(content)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
' TestErrorRetry — a stream error before the first frame, with a next stream url to retry: runs the REAL
|
||||||
|
' OnVideoError and returns the seek the device held when the retry wrote control=play.
|
||||||
|
function TestErrorRetry(content as object) as float
|
||||||
|
m.videoPlayedSuccessfully = false ' the seam spec's first-frame setup marked the stream played
|
||||||
|
m.top.content = content
|
||||||
|
m.top.errorInfo = { category: "http", source: "buffer:reader", ignored: false }
|
||||||
|
OnVideoError()
|
||||||
|
return m.top.seekAtPlay
|
||||||
|
end function
|
||||||
|
|
||||||
' TestSetContentLoading — a VideoContentJob in flight (or not), minus the job.
|
' TestSetContentLoading — a VideoContentJob in flight (or not), minus the job.
|
||||||
function TestSetContentLoading(loading as boolean) as void
|
function TestSetContentLoading(loading as boolean) as void
|
||||||
if loading
|
if loading
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<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" />
|
||||||
@@ -50,6 +51,8 @@
|
|||||||
<field id="nudgeCount" type="integer" />
|
<field id="nudgeCount" type="integer" />
|
||||||
<!-- test-only probe: how many SponsorBlock viewed-segment reports the coordinator queued. -->
|
<!-- test-only probe: how many SponsorBlock viewed-segment reports the coordinator queued. -->
|
||||||
<field id="sponsorViewedCount" type="integer" />
|
<field id="sponsorViewedCount" type="integer" />
|
||||||
|
<!-- test-only probe: the seek the device held when the coordinator last wrote control=play. -->
|
||||||
|
<field id="seekAtPlay" type="float" />
|
||||||
<!-- the Video-only method Initialize calls, plus the spec's drivers (callFunc reaches only interface funcs). -->
|
<!-- the Video-only method Initialize calls, plus the spec's drivers (callFunc reaches only interface funcs). -->
|
||||||
<function name="getHttpAgent" />
|
<function name="getHttpAgent" />
|
||||||
<function name="TestSetup" />
|
<function name="TestSetup" />
|
||||||
@@ -62,6 +65,7 @@
|
|||||||
<function name="TestSetLive" />
|
<function name="TestSetLive" />
|
||||||
<function name="TestSeedSponsorBlock" />
|
<function name="TestSeedSponsorBlock" />
|
||||||
<function name="TestSeekToInitialPosition" />
|
<function name="TestSeekToInitialPosition" />
|
||||||
|
<function name="TestErrorRetry" />
|
||||||
<function name="TestSetContentLoading" />
|
<function name="TestSetContentLoading" />
|
||||||
<function name="TestFireLiveBadgeHold" />
|
<function name="TestFireLiveBadgeHold" />
|
||||||
<function name="TestKillAutoHide" />
|
<function name="TestKillAutoHide" />
|
||||||
|
|||||||
@@ -312,17 +312,6 @@ namespace Tests
|
|||||||
m.assertEqual(Int(m.top.seek * 1000), 42000)
|
m.assertEqual(Int(m.top.seek * 1000), 42000)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@it("setSeek before the duration is known cancels the pending percent-watched seek")
|
|
||||||
function _()
|
|
||||||
m.ArmSeekState("first load")
|
|
||||||
content = CreateObject("roSGNode", "ContentNode")
|
|
||||||
content.AddFields({ percentDurationWatched: 50.0 })
|
|
||||||
m.top.callFunc("TestSeekToInitialPosition", content)
|
|
||||||
m.top.setSeek = 30.5
|
|
||||||
m.top.duration = 600.0
|
|
||||||
m.assertEqual(Int(m.top.seek * 1000), 30500, "the percent seek did not override the setSeek")
|
|
||||||
end function
|
|
||||||
|
|
||||||
@it("setSeek while the content loads becomes the content-load seek, over the resume timestamp")
|
@it("setSeek while the content loads becomes the content-load seek, over the resume timestamp")
|
||||||
function _()
|
function _()
|
||||||
m.top.callFunc("TestSetContentLoading", true)
|
m.top.callFunc("TestSetContentLoading", true)
|
||||||
@@ -357,16 +346,50 @@ namespace Tests
|
|||||||
m.assertEqual(Int(m.top.seek * 1000), 42000)
|
m.assertEqual(Int(m.top.seek * 1000), 42000)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@it("the content-load seek goes to the percent watched once the duration is known")
|
@it("the content-load seek goes to the percent watched of the video's length")
|
||||||
function _()
|
function _()
|
||||||
content = CreateObject("roSGNode", "ContentNode")
|
content = CreateObject("roSGNode", "ContentNode")
|
||||||
content.AddFields({ percentDurationWatched: 25.0 })
|
content.AddFields({ percentDurationWatched: 25.0, metadata: { lengthSeconds: 600 } })
|
||||||
m.top.callFunc("TestSeekToInitialPosition", content)
|
m.top.callFunc("TestSeekToInitialPosition", content)
|
||||||
m.assertEqual(m.top.seek, 0.0, "no seek before the duration is known")
|
|
||||||
m.top.duration = 600.0
|
|
||||||
m.assertEqual(Int(m.top.seek * 1000), 150000)
|
m.assertEqual(Int(m.top.seek * 1000), 150000)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
@it("the content-load seek skips the percent watched when the video's length is unknown")
|
||||||
|
function _()
|
||||||
|
for each metadata in [{}, { lengthSeconds: 0 }]
|
||||||
|
m.top.seek = -1
|
||||||
|
content = CreateObject("roSGNode", "ContentNode")
|
||||||
|
content.AddFields({ percentDurationWatched: 25.0, metadata: metadata })
|
||||||
|
m.top.callFunc("TestSeekToInitialPosition", content)
|
||||||
|
m.top.duration = 600.0
|
||||||
|
m.assertEqual(m.top.seek, -1.0, FormatJson(metadata))
|
||||||
|
end for
|
||||||
|
end function
|
||||||
|
|
||||||
|
@it("the content-load seek skips the percent watched on a video shorter than 30 seconds")
|
||||||
|
function _()
|
||||||
|
m.top.seek = -1
|
||||||
|
content = CreateObject("roSGNode", "ContentNode")
|
||||||
|
content.AddFields({ percentDurationWatched: 50.0, metadata: { lengthSeconds: 29 } })
|
||||||
|
m.top.callFunc("TestSeekToInitialPosition", content)
|
||||||
|
m.assertEqual(m.top.seek, -1.0)
|
||||||
|
end function
|
||||||
|
|
||||||
|
@it("an error retry seeks to the percent watched before it plays")
|
||||||
|
function _()
|
||||||
|
content = CreateObject("roSGNode", "ContentNode")
|
||||||
|
content.AddFields({
|
||||||
|
videoId: "vid1"
|
||||||
|
playletStreamUrls: ["http://a", "http://b"]
|
||||||
|
playletStreamUrlIndex: 0
|
||||||
|
percentDurationWatched: 25.0
|
||||||
|
metadata: { lengthSeconds: 600 }
|
||||||
|
})
|
||||||
|
content.url = "http://a"
|
||||||
|
m.assertEqual(m.top.callFunc("TestErrorRetry", content), 150.0)
|
||||||
|
m.assertEqual(content.url, "http://b", "retried the next stream url")
|
||||||
|
end function
|
||||||
|
|
||||||
@it("the error dialog displays every captured error field, not just the category")
|
@it("the error dialog displays every captured error field, not just the category")
|
||||||
function _()
|
function _()
|
||||||
' Real Roku Video error captured on device (an http stream failure, 502 manifest).
|
' Real Roku Video error captured on device (an http stream failure, 502 manifest).
|
||||||
@@ -1072,7 +1095,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", "seekToPercent", "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"]
|
||||||
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
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import "pkg:/components/Services/Dash/DashManifest.bs"
|
import "pkg:/components/Services/Dash/DashManifest.bs"
|
||||||
import "pkg:/components/Services/Dash/LiveHeadChecks.bs"
|
import "pkg:/components/Services/Dash/LiveHeadChecks.bs"
|
||||||
import "pkg:/components/Services/Dash/LiveHeadCounts.bs"
|
import "pkg:/components/Services/Dash/LiveLoadCounts.bs"
|
||||||
import "pkg:/components/Services/Dash/LiveTimeline.types.bs"
|
import "pkg:/components/Services/Dash/LiveTimeline.types.bs"
|
||||||
import "pkg:/components/Services/Innertube/LiveStreamInfo.bs"
|
import "pkg:/components/Services/Innertube/LiveStreamInfo.bs"
|
||||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||||
|
import "pkg:/components/Telemetry/VideoLoadHandoff.bs"
|
||||||
import "pkg:/components/Web/WebServer/Http/HttpRouter.bs"
|
import "pkg:/components/Web/WebServer/Http/HttpRouter.bs"
|
||||||
import "pkg:/source/services/HttpClient.bs"
|
import "pkg:/source/services/HttpClient.bs"
|
||||||
import "pkg:/source/utils/MathUtils.bs"
|
import "pkg:/source/utils/MathUtils.bs"
|
||||||
@@ -52,6 +53,7 @@ namespace Http
|
|||||||
m.liveLeadMs = 0
|
m.liveLeadMs = 0
|
||||||
m.liveDriftMs = 0
|
m.liveDriftMs = 0
|
||||||
m.liveLastCheckJumped = false
|
m.liveLastCheckJumped = false
|
||||||
|
m.liveTimelineCounts = invalid
|
||||||
m.reportedLiveCorrection = false
|
m.reportedLiveCorrection = false
|
||||||
m.liveManifestTemplate = ""
|
m.liveManifestTemplate = ""
|
||||||
m.liveManifestTemplateKey = invalid
|
m.liveManifestTemplateKey = invalid
|
||||||
@@ -250,13 +252,13 @@ namespace Http
|
|||||||
newest = head
|
newest = head
|
||||||
end if
|
end if
|
||||||
end for
|
end for
|
||||||
WriteAsciiFile(LIVE_HEAD_COUNTS_PATH, FormatJson({ "video_load_id": m.cachedVideoLoadId, "counts": m.liveHeadChecks.counts }))
|
|
||||||
|
|
||||||
' Listed segments can't be withdrawn: the head only moves forward.
|
' Listed segments can't be withdrawn: the head only moves forward.
|
||||||
if newest <> invalid and newest.seqnum > m.liveHeadSeqnum
|
if newest <> invalid and newest.seqnum > m.liveHeadSeqnum
|
||||||
m.AlignLiveTimeline(newest)
|
m.AlignLiveTimeline(newest)
|
||||||
m.liveHeadSeqnum = newest.seqnum
|
m.liveHeadSeqnum = newest.seqnum
|
||||||
end if
|
end if
|
||||||
|
VideoLoadHandoff.Write(LIVE_LOAD_COUNTS_PATH, ValidString(m.cachedVideoLoadId), { "live_head": m.liveHeadChecks.counts, "live_timeline": m.liveTimelineCounts })
|
||||||
end function
|
end function
|
||||||
|
|
||||||
' Segments are listed at the duration at load, the stream's lifetime average: off
|
' Segments are listed at the duration at load, the stream's lifetime average: off
|
||||||
@@ -272,11 +274,23 @@ namespace Http
|
|||||||
if head.timeMs = invalid or m.liveBaseTimeMs = invalid
|
if head.timeMs = invalid or m.liveBaseTimeMs = invalid
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
' The cadence since the base.
|
||||||
|
sinceBaseDurationMs = Cint((head.timeMs - m.liveBaseTimeMs) / (head.seqnum - m.liveBaseSeqnum))
|
||||||
|
if sinceBaseDurationMs <= 0
|
||||||
|
LogWarnNoTelemetry("Live head time went back:", head.timeMs, "ms at", head.seqnum, "after", m.liveBaseTimeMs, "ms at", m.liveBaseSeqnum)
|
||||||
|
return
|
||||||
|
end if
|
||||||
durationRuns = m.liveDurationRuns
|
durationRuns = m.liveDurationRuns
|
||||||
headEndMs = m.liveBaseEndMs + Cint(head.timeMs - m.liveBaseTimeMs)
|
headEndMs = m.liveBaseEndMs + Cint(head.timeMs - m.liveBaseTimeMs)
|
||||||
driftMs = m.dashManifest.LiveSegmentStartMs(durationRuns, head.seqnum + 1) - headEndMs - m.liveLeadMs
|
driftMs = m.dashManifest.LiveSegmentStartMs(durationRuns, head.seqnum + 1) - headEndMs - m.liveLeadMs
|
||||||
stepMs = driftMs - m.liveDriftMs
|
stepMs = driftMs - m.liveDriftMs
|
||||||
m.liveDriftMs = driftMs
|
m.liveDriftMs = driftMs
|
||||||
|
counts = m.liveTimelineCounts
|
||||||
|
counts["timed_checks"] += 1
|
||||||
|
counts["drift_ms_min"] = MathUtils.Min(counts["drift_ms_min"], driftMs)
|
||||||
|
counts["drift_ms_max"] = MathUtils.Max(counts["drift_ms_max"], driftMs)
|
||||||
|
counts["step_ms_min"] = MathUtils.Min(counts["step_ms_min"], stepMs)
|
||||||
|
counts["step_ms_max"] = MathUtils.Max(counts["step_ms_max"], stepMs)
|
||||||
lastCheckJumped = m.liveLastCheckJumped
|
lastCheckJumped = m.liveLastCheckJumped
|
||||||
m.liveLastCheckJumped = false
|
m.liveLastCheckJumped = false
|
||||||
listedDurationMs = durationRuns[durationRuns.Count() - 1].durationMs
|
listedDurationMs = durationRuns[durationRuns.Count() - 1].durationMs
|
||||||
@@ -288,14 +302,9 @@ namespace Http
|
|||||||
' large cadence error can leap too (a young stream between sparse checks): the
|
' large cadence error can leap too (a young stream between sparse checks): the
|
||||||
' next check measures it.
|
' next check measures it.
|
||||||
isStall = stepMs < -LIVE_STALL_JUMP_MS and not lastCheckJumped
|
isStall = stepMs < -LIVE_STALL_JUMP_MS and not lastCheckJumped
|
||||||
|
durationMs = sinceBaseDurationMs
|
||||||
if isStall
|
if isStall
|
||||||
durationMs = listedDurationMs
|
durationMs = listedDurationMs
|
||||||
else
|
|
||||||
durationMs = Cint((head.timeMs - m.liveBaseTimeMs) / (head.seqnum - m.liveBaseSeqnum))
|
|
||||||
if durationMs <= 0
|
|
||||||
LogWarnNoTelemetry("Live head time went back:", head.timeMs, "ms at", head.seqnum, "after", m.liveBaseTimeMs, "ms at", m.liveBaseSeqnum)
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
fromSeqnum = m.dashManifest.LiveLastListedSeqnum(durationRuns, m.liveHeadSeqnum) + 1
|
fromSeqnum = m.dashManifest.LiveLastListedSeqnum(durationRuns, m.liveHeadSeqnum) + 1
|
||||||
@@ -316,6 +325,11 @@ namespace Http
|
|||||||
durationRuns.Shift()
|
durationRuns.Shift()
|
||||||
end while
|
end while
|
||||||
durationRuns.Push({ fromSeqnum: fromSeqnum, startMs: startMs, durationMs: durationMs })
|
durationRuns.Push({ fromSeqnum: fromSeqnum, startMs: startMs, durationMs: durationMs })
|
||||||
|
counts["corrections"] += 1
|
||||||
|
if isStall
|
||||||
|
counts["stall_corrections"] += 1
|
||||||
|
end if
|
||||||
|
counts["duration_runs_max"] = MathUtils.Max(counts["duration_runs_max"], durationRuns.Count())
|
||||||
|
|
||||||
m.ReportLiveCorrection(head, durationMs, driftMs, stepMs, isStall)
|
m.ReportLiveCorrection(head, durationMs, driftMs, stepMs, isStall)
|
||||||
end function
|
end function
|
||||||
@@ -393,6 +407,16 @@ namespace Http
|
|||||||
m.liveLeadMs = 0
|
m.liveLeadMs = 0
|
||||||
m.liveDriftMs = 0
|
m.liveDriftMs = 0
|
||||||
m.liveLastCheckJumped = false
|
m.liveLastCheckJumped = false
|
||||||
|
m.liveTimelineCounts = {
|
||||||
|
"timed_checks": 0
|
||||||
|
"corrections": 0
|
||||||
|
"stall_corrections": 0
|
||||||
|
"drift_ms_min": 0
|
||||||
|
"drift_ms_max": 0
|
||||||
|
"step_ms_min": 0
|
||||||
|
"step_ms_max": 0
|
||||||
|
"duration_runs_max": m.liveDurationRuns.Count()
|
||||||
|
}
|
||||||
m.reportedLiveCorrection = false
|
m.reportedLiveCorrection = false
|
||||||
m.liveManifestTemplate = ""
|
m.liveManifestTemplate = ""
|
||||||
m.liveManifestTemplateKey = invalid
|
m.liveManifestTemplateKey = invalid
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import "pkg:/components/ContentNode/ProfileContentAuthTokenUtils.bs"
|
import "pkg:/components/ContentNode/ProfileContentAuthTokenUtils.bs"
|
||||||
import "pkg:/components/Services/Innertube/Constants.bs"
|
import "pkg:/components/Services/Innertube/Constants.bs"
|
||||||
|
import "pkg:/components/Services/Innertube/DrmLicenseRequests.bs"
|
||||||
import "pkg:/components/Services/Innertube/InnertubeService.bs"
|
import "pkg:/components/Services/Innertube/InnertubeService.bs"
|
||||||
import "pkg:/components/Services/Innertube/PoTokens.bs"
|
import "pkg:/components/Services/Innertube/PoTokens.bs"
|
||||||
import "pkg:/components/Web/WebServer/Http/HttpRouter.bs"
|
import "pkg:/components/Web/WebServer/Http/HttpRouter.bs"
|
||||||
@@ -161,7 +162,7 @@ namespace Http
|
|||||||
request = context.request
|
request = context.request
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
drmStringQueryParams = ["videoId", "drmParams", "drmSessionId", "cpn"]
|
drmStringQueryParams = ["videoId", "videoLoadId", "drmParams", "drmSessionId", "cpn"]
|
||||||
for each paramName in drmStringQueryParams
|
for each paramName in drmStringQueryParams
|
||||||
if StringUtils.IsNullOrEmpty(request.query[paramName])
|
if StringUtils.IsNullOrEmpty(request.query[paramName])
|
||||||
response.Default(400, "Missing " + paramName)
|
response.Default(400, "Missing " + paramName)
|
||||||
@@ -194,29 +195,25 @@ namespace Http
|
|||||||
options["visitorData"] = m.innertube.sessionData.visitorData
|
options["visitorData"] = m.innertube.sessionData.visitorData
|
||||||
end if
|
end if
|
||||||
|
|
||||||
drmResponse = InnertubeService.GetDrmLicense(options)
|
DrmLicenseRequests.RecordSent(request.query.videoLoadId)
|
||||||
|
licenseResponse = InnertubeService.GetDrmLicense(options)
|
||||||
|
DrmLicenseRequests.RecordResponse(request.query.videoLoadId, licenseResponse)
|
||||||
|
|
||||||
if IsByteArray(drmResponse)
|
license = licenseResponse.license
|
||||||
response.http_code = 200
|
if not IsByteArray(license) or license.Count() = 0
|
||||||
response.SetBodyDataBuffer(drmResponse)
|
|
||||||
response.ContentType("text/html; charset=utf-8")
|
|
||||||
response.headers["Cache-Control"] = "no-cache"
|
|
||||||
else if IsAssociativeArray(drmResponse)
|
|
||||||
LogTelemetryEvent({
|
LogTelemetryEvent({
|
||||||
level: "error"
|
level: "error"
|
||||||
message: `DRM license request failed: ${ValidString(drmResponse.error)}\nvideoId: ${request.query.videoId}`
|
message: `DRM license request failed: ${ValidString(licenseResponse.error)}\nvideoId: ${request.query.videoId}\nvideo_load_id: ${request.query.videoLoadId}`
|
||||||
fingerprint: ["DRM license request failed"]
|
fingerprint: ["DRM license request failed"]
|
||||||
})
|
})
|
||||||
response.Default(500, FormatJson(drmResponse))
|
response.Default(500, FormatJson(licenseResponse))
|
||||||
else
|
return true
|
||||||
LogTelemetryEvent({
|
|
||||||
level: "error"
|
|
||||||
message: `DRM license request returned an unexpected response type\nvideoId: ${request.query.videoId}`
|
|
||||||
fingerprint: ["DRM license request failed"]
|
|
||||||
})
|
|
||||||
response.Default(500, "Invalid DRM license response")
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
response.http_code = 200
|
||||||
|
response.SetBodyDataBuffer(license)
|
||||||
|
response.ContentType("text/html; charset=utf-8")
|
||||||
|
response.headers["Cache-Control"] = "no-cache"
|
||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,756 @@
|
|||||||
|
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-24"
|
||||||
|
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
|
||||||
|
|
||||||
|
m.SendJson(response, PipedToInvidious.VideoMetadataFromPiped(data, ValidString(context.videoId)))
|
||||||
|
return true
|
||||||
|
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()
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import "pkg:/source/utils/Types.bs"
|
|||||||
' /delay/<ms> 200 after <ms>
|
' /delay/<ms> 200 after <ms>
|
||||||
' /echo 200 with the request's { method, path, headers, body } as JSON
|
' /echo 200 with the request's { method, path, headers, body } as JSON
|
||||||
' /maxage/<seconds>/<id> 200 with Cache-Control: max-age=<seconds>
|
' /maxage/<seconds>/<id> 200 with Cache-Control: max-age=<seconds>
|
||||||
' A path in routes (its query aside) responds as its route says instead: { status, headers, body, delayMs }.
|
' A path in routes responds as its route says instead: { status, headers, body, delayMs }. A route keyed
|
||||||
|
' with a query answers that query only, ahead of the route keyed with the bare path.
|
||||||
' A route { drop: true } closes the connection without a response.
|
' A route { drop: true } closes the connection without a response.
|
||||||
' Every response carries X-Hit, the request's count for its path. Connections are read and responded to
|
' Every response carries X-Hit, the request's count for its path. Connections are read and responded to
|
||||||
' without blocking each other, so a slow or abandoned one holds up nothing.
|
' without blocking each other, so a slow or abandoned one holds up nothing.
|
||||||
@@ -162,7 +163,11 @@ function BuildResponse(item as object) as object
|
|||||||
m.top.lastRequest = request
|
m.top.lastRequest = request
|
||||||
|
|
||||||
delayMs = MIN_RESPONSE_DELAY_MS
|
delayMs = MIN_RESPONSE_DELAY_MS
|
||||||
route = ValidAssociativeArray(m.top.routes)[path.Split("?")[0]]
|
routes = ValidAssociativeArray(m.top.routes)
|
||||||
|
route = routes[path]
|
||||||
|
if route = invalid
|
||||||
|
route = routes[path.Split("?")[0]]
|
||||||
|
end if
|
||||||
if route <> invalid
|
if route <> invalid
|
||||||
if ValidInt(route.delayMs) > delayMs
|
if ValidInt(route.delayMs) > delayMs
|
||||||
delayMs = route.delayMs
|
delayMs = route.delayMs
|
||||||
|
|||||||
@@ -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.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 |