Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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
@@ -5,6 +5,47 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.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
|
## [0.43.3] - 2025-10-30
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
Generated
+33
-32
@@ -1,21 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.43.3",
|
"version": "0.43.9",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.43.3",
|
"version": "0.43.9",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rokucommunity/bslint": "^0.8.37",
|
"@rokucommunity/bslint": "^0.8.38",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/node": "^24.9.1",
|
"@types/node": "^24.9.2",
|
||||||
"@types/xml2js": "^0.4.14",
|
"@types/xml2js": "^0.4.14",
|
||||||
"argparse": "^2.0.1",
|
"argparse": "^2.0.1",
|
||||||
"brighterscript": "0.70.2",
|
"brighterscript": "0.70.3",
|
||||||
"brighterscript-formatter": "^1.7.19",
|
"brighterscript-formatter": "^1.7.19",
|
||||||
"convert-svg-to-png": "^0.7.1",
|
"convert-svg-to-png": "^0.7.1",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"mailparser": "^3.7.5",
|
"mailparser": "^3.7.5",
|
||||||
"protocol-buffers-schema": "^3.6.0",
|
"protocol-buffers-schema": "^3.6.0",
|
||||||
"puppeteer": "^24.26.1",
|
"puppeteer": "^24.27.0",
|
||||||
"roku-deploy": "^3.13.0",
|
"roku-deploy": "^3.14.4",
|
||||||
"roku-test-automation": "^2.2.1",
|
"roku-test-automation": "^2.2.1",
|
||||||
"rooibos-roku": "5.15.5",
|
"rooibos-roku": "5.15.5",
|
||||||
"rounded-rect-9patch": "^1.1.2",
|
"rounded-rect-9patch": "^1.1.2",
|
||||||
@@ -415,9 +415,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@rokucommunity/bslint": {
|
"node_modules/@rokucommunity/bslint": {
|
||||||
"version": "0.8.37",
|
"version": "0.8.38",
|
||||||
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.37.tgz",
|
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.38.tgz",
|
||||||
"integrity": "sha512-22/1RqqI0S95Qd9XuSq9G9U/15pR9qOAQTKNjyZ2OQukWyhjEMJPdB7Yy2MOut56OjSwoJ1ihvWFeWN3snCccw==",
|
"integrity": "sha512-HpAkxWHev3d/d9thJsSwjO8fP18IRspjI2xS95EAz0GIPrsEdWuazoa+dXwHcAHrJ8QDGVMBg2nyZRwyvt7hYw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -737,9 +737,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "24.9.1",
|
"version": "24.9.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.2.tgz",
|
||||||
"integrity": "sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg==",
|
"integrity": "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1280,9 +1280,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/brighterscript": {
|
"node_modules/brighterscript": {
|
||||||
"version": "0.70.2",
|
"version": "0.70.3",
|
||||||
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.70.2.tgz",
|
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.70.3.tgz",
|
||||||
"integrity": "sha512-BHCZOKUNM4Pt7uLcA9JhQ17rxGnEz60dUdMfANTXGa8gYVjLNVd2WwVQS1L8roYRUuKXc83Hk01uxzmrcGmz9Q==",
|
"integrity": "sha512-R9r/AWvxDZioTfDvRZT50yO+PAHl/nElKA3SO9eWfmF43J88CBEtLT1dpLfFPfmPfdtxjcF58ZW87rmcqqYVyA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1312,7 +1312,7 @@
|
|||||||
"parse-ms": "^2.1.0",
|
"parse-ms": "^2.1.0",
|
||||||
"readline": "^1.3.0",
|
"readline": "^1.3.0",
|
||||||
"require-relative": "^0.8.7",
|
"require-relative": "^0.8.7",
|
||||||
"roku-deploy": "^3.13.0",
|
"roku-deploy": "^3.14.4",
|
||||||
"safe-json-stringify": "^1.2.0",
|
"safe-json-stringify": "^1.2.0",
|
||||||
"serialize-error": "^7.0.1",
|
"serialize-error": "^7.0.1",
|
||||||
"source-map": "^0.7.4",
|
"source-map": "^0.7.4",
|
||||||
@@ -5318,9 +5318,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/puppeteer": {
|
"node_modules/puppeteer": {
|
||||||
"version": "24.26.1",
|
"version": "24.27.0",
|
||||||
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-24.26.1.tgz",
|
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-24.27.0.tgz",
|
||||||
"integrity": "sha512-3RG2UqclzMFolM2fS4bN8t5/EjZ0VwEoAGVxG8PMGeprjLzj+x0U4auH7MQ4B6ftW+u1JUnTTN8ab4ABPdl4mA==",
|
"integrity": "sha512-eEcAFGxmHRSrk74DVkFAMAwfj4l3Ak8avBuA2bZaAoocY1+Fb9WLS3I7jlOc/tIOU7EmGLiDdVP08R44wADpHw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
@@ -5328,8 +5328,8 @@
|
|||||||
"@puppeteer/browsers": "2.10.12",
|
"@puppeteer/browsers": "2.10.12",
|
||||||
"chromium-bidi": "10.5.1",
|
"chromium-bidi": "10.5.1",
|
||||||
"cosmiconfig": "^9.0.0",
|
"cosmiconfig": "^9.0.0",
|
||||||
"devtools-protocol": "0.0.1508733",
|
"devtools-protocol": "0.0.1521046",
|
||||||
"puppeteer-core": "24.26.1",
|
"puppeteer-core": "24.27.0",
|
||||||
"typed-query-selector": "^2.12.0"
|
"typed-query-selector": "^2.12.0"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -5460,9 +5460,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/puppeteer/node_modules/devtools-protocol": {
|
"node_modules/puppeteer/node_modules/devtools-protocol": {
|
||||||
"version": "0.0.1508733",
|
"version": "0.0.1521046",
|
||||||
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1508733.tgz",
|
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1521046.tgz",
|
||||||
"integrity": "sha512-QJ1R5gtck6nDcdM+nlsaJXcelPEI7ZxSMw1ujHpO1c4+9l+Nue5qlebi9xO1Z2MGr92bFOQTW7/rrheh5hHxDg==",
|
"integrity": "sha512-vhE6eymDQSKWUXwwA37NtTTVEzjtGVfDr3pRbsWEQ5onH/Snp2c+2xZHWJJawG/0hCCJLRGt4xVtEVUVILol4w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BSD-3-Clause"
|
"license": "BSD-3-Clause"
|
||||||
},
|
},
|
||||||
@@ -5474,16 +5474,16 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/puppeteer/node_modules/puppeteer-core": {
|
"node_modules/puppeteer/node_modules/puppeteer-core": {
|
||||||
"version": "24.26.1",
|
"version": "24.27.0",
|
||||||
"resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-24.26.1.tgz",
|
"resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-24.27.0.tgz",
|
||||||
"integrity": "sha512-YHZdo3chJ5b9pTYVnuDuoI3UX/tWJFJyRZvkLbThGy6XeHWC+0KI8iN0UMCkvde5l/YOk3huiVZ/PvwgSbwdrA==",
|
"integrity": "sha512-yubwj2XXmTM3wRIpbhO5nCjbByPgpFHlgrsD4IK+gMPqO7/a5FfnoSXDKjmqi8A2M1Ewusz0rTI/r+IN0GU0MA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@puppeteer/browsers": "2.10.12",
|
"@puppeteer/browsers": "2.10.12",
|
||||||
"chromium-bidi": "10.5.1",
|
"chromium-bidi": "10.5.1",
|
||||||
"debug": "^4.4.3",
|
"debug": "^4.4.3",
|
||||||
"devtools-protocol": "0.0.1508733",
|
"devtools-protocol": "0.0.1521046",
|
||||||
"typed-query-selector": "^2.12.0",
|
"typed-query-selector": "^2.12.0",
|
||||||
"webdriver-bidi-protocol": "0.3.8",
|
"webdriver-bidi-protocol": "0.3.8",
|
||||||
"ws": "^8.18.3"
|
"ws": "^8.18.3"
|
||||||
@@ -6355,9 +6355,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/roku-deploy": {
|
"node_modules/roku-deploy": {
|
||||||
"version": "3.13.0",
|
"version": "3.14.4",
|
||||||
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.13.0.tgz",
|
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.14.4.tgz",
|
||||||
"integrity": "sha512-Bmg2n/NzZmnydfsGeCtMiXagRkm3o4xB8OYGy33NT1+Ghn9tWeniDmzWO8/G3hTbqtqG/jYpWBpSuzVwUUaNGQ==",
|
"integrity": "sha512-JWx+VetKadMPnGrc80cQCSaJSuTtR1tAA/3JiygFBJiK7gPYBCx8/2c9fq1wajuJ+t/0dqP7XYD/6v33nliFwA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -6375,6 +6375,7 @@
|
|||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"parse-ms": "^2.1.0",
|
"parse-ms": "^2.1.0",
|
||||||
"postman-request": "^2.88.1-postman.40",
|
"postman-request": "^2.88.1-postman.40",
|
||||||
|
"semver": "^7.7.3",
|
||||||
"temp-dir": "^2.0.0",
|
"temp-dir": "^2.0.0",
|
||||||
"xml2js": "^0.5.0"
|
"xml2js": "^0.5.0"
|
||||||
},
|
},
|
||||||
|
|||||||
+6
-6
@@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.43.3",
|
"version": "0.43.9",
|
||||||
"description": "Unofficial YouTube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rokucommunity/bslint": "^0.8.37",
|
"@rokucommunity/bslint": "^0.8.38",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/node": "^24.9.1",
|
"@types/node": "^24.9.2",
|
||||||
"@types/xml2js": "^0.4.14",
|
"@types/xml2js": "^0.4.14",
|
||||||
"argparse": "^2.0.1",
|
"argparse": "^2.0.1",
|
||||||
"brighterscript": "0.70.2",
|
"brighterscript": "0.70.3",
|
||||||
"brighterscript-formatter": "^1.7.19",
|
"brighterscript-formatter": "^1.7.19",
|
||||||
"convert-svg-to-png": "^0.7.1",
|
"convert-svg-to-png": "^0.7.1",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
@@ -21,8 +21,8 @@
|
|||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"mailparser": "^3.7.5",
|
"mailparser": "^3.7.5",
|
||||||
"protocol-buffers-schema": "^3.6.0",
|
"protocol-buffers-schema": "^3.6.0",
|
||||||
"puppeteer": "^24.26.1",
|
"puppeteer": "^24.27.0",
|
||||||
"roku-deploy": "^3.13.0",
|
"roku-deploy": "^3.14.4",
|
||||||
"roku-test-automation": "^2.2.1",
|
"roku-test-automation": "^2.2.1",
|
||||||
"rooibos-roku": "5.15.5",
|
"rooibos-roku": "5.15.5",
|
||||||
"rounded-rect-9patch": "^1.1.2",
|
"rounded-rect-9patch": "^1.1.2",
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.43.3",
|
"version": "0.43.9",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.43.3"
|
"version": "0.43.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.43.3",
|
"version": "0.43.9",
|
||||||
"description": "Unofficial YouTube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "node ../tools/rm.js ../build/playlet-app",
|
"prebuild": "node ../tools/rm.js ../build/playlet-app",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title=Playlet
|
|||||||
# Do not update version manually, it is auto updated from package.json
|
# Do not update version manually, it is auto updated from package.json
|
||||||
major_version=0
|
major_version=0
|
||||||
minor_version=43
|
minor_version=43
|
||||||
build_version=00003
|
build_version=00009
|
||||||
|
|
||||||
ui_resolutions=hd
|
ui_resolutions=hd
|
||||||
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.43.3",
|
"version": "0.43.9",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.43.3"
|
"version": "0.43.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.43.3",
|
"version": "0.43.9",
|
||||||
"description": "Unofficial YouTube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "node ../tools/rm.js ../build/playlet-lib",
|
"prebuild": "node ../tools/rm.js ../build/playlet-lib",
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class DashManifest
|
|||||||
}
|
}
|
||||||
end function
|
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 = []
|
||||||
adaptiveFormats.Append(metadata.adaptiveFormats)
|
adaptiveFormats.Append(metadata.adaptiveFormats)
|
||||||
|
|
||||||
@@ -48,14 +48,19 @@ class DashManifest
|
|||||||
end for
|
end for
|
||||||
end if
|
end if
|
||||||
|
|
||||||
audioStreams = m.getAudioStreams(adaptiveFormats)
|
duration = m.GetDuration(metadata)
|
||||||
videoStreams = m.getVideoStreams(adaptiveFormats, qualityFilter)
|
|
||||||
if videoStreams.Count() = 0
|
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")
|
LogWarnNoTelemetry("No video streams found using quality filter:", qualityFilter, "Falling back to all video streams")
|
||||||
videoStreams = m.getVideoStreams(adaptiveFormats, {})
|
filteredVideoGroups = videoGroups
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if videoStreams.Count() = 0
|
if filteredVideoGroups.Count() = 0
|
||||||
lastPlayerResponse = ValidString(ReadAsciiFile("cachefs:/last_player_response.json"))
|
lastPlayerResponse = ValidString(ReadAsciiFile("cachefs:/last_player_response.json"))
|
||||||
LogTelemetryEvent({
|
LogTelemetryEvent({
|
||||||
level: "error"
|
level: "error"
|
||||||
@@ -72,9 +77,6 @@ class DashManifest
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
end if
|
end if
|
||||||
|
|
||||||
videoMimeTypes = m.getMimeTypes(videoStreams)
|
|
||||||
audioSets = m.getMimeTypeLanguageCombos(audioStreams)
|
|
||||||
storyboards = metadata.storyboards
|
storyboards = metadata.storyboards
|
||||||
|
|
||||||
xml = new XmlObject()
|
xml = new XmlObject()
|
||||||
@@ -86,157 +88,357 @@ class DashManifest
|
|||||||
"profiles": "urn:mpeg:dash:profile:full:2011"
|
"profiles": "urn:mpeg:dash:profile:full:2011"
|
||||||
"minBufferTime": "PT1.5S"
|
"minBufferTime": "PT1.5S"
|
||||||
"type": "static"
|
"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")
|
if xml.Node("Period")
|
||||||
|
|
||||||
id = 0
|
id = 0
|
||||||
id = m.generateAudioAdaptationSets(xml, audioSets, audioStreams, id)
|
id = m.GenerateAudioAdaptationSets(xml, audioGroups, id, metadata)
|
||||||
id = m.generateVideoAdaptationSets(xml, videoMimeTypes, videoStreams, id)
|
id = m.GenerateVideoAdaptationSets(xml, filteredVideoGroups, id, metadata)
|
||||||
m.generateImageAdaptationSets(xml, storyboards, id)
|
m.GenerateImageAdaptationSets(xml, storyboards, id)
|
||||||
|
|
||||||
xml.End()
|
xml.End()
|
||||||
end if
|
end if
|
||||||
xml.End()
|
xml.End()
|
||||||
end if
|
end if
|
||||||
|
|
||||||
return xml.ToXmlString()
|
return xml.ToXmlString()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function generateAudioAdaptationSets(xml as object, audioSets as object, audioStreams as object, id as integer) as integer
|
function GetDuration(metadata as object) as dynamic
|
||||||
for each audioSet in audioSets
|
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]
|
||||||
|
hoisted = {}
|
||||||
|
|
||||||
adaptationSetAttributes = {
|
adaptationSetAttributes = {
|
||||||
"id": `${id}`
|
"id": `${id}`
|
||||||
"mimeType": audioSet.mimeType
|
"mimeType": firstFormat.type.Tokenize(";")[0]
|
||||||
"startWithSAP": "1"
|
"startWithSAP": "1"
|
||||||
"subsegmentAlignment": "true"
|
"subsegmentAlignment": "true"
|
||||||
|
"contentType": "audio"
|
||||||
}
|
}
|
||||||
if not StringUtils.IsNullOrEmpty(audioSet.lang)
|
|
||||||
adaptationSetAttributes["lang"] = audioSet.lang
|
if IsAssociativeArray(firstFormat.audioTrack) and IsString(firstFormat.audioTrack.languageCode)
|
||||||
|
adaptationSetAttributes["lang"] = firstFormat.audioTrack.languageCode
|
||||||
|
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
|
end if
|
||||||
|
|
||||||
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
||||||
xml.EmptyNode("Role", {
|
if IsArray(firstFormat.drmFamilies)
|
||||||
"schemeIdUri": "urn:mpeg:dash:role:2011"
|
for each drmFamily in firstFormat.drmFamilies
|
||||||
"value": audioSet.acont = "original" ? "main" : "alternate"
|
systemId = m.GetDrmSystemId(drmFamily)
|
||||||
})
|
if IsString(systemId)
|
||||||
|
xml.EmptyNode("ContentProtection", { "schemeIdUri": `urn:uuid:${systemId}` })
|
||||||
for i = 0 to audioStreams.Count() - 1
|
end if
|
||||||
stream = audioStreams[i]
|
end for
|
||||||
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
|
end if
|
||||||
|
|
||||||
codecs = stream.type.split("codecs=")[1]
|
if IsAssociativeArray(firstFormat.audioTrack) or firstFormat.isDrc = true
|
||||||
if codecs.startsWith(`"`)
|
' Roles
|
||||||
codecs = codecs.mid(1)
|
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
|
||||||
|
xml.Node("Label", { "id": id })
|
||||||
|
xml.Text(displayName)
|
||||||
|
xml.End()
|
||||||
end if
|
end if
|
||||||
if codecs.endsWith(`"`)
|
|
||||||
codecs = codecs.left(codecs.len() - 1)
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if xml.Node("Representation", {
|
' AudioChannelConfiguration
|
||||||
"id": stream.itag
|
channels = m.HoistAudioChannels(group, hoisted)
|
||||||
"codecs": codecs
|
if IsInt(channels)
|
||||||
"bandwidth": stream.bitrate
|
|
||||||
})
|
|
||||||
|
|
||||||
xml.EmptyNode("AudioChannelConfiguration", {
|
xml.EmptyNode("AudioChannelConfiguration", {
|
||||||
"schemeIdUri": "urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
|
"schemeIdUri": "urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
|
||||||
"value": `${stream.audioChannels}`
|
"value": channels
|
||||||
})
|
})
|
||||||
|
|
||||||
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()
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
xml.End()
|
for each stream in group
|
||||||
|
representationId = stream.itag
|
||||||
|
if IsAssociativeArray(stream.audioTrack) and IsString(stream.audioTrack.id)
|
||||||
|
representationId = `${representationId}-${stream.audioTrack.id}`
|
||||||
end if
|
end if
|
||||||
end for
|
if stream.isDrc = true
|
||||||
|
representationId = `${representationId}-drc`
|
||||||
xml.End()
|
|
||||||
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
|
|
||||||
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
|
end if
|
||||||
|
|
||||||
representationAttributes = {
|
representationAttributes = {
|
||||||
"id": stream.itag
|
"id": representationId
|
||||||
"codecs": codecs
|
|
||||||
"startWithSAP": "1"
|
|
||||||
"maxPlayoutRate": "1"
|
|
||||||
"bandwidth": stream.bitrate
|
"bandwidth": stream.bitrate
|
||||||
}
|
}
|
||||||
if stream.width <> invalid
|
if hoisted["codecs"] = invalid and (stream.type.inStr("codecs=") <> -1)
|
||||||
representationAttributes["width"] = `${stream.width}`
|
representationAttributes["codecs"] = stream.type.split("codecs=")[1].replace(`"`, "").replace(`"`, "")
|
||||||
end if
|
end if
|
||||||
if stream.height <> invalid
|
if hoisted["audioSampleRate"] = invalid
|
||||||
representationAttributes["height"] = `${stream.height}`
|
representationAttributes["audioSamplingRate"] = stream.audioSampleRate
|
||||||
end if
|
|
||||||
if stream.fps <> invalid
|
|
||||||
representationAttributes["frameRate"] = `${stream.fps}`
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if xml.Node("Representation", representationAttributes)
|
if xml.Node("Representation", representationAttributes)
|
||||||
m.AddColorInfo(stream, xml)
|
if hoisted["AudioChannelConfiguration"] = invalid and IsInt(stream.audioChannels)
|
||||||
|
xml.EmptyNode("AudioChannelConfiguration", {
|
||||||
if StringUtils.IsNullOrEmpty(stream.url)
|
"schemeIdUri": "urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
|
||||||
xml.Comment(`[ERROR] Stream.url is null or empty for itag: ${stream.itag}`)
|
"value": stream.audioChannels
|
||||||
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
|
end if
|
||||||
xml.TextNode("BaseURL", ValidString(stream.url))
|
|
||||||
|
|
||||||
if StringUtils.IsNullOrEmpty(stream.index) or StringUtils.IsNullOrEmpty(stream.init)
|
m.GenerateSegmentInformation(xml, stream, metadata)
|
||||||
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()
|
xml.End()
|
||||||
end if
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
xml.End()
|
xml.End()
|
||||||
end if
|
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
|
end for
|
||||||
|
|
||||||
xml.End()
|
xml.End()
|
||||||
@@ -247,7 +449,159 @@ class DashManifest
|
|||||||
return id
|
return id
|
||||||
end function
|
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
|
' 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
|
for i = storyboards.Count() - 1 to 0 step -1
|
||||||
storyboard = storyboards[i]
|
storyboard = storyboards[i]
|
||||||
@@ -322,169 +676,6 @@ class DashManifest
|
|||||||
return id
|
return id
|
||||||
end function
|
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
|
function AddColorInfo(videoStream as object, xml as object) as void
|
||||||
if videoStream.colorInfo = invalid
|
if videoStream.colorInfo = invalid
|
||||||
return
|
return
|
||||||
@@ -493,7 +684,7 @@ class DashManifest
|
|||||||
if videoStream.colorInfo.primaries <> invalid
|
if videoStream.colorInfo.primaries <> invalid
|
||||||
primaries = m.colorInfo.primaries[videoStream.colorInfo.primaries]
|
primaries = m.colorInfo.primaries[videoStream.colorInfo.primaries]
|
||||||
if primaries <> invalid
|
if primaries <> invalid
|
||||||
xml.EmptyNode("EssentialProperty", {
|
xml.EmptyNode("SupplementalProperty", {
|
||||||
"schemeIdUri": "urn:mpeg:mpegB:cicp:ColourPrimaries"
|
"schemeIdUri": "urn:mpeg:mpegB:cicp:ColourPrimaries"
|
||||||
"value": primaries
|
"value": primaries
|
||||||
})
|
})
|
||||||
@@ -505,7 +696,7 @@ class DashManifest
|
|||||||
if videoStream.colorInfo.transferCharacteristics <> invalid
|
if videoStream.colorInfo.transferCharacteristics <> invalid
|
||||||
transferCharacteristics = m.colorInfo.transferCharacteristics[videoStream.colorInfo.transferCharacteristics]
|
transferCharacteristics = m.colorInfo.transferCharacteristics[videoStream.colorInfo.transferCharacteristics]
|
||||||
if transferCharacteristics <> invalid
|
if transferCharacteristics <> invalid
|
||||||
xml.EmptyNode("EssentialProperty", {
|
xml.EmptyNode("SupplementalProperty", {
|
||||||
"schemeIdUri": "urn:mpeg:mpegB:cicp:TransferCharacteristics"
|
"schemeIdUri": "urn:mpeg:mpegB:cicp:TransferCharacteristics"
|
||||||
"value": transferCharacteristics
|
"value": transferCharacteristics
|
||||||
})
|
})
|
||||||
@@ -517,7 +708,7 @@ class DashManifest
|
|||||||
if videoStream.colorInfo.matrixCoefficients <> invalid
|
if videoStream.colorInfo.matrixCoefficients <> invalid
|
||||||
matrixCoefficients = m.colorInfo.matrixCoefficients[videoStream.colorInfo.matrixCoefficients]
|
matrixCoefficients = m.colorInfo.matrixCoefficients[videoStream.colorInfo.matrixCoefficients]
|
||||||
if matrixCoefficients <> invalid
|
if matrixCoefficients <> invalid
|
||||||
xml.EmptyNode("EssentialProperty", {
|
xml.EmptyNode("SupplementalProperty", {
|
||||||
"schemeIdUri": "urn:mpeg:mpegB:cicp:MatrixCoefficients"
|
"schemeIdUri": "urn:mpeg:mpegB:cicp:MatrixCoefficients"
|
||||||
"value": matrixCoefficients
|
"value": matrixCoefficients
|
||||||
})
|
})
|
||||||
@@ -527,4 +718,81 @@ class DashManifest
|
|||||||
end if
|
end if
|
||||||
end function
|
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
|
end class
|
||||||
@@ -81,16 +81,16 @@ namespace InnertubeService
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
playerResponseJson = playerResponse.Json()
|
playerResponseJson = playerResponse.Json()
|
||||||
isLive = Innertube.IsLiveStream(playerResponseJson)
|
notDashSupported = Innertube.IsLiveStream(playerResponseJson)
|
||||||
if isLive and client = Innertube.ClientType.Tv
|
if notDashSupported and client = Innertube.ClientType.Tv
|
||||||
LogDebug("Live video detected, falling back to iOS for HLS streams.")
|
LogDebug("Falling back to iOS client for live video.")
|
||||||
isLoggedIn = Innertube.ParseIsLoggedIn(playerResponseJson)
|
isLoggedIn = Innertube.ParseIsLoggedIn(playerResponseJson)
|
||||||
playbackTrackingUrls = Innertube.ParsePlaybackTrackingUrls(playerResponseJson, isLoggedIn)
|
playbackTrackingUrls = Innertube.ParsePlaybackTrackingUrls(playerResponseJson, isLoggedIn)
|
||||||
client = Innertube.ClientType.IOS
|
client = Innertube.ClientType.IOS
|
||||||
continue while
|
continue while
|
||||||
end if
|
end if
|
||||||
|
|
||||||
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerRequest, playerResponse, {}, cancellation)
|
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerRequest, playerResponse, client, cancellation)
|
||||||
|
|
||||||
if parsedResponse.error = invalid
|
if parsedResponse.error = invalid
|
||||||
exit while
|
exit while
|
||||||
|
|||||||
@@ -0,0 +1,194 @@
|
|||||||
|
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]
|
||||||
|
file: `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"
|
||||||
|
|
||||||
|
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.file, 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.file, 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, file 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(file)
|
||||||
|
request.Cancellation(cancellation)
|
||||||
|
request.Send()
|
||||||
|
|
||||||
|
return request
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OTFProcessPendingFormat(format as object, request as object, file as string, 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(file, 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, 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 file at path ${filePath}.\n`
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
contentHex = buffer.ToHexString()
|
||||||
|
|
||||||
|
startIndex = contentHex.InStr(startMarkerHex)
|
||||||
|
if startIndex = -1
|
||||||
|
errors.message += `Start marker not found in file at path ${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 file at path ${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()
|
||||||
|
|
||||||
|
regex = CreateObject("roRegex", "(\d+)(?:\(r=(\d+)\))?", "g")
|
||||||
|
matches = regex.MatchAll(segmentDurationsMs)
|
||||||
|
if not IsArray(matches) or matches.Count() = 0
|
||||||
|
errors.message += `No segment duration matches found in file at path ${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
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import "pkg:/components/Services/Innertube/Context.bs"
|
import "pkg:/components/Services/Innertube/Context.bs"
|
||||||
import "pkg:/components/Services/Innertube/NodesParser.bs"
|
import "pkg:/components/Services/Innertube/NodesParser.bs"
|
||||||
|
import "pkg:/components/Services/Innertube/OTFSegmentInfo.bs"
|
||||||
import "pkg:/source/services/HttpClient.bs"
|
import "pkg:/source/services/HttpClient.bs"
|
||||||
import "pkg:/source/utils/ObjectUtils.bs"
|
import "pkg:/source/utils/ObjectUtils.bs"
|
||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
@@ -22,6 +23,12 @@ namespace Innertube
|
|||||||
|
|
||||||
context = Innertube.CreateContext(client, deviceInfo, options)
|
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 = {
|
payload = {
|
||||||
"videoId": videoId
|
"videoId": videoId
|
||||||
"context": context
|
"context": context
|
||||||
@@ -30,13 +37,12 @@ namespace Innertube
|
|||||||
"contentPlaybackContext": {
|
"contentPlaybackContext": {
|
||||||
"vis": 0
|
"vis": 0
|
||||||
"splay": false
|
"splay": false
|
||||||
"referer": "https://www.youtube.com/watch?v=" + videoId
|
"referer": referer
|
||||||
"currentUrl": "/watch?v=" + videoId
|
"currentUrl": "/watch?v=" + videoId
|
||||||
"autonavState": "STATE_ON"
|
"autonavState": "STATE_ON"
|
||||||
"autoCaptionsDefaultOn": false
|
"autoCaptionsDefaultOn": false
|
||||||
"html5Preference": "HTML5_PREF_WANTS"
|
"html5Preference": "HTML5_PREF_WANTS"
|
||||||
"lactMilliseconds": "-1"
|
"lactMilliseconds": "-1"
|
||||||
"isInlinePlaybackNoAd": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"attestationRequest": {
|
"attestationRequest": {
|
||||||
@@ -67,9 +73,9 @@ namespace Innertube
|
|||||||
return request
|
return request
|
||||||
end function
|
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())
|
WriteAsciiFile("cachefs:/last_player_response.json", playerResponse.Text())
|
||||||
|
parsedResponse = {}
|
||||||
payload = playerResponse.Json()
|
payload = playerResponse.Json()
|
||||||
|
|
||||||
error = ParsePlayerResponseForError(payload, playerRequest)
|
error = ParsePlayerResponseForError(payload, playerRequest)
|
||||||
@@ -92,6 +98,7 @@ namespace Innertube
|
|||||||
|
|
||||||
lengthSeconds = videoDetails["lengthSeconds"].ToInt()
|
lengthSeconds = videoDetails["lengthSeconds"].ToInt()
|
||||||
isLive = ValidBool(videoDetails["isLive"])
|
isLive = ValidBool(videoDetails["isLive"])
|
||||||
|
isPostLiveDvr = ValidBool(videoDetails["isPostLiveDvr"])
|
||||||
|
|
||||||
adaptiveFormats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"]))
|
adaptiveFormats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"]))
|
||||||
formats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "formats"]))
|
formats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "formats"]))
|
||||||
@@ -108,11 +115,11 @@ namespace Innertube
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
hasLiveStreamingData = FormatsHaveLiveStreamingData(adaptiveFormats) or FormatsHaveLiveStreamingData(formats)
|
hasLiveStreamingData = FormatsHaveLiveStreamingData(adaptiveFormats) or FormatsHaveLiveStreamingData(formats)
|
||||||
|
isOTF = FormatsHasTypeOTF(adaptiveFormats)
|
||||||
hasDrm = (not StringUtils.IsNullOrEmpty(streamingData.drmParams)) or IsArray(streamingData.licenseInfos)
|
hasDrm = (not StringUtils.IsNullOrEmpty(streamingData.drmParams)) or IsArray(streamingData.licenseInfos)
|
||||||
|
|
||||||
shouldAnalyze = (not isLive) and (not hasLiveStreamingData) and (not hasDrm)
|
adaptiveFormats = TransformFormats(adaptiveFormats)
|
||||||
adaptiveFormats = TransformFormats(adaptiveFormats, shouldAnalyze)
|
formats = TransformFormats(formats)
|
||||||
formats = TransformFormats(formats, false)
|
|
||||||
|
|
||||||
parsedResponse["type"] = "video"
|
parsedResponse["type"] = "video"
|
||||||
parsedResponse["videoId"] = videoDetails["videoId"]
|
parsedResponse["videoId"] = videoDetails["videoId"]
|
||||||
@@ -122,6 +129,7 @@ namespace Innertube
|
|||||||
parsedResponse["authorId"] = videoDetails["channelId"]
|
parsedResponse["authorId"] = videoDetails["channelId"]
|
||||||
parsedResponse["lengthSeconds"] = lengthSeconds
|
parsedResponse["lengthSeconds"] = lengthSeconds
|
||||||
parsedResponse["liveNow"] = isLive
|
parsedResponse["liveNow"] = isLive
|
||||||
|
parsedResponse["isPostLiveDvr"] = isPostLiveDvr
|
||||||
parsedResponse["hasLiveStreamingData"] = hasLiveStreamingData
|
parsedResponse["hasLiveStreamingData"] = hasLiveStreamingData
|
||||||
parsedResponse["hlsUrl"] = streamingData["hlsManifestUrl"]
|
parsedResponse["hlsUrl"] = streamingData["hlsManifestUrl"]
|
||||||
parsedResponse["dashUrl"] = streamingData["dashManifestUrl"]
|
parsedResponse["dashUrl"] = streamingData["dashManifestUrl"]
|
||||||
@@ -154,6 +162,16 @@ namespace Innertube
|
|||||||
parsedResponse["isLoggedIn"] = ParseIsLoggedIn(payload)
|
parsedResponse["isLoggedIn"] = ParseIsLoggedIn(payload)
|
||||||
parsedResponse["playbackTrackingUrls"] = ParsePlaybackTrackingUrls(payload, parsedResponse.isLoggedIn)
|
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
|
return parsedResponse
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -333,57 +351,33 @@ namespace Innertube
|
|||||||
return captions
|
return captions
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function TransformFormats(formats as object, analyze as boolean) as object
|
function TransformFormats(formats as object) as object
|
||||||
analysis = invalid
|
|
||||||
if analyze
|
|
||||||
analysis = {
|
|
||||||
"issueDetected": false
|
|
||||||
}
|
|
||||||
end if
|
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
for i = 0 to formats.Count() - 1
|
for i = 0 to formats.Count() - 1
|
||||||
result.Push(TransformFormat(formats[i], analysis))
|
result.Push(TransformFormat(formats[i]))
|
||||||
end for
|
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
|
return result
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function TransformFormat(fmt as object, analysis as object) as object
|
function TransformFormat(fmt as object) as object
|
||||||
itag = `${fmt["itag"]}`
|
itag = `${fmt["itag"]}`
|
||||||
result = {
|
result = {
|
||||||
"bitrate": `${fmt["bitrate"]}`
|
"bitrate": `${fmt["bitrate"]}`
|
||||||
"url": fmt["url"]
|
"url": fmt["url"]
|
||||||
"itag": itag
|
"itag": itag
|
||||||
"type": fmt["mimeType"]
|
"type": fmt["mimeType"]
|
||||||
"clen": `${fmt["approxDurationMs"]}`
|
|
||||||
"lmt": `${fmt["lastModified"]}`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fmt["approxDurationMs"] <> invalid
|
||||||
|
result["approxDurationMs"] = fmt["approxDurationMs"]
|
||||||
|
end if
|
||||||
|
|
||||||
if IsAssociativeArray(fmt["initRange"])
|
if IsAssociativeArray(fmt["initRange"])
|
||||||
result["init"] = `${fmt["initRange"]["start"]}-${fmt["initRange"]["end"]}`
|
result["init"] = `${fmt["initRange"]["start"]}-${fmt["initRange"]["end"]}`
|
||||||
else
|
|
||||||
result["init"] = ""
|
|
||||||
if analysis <> invalid
|
|
||||||
analysis.issueDetected = true
|
|
||||||
end if
|
|
||||||
end if
|
end if
|
||||||
if IsAssociativeArray(fmt["indexRange"])
|
if IsAssociativeArray(fmt["indexRange"])
|
||||||
result["index"] = `${fmt["indexRange"]["start"]}-${fmt["indexRange"]["end"]}`
|
result["index"] = `${fmt["indexRange"]["start"]}-${fmt["indexRange"]["end"]}`
|
||||||
else
|
|
||||||
result["index"] = ""
|
|
||||||
if analysis <> invalid
|
|
||||||
analysis.issueDetected = true
|
|
||||||
end if
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if fmt["audioQuality"] <> invalid
|
if fmt["audioQuality"] <> invalid
|
||||||
@@ -403,6 +397,31 @@ namespace Innertube
|
|||||||
result["fps"] = ToString(fmt["fps"])
|
result["fps"] = ToString(fmt["fps"])
|
||||||
end if
|
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["width"] = fmt["width"]
|
||||||
result["height"] = fmt["height"]
|
result["height"] = fmt["height"]
|
||||||
|
|
||||||
@@ -529,8 +548,7 @@ namespace Innertube
|
|||||||
for i = 0 to decipheredFormats.Count() - 1
|
for i = 0 to decipheredFormats.Count() - 1
|
||||||
fmt = formats[i]
|
fmt = formats[i]
|
||||||
decipheredFmt = decipheredFormats[i]
|
decipheredFmt = decipheredFormats[i]
|
||||||
|
fmt["url"] = ResetUrlClientVersion(decipheredFmt["url"])
|
||||||
fmt["url"] = decipheredFmt["url"]
|
|
||||||
end for
|
end for
|
||||||
|
|
||||||
decipheredAdaptiveFormats = json["adaptiveFormats"]
|
decipheredAdaptiveFormats = json["adaptiveFormats"]
|
||||||
@@ -544,11 +562,34 @@ namespace Innertube
|
|||||||
for i = 0 to decipheredAdaptiveFormats.Count() - 1
|
for i = 0 to decipheredAdaptiveFormats.Count() - 1
|
||||||
fmt = adaptiveFormats[i]
|
fmt = adaptiveFormats[i]
|
||||||
decipheredFmt = decipheredAdaptiveFormats[i]
|
decipheredFmt = decipheredAdaptiveFormats[i]
|
||||||
fmt["url"] = decipheredFmt["url"]
|
fmt["url"] = ResetUrlClientVersion(decipheredFmt["url"])
|
||||||
end for
|
end for
|
||||||
return invalid
|
return invalid
|
||||||
end function
|
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
|
function ParseIsLoggedIn(payload as object) as boolean
|
||||||
trackingParams = ObjectUtils.Dig(payload, ["responseContext", "serviceTrackingParams"])
|
trackingParams = ObjectUtils.Dig(payload, ["responseContext", "serviceTrackingParams"])
|
||||||
if not IsArray(trackingParams)
|
if not IsArray(trackingParams)
|
||||||
@@ -623,4 +664,72 @@ namespace Innertube
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
end function
|
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")
|
||||||
|
LogError("GetPostLiveDvrInfo: Missing Post-Live DVR info in headers", headers)
|
||||||
|
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
|
end namespace
|
||||||
@@ -103,8 +103,8 @@ function ExecuteJob() as void
|
|||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
isDrmDash = SupportsDrmDashManifest(metadata)
|
isDrm = not StringUtils.IsNullOrEmpty(metadata.drmParams)
|
||||||
if isDrmDash
|
if isDrm
|
||||||
licenseServerURL = UrlUtils.BuildUrl(`http://127.0.0.1:${playletServerPort}/api/innertube/get_drm_license`, invalid, {
|
licenseServerURL = UrlUtils.BuildUrl(`http://127.0.0.1:${playletServerPort}/api/innertube/get_drm_license`, invalid, {
|
||||||
videoId: metadata.videoId
|
videoId: metadata.videoId
|
||||||
drmParams: metadata.drmParams
|
drmParams: metadata.drmParams
|
||||||
@@ -150,7 +150,7 @@ function CreateStreamUrls(metadata as object, service as Invidious.InvidiousServ
|
|||||||
|
|
||||||
streamUrls = []
|
streamUrls = []
|
||||||
|
|
||||||
if SupportsDrmDashManifest(metadata)
|
if SupportsDrmDashManifestUrl(metadata)
|
||||||
dashUrl = UrlUtils.AppendQueryParams(`http://127.0.0.1:${playletServerPort}/api/dash`, {
|
dashUrl = UrlUtils.AppendQueryParams(`http://127.0.0.1:${playletServerPort}/api/dash`, {
|
||||||
url: metadata.dashUrl
|
url: metadata.dashUrl
|
||||||
})
|
})
|
||||||
@@ -195,11 +195,15 @@ function SupportsMuxedFormats(metadata as object) as boolean
|
|||||||
return IsArray(metadata.formatStreams) and metadata.formatStreams.Count() > 0
|
return IsArray(metadata.formatStreams) and metadata.formatStreams.Count() > 0
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function SupportsDrmDashManifest(metadata as object) as boolean
|
function SupportsDrmDashManifestUrl(metadata as object) as boolean
|
||||||
if StringUtils.IsNullOrEmpty(metadata.drmParams)
|
if StringUtils.IsNullOrEmpty(metadata.drmParams)
|
||||||
return false
|
return false
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
if StringUtils.IsNullOrEmpty(metadata.dashUrl)
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
if StringUtils.IsNullOrEmpty(metadata.drmSessionId)
|
if StringUtils.IsNullOrEmpty(metadata.drmSessionId)
|
||||||
return false
|
return false
|
||||||
end if
|
end if
|
||||||
@@ -212,10 +216,6 @@ function SupportsDrmDashManifest(metadata as object) as boolean
|
|||||||
return false
|
return false
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if StringUtils.IsNullOrEmpty(metadata.dashUrl)
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ function OnVideoPlayerStateChange() as void
|
|||||||
errorData = GetPlayerErrorData(content.videoId, errorInfo)
|
errorData = GetPlayerErrorData(content.videoId, errorInfo)
|
||||||
|
|
||||||
LogErrorNoTelemetry(errorData.title, errorData.body)
|
LogErrorNoTelemetry(errorData.title, errorData.body)
|
||||||
ReportVideoError(errorData, content.url)
|
ReportVideoError(errorData, content.url, content.playletStreamUrls, content.playletStreamUrlIndex)
|
||||||
errorReported = true
|
errorReported = true
|
||||||
|
|
||||||
if m.videoPlayingSuccess <> true
|
if m.videoPlayingSuccess <> true
|
||||||
@@ -509,7 +509,7 @@ function OnVideoPlayerStateChange() as void
|
|||||||
|
|
||||||
LogErrorNoTelemetry(errorData.title, errorData.body)
|
LogErrorNoTelemetry(errorData.title, errorData.body)
|
||||||
if not errorReported
|
if not errorReported
|
||||||
ReportVideoError(errorData, content.url)
|
ReportVideoError(errorData, content.url, content.playletStreamUrls, content.playletStreamUrlIndex)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
buttons = [Tr(Locale.Buttons.PlayNextVideo), Tr(Locale.Buttons.Cancel)]
|
buttons = [Tr(Locale.Buttons.PlayNextVideo), Tr(Locale.Buttons.Cancel)]
|
||||||
@@ -557,7 +557,7 @@ function GetPlayerErrorData(videoId as string, errorInfo as object) as object
|
|||||||
}
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ReportVideoError(errorData as object, url as string) as void
|
function ReportVideoError(errorData as object, url as string, urls as object, urlIndex as dynamic) as void
|
||||||
attachments = invalid
|
attachments = invalid
|
||||||
if errorData.body.Instr("malformed data") <> -1 or errorData.body.Instr("invalid pathname") <> -1
|
if errorData.body.Instr("malformed data") <> -1 or errorData.body.Instr("invalid pathname") <> -1
|
||||||
lastGeneratedDash = ValidString(ReadAsciiFile("cachefs:/last_generated_dash.xml"))
|
lastGeneratedDash = ValidString(ReadAsciiFile("cachefs:/last_generated_dash.xml"))
|
||||||
@@ -579,9 +579,20 @@ function ReportVideoError(errorData as object, url as string) as void
|
|||||||
}]
|
}]
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
position = m.top.position
|
||||||
|
duration = m.top.duration
|
||||||
|
message = [
|
||||||
|
errorData.title
|
||||||
|
errorData.body
|
||||||
|
`Position: ${position}`
|
||||||
|
`Duration: ${duration}`
|
||||||
|
`Url: ${url}`
|
||||||
|
`Urls: ` + ToString(urls)
|
||||||
|
`Url index: ${urlIndex}`
|
||||||
|
].Join(`\n`)
|
||||||
LogTelemetryEvent({
|
LogTelemetryEvent({
|
||||||
level: "error"
|
level: "error"
|
||||||
message: errorData.title + " " + errorData.body + `\nurl: ${url}`
|
message: message
|
||||||
fingerprint: errorData.fingerprint
|
fingerprint: errorData.fingerprint
|
||||||
attachments: attachments
|
attachments: attachments
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -53,7 +53,25 @@ namespace Http
|
|||||||
m.dashManifest.invidiousInstance = m.invidiousService.GetInstance()
|
m.dashManifest.invidiousInstance = m.invidiousService.GetInstance()
|
||||||
|
|
||||||
qualityFilter = m.CreateQualityFilter(quality)
|
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.http_code = 200
|
||||||
response.SetBodyDataString(xmlContent)
|
response.SetBodyDataString(xmlContent)
|
||||||
@@ -115,7 +133,7 @@ namespace Http
|
|||||||
|
|
||||||
xml = new XmlObject()
|
xml = new XmlObject()
|
||||||
manifestObj = new DashManifest("")
|
manifestObj = new DashManifest("")
|
||||||
manifestObj.generateImageAdaptationSets(xml, storyboards, 100)
|
manifestObj.GenerateImageAdaptationSets(xml, storyboards, 100)
|
||||||
storyboardXml = xml.ToXmlString(false)
|
storyboardXml = xml.ToXmlString(false)
|
||||||
|
|
||||||
newDashContent = dashContent.Left(storyboardIndex) + storyboardXml + dashContent.Mid(storyboardIndex)
|
newDashContent = dashContent.Left(storyboardIndex) + storyboardXml + dashContent.Mid(storyboardIndex)
|
||||||
|
|||||||
@@ -127,6 +127,9 @@ namespace Http
|
|||||||
if ValidBool(metadata.liveNow) or ValidBool(metadata.hasLiveStreamingData)
|
if ValidBool(metadata.liveNow) or ValidBool(metadata.hasLiveStreamingData)
|
||||||
return hlsManifest
|
return hlsManifest
|
||||||
end if
|
end if
|
||||||
|
if hlsManifest.InStr("/source/yt_live_broadcast") <> -1 or hlsManifest.InStr("/live/1") <> -1
|
||||||
|
return hlsManifest
|
||||||
|
end if
|
||||||
|
|
||||||
storyboards = metadata.storyboards
|
storyboards = metadata.storyboards
|
||||||
if not IsArray(storyboards)
|
if not IsArray(storyboards)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title=PlayletLib
|
|||||||
# Do not update version manually, it is auto updated from package.json
|
# Do not update version manually, it is auto updated from package.json
|
||||||
major_version=0
|
major_version=0
|
||||||
minor_version=43
|
minor_version=43
|
||||||
build_version=00003
|
build_version=00009
|
||||||
|
|
||||||
ui_resolutions=hd
|
ui_resolutions=hd
|
||||||
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
||||||
|
|||||||
@@ -299,6 +299,11 @@ namespace HttpClient
|
|||||||
return m
|
return m
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function ToFile(filePath as string) as HttpRequest
|
||||||
|
m._toFilePath = filePath
|
||||||
|
return m
|
||||||
|
end function
|
||||||
|
|
||||||
function ToCurlCommand() as string
|
function ToCurlCommand() as string
|
||||||
command = `curl "${m.BuildUrl()}"`
|
command = `curl "${m.BuildUrl()}"`
|
||||||
if m._method = "HEAD"
|
if m._method = "HEAD"
|
||||||
@@ -387,6 +392,10 @@ namespace HttpClient
|
|||||||
end if
|
end if
|
||||||
#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"
|
if m._method = "POST"
|
||||||
body = m._body
|
body = m._body
|
||||||
if body = invalid
|
if body = invalid
|
||||||
@@ -394,7 +403,11 @@ namespace HttpClient
|
|||||||
end if
|
end if
|
||||||
m._sent = m.urlTransfer.AsyncPostFromString(body)
|
m._sent = m.urlTransfer.AsyncPostFromString(body)
|
||||||
else if m._method = "GET"
|
else if m._method = "GET"
|
||||||
|
if m._toFilePath <> invalid
|
||||||
|
m._sent = m.urlTransfer.AsyncGetToFile(m._toFilePath)
|
||||||
|
else
|
||||||
m._sent = m.urlTransfer.AsyncGetToString()
|
m._sent = m.urlTransfer.AsyncGetToString()
|
||||||
|
end if
|
||||||
else if m._method = "HEAD"
|
else if m._method = "HEAD"
|
||||||
m._sent = m.urlTransfer.AsyncHead()
|
m._sent = m.urlTransfer.AsyncHead()
|
||||||
else
|
else
|
||||||
|
|||||||
Generated
+10
-10
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-web",
|
"name": "playlet-web",
|
||||||
"version": "0.43.3",
|
"version": "0.43.9",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-web",
|
"name": "playlet-web",
|
||||||
"version": "0.43.3",
|
"version": "0.43.9",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
||||||
"@tailwindcss/postcss": "^4.1.16",
|
"@tailwindcss/postcss": "^4.1.16",
|
||||||
@@ -15,13 +15,13 @@
|
|||||||
"@vitejs/plugin-legacy": "^7.2.1",
|
"@vitejs/plugin-legacy": "^7.2.1",
|
||||||
"autoprefixer": "^10.4.21",
|
"autoprefixer": "^10.4.21",
|
||||||
"bgutils-js": "^3.2.0",
|
"bgutils-js": "^3.2.0",
|
||||||
"daisyui": "^5.3.9",
|
"daisyui": "^5.3.10",
|
||||||
"dotenv": "^17.2.3",
|
"dotenv": "^17.2.3",
|
||||||
"ip": "^2.0.1",
|
"ip": "^2.0.1",
|
||||||
"jszip": "^3.10.1",
|
"jszip": "^3.10.1",
|
||||||
"postcss": "^8.5.6",
|
"postcss": "^8.5.6",
|
||||||
"rollup-plugin-visualizer": "^6.0.5",
|
"rollup-plugin-visualizer": "^6.0.5",
|
||||||
"svelte": "^5.41.4",
|
"svelte": "^5.43.2",
|
||||||
"svelte-check": "^4.3.3",
|
"svelte-check": "^4.3.3",
|
||||||
"svelte-preprocess": "^6.0.3",
|
"svelte-preprocess": "^6.0.3",
|
||||||
"tailwindcss": "^4.1.16",
|
"tailwindcss": "^4.1.16",
|
||||||
@@ -3123,9 +3123,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/daisyui": {
|
"node_modules/daisyui": {
|
||||||
"version": "5.3.9",
|
"version": "5.3.10",
|
||||||
"resolved": "https://registry.npmjs.org/daisyui/-/daisyui-5.3.9.tgz",
|
"resolved": "https://registry.npmjs.org/daisyui/-/daisyui-5.3.10.tgz",
|
||||||
"integrity": "sha512-741x1pGGSGHcrBYtdE7iKbqW1OoiijYdAZ8oJPZR9MhSKLcMBlHjKfN3YlM2/K7t5jd7O0sg4SqkVNPylalRFw==",
|
"integrity": "sha512-vmjyPmm0hvFhA95KB6uiGmWakziB2pBv6CUcs5Ka/3iMBMn9S+C3SZYx9G9l2JrgTZ1EFn61F/HrPcwaUm2kLQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"funding": {
|
"funding": {
|
||||||
@@ -4403,9 +4403,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/svelte": {
|
"node_modules/svelte": {
|
||||||
"version": "5.41.4",
|
"version": "5.43.2",
|
||||||
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.41.4.tgz",
|
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.43.2.tgz",
|
||||||
"integrity": "sha512-sBrVmskY0eij5+CSSuMK1kOk1xSiRh0BRTEhUnxnd1x3p42GbQmm4rwq4WMD23rUG3QR53Nfv8kpaER3tV5F4A==",
|
"integrity": "sha512-ro1umEzX8rT5JpCmlf0PPv7ncD8MdVob9e18bhwqTKNoLjS8kDvhVpaoYVPc+qMwDAOfcwJtyY7ZFSDbOaNPgA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-web",
|
"name": "playlet-web",
|
||||||
"version": "0.43.3",
|
"version": "0.43.9",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@@ -16,13 +16,13 @@
|
|||||||
"@vitejs/plugin-legacy": "^7.2.1",
|
"@vitejs/plugin-legacy": "^7.2.1",
|
||||||
"autoprefixer": "^10.4.21",
|
"autoprefixer": "^10.4.21",
|
||||||
"bgutils-js": "^3.2.0",
|
"bgutils-js": "^3.2.0",
|
||||||
"daisyui": "^5.3.9",
|
"daisyui": "^5.3.10",
|
||||||
"dotenv": "^17.2.3",
|
"dotenv": "^17.2.3",
|
||||||
"ip": "^2.0.1",
|
"ip": "^2.0.1",
|
||||||
"jszip": "^3.10.1",
|
"jszip": "^3.10.1",
|
||||||
"postcss": "^8.5.6",
|
"postcss": "^8.5.6",
|
||||||
"rollup-plugin-visualizer": "^6.0.5",
|
"rollup-plugin-visualizer": "^6.0.5",
|
||||||
"svelte": "^5.41.4",
|
"svelte": "^5.43.2",
|
||||||
"svelte-check": "^4.3.3",
|
"svelte-check": "^4.3.3",
|
||||||
"svelte-preprocess": "^6.0.3",
|
"svelte-preprocess": "^6.0.3",
|
||||||
"tailwindcss": "^4.1.16",
|
"tailwindcss": "^4.1.16",
|
||||||
|
|||||||
Reference in new issue
Block a user