Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99f606610c | ||
|
|
62b4a90a7e | ||
|
|
ee98f0f368 | ||
|
|
81db556699 | ||
|
|
81ee5b3262 | ||
|
|
338ad6f82c | ||
|
|
c89eb3ccce | ||
|
|
7a38245630 | ||
|
|
6ca16bd0b2 | ||
|
|
70fc97ae38 | ||
|
|
22f8031b91 | ||
|
|
1e121fdddd | ||
|
|
97f4a0ed61 | ||
|
|
277c5e0562 | ||
|
|
fa64af7ff5 | ||
|
|
10bcf9f1f4 | ||
|
|
a75c42f4ac | ||
|
|
f5b81eff4d | ||
|
|
b6bdbee42f | ||
|
|
0fc9fbb79a | ||
|
|
f3c159218a | ||
|
|
e8624cdb1f | ||
|
|
d427989576 | ||
|
|
4706d71639 | ||
|
|
16df893c2c | ||
|
|
6129afd695 | ||
|
|
84504a5931 | ||
|
|
0123f9fa8e | ||
|
|
7227d4e26b | ||
|
|
58fe601b25 | ||
|
|
a61d132b57 | ||
|
|
ee4acfc8e7 | ||
|
|
fcd798a2fa | ||
|
|
f5be0e5842 | ||
|
|
2d9f3abe5d | ||
|
|
69fe737006 | ||
|
|
ac6c9122c2 | ||
|
|
d3e0883332 | ||
|
|
5c39405255 | ||
|
|
6535006d66 | ||
|
|
a43cb91e1e | ||
|
|
58ce807e42 | ||
|
|
2319ae7025 | ||
|
|
1f2058abce | ||
|
|
aadbde330d | ||
|
|
60df07c95c | ||
|
|
71757bb9d5 | ||
|
|
630176d8aa | ||
|
|
03c7f9afe6 | ||
|
|
3c58f90cc9 | ||
|
|
b5261d900f | ||
|
|
9a319eab75 | ||
|
|
aca9cb890d | ||
|
|
c77eb30985 | ||
|
|
6fc842ca37 | ||
|
|
a1ce7aa9fc | ||
|
|
9e3363f22c | ||
|
|
d42d783738 | ||
|
|
5f1a4c8eb6 | ||
|
|
c3494a7f5d | ||
|
|
103b7f2a71 | ||
|
|
c7377e0e06 | ||
|
|
58f521f923 | ||
|
|
4293a958d0 | ||
|
|
4a89fd0aa9 | ||
|
|
f1a3df81b2 | ||
|
|
d876f819fc | ||
|
|
757dc6069e | ||
|
|
e7f4b3fee1 | ||
|
|
319457bada | ||
|
|
c91f5e49c0 | ||
|
|
45e320abe4 | ||
|
|
4d1673ecfb | ||
|
|
3eb3c0854a | ||
|
|
24cf06bf44 | ||
|
|
9318db7762 | ||
|
|
42ca2d1b30 | ||
|
|
446bba67c9 | ||
|
|
c034dfe109 | ||
|
|
129f0a8adb | ||
|
|
a42c7221c6 | ||
|
|
c602fe3ed2 | ||
|
|
33bb74d976 | ||
|
|
422c867c00 | ||
|
|
6e43528802 | ||
|
|
61d4baa181 | ||
|
|
7f451af418 | ||
|
|
b72a1522a4 | ||
|
|
86b1afe243 | ||
|
|
67bf473dda | ||
|
|
5f744fa7bc | ||
|
|
5a8762c7e5 | ||
|
|
b80b067afb | ||
|
|
777b36852f | ||
|
|
dd1cd8db97 | ||
|
|
a1caa78e6e | ||
|
|
4d1e46cbcc | ||
|
|
f59ed85b62 |
No files matched your search
@@ -2,7 +2,7 @@ name: Stats
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 11 * * *"
|
||||
- cron: "0 9 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
Vendored
+23
@@ -76,6 +76,29 @@
|
||||
"args": "--log-level info --project bsconfig.tests.json --create-package --sourceMap=true --debug --test-mode --lintConfig ../config/bslint.jsonc",
|
||||
"cwd": "${workspaceFolder}/playlet-lib",
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
"name": "Playground",
|
||||
"type": "brightscript",
|
||||
"request": "launch",
|
||||
"envFile": "${workspaceFolder}/.env",
|
||||
"host": "${env:ROKU_DEV_TARGET}",
|
||||
"password": "${env:ROKU_DEVPASSWORD}",
|
||||
"stopOnEntry": false,
|
||||
"enableDebuggerAutoRecovery": false,
|
||||
"stopDebuggerOnAppExit": false,
|
||||
"rootDir": "${workspaceFolder}/build/playground",
|
||||
"sourceDirs": [
|
||||
"${workspaceFolder}/playground/src"
|
||||
],
|
||||
"files": [
|
||||
"**"
|
||||
],
|
||||
"preLaunchTask": "build-playground",
|
||||
"injectRdbOnDeviceComponent": true,
|
||||
"injectRaleTrackerTask": true,
|
||||
"raleTrackerTaskFileLocation": "${workspaceFolder}/tools/RALE/TrackerTask.xml",
|
||||
"enableDebugProtocol": true
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
|
||||
Vendored
+5
@@ -49,6 +49,11 @@
|
||||
"label": "build-web",
|
||||
"script": "build:web",
|
||||
"type": "npm"
|
||||
},
|
||||
{
|
||||
"label": "build-playground",
|
||||
"script": "build:playground",
|
||||
"type": "npm"
|
||||
}
|
||||
]
|
||||
}
|
||||
+128
@@ -5,6 +5,134 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.45.0] - 2026-05-25
|
||||
|
||||
### Added
|
||||
|
||||
- Experimental support for changing playback speed from YouTube mobile app using Leanback/Lounge api
|
||||
- Support for disabling AI auto-dubbed audio tracks
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bug where large playlists (1k+ videos) only load the first page
|
||||
|
||||
## [0.44.10] - 2026-05-03
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bug where home screen editor is empty with a fresh install
|
||||
|
||||
## [0.44.9] - 2026-04-25
|
||||
|
||||
### Fixed
|
||||
|
||||
- Updated dependencies and innertube versions
|
||||
|
||||
## [0.44.8] - 2026-04-24
|
||||
|
||||
### Fixed
|
||||
|
||||
- Always use `signatureTimestamp` in `/player` calls to prevent "reload page" errors. This affects watch history.
|
||||
- Attempt 2 to fix watch history and watch progress
|
||||
|
||||
## [0.44.7] - 2026-04-23
|
||||
|
||||
### Fixed
|
||||
|
||||
- Attempt to fix watch history and watch progress
|
||||
- Channel sort
|
||||
|
||||
## [0.44.6] - 2026-02-08
|
||||
|
||||
### Fixed
|
||||
|
||||
- Error dialog doesn't close automatically when playback recovers after an error
|
||||
- All audio track names are shown as "Other" in multi audio track videos
|
||||
|
||||
## [0.44.5] - 2026-01-17
|
||||
|
||||
### Fixed
|
||||
|
||||
- Error handling when ytjs formats have missing urls
|
||||
|
||||
## [0.44.4] - 2025-11-23
|
||||
|
||||
### Fixed
|
||||
|
||||
- Subscriptions looping instead of loading older videos
|
||||
|
||||
### Removed
|
||||
|
||||
- Trending endpoints from code base
|
||||
|
||||
## [0.44.3] - 2025-11-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- Json parsing with invalid chars like `\u0000` preventing some channels from loading
|
||||
|
||||
## [0.44.2] - 2025-11-13
|
||||
|
||||
### Fixed
|
||||
|
||||
- Removed retry on trending feeds
|
||||
|
||||
## [0.44.1] - 2025-11-12
|
||||
|
||||
### Fixed
|
||||
|
||||
- Small change in post-live dvr detection
|
||||
- Issue where recommended videos are all "UPCOMING" paid content
|
||||
- Errors related to loading the trending feeds. Trending will be removed from Playlet in a future release.
|
||||
|
||||
## [0.44.0] - 2025-11-09
|
||||
|
||||
### Added
|
||||
|
||||
- Implemented compactRadioRenderer node
|
||||
- Prioritise manually created subtitles over auto-generated ones
|
||||
|
||||
## [0.43.9] - 2025-11-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- Another mistake in OTF streams
|
||||
|
||||
## [0.43.8] - 2025-11-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix in url decipher logic
|
||||
- Redo OTF segment processing
|
||||
|
||||
## [0.43.7] - 2025-11-06
|
||||
|
||||
### Fixed
|
||||
|
||||
- Adjust telemetry for OTF streams to debug
|
||||
|
||||
## [0.43.6] - 2025-11-06
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bug in processing OTF streams info
|
||||
|
||||
## [0.43.5] - 2025-11-06
|
||||
|
||||
### Fixed
|
||||
|
||||
- Post live DVR video support
|
||||
- Attempted OTF stream support
|
||||
- Better parsing of audio track metadata
|
||||
- Bug in detecting live videos in HLS streams
|
||||
|
||||
## [0.43.4] - 2025-11-03
|
||||
|
||||
### Fixed
|
||||
|
||||
- Playback error when regular videos are returned with DRM protection (unless they are OTF)
|
||||
- Fallback to iOS HLS for post dvr and OTF videos
|
||||
|
||||
## [0.43.3] - 2025-10-30
|
||||
|
||||
### Fixed
|
||||
|
||||
+20
@@ -8,6 +8,26 @@ Playlet does not show advertising, whether personalized or non personalized.
|
||||
|
||||
Playlet may integrate with 3rd party telemetry services in order to capture anonymous diagnostics data. The only purpose of this data is to diagnose issues and improve the app.
|
||||
|
||||
### Current telemetry implementation
|
||||
|
||||
> This section tries to explain in more detail what data is collected and how it is used. Due to the granularity and details of the following explanation, it might be slightly out of date, but mostly represents the reality of the "Playlet may integrate with 3rd party telemetry services"
|
||||
|
||||
Currently, Playlet captures a bunch of errors through the [telemetry client code](https://github.com/iBicha/playlet/tree/f3c159218ac8e3eec08eb7b62cbd45ad6c451b99/playlet-lib/src/components/Telemetry).
|
||||
It's mostly OS info (version, device model, etc), app info, user country code, locale, error messages, and stack traces. Nothing more than necessary is captured to debug problems.
|
||||
|
||||
In addition to that, an anonymous user id (just a guid stable across app launches of Playlet) and a session id (generated on every launch) are collected.
|
||||
|
||||
The user id is used to understand how many people an error affects. Sometimes one issue is spread out evenly among users, sometimes it's a handful of users (or even just one) spamming the same errors. This helps investigate that aspect.
|
||||
|
||||
The session id is used to understand how an error happened. By isolating a specific error to a session, it helps understand what led to said error.
|
||||
|
||||
This data is currently sent to a server, then forwarded to a self-hosted instance [Glitch-Tip](https://gitlab.com/glitchtip/glitchtip) which provides a simple dashboard showing how frequent errors are, and on which versions they occur.
|
||||
|
||||
This data is anonymous. The data is not collected in a way that can be linked back to a real person, or a YouTube profile for example.
|
||||
The data is stored on a local hard drive, does not leave said hard drive, and accessed only by the currently single developer of Playlet, and frequently purged (because honestly I don't have the disk space).
|
||||
|
||||
The data is used to investigate errors, like playback errors, feed load errors, login errors, and so on.
|
||||
|
||||
## Invidious
|
||||
|
||||
Playlet may request information from one or more [Invidious](https://invidious.io/)
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
|
||||
Playlet is an unofficial YouTube client for Roku 📺
|
||||
|
||||
**[Playlet February 2026 Update](https://github.com/iBicha/playlet/discussions/827)**
|
||||
|
||||
|
||||
## Screenshots
|
||||
|
||||
<a href="./docs/screenshots/README.md">
|
||||
|
||||
@@ -58,6 +58,12 @@
|
||||
"regex": "\\bTr\\s*\\(\\s*\"[^\\\"]*\"\\s*\\)",
|
||||
"regexFlags": "ig",
|
||||
"message": "Tr(\"String\") is not allowed. Use Tr(Locale.Key) instead."
|
||||
},
|
||||
{
|
||||
"code": "NO_PARSE_JSON",
|
||||
"regex": "\\s*ParseJson\\(",
|
||||
"regexFlags": "ig",
|
||||
"message": "ParseJson is not allowed. Use StringUtils.ParseJsonSafe() instead."
|
||||
}
|
||||
],
|
||||
"files": [
|
||||
|
||||
Generated
+626
-1437
File diff suppressed because it is too large.
Load diff
+22
-21
@@ -1,38 +1,38 @@
|
||||
{
|
||||
"name": "playlet",
|
||||
"version": "0.43.3",
|
||||
"version": "0.45.0",
|
||||
"description": "Unofficial YouTube client for Roku",
|
||||
"devDependencies": {
|
||||
"@rokucommunity/bslint": "^0.8.37",
|
||||
"@rokucommunity/bslint": "^0.8.43",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/node": "^24.9.1",
|
||||
"@types/node": "^25.9.1",
|
||||
"@types/xml2js": "^0.4.14",
|
||||
"argparse": "^2.0.1",
|
||||
"brighterscript": "0.70.2",
|
||||
"brighterscript-formatter": "^1.7.19",
|
||||
"brighterscript": "0.72.2",
|
||||
"brighterscript-formatter": "^1.7.26",
|
||||
"convert-svg-to-png": "^0.7.1",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dotenv": "^17.2.3",
|
||||
"fs-extra": "^11.3.2",
|
||||
"glob": "^11.0.3",
|
||||
"dotenv": "^17.4.2",
|
||||
"fs-extra": "^11.3.5",
|
||||
"glob": "^13.0.6",
|
||||
"imap": "^0.8.19",
|
||||
"ip": "^2.0.1",
|
||||
"json5": "^2.2.3",
|
||||
"mailparser": "^3.7.5",
|
||||
"protocol-buffers-schema": "^3.6.0",
|
||||
"puppeteer": "^24.26.1",
|
||||
"roku-deploy": "^3.13.0",
|
||||
"roku-test-automation": "^2.2.1",
|
||||
"rooibos-roku": "5.15.5",
|
||||
"mailparser": "^3.9.8",
|
||||
"protocol-buffers-schema": "^3.6.1",
|
||||
"puppeteer": "^25.0.4",
|
||||
"roku-deploy": "^3.17.4",
|
||||
"roku-test-automation": "^2.2.2",
|
||||
"rooibos-roku": "5.16.3",
|
||||
"rounded-rect-9patch": "^1.1.2",
|
||||
"semver": "^7.7.3",
|
||||
"semver": "^7.8.1",
|
||||
"shelljs": "^0.10.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "5.9.3",
|
||||
"telnet-client": "^2.2.6",
|
||||
"typescript": "6.0.3",
|
||||
"telnet-client": "^2.2.13",
|
||||
"xml2js": "^0.6.2",
|
||||
"yaml": "^2.8.1"
|
||||
"yaml": "^2.9.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "22"
|
||||
@@ -48,6 +48,7 @@
|
||||
"build:lib:dev": "cd playlet-lib && npm run build:dev",
|
||||
"build:lib:prod": "cd playlet-lib && npm run build:prod",
|
||||
"build:web": "cd playlet-web && npm run build",
|
||||
"build:playground": "cd playground && npm run build",
|
||||
"lint": "cd playlet-lib && npm run lint && cd ../playlet-app && npm run lint && cd ../playlet-web && npm run lint",
|
||||
"lint:fix": "cd playlet-lib && npm run lint:fix && cd ../playlet-app && npm run lint:fix && cd ../playlet-web && npm run lint",
|
||||
"format": "cd playlet-lib && npm run format && cd ../playlet-app && npm run format",
|
||||
@@ -65,8 +66,8 @@
|
||||
"screenshot": "node tools/screenshot.js",
|
||||
"convert-images": "node tools/convert-images.js",
|
||||
"update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip",
|
||||
"postinstall": "cd playlet-lib && npm install && cd ../playlet-app && npm install && cd ../playlet-web && npm install",
|
||||
"update-deps": "npx npm-check-updates --deep --upgrade --install always --reject rooibos-roku",
|
||||
"postinstall": "cd playlet-lib && npm install && cd ../playlet-app && npm install && cd ../playground && npm install && cd ../playlet-web && npm install",
|
||||
"update-deps": "npx npm-check-updates --deep --upgrade --install always --reject typescript,svelte-preprocess",
|
||||
"registry:write": "node tools/registry.js --input registry.json",
|
||||
"registry:read": "node tools/registry.js --output registry.json",
|
||||
"registry:clear": "node tools/registry.js --clear",
|
||||
@@ -75,6 +76,6 @@
|
||||
"shutdown": "node tools/shutdown.js"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rollup/rollup-linux-x64-gnu": "^4.52.5"
|
||||
"@rollup/rollup-linux-x64-gnu": "^4.60.4"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# Playground
|
||||
|
||||
Playground is a test project to try things out or iterate on a concept.
|
||||
|
||||
Playlet app relies on playlet lib, and playlet lib relies on web app, so sometimes iteration speed can be slower when building everything everytime.
|
||||
|
||||
Just like Playlet, Playground can be launched from the VSCode "Run and debug" menu.
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "../config/bsconfig.base.jsonc",
|
||||
"rootDir": "src/",
|
||||
"stagingDir": "../build/playground",
|
||||
"outFile": "../dist/playground.zip"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "bsconfig.json",
|
||||
"createPackage": false,
|
||||
"deploy": false,
|
||||
"retainStagingDir": false,
|
||||
"sourceMap": false
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "../config/bsconfig.tests.base.jsonc",
|
||||
"rootDir": "src/",
|
||||
"stagingDir": "../build/playground-tests",
|
||||
"outFile": "../build/playground-tests.zip"
|
||||
}
|
||||
Generated
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "playground",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playground",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "playground",
|
||||
"version": "0.1.0",
|
||||
"description": "A playground for testing Roku development",
|
||||
"scripts": {
|
||||
"prebuild": "node ../tools/rm.js ../build/playground",
|
||||
"build": "bsc --debug --create-package --sourceMap=true --lintConfig ../config/bslint.jsonc",
|
||||
"lint": "bslint --project bsconfig.lint.json --lintConfig ../config/bslint.jsonc",
|
||||
"lint:fix": "npm run lint -- --fix",
|
||||
"format:base": "bsfmt \"src/**/*.brs\" \"src/**/*.bs\" \"!**/bslib.brs\" \"!**/roku_modules/**/*\" --bsfmt-path ../config/bsfmt.jsonc",
|
||||
"format": "npm run format:base -- --check",
|
||||
"format:fix": "npm run format:base -- --write",
|
||||
"test": "npm run test:build && npm run test:run",
|
||||
"test:build": "bsc --project bsconfig.tests.json --create-package --sourceMap=true --debug --test-mode --lintConfig ../config/bslint.jsonc",
|
||||
"test:run": "node ../tools/run-test-app.js --package ../build/playground-tests.zip"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
function Init()
|
||||
print "Playground Init"
|
||||
end function
|
||||
@@ -0,0 +1,10 @@
|
||||
<component name="Playground" extends="Scene">
|
||||
<interface>
|
||||
<field id="exitChannel" type="bool" alwaysNotify="true" />
|
||||
<field id="launchArgs" type="assocarray" />
|
||||
<field id="inputArgs" type="assocarray" alwaysNotify="true" />
|
||||
</interface>
|
||||
<children>
|
||||
<Label text="Welcome to Playlet Playground!" />
|
||||
</children>
|
||||
</component>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,31 @@
|
||||
title=Playlet Playground
|
||||
|
||||
major_version=0
|
||||
minor_version=1
|
||||
build_version=00000
|
||||
|
||||
ui_resolutions=hd
|
||||
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
||||
|
||||
## Channel Assets
|
||||
### Main Menu Icons / Channel Poster Artwork
|
||||
#### Image sizes are FHD: 540x405px | HD: 290x218px | SD: 246x140px
|
||||
mm_icon_focus_fhd=pkg:/images/channel-poster_fhd.png
|
||||
mm_icon_focus_hd=pkg:/images/channel-poster_hd.png
|
||||
mm_icon_focus_sd=pkg:/images/channel-poster_sd.png
|
||||
|
||||
### Splash Screen + Loading Screen Artwork
|
||||
#### Image sizes are FHD: 1920x1080px | HD: 1280x720px | SD: 720x480px
|
||||
splash_screen_fhd=pkg:/images/splash-screen_fhd.jpg
|
||||
splash_screen_hd=pkg:/images/splash-screen_hd.jpg
|
||||
splash_screen_sd=pkg:/images/splash-screen_sd.jpg
|
||||
|
||||
splash_color=#242424
|
||||
splash_min_time=0
|
||||
|
||||
confirm_partner_button=1
|
||||
|
||||
supports_input_launch=1
|
||||
|
||||
requires_widevine_drm=1
|
||||
requires_widevine_version=1.0
|
||||
@@ -0,0 +1,56 @@
|
||||
' Playlet (App to play videos from an Invidious server on Roku TVs)
|
||||
' Copyright (C) 2025 Brahim Hadriche
|
||||
|
||||
' This program is free software: you can redistribute it and/or modify
|
||||
' it under the terms of the GNU Affero General Public License as published by
|
||||
' the Free Software Foundation, either version 3 of the License, or
|
||||
' (at your option) any later version.
|
||||
|
||||
' This program is distributed in the hope that it will be useful,
|
||||
' but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
' GNU Affero General Public License for more details.
|
||||
|
||||
' You should have received a copy of the GNU Affero General Public License
|
||||
' along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
function Main(args as object) as void
|
||||
screen = CreateObject("roSGScreen")
|
||||
port = CreateObject("roMessagePort")
|
||||
screen.setMessagePort(port)
|
||||
|
||||
scene = screen.CreateScene("Playground")
|
||||
screen.show()
|
||||
|
||||
scene.ObserveField("exitChannel", port)
|
||||
scene.launchArgs = args
|
||||
|
||||
input = CreateObject("roInput")
|
||||
input.setMessagePort(port)
|
||||
|
||||
' The following comment is to enable the SceneGraph inspector
|
||||
' on the VSCode BrightScript plugin.
|
||||
' vscode_rdb_on_device_component_entry
|
||||
|
||||
' The following comment is to enable RALE tracking
|
||||
' vscode_rale_tracker_entry
|
||||
|
||||
while true
|
||||
msg = wait(0, port)
|
||||
msgType = type(msg)
|
||||
if msgType = "roSGScreenEvent"
|
||||
if msg.isScreenClosed()
|
||||
return
|
||||
end if
|
||||
else if msgType = "roSGNodeEvent"
|
||||
field = msg.getField()
|
||||
data = msg.getData()
|
||||
if field = "exitChannel" and data = true
|
||||
return
|
||||
end if
|
||||
else if msgType = "roInputEvent"
|
||||
scene.inputArgs = msg.getInfo()
|
||||
end if
|
||||
end while
|
||||
|
||||
end function
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "playlet-app",
|
||||
"version": "0.43.3",
|
||||
"version": "0.45.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playlet-app",
|
||||
"version": "0.43.3"
|
||||
"version": "0.45.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playlet-app",
|
||||
"version": "0.43.3",
|
||||
"version": "0.45.0",
|
||||
"description": "Unofficial YouTube client for Roku",
|
||||
"scripts": {
|
||||
"prebuild": "node ../tools/rm.js ../build/playlet-app",
|
||||
|
||||
@@ -37,6 +37,7 @@ function GetLoadingMessagesFromCache() as object
|
||||
if messagesFile = ""
|
||||
return invalid
|
||||
end if
|
||||
' bs:disable-next-line NO_PARSE_JSON
|
||||
return ParseJson(messagesFile)
|
||||
end function
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ title=Playlet
|
||||
|
||||
# Do not update version manually, it is auto updated from package.json
|
||||
major_version=0
|
||||
minor_version=43
|
||||
build_version=00003
|
||||
minor_version=45
|
||||
build_version=00000
|
||||
|
||||
ui_resolutions=hd
|
||||
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Registry
|
||||
if urlsJson = invalid
|
||||
return invalid
|
||||
end if
|
||||
' bs:disable-next-line NO_PARSE_JSON
|
||||
urls = ParseJson(urlsJson)
|
||||
return urls
|
||||
end function
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "playlet-lib",
|
||||
"version": "0.43.3",
|
||||
"version": "0.45.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playlet-lib",
|
||||
"version": "0.43.3"
|
||||
"version": "0.45.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playlet-lib",
|
||||
"version": "0.43.3",
|
||||
"version": "0.45.0",
|
||||
"description": "Unofficial YouTube client for Roku",
|
||||
"scripts": {
|
||||
"prebuild": "node ../tools/rm.js ../build/playlet-lib",
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace DialogUtils
|
||||
if hasMessageId
|
||||
messages = RegistryUtils.Read(RegistryUtils.MESSAGES)
|
||||
if not StringUtils.IsNullOrEmpty(messages)
|
||||
messages = ParseJson(messages)
|
||||
messages = StringUtils.ParseJsonSafe(messages)
|
||||
if IsAssociativeArray(messages)
|
||||
savedMessageId = ValidString(messages["messageId"])
|
||||
if savedMessageId = messageId
|
||||
|
||||
@@ -50,7 +50,7 @@ end function
|
||||
|
||||
function JobError(error as dynamic) as void
|
||||
error = ErrorUtils.Format(error)
|
||||
LogError(error)
|
||||
LogError(`[${m.top.subtype()}]${error}`)
|
||||
callbackNode = JobGetCallbackNode()
|
||||
if callbackNode = invalid
|
||||
return
|
||||
|
||||
@@ -115,12 +115,17 @@ function OnLineSysLog(event as object, dateTime as object, logsFile as string, b
|
||||
if info.LogType <> "http.error"
|
||||
return
|
||||
end if
|
||||
httpCode = ValidInt(info.HttpCode)
|
||||
if httpCode >= 200 and httpCode < 300
|
||||
return
|
||||
end if
|
||||
|
||||
line = FormatTime(dateTime) + "[ERROR][SysLog] " + ToString(info)
|
||||
print line
|
||||
buffer.FromAsciiString(line + `\n`)
|
||||
buffer.AppendFile(logsFile)
|
||||
|
||||
fingerprint = `SysLog${info.Status}${info.LogType}${info.HttpCode}${info.Method}`
|
||||
fingerprint = `SysLog${info.Status}${info.LogType}${httpCode}${info.Method}`
|
||||
|
||||
if ThrottleEvent("SysLogError", fingerprint, 60)
|
||||
return
|
||||
@@ -145,11 +150,11 @@ function OnLineLogMonitorMemoryWarning(event as object, dateTime as object, logs
|
||||
return
|
||||
end if
|
||||
|
||||
LogTelemetryEvent({
|
||||
level: "warning"
|
||||
message: line + `\nCurrentTime: ${m.eventThrottleTimer.TotalSeconds()}`
|
||||
fingerprint: [message]
|
||||
})
|
||||
' LogTelemetryEvent({
|
||||
' level: "warning"
|
||||
' message: line + `\nCurrentTime: ${m.eventThrottleTimer.TotalSeconds()}`
|
||||
' fingerprint: [message]
|
||||
' })
|
||||
end function
|
||||
|
||||
function OnLineLogDeviceInfoMemoryWarning(event as object, dateTime as object, logsFile as string, buffer as object) as void
|
||||
@@ -168,11 +173,11 @@ function OnLineLogDeviceInfoMemoryWarning(event as object, dateTime as object, l
|
||||
buffer.FromAsciiString(line + `\n`)
|
||||
buffer.AppendFile(logsFile)
|
||||
|
||||
LogTelemetryEvent({
|
||||
level: "warning"
|
||||
message: line + `\nCurrentTime: ${m.eventThrottleTimer.TotalSeconds()}`
|
||||
fingerprint: [message]
|
||||
})
|
||||
' LogTelemetryEvent({
|
||||
' level: "warning"
|
||||
' message: line + `\nCurrentTime: ${m.eventThrottleTimer.TotalSeconds()}`
|
||||
' fingerprint: [message]
|
||||
' })
|
||||
end function
|
||||
|
||||
' Returns true if the event should be throttled
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace HomeScreenUtils
|
||||
|
||||
function GetFeed(feedFileName as string, preferences as object) as object
|
||||
feed = ParseJson(ReadAsciiFile(feedFileName))
|
||||
feed = StringUtils.ParseJsonSafe(ReadAsciiFile(feedFileName))
|
||||
for each item in feed
|
||||
item.title = Tr(item.title)
|
||||
|
||||
|
||||
@@ -68,8 +68,8 @@ function LoginWithInvidious() as void
|
||||
DialogUtils.ShowDialogEx({
|
||||
title: "No Invidious Instance"
|
||||
message: [
|
||||
"Playlet built-in backend does not support login yet.",
|
||||
"Can only login if an Invidious instance is set in the settings."
|
||||
"Playlet built-in backend does not support Invidious login.",
|
||||
"Can only login with Invidious if an Invidious instance is set in the settings."
|
||||
]
|
||||
})
|
||||
return
|
||||
|
||||
+24
-6
@@ -3,13 +3,14 @@ import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/MathUtils.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.homeLayout = {}
|
||||
homeLayout = ParseJson(ReadAsciiFile("libpkg:/config/default_home_layout.yaml"))
|
||||
for each item in homeLayout
|
||||
m.homeLayout[item.id] = item
|
||||
m.homeLayoutMap = {}
|
||||
homeLayoutMap = StringUtils.ParseJsonSafe(ReadAsciiFile("libpkg:/config/default_home_layout.yaml"))
|
||||
for each item in homeLayoutMap
|
||||
m.homeLayoutMap[item.id] = item
|
||||
end for
|
||||
|
||||
m.checkList = m.top.findNode("checkList")
|
||||
@@ -80,17 +81,34 @@ function OnValueChange()
|
||||
|
||||
nodes = []
|
||||
checkedState = []
|
||||
homeLayoutMap = {}
|
||||
homeLayoutMap.Append(m.homeLayoutMap)
|
||||
|
||||
for each item in value
|
||||
feed = m.homeLayout[item.id]
|
||||
feed = homeLayoutMap[item.id]
|
||||
if feed = invalid
|
||||
LogWarn("unknown feed id:", item.id)
|
||||
continue for
|
||||
end if
|
||||
homeLayoutMap.Delete(item.id)
|
||||
node = CreateObject("roSGNode", "ContentNode")
|
||||
node.id = feed.id
|
||||
node.title = Tr(feed.title)
|
||||
nodes.push(node)
|
||||
checkedState.push(item.enabled)
|
||||
end for
|
||||
|
||||
for each id in homeLayoutMap
|
||||
feed = homeLayoutMap[id]
|
||||
if feed = invalid
|
||||
LogWarn("unknown feed id:", id)
|
||||
continue for
|
||||
end if
|
||||
node = CreateObject("roSGNode", "ContentNode")
|
||||
node.id = feed.id
|
||||
node.title = Tr(feed.title)
|
||||
nodes.push(node)
|
||||
checkedState.push(item.enabled)
|
||||
checkedState.push(false)
|
||||
end for
|
||||
|
||||
labelCount = content.getChildCount()
|
||||
|
||||
+1
-1
@@ -324,7 +324,7 @@ end function
|
||||
|
||||
function CanFetchWithCors(instance as string, testNode as object, cancellation as object) as void
|
||||
try
|
||||
url = `${instance}/api/v1/trending`
|
||||
url = `${instance}/api/v1/popular`
|
||||
response = HttpClient.Get(url).NoCache().Cancellation(cancellation).Await()
|
||||
|
||||
if not response.IsSuccess()
|
||||
|
||||
@@ -20,7 +20,7 @@ function Load() as void
|
||||
end if
|
||||
|
||||
m.bookmarksString = bookmarksString
|
||||
bookmarks = ParseJson(bookmarksString)
|
||||
bookmarks = StringUtils.ParseJsonSafe(bookmarksString)
|
||||
if bookmarks = invalid
|
||||
LogWarn("Failed to parse bookmarks json")
|
||||
return
|
||||
|
||||
@@ -7,9 +7,11 @@ import "pkg:/source/utils/UrlUtils.bs"
|
||||
class DashManifest
|
||||
|
||||
public invidiousInstance as dynamic
|
||||
public disableAutoDubbed as boolean
|
||||
|
||||
function new(invidiousInstance as string)
|
||||
function new(invidiousInstance as string, disableAutoDubbed = false as boolean)
|
||||
m.invidiousInstance = invidiousInstance
|
||||
m.disableAutoDubbed = disableAutoDubbed
|
||||
|
||||
m.utils = new Http.Utils()
|
||||
|
||||
@@ -32,7 +34,7 @@ class DashManifest
|
||||
}
|
||||
end function
|
||||
|
||||
function fromVideoMetadata(metadata as object, qualityFilter as object, local as boolean) as string
|
||||
function FromVideoMetadata(metadata as object, qualityFilter as object, local as boolean) as string
|
||||
adaptiveFormats = []
|
||||
adaptiveFormats.Append(metadata.adaptiveFormats)
|
||||
|
||||
@@ -48,14 +50,19 @@ class DashManifest
|
||||
end for
|
||||
end if
|
||||
|
||||
audioStreams = m.getAudioStreams(adaptiveFormats)
|
||||
videoStreams = m.getVideoStreams(adaptiveFormats, qualityFilter)
|
||||
if videoStreams.Count() = 0
|
||||
duration = m.GetDuration(metadata)
|
||||
|
||||
groupings = m.CreateFormatGroupings(adaptiveFormats, metadata.isPostLiveDvr)
|
||||
audioGroups = groupings.audio
|
||||
videoGroups = groupings.video
|
||||
|
||||
filteredVideoGroups = m.FilterVideoGroups(videoGroups, qualityFilter)
|
||||
if filteredVideoGroups.Count() = 0 and videoGroups.Count() > 0
|
||||
LogWarnNoTelemetry("No video streams found using quality filter:", qualityFilter, "Falling back to all video streams")
|
||||
videoStreams = m.getVideoStreams(adaptiveFormats, {})
|
||||
filteredVideoGroups = videoGroups
|
||||
end if
|
||||
|
||||
if videoStreams.Count() = 0
|
||||
if filteredVideoGroups.Count() = 0
|
||||
lastPlayerResponse = ValidString(ReadAsciiFile("cachefs:/last_player_response.json"))
|
||||
LogTelemetryEvent({
|
||||
level: "error"
|
||||
@@ -72,169 +79,375 @@ class DashManifest
|
||||
}]
|
||||
})
|
||||
end if
|
||||
|
||||
videoMimeTypes = m.getMimeTypes(videoStreams)
|
||||
audioSets = m.getMimeTypeLanguageCombos(audioStreams)
|
||||
storyboards = metadata.storyboards
|
||||
|
||||
xml = new XmlObject()
|
||||
|
||||
xml.Comment(`Generated by Playlet - Video ID: ${metadata.videoId}`)
|
||||
xml.Comment(`Parser: ${ValidString(metadata.parser)}`)
|
||||
|
||||
if xml.Node("MPD", {
|
||||
"xmlns": "urn:mpeg:dash:schema:mpd:2011"
|
||||
"profiles": "urn:mpeg:dash:profile:full:2011"
|
||||
"minBufferTime": "PT1.5S"
|
||||
"type": "static"
|
||||
"mediaPresentationDuration": `PT${metadata.lengthSeconds ?? 0}S`
|
||||
"mediaPresentationDuration": `PT${duration}S`
|
||||
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
|
||||
"xsi:schemaLocation": "urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd"
|
||||
})
|
||||
if xml.Node("Period")
|
||||
|
||||
id = 0
|
||||
id = m.generateAudioAdaptationSets(xml, audioSets, audioStreams, id)
|
||||
id = m.generateVideoAdaptationSets(xml, videoMimeTypes, videoStreams, id)
|
||||
m.generateImageAdaptationSets(xml, storyboards, id)
|
||||
id = m.GenerateAudioAdaptationSets(xml, audioGroups, id, metadata)
|
||||
id = m.GenerateVideoAdaptationSets(xml, filteredVideoGroups, id, metadata)
|
||||
m.GenerateImageAdaptationSets(xml, storyboards, id)
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
return xml.ToXmlString()
|
||||
end function
|
||||
|
||||
function generateAudioAdaptationSets(xml as object, audioSets as object, audioStreams as object, id as integer) as integer
|
||||
for each audioSet in audioSets
|
||||
function GetDuration(metadata as object) as dynamic
|
||||
if metadata["isPostLiveDvr"] = true and IsInt(metadata["postLiveDvrDurationMs"])
|
||||
return metadata["postLiveDvrDurationMs"] / 1000.0
|
||||
end if
|
||||
|
||||
approxDurationMs = ValidString(ObjectUtils.Dig(metadata, ["adaptiveFormats", 0, "approxDurationMs"])).ToInt()
|
||||
if approxDurationMs > 0
|
||||
return approxDurationMs / 1000.0
|
||||
end if
|
||||
|
||||
return ValidInt(metadata["lengthSeconds"])
|
||||
end function
|
||||
|
||||
function CreateFormatGroupings(formats as object, isPostLiveDvr as boolean) as object
|
||||
groupInfo = {}
|
||||
|
||||
for each format in formats
|
||||
isOtf = format.isTypeOTF = true
|
||||
hasInit = not StringUtils.IsNullOrEmpty(format.init)
|
||||
hasIndex = not StringUtils.IsNullOrEmpty(format.index)
|
||||
isValid = (hasInit and hasIndex) or isOtf or isPostLiveDvr
|
||||
if not isValid
|
||||
continue for
|
||||
end if
|
||||
|
||||
if not IsString(format.type)
|
||||
continue for
|
||||
end if
|
||||
|
||||
if (format.width = invalid or format.height = invalid) and not StringUtils.IsNullOrEmpty(format.size)
|
||||
if format.size.instr("x") > 0
|
||||
parts = format.size.Tokenize("x")
|
||||
if parts.Count() = 2
|
||||
format.width = ValidInt(parts[0].toInt())
|
||||
format.height = ValidInt(parts[1].toInt())
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
codecs = ""
|
||||
mimeType = format.type.Tokenize(";")[0]
|
||||
if format.type.inStr("codecs=") <> -1
|
||||
codecs = format.type.split("codecs=")[1]
|
||||
if codecs.startsWith(`"`)
|
||||
codecs = codecs.mid(1)
|
||||
end if
|
||||
if codecs.endsWith(`"`)
|
||||
codecs = codecs.left(codecs.len() - 1)
|
||||
end if
|
||||
end if
|
||||
|
||||
justCodec = codecs.split(".")[0]
|
||||
|
||||
colorInfo = ""
|
||||
if IsAssociativeArray(format.colorInfo)
|
||||
colorInfo = `${format.colorInfo.primaries}-${format.colorInfo.transferCharacteristics}-${format.colorInfo.matrixCoefficients}`
|
||||
end if
|
||||
|
||||
audioTrackId = ""
|
||||
if IsAssociativeArray(format.audioTrack) and IsString(format.audioTrack.id)
|
||||
audioTrackId = format.audioTrack.id
|
||||
end if
|
||||
|
||||
if format.type.startsWith("audio")
|
||||
xtagsInfo = m.GetXtagsInfo(format)
|
||||
format.xtagsInfo = xtagsInfo
|
||||
format.isDrc = xtagsInfo.isDrc
|
||||
format.isDubbed = xtagsInfo.isDubbed
|
||||
format.isAutoDubbed = xtagsInfo.isAutoDubbed
|
||||
format.isDescriptive = xtagsInfo.isDescriptive
|
||||
format.isSecondary = xtagsInfo.isSecondary
|
||||
format.isOriginal = xtagsInfo.isOriginal
|
||||
end if
|
||||
|
||||
drc = ""
|
||||
if format.isDrc = true
|
||||
drc = "drc"
|
||||
end if
|
||||
|
||||
groupId = `${mimeType}-${justCodec}-${colorInfo}-${audioTrackId}-${drc}`
|
||||
|
||||
if groupInfo[groupId] = invalid
|
||||
groupInfo[groupId] = []
|
||||
end if
|
||||
groupInfo[groupId].Push(format)
|
||||
end for
|
||||
|
||||
audioGroups = []
|
||||
videoGroups = []
|
||||
|
||||
for each key in groupInfo
|
||||
group = groupInfo[key]
|
||||
if group[0].type.startsWith("audio")
|
||||
audioGroups.Push(group)
|
||||
else if group[0].type.startsWith("video")
|
||||
videoGroups.Push(group)
|
||||
end if
|
||||
end for
|
||||
|
||||
return { audio: audioGroups, video: videoGroups }
|
||||
end function
|
||||
|
||||
function FilterVideoGroups(videoGroups as object, qualityFilter as object) as object
|
||||
if qualityFilter.Count() = 0
|
||||
return videoGroups
|
||||
end if
|
||||
|
||||
filteredGroups = []
|
||||
for each group in videoGroups
|
||||
filteredStreams = []
|
||||
for each stream in group
|
||||
if m.IsVideoFormatIncluded(stream, qualityFilter)
|
||||
filteredStreams.Push(stream)
|
||||
end if
|
||||
end for
|
||||
|
||||
if filteredStreams.Count() > 0
|
||||
filteredGroups.Push(filteredStreams)
|
||||
end if
|
||||
end for
|
||||
return filteredGroups
|
||||
end function
|
||||
|
||||
function IsVideoFormatIncluded(stream as object, qualityFilter as object) as boolean
|
||||
if qualityFilter.Count() = 0
|
||||
return true
|
||||
end if
|
||||
|
||||
qualityLabel = stream.qualityLabel
|
||||
if not StringUtils.IsNullOrEmpty(qualityLabel)
|
||||
pIndex = qualityLabel.InStr("p")
|
||||
if pIndex <> -1
|
||||
qualityLabel = qualityLabel.Mid(0, pIndex)
|
||||
end if
|
||||
if qualityFilter[qualityLabel] = true
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
if stream.height <> invalid
|
||||
if qualityFilter[ToString(stream.height)] = true
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
resolution = stream.resolution
|
||||
if not StringUtils.IsNullOrEmpty(resolution)
|
||||
pIndex = resolution.InStr("p")
|
||||
if pIndex <> -1
|
||||
resolution = resolution.Mid(0, pIndex)
|
||||
end if
|
||||
if qualityFilter[resolution] = true
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
size = stream.size
|
||||
if not StringUtils.IsNullOrEmpty(size)
|
||||
sizeParts = size.Split("x")
|
||||
if sizeParts.Count() = 2
|
||||
if qualityFilter[sizeParts[1]] = true
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
return false
|
||||
end function
|
||||
|
||||
function GenerateAudioAdaptationSets(xml as object, audioGroups as object, id as integer, metadata as object) as integer
|
||||
for each group in audioGroups
|
||||
firstFormat = group[0]
|
||||
if m.disableAutoDubbed and ValidBool(firstFormat.isAutoDubbed)
|
||||
continue for
|
||||
end if
|
||||
hoisted = {}
|
||||
|
||||
adaptationSetAttributes = {
|
||||
"id": `${id}`
|
||||
"mimeType": audioSet.mimeType
|
||||
"mimeType": firstFormat.type.Tokenize(";")[0]
|
||||
"startWithSAP": "1"
|
||||
"subsegmentAlignment": "true"
|
||||
"contentType": "audio"
|
||||
}
|
||||
if not StringUtils.IsNullOrEmpty(audioSet.lang)
|
||||
adaptationSetAttributes["lang"] = audioSet.lang
|
||||
|
||||
if IsAssociativeArray(firstFormat.audioTrack)
|
||||
if IsString(firstFormat.audioTrack.languageCode)
|
||||
adaptationSetAttributes["lang"] = firstFormat.audioTrack.languageCode
|
||||
else if IsString(firstFormat.audioTrack.id)
|
||||
' ID is in the format "CODE.DIGIT" e.g. "en.4"
|
||||
adaptationSetAttributes["lang"] = firstFormat.audioTrack.id.split(".")[0]
|
||||
end if
|
||||
end if
|
||||
|
||||
' Hoist common attributes
|
||||
codecs = m.HoistCodecs(group, hoisted)
|
||||
if IsString(codecs)
|
||||
adaptationSetAttributes["codecs"] = codecs
|
||||
end if
|
||||
audioSampleRate = m.HoistNumberAttribute(group, "audioSampleRate", hoisted)
|
||||
if IsInt(audioSampleRate)
|
||||
adaptationSetAttributes["audioSamplingRate"] = audioSampleRate
|
||||
end if
|
||||
|
||||
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
||||
xml.EmptyNode("Role", {
|
||||
"schemeIdUri": "urn:mpeg:dash:role:2011"
|
||||
"value": audioSet.acont = "original" ? "main" : "alternate"
|
||||
})
|
||||
|
||||
for i = 0 to audioStreams.Count() - 1
|
||||
stream = audioStreams[i]
|
||||
streamMimeType = stream.type.Tokenize(";")[0]
|
||||
if streamMimeType <> audioSet.mimeType or stream.languageInfo.lang <> audioSet.lang or stream.languageInfo.acont <> audioSet.acont
|
||||
continue for
|
||||
end if
|
||||
|
||||
codecs = stream.type.split("codecs=")[1]
|
||||
if codecs.startsWith(`"`)
|
||||
codecs = codecs.mid(1)
|
||||
end if
|
||||
if codecs.endsWith(`"`)
|
||||
codecs = codecs.left(codecs.len() - 1)
|
||||
end if
|
||||
|
||||
if xml.Node("Representation", {
|
||||
"id": stream.itag
|
||||
"codecs": codecs
|
||||
"bandwidth": stream.bitrate
|
||||
})
|
||||
|
||||
xml.EmptyNode("AudioChannelConfiguration", {
|
||||
"schemeIdUri": "urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
|
||||
"value": `${stream.audioChannels}`
|
||||
})
|
||||
|
||||
if StringUtils.IsNullOrEmpty(stream.url)
|
||||
xml.Comment(`[ERROR] Stream.url is null or empty for itag: ${stream.itag}`)
|
||||
else if stream.url.InStr("yt_live_broadcast") <> -1 or stream.url.InStr("yt_premiere_broadcast") <> -1
|
||||
xml.Comment(`[WARN] Stream URL indicates a live broadcast for itag: ${stream.itag}`)
|
||||
if IsArray(firstFormat.drmFamilies)
|
||||
for each drmFamily in firstFormat.drmFamilies
|
||||
systemId = m.GetDrmSystemId(drmFamily)
|
||||
if IsString(systemId)
|
||||
xml.EmptyNode("ContentProtection", { "schemeIdUri": `urn:uuid:${systemId}` })
|
||||
end if
|
||||
xml.TextNode("BaseURL", ValidString(stream.url))
|
||||
end for
|
||||
end if
|
||||
|
||||
if StringUtils.IsNullOrEmpty(stream.index) or StringUtils.IsNullOrEmpty(stream.init)
|
||||
xml.Comment(`[ERROR] Stream index: ${stream.index}, init: ${stream.init} is invalid for itag: ${stream.itag}`)
|
||||
if IsAssociativeArray(firstFormat.audioTrack) or firstFormat.isDrc = true
|
||||
' Roles
|
||||
roles = m.GetTrackRoles(firstFormat)
|
||||
for each role in roles
|
||||
xml.EmptyNode("Role", { "schemeIdUri": "urn:mpeg:dash:role:2011", "value": role })
|
||||
end for
|
||||
|
||||
' Label
|
||||
if IsAssociativeArray(firstFormat.audioTrack) and IsString(firstFormat.audioTrack.displayName)
|
||||
displayName = firstFormat.audioTrack.displayName
|
||||
if firstFormat.isDrc = true
|
||||
displayName = `${displayName} (Stable Volume)`
|
||||
end if
|
||||
if xml.Node("SegmentBase", { "indexRange": stream.index })
|
||||
xml.EmptyNode("Initialization", { "range": stream.init })
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
xml.Node("Label", { "id": id })
|
||||
xml.Text(displayName)
|
||||
xml.End()
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
' AudioChannelConfiguration
|
||||
channels = m.HoistAudioChannels(group, hoisted)
|
||||
if IsInt(channels)
|
||||
xml.EmptyNode("AudioChannelConfiguration", {
|
||||
"schemeIdUri": "urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
|
||||
"value": channels
|
||||
})
|
||||
end if
|
||||
|
||||
id += 1
|
||||
end for
|
||||
return id
|
||||
end function
|
||||
|
||||
function generateVideoAdaptationSets(xml as object, videoMimeTypes as object, videoStreams as object, id as integer) as integer
|
||||
for each mimeType in videoMimeTypes
|
||||
if xml.Node("AdaptationSet", {
|
||||
"id": `${id}`
|
||||
"mimeType": mimeType
|
||||
"startWithSAP": "1"
|
||||
"subsegmentAlignment": "true"
|
||||
})
|
||||
|
||||
for i = 0 to videoStreams.Count() - 1
|
||||
stream = videoStreams[i]
|
||||
streamMimeType = stream.type.Tokenize(";")[0]
|
||||
if streamMimeType <> mimeType
|
||||
continue for
|
||||
for each stream in group
|
||||
representationId = stream.itag
|
||||
if IsAssociativeArray(stream.audioTrack) and IsString(stream.audioTrack.id)
|
||||
representationId = `${representationId}-${stream.audioTrack.id}`
|
||||
end if
|
||||
|
||||
codecs = stream.type.split("codecs=")[1]
|
||||
if codecs.startsWith(`"`)
|
||||
codecs = codecs.mid(1)
|
||||
end if
|
||||
if codecs.endsWith(`"`)
|
||||
codecs = codecs.left(codecs.len() - 1)
|
||||
if stream.isDrc = true
|
||||
representationId = `${representationId}-drc`
|
||||
end if
|
||||
|
||||
representationAttributes = {
|
||||
"id": stream.itag
|
||||
"codecs": codecs
|
||||
"startWithSAP": "1"
|
||||
"maxPlayoutRate": "1"
|
||||
"id": representationId
|
||||
"bandwidth": stream.bitrate
|
||||
}
|
||||
if stream.width <> invalid
|
||||
representationAttributes["width"] = `${stream.width}`
|
||||
if hoisted["codecs"] = invalid and (stream.type.inStr("codecs=") <> -1)
|
||||
representationAttributes["codecs"] = stream.type.split("codecs=")[1].replace(`"`, "").replace(`"`, "")
|
||||
end if
|
||||
if stream.height <> invalid
|
||||
representationAttributes["height"] = `${stream.height}`
|
||||
end if
|
||||
if stream.fps <> invalid
|
||||
representationAttributes["frameRate"] = `${stream.fps}`
|
||||
if hoisted["audioSampleRate"] = invalid
|
||||
representationAttributes["audioSamplingRate"] = stream.audioSampleRate
|
||||
end if
|
||||
|
||||
if xml.Node("Representation", representationAttributes)
|
||||
m.AddColorInfo(stream, xml)
|
||||
|
||||
if StringUtils.IsNullOrEmpty(stream.url)
|
||||
xml.Comment(`[ERROR] Stream.url is null or empty for itag: ${stream.itag}`)
|
||||
else if stream.url.InStr("yt_live_broadcast") <> -1 or stream.url.InStr("yt_premiere_broadcast") <> -1
|
||||
xml.Comment(`[WARN] Stream URL indicates a live broadcast for itag: ${stream.itag}`)
|
||||
end if
|
||||
xml.TextNode("BaseURL", ValidString(stream.url))
|
||||
|
||||
if StringUtils.IsNullOrEmpty(stream.index) or StringUtils.IsNullOrEmpty(stream.init)
|
||||
xml.Comment(`[ERROR] Stream index: ${stream.index}, init: ${stream.init} is invalid for itag: ${stream.itag}`)
|
||||
end if
|
||||
if xml.Node("SegmentBase", { "indexRange": stream.index })
|
||||
xml.EmptyNode("Initialization", { "range": stream.init })
|
||||
|
||||
xml.End()
|
||||
if hoisted["AudioChannelConfiguration"] = invalid and IsInt(stream.audioChannels)
|
||||
xml.EmptyNode("AudioChannelConfiguration", {
|
||||
"schemeIdUri": "urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
|
||||
"value": stream.audioChannels
|
||||
})
|
||||
end if
|
||||
|
||||
m.GenerateSegmentInformation(xml, stream, metadata)
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
end for
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
id += 1
|
||||
end for
|
||||
return id
|
||||
end function
|
||||
|
||||
function GenerateVideoAdaptationSets(xml as object, videoGroups as object, id as integer, metadata as object) as integer
|
||||
for each group in videoGroups
|
||||
firstFormat = group[0]
|
||||
hoisted = {}
|
||||
|
||||
adaptationSetAttributes = {
|
||||
"id": `${id}`
|
||||
"mimeType": firstFormat.type.Tokenize(";")[0]
|
||||
"startWithSAP": "1"
|
||||
"subsegmentAlignment": "true"
|
||||
"maxPlayoutRate": "1"
|
||||
"contentType": "video"
|
||||
}
|
||||
|
||||
' Hoist common attributes
|
||||
codecs = m.HoistCodecs(group, hoisted)
|
||||
if IsString(codecs)
|
||||
adaptationSetAttributes["codecs"] = codecs
|
||||
end if
|
||||
fps = m.HoistNumberAttribute(group, "fps", hoisted)
|
||||
if fps <> invalid
|
||||
adaptationSetAttributes["frameRate"] = fps
|
||||
end if
|
||||
|
||||
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
||||
if IsArray(firstFormat.drmFamilies)
|
||||
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)
|
||||
|
||||
for each stream in group
|
||||
representationAttributes = {
|
||||
"id": stream.itag
|
||||
"bandwidth": stream.bitrate
|
||||
}
|
||||
if stream.width <> invalid
|
||||
representationAttributes["width"] = stream.width
|
||||
end if
|
||||
if stream.height <> invalid
|
||||
representationAttributes["height"] = stream.height
|
||||
end if
|
||||
if hoisted["codecs"] = invalid and (stream.type.inStr("codecs=") <> -1)
|
||||
representationAttributes["codecs"] = stream.type.split("codecs=")[1].replace(`"`, "").replace(`"`, "")
|
||||
end if
|
||||
if hoisted["fps"] = invalid
|
||||
representationAttributes["frameRate"] = stream.fps
|
||||
end if
|
||||
|
||||
if xml.Node("Representation", representationAttributes)
|
||||
m.GenerateSegmentInformation(xml, stream, metadata)
|
||||
xml.End()
|
||||
end if
|
||||
end for
|
||||
@@ -247,7 +460,159 @@ class DashManifest
|
||||
return id
|
||||
end function
|
||||
|
||||
function generateImageAdaptationSets(xml as object, storyboards as object, id as integer) as integer
|
||||
function GenerateSegmentInformation(xml as object, stream as object, metadata as object) as void
|
||||
if StringUtils.IsNullOrEmpty(stream.url)
|
||||
xml.Comment(`[ERROR] Stream.url is null or empty for itag: ${stream.itag}`)
|
||||
end if
|
||||
|
||||
if metadata.isPostLiveDvr = true
|
||||
if not IsInt(stream.targetDurationSec)
|
||||
xml.Comment(`[ERROR] Post-Live DVR stream missing targetDurationSec for itag: ${stream.itag}`)
|
||||
return
|
||||
end if
|
||||
|
||||
if stream.targetDurationSec < 1
|
||||
xml.Comment(`[ERROR] Post-Live DVR stream has invalid targetDurationSec (${stream.targetDurationSec}) for itag: ${stream.itag}`)
|
||||
return
|
||||
end if
|
||||
|
||||
postLiveDvrSegmentCount = metadata.postLiveDvrSegmentCount
|
||||
if not IsInt(postLiveDvrSegmentCount)
|
||||
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
|
||||
totalDurationMs = m.GetDuration(metadata) * 1000.0
|
||||
postLiveDvrSegmentCount = MathUtils.Max(Fix(totalDurationMs / (stream.targetDurationSec * 1000)), 1)
|
||||
xml.Comment(`[INFO] Guessing postLiveDvrSegmentCount as ${postLiveDvrSegmentCount} for itag: ${stream.itag}`)
|
||||
end if
|
||||
|
||||
duration = stream.targetDurationSec * 1000
|
||||
repeatCount = postLiveDvrSegmentCount - 1
|
||||
if xml.Node("SegmentTemplate", { "initialization": `${stream.url}&sq=0`, "media": `${stream.url}&sq=$Number$`, "timescale": "1000" })
|
||||
if xml.Node("SegmentTimeline")
|
||||
xml.EmptyNode("S", { "d": duration, "r": repeatCount })
|
||||
xml.End()
|
||||
end if
|
||||
xml.End()
|
||||
end if
|
||||
else if stream.isTypeOTF = true
|
||||
segmentDurations = stream.otfSegmentDurations
|
||||
if not IsArray(segmentDurations)
|
||||
xml.Comment(`[ERROR] OTF stream missing otfSegmentDurations for itag: ${stream.itag}`)
|
||||
return
|
||||
end if
|
||||
|
||||
if xml.Node("SegmentTemplate", { "initialization": `${stream.url}&sq=0`, "media": `${stream.url}&sq=$Number$`, "timescale": "1000" })
|
||||
if xml.Node("SegmentTimeline")
|
||||
if segmentDurations.Count() = 0
|
||||
xml.Comment(`[ERROR] OTF stream has empty otfSegmentDurations for itag: ${stream.itag}`)
|
||||
end if
|
||||
for each segment in segmentDurations
|
||||
xml.EmptyNode("S", segment)
|
||||
end for
|
||||
xml.End()
|
||||
end if
|
||||
xml.End()
|
||||
end if
|
||||
else
|
||||
xml.TextNode("BaseURL", ValidString(stream.url))
|
||||
|
||||
if StringUtils.IsNullOrEmpty(stream.index) or StringUtils.IsNullOrEmpty(stream.init)
|
||||
xml.Comment(`[ERROR] Stream index: ${stream.index}, init: ${stream.init} is invalid for itag: ${stream.itag}`)
|
||||
end if
|
||||
if xml.Node("SegmentBase", { "indexRange": stream.index })
|
||||
xml.EmptyNode("Initialization", { "range": stream.init })
|
||||
xml.End()
|
||||
end if
|
||||
end if
|
||||
end function
|
||||
|
||||
function HoistCodecs(formats as object, hoisted as object) as dynamic
|
||||
if formats.Count() < 2
|
||||
return invalid
|
||||
end if
|
||||
|
||||
firstCodec = formats[0].type.split("codecs=")[1]
|
||||
for i = 1 to formats.Count() - 1
|
||||
currentCodec = formats[i].type.split("codecs=")[1]
|
||||
if firstCodec <> currentCodec
|
||||
return invalid
|
||||
end if
|
||||
end for
|
||||
|
||||
hoisted["codecs"] = true
|
||||
return firstCodec.replace(`"`, "").replace(`"`, "")
|
||||
end function
|
||||
|
||||
function HoistNumberAttribute(formats as object, property as string, hoisted as object) as dynamic
|
||||
if formats.Count() < 2
|
||||
return invalid
|
||||
end if
|
||||
|
||||
firstFormat = formats[0]
|
||||
if firstFormat[property] = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
firstValue = firstFormat[property]
|
||||
for i = 1 to formats.Count() - 1
|
||||
otherValue = formats[i][property]
|
||||
if type(otherValue) <> type(firstValue) or otherValue <> firstValue
|
||||
return invalid
|
||||
end if
|
||||
end for
|
||||
|
||||
hoisted[property] = true
|
||||
return firstValue
|
||||
end function
|
||||
|
||||
function HoistAudioChannels(formats as object, hoisted as object) as dynamic
|
||||
if formats.Count() < 2
|
||||
return invalid
|
||||
end if
|
||||
|
||||
firstValue = formats[0].audioChannels
|
||||
if firstValue = invalid
|
||||
firstValue = 2
|
||||
end if
|
||||
|
||||
for i = 1 to formats.Count() - 1
|
||||
currentValue = formats[i].audioChannels
|
||||
if currentValue = invalid
|
||||
currentValue = 2
|
||||
end if
|
||||
if currentValue <> firstValue
|
||||
return invalid
|
||||
end if
|
||||
end for
|
||||
|
||||
hoisted["AudioChannelConfiguration"] = true
|
||||
return firstValue
|
||||
end function
|
||||
|
||||
function GetTrackRoles(format as object) as object
|
||||
roles = []
|
||||
if format.isOriginal = true
|
||||
roles.Push("main")
|
||||
else
|
||||
roles.Push("alternate")
|
||||
end if
|
||||
|
||||
if format.isDubbed = true or format.isAutoDubbed = true
|
||||
roles.Push("dub")
|
||||
end if
|
||||
|
||||
if format.isDescriptive = true
|
||||
roles.Push("description")
|
||||
end if
|
||||
|
||||
if format.isDrc = true
|
||||
roles.Push("enhanced-audio-intelligibility")
|
||||
end if
|
||||
|
||||
return roles
|
||||
end function
|
||||
|
||||
function GenerateImageAdaptationSets(xml as object, storyboards as object, id as integer) as integer
|
||||
' https://developer.roku.com/en-ca/docs/developer-program/media-playback/trick-mode/hls-and-dash.md#dash-standard-thumbnail-tiles
|
||||
for i = storyboards.Count() - 1 to 0 step -1
|
||||
storyboard = storyboards[i]
|
||||
@@ -322,169 +687,6 @@ class DashManifest
|
||||
return id
|
||||
end function
|
||||
|
||||
function getAudioStreams(streams as object) as object
|
||||
audioStreams = []
|
||||
for i = 0 to streams.Count() - 1
|
||||
stream = streams[i]
|
||||
if stream.type.startsWith("audio/")
|
||||
if StringUtils.IsNullOrEmpty(stream.bitrate)
|
||||
LogWarnNoTelemetry("Invalid audio stream bitrate, itag:", stream.itag)
|
||||
continue for
|
||||
end if
|
||||
if StringUtils.IsNullOrEmpty(stream.init)
|
||||
LogWarnNoTelemetry("Invalid audio stream init, itag:", stream.itag)
|
||||
continue for
|
||||
end if
|
||||
if StringUtils.IsNullOrEmpty(stream.index)
|
||||
LogWarnNoTelemetry("Invalid audio stream index, itag:", stream.itag)
|
||||
continue for
|
||||
end if
|
||||
stream.languageInfo = m.ParseAudioLanguage(stream.url)
|
||||
audioStreams.Push(stream)
|
||||
end if
|
||||
end for
|
||||
|
||||
audioStreams.SortBy("bitrate", "r")
|
||||
return audioStreams
|
||||
end function
|
||||
|
||||
function getVideoStreams(streams as object, qualityFilter as object) as object
|
||||
videoStreams = []
|
||||
for i = 0 to streams.Count() - 1
|
||||
if not m.isVideoFormatIncluded(streams[i], qualityFilter)
|
||||
continue for
|
||||
end if
|
||||
|
||||
stream = streams[i]
|
||||
if stream.type.startsWith("video/")
|
||||
if StringUtils.IsNullOrEmpty(stream.bitrate)
|
||||
LogWarnNoTelemetry("Invalid video stream bitrate, itag:", stream.itag)
|
||||
continue for
|
||||
end if
|
||||
if StringUtils.IsNullOrEmpty(stream.init)
|
||||
LogWarnNoTelemetry("Invalid video stream init, itag:", stream.itag)
|
||||
continue for
|
||||
end if
|
||||
if StringUtils.IsNullOrEmpty(stream.index)
|
||||
LogWarnNoTelemetry("Invalid video stream index, itag:", stream.itag)
|
||||
continue for
|
||||
end if
|
||||
|
||||
if (stream.width = invalid or stream.height = invalid) and not StringUtils.IsNullOrEmpty(stream.size)
|
||||
if stream.size.instr("x") > 0
|
||||
parts = stream.size.Tokenize("x")
|
||||
if parts.Count() = 2
|
||||
stream.width = ValidInt(parts[0].toInt())
|
||||
stream.height = ValidInt(parts[1].toInt())
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
videoStreams.Push(stream)
|
||||
end if
|
||||
end for
|
||||
|
||||
videoStreams.SortBy("bitrate", "r")
|
||||
return videoStreams
|
||||
end function
|
||||
|
||||
function isVideoFormatIncluded(stream as object, qualityFilter as object) as boolean
|
||||
if qualityFilter.Count() = 0
|
||||
return true
|
||||
end if
|
||||
|
||||
qualityLabel = stream.qualityLabel
|
||||
if not StringUtils.IsNullOrEmpty(qualityLabel)
|
||||
pIndex = qualityLabel.InStr("p")
|
||||
if pIndex <> -1
|
||||
qualityLabel = qualityLabel.Mid(0, pIndex)
|
||||
end if
|
||||
if qualityFilter[qualityLabel] = true
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
resolution = stream.resolution
|
||||
if not StringUtils.IsNullOrEmpty(resolution)
|
||||
pIndex = resolution.InStr("p")
|
||||
if pIndex <> -1
|
||||
resolution = resolution.Mid(0, pIndex)
|
||||
end if
|
||||
if qualityFilter[resolution] = true
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
size = stream.size
|
||||
if not StringUtils.IsNullOrEmpty(size)
|
||||
size = size.Split("x")
|
||||
if size.Count() = 2
|
||||
if qualityFilter[size[1]] = true
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
return false
|
||||
end function
|
||||
|
||||
function getMimeTypes(streams as object) as object
|
||||
mimeTypes = {}
|
||||
for i = 0 to streams.Count() - 1
|
||||
stream = streams[i]
|
||||
mimeType = stream.type.Tokenize(";")[0]
|
||||
mimeTypes[mimeType] = true
|
||||
end for
|
||||
return mimeTypes.Keys()
|
||||
end function
|
||||
|
||||
function getMimeTypeLanguageCombos(streams as object) as object
|
||||
types = {}
|
||||
for i = 0 to streams.Count() - 1
|
||||
stream = streams[i]
|
||||
mimeType = stream.type.Tokenize(";")[0]
|
||||
types[`${mimeType}-${stream.languageInfo.lang}-${stream.languageInfo.acont}`] = {
|
||||
"mimeType": mimeType
|
||||
"lang": stream.languageInfo.lang
|
||||
"acont": stream.languageInfo.acont
|
||||
}
|
||||
end for
|
||||
|
||||
combos = []
|
||||
for each t in types
|
||||
combos.Push(types[t])
|
||||
end for
|
||||
|
||||
return combos
|
||||
end function
|
||||
|
||||
function ParseAudioLanguage(url as dynamic) as object
|
||||
result = { lang: "", acont: "" }
|
||||
if StringUtils.IsNullOrEmpty(url)
|
||||
return result
|
||||
end if
|
||||
queryParams = UrlUtils.ParseQueryComponents(url)
|
||||
if StringUtils.IsNullOrEmpty(queryParams["xtags"])
|
||||
return result
|
||||
end if
|
||||
|
||||
xtags = queryParams["xtags"].split(":")
|
||||
for each xtag in xtags
|
||||
if xtag.instr("=") > 0
|
||||
parts = xtag.split("=")
|
||||
if parts.Count() = 2
|
||||
if parts[0] = "lang"
|
||||
result["lang"] = parts[1]
|
||||
end if
|
||||
if parts[0] = "acont"
|
||||
result["acont"] = parts[1]
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
return result
|
||||
end function
|
||||
|
||||
function AddColorInfo(videoStream as object, xml as object) as void
|
||||
if videoStream.colorInfo = invalid
|
||||
return
|
||||
@@ -493,7 +695,7 @@ class DashManifest
|
||||
if videoStream.colorInfo.primaries <> invalid
|
||||
primaries = m.colorInfo.primaries[videoStream.colorInfo.primaries]
|
||||
if primaries <> invalid
|
||||
xml.EmptyNode("EssentialProperty", {
|
||||
xml.EmptyNode("SupplementalProperty", {
|
||||
"schemeIdUri": "urn:mpeg:mpegB:cicp:ColourPrimaries"
|
||||
"value": primaries
|
||||
})
|
||||
@@ -505,7 +707,7 @@ class DashManifest
|
||||
if videoStream.colorInfo.transferCharacteristics <> invalid
|
||||
transferCharacteristics = m.colorInfo.transferCharacteristics[videoStream.colorInfo.transferCharacteristics]
|
||||
if transferCharacteristics <> invalid
|
||||
xml.EmptyNode("EssentialProperty", {
|
||||
xml.EmptyNode("SupplementalProperty", {
|
||||
"schemeIdUri": "urn:mpeg:mpegB:cicp:TransferCharacteristics"
|
||||
"value": transferCharacteristics
|
||||
})
|
||||
@@ -517,7 +719,7 @@ class DashManifest
|
||||
if videoStream.colorInfo.matrixCoefficients <> invalid
|
||||
matrixCoefficients = m.colorInfo.matrixCoefficients[videoStream.colorInfo.matrixCoefficients]
|
||||
if matrixCoefficients <> invalid
|
||||
xml.EmptyNode("EssentialProperty", {
|
||||
xml.EmptyNode("SupplementalProperty", {
|
||||
"schemeIdUri": "urn:mpeg:mpegB:cicp:MatrixCoefficients"
|
||||
"value": matrixCoefficients
|
||||
})
|
||||
@@ -527,4 +729,81 @@ class DashManifest
|
||||
end if
|
||||
end function
|
||||
|
||||
function GetXtagsInfo(format as object) as object
|
||||
result = {
|
||||
lang: ""
|
||||
acont: ""
|
||||
isDrc: false
|
||||
isDubbed: false
|
||||
isAutoDubbed: false
|
||||
isDescriptive: false
|
||||
isSecondary: false
|
||||
isOriginal: false
|
||||
}
|
||||
|
||||
if StringUtils.IsNullOrEmpty(format.url)
|
||||
return result
|
||||
end if
|
||||
|
||||
' Technically format.xtags can be used, but it is protobuf encoded
|
||||
' so this is simpler. Also, this is consistent for both local
|
||||
' Innertube and Invidious.
|
||||
queryParams = UrlUtils.ParseQueryComponents(format.url)
|
||||
xtagsString = queryParams["xtags"]
|
||||
if StringUtils.IsNullOrEmpty(xtagsString)
|
||||
return result
|
||||
end if
|
||||
|
||||
tags = {}
|
||||
xtagsList = xtagsString.split(":")
|
||||
for each xtag in xtagsList
|
||||
pair = xtag.split("=")
|
||||
if pair.Count() = 2
|
||||
tags[pair[0]] = pair[1]
|
||||
end if
|
||||
end for
|
||||
|
||||
for each key in tags
|
||||
if key = "lang"
|
||||
result.lang = tags[key]
|
||||
else if key = "acont"
|
||||
result.acont = tags[key]
|
||||
else if key = "drc" and tags[key] = "1"
|
||||
result.isDrc = true
|
||||
end if
|
||||
end for
|
||||
|
||||
if format.isDrc = true
|
||||
result.isDrc = true
|
||||
end if
|
||||
|
||||
if result.acont = "dubbed"
|
||||
result.isDubbed = true
|
||||
else if result.acont = "dubbed-auto"
|
||||
result.isAutoDubbed = true
|
||||
else if result.acont = "descriptive"
|
||||
result.isDescriptive = true
|
||||
else if result.acont = "secondary"
|
||||
result.isSecondary = true
|
||||
end if
|
||||
|
||||
if result.acont = "original" or (not result.isDubbed and not result.isAutoDubbed and not result.isDescriptive and not result.isSecondary)
|
||||
result.isOriginal = true
|
||||
end if
|
||||
|
||||
return result
|
||||
end function
|
||||
|
||||
function GetDrmSystemId(drmFamily as dynamic) as dynamic
|
||||
if not IsString(drmFamily)
|
||||
return invalid
|
||||
end if
|
||||
if drmFamily = "WIDEVINE"
|
||||
return "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
|
||||
else if drmFamily = "PLAYREADY"
|
||||
return "9a04f079-9840-4286-ab92-e65be0885f95"
|
||||
end if
|
||||
return invalid
|
||||
end function
|
||||
|
||||
end class
|
||||
@@ -1,23 +1,23 @@
|
||||
const PLAYLET_SUPPORT_SERVER = "https://playlet-v8556.ondigitalocean.app"
|
||||
|
||||
const VIDEO_PLAYER_USER_AGENT = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0"
|
||||
const VIDEO_PLAYER_USER_AGENT = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"
|
||||
|
||||
const INNERTUBE_IOS_CLIENT_NAME = "5"
|
||||
const INNERTUBE_IOS_CLIENT_VERSION = "20.39.4"
|
||||
const INNERTUBE_IOS_CLIENT_VERSION = "21.16.2"
|
||||
const INNERTUBE_IOS_DEVICE_MODEL = "iPhone16,2"
|
||||
const INNERTUBE_IOS_OS_VERSION = "18.1"
|
||||
const INNERTUBE_IOS_USER_AGENT = "com.google.ios.youtube/20.39.4 (iPhone16,2; U; CPU iOS 18_1_0 like Mac OS X)"
|
||||
const INNERTUBE_IOS_USER_AGENT = "com.google.ios.youtube/21.16.2 (iPhone16,2; U; CPU iOS 18_1_0 like Mac OS X)"
|
||||
|
||||
const INNERTUBE_WEB_BROWSER_NAME = "Chrome"
|
||||
const INNERTUBE_WEB_BROWSER_VERSION = "140.0.0.0"
|
||||
const INNERTUBE_WEB_BROWSER_VERSION = "147.0.0.0"
|
||||
const INNERTUBE_WEB_CLIENT_NAME = "1"
|
||||
const INNERTUBE_WEB_CLIENT_VERSION = "2.20250927.00.01"
|
||||
const INNERTUBE_WEB_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0"
|
||||
const INNERTUBE_WEB_CLIENT_VERSION = "2.20260424.01.00"
|
||||
const INNERTUBE_WEB_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36"
|
||||
|
||||
const INNERTUBE_TV_BROWSER_NAME = "SamsungBrowser"
|
||||
const INNERTUBE_TV_BROWSER_VERSION = "9.2"
|
||||
const INNERTUBE_TV_CLIENT_NAME = "2"
|
||||
const INNERTUBE_TV_CLIENT_VERSION = "7.20251015.07.00"
|
||||
const INNERTUBE_TV_CLIENT_VERSION = "7.20260422.12.00"
|
||||
const INNERTUBE_TV_DEVICE_MAKE = "Samsung"
|
||||
const INNERTUBE_TV_DEVICE_MODEL = "SmartTV"
|
||||
const INNERTUBE_TV_OS_NAME = "Tizen"
|
||||
|
||||
@@ -81,16 +81,16 @@ namespace InnertubeService
|
||||
end if
|
||||
|
||||
playerResponseJson = playerResponse.Json()
|
||||
isLive = Innertube.IsLiveStream(playerResponseJson)
|
||||
if isLive and client = Innertube.ClientType.Tv
|
||||
LogDebug("Live video detected, falling back to iOS for HLS streams.")
|
||||
notDashSupported = Innertube.IsLiveStream(playerResponseJson)
|
||||
if notDashSupported and client = Innertube.ClientType.Tv
|
||||
LogDebug("Falling back to iOS client for live video.")
|
||||
isLoggedIn = Innertube.ParseIsLoggedIn(playerResponseJson)
|
||||
playbackTrackingUrls = Innertube.ParsePlaybackTrackingUrls(playerResponseJson, isLoggedIn)
|
||||
client = Innertube.ClientType.IOS
|
||||
continue while
|
||||
end if
|
||||
|
||||
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerRequest, playerResponse, {}, cancellation)
|
||||
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerRequest, playerResponse, client, cancellation)
|
||||
|
||||
if parsedResponse.error = invalid
|
||||
exit while
|
||||
@@ -267,61 +267,6 @@ namespace InnertubeService
|
||||
return Innertube.Search(query, options)
|
||||
end function
|
||||
|
||||
function GetTrending(options = invalid as object) as object
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
trendingType = LCase(OptionUtils.GetOrDefault(options, "type", ""))
|
||||
disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
|
||||
raw = OptionUtils.GetOrDefault(options, "raw", false)
|
||||
|
||||
params = ""
|
||||
if trendingType = "music"
|
||||
' {"44:proto": {"3:string": "ytma_charts"}}
|
||||
params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
|
||||
else if trendingType = "gaming"
|
||||
' {"44:proto": {"3:string": "gaming_corpus_most_popular"}}
|
||||
params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
|
||||
else if trendingType = "movies"
|
||||
' {"44:proto": {"3:string": "trailers"}}
|
||||
params = "4gIKGgh0cmFpbGVycw%3D%3D"
|
||||
end if
|
||||
|
||||
request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, { params: params })
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
if raw
|
||||
request.LogCurlCommand(true)
|
||||
request.NoCache()
|
||||
end if
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
return {
|
||||
error: response.ErrorMessage()
|
||||
}
|
||||
end if
|
||||
|
||||
if raw
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
feeds = Innertube.ParseResponseDataForFeeds(response.Json(), {
|
||||
response: response
|
||||
disableCreatorOnTheRise: true
|
||||
disableShorts: disableShorts
|
||||
})
|
||||
|
||||
result = {
|
||||
feeds: feeds
|
||||
}
|
||||
|
||||
cacheControl = Innertube.ParseResponseForCacheControl(response)
|
||||
if cacheControl <> invalid
|
||||
result["cache-control"] = cacheControl
|
||||
end if
|
||||
|
||||
return result
|
||||
end function
|
||||
|
||||
function GetHome(options = invalid as object) as object
|
||||
return GetBrowseAuthenticatedPage("FEwhat_to_watch", options)
|
||||
end function
|
||||
@@ -338,12 +283,12 @@ namespace InnertubeService
|
||||
return GetBrowseAuthenticatedPage("FEplaylist_aggregation", options)
|
||||
end function
|
||||
|
||||
function GetBrowseAuthenticatedPage(browserId as string, options = invalid as object) as object
|
||||
function GetBrowseAuthenticatedPage(browseId as string, options = invalid as object) as object
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
|
||||
|
||||
request = Innertube.CreateBrowseRequest(browserId, Innertube.ClientType.Tv, options)
|
||||
request = Innertube.CreateBrowseRequest(browseId, Innertube.ClientType.Tv, options)
|
||||
|
||||
if accessToken <> invalid
|
||||
request.Header("Authorization", "Bearer " + accessToken)
|
||||
@@ -360,6 +305,7 @@ namespace InnertubeService
|
||||
feeds = Innertube.ParseResponseDataForFeeds(response.Json(), {
|
||||
response: response
|
||||
disableShorts: disableShorts
|
||||
browseId: browseId
|
||||
})
|
||||
|
||||
result = {
|
||||
@@ -416,6 +362,7 @@ namespace InnertubeService
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
|
||||
cpn = OptionUtils.Get(options, "cpn")
|
||||
|
||||
videostatsPlaybackUrl = videostatsPlaybackUrl.replace("https://s.", "https://www.")
|
||||
queryParams = UrlUtils.ParseQueryComponents(videostatsPlaybackUrl)
|
||||
@@ -423,8 +370,8 @@ namespace InnertubeService
|
||||
queryParams["cbrver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||
queryParams["cver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||
queryParams["ver"] = "2"
|
||||
queryParams["cpn"] = InnertubeService.CreateClientPlaybackNonce()
|
||||
queryParams["cmt"] = 0
|
||||
queryParams["cmt"] = "0"
|
||||
queryParams["cpn"] = cpn
|
||||
queryParams["final"] = "1"
|
||||
videostatsPlaybackUrl = UrlUtils.SetQueryParams(videostatsPlaybackUrl, queryParams)
|
||||
|
||||
@@ -453,6 +400,7 @@ namespace InnertubeService
|
||||
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
|
||||
|
||||
timeStr = time.ToStr("%.3f")
|
||||
cpn = OptionUtils.Get(options, "cpn")
|
||||
|
||||
videostatsWatchtimeUrl = videostatsWatchtimeUrl.replace("https://s.", "https://www.")
|
||||
queryParams = UrlUtils.ParseQueryComponents(videostatsWatchtimeUrl)
|
||||
@@ -460,11 +408,11 @@ namespace InnertubeService
|
||||
queryParams["cbrver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||
queryParams["cver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||
queryParams["ver"] = "2"
|
||||
queryParams["cpn"] = InnertubeService.CreateClientPlaybackNonce()
|
||||
queryParams["cmt"] = 0
|
||||
queryParams["final"] = "1"
|
||||
queryParams["cpn"] = cpn
|
||||
queryParams["cmt"] = "0"
|
||||
queryParams["st"] = timeStr
|
||||
queryParams["et"] = timeStr
|
||||
queryParams["final"] = "1"
|
||||
videostatsWatchtimeUrl = UrlUtils.SetQueryParams(videostatsWatchtimeUrl, queryParams)
|
||||
|
||||
request = HttpClient.Get(videostatsWatchtimeUrl)
|
||||
@@ -521,7 +469,7 @@ namespace InnertubeService
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
result = Innertube.ParseChannelPageResponseData(response.Json(), response)
|
||||
result = Innertube.ParseChannelPageResponseData(channelId, response.Json(), response)
|
||||
if result.authorId = invalid and result.error = invalid
|
||||
result["authorId"] = channelId
|
||||
end if
|
||||
@@ -663,7 +611,7 @@ namespace InnertubeService
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
result = Innertube.ParsePlaylistPageResponseData(response.Json(), response)
|
||||
result = Innertube.ParsePlaylistPageResponseData(playlistId, response.Json(), response)
|
||||
|
||||
if result.playlistId = invalid and result.error = invalid
|
||||
result["playlistId"] = playlistId
|
||||
|
||||
@@ -86,6 +86,7 @@ namespace Innertube
|
||||
"richGridRenderer": ParseRichGridRenderer
|
||||
"richItemRenderer": ParseRichItemRenderer
|
||||
"feedFilterChipBarRenderer": ParseFeedFilterChipBarRenderer
|
||||
"chipBarViewModel": ParseChipBarViewModel
|
||||
"continuationItemRenderer": ParseContinuationItemRenderer
|
||||
"appendContinuationItemsAction": ParseAppendContinuationItemsAction
|
||||
"reloadContinuationItemsCommand": ParseReloadContinuationItemsCommand
|
||||
@@ -103,9 +104,8 @@ namespace Innertube
|
||||
' Ignored nodes:
|
||||
' TODO:P2 handle navigateAction - which are usually a redirect
|
||||
' "navigateAction": ParseNotImplemented
|
||||
' TODO:P2 radioRenderer seems like a Mix https://github.com/iBicha/playlet/issues/709
|
||||
"radioRenderer": ParseRadioRenderer
|
||||
' "compactRadioRenderer": ParseNotImplemented
|
||||
"compactRadioRenderer": ParseCompactRadioRenderer
|
||||
' TODO:P2 A carousel of videos, found on the home tab of a channel.
|
||||
' Should probably be parsed.
|
||||
' "carouselItemRenderer": ParseNotImplemented
|
||||
@@ -164,6 +164,7 @@ namespace Innertube
|
||||
"emergencyOneboxRenderer": ParseNotImplemented
|
||||
' Suicide & crisis lifeline, within search
|
||||
"searchFrictionViewModel": ParseNotImplemented
|
||||
"shoppingTimelyShelfViewModel": ParseNotImplemented
|
||||
"backstagePostRenderer": ParseNotImplemented
|
||||
"backstagePostThreadRenderer": ParseNotImplemented
|
||||
"counterfactualRenderer": ParseNotImplemented
|
||||
@@ -252,6 +253,15 @@ namespace Innertube
|
||||
context.currentFeed.sortOptions = sortOptions
|
||||
end if
|
||||
end if
|
||||
|
||||
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
|
||||
if IsString(continuation)
|
||||
if not StringUtils.IsNullOrEmpty(context.currentFeed.continuation)
|
||||
StartNewFeed("", context)
|
||||
end if
|
||||
context.currentFeed.continuation = continuation
|
||||
end if
|
||||
|
||||
return nodeData["contents"]
|
||||
end function
|
||||
|
||||
@@ -277,6 +287,17 @@ namespace Innertube
|
||||
end if
|
||||
end if
|
||||
|
||||
if ValidString(context.browseId) = "FEwhat_to_watch"
|
||||
' shelfs with a heroCarouselHeaderRenderer are usually big carousels at the top of the home page
|
||||
' to advertise some paid content.
|
||||
' They hijack the shelf we want to parse (e.g. Recommended videos).
|
||||
heroCarouselHeader = ObjectUtils.Dig(nodeData, ["headerRenderer", "heroCarouselHeaderRenderer"])
|
||||
if heroCarouselHeader <> invalid
|
||||
LogInfo("Skipping shelf with heroCarouselHeaderRenderer")
|
||||
return invalid
|
||||
end if
|
||||
end if
|
||||
|
||||
' TODO: handle shelfRenderer.title
|
||||
' TODO: handle shelfRenderer.headerRenderer.shelfHeaderRenderer.avatarLockup.avatarLockupRenderer.title
|
||||
return nodeData["content"]
|
||||
@@ -1025,6 +1046,36 @@ namespace Innertube
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function ParseCompactRadioRenderer(nodeData as object, context as object) as object
|
||||
playlistId = nodeData["playlistId"]
|
||||
if not IsString(playlistId)
|
||||
Warning("Invalid playlist ID in compactRadioRenderer", nodeData, context)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
videoCountText = ParseText(nodeData["videoCountText"])
|
||||
if videoCountText = ""
|
||||
videoCountText = ParseText(nodeData["videoCountShortText"])
|
||||
end if
|
||||
|
||||
playlist = {
|
||||
"type": "playlist"
|
||||
"playlistId": playlistId
|
||||
"title": ParseText(nodeData["title"])
|
||||
"playlistThumbnail": ObjectUtils.Dig(nodeData, ["thumbnail", "thumbnails", 0, "url"])
|
||||
"videoCountText": videoCountText
|
||||
}
|
||||
|
||||
' Mixes have a videoId, which is the first video in the mix
|
||||
videoId = ObjectUtils.Dig(nodeData, ["navigationEndpoint", "watchEndpoint", "videoId"])
|
||||
if IsString(videoId)
|
||||
playlist["videoId"] = videoId
|
||||
end if
|
||||
|
||||
PushFeedItem(playlist, context)
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function ParseGridShelfViewModel(nodeData as object, _context as object) as object
|
||||
return nodeData["contents"]
|
||||
end function
|
||||
@@ -1400,6 +1451,10 @@ namespace Innertube
|
||||
return TileRendererTypeChannel(nodeData, context)
|
||||
else if contentType = "TILE_CONTENT_TYPE_EDU"
|
||||
' Not implemented yet - https://github.com/iBicha/playlet/issues/751
|
||||
' Basically a tile that redirects to a search with predifined querty.
|
||||
' To support, Playlet will probably need to implement an independent
|
||||
' search view that can be opened from anywhere.
|
||||
return invalid
|
||||
end if
|
||||
|
||||
Warning(`Unknown content type: ${contentType}`, nodeData, context)
|
||||
@@ -1666,13 +1721,64 @@ namespace Innertube
|
||||
end function
|
||||
|
||||
function ParseRichGridRenderer(nodeData as object, context as object) as object
|
||||
feedFilterChipBarRenderer = ObjectUtils.Dig(nodeData, ["header", "feedFilterChipBarRenderer"])
|
||||
header = nodeData["header"]
|
||||
feedFilterChipBarRenderer = invalid
|
||||
chipBarViewModel = invalid
|
||||
if IsAssociativeArray(header)
|
||||
feedFilterChipBarRenderer = header["feedFilterChipBarRenderer"]
|
||||
chipBarViewModel = header["chipBarViewModel"]
|
||||
end if
|
||||
|
||||
if feedFilterChipBarRenderer <> invalid
|
||||
ParseFeedFilterChipBarRenderer(feedFilterChipBarRenderer, context)
|
||||
else if chipBarViewModel <> invalid
|
||||
ParseChipBarViewModel(chipBarViewModel, context)
|
||||
end if
|
||||
return nodeData["contents"]
|
||||
end function
|
||||
|
||||
function ParseChipBarViewModel(nodeData as object, context as object) as object
|
||||
chips = ObjectUtils.Dig(nodeData, ["chips"])
|
||||
if not IsArray(chips)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
sortOptions = []
|
||||
for each chip in chips
|
||||
chipViewModel = chip["chipViewModel"]
|
||||
if not IsAssociativeArray(chipViewModel)
|
||||
continue for
|
||||
end if
|
||||
title = ValidString(chipViewModel["text"])
|
||||
isSelected = ValidBool(chipViewModel["selected"])
|
||||
token = invalid
|
||||
tapCommand = chipViewModel["tapCommand"]
|
||||
if IsAssociativeArray(tapCommand)
|
||||
innertubeCommand = tapCommand["innertubeCommand"]
|
||||
if IsAssociativeArray(innertubeCommand)
|
||||
continuationCommand = innertubeCommand["continuationCommand"]
|
||||
if IsAssociativeArray(continuationCommand)
|
||||
token = ValidString(continuationCommand["token"])
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
if title = "" or StringUtils.IsNullOrEmpty(token)
|
||||
continue for
|
||||
end if
|
||||
sortOptions.Push({
|
||||
"title": title
|
||||
"continuation": token
|
||||
"isSelected": isSelected
|
||||
})
|
||||
end for
|
||||
|
||||
if sortOptions.Count() > 0
|
||||
context.currentFeed.sortOptions = sortOptions
|
||||
end if
|
||||
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function ParseRichItemRenderer(nodeData as object, _context as object) as object
|
||||
return nodeData["content"]
|
||||
end function
|
||||
@@ -1893,6 +1999,8 @@ namespace Innertube
|
||||
function ParseCompactMovieRenderer(nodeData as object, context as object) as object
|
||||
videoId = nodeData["videoId"]
|
||||
if not IsString(videoId)
|
||||
' TODO:P2 Can be a show, example
|
||||
' {"badges":[{"metadataBadgeRenderer":{"accessibilityData":{"label":"Free with ads"},"label":"Free with ads","style":"BADGE_STYLE_TYPE_YPC","trackingParams":"CKQBEJaLARgJIhMI15bJgdLnkAMVoHtMCB0nGTYG"}},{"metadataBadgeRenderer":{"accessibilityData":{"label":"tv-g"},"label":"TV-G","style":"BADGE_STYLE_TYPE_MEDIA","trackingParams":"CKQBEJaLARgJIhMI15bJgdLnkAMVoHtMCB0nGTYG"}}],"navigationEndpoint":{"browseEndpoint":{"browseId":"SCLKZr4NmdhyFZXLCYhehRmg","params":"kgYcGhoSGFVDTEtacjRObWRoeUZaWExDWWhlaFJtZw%3D%3D"},"clickTrackingParams":"CKQBEJaLARgJIhMI15bJgdLnkAMVoHtMCB0nGTYGygEEl7wVRg==","commandMetadata":{"webCommandMetadata":{"apiUrl":"/youtubei/v1/browse","rootVe":6827,"url":"/show/SCLKZr4NmdhyFZXLCYhehRmg?sbp=GhoSGFVDTEtacjRObWRoeUZaWExDWWhlaFJtZw%253D%253D","webPageType":"WEB_PAGE_TYPE_BROWSE"}}},"thumbnail":{"thumbnails":[{"height":596,"url":"https://yt3.ggpht.com/KPRERPv8FmjHUtaEip00aL1RuIkU-0_YR4XrbzG_66s6kkm1sx9MtSJgzeYexpRVtXoN1P1OjQ=w1060-fcrop64=1,00000000ffffffff-k-c0xffffffff-no-nd-rj","width":1060}]},"thumbnailOverlays":[{"thumbnailOverlayBottomPanelRenderer":{"text":{"runs":[{"text":"4"},{"text":" seasons"}]}}}],"title":{"accessibility":{"accessibilityData":{"label":"Everything's Rosie 4 seasons"}},"simpleText":"Everything's Rosie"},"topMetadataItems":[{"simpleText":"Animation \u2022 2011"}],"trackingParams":"CKQBEJaLARgJIhMI15bJgdLnkAMVoHtMCB0nGTYG"}
|
||||
Warning("Invalid videoId in compactMovieRenderer", nodeData, context)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
import "pkg:/components/Services/Innertube/Context.bs"
|
||||
|
||||
namespace Innertube
|
||||
|
||||
' OTF (On-The-Fly?) segment info retrieval and parsing
|
||||
' When innertube returns adaptive formats, sometimes there's a property
|
||||
' attached to the object: adaptiveFormats[].type = "FORMAT_STREAM_TYPE_OTF".
|
||||
' When that happens, the segment info (durations, repeat counts) is not included
|
||||
' in the response. Instead, they are appended to the media init segment itself.
|
||||
' The init segment would contain video init information, which is binary, appended
|
||||
' with a text section in this format:
|
||||
' `Segment-Count: 731\r\n` +
|
||||
' `Segment-Durations-Ms: 5333,5334,5333(r=1),5334,5333(r=1),\r\n`
|
||||
' Because of this, the init segment needs to be downloaded to a tmp file, loaded in
|
||||
' a byte array, converted to hex, and parsed. Loading the file to ascii string directly
|
||||
' would not work because it would be truncated at the first null byte.
|
||||
|
||||
const OTF_MAX_REQUEST_COUNT = 8
|
||||
|
||||
function OTFGetSegmentInfo(adaptiveFormats as object, client as Innertube.ClientType, cancellation as object) as void
|
||||
errors = {
|
||||
message: ""
|
||||
attachments: []
|
||||
}
|
||||
|
||||
formatsToProcess = []
|
||||
for i = 0 to adaptiveFormats.Count() - 1
|
||||
formatsToProcess.Push({
|
||||
format: adaptiveFormats[i]
|
||||
filePath: `tmp:/otf_segments/${i}.bin`
|
||||
})
|
||||
end for
|
||||
|
||||
pendingFormats = []
|
||||
|
||||
requestHeaders = Innertube.CreateHeaders(client)
|
||||
requestHeaders["origin"] = "https://www.youtube.com"
|
||||
requestHeaders["referer"] = "https://www.youtube.com"
|
||||
requestHeaders["DNT"] = "?1"
|
||||
|
||||
segmentDurationsRegex = CreateObject("roRegex", "(\d+)(?:\(r=(\d+)\))?", "g")
|
||||
|
||||
fs = CreateObject("roFileSystem")
|
||||
fs.Delete("tmp:/otf_segments")
|
||||
fs.CreateDirectory("tmp:/otf_segments")
|
||||
|
||||
while true
|
||||
while formatsToProcess.Count() > 0 and pendingFormats.Count() < OTF_MAX_REQUEST_COUNT
|
||||
formatToProcess = formatsToProcess.Pop()
|
||||
request = OTFMakeSegmentInfoRequest(formatToProcess.format, formatToProcess.filePath, requestHeaders, errors, cancellation)
|
||||
if request <> invalid
|
||||
formatToProcess.request = request
|
||||
pendingFormats.Push(formatToProcess)
|
||||
end if
|
||||
end while
|
||||
|
||||
if pendingFormats.Count() = 0
|
||||
exit while
|
||||
end if
|
||||
|
||||
pendingFormat = pendingFormats.Shift()
|
||||
' returns false if processing should stop (e.g., cancelled)
|
||||
if not OTFProcessPendingFormat(pendingFormat.format, pendingFormat.request, pendingFormat.filePath, segmentDurationsRegex, errors)
|
||||
exit while
|
||||
end if
|
||||
end while
|
||||
|
||||
fs.Delete("tmp:/otf_segments")
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(errors.message) or errors.attachments.Count() > 0
|
||||
LogTelemetryEvent({
|
||||
level: "error"
|
||||
message: `OTF errors during segment info retrieval: \n${errors.message}`
|
||||
fingerprint: ["OTF errors during segment info retrieval"]
|
||||
attachments: errors.attachments
|
||||
})
|
||||
end if
|
||||
end function
|
||||
|
||||
function OTFMakeSegmentInfoRequest(format as object, filePath as string, requestHeaders as object, errors as object, cancellation as object) as object
|
||||
url = format.url
|
||||
if StringUtils.IsNullOrEmpty(url)
|
||||
errors.message += `URL is empty for itag ${format.itag}.\n`
|
||||
return invalid
|
||||
end if
|
||||
|
||||
queryComponents = UrlUtils.ParseQueryComponents(url)
|
||||
queryComponents["rn"] = "0"
|
||||
queryComponents["sq"] = "0"
|
||||
otfUrl = UrlUtils.SetQueryParams(url, queryComponents)
|
||||
|
||||
request = HttpClient.Get(otfUrl)
|
||||
request.Headers(requestHeaders)
|
||||
request.ToFile(filePath)
|
||||
request.Cancellation(cancellation)
|
||||
request.Send()
|
||||
|
||||
return request
|
||||
end function
|
||||
|
||||
function OTFProcessPendingFormat(format as object, request as object, filePath as string, segmentDurationsRegex as object, errors as object) as boolean
|
||||
response = request.Await()
|
||||
|
||||
if response.IsCancelled()
|
||||
return false
|
||||
end if
|
||||
|
||||
if not response.IsSuccess()
|
||||
errors.message += `Failed to get segment info for itag ${format.itag}: ${response.ErrorMessage()}\n`
|
||||
return true
|
||||
end if
|
||||
|
||||
segmentDurations = OTFParseFileForSegmentDurations(filePath, segmentDurationsRegex, errors)
|
||||
if segmentDurations = invalid
|
||||
errors.message += `Failed to parse segment durations for itag ${format.itag}.\n`
|
||||
errors.message += `Headers: ${ToString(response.Headers())}\n`
|
||||
return true
|
||||
end if
|
||||
|
||||
format["otfSegmentDurations"] = segmentDurations
|
||||
return true
|
||||
end function
|
||||
|
||||
function OTFParseFileForSegmentDurations(filePath as string, segmentDurationsRegex as object, errors as object) as dynamic
|
||||
buffer = CreateObject("roByteArray")
|
||||
|
||||
buffer.FromAsciiString("Segment-Durations-Ms:")
|
||||
startMarkerHex = buffer.ToHexString()
|
||||
|
||||
buffer.FromAsciiString(`\r\n`)
|
||||
endMarkerHex = buffer.ToHexString()
|
||||
|
||||
if not buffer.ReadFile(filePath)
|
||||
errors.message += `Failed to read filePath ${filePath}.\n`
|
||||
return invalid
|
||||
end if
|
||||
contentHex = buffer.ToHexString()
|
||||
|
||||
startIndex = contentHex.InStr(startMarkerHex)
|
||||
if startIndex = -1
|
||||
errors.message += `Start marker not found in filePath ${filePath}.\n`
|
||||
errors.attachments.Push({
|
||||
filename: filePath
|
||||
content_type: "plain/text"
|
||||
data: contentHex
|
||||
})
|
||||
return invalid
|
||||
end if
|
||||
|
||||
endIndex = contentHex.InStr(startIndex, endMarkerHex)
|
||||
if endIndex = -1
|
||||
errors.message += `End marker not found in filePath ${filePath}.\n`
|
||||
errors.attachments.Push({
|
||||
filename: filePath
|
||||
content_type: "plain/text"
|
||||
data: contentHex
|
||||
})
|
||||
return invalid
|
||||
end if
|
||||
|
||||
segmentDurationsMsHex = contentHex.Mid(startIndex + startMarkerHex.len(), endIndex - (startIndex + startMarkerHex.len()))
|
||||
buffer.FromHexString(segmentDurationsMsHex)
|
||||
segmentDurationsMs = buffer.ToAsciiString()
|
||||
|
||||
matches = segmentDurationsRegex.MatchAll(segmentDurationsMs)
|
||||
if not IsArray(matches) or matches.Count() = 0
|
||||
errors.message += `No segment duration matches found in filePath ${filePath}.\n`
|
||||
errors.attachments.Push({
|
||||
filename: filePath
|
||||
content_type: "plain/text"
|
||||
data: contentHex
|
||||
})
|
||||
return invalid
|
||||
end if
|
||||
|
||||
segmentDurations = CreateObject("roArray", matches.Count(), false)
|
||||
|
||||
for i = 0 to matches.Count() - 1
|
||||
match = matches[i]
|
||||
segment = {}
|
||||
' We set duration and repeatCount to "d" and "r" so that we can feed
|
||||
' them directly into the DashManifest generation code.
|
||||
if match.Count() >= 2
|
||||
segment["d"] = match[1].ToInt()
|
||||
end if
|
||||
if match.Count() >= 3
|
||||
segment["r"] = match[2].ToInt()
|
||||
end if
|
||||
segmentDurations[i] = segment
|
||||
end for
|
||||
|
||||
return segmentDurations
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -44,7 +44,7 @@ namespace Innertube
|
||||
return context.feeds
|
||||
end function
|
||||
|
||||
function ParseChannelPageResponseData(responseData as object, response as object) as object
|
||||
function ParseChannelPageResponseData(browseId as string, responseData as object, response as object) as object
|
||||
if responseData = invalid
|
||||
return {
|
||||
error: "Invalid response data"
|
||||
@@ -63,6 +63,9 @@ namespace Innertube
|
||||
author = ObjectUtils.Dig(responseData, ["header", "pageHeaderRenderer", "pageTitle"])
|
||||
end if
|
||||
authorId = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "externalId"])
|
||||
if StringUtils.IsNullOrEmpty(authorId)
|
||||
authorId = browseId
|
||||
end if
|
||||
|
||||
thumbnails = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "avatar", "thumbnails"])
|
||||
if thumbnails = invalid
|
||||
@@ -149,6 +152,7 @@ namespace Innertube
|
||||
response: response
|
||||
"currentAuthor": author
|
||||
"currentAuthorId": authorId
|
||||
browseId: browseId
|
||||
})
|
||||
if feeds.Count() > 0
|
||||
items = ValidArray(feeds[0].items)
|
||||
@@ -183,7 +187,7 @@ namespace Innertube
|
||||
return channel
|
||||
end function
|
||||
|
||||
function ParsePlaylistPageResponseData(responseData as object, response as object) as object
|
||||
function ParsePlaylistPageResponseData(browseId as string, responseData as object, response as object) as object
|
||||
if responseData = invalid
|
||||
return {
|
||||
error: "Invalid response data"
|
||||
@@ -214,7 +218,7 @@ namespace Innertube
|
||||
playlistId = ObjectUtils.Dig(primaryInfo, ["navigationEndpoint", "watchEndpoint", "playlistId"])
|
||||
title = ParseText(ObjectUtils.Dig(primaryInfo, ["title"]))
|
||||
description = ParseText(ObjectUtils.Dig(primaryInfo, ["description"]))
|
||||
videoCount = ParseText(ObjectUtils.Dig(primaryInfo, ["stats", 0, "runs", 0, "text"])).ToInt()
|
||||
videoCount = ParseText(ObjectUtils.Dig(primaryInfo, ["stats", 0, "runs", 0, "text"])).Replace(",", "").ToInt()
|
||||
thumbnail = ObjectUtils.Dig(primaryInfo, ["thumbnailRenderer", "playlistVideoThumbnailRenderer", "thumbnail", "thumbnails", 0, "url"])
|
||||
|
||||
author = ParseText(ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "title"]))
|
||||
@@ -251,13 +255,16 @@ namespace Innertube
|
||||
end if
|
||||
end if
|
||||
|
||||
if StringUtils.IsNullOrEmpty(playlistId)
|
||||
playlistId = browseId
|
||||
end if
|
||||
|
||||
playlist = {
|
||||
"playlistId": playlistId
|
||||
"videoCount": videoCount
|
||||
"videos": []
|
||||
}
|
||||
if playlistId <> invalid
|
||||
playlist["playlistId"] = playlistId
|
||||
end if
|
||||
|
||||
if title <> invalid
|
||||
playlist["title"] = title
|
||||
end if
|
||||
@@ -279,6 +286,7 @@ namespace Innertube
|
||||
|
||||
feeds = ParseResponseDataForFeeds(responseData, {
|
||||
response: response
|
||||
browseId: browseId
|
||||
})
|
||||
if feeds.Count() > 0
|
||||
playlist["videos"] = ValidArray(feeds[0].items)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import "pkg:/components/Services/Innertube/Context.bs"
|
||||
import "pkg:/components/Services/Innertube/NodesParser.bs"
|
||||
import "pkg:/components/Services/Innertube/OTFSegmentInfo.bs"
|
||||
import "pkg:/source/services/HttpClient.bs"
|
||||
import "pkg:/source/utils/ObjectUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
@@ -12,8 +13,6 @@ namespace Innertube
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
visitorData = OptionUtils.Get(options, "visitorData")
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
doSignatureTimestamp = ValidBool(OptionUtils.Get(options, "signatureTimestamp"))
|
||||
|
||||
cpn = InnertubeService.CreateClientPlaybackNonce()
|
||||
|
||||
useAccessToken = client = Innertube.ClientType.TV and not StringUtils.IsNullOrEmpty(accessToken)
|
||||
@@ -22,6 +21,12 @@ namespace Innertube
|
||||
|
||||
context = Innertube.CreateContext(client, deviceInfo, options)
|
||||
|
||||
if client = Innertube.ClientType.TV
|
||||
referer = "https://www.youtube.com/tv#/watch?v=" + videoId
|
||||
else
|
||||
referer = "https://www.youtube.com/watch?v=" + videoId
|
||||
end if
|
||||
|
||||
payload = {
|
||||
"videoId": videoId
|
||||
"context": context
|
||||
@@ -30,13 +35,12 @@ namespace Innertube
|
||||
"contentPlaybackContext": {
|
||||
"vis": 0
|
||||
"splay": false
|
||||
"referer": "https://www.youtube.com/watch?v=" + videoId
|
||||
"referer": referer
|
||||
"currentUrl": "/watch?v=" + videoId
|
||||
"autonavState": "STATE_ON"
|
||||
"autoCaptionsDefaultOn": false
|
||||
"html5Preference": "HTML5_PREF_WANTS"
|
||||
"lactMilliseconds": "-1"
|
||||
"isInlinePlaybackNoAd": true
|
||||
}
|
||||
}
|
||||
"attestationRequest": {
|
||||
@@ -46,12 +50,9 @@ namespace Innertube
|
||||
"contentCheckOk": true
|
||||
}
|
||||
|
||||
signatureTimestamp = invalid
|
||||
if doSignatureTimestamp
|
||||
signatureTimestamp = GetSignatureTimestamp(cancellation)
|
||||
if signatureTimestamp <> invalid
|
||||
payload["playbackContext"]["contentPlaybackContext"]["signatureTimestamp"] = signatureTimestamp
|
||||
end if
|
||||
signatureTimestamp = GetSignatureTimestamp(cancellation)
|
||||
if signatureTimestamp <> invalid
|
||||
payload["playbackContext"]["contentPlaybackContext"]["signatureTimestamp"] = signatureTimestamp
|
||||
end if
|
||||
|
||||
request = HttpClient.PostJson("https://www.youtube.com/youtubei/v1/player?prettyPrint=false&alt=json", payload)
|
||||
@@ -67,9 +68,9 @@ namespace Innertube
|
||||
return request
|
||||
end function
|
||||
|
||||
function ParseInnertubePlayerResponse(playerRequest as dynamic, playerResponse as dynamic, parsedResponse as object, cancellation as object) as object
|
||||
function ParseInnertubePlayerResponse(playerRequest as dynamic, playerResponse as dynamic, client as Innertube.ClientType, cancellation as object) as object
|
||||
WriteAsciiFile("cachefs:/last_player_response.json", playerResponse.Text())
|
||||
|
||||
parsedResponse = {}
|
||||
payload = playerResponse.Json()
|
||||
|
||||
error = ParsePlayerResponseForError(payload, playerRequest)
|
||||
@@ -92,6 +93,7 @@ namespace Innertube
|
||||
|
||||
lengthSeconds = videoDetails["lengthSeconds"].ToInt()
|
||||
isLive = ValidBool(videoDetails["isLive"])
|
||||
isPostLiveDvr = ValidBool(videoDetails["isPostLiveDvr"])
|
||||
|
||||
adaptiveFormats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"]))
|
||||
formats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "formats"]))
|
||||
@@ -108,13 +110,14 @@ namespace Innertube
|
||||
end if
|
||||
|
||||
hasLiveStreamingData = FormatsHaveLiveStreamingData(adaptiveFormats) or FormatsHaveLiveStreamingData(formats)
|
||||
isOTF = FormatsHasTypeOTF(adaptiveFormats)
|
||||
hasDrm = (not StringUtils.IsNullOrEmpty(streamingData.drmParams)) or IsArray(streamingData.licenseInfos)
|
||||
|
||||
shouldAnalyze = (not isLive) and (not hasLiveStreamingData) and (not hasDrm)
|
||||
adaptiveFormats = TransformFormats(adaptiveFormats, shouldAnalyze)
|
||||
formats = TransformFormats(formats, false)
|
||||
adaptiveFormats = TransformFormats(adaptiveFormats)
|
||||
formats = TransformFormats(formats)
|
||||
|
||||
parsedResponse["type"] = "video"
|
||||
parsedResponse["parser"] = "playlet"
|
||||
parsedResponse["videoId"] = videoDetails["videoId"]
|
||||
parsedResponse["videoThumbnails"] = videoDetails["thumbnail"]["thumbnails"]
|
||||
parsedResponse["storyboards"] = ParseStoryboards(payload, lengthSeconds)
|
||||
@@ -122,6 +125,7 @@ namespace Innertube
|
||||
parsedResponse["authorId"] = videoDetails["channelId"]
|
||||
parsedResponse["lengthSeconds"] = lengthSeconds
|
||||
parsedResponse["liveNow"] = isLive
|
||||
parsedResponse["isPostLiveDvr"] = isPostLiveDvr
|
||||
parsedResponse["hasLiveStreamingData"] = hasLiveStreamingData
|
||||
parsedResponse["hlsUrl"] = streamingData["hlsManifestUrl"]
|
||||
parsedResponse["dashUrl"] = streamingData["dashManifestUrl"]
|
||||
@@ -154,6 +158,16 @@ namespace Innertube
|
||||
parsedResponse["isLoggedIn"] = ParseIsLoggedIn(payload)
|
||||
parsedResponse["playbackTrackingUrls"] = ParsePlaybackTrackingUrls(payload, parsedResponse.isLoggedIn)
|
||||
|
||||
if isPostLiveDvr
|
||||
LogDebug("Fetching Post-Live DVR info")
|
||||
GetPostLiveDvrInfo(parsedResponse, adaptiveFormats, playerRequest.cpn, client, cancellation)
|
||||
end if
|
||||
|
||||
if isOTF
|
||||
LogDebug("Fetching OTF segment info")
|
||||
OTFGetSegmentInfo(adaptiveFormats, client, cancellation)
|
||||
end if
|
||||
|
||||
return parsedResponse
|
||||
end function
|
||||
|
||||
@@ -298,6 +312,7 @@ namespace Innertube
|
||||
end if
|
||||
|
||||
captions = []
|
||||
autoCaptions = []
|
||||
for each track in tracks
|
||||
if not IsAssociativeArray(track)
|
||||
continue for
|
||||
@@ -323,67 +338,52 @@ namespace Innertube
|
||||
|
||||
label = ParseText(track["name"])
|
||||
|
||||
captions.Push({
|
||||
thisCaption = {
|
||||
"label": label
|
||||
"language_code": languageCode
|
||||
"url": baseUrl
|
||||
})
|
||||
}
|
||||
|
||||
if track["kind"] = "asr"
|
||||
autoCaptions.Push(thisCaption)
|
||||
continue for
|
||||
end if
|
||||
|
||||
captions.Push(thisCaption)
|
||||
end for
|
||||
|
||||
' Put automatically generated captions at the end so human-generated ones take priority
|
||||
captions.Append(autoCaptions)
|
||||
return captions
|
||||
end function
|
||||
|
||||
function TransformFormats(formats as object, analyze as boolean) as object
|
||||
analysis = invalid
|
||||
if analyze
|
||||
analysis = {
|
||||
"issueDetected": false
|
||||
}
|
||||
end if
|
||||
|
||||
function TransformFormats(formats as object) as object
|
||||
result = []
|
||||
for i = 0 to formats.Count() - 1
|
||||
result.Push(TransformFormat(formats[i], analysis))
|
||||
result.Push(TransformFormat(formats[i]))
|
||||
end for
|
||||
|
||||
if analyze and analysis.issueDetected
|
||||
' Are these OTF streams?
|
||||
LogTelemetryEvent({
|
||||
level: "error"
|
||||
message: `Some formats are missing initRange or indexRange\nFormats: ${FormatJson(formats)}`
|
||||
fingerprint: ["Some formats are missing initRange or indexRange"]
|
||||
})
|
||||
end if
|
||||
|
||||
return result
|
||||
end function
|
||||
|
||||
function TransformFormat(fmt as object, analysis as object) as object
|
||||
function TransformFormat(fmt as object) as object
|
||||
itag = `${fmt["itag"]}`
|
||||
result = {
|
||||
"bitrate": `${fmt["bitrate"]}`
|
||||
"url": fmt["url"]
|
||||
"itag": itag
|
||||
"type": fmt["mimeType"]
|
||||
"clen": `${fmt["approxDurationMs"]}`
|
||||
"lmt": `${fmt["lastModified"]}`
|
||||
}
|
||||
|
||||
if fmt["approxDurationMs"] <> invalid
|
||||
result["approxDurationMs"] = fmt["approxDurationMs"]
|
||||
end if
|
||||
|
||||
if IsAssociativeArray(fmt["initRange"])
|
||||
result["init"] = `${fmt["initRange"]["start"]}-${fmt["initRange"]["end"]}`
|
||||
else
|
||||
result["init"] = ""
|
||||
if analysis <> invalid
|
||||
analysis.issueDetected = true
|
||||
end if
|
||||
end if
|
||||
if IsAssociativeArray(fmt["indexRange"])
|
||||
result["index"] = `${fmt["indexRange"]["start"]}-${fmt["indexRange"]["end"]}`
|
||||
else
|
||||
result["index"] = ""
|
||||
if analysis <> invalid
|
||||
analysis.issueDetected = true
|
||||
end if
|
||||
end if
|
||||
|
||||
if fmt["audioQuality"] <> invalid
|
||||
@@ -403,6 +403,31 @@ namespace Innertube
|
||||
result["fps"] = ToString(fmt["fps"])
|
||||
end if
|
||||
|
||||
if fmt["colorInfo"] <> invalid
|
||||
result["colorInfo"] = fmt["colorInfo"]
|
||||
end if
|
||||
if fmt["audioTrack"] <> invalid
|
||||
result["audioTrack"] = fmt["audioTrack"]
|
||||
end if
|
||||
if fmt["isDrc"] <> invalid
|
||||
result["isDrc"] = fmt["isDrc"]
|
||||
end if
|
||||
if fmt["targetDurationSec"] <> invalid
|
||||
result["targetDurationSec"] = fmt["targetDurationSec"]
|
||||
end if
|
||||
|
||||
if ValidString(fmt["type"]) = "FORMAT_STREAM_TYPE_OTF"
|
||||
result["isTypeOTF"] = true
|
||||
end if
|
||||
|
||||
if fmt["drmFamilies"] <> invalid
|
||||
result["drmFamilies"] = fmt["drmFamilies"]
|
||||
end if
|
||||
|
||||
if fmt["xtags"] <> invalid
|
||||
result["xtags"] = fmt["xtags"]
|
||||
end if
|
||||
|
||||
result["width"] = fmt["width"]
|
||||
result["height"] = fmt["height"]
|
||||
|
||||
@@ -424,7 +449,7 @@ namespace Innertube
|
||||
LogDebug(`ReadAsciiFile("tmp:/sts_cache.json")`)
|
||||
cache = ReadAsciiFile("tmp:/sts_cache.json")
|
||||
if not StringUtils.IsNullOrEmpty(cache)
|
||||
json = ParseJson(cache)
|
||||
json = StringUtils.ParseJsonSafe(cache)
|
||||
return json["sts"]
|
||||
end if
|
||||
|
||||
@@ -529,8 +554,7 @@ namespace Innertube
|
||||
for i = 0 to decipheredFormats.Count() - 1
|
||||
fmt = formats[i]
|
||||
decipheredFmt = decipheredFormats[i]
|
||||
|
||||
fmt["url"] = decipheredFmt["url"]
|
||||
fmt["url"] = ResetUrlClientVersion(decipheredFmt["url"])
|
||||
end for
|
||||
|
||||
decipheredAdaptiveFormats = json["adaptiveFormats"]
|
||||
@@ -544,11 +568,34 @@ namespace Innertube
|
||||
for i = 0 to decipheredAdaptiveFormats.Count() - 1
|
||||
fmt = adaptiveFormats[i]
|
||||
decipheredFmt = decipheredAdaptiveFormats[i]
|
||||
fmt["url"] = decipheredFmt["url"]
|
||||
fmt["url"] = ResetUrlClientVersion(decipheredFmt["url"])
|
||||
end for
|
||||
return invalid
|
||||
end function
|
||||
|
||||
' YouTube.js sets cver to hardcoded values that might be different from
|
||||
' What's used in Playlet. There's no indication that this makes a difference,
|
||||
' but it makes sense to keep it consistent.
|
||||
function ResetUrlClientVersion(url as dynamic) as dynamic
|
||||
if StringUtils.IsNullOrEmpty(url)
|
||||
return url
|
||||
end if
|
||||
|
||||
queryComponents = UrlUtils.ParseQueryComponents(url)
|
||||
client = ValidString(queryComponents["c"])
|
||||
if client = "TVHTML5"
|
||||
queryComponents["cver"] = INNERTUBE_TV_CLIENT_VERSION
|
||||
else if client = "IOS"
|
||||
queryComponents["cver"] = INNERTUBE_IOS_CLIENT_VERSION
|
||||
else if client = "WEB"
|
||||
queryComponents["cver"] = INNERTUBE_WEB_CLIENT_VERSION
|
||||
else
|
||||
return url
|
||||
end if
|
||||
|
||||
return UrlUtils.SetQueryParams(url, queryComponents)
|
||||
end function
|
||||
|
||||
function ParseIsLoggedIn(payload as object) as boolean
|
||||
trackingParams = ObjectUtils.Dig(payload, ["responseContext", "serviceTrackingParams"])
|
||||
if not IsArray(trackingParams)
|
||||
@@ -598,6 +645,10 @@ namespace Innertube
|
||||
return true
|
||||
end if
|
||||
|
||||
if ValidBool(ObjectUtils.Dig(payload, ["videoDetails", "isPostLiveDvr"]))
|
||||
return false
|
||||
end if
|
||||
|
||||
adaptiveFormats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"]))
|
||||
if FormatsHaveLiveStreamingData(adaptiveFormats)
|
||||
return true
|
||||
@@ -623,4 +674,78 @@ namespace Innertube
|
||||
|
||||
return false
|
||||
end function
|
||||
|
||||
function FormatsHasTypeOTF(formats as object) as boolean
|
||||
if not IsArray(formats)
|
||||
return false
|
||||
end if
|
||||
for each fmt in formats
|
||||
if ValidString(fmt["type"]) = "FORMAT_STREAM_TYPE_OTF"
|
||||
return true
|
||||
end if
|
||||
end for
|
||||
|
||||
return false
|
||||
end function
|
||||
|
||||
function GetPostLiveDvrInfo(parsedResponse as object, adaptiveFormats as object, cpn as dynamic, client as Innertube.ClientType, cancellation as object) as void
|
||||
if adaptiveFormats.Count() = 0
|
||||
LogWarn("GetPostLiveDvrInfo: No adaptive formats available")
|
||||
return
|
||||
end if
|
||||
|
||||
url = adaptiveFormats[0]["url"]
|
||||
if StringUtils.IsNullOrEmpty(url)
|
||||
LogWarn("GetPostLiveDvrInfo: URL is empty")
|
||||
return
|
||||
end if
|
||||
|
||||
queryComponents = UrlUtils.ParseQueryComponents(url)
|
||||
queryComponents["rn"] = "0"
|
||||
queryComponents["sq"] = "0"
|
||||
if not StringUtils.IsNullOrEmpty(cpn)
|
||||
queryComponents["cpn"] = cpn
|
||||
end if
|
||||
|
||||
url = UrlUtils.SetQueryParams(url, 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.TryCount(2)
|
||||
request.Cancellation(cancellation)
|
||||
response = request.Await()
|
||||
|
||||
if not response.IsSuccess()
|
||||
LogError("Failed to fetch Post-Live DVR info", response.ErrorMessage())
|
||||
return
|
||||
end if
|
||||
|
||||
headers = response.Headers()
|
||||
|
||||
if not headers.DoesExist("X-Head-Time-Millis") or not headers.DoesExist("X-Head-Seqnum")
|
||||
msg = "GetPostLiveDvrInfo: Missing Post-Live DVR info in headers"
|
||||
LogErrorNoTelemetry(msg, url, headers)
|
||||
LogTelemetryEvent({
|
||||
level: "error"
|
||||
message: msg + `\nVideoID: ${parsedResponse["videoId"]}\nUrl: ${url}\nHeaders: ${FormatJson(headers)}`
|
||||
fingerprint: [msg]
|
||||
})
|
||||
end if
|
||||
|
||||
durationMs = ValidString(headers["X-Head-Time-Millis"]).ToInt()
|
||||
segmentCount = ValidString(headers["X-Head-Seqnum"]).ToInt()
|
||||
|
||||
if durationMs > 0
|
||||
parsedResponse["postLiveDvrDurationMs"] = durationMs
|
||||
end if
|
||||
if segmentCount > 0
|
||||
parsedResponse["postLiveDvrSegmentCount"] = segmentCount
|
||||
end if
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -87,7 +87,7 @@ namespace Innertube
|
||||
text = response.Text()
|
||||
text = text.Replace(`)]}'`, "")
|
||||
|
||||
parsed = ParseJson(text)
|
||||
parsed = StringUtils.ParseJsonSafe(text)
|
||||
if not IsArray(parsed) or parsed.Count() < 2
|
||||
return {
|
||||
error: "Failed to parse search suggestions"
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Innertube
|
||||
text = response.Text()
|
||||
text = text.Replace(`)]}'`, "")
|
||||
|
||||
json = ParseJson(text)
|
||||
json = StringUtils.ParseJsonSafe(text)
|
||||
if json = invalid
|
||||
return {
|
||||
"error": "Failed to parse session data: " + text
|
||||
@@ -78,7 +78,7 @@ namespace Innertube
|
||||
return invalid
|
||||
end if
|
||||
|
||||
sessionData = ParseJson(sessionData)
|
||||
sessionData = StringUtils.ParseJsonSafe(sessionData)
|
||||
if sessionData = invalid
|
||||
RegistryUtils.Delete(RegistryUtils.INNERTUBE_SESSION_DATA)
|
||||
return invalid
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
' Auto-generated file - do not modify manually
|
||||
' md5:252058d604a761c9fd33d800fce1b72b
|
||||
' md5:1dc03998a561a4b1270454e10a4d7ead
|
||||
|
||||
import "pkg:/source/Protobuf/BinaryReader.bs"
|
||||
import "pkg:/source/Protobuf/BinaryWriter.bs"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import "InvidiousService.bs"
|
||||
|
||||
function Init()
|
||||
m.top.apiDefinitions = ParseJson(ReadAsciiFile("libpkg:/config/invidious_video_api.yaml"))
|
||||
m.top.apiDefinitions = StringUtils.ParseJsonSafe(ReadAsciiFile("libpkg:/config/invidious_video_api.yaml"))
|
||||
m.service = new Invidious.InvidiousService(m.top)
|
||||
end function
|
||||
|
||||
|
||||
@@ -698,7 +698,7 @@ namespace Invidious
|
||||
end function
|
||||
|
||||
function VerifyTokenScope(token as string) as boolean
|
||||
tokenObject = ParseJson(token)
|
||||
tokenObject = StringUtils.ParseJsonSafe(token)
|
||||
if tokenObject = invalid
|
||||
LogWarn("Failed to json parse token:", token)
|
||||
return false
|
||||
|
||||
@@ -68,6 +68,8 @@ class LoungeApi
|
||||
commandHandlers[COMMAND_TYPE_GRACEFUL_RECONNECT] = m.HandleIgnoreCommand
|
||||
commandHandlers[COMMAND_TYPE_GET_RECEIVER_STATUS] = m.HandleIgnoreCommand
|
||||
commandHandlers[COMMAND_TYPE_SEND_DEBUG_COMMAND] = m.HandleIgnoreCommand
|
||||
commandHandlers[COMMAND_TYPE_SET_AUTOPLAY_MODE] = m.HandleIgnoreCommand
|
||||
commandHandlers[COMMAND_TYPE_GET_PARTY_GAMES_MODE] = m.HandleIgnoreCommand
|
||||
|
||||
commandHandlers[COMMAND_TYPE_GET_NOW_PLAYING] = m.HandleGetPlayingNow
|
||||
commandHandlers[COMMAND_TYPE_SESSION_ID] = m.HandleSessionId
|
||||
@@ -83,6 +85,7 @@ class LoungeApi
|
||||
commandHandlers[COMMAND_TYPE_NEXT] = m.HandleNext
|
||||
commandHandlers[COMMAND_TYPE_STOP_VIDEO] = m.HandleStopVideo
|
||||
commandHandlers[COMMAND_TYPE_SEEK_TO] = m.HandleSeekTo
|
||||
commandHandlers[COMMAND_TYPE_SET_PLAYBACK_SPEED] = m.HandleSetPlaybackSpeed
|
||||
|
||||
for each key in commandHandlers
|
||||
m[COMMAND_HANDLER_PREFIX + key] = commandHandlers[key]
|
||||
@@ -175,7 +178,7 @@ class LoungeApi
|
||||
queryParams = {
|
||||
"device": "LOUNGE_SCREEN"
|
||||
"theme": "cl"
|
||||
"capabilities": ""
|
||||
"capabilities": "vsp"
|
||||
"mdxVersion": "2"
|
||||
"VER": "8"
|
||||
"v": "2"
|
||||
@@ -211,7 +214,7 @@ class LoungeApi
|
||||
text = text.Mid(text.instr(`\n`) + 1)
|
||||
|
||||
messagesToSend = []
|
||||
commands = ParseJson(text)
|
||||
commands = StringUtils.ParseJsonSafe(text)
|
||||
m.ProcessCommands(commands, messagesToSend)
|
||||
m.SendMessages(messagesToSend)
|
||||
return true
|
||||
@@ -223,7 +226,7 @@ class LoungeApi
|
||||
queryParams = {
|
||||
"device": "LOUNGE_SCREEN"
|
||||
"theme": "cl"
|
||||
"capabilities": ""
|
||||
"capabilities": "vsp"
|
||||
"mdxVersion": "2"
|
||||
"VER": "8"
|
||||
"v": "2"
|
||||
@@ -267,7 +270,7 @@ class LoungeApi
|
||||
payloadSize = chunk.Left(newLineIndex).trim()
|
||||
payloadSize = payloadSize.ToInt()
|
||||
payload = chunk.Mid(newLineIndex + 1, payloadSize)
|
||||
commands = ParseJson(payload)
|
||||
commands = StringUtils.ParseJsonSafe(payload)
|
||||
m.ProcessCommands(commands, messagesToSend)
|
||||
chunk = chunk.Mid(newLineIndex + payloadSize + 1)
|
||||
newLineIndex = chunk.InStr(`\n`)
|
||||
@@ -324,9 +327,16 @@ class LoungeApi
|
||||
LogInfo(commandIndex, commandType)
|
||||
m[handler](commandIndex, commandType, commandArgs, messagesToSend)
|
||||
else
|
||||
LogWarn("Unknown command type:", commandType, "command:", command)
|
||||
fingerprint = "Unknown command type:" + ToString(commandType)
|
||||
message = fingerprint + " command:" + ToString(command)
|
||||
LogWarnNoTelemetry(message)
|
||||
LogTelemetryEvent({
|
||||
level: "warning"
|
||||
message: message
|
||||
fingerprint: fingerprint
|
||||
})
|
||||
#if DEBUG
|
||||
throw `Unknown command type: ${commandType} command: ${ToString(command)}`
|
||||
throw message
|
||||
#end if
|
||||
end if
|
||||
end for
|
||||
@@ -368,7 +378,7 @@ class LoungeApi
|
||||
if not IsString(devices)
|
||||
return
|
||||
end if
|
||||
devices = ParseJson(devices)
|
||||
devices = StringUtils.ParseJsonSafe(devices)
|
||||
if devices = invalid
|
||||
return
|
||||
end if
|
||||
@@ -482,6 +492,48 @@ class LoungeApi
|
||||
player.seek = seekTo
|
||||
end function
|
||||
|
||||
function HandleSetPlaybackSpeed(_commandId as integer, _commandType as string, commandArgs as object, messagesToSend as object) as void
|
||||
player = m.videoQueueNode.player
|
||||
if player = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
if not player.hasField("playbackSpeed")
|
||||
LogWarn("Video node does not support 'playbackSpeed' field on this device, ignoring setPlaybackSpeed command")
|
||||
return
|
||||
end if
|
||||
|
||||
speed = Val(commandArgs[FIELD_PLAYBACK_SPEED])
|
||||
if speed <= 0
|
||||
speed = 1.0
|
||||
end if
|
||||
|
||||
currentSpeed = ValidFloat(player.playbackSpeed)
|
||||
|
||||
if Abs(currentSpeed - speed) < 0.001
|
||||
LogDebug("Playback speed is already close to the requested speed. current:", currentSpeed, "requested:", speed)
|
||||
return
|
||||
end if
|
||||
|
||||
LogInfo("Setting playback speed to:", speed)
|
||||
|
||||
' Usually playbackSpeed doesn't get applied without pausing and resuming.
|
||||
didPause = false
|
||||
state = player.state
|
||||
if state = "playing"
|
||||
player.control = "pause"
|
||||
didPause = true
|
||||
end if
|
||||
|
||||
player.playbackSpeed = speed
|
||||
|
||||
if didPause
|
||||
player.control = "resume"
|
||||
end if
|
||||
|
||||
messagesToSend.Push(LoungeMessages.OnPlaybackSpeedChanged(speed, true))
|
||||
end function
|
||||
|
||||
function SendMessages(messages as object, loungeData = invalid as object) as void
|
||||
if messages.Count() = 0
|
||||
return
|
||||
@@ -490,7 +542,7 @@ class LoungeApi
|
||||
queryParams = {
|
||||
"device": "LOUNGE_SCREEN"
|
||||
"theme": "cl"
|
||||
"capabilities": ""
|
||||
"capabilities": "vsp"
|
||||
"mdxVersion": "2"
|
||||
"VER": "8"
|
||||
"v": "2"
|
||||
@@ -610,7 +662,7 @@ class LoungeApi
|
||||
|
||||
RegistryUtils.Delete(RegistryUtils.LAST_LOUNGE_DATA)
|
||||
|
||||
loungeData = ParseJson(loungeData)
|
||||
loungeData = StringUtils.ParseJsonSafe(loungeData)
|
||||
if not IsAssociativeArray(loungeData)
|
||||
LogWarn("Can't disconnect from lounge. Invalid data:", loungeData)
|
||||
return
|
||||
|
||||
@@ -3,6 +3,7 @@ const COMMAND_NOW_PLAYING = "nowPlaying"
|
||||
const COMMAND_ON_STATE_CHANGE = "onStateChange"
|
||||
const COMMAND_ON_VOLUME_CHANGED = "onVolumeChanged"
|
||||
const COMMAND_ON_PREVIOUS_NEXT_CHANGE = "onHasPreviousNextChanged"
|
||||
const COMMAND_ON_PLAYBACK_SPEED_CHANGED = "onPlaybackSpeedChanged"
|
||||
const COMMAND_LOUNGE_SCREEN_DISCONNECTED = "loungeScreenDisconnected"
|
||||
' Incoming commands
|
||||
const COMMAND_TYPE_SET_PLAYLIST = "setPlaylist"
|
||||
@@ -12,6 +13,7 @@ const COMMAND_TYPE_REMOTE_DISCONNECTED = "remoteDisconnected"
|
||||
const COMMAND_TYPE_GET_NOW_PLAYING = "getNowPlaying"
|
||||
const COMMAND_TYPE_GET_VOLUME = "getVolume"
|
||||
const COMMAND_TYPE_GET_SUBTITLES_TRACK = "getSubtitlesTrack"
|
||||
const COMMAND_TYPE_GET_PARTY_GAMES_MODE = "getPartyGamesMode"
|
||||
const COMMAND_TYPE_UPDATE_PLAYLIST = "updatePlaylist"
|
||||
const COMMAND_TYPE_NOOP = "noop"
|
||||
const COMMAND_TYPE_PLAY = "play"
|
||||
@@ -30,6 +32,8 @@ const COMMAND_TYPE_GET_DISCOVERT_DEVICE_ID = "getDiscoveryDeviceId"
|
||||
const COMMAND_TYPE_GRACEFUL_RECONNECT = "gracefulReconnect"
|
||||
const COMMAND_TYPE_GET_RECEIVER_STATUS = "getReceiverStatus"
|
||||
const COMMAND_TYPE_SEND_DEBUG_COMMAND = "sendDebugCommand"
|
||||
const COMMAND_TYPE_SET_AUTOPLAY_MODE = "setAutoplayMode"
|
||||
const COMMAND_TYPE_SET_PLAYBACK_SPEED = "setPlaybackSpeed"
|
||||
' Special commands
|
||||
const COMMAND_TYPE_SESSION_ID = "c"
|
||||
const COMMAND_TYPE_G_SESSION_ID = "S"
|
||||
@@ -63,6 +67,8 @@ const FIELD_SEEKABLE_END_TIME = "seekableEndTime"
|
||||
const FIELD_HAS_PREVIOUS = "hasPrevious"
|
||||
const FIELD_HAS_NEXT = "hasNext"
|
||||
const FIELD_NEW_TIME = "newTime"
|
||||
const FIELD_PLAYBACK_SPEED = "playbackSpeed"
|
||||
const FIELD_PLAYBACK_SPEED_INFO = "playbackSpeedInfo"
|
||||
|
||||
enum PlayerState
|
||||
UNSTARTED = -1
|
||||
|
||||
@@ -15,6 +15,20 @@ namespace LoungeMessages
|
||||
return message
|
||||
end function
|
||||
|
||||
function OnPlaybackSpeedChanged(speed as float, isContentSupportVSP as boolean) as object
|
||||
message = {
|
||||
commandType: COMMAND_ON_PLAYBACK_SPEED_CHANGED
|
||||
}
|
||||
commandArgs = {}
|
||||
commandArgs[FIELD_PLAYBACK_SPEED] = speed
|
||||
commandArgs[FIELD_PLAYBACK_SPEED_INFO] = FormatJson({
|
||||
"playbackSpeed": speed
|
||||
"isContentSupportVSP": isContentSupportVSP
|
||||
})
|
||||
message.commandArgs = commandArgs
|
||||
return message
|
||||
end function
|
||||
|
||||
function OnStateChange(player as object, overrides = invalid as object) as object
|
||||
message = {
|
||||
commandType: COMMAND_ON_STATE_CHANGE
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace LoungeVideoQueue
|
||||
' - eventDetails is of the form {"eventType":"VIDEO_REMOVED","videoId":"<videoId>"}
|
||||
eventDetails = playlistData[FIELD_EVENT_DETAILS]
|
||||
if IsString(eventDetails)
|
||||
eventDetails = ParseJson(eventDetails)
|
||||
eventDetails = StringUtils.ParseJsonSafe(eventDetails)
|
||||
end if
|
||||
if eventDetails <> invalid and eventDetails["eventType"] = "VIDEO_ADDED"
|
||||
eventVideoId = eventDetails[FIELD_VIDEO_ID]
|
||||
|
||||
@@ -21,7 +21,7 @@ function Init()
|
||||
end function
|
||||
|
||||
function LoadPreferencesFile()
|
||||
m.top.prefsModel = ParseJson(ReadAsciiFile("libpkg:/config/preferences.json5"))
|
||||
m.top.prefsModel = StringUtils.ParseJsonSafe(ReadAsciiFile("libpkg:/config/preferences.json5"))
|
||||
end function
|
||||
|
||||
function AddNodeFields()
|
||||
@@ -60,7 +60,7 @@ function LoadUserPreferencesFromRegistry()
|
||||
if userPrefs = invalid
|
||||
userPrefs = {}
|
||||
else
|
||||
userPrefs = ParseJson(userPrefs)
|
||||
userPrefs = StringUtils.ParseJsonSafe(userPrefs)
|
||||
end if
|
||||
|
||||
' Step 2: Migrate existing preferences to new format (if needed)
|
||||
@@ -101,7 +101,7 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
|
||||
if not StringUtils.IsNullOrEmpty(instances)
|
||||
currentInstance = userPrefs["invidious.instance"]
|
||||
if StringUtils.IsNullOrEmpty(currentInstance)
|
||||
instances = ParseJson(instances)
|
||||
instances = StringUtils.ParseJsonSafe(instances)
|
||||
if IsArray(instances) and instances.Count() > 0
|
||||
instance = instances[0]
|
||||
if not StringUtils.IsNullOrEmpty(instance)
|
||||
@@ -162,6 +162,22 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
|
||||
isDirty = true
|
||||
end if
|
||||
|
||||
if userPrefs.__version = 5
|
||||
filteredLayout = []
|
||||
homeScreenLayout = ValidArray(userPrefs["misc.home_screen_layout"])
|
||||
for each item in homeScreenLayout
|
||||
if item.id = "trending" or item.id = "trending_music" or item.id = "trending_gaming" or item.id = "trending_movies"
|
||||
continue for
|
||||
end if
|
||||
filteredLayout.Push(item)
|
||||
end for
|
||||
if filteredLayout.Count() > 0
|
||||
userPrefs["misc.home_screen_layout"] = filteredLayout
|
||||
end if
|
||||
userPrefs.__version = 6
|
||||
isDirty = true
|
||||
end if
|
||||
|
||||
' TODO:P2 handle case where saved preferences version is higher than current version (e.g. user downgraded)
|
||||
|
||||
#if DEBUG
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
user prefs saved need to be migrated. If the version is less than the
|
||||
current version, a migration is needed.
|
||||
-->
|
||||
<field id="__version" type="integer" value="5" />
|
||||
<field id="__version" type="integer" value="6" />
|
||||
<field id="prefsModel" type="array" />
|
||||
<field id="preferenceFields" type="assocarray" />
|
||||
<function name="GetUserPreferences" />
|
||||
|
||||
@@ -31,7 +31,7 @@ function LoadProfilesFromRegistry()
|
||||
currentProfile: invalid
|
||||
}
|
||||
else
|
||||
userProfiles = ParseJson(userProfiles)
|
||||
userProfiles = StringUtils.ParseJsonSafe(userProfiles)
|
||||
end if
|
||||
|
||||
' Step 2: Migrate existing profiles to new format (if needed)
|
||||
@@ -98,7 +98,7 @@ function MigrateExistingProfiles(userProfiles as object) as boolean
|
||||
return false
|
||||
end if
|
||||
|
||||
authToken = ParseJson(tokenPayload)
|
||||
authToken = StringUtils.ParseJsonSafe(tokenPayload)
|
||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
|
||||
|
||||
if authToken = invalid or authToken.instance = invalid or authToken.token = invalid or authToken.username = invalid
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace SearchHistoryUtils
|
||||
return []
|
||||
end if
|
||||
|
||||
history = ParseJson(history)
|
||||
history = StringUtils.ParseJsonSafe(history)
|
||||
if not IsArray(history)
|
||||
return []
|
||||
end if
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace SponsorBlock
|
||||
class SponsorBlockService
|
||||
function new()
|
||||
' TODO:P2 this is being read and parsed on every skipped segment. It should be cached.
|
||||
m.sponsorBlockConfig = ParseJson(ReadAsciiFile("libpkg:/config/sponsorblock_config.json5"))
|
||||
m.sponsorBlockConfig = StringUtils.ParseJsonSafe(ReadAsciiFile("libpkg:/config/sponsorblock_config.json5"))
|
||||
end function
|
||||
|
||||
function GetCategories() as object
|
||||
|
||||
@@ -15,7 +15,7 @@ end function
|
||||
function OnNodeReady() as void
|
||||
m.top.ObserveField("enabled", FuncName(OnEnabledChanged))
|
||||
m.preferences.ObserveFieldScoped("dev.diagnostics.enabled", FuncName(OnPreferencesChanged))
|
||||
enabled = m.preferences["dev.diagnostics.enabled"]
|
||||
enabled = ValidBool(m.preferences["dev.diagnostics.enabled"])
|
||||
OnPreferencesChanged({
|
||||
enabled: enabled
|
||||
getData: function() as boolean
|
||||
|
||||
@@ -65,31 +65,9 @@ function ExecuteJob() as void
|
||||
})
|
||||
|
||||
if not response.success
|
||||
if response.error = Invidious.ERROR_NOT_AUTHENTICATED
|
||||
if feedSources.Count() = 1
|
||||
parent = feedContentNode.getParent()
|
||||
if parent <> invalid
|
||||
parent.removeChild(feedContentNode)
|
||||
end if
|
||||
JobSuccess()
|
||||
return
|
||||
end if
|
||||
|
||||
continue while
|
||||
end if
|
||||
|
||||
if response.error.instr("Administrator has disabled this endpoint.") > -1
|
||||
LogWarnNoTelemetry(feedSource.endpoint, "feedSource not available:", response.error)
|
||||
if feedSources.Count() = 1
|
||||
parent = feedContentNode.getParent()
|
||||
if parent <> invalid
|
||||
parent.removeChild(feedContentNode)
|
||||
end if
|
||||
JobSuccess()
|
||||
return
|
||||
end if
|
||||
|
||||
continue while
|
||||
if RemoveSingleFailedRow(response.error, feedSource, feedSources, feedContentNode)
|
||||
JobSuccess()
|
||||
return
|
||||
end if
|
||||
|
||||
feedSource.state.loadState = FeedLoadState.Error
|
||||
@@ -243,6 +221,32 @@ function DeduplicateAppendAuthPlaylists(feedContentNode as object, itemNodes as
|
||||
return nodesToAdd.Count()
|
||||
end function
|
||||
|
||||
function RemoveSingleFailedRow(error as dynamic, feedSource as object, feedSources as object, feedContentNode as object) as boolean
|
||||
error = ValidString(error)
|
||||
LogWarnNoTelemetry(feedSource.id, "feedSource not available:", error)
|
||||
|
||||
if feedSources.Count() <> 1
|
||||
return false
|
||||
end if
|
||||
|
||||
isError = error = Invidious.ERROR_NOT_AUTHENTICATED
|
||||
' Invidious admins disable endpoints sometimes
|
||||
isError = isError or error.instr("Administrator has disabled this endpoint") <> -1
|
||||
isError = isError or error.instr("API disabled") <> -1
|
||||
' Playlet not supporting popular
|
||||
isError = isError or feedSource.id = "inv_popular"
|
||||
if not isError
|
||||
return false
|
||||
end if
|
||||
|
||||
parent = feedContentNode.getParent()
|
||||
if parent <> invalid
|
||||
parent.removeChild(feedContentNode)
|
||||
end if
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
function HandleFeedLoadErrorDialog(error as object, isCancelled as boolean, rowList as object) as void
|
||||
error = ErrorUtils.Format(error)
|
||||
if isCancelled
|
||||
|
||||
@@ -4,7 +4,7 @@ import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
namespace Lounge
|
||||
|
||||
function SendNowPlayingLoading(videoId as dynamic) as void
|
||||
function SendNowPlayingLoading(videoId as dynamic, playbackSpeed as float) as void
|
||||
if StringUtils.IsNullOrEmpty(m.loungeService.loungeToken)
|
||||
return
|
||||
end if
|
||||
@@ -16,7 +16,9 @@ namespace Lounge
|
||||
overrides[FIELD_VIDEO_ID] = videoId
|
||||
end if
|
||||
nowPlayingMsg = LoungeMessages.NowPlaying(m.top, overrides)
|
||||
m.loungeService.outgoingMessages = [nowPlayingMsg, loungeStateMsg]
|
||||
' Sending playback speed to indicate that we will reset it to 1.0 when the content starts playing
|
||||
playbackSpeedMsg = LoungeMessages.OnPlaybackSpeedChanged(playbackSpeed, true)
|
||||
m.loungeService.outgoingMessages = [nowPlayingMsg, loungeStateMsg, playbackSpeedMsg]
|
||||
end function
|
||||
|
||||
function SendOnStateChange() as void
|
||||
|
||||
@@ -11,6 +11,7 @@ function ExecuteJob() as void
|
||||
authToken = input.authToken
|
||||
profileType = input.profileType
|
||||
playbackTrackingUrls = input.playbackTrackingUrls
|
||||
cpn = input.cpn
|
||||
|
||||
cancellation = JobGetCancellation()
|
||||
|
||||
@@ -43,9 +44,14 @@ function ExecuteJob() as void
|
||||
return
|
||||
end if
|
||||
|
||||
if StringUtils.IsNullOrEmpty(cpn)
|
||||
cpn = InnertubeService.CreateClientPlaybackNonce()
|
||||
end if
|
||||
|
||||
markedAsWatched = InnertubeService.AuthMarkVideoWatched(playbackTrackingUrls.videostatsPlaybackUrl, {
|
||||
accessToken: authToken.token
|
||||
onBehalfOfUser: authToken.activeIdentifyToken
|
||||
cpn: cpn
|
||||
cancellation: cancellation
|
||||
})
|
||||
if not markedAsWatched
|
||||
@@ -93,6 +99,7 @@ function ExecuteJob() as void
|
||||
success = InnertubeService.AuthMarkVideoWatchTime(watchTime, playbackTrackingUrls.videostatsWatchtimeUrl, {
|
||||
accessToken: authToken.token
|
||||
onBehalfOfUser: authToken.activeIdentifyToken
|
||||
cpn: cpn
|
||||
' TODO:P1 if we pass cancellation here, http client will remove scoped
|
||||
' observer, which is stored on the current node.
|
||||
' This requires an extra observer node to be independent.
|
||||
|
||||
@@ -61,7 +61,6 @@ function ExecuteJob() as void
|
||||
"visitorData": visitorData
|
||||
"accessToken": accessToken
|
||||
"onBehalfOfUser": onBehalfOfUser
|
||||
"signatureTimestamp": true
|
||||
})
|
||||
else
|
||||
metadata = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
|
||||
@@ -99,12 +98,24 @@ function ExecuteJob() as void
|
||||
streamUrls = CreateStreamUrls(metadata, service, preferencesNode, backend, playletServerPort)
|
||||
if streamUrls.Count() = 0
|
||||
contentNode.addFields({ metadata: metadata })
|
||||
JobError("No playable streams found for this video.")
|
||||
error = "No playable streams found for this video."
|
||||
lastPlayerResponse = ValidString(ReadAsciiFile("cachefs:/last_player_response.json"))
|
||||
LogTelemetryEvent({
|
||||
level: "error"
|
||||
message: error
|
||||
fingerprint: error
|
||||
attachments: [{
|
||||
filename: "last_player_response.json"
|
||||
content_type: "application/json"
|
||||
data: lastPlayerResponse
|
||||
}]
|
||||
})
|
||||
JobError(error)
|
||||
return
|
||||
end if
|
||||
|
||||
isDrmDash = SupportsDrmDashManifest(metadata)
|
||||
if isDrmDash
|
||||
isDrm = not StringUtils.IsNullOrEmpty(metadata.drmParams)
|
||||
if isDrm
|
||||
licenseServerURL = UrlUtils.BuildUrl(`http://127.0.0.1:${playletServerPort}/api/innertube/get_drm_license`, invalid, {
|
||||
videoId: metadata.videoId
|
||||
drmParams: metadata.drmParams
|
||||
@@ -150,7 +161,7 @@ function CreateStreamUrls(metadata as object, service as Invidious.InvidiousServ
|
||||
|
||||
streamUrls = []
|
||||
|
||||
if SupportsDrmDashManifest(metadata)
|
||||
if SupportsDrmDashManifestUrl(metadata)
|
||||
dashUrl = UrlUtils.AppendQueryParams(`http://127.0.0.1:${playletServerPort}/api/dash`, {
|
||||
url: metadata.dashUrl
|
||||
})
|
||||
@@ -195,11 +206,15 @@ function SupportsMuxedFormats(metadata as object) as boolean
|
||||
return IsArray(metadata.formatStreams) and metadata.formatStreams.Count() > 0
|
||||
end function
|
||||
|
||||
function SupportsDrmDashManifest(metadata as object) as boolean
|
||||
function SupportsDrmDashManifestUrl(metadata as object) as boolean
|
||||
if StringUtils.IsNullOrEmpty(metadata.drmParams)
|
||||
return false
|
||||
end if
|
||||
|
||||
if StringUtils.IsNullOrEmpty(metadata.dashUrl)
|
||||
return false
|
||||
end if
|
||||
|
||||
if StringUtils.IsNullOrEmpty(metadata.drmSessionId)
|
||||
return false
|
||||
end if
|
||||
@@ -212,10 +227,6 @@ function SupportsDrmDashManifest(metadata as object) as boolean
|
||||
return false
|
||||
end if
|
||||
|
||||
if StringUtils.IsNullOrEmpty(metadata.dashUrl)
|
||||
return false
|
||||
end if
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
@@ -329,7 +340,7 @@ function SetCaptions(metadata as object, service as object, contentNode as objec
|
||||
return
|
||||
end if
|
||||
|
||||
isoLanguageList = ParseJson(ReadAsciiFile("libpkg:/config/ISO-639-1-to-ISO-639-2T.json5"))
|
||||
isoLanguageList = StringUtils.ParseJsonSafe(ReadAsciiFile("libpkg:/config/ISO-639-1-to-ISO-639-2T.json5"))
|
||||
instance = service.GetInstance()
|
||||
|
||||
subtitleTracks = []
|
||||
|
||||
@@ -13,6 +13,18 @@ import "pkg:/source/utils/ErrorUtils.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
|
||||
enum DownloadErrors
|
||||
Unknown = 900
|
||||
TimeoutByCurl = 950
|
||||
TimeoutBySelector = 951
|
||||
Abort = 960
|
||||
AbortByServer = 961
|
||||
AbortBySelector = 962
|
||||
AbortByParallel = 963
|
||||
ParallelFragmentError = 964
|
||||
BadMedia = 970
|
||||
end enum
|
||||
|
||||
function Init()
|
||||
SetPlayerStyle()
|
||||
SetupAnimation()
|
||||
@@ -152,7 +164,12 @@ function PlayWithContent(contentNode as object)
|
||||
end if
|
||||
|
||||
StartVideoContentJob(videoContentNode)
|
||||
Lounge.SendNowPlayingLoading(contentNode.videoId)
|
||||
|
||||
playbackSpeed = ValidFloat(m.top.playbackSpeed)
|
||||
if playbackSpeed <= 0
|
||||
playbackSpeed = 1.0
|
||||
end if
|
||||
Lounge.SendNowPlayingLoading(contentNode.videoId, playbackSpeed)
|
||||
end function
|
||||
|
||||
function StartVideoContentJob(videoContentNode as object)
|
||||
@@ -214,7 +231,7 @@ function OnVideoContentJobDone(event as object) as void
|
||||
SeekToInitialPosition(content)
|
||||
|
||||
PlayAfterPreviousPlayerHasStopped()
|
||||
MarkVideoWatched(content.videoId, metadata.playbackTrackingUrls)
|
||||
MarkVideoWatched(content.videoId, metadata.playbackTrackingUrls, metadata.cpn)
|
||||
end function
|
||||
|
||||
function SeekToInitialPosition(content as object) as void
|
||||
@@ -317,6 +334,9 @@ function OnVideoContentJobErrorDialogResponse(event as object)
|
||||
shouldPlayNext = false
|
||||
if event <> invalid
|
||||
dialog = event.getRoSGNode()
|
||||
if m.errorDialog <> invalid and dialog.isSameNode(m.errorDialog)
|
||||
m.errorDialog = invalid
|
||||
end if
|
||||
dialog.unobserveFieldScoped("wasClosed")
|
||||
shouldPlayNext = dialog.actualButtonSelected = 0
|
||||
end if
|
||||
@@ -330,7 +350,7 @@ function OnVideoContentJobErrorDialogResponse(event as object)
|
||||
Lounge.SendOnStateChange()
|
||||
end function
|
||||
|
||||
function MarkVideoWatched(videoId as dynamic, playbackTrackingUrls as dynamic) as void
|
||||
function MarkVideoWatched(videoId as dynamic, playbackTrackingUrls as dynamic, cpn as dynamic) as void
|
||||
if StringUtils.IsNullOrEmpty(videoId)
|
||||
return
|
||||
end if
|
||||
@@ -353,6 +373,7 @@ function MarkVideoWatched(videoId as dynamic, playbackTrackingUrls as dynamic) a
|
||||
authToken: authToken
|
||||
profileType: profileType
|
||||
playbackTrackingUrls: playbackTrackingUrls
|
||||
cpn: cpn
|
||||
}
|
||||
|
||||
m.markVideoWatchedJob = JobSystem.CreateCallback()
|
||||
@@ -432,6 +453,14 @@ function OnVideoPlayerStateChange() as void
|
||||
' Reset isSeekingPosition when started to play the video
|
||||
if state = "playing"
|
||||
m.isSeekingPosition = false
|
||||
|
||||
' If we somehow was able to recover playback after an error dialog, close the dialog
|
||||
errorDialog = m.errorDialog
|
||||
if errorDialog <> invalid
|
||||
m.errorDialog = invalid
|
||||
errorDialog.unobserveFieldScoped("wasClosed")
|
||||
errorDialog.close = true
|
||||
end if
|
||||
end if
|
||||
|
||||
' If we successfully played the video, then any error that comes later is not due to a 403 (FORBIDDEN).
|
||||
@@ -441,32 +470,23 @@ function OnVideoPlayerStateChange() as void
|
||||
m.videoPlayingSuccess = true
|
||||
end if
|
||||
|
||||
errorReported = false
|
||||
errorData = invalid
|
||||
if state = "error"
|
||||
errorInfo = m.top.errorInfo
|
||||
errorData = GetPlayerErrorData(content.videoId, errorInfo)
|
||||
|
||||
LogErrorNoTelemetry(errorData.title, errorData.body)
|
||||
ReportVideoError(errorData, content.url)
|
||||
errorReported = true
|
||||
|
||||
if m.videoPlayingSuccess <> true
|
||||
' http for stream format, mediaerror for DASH
|
||||
if errorInfo.category = "http" or errorInfo.category = "mediaerror"
|
||||
currentUrl = content.url
|
||||
playletStreamUrls = content.playletStreamUrls
|
||||
playletStreamUrlIndex = content.playletStreamUrlIndex
|
||||
playletStreamUrlIndex++
|
||||
content.playletStreamUrlIndex = playletStreamUrlIndex
|
||||
if playletStreamUrlIndex < playletStreamUrls.Count()
|
||||
nextUrl = playletStreamUrls[playletStreamUrlIndex]
|
||||
msg = `Stream ${currentUrl} failed to play. Trying next stream ${nextUrl}`
|
||||
LogErrorNoTelemetry(msg)
|
||||
LogTelemetryEvent({
|
||||
level: "error"
|
||||
message: msg
|
||||
fingerprint: ["Stream <URL> failed to play. Trying next stream <URL>"]
|
||||
})
|
||||
currentUrlIndex = content.playletStreamUrlIndex
|
||||
nextUrlIndex = currentUrlIndex + 1
|
||||
content.playletStreamUrlIndex = nextUrlIndex
|
||||
if nextUrlIndex < playletStreamUrls.Count()
|
||||
currentUrl = content.url
|
||||
nextUrl = playletStreamUrls[nextUrlIndex]
|
||||
|
||||
if StringUtils.IsNullOrEmpty(nextUrl)
|
||||
LogError("Next stream URL is empty, cannot try next stream")
|
||||
@@ -487,6 +507,12 @@ function OnVideoPlayerStateChange() as void
|
||||
if hasTimestamp and timestamp > 0
|
||||
m.top.seek = content.timestamp
|
||||
end if
|
||||
|
||||
msg = `Stream ${currentUrl} failed to play. Trying next stream ${nextUrl}`
|
||||
LogErrorNoTelemetry(msg)
|
||||
|
||||
errorData.title = msg + `\n` + errorData.title
|
||||
ReportVideoError(errorData, currentUrl, playletStreamUrls, currentUrlIndex, false)
|
||||
return
|
||||
end if
|
||||
end if
|
||||
@@ -504,18 +530,14 @@ function OnVideoPlayerStateChange() as void
|
||||
end if
|
||||
|
||||
if state = "error"
|
||||
errorInfo = m.top.errorInfo
|
||||
errorData = GetPlayerErrorData(content.videoId, errorInfo)
|
||||
|
||||
LogErrorNoTelemetry(errorData.title, errorData.body)
|
||||
if not errorReported
|
||||
ReportVideoError(errorData, content.url)
|
||||
end if
|
||||
ReportVideoError(errorData, content.url, content.playletStreamUrls, content.playletStreamUrlIndex, true)
|
||||
|
||||
buttons = [Tr(Locale.Buttons.PlayNextVideo), Tr(Locale.Buttons.Cancel)]
|
||||
|
||||
dialog = DialogUtils.ShowTimedDialogButtons(errorData.body, errorData.title, buttons, 0, 10, true)
|
||||
if dialog <> invalid
|
||||
m.errorDialog = dialog
|
||||
dialog.observeFieldScoped("wasClosed", FuncName(OnVideoContentJobErrorDialogResponse))
|
||||
else
|
||||
OnVideoContentJobErrorDialogResponse(invalid)
|
||||
@@ -557,7 +579,7 @@ function GetPlayerErrorData(videoId as string, errorInfo as object) as object
|
||||
}
|
||||
end function
|
||||
|
||||
function ReportVideoError(errorData as object, url as string) as void
|
||||
function ReportVideoError(errorData as object, url as dynamic, urls as object, urlIndex as dynamic, shownInDialog as boolean) as void
|
||||
attachments = invalid
|
||||
if errorData.body.Instr("malformed data") <> -1 or errorData.body.Instr("invalid pathname") <> -1
|
||||
lastGeneratedDash = ValidString(ReadAsciiFile("cachefs:/last_generated_dash.xml"))
|
||||
@@ -579,9 +601,30 @@ function ReportVideoError(errorData as object, url as string) as void
|
||||
}]
|
||||
end if
|
||||
|
||||
position = m.top.position
|
||||
duration = m.top.duration
|
||||
message = [
|
||||
errorData.title
|
||||
errorData.body
|
||||
`Dialog shown: ${shownInDialog}`
|
||||
`Position: ${position}`
|
||||
`Duration: ${duration}`
|
||||
`Url: ${url}`
|
||||
`Urls: ` + ToString(urls)
|
||||
`Url index: ${urlIndex}`
|
||||
].Join(`\n`)
|
||||
|
||||
errorData.fingerprint.push(shownInDialog)
|
||||
|
||||
if shownInDialog
|
||||
level = "error"
|
||||
else
|
||||
level = "warning"
|
||||
end if
|
||||
|
||||
LogTelemetryEvent({
|
||||
level: "error"
|
||||
message: errorData.title + " " + errorData.body + `\nurl: ${url}`
|
||||
level: level
|
||||
message: message
|
||||
fingerprint: errorData.fingerprint
|
||||
attachments: attachments
|
||||
})
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Http
|
||||
|
||||
m.videoQueueNode = server.sceneNodes.videoQueue
|
||||
m.invidiousNode = server.sceneNodes.invidious
|
||||
m.preferencesNode = server.sceneNodes.preferences
|
||||
m.invidiousService = new Invidious.InvidiousService(m.invidiousNode)
|
||||
' No need to pass the invidious instance here, we will refresh it for
|
||||
' each request to make sure we are using the latest one
|
||||
@@ -51,9 +52,28 @@ namespace Http
|
||||
end if
|
||||
|
||||
m.dashManifest.invidiousInstance = m.invidiousService.GetInstance()
|
||||
m.dashManifest.disableAutoDubbed = ValidBool(m.preferencesNode["playback.disable_auto_dubbed"])
|
||||
|
||||
qualityFilter = m.CreateQualityFilter(quality)
|
||||
xmlContent = m.dashManifest.fromVideoMetadata(metadata, qualityFilter, ValidString(local) = "true")
|
||||
xmlContent = m.dashManifest.FromVideoMetadata(metadata, qualityFilter, ValidString(local) = "true")
|
||||
|
||||
if xmlContent.InStr("[ERROR]") <> -1
|
||||
LogErrorNoTelemetry("Dash manifest generated with errors")
|
||||
lastPlayerResponse = ValidString(ReadAsciiFile("cachefs:/last_player_response.json"))
|
||||
LogTelemetryEvent({
|
||||
level: "error"
|
||||
message: "Dash manifest generated with errors"
|
||||
attachments: [{
|
||||
filename: "dash.xml"
|
||||
content_type: "text/plain"
|
||||
data: xmlContent
|
||||
}, {
|
||||
filename: "last_player_response.json"
|
||||
content_type: "application/json"
|
||||
data: lastPlayerResponse
|
||||
}]
|
||||
})
|
||||
end if
|
||||
|
||||
response.http_code = 200
|
||||
response.SetBodyDataString(xmlContent)
|
||||
@@ -115,7 +135,7 @@ namespace Http
|
||||
|
||||
xml = new XmlObject()
|
||||
manifestObj = new DashManifest("")
|
||||
manifestObj.generateImageAdaptationSets(xml, storyboards, 100)
|
||||
manifestObj.GenerateImageAdaptationSets(xml, storyboards, 100)
|
||||
storyboardXml = xml.ToXmlString(false)
|
||||
|
||||
newDashContent = dashContent.Left(storyboardIndex) + storyboardXml + dashContent.Mid(storyboardIndex)
|
||||
|
||||
@@ -127,6 +127,9 @@ namespace Http
|
||||
if ValidBool(metadata.liveNow) or ValidBool(metadata.hasLiveStreamingData)
|
||||
return hlsManifest
|
||||
end if
|
||||
if hlsManifest.InStr("/source/yt_live_broadcast") <> -1 or hlsManifest.InStr("/live/1") <> -1
|
||||
return hlsManifest
|
||||
end if
|
||||
|
||||
storyboards = metadata.storyboards
|
||||
if not IsArray(storyboards)
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Http
|
||||
return true
|
||||
end if
|
||||
|
||||
feedSource = ParseJson(feedSource)
|
||||
feedSource = StringUtils.ParseJsonSafe(feedSource)
|
||||
if feedSource = invalid
|
||||
response.Default(400, "Expected valid JSON for feed-source")
|
||||
return true
|
||||
|
||||
+54
-99
@@ -56,17 +56,13 @@ namespace Http
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
accessToken = m.RequireAccessToken(request, response)
|
||||
if accessToken = invalid
|
||||
return true
|
||||
end if
|
||||
|
||||
options = {
|
||||
"accessToken": accessToken.Mid("Bearer ".Len())
|
||||
"accessToken": accessToken
|
||||
"disableShorts": m.preferences["content_feed.disable_shorts"]
|
||||
}
|
||||
|
||||
@@ -117,12 +113,8 @@ namespace Http
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
accessToken = m.RequireAccessToken(request, response)
|
||||
if accessToken = invalid
|
||||
return true
|
||||
end if
|
||||
|
||||
@@ -135,17 +127,13 @@ namespace Http
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
accessToken = m.RequireAccessToken(request, response)
|
||||
if accessToken = invalid
|
||||
return true
|
||||
end if
|
||||
|
||||
options = {
|
||||
"accessToken": accessToken.Mid("Bearer ".Len())
|
||||
"accessToken": accessToken
|
||||
}
|
||||
|
||||
activeIdentifyToken = request.query.activeIdentifyToken
|
||||
@@ -187,17 +175,13 @@ namespace Http
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
accessToken = m.RequireAccessToken(request, response)
|
||||
if accessToken = invalid
|
||||
return true
|
||||
end if
|
||||
|
||||
options = {
|
||||
"accessToken": accessToken.Mid("Bearer ".Len())
|
||||
"accessToken": accessToken
|
||||
}
|
||||
|
||||
activeIdentifyToken = request.query.activeIdentifyToken
|
||||
@@ -253,9 +237,8 @@ namespace Http
|
||||
return true
|
||||
end function
|
||||
|
||||
@get("/playlet-invidious-backend/api/v1/trending")
|
||||
@get("/playlet-invidious-backend/api/v1/popular")
|
||||
function GetTrending(context as object) as boolean
|
||||
function GetPopular(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
@@ -264,40 +247,10 @@ namespace Http
|
||||
return m.GetAuthRecommended(context)
|
||||
end if
|
||||
|
||||
raw = request.query.raw <> invalid
|
||||
|
||||
options = {
|
||||
"disableShorts": m.preferences["content_feed.disable_shorts"]
|
||||
raw: raw
|
||||
type: request.query.type
|
||||
}
|
||||
|
||||
result = InnertubeService.GetTrending(options)
|
||||
if raw
|
||||
response.Json(result)
|
||||
return true
|
||||
end if
|
||||
|
||||
if result.error <> invalid
|
||||
response.Json(result)
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
|
||||
if not IsArray(result.feeds) or result.feeds.Count() = 0
|
||||
response.Json({
|
||||
"error": "Failed to get trending feed"
|
||||
})
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
|
||||
response.Json(ValidArray(result.feeds[0].items))
|
||||
|
||||
if result.DoesExist("cache-control")
|
||||
response.headers["cache-control"] = result["cache-control"]
|
||||
end if
|
||||
|
||||
response.Json({
|
||||
"error": "Playlet built-in Invidious backend does not support popular videos."
|
||||
})
|
||||
response.http_code = 400
|
||||
return true
|
||||
end function
|
||||
|
||||
@@ -305,17 +258,13 @@ namespace Http
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
accessToken = m.RequireAccessToken(request, response)
|
||||
if accessToken = invalid
|
||||
return true
|
||||
end if
|
||||
|
||||
options = {
|
||||
"accessToken": accessToken.Mid("Bearer ".Len())
|
||||
"accessToken": accessToken
|
||||
"disableShorts": m.preferences["content_feed.disable_shorts"]
|
||||
}
|
||||
|
||||
@@ -346,10 +295,6 @@ namespace Http
|
||||
|
||||
response.Json(result.feeds[0])
|
||||
|
||||
if result.DoesExist("cache-control")
|
||||
response.headers["cache-control"] = result["cache-control"]
|
||||
end if
|
||||
|
||||
return true
|
||||
end function
|
||||
|
||||
@@ -619,7 +564,6 @@ namespace Http
|
||||
}
|
||||
end if
|
||||
else
|
||||
options["signatureTimestamp"] = true
|
||||
options["credentialTransferToken"] = m.loungeService.credentialTransferToken
|
||||
metadata = InnertubeService.GetVideoMetadata(videoId, options)
|
||||
end if
|
||||
@@ -660,9 +604,9 @@ namespace Http
|
||||
raw: raw
|
||||
}
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if not StringUtils.IsNullOrEmpty(accessToken) and accessToken.StartsWith("Bearer ")
|
||||
options["accessToken"] = accessToken.Mid("Bearer ".Len())
|
||||
accessToken = m.GetAccessToken(request)
|
||||
if accessToken <> invalid
|
||||
options["accessToken"] = accessToken
|
||||
|
||||
activeIdentifyToken = request.query.activeIdentifyToken
|
||||
if not StringUtils.IsNullOrEmpty(activeIdentifyToken)
|
||||
@@ -728,12 +672,8 @@ namespace Http
|
||||
response = context.response
|
||||
route = request.route
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
accessToken = m.RequireAccessToken(request, response)
|
||||
if accessToken = invalid
|
||||
return true
|
||||
end if
|
||||
|
||||
@@ -804,7 +744,7 @@ namespace Http
|
||||
' (such as "newest", "oldest", etc.), we'll ignore it, as it is not supported.
|
||||
sortBy = request.query.sort_by
|
||||
if not StringUtils.IsNullOrEmpty(sortBy) and sortBy.StartsWith("{")
|
||||
sortBy = ParseJson(sortBy)
|
||||
sortBy = StringUtils.ParseJsonSafe(sortBy)
|
||||
if IsAssociativeArray(sortBy)
|
||||
if sortBy.DoesExist("params")
|
||||
options.params = sortBy.params
|
||||
@@ -886,12 +826,8 @@ namespace Http
|
||||
response = context.response
|
||||
route = request.route
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
accessToken = m.RequireAccessToken(request, response)
|
||||
if accessToken = invalid
|
||||
return true
|
||||
end if
|
||||
|
||||
@@ -909,7 +845,7 @@ namespace Http
|
||||
end if
|
||||
|
||||
options = {
|
||||
"accessToken": accessToken.Mid("Bearer ".Len())
|
||||
"accessToken": accessToken
|
||||
}
|
||||
|
||||
activeIdentifyToken = request.query.activeIdentifyToken
|
||||
@@ -946,12 +882,8 @@ namespace Http
|
||||
response = context.response
|
||||
route = request.route
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
accessToken = m.RequireAccessToken(request, response)
|
||||
if accessToken = invalid
|
||||
return true
|
||||
end if
|
||||
|
||||
@@ -969,7 +901,7 @@ namespace Http
|
||||
end if
|
||||
|
||||
options = {
|
||||
"accessToken": accessToken.Mid("Bearer ".Len())
|
||||
"accessToken": accessToken
|
||||
}
|
||||
|
||||
activeIdentifyToken = request.query.activeIdentifyToken
|
||||
@@ -1049,6 +981,29 @@ namespace Http
|
||||
return true
|
||||
end function
|
||||
|
||||
|
||||
function GetAccessToken(request as object) as dynamic
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
return accessToken.Mid("Bearer ".Len())
|
||||
end function
|
||||
|
||||
function RequireAccessToken(request as object, response as object) as dynamic
|
||||
accessToken = m.GetAccessToken(request)
|
||||
if accessToken = invalid
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header. Please login again."
|
||||
})
|
||||
response.http_code = 403
|
||||
return invalid
|
||||
end if
|
||||
|
||||
return accessToken
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -19,7 +19,7 @@ namespace Http
|
||||
|
||||
saved = RegistryUtils.Read(RegistryUtils.PLAYLET_LIB_URLS)
|
||||
if saved <> invalid
|
||||
saved = ParseJson(saved)
|
||||
saved = StringUtils.ParseJsonSafe(saved)
|
||||
end if
|
||||
|
||||
response.Json({
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace Http
|
||||
return invalid
|
||||
end if
|
||||
|
||||
m.body_json = ParseJson(text)
|
||||
m.body_json = StringUtils.ParseJsonSafe(text)
|
||||
return m.body_json
|
||||
end function
|
||||
end class
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Http
|
||||
if StringUtils.IsNullOrEmpty(json)
|
||||
return "application/octet-stream"
|
||||
end if
|
||||
map = ParseJson(json)
|
||||
map = StringUtils.ParseJsonSafe(json)
|
||||
if not IsAssociativeArray(map)
|
||||
return "application/octet-stream"
|
||||
end if
|
||||
@@ -41,7 +41,7 @@ namespace Http
|
||||
if StringUtils.IsNullOrEmpty(json)
|
||||
return ""
|
||||
end if
|
||||
map = ParseJson(json)
|
||||
map = StringUtils.ParseJsonSafe(json)
|
||||
if not IsAssociativeArray(map)
|
||||
return ""
|
||||
end if
|
||||
|
||||
@@ -83,10 +83,10 @@ namespace Web
|
||||
for i = 7 to 0 step -1
|
||||
m.payload_size_buffer[i] = payloadSize and &hFF
|
||||
payloadSize = payloadSize >> 8
|
||||
next
|
||||
end for
|
||||
for i = 0 to 7
|
||||
m.WriteByte(m.payload_size_buffer[i])
|
||||
next
|
||||
end for
|
||||
end if
|
||||
end function
|
||||
|
||||
|
||||
@@ -14,44 +14,6 @@
|
||||
apiType: Invidious
|
||||
endpoint: auth_recommended
|
||||
|
||||
- title: Trending
|
||||
id: trending
|
||||
feedSources:
|
||||
- id: inv_trending
|
||||
title: Trending
|
||||
apiType: Invidious
|
||||
endpoint: trending
|
||||
|
||||
- title: Trending - Music
|
||||
id: trending_music
|
||||
feedSources:
|
||||
- id: inv_trending_music
|
||||
title: Trending - Music
|
||||
apiType: Invidious
|
||||
endpoint: trending
|
||||
queryParams:
|
||||
type: Music
|
||||
|
||||
- title: Trending - Gaming
|
||||
id: trending_gaming
|
||||
feedSources:
|
||||
- id: inv_trending_gaming
|
||||
title: Trending - Gaming
|
||||
apiType: Invidious
|
||||
endpoint: trending
|
||||
queryParams:
|
||||
type: Gaming
|
||||
|
||||
- title: Trending - Movies
|
||||
id: trending_movies
|
||||
feedSources:
|
||||
- id: inv_trending_movies
|
||||
title: Trending - Movies
|
||||
apiType: Invidious
|
||||
endpoint: trending
|
||||
queryParams:
|
||||
type: Movies
|
||||
|
||||
- title: Popular
|
||||
id: popular
|
||||
feedSources:
|
||||
|
||||
@@ -1,18 +1,3 @@
|
||||
trending:
|
||||
title: Trending
|
||||
url: /api/v1/trending
|
||||
cacheSeconds: 21600 # 6 hours
|
||||
queryParams:
|
||||
type:
|
||||
type:
|
||||
- Music
|
||||
- Gaming
|
||||
- Movies
|
||||
region:
|
||||
type: "#ISO3166"
|
||||
default: GetUserCountryCode
|
||||
tryCount: 3 # trending is being phased out, sometimes it returns a 400 INVALID_ARGUMENT
|
||||
|
||||
popular:
|
||||
title: Popular
|
||||
url: /api/v1/popular
|
||||
|
||||
@@ -27,6 +27,13 @@
|
||||
visibility: "web",
|
||||
svelteComponent: "EditQualityControl",
|
||||
},
|
||||
{
|
||||
displayText: "Disable auto-dubbed audio",
|
||||
key: "playback.disable_auto_dubbed",
|
||||
description: "Remove AI-generated dubbed audio tracks.",
|
||||
type: "boolean",
|
||||
defaultValue: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -243,22 +250,6 @@
|
||||
id: "recommended",
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
id: "trending",
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
id: "trending_music",
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
id: "trending_gaming",
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
id: "trending_movies",
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
id: "popular",
|
||||
enabled: true,
|
||||
|
||||
@@ -312,22 +312,6 @@
|
||||
<source>Watch history</source>
|
||||
<translation>Wiedergabeverlauf</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending</source>
|
||||
<translation>Trends</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Movies</source>
|
||||
<translation>Trends - Filme</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Music</source>
|
||||
<translation>Trends - Musik</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Gaming</source>
|
||||
<translation>Trends - Gaming</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Popular</source>
|
||||
<translation>Populär</translation>
|
||||
|
||||
@@ -88,22 +88,6 @@
|
||||
<source>Watch history</source>
|
||||
<translation>Watch history</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending</source>
|
||||
<translation>Trending</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Movies</source>
|
||||
<translation>Trending - Movies</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Music</source>
|
||||
<translation>Trending - Music</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Gaming</source>
|
||||
<translation>Trending - Gaming</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Popular</source>
|
||||
<translation>Popular</translation>
|
||||
@@ -816,6 +800,14 @@
|
||||
<source>Feed preferences</source>
|
||||
<translation>Feed preferences</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Disable auto-dubbed audio</source>
|
||||
<translation>Disable auto-dubbed audio</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remove AI-generated dubbed audio tracks.</source>
|
||||
<translation>Remove AI-generated dubbed audio tracks.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Disable Shorts</source>
|
||||
<translation>Disable Shorts</translation>
|
||||
|
||||
@@ -80,22 +80,6 @@
|
||||
<source>Watch history</source>
|
||||
<translation>Ver el historial</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending</source>
|
||||
<translation>Tendencias</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Movies</source>
|
||||
<translation>Tendencias - Películas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Music</source>
|
||||
<translation>Tendencias - Música</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Gaming</source>
|
||||
<translation>Tendencias - Juegos</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Popular</source>
|
||||
<translation>Popular</translation>
|
||||
|
||||
@@ -36,10 +36,6 @@
|
||||
<source>Filters</source>
|
||||
<translation>Filtros</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Music</source>
|
||||
<translation>Tendencias - Música</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Login to Invidious in order to view Subscriptions, Playlists, and use the Watch history.</source>
|
||||
<translation>Accede a Invidious para ver tus suscripciones, playlists, y usar el historial de reproducción.</translation>
|
||||
@@ -80,18 +76,6 @@
|
||||
<source>Watch history</source>
|
||||
<translation>Historial de reproducción</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending</source>
|
||||
<translation>Tendencias</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Movies</source>
|
||||
<translation>Tendencias - Películas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Gaming</source>
|
||||
<translation>Tendencias - Videojuegos</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Edit</source>
|
||||
<translation>Editar</translation>
|
||||
|
||||
@@ -76,22 +76,6 @@
|
||||
<source>Watch history</source>
|
||||
<translation>Historique</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending</source>
|
||||
<translation>Tendances</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Movies</source>
|
||||
<translation>Tendances - Films</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Music</source>
|
||||
<translation>Tendances - Musique</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Gaming</source>
|
||||
<translation>Tendances - Jeux vidéo</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Popular</source>
|
||||
<translation>Populaire</translation>
|
||||
|
||||
@@ -140,22 +140,6 @@
|
||||
<source>Watch history</source>
|
||||
<translation>Histórico de assistidos</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending</source>
|
||||
<translation>Em alta</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Movies</source>
|
||||
<translation>Em alta - Flimes</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Music</source>
|
||||
<translation>Em alta - Música</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Trending - Gaming</source>
|
||||
<translation>Em alta - Jogos</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Popular</source>
|
||||
<translation>Popular</translation>
|
||||
|
||||
@@ -2,8 +2,8 @@ title=PlayletLib
|
||||
|
||||
# Do not update version manually, it is auto updated from package.json
|
||||
major_version=0
|
||||
minor_version=43
|
||||
build_version=00003
|
||||
minor_version=45
|
||||
build_version=00000
|
||||
|
||||
ui_resolutions=hd
|
||||
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
||||
|
||||
@@ -299,6 +299,11 @@ namespace HttpClient
|
||||
return m
|
||||
end function
|
||||
|
||||
function ToFile(filePath as string) as HttpRequest
|
||||
m._toFilePath = filePath
|
||||
return m
|
||||
end function
|
||||
|
||||
function ToCurlCommand() as string
|
||||
command = `curl "${m.BuildUrl()}"`
|
||||
if m._method = "HEAD"
|
||||
@@ -387,6 +392,10 @@ namespace HttpClient
|
||||
end if
|
||||
#end if
|
||||
|
||||
if m._toFilePath <> invalid and m._method <> "GET"
|
||||
throw "ToFile() can only be used with GET requests."
|
||||
end if
|
||||
|
||||
if m._method = "POST"
|
||||
body = m._body
|
||||
if body = invalid
|
||||
@@ -394,7 +403,11 @@ namespace HttpClient
|
||||
end if
|
||||
m._sent = m.urlTransfer.AsyncPostFromString(body)
|
||||
else if m._method = "GET"
|
||||
m._sent = m.urlTransfer.AsyncGetToString()
|
||||
if m._toFilePath <> invalid
|
||||
m._sent = m.urlTransfer.AsyncGetToFile(m._toFilePath)
|
||||
else
|
||||
m._sent = m.urlTransfer.AsyncGetToString()
|
||||
end if
|
||||
else if m._method = "HEAD"
|
||||
m._sent = m.urlTransfer.AsyncHead()
|
||||
else
|
||||
@@ -441,7 +454,7 @@ namespace HttpClient
|
||||
backoffMs = 1000 + Rnd(2000)
|
||||
tryNumber = m._tryCount - triesLeft + 1
|
||||
LogWarnNoTelemetry("Request failed ID:", m.urlTransfer.GetIdentity(), "ErrorMessage:", response.ErrorMessage(), `\nRetrying: (`, tryNumber, "/", m._tryCount, ") in", backoffMs, "ms")
|
||||
LogWarnTelemetry(response.ErrorMessage())
|
||||
LogWarnTelemetry(response.ErrorMessage() + `\n` + m.ToCurlCommand())
|
||||
|
||||
if IsFunction(m._retryCallback)
|
||||
try
|
||||
@@ -690,7 +703,7 @@ namespace HttpClient
|
||||
if text = invalid
|
||||
return invalid
|
||||
end if
|
||||
m._json = ParseJson(text)
|
||||
m._json = StringUtils.ParseJsonSafe(text)
|
||||
return m._json
|
||||
end function
|
||||
|
||||
@@ -800,7 +813,7 @@ namespace HttpClientCache
|
||||
end if
|
||||
|
||||
metadataText = cacheText.Left(firstLineIndex)
|
||||
metadata = ParseJson(metadataText)
|
||||
metadata = StringUtils.ParseJsonSafe(metadataText)
|
||||
if metadata = invalid
|
||||
LogWarn("Failed to parse metadata from cache.")
|
||||
Delete(request)
|
||||
@@ -808,7 +821,7 @@ namespace HttpClientCache
|
||||
end if
|
||||
|
||||
headersText = cacheText.Mid(firstLineIndex + 1, metadata.headers)
|
||||
headers = ParseJson(headersText)
|
||||
headers = StringUtils.ParseJsonSafe(headersText)
|
||||
if headers = invalid
|
||||
LogWarn("Failed to parse headers from cache.")
|
||||
Delete(request)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
namespace DebugUtils
|
||||
function PrintStackTrace(message = invalid as dynamic)
|
||||
#if DEBUG
|
||||
#if DEBUG
|
||||
namespace DebugUtils
|
||||
function PrintStackTrace(message = invalid as dynamic)
|
||||
|
||||
try
|
||||
throw "Handled throw in DebugUtils.PrintStackTrace()"
|
||||
catch error
|
||||
@@ -15,11 +16,9 @@ namespace DebugUtils
|
||||
end for
|
||||
PrintInABox(lines)
|
||||
end try
|
||||
#end if
|
||||
end function
|
||||
end function
|
||||
|
||||
function PrintInABox(lines as object)
|
||||
#if DEBUG
|
||||
function PrintInABox(lines as object)
|
||||
maxLen = 0
|
||||
for each line in lines
|
||||
if line.len() > maxLen
|
||||
@@ -32,6 +31,6 @@ namespace DebugUtils
|
||||
end for
|
||||
out += `\n` + "╚" + string(maxLen + 2, "═") + "╝"
|
||||
print out
|
||||
#end if
|
||||
end function
|
||||
end namespace
|
||||
end function
|
||||
end namespace
|
||||
#end if
|
||||
@@ -26,14 +26,14 @@ function DisposeObservers()
|
||||
if m._disposableObserveFields <> invalid
|
||||
for each item in m._disposableObserveFields
|
||||
item.node.UnobserveField(item.field)
|
||||
next
|
||||
end for
|
||||
m._disposableObserveFields = invalid
|
||||
end if
|
||||
|
||||
if m._disposableObserveFieldsScoped <> invalid
|
||||
for each item in m._disposableObserveFieldsScoped
|
||||
item.node.UnobserveFieldScoped(item.field)
|
||||
next
|
||||
end for
|
||||
m._disposableObserveFieldsScoped = invalid
|
||||
end if
|
||||
end function
|
||||
@@ -41,10 +41,6 @@ namespace Locale
|
||||
Recommended = "Recommended"
|
||||
Playlists = "Playlists"
|
||||
WatchHistory = "Watch history"
|
||||
Trending = "Trending"
|
||||
TrendingMovies = "Trending - Movies"
|
||||
TrendingMusic = "Trending - Music"
|
||||
TrendingGaming = "Trending - Gaming"
|
||||
Popular = "Popular"
|
||||
Videos = "Videos"
|
||||
Shorts = "Shorts"
|
||||
@@ -257,6 +253,9 @@ namespace Locale
|
||||
PreferredQualityDescription = "Preferred video quality"
|
||||
AutoQuality = "Auto"
|
||||
|
||||
DisableAutoDubbedAudio = "Disable auto-dubbed audio"
|
||||
DisableAutoDubbedAudioDescription = "Remove AI-generated dubbed audio tracks."
|
||||
|
||||
Backend = "Backend"
|
||||
BackendPreferences = "Backend preferences"
|
||||
SelectedBackend = "Selected backend"
|
||||
|
||||
@@ -29,5 +29,18 @@ namespace StringUtils
|
||||
function RandomId() as string
|
||||
return StrI(rnd(2147483647), 36)
|
||||
end function
|
||||
|
||||
function ParseJsonSafe(jsonString as dynamic) as dynamic
|
||||
if IsNullOrEmpty(jsonString)
|
||||
return invalid
|
||||
end if
|
||||
' bs:disable-next-line NO_PARSE_JSON
|
||||
json = ParseJson(jsonString)
|
||||
if json <> invalid
|
||||
return json
|
||||
end if
|
||||
' bs:disable-next-line NO_PARSE_JSON
|
||||
return ParseJson(jsonString.Replace("\u0000", ""))
|
||||
end function
|
||||
end namespace
|
||||
|
||||
Generated
+1336
-1668
File diff suppressed because it is too large.
Load diff
+17
-18
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playlet-web",
|
||||
"version": "0.43.3",
|
||||
"version": "0.45.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -9,29 +9,28 @@
|
||||
"lint": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
||||
"@tailwindcss/postcss": "^4.1.16",
|
||||
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
||||
"@tailwindcss/postcss": "^4.3.0",
|
||||
"@tailwindcss/typography": "^0.5.19",
|
||||
"@tsconfig/svelte": "^5.0.5",
|
||||
"@vitejs/plugin-legacy": "^7.2.1",
|
||||
"autoprefixer": "^10.4.21",
|
||||
"@tsconfig/svelte": "^5.0.8",
|
||||
"@vitejs/plugin-legacy": "^8.0.2",
|
||||
"autoprefixer": "^10.5.0",
|
||||
"bgutils-js": "^3.2.0",
|
||||
"daisyui": "^5.3.9",
|
||||
"dotenv": "^17.2.3",
|
||||
"daisyui": "^5.5.20",
|
||||
"dotenv": "^17.4.2",
|
||||
"ip": "^2.0.1",
|
||||
"jszip": "^3.10.1",
|
||||
"postcss": "^8.5.6",
|
||||
"rollup-plugin-visualizer": "^6.0.5",
|
||||
"svelte": "^5.41.4",
|
||||
"svelte-check": "^4.3.3",
|
||||
"svelte-preprocess": "^6.0.3",
|
||||
"tailwindcss": "^4.1.16",
|
||||
"terser": "^5.44.0",
|
||||
"postcss": "^8.5.15",
|
||||
"rollup-plugin-visualizer": "^7.0.1",
|
||||
"svelte": "^5.55.9",
|
||||
"svelte-check": "^4.4.8",
|
||||
"svelte-preprocess": "6.0.3",
|
||||
"tailwindcss": "^4.3.0",
|
||||
"terser": "^5.48.0",
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.9.3",
|
||||
"vite": "^7.1.12",
|
||||
"vite": "^8.0.14",
|
||||
"vite-plugin-compression": "^0.5.1",
|
||||
"vite-tsconfig-paths": "^5.1.4",
|
||||
"youtubei.js": "^16.0.1"
|
||||
"youtubei.js": "^17.0.1"
|
||||
}
|
||||
}
|
||||
@@ -141,20 +141,8 @@ export class YoutubeJs {
|
||||
|
||||
static initJsEvaluator() {
|
||||
Platform.shim.eval = async (data: Types.BuildScriptResult, env: Record<string, Types.VMPrimative>) => {
|
||||
const properties = [];
|
||||
|
||||
if (env.n) {
|
||||
properties.push(`n: exportedVars.nFunction("${env.n}")`)
|
||||
}
|
||||
|
||||
if (env.sig) {
|
||||
properties.push(`sig: exportedVars.sigFunction("${env.sig}")`)
|
||||
}
|
||||
|
||||
const code = `${data.output}\nreturn { ${properties.join(', ')} }`;
|
||||
|
||||
return new Function(code)();
|
||||
}
|
||||
return new Function(data.output)();
|
||||
};
|
||||
}
|
||||
|
||||
static async generateVisitorData() {
|
||||
@@ -255,6 +243,10 @@ export class YoutubeJs {
|
||||
po_token: await YoutubeJs.generatePoToken(videoId),
|
||||
});
|
||||
|
||||
if (info.playability_status.status !== 'OK') {
|
||||
throw new Error(`Video is not playable: ${info.playability_status.status}\nReason: ${info.playability_status.reason}`);
|
||||
}
|
||||
|
||||
// We can't generate a proper dash from live videos.
|
||||
// By returning null, we're telling Playlet to fetch video info itself.
|
||||
if (info.basic_info.is_live) {
|
||||
@@ -320,12 +312,16 @@ export class YoutubeJs {
|
||||
init: format.init_range ? `${format.init_range.start}-${format.init_range.end}` : "",
|
||||
index: format.index_range ? `${format.index_range.start}-${format.index_range.end}` : "",
|
||||
bitrate: `${format.bitrate}`,
|
||||
url: await format.decipher(YoutubeJs.innerTube.session.player),
|
||||
itag: `${format.itag}`,
|
||||
type: format.mime_type,
|
||||
clen: `${format.approx_duration_ms}`,
|
||||
lmt: `${format.last_modified}`,
|
||||
};
|
||||
|
||||
if (format.url || format.signature_cipher || format.cipher) {
|
||||
result.url = await format.decipher(YoutubeJs.innerTube.session.player);
|
||||
}
|
||||
|
||||
if (format.audio_quality) {
|
||||
result.audioQuality = format.audio_quality;
|
||||
}
|
||||
|
||||
@@ -49,28 +49,43 @@
|
||||
});
|
||||
|
||||
async function playOnTv() {
|
||||
const videoInfo = getVideoInfo();
|
||||
await PlayletApi.playVideo(videoInfo);
|
||||
try {
|
||||
const videoInfo = getVideoInfo();
|
||||
await PlayletApi.playVideo(videoInfo);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
alert(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function playOnTvYtjs() {
|
||||
const videoInfo = getVideoInfo() as any;
|
||||
try {
|
||||
const videoInfo = getVideoInfo() as any;
|
||||
|
||||
// measure length of time it takes to get video info
|
||||
const start = performance.now();
|
||||
const metadata = await YoutubeJs.getVideoInfo(videoId);
|
||||
const end = performance.now();
|
||||
console.log(`Time to get video info: ${end - start}ms`);
|
||||
// measure length of time it takes to get video info
|
||||
const start = performance.now();
|
||||
const metadata = await YoutubeJs.getVideoInfo(videoId);
|
||||
const end = performance.now();
|
||||
console.log(`Time to get video info: ${end - start}ms`);
|
||||
|
||||
if (metadata) {
|
||||
videoInfo.metadata = metadata;
|
||||
if (metadata) {
|
||||
videoInfo.metadata = metadata;
|
||||
}
|
||||
await PlayletApi.playVideo(videoInfo);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
alert(error);
|
||||
}
|
||||
await PlayletApi.playVideo(videoInfo);
|
||||
}
|
||||
|
||||
async function queueOnTv() {
|
||||
const videoInfo = getVideoInfo();
|
||||
await PlayletApi.queueVideo(videoInfo);
|
||||
try {
|
||||
const videoInfo = getVideoInfo();
|
||||
await PlayletApi.queueVideo(videoInfo);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
alert(error);
|
||||
}
|
||||
}
|
||||
|
||||
function openInvidious() {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node"
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext"
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
"include": [
|
||||
"vite.config.ts"
|
||||
]
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import { visualizer } from 'rollup-plugin-visualizer';
|
||||
import { defineConfig, UserConfig } from 'vite'
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||
import viteCompression from 'vite-plugin-compression';
|
||||
import tsconfigPaths from 'vite-tsconfig-paths'
|
||||
import ip from 'ip';
|
||||
import { existsSync, readFileSync } from 'fs'
|
||||
import { join as joinPath } from 'path'
|
||||
@@ -13,7 +12,6 @@ const PORT = 5173
|
||||
|
||||
const config: UserConfig = {
|
||||
plugins: [
|
||||
tsconfigPaths(),
|
||||
svelte(),
|
||||
legacy({
|
||||
targets: ['defaults', 'not IE 11'],
|
||||
@@ -23,6 +21,9 @@ const config: UserConfig = {
|
||||
deleteOriginFile: true
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
tsconfigPaths: true
|
||||
},
|
||||
build: {
|
||||
outDir: "../playlet-lib/src/www",
|
||||
emptyOutDir: true
|
||||
|
||||
@@ -260,7 +260,7 @@ end function`;
|
||||
bsfmtPath: bsfmtPath
|
||||
});
|
||||
|
||||
return new Formatter(options);
|
||||
return new Formatter(options ?? undefined);
|
||||
}
|
||||
|
||||
getCurrentFileHash() {
|
||||
|
||||
@@ -44,6 +44,9 @@ export class ValidationPlugin implements CompilerPlugin {
|
||||
|
||||
this.validation.forEach((validation) => {
|
||||
const regex = validation.regexObject;
|
||||
if (!regex) {
|
||||
return;
|
||||
}
|
||||
const fileContents = file.fileContents;
|
||||
|
||||
let match: RegExpExecArray | null;
|
||||
|
||||
@@ -15,6 +15,6 @@ INVIDIOUS_HMAC_KEY=PASSWORD_1
|
||||
INVIDIOUS_COMPANION_KEY=PASSWORD_2
|
||||
```
|
||||
|
||||
- Run `docker-compose up`
|
||||
- Run `docker compose up -d --pull always`
|
||||
|
||||
Invidious should now be running locally on port 3000.
|
||||
@@ -32,7 +32,7 @@ services:
|
||||
# Use the key generated in the 2nd step
|
||||
hmac_key: $INVIDIOUS_HMAC_KEY
|
||||
healthcheck:
|
||||
test: wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/trending || exit 1
|
||||
test: wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/popular || exit 1
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 2
|
||||
|
||||
Loaded 100 of 101 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user