Compare commits

...
12 Commits
Author SHA1 Message Date
Brahim Hadriche c2abcc5478 Release v0.33.0 (#504) 2024-12-14 14:23:52 -05:00
Brahim Hadriche 8307f577fd update dependencies (#503) 2024-12-14 10:22:48 -05:00
Brahim Hadriche 0ce0dc43c3 [skip ci] typo 2024-12-12 20:19:03 -05:00
Brahim Hadriche 357019d74b Improvements for very long HLS playlists 2024-12-12 19:26:45 -05:00
Brahim Hadriche bfc1439d1a [skip ci] curl command 2024-12-12 17:48:12 -05:00
Brahim Hadriche dd2262ec28 Improve validation plugin 2024-12-12 10:18:50 -05:00
Brahim Hadriche 0c3f8cea2a reuse sponsorblock bar png 2024-12-10 16:48:41 -05:00
Brahim Hadriche 4682d4f3e4 [skip ci] changelog adjustment 2024-12-09 20:55:47 -05:00
Brahim Hadriche 1e161e8a77 Use credentialTransferToken to play age restricted videos (#498)
* Use credentialTransferToken to play age restricted videos

* changelog
2024-12-09 20:48:56 -05:00
Brahim Hadriche ee239c3ea9 deps 2024-12-06 22:06:07 -05:00
Brahim Hadriche 1daddc9b91 Handle preferences v0 to v1 migration 2024-12-05 20:41:53 -05:00
Brahim Hadriche 335761aa8e search suggestions 2024-12-04 20:07:06 -05:00
23 changed files with 252 additions and 127 deletions

No files matched your search

+12
View File
@@ -5,6 +5,18 @@ 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.33.0] - 2024-12-14
### Added
- Search suggestions to Playlet backend
- Support for age restrcited videos and private videos when cast from YouTube app (logged in)
- Note: it works when the video is explicitely cast. If it was added to queue, or added as part of a playlist, this might not work.
### Fixed
- Improved on issue with long videos (10+ hours) showing as 2:30 only. They now show about 5 hours.
## [0.32.1] - 2024-12-03 ## [0.32.1] - 2024-12-03
### Fixed ### Fixed
+1 -1
View File
@@ -2,7 +2,7 @@ openapi: 3.0.0
info: info:
title: Playlet Web API title: Playlet Web API
version: 0.32.1 version: 0.33.0
description: description:
Playlet Web API is a RESTful API for controlling the Playlet app on Playlet Web API is a RESTful API for controlling the Playlet app on
Roku devices. The API is intended to be used by the Playlet web app, but can Roku devices. The API is intended to be used by the Playlet web app, but can
+43 -40
View File
@@ -1,34 +1,34 @@
{ {
"name": "playlet", "name": "playlet",
"version": "0.32.1", "version": "0.33.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet", "name": "playlet",
"version": "0.32.1", "version": "0.33.0",
"hasInstallScript": true, "hasInstallScript": true,
"devDependencies": { "devDependencies": {
"@rokucommunity/bslint": "^0.8.26", "@rokucommunity/bslint": "^0.8.26",
"@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": "^22.10.1", "@types/node": "^22.10.2",
"@types/xml2js": "^0.4.14", "@types/xml2js": "^0.4.14",
"argparse": "^2.0.1", "argparse": "^2.0.1",
"brighterscript": "0.68.1", "brighterscript": "0.68.2",
"brighterscript-formatter": "^1.7.6", "brighterscript-formatter": "^1.7.6",
"convert-svg-to-png": "^0.6.4", "convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0", "cross-fetch": "^4.0.0",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"dotenv": "^16.4.5", "dotenv": "^16.4.7",
"express": "^4.21.1", "express": "^4.21.2",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"glob": "^11.0.0", "glob": "^11.0.0",
"imap": "^0.8.19", "imap": "^0.8.19",
"ip": "^2.0.1", "ip": "^2.0.1",
"json5": "^2.2.3", "json5": "^2.2.3",
"mailparser": "^3.7.2", "mailparser": "^3.7.2",
"roku-deploy": "^3.12.2", "roku-deploy": "^3.12.3",
"rooibos-roku": "5.14.0", "rooibos-roku": "5.14.0",
"rounded-rect-9patch": "^1.0.1", "rounded-rect-9patch": "^1.0.1",
"semver": "^7.6.3", "semver": "^7.6.3",
@@ -271,9 +271,9 @@
} }
}, },
"node_modules/@postman/tunnel-agent": { "node_modules/@postman/tunnel-agent": {
"version": "0.6.3", "version": "0.6.4",
"resolved": "https://registry.npmjs.org/@postman/tunnel-agent/-/tunnel-agent-0.6.3.tgz", "resolved": "https://registry.npmjs.org/@postman/tunnel-agent/-/tunnel-agent-0.6.4.tgz",
"integrity": "sha512-k57fzmAZ2PJGxfOA4SGR05ejorHbVAa/84Hxh/2nAztjNXc4ZjOm9NUIk6/Z6LCrBvJZqjRZbN8e/nROVUPVdg==", "integrity": "sha512-CJJlq8V7rNKhAw4sBfjixKpJW00SHqebqNUQKxMoepgeWZIbdPcD+rguRcivGhS4N12PymDcKgUgSD4rVC+RjQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"safe-buffer": "^5.0.1" "safe-buffer": "^5.0.1"
@@ -522,10 +522,11 @@
"dev": true "dev": true
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.10.1", "version": "22.10.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.2.tgz",
"integrity": "sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==", "integrity": "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"undici-types": "~6.20.0" "undici-types": "~6.20.0"
} }
@@ -926,9 +927,9 @@
} }
}, },
"node_modules/brighterscript": { "node_modules/brighterscript": {
"version": "0.68.1", "version": "0.68.2",
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.68.1.tgz", "resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.68.2.tgz",
"integrity": "sha512-sdbTfg0jmWO/GD0cJpOaBdoR7h80ocN2SqgFeIn6FrXmGHOopYJH89K76V9ZKNXzY3yBdMcZJGsXM+Rv1T0/Tg==", "integrity": "sha512-KV7CcvpPRqFtlBBVNWYPR8dq7KmmKB6Ymkd6pTt1uztm1c3Fgm3DaqfT842I0yW2LZz3uIb2EKmoLDdnnjEQFQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@rokucommunity/bslib": "^0.1.1", "@rokucommunity/bslib": "^0.1.1",
@@ -954,7 +955,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.12.2", "roku-deploy": "^3.12.3",
"serialize-error": "^7.0.1", "serialize-error": "^7.0.1",
"source-map": "^0.7.4", "source-map": "^0.7.4",
"vscode-languageserver": "^9.0.1", "vscode-languageserver": "^9.0.1",
@@ -2115,9 +2116,9 @@
} }
}, },
"node_modules/dotenv": { "node_modules/dotenv": {
"version": "16.4.5", "version": "16.4.7",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz",
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
@@ -2301,11 +2302,10 @@
"dev": true "dev": true
}, },
"node_modules/express": { "node_modules/express": {
"version": "4.21.1", "version": "4.21.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
"integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"accepts": "~1.3.8", "accepts": "~1.3.8",
"array-flatten": "1.1.1", "array-flatten": "1.1.1",
@@ -2326,7 +2326,7 @@
"methods": "~1.1.2", "methods": "~1.1.2",
"on-finished": "2.4.1", "on-finished": "2.4.1",
"parseurl": "~1.3.3", "parseurl": "~1.3.3",
"path-to-regexp": "0.1.10", "path-to-regexp": "0.1.12",
"proxy-addr": "~2.0.7", "proxy-addr": "~2.0.7",
"qs": "6.13.0", "qs": "6.13.0",
"range-parser": "~1.2.1", "range-parser": "~1.2.1",
@@ -2341,6 +2341,10 @@
}, },
"engines": { "engines": {
"node": ">= 0.10.0" "node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
} }
}, },
"node_modules/extend": { "node_modules/extend": {
@@ -4156,11 +4160,10 @@
} }
}, },
"node_modules/path-to-regexp": { "node_modules/path-to-regexp": {
"version": "0.1.10", "version": "0.1.12",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
"integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==", "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
"dev": true, "dev": true
"license": "MIT"
}, },
"node_modules/peberminta": { "node_modules/peberminta": {
"version": "0.9.0", "version": "0.9.0",
@@ -4246,14 +4249,14 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/postman-request": { "node_modules/postman-request": {
"version": "2.88.1-postman.33", "version": "2.88.1-postman.40",
"resolved": "https://registry.npmjs.org/postman-request/-/postman-request-2.88.1-postman.33.tgz", "resolved": "https://registry.npmjs.org/postman-request/-/postman-request-2.88.1-postman.40.tgz",
"integrity": "sha512-uL9sCML4gPH6Z4hreDWbeinKU0p0Ke261nU7OvII95NU22HN6Dk7T/SaVPaj6T4TsQqGKIFw6/woLZnH7ugFNA==", "integrity": "sha512-uE4AiIqhjtHKp4pj9ei7fkdfNXEX9IqDBlK1plGAQne6y79UUlrTdtYLhwXoO0AMOvqyl9Ar+BU6Eo6P/MPgfg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@postman/form-data": "~3.1.1", "@postman/form-data": "~3.1.1",
"@postman/tough-cookie": "~4.1.3-postman.1", "@postman/tough-cookie": "~4.1.3-postman.1",
"@postman/tunnel-agent": "^0.6.3", "@postman/tunnel-agent": "^0.6.4",
"aws-sign2": "~0.7.0", "aws-sign2": "~0.7.0",
"aws4": "^1.12.0", "aws4": "^1.12.0",
"brotli": "^1.3.3", "brotli": "^1.3.3",
@@ -4275,7 +4278,7 @@
"uuid": "^8.3.2" "uuid": "^8.3.2"
}, },
"engines": { "engines": {
"node": ">= 6" "node": ">= 16"
} }
}, },
"node_modules/postman-request/node_modules/qs": { "node_modules/postman-request/node_modules/qs": {
@@ -5193,12 +5196,12 @@
} }
}, },
"node_modules/roku-deploy": { "node_modules/roku-deploy": {
"version": "3.12.2", "version": "3.12.3",
"resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.12.2.tgz", "resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.12.3.tgz",
"integrity": "sha512-CePBiVk+6u4Pka/aq7WR4GnTW39BlAveEbhuDHQX2UfR9+4j3+YEvfXqxB0R69RU52eGfnk1ejI7H0HStEKa2Q==", "integrity": "sha512-4gkNW/N4VeP4hKFMNUzMS9tCXm67OdLaJIPj9kBjf81Nqn7EPHfdYLVAa9sQbRV0tSNDUUM7qk5/bSLC1G653A==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"@types/request": "^2.47.0",
"chalk": "^2.4.2", "chalk": "^2.4.2",
"dateformat": "^3.0.3", "dateformat": "^3.0.3",
"dayjs": "^1.11.0", "dayjs": "^1.11.0",
@@ -5211,7 +5214,7 @@
"micromatch": "^4.0.4", "micromatch": "^4.0.4",
"moment": "^2.29.1", "moment": "^2.29.1",
"parse-ms": "^2.1.0", "parse-ms": "^2.1.0",
"postman-request": "^2.88.1-postman.32", "postman-request": "^2.88.1-postman.40",
"temp-dir": "^2.0.0", "temp-dir": "^2.0.0",
"xml2js": "^0.5.0" "xml2js": "^0.5.0"
}, },
+7 -7
View File
@@ -1,28 +1,28 @@
{ {
"name": "playlet", "name": "playlet",
"version": "0.32.1", "version": "0.33.0",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"devDependencies": { "devDependencies": {
"@rokucommunity/bslint": "^0.8.26", "@rokucommunity/bslint": "^0.8.26",
"@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": "^22.10.1", "@types/node": "^22.10.2",
"@types/xml2js": "^0.4.14", "@types/xml2js": "^0.4.14",
"argparse": "^2.0.1", "argparse": "^2.0.1",
"brighterscript": "0.68.1", "brighterscript": "0.68.2",
"brighterscript-formatter": "^1.7.6", "brighterscript-formatter": "^1.7.6",
"convert-svg-to-png": "^0.6.4", "convert-svg-to-png": "^0.6.4",
"cross-fetch": "^4.0.0", "cross-fetch": "^4.0.0",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"dotenv": "^16.4.5", "dotenv": "^16.4.7",
"express": "^4.21.1", "express": "^4.21.2",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"glob": "^11.0.0", "glob": "^11.0.0",
"imap": "^0.8.19", "imap": "^0.8.19",
"ip": "^2.0.1", "ip": "^2.0.1",
"json5": "^2.2.3", "json5": "^2.2.3",
"mailparser": "^3.7.2", "mailparser": "^3.7.2",
"roku-deploy": "^3.12.2", "roku-deploy": "^3.12.3",
"rooibos-roku": "5.14.0", "rooibos-roku": "5.14.0",
"rounded-rect-9patch": "^1.0.1", "rounded-rect-9patch": "^1.0.1",
"semver": "^7.6.3", "semver": "^7.6.3",
@@ -64,7 +64,7 @@
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js", "generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
"update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip", "update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip",
"postinstall": "cd playlet-lib && npm install && cd ../playlet-app && npm install && cd ../playlet-web && npm install", "postinstall": "cd playlet-lib && npm install && cd ../playlet-app && npm install && cd ../playlet-web && npm install",
"update-deps": "npx npm-check-updates --deep --upgrade --install always --reject @sveltejs/vite-plugin-svelte,svelte", "update-deps": "npx npm-check-updates --deep --upgrade --install always --reject @sveltejs/vite-plugin-svelte,svelte,vite,@vitejs/plugin-legacy",
"registry:write": "node tools/registry.js --input registry.json", "registry:write": "node tools/registry.js --input registry.json",
"registry:read": "node tools/registry.js --output registry.json", "registry:read": "node tools/registry.js --output registry.json",
"registry:clear": "node tools/registry.js --clear" "registry:clear": "node tools/registry.js --clear"
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.32.1", "version": "0.33.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-app", "name": "playlet-app",
"version": "0.32.1" "version": "0.33.0"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.32.1", "version": "0.33.0",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"scripts": { "scripts": {
"prebuild": "rm -rf ../build/playlet-app", "prebuild": "rm -rf ../build/playlet-app",
+2 -2
View File
@@ -2,8 +2,8 @@ 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=32 minor_version=33
build_version=00001 build_version=00000
ui_resolutions=hd ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p uri_resolution_autosub=$$RES$$,480p,720p,1080p
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.32.1", "version": "0.33.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.32.1" "version": "0.33.0"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.32.1", "version": "0.33.0",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"scripts": { "scripts": {
"prebuild": "rm -rf ../build/playlet-lib", "prebuild": "rm -rf ../build/playlet-lib",
@@ -1,3 +1,4 @@
import "pkg:/components/Services/Innertube/InnertubeService.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs" import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/components/Services/SearchHistory/SearchHistoryUtils.bs" import "pkg:/components/Services/SearchHistory/SearchHistoryUtils.bs"
@@ -7,13 +8,17 @@ function SearchSuggestionsTask(input as object) as object
invidiousNode = input.invidious invidiousNode = input.invidious
preferencesNode = input.preferences preferencesNode = input.preferences
service = new Invidious.InvidiousService(invidiousNode)
if m.top.cancel if m.top.cancel
return invalid return invalid
end if end if
backend = preferencesNode["playback.backend"]
if backend = "playlet"
searchSuggestsions = StringUtils.IsNullOrEmpty(q) ? invalid : InnertubeService.GetSearchSuggestions(q, m.top.cancellation)
else
service = new Invidious.InvidiousService(invidiousNode)
searchSuggestsions = StringUtils.IsNullOrEmpty(q) ? invalid : service.SearchSuggestions(q, m.top.cancellation) searchSuggestsions = StringUtils.IsNullOrEmpty(q) ? invalid : service.SearchSuggestions(q, m.top.cancellation)
end if
if m.top.cancel if m.top.cancel
return invalid return invalid
@@ -18,6 +18,7 @@ namespace InnertubeService
function GetVideoMetadata(videoId as string, options = invalid as object) as object function GetVideoMetadata(videoId as string, options = invalid as object) as object
cancellation = invalid cancellation = invalid
fetchNext = true fetchNext = true
ctt = ""
if options <> invalid if options <> invalid
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
@@ -26,16 +27,19 @@ namespace InnertubeService
if options.DoesExist("fetchNext") if options.DoesExist("fetchNext")
fetchNext = options.fetchNext fetchNext = options.fetchNext
end if end if
if options.DoesExist("ctt")
ctt = options.ctt
end if
end if end if
playerRequest = CreatePlayerRequest(videoId) playerRequest = CreatePlayerRequest(videoId, ctt)
playerRequest.Cancellation(cancellation) playerRequest.Cancellation(cancellation)
playerRequest.Send() playerRequest.Send()
nextRequest = invalid nextRequest = invalid
nextResponse = invalid nextResponse = invalid
if fetchNext if fetchNext
nextRequest = CreateNextRequest(videoId) nextRequest = CreateNextRequest(videoId, ctt)
nextRequest.Cancellation(cancellation) nextRequest.Cancellation(cancellation)
nextRequest.Send() nextRequest.Send()
end if end if
@@ -67,7 +71,7 @@ namespace InnertubeService
return playerResponse return playerResponse
end function end function
function CreatePlayerRequest(videoId as string) as object function CreatePlayerRequest(videoId as string, ctt as string) as object
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
@@ -124,6 +128,13 @@ namespace InnertubeService
} }
} }
if not StringUtils.IsNullOrEmpty(ctt)
payload["context"]["user"]["credentialTransferTokens"] = [{
"token": ctt
"scope": "VIDEO"
}]
end if
request = HttpClient.Post("https://www.youtube.com/youtubei/v1/player?prettyPrint=false&alt=json", FormatJson(payload)) request = HttpClient.Post("https://www.youtube.com/youtubei/v1/player?prettyPrint=false&alt=json", FormatJson(payload))
request.Headers({ request.Headers({
"accept": "*/*" "accept": "*/*"
@@ -137,7 +148,7 @@ namespace InnertubeService
return request return request
end function end function
function CreateNextRequest(videoId as string) as object function CreateNextRequest(videoId as string, ctt as string) as object
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
@@ -185,6 +196,13 @@ namespace InnertubeService
} }
} }
if not StringUtils.IsNullOrEmpty(ctt)
payload["context"]["user"]["credentialTransferTokens"] = [{
"token": ctt
"scope": "VIDEO"
}]
end if
request = HttpClient.Post("https://www.youtube.com/youtubei/v1/next?prettyPrint=false&alt=json", FormatJson(payload)) request = HttpClient.Post("https://www.youtube.com/youtubei/v1/next?prettyPrint=false&alt=json", FormatJson(payload))
request.Headers({ request.Headers({
"accept": "*/*" "accept": "*/*"
@@ -465,4 +483,44 @@ namespace InnertubeService
return parsedResponse return parsedResponse
end function end function
function GetSearchSuggestions(q as string, cancellation = invalid as object) as object
request = HttpClient.Get("https://suggestqueries.google.com/complete/search?hl=en&gl=US&ds=yt&client=youtube&xssi=t&oe=UTF&q=" + q.EncodeUriComponent())
request.Headers({
"user-agent": INNERTUBE_WEB_USER_AGENT
})
request.CacheSeconds(60 * 60 * 24)
request.Cancellation(cancellation)
response = request.Await()
if not response.IsSuccess()
return {
suggestions: []
}
end if
text = response.Text()
text = text.Replace(`)]}'`, "")
parsed = ParseJson(text)
if not IsArray(parsed) or parsed.Count() < 2
return {
suggestions: []
}
end if
parsed = parsed[1]
suggestions = []
for each suggestion in parsed
s = suggestion[0]
if not IsString(s)
continue for
end if
suggestions.Push(s)
end for
return {
suggestions: suggestions
}
end function
end namespace end namespace
@@ -404,6 +404,17 @@ class LoungeApi
function HandleSetPlaylist(_commandId as integer, commandType as string, commandArgs as object, _messagesToSend as object) function HandleSetPlaylist(_commandId as integer, commandType as string, commandArgs as object, _messagesToSend as object)
LogDebug(commandType, commandArgs) LogDebug(commandType, commandArgs)
' TODO:P2 ctt: credentialTransferToken
' We receive credentialTransferTokens here that can be attached to innertube requests.
' The tokens belong to the user logged in on the mobile app.
' These allow us to watch age restricted videos and private videos.
' They are scoped by video.
' Right now we just store only the last ctt, which works ok if we're casting one video at a time.
' But if the age restrcited video is added to the queue, we don't capture a token and playing the video would fail.
' These tokens need to be managed better, based on the video they belong to.
if not StringUtils.IsNullOrEmpty(commandArgs.ctt)
m.loungeServiceNode.ctt = commandArgs.ctt
end if
LoungeVideoQueue.SetPlaylist(m.videoQueueNode, m.invService, commandArgs) LoungeVideoQueue.SetPlaylist(m.videoQueueNode, m.invService, commandArgs)
end function end function
@@ -5,6 +5,7 @@
<field id="deviceName" type="string" /> <field id="deviceName" type="string" />
<field id="screenId" type="string" /> <field id="screenId" type="string" />
<field id="loungeToken" type="string" /> <field id="loungeToken" type="string" />
<field id="ctt" type="string" />
<field id="join" type="boolean" alwaysNotify="true" /> <field id="join" type="boolean" alwaysNotify="true" />
<field id="outgoingMessages" type="array" alwaysNotify="true" /> <field id="outgoingMessages" type="array" alwaysNotify="true" />
@@ -109,6 +109,11 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES) RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES)
end if end if
if ValidInt(userPrefs.__version) = 0
userPrefs.__version = 1
isDirty = true
end if
if userPrefs.__version = 1 if userPrefs.__version = 1
if ValidString(userPrefs["playback.preferred_quality"]) = "medium" if ValidString(userPrefs["playback.preferred_quality"]) = "medium"
userPrefs["playback.preferred_quality"] = "480p,360p" userPrefs["playback.preferred_quality"] = "480p,360p"
@@ -10,7 +10,7 @@ function SponsorBlockTask(input as object) as object
barPath = invalid barPath = invalid
if skipSegments <> invalid if skipSegments <> invalid
barPath = `tmp:/sponsorblock_bar_${videoId}.png` barPath = `tmp:/sponsorblock_bar.png`
service.GenerateProgressBarBackground(skipSegments, lengthSeconds, barPath) service.GenerateProgressBarBackground(skipSegments, lengthSeconds, barPath)
end if end if
@@ -6,6 +6,7 @@ function VideoContentTask(input as object) as object
contentNode = input.content contentNode = input.content
invidiousNode = input.invidious invidiousNode = input.invidious
preferencesNode = input.preferences preferencesNode = input.preferences
loungeServiceNode = input.loungeService
playletServerPort = input.playletServerPort playletServerPort = input.playletServerPort
if m.top.cancel if m.top.cancel
@@ -20,7 +21,10 @@ function VideoContentTask(input as object) as object
backend = preferencesNode["playback.backend"] backend = preferencesNode["playback.backend"]
if backend = "playlet" if backend = "playlet"
response = InnertubeService.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation }) response = InnertubeService.GetVideoMetadata(contentNode.videoId, {
cancellation: m.top.cancellation
ctt: loungeServiceNode.ctt
})
else else
response = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation }) response = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
end if end if
@@ -60,6 +64,10 @@ function VideoContentTask(input as object) as object
end if end if
streamUrls = CreateStreamUrls(metadata, service, preferencesNode, backend, playletServerPort) streamUrls = CreateStreamUrls(metadata, service, preferencesNode, backend, playletServerPort)
' Forwarding query params to HLS playlists is not needed. In fact, it can cause issues
' because the playlist is limited to 4MB, and on large playlists the query params
' significantly increase the size of the playlist, making it cropped.
contentNode.ForwardQueryStringParams = false
contentNode.addFields({ contentNode.addFields({
metadata: metadata metadata: metadata
' StreamUrls is taken ' StreamUrls is taken
@@ -152,6 +152,7 @@ function StartVideoContentTask(videoContentNode as object)
content: videoContentNode content: videoContentNode
invidious: m.top.invidious invidious: m.top.invidious
preferences: m.top.preferences preferences: m.top.preferences
loungeService: m.top.loungeService
playletServerPort: m.top.webServer.port playletServerPort: m.top.webServer.port
}, OnVideoContentTaskResults) }, OnVideoContentTaskResults)
end function end function
@@ -24,6 +24,7 @@ namespace Http
hlsRequest = HttpClient.Get(url) hlsRequest = HttpClient.Get(url)
headers = request.headers headers = request.headers
' Host is probably 127.0.0.1 so we should remove it before hitting the server
headers.Delete("Host") headers.Delete("Host")
hlsRequest.Headers(headers) hlsRequest.Headers(headers)
@@ -43,7 +44,10 @@ namespace Http
hlsManifest = m.AppendStoryboardPlaylists(hlsManifest) hlsManifest = m.AppendStoryboardPlaylists(hlsManifest)
response.http_code = hlsResponse.StatusCode() response.http_code = hlsResponse.StatusCode()
response.headers = hlsResponse.Headers() headers = hlsResponse.Headers()
' We responding with uncompressed data
headers.Delete("Content-Encoding")
response.headers = headers
response.SetBodyDataString(ValidString(hlsManifest)) response.SetBodyDataString(ValidString(hlsManifest))
return true return true
+2 -2
View File
@@ -2,8 +2,8 @@ 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=32 minor_version=33
build_version=00001 build_version=00000
ui_resolutions=hd ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p uri_resolution_autosub=$$RES$$,480p,720p,1080p
@@ -281,12 +281,14 @@ namespace HttpClient
function ToCurlCommand() as string function ToCurlCommand() as string
command = `curl "${m.BuildUrl()}"` command = `curl "${m.BuildUrl()}"`
if m._method = "HEAD" if m._method = "HEAD"
command += ` \\\n -I` command += ` \\\n --head`
else if m._method <> "GET" else if m._method <> "GET"
command += ` \\\n -X ${m._method}` command += ` \\\n --request ${m._method}`
end if end if
command += ` \\\n --max-time ${m._timeoutSeconds}` command += ` \\\n --max-time ${m._timeoutSeconds}`
command += ` \\\n --location`
command += ` \\\n --show-error`
if COMPRESSION_ENABLED if COMPRESSION_ENABLED
command += ` \\\n --compressed` command += ` \\\n --compressed`
+45 -49
View File
@@ -1,14 +1,14 @@
{ {
"name": "playlet-web", "name": "playlet-web",
"version": "0.32.1", "version": "0.33.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-web", "name": "playlet-web",
"version": "0.32.1", "version": "0.33.0",
"dependencies": { "dependencies": {
"youtubei.js": "^11.0.1" "youtubei.js": "^12.2.0"
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/vite-plugin-svelte": "3.1.2", "@sveltejs/vite-plugin-svelte": "3.1.2",
@@ -16,19 +16,19 @@
"@tsconfig/svelte": "^5.0.4", "@tsconfig/svelte": "^5.0.4",
"@vitejs/plugin-legacy": "^5.4.3", "@vitejs/plugin-legacy": "^5.4.3",
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.20",
"daisyui": "^4.12.14", "daisyui": "^4.12.22",
"dotenv": "^16.4.5", "dotenv": "^16.4.7",
"ip": "^2.0.1", "ip": "^2.0.1",
"postcss": "^8.4.49", "postcss": "^8.4.49",
"svelte": "4.2.19", "svelte": "4.2.19",
"svelte-check": "^4.1.0", "svelte-check": "^4.1.1",
"svelte-preprocess": "^6.0.3", "svelte-preprocess": "^6.0.3",
"tailwindcss": "^3.4.15", "tailwindcss": "^3.4.16",
"terser": "^5.36.0", "terser": "^5.37.0",
"tslib": "^2.8.1", "tslib": "^2.8.1",
"typescript": "^5.7.2", "typescript": "^5.7.2",
"vite": "^5.4.11", "vite": "^5.4.11",
"vite-tsconfig-paths": "^5.1.3" "vite-tsconfig-paths": "^5.1.4"
} }
}, },
"node_modules/@alloc/quick-lru": { "node_modules/@alloc/quick-lru": {
@@ -2745,10 +2745,11 @@
} }
}, },
"node_modules/daisyui": { "node_modules/daisyui": {
"version": "4.12.14", "version": "4.12.22",
"resolved": "https://registry.npmjs.org/daisyui/-/daisyui-4.12.14.tgz", "resolved": "https://registry.npmjs.org/daisyui/-/daisyui-4.12.22.tgz",
"integrity": "sha512-hA27cdBasdwd4/iEjn+aidoCrRroDuo3G5W9NDKaVCJI437Mm/3eSL/2u7MkZ0pt8a+TrYF3aT2pFVemTS3how==", "integrity": "sha512-HDLWbmTnXxhE1MrMgSWjVgdRt+bVYHvfNbW3GTsyIokRSqTHonUTrxV3RhpPDjGIWaHt+ELtDCTYCtUFgL2/Nw==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"css-selector-tokenizer": "^0.8", "css-selector-tokenizer": "^0.8",
"culori": "^3", "culori": "^3",
@@ -2811,9 +2812,9 @@
"dev": true "dev": true
}, },
"node_modules/dotenv": { "node_modules/dotenv": {
"version": "16.4.5", "version": "16.4.7",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz",
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
@@ -3168,12 +3169,13 @@
} }
}, },
"node_modules/jintr": { "node_modules/jintr": {
"version": "3.0.2", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/jintr/-/jintr-3.0.2.tgz", "resolved": "https://registry.npmjs.org/jintr/-/jintr-3.2.0.tgz",
"integrity": "sha512-5g2EBudeJFOopjAX4exAv5OCCW1DgUISfoioCsm1h9Q9HJ41LmnZ6J52PCsqBlQihsmp0VDuxreAVzM7yk5nFA==", "integrity": "sha512-psD1yf05kMKDNsUdW1l5YhO59pHScQ6OIHHb8W5SKSM2dCOFPsqolmIuSHgVA8+3Dc47NJR181CXZ4alCAPTkA==",
"funding": [ "funding": [
"https://github.com/sponsors/LuanRT" "https://github.com/sponsors/LuanRT"
], ],
"license": "MIT",
"dependencies": { "dependencies": {
"acorn": "^8.8.0" "acorn": "^8.8.0"
} }
@@ -3227,12 +3229,15 @@
} }
}, },
"node_modules/lilconfig": { "node_modules/lilconfig": {
"version": "2.1.0", "version": "3.1.3",
"resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz",
"integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==", "integrity": "sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=10" "node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/antonk52"
} }
}, },
"node_modules/lines-and-columns": { "node_modules/lines-and-columns": {
@@ -3629,15 +3634,6 @@
} }
} }
}, },
"node_modules/postcss-load-config/node_modules/lilconfig": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.0.0.tgz",
"integrity": "sha512-K2U4W2Ff5ibV7j7ydLr+zLAkIg5JJ4lPn1Ltsdt+Tz/IjQ8buJ55pZAxoP34lqIiwtF9iAvtLv3JGv7CAyAg+g==",
"dev": true,
"engines": {
"node": ">=14"
}
},
"node_modules/postcss-nested": { "node_modules/postcss-nested": {
"version": "6.2.0", "version": "6.2.0",
"resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.2.0.tgz", "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.2.0.tgz",
@@ -4130,9 +4126,9 @@
} }
}, },
"node_modules/svelte-check": { "node_modules/svelte-check": {
"version": "4.1.0", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.1.0.tgz", "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.1.1.tgz",
"integrity": "sha512-AflEZYqI578KuDZcpcorPSf597LStxlkN7XqXi38u09zlHODVKd7c+7OuubGzbhgGRUqNTdQCZ+Ga96iRXEf2g==", "integrity": "sha512-NfaX+6Qtc8W/CyVGS/F7/XdiSSyXz+WGYA9ZWV3z8tso14V2vzjfXviKaTFEzB7g8TqfgO2FOzP6XT4ApSTUTw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@jridgewell/trace-mapping": "^0.3.25", "@jridgewell/trace-mapping": "^0.3.25",
@@ -4287,9 +4283,9 @@
"dev": true "dev": true
}, },
"node_modules/tailwindcss": { "node_modules/tailwindcss": {
"version": "3.4.15", "version": "3.4.16",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.15.tgz", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.16.tgz",
"integrity": "sha512-r4MeXnfBmSOuKUWmXe6h2CcyfzJCEk4F0pptO5jlnYSIViUkVmsawj80N5h2lO3gwcmSb4n3PuN+e+GC1Guylw==", "integrity": "sha512-TI4Cyx7gDiZ6r44ewaJmt0o6BrMCT5aK5e0rmJ/G9Xq3w7CX/5VXl/zIPEJZFUK5VEqwByyhqNPycPlvcK4ZNw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@alloc/quick-lru": "^5.2.0", "@alloc/quick-lru": "^5.2.0",
@@ -4301,7 +4297,7 @@
"glob-parent": "^6.0.2", "glob-parent": "^6.0.2",
"is-glob": "^4.0.3", "is-glob": "^4.0.3",
"jiti": "^1.21.6", "jiti": "^1.21.6",
"lilconfig": "^2.1.0", "lilconfig": "^3.1.3",
"micromatch": "^4.0.8", "micromatch": "^4.0.8",
"normalize-path": "^3.0.0", "normalize-path": "^3.0.0",
"object-hash": "^3.0.0", "object-hash": "^3.0.0",
@@ -4349,11 +4345,10 @@
} }
}, },
"node_modules/terser": { "node_modules/terser": {
"version": "5.36.0", "version": "5.37.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.36.0.tgz", "resolved": "https://registry.npmjs.org/terser/-/terser-5.37.0.tgz",
"integrity": "sha512-IYV9eNMuFAV4THUspIRXkLakHnV6XO7FEdtKjf/mDyrnqUg9LnlOn6/RwRvM9SZjR4GUq8Nk8zj67FzVARr74w==", "integrity": "sha512-B8wRRkmre4ERucLM/uXx4MOV5cbnOlVAqUst+1+iLKPI0dOgFO28f84ptoQt9HEI537PMzfYa/d+GEPKTRXmYA==",
"dev": true, "dev": true,
"license": "BSD-2-Clause",
"dependencies": { "dependencies": {
"@jridgewell/source-map": "^0.3.3", "@jridgewell/source-map": "^0.3.3",
"acorn": "^8.8.2", "acorn": "^8.8.2",
@@ -4597,9 +4592,9 @@
} }
}, },
"node_modules/vite-tsconfig-paths": { "node_modules/vite-tsconfig-paths": {
"version": "5.1.3", "version": "5.1.4",
"resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-5.1.3.tgz", "resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-5.1.4.tgz",
"integrity": "sha512-0bz+PDlLpGfP2CigeSKL9NFTF1KtXkeHGZSSaGQSuPZH77GhoiQaA8IjYgOaynSuwlDTolSUEU0ErVvju3NURg==", "integrity": "sha512-cYj0LRuLV2c2sMqhqhGpaO3LretdtMn/BVX4cPLanIZuwwrkVl+lK84E/miEXkCHWXuq65rhNN4rXsBcOB3S4w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"debug": "^4.1.1", "debug": "^4.1.1",
@@ -4751,15 +4746,16 @@
} }
}, },
"node_modules/youtubei.js": { "node_modules/youtubei.js": {
"version": "11.0.1", "version": "12.2.0",
"resolved": "https://registry.npmjs.org/youtubei.js/-/youtubei.js-11.0.1.tgz", "resolved": "https://registry.npmjs.org/youtubei.js/-/youtubei.js-12.2.0.tgz",
"integrity": "sha512-ZsbOd+5XF2Ofi3FrLMfYd+f9g9H8xswlouFhjhOqbwT68dMJtX6CRGsHNj5VTFCR/+L/865x1lnUlllB2dDDTA==", "integrity": "sha512-G+50qrbJCToMYhu8jbaHiS3Vf+RRul+CcDbz3hEGwHkGPh+zLiWwD6SS+YhYF+2/op4ZU5zDYQJrGqJ+wKh7Gw==",
"funding": [ "funding": [
"https://github.com/sponsors/LuanRT" "https://github.com/sponsors/LuanRT"
], ],
"license": "MIT",
"dependencies": { "dependencies": {
"@bufbuild/protobuf": "^2.0.0", "@bufbuild/protobuf": "^2.0.0",
"jintr": "^3.0.2", "jintr": "^3.2.0",
"tslib": "^2.5.0", "tslib": "^2.5.0",
"undici": "^5.19.1" "undici": "^5.19.1"
} }
+8 -8
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-web", "name": "playlet-web",
"version": "0.32.1", "version": "0.33.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
@@ -14,21 +14,21 @@
"@tsconfig/svelte": "^5.0.4", "@tsconfig/svelte": "^5.0.4",
"@vitejs/plugin-legacy": "^5.4.3", "@vitejs/plugin-legacy": "^5.4.3",
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.20",
"daisyui": "^4.12.14", "daisyui": "^4.12.22",
"dotenv": "^16.4.5", "dotenv": "^16.4.7",
"ip": "^2.0.1", "ip": "^2.0.1",
"postcss": "^8.4.49", "postcss": "^8.4.49",
"svelte": "4.2.19", "svelte": "4.2.19",
"svelte-check": "^4.1.0", "svelte-check": "^4.1.1",
"svelte-preprocess": "^6.0.3", "svelte-preprocess": "^6.0.3",
"tailwindcss": "^3.4.15", "tailwindcss": "^3.4.16",
"terser": "^5.36.0", "terser": "^5.37.0",
"tslib": "^2.8.1", "tslib": "^2.8.1",
"typescript": "^5.7.2", "typescript": "^5.7.2",
"vite": "^5.4.11", "vite": "^5.4.11",
"vite-tsconfig-paths": "^5.1.3" "vite-tsconfig-paths": "^5.1.4"
}, },
"dependencies": { "dependencies": {
"youtubei.js": "^11.0.1" "youtubei.js": "^12.2.0"
} }
} }
+20 -1
View File
@@ -15,6 +15,7 @@ type Validation = {
regex: string; regex: string;
regexFlags?: string; regexFlags?: string;
message: string; message: string;
regexObject: RegExp | undefined;
} }
export class ValidationPlugin implements CompilerPlugin { export class ValidationPlugin implements CompilerPlugin {
@@ -25,6 +26,11 @@ export class ValidationPlugin implements CompilerPlugin {
beforeProgramValidate(program: Program) { beforeProgramValidate(program: Program) {
// @ts-ignore // @ts-ignore
this.validation = program.options.validation as Validation[] | undefined; this.validation = program.options.validation as Validation[] | undefined;
if (this.validation) {
this.validation.forEach((validation) => {
validation.regexObject = new RegExp(validation.regex, validation.regexFlags);
});
}
} }
onFileValidate(event: OnFileValidateEvent<BscFile>) { onFileValidate(event: OnFileValidateEvent<BscFile>) {
@@ -34,14 +40,27 @@ export class ValidationPlugin implements CompilerPlugin {
return; return;
} }
let fileContentsLines: string[] | undefined = undefined;
this.validation.forEach((validation) => { this.validation.forEach((validation) => {
const regex = new RegExp(validation.regex, validation.regexFlags); const regex = validation.regexObject;
const fileContents = file.fileContents; const fileContents = file.fileContents;
let match: RegExpExecArray | null; let match: RegExpExecArray | null;
while ((match = regex.exec(fileContents)) !== null) { while ((match = regex.exec(fileContents)) !== null) {
if (!fileContentsLines) {
fileContentsLines = fileContents.split('\n');
}
const line = fileContents.substring(0, match.index).split('\n').length - 1; const line = fileContents.substring(0, match.index).split('\n').length - 1;
const column = match.index - fileContents.lastIndexOf('\n', match.index) - 1; const column = match.index - fileContents.lastIndexOf('\n', match.index) - 1;
const lineContent = fileContentsLines[line];
// Skip if the line is a comment
if (lineContent.trim().startsWith("'")) {
continue;
}
file.diagnostics.push({ file.diagnostics.push({
code: validation.code, code: validation.code,
message: validation.message, message: validation.message,