Compare commits

..
13 Commits
44 changed files with 171 additions and 84 deletions

No files matched your search

+20
View File
@@ -5,6 +5,26 @@ 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.44.3] - 2025-11-14
### Fixed
- Json parsing with invalid chars like `\u0000` preventing some channels from loading
## [0.44.2] - 2025-11-13
### Fixed
- Removed retry on trending feeds
## [0.44.1] - 2025-11-12
### Fixed
- Small change in post-live dvr detection
- Issue where recommended videos are all "UPCOMING" paid content
- Errors related to loading the trending feeds. Trending will be removed from Playlet in a future release.
## [0.44.0] - 2025-11-09 ## [0.44.0] - 2025-11-09
### Added ### Added
+6
View File
@@ -58,6 +58,12 @@
"regex": "\\bTr\\s*\\(\\s*\"[^\\\"]*\"\\s*\\)", "regex": "\\bTr\\s*\\(\\s*\"[^\\\"]*\"\\s*\\)",
"regexFlags": "ig", "regexFlags": "ig",
"message": "Tr(\"String\") is not allowed. Use Tr(Locale.Key) instead." "message": "Tr(\"String\") is not allowed. Use Tr(Locale.Key) instead."
},
{
"code": "NO_PARSE_JSON",
"regex": "\\s*ParseJson\\(",
"regexFlags": "ig",
"message": "ParseJson is not allowed. Use StringUtils.ParseJsonSafe() instead."
} }
], ],
"files": [ "files": [
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet", "name": "playlet",
"version": "0.44.0", "version": "0.44.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet", "name": "playlet",
"version": "0.44.0", "version": "0.44.3",
"hasInstallScript": true, "hasInstallScript": true,
"devDependencies": { "devDependencies": {
"@rokucommunity/bslint": "^0.8.38", "@rokucommunity/bslint": "^0.8.38",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet", "name": "playlet",
"version": "0.44.0", "version": "0.44.3",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"devDependencies": { "devDependencies": {
"@rokucommunity/bslint": "^0.8.38", "@rokucommunity/bslint": "^0.8.38",
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.44.0", "version": "0.44.3",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-app", "name": "playlet-app",
"version": "0.44.0" "version": "0.44.3"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.44.0", "version": "0.44.3",
"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",
@@ -37,6 +37,7 @@ function GetLoadingMessagesFromCache() as object
if messagesFile = "" if messagesFile = ""
return invalid return invalid
end if end if
' bs:disable-next-line NO_PARSE_JSON
return ParseJson(messagesFile) return ParseJson(messagesFile)
end function end function
+1 -1
View File
@@ -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=44 minor_version=44
build_version=00000 build_version=00003
ui_resolutions=hd ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p uri_resolution_autosub=$$RES$$,480p,720p,1080p
+1
View File
@@ -28,6 +28,7 @@ namespace Registry
if urlsJson = invalid if urlsJson = invalid
return invalid return invalid
end if end if
' bs:disable-next-line NO_PARSE_JSON
urls = ParseJson(urlsJson) urls = ParseJson(urlsJson)
return urls return urls
end function end function
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.44.0", "version": "0.44.3",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.44.0" "version": "0.44.3"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.44.0", "version": "0.44.3",
"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",
@@ -125,7 +125,7 @@ namespace DialogUtils
if hasMessageId if hasMessageId
messages = RegistryUtils.Read(RegistryUtils.MESSAGES) messages = RegistryUtils.Read(RegistryUtils.MESSAGES)
if not StringUtils.IsNullOrEmpty(messages) if not StringUtils.IsNullOrEmpty(messages)
messages = ParseJson(messages) messages = StringUtils.ParseJsonSafe(messages)
if IsAssociativeArray(messages) if IsAssociativeArray(messages)
savedMessageId = ValidString(messages["messageId"]) savedMessageId = ValidString(messages["messageId"])
if savedMessageId = messageId if savedMessageId = messageId
@@ -1,9 +1,10 @@
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
namespace HomeScreenUtils namespace HomeScreenUtils
function GetFeed(feedFileName as string, preferences as object) as object function GetFeed(feedFileName as string, preferences as object) as object
feed = ParseJson(ReadAsciiFile(feedFileName)) feed = StringUtils.ParseJsonSafe(ReadAsciiFile(feedFileName))
for each item in feed for each item in feed
item.title = Tr(item.title) item.title = Tr(item.title)
@@ -3,11 +3,12 @@ import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/MathUtils.bs" import "pkg:/source/utils/MathUtils.bs"
import "pkg:/source/utils/RemoteKeys.bs" import "pkg:/source/utils/RemoteKeys.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
m.homeLayout = {} m.homeLayout = {}
homeLayout = ParseJson(ReadAsciiFile("libpkg:/config/default_home_layout.yaml")) homeLayout = StringUtils.ParseJsonSafe(ReadAsciiFile("libpkg:/config/default_home_layout.yaml"))
for each item in homeLayout for each item in homeLayout
m.homeLayout[item.id] = item m.homeLayout[item.id] = item
end for end for
@@ -20,7 +20,7 @@ function Load() as void
end if end if
m.bookmarksString = bookmarksString m.bookmarksString = bookmarksString
bookmarks = ParseJson(bookmarksString) bookmarks = StringUtils.ParseJsonSafe(bookmarksString)
if bookmarks = invalid if bookmarks = invalid
LogWarn("Failed to parse bookmarks json") LogWarn("Failed to parse bookmarks json")
return return
@@ -82,6 +82,7 @@ class DashManifest
xml = new XmlObject() xml = new XmlObject()
xml.Comment(`Generated by Playlet - Video ID: ${metadata.videoId}`) xml.Comment(`Generated by Playlet - Video ID: ${metadata.videoId}`)
xml.Comment(`Parser: ${ValidString(metadata.parser)}`)
if xml.Node("MPD", { if xml.Node("MPD", {
"xmlns": "urn:mpeg:dash:schema:mpd:2011" "xmlns": "urn:mpeg:dash:schema:mpd:2011"
@@ -272,6 +272,7 @@ namespace InnertubeService
trendingType = LCase(OptionUtils.GetOrDefault(options, "type", "")) trendingType = LCase(OptionUtils.GetOrDefault(options, "type", ""))
disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false) disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
raw = OptionUtils.GetOrDefault(options, "raw", false) raw = OptionUtils.GetOrDefault(options, "raw", false)
browseId = "FEtrending"
params = "" params = ""
if trendingType = "music" if trendingType = "music"
@@ -285,7 +286,7 @@ namespace InnertubeService
params = "4gIKGgh0cmFpbGVycw%3D%3D" params = "4gIKGgh0cmFpbGVycw%3D%3D"
end if end if
request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, { params: params }) request = Innertube.CreateBrowseRequest(browseId, Innertube.ClientType.WEB, { params: params })
request.Cancellation(cancellation) request.Cancellation(cancellation)
if raw if raw
@@ -308,6 +309,7 @@ namespace InnertubeService
response: response response: response
disableCreatorOnTheRise: true disableCreatorOnTheRise: true
disableShorts: disableShorts disableShorts: disableShorts
browseId: browseId
}) })
result = { result = {
@@ -338,12 +340,12 @@ namespace InnertubeService
return GetBrowseAuthenticatedPage("FEplaylist_aggregation", options) return GetBrowseAuthenticatedPage("FEplaylist_aggregation", options)
end function end function
function GetBrowseAuthenticatedPage(browserId as string, options = invalid as object) as object function GetBrowseAuthenticatedPage(browseId as string, options = invalid as object) as object
cancellation = OptionUtils.Get(options, "cancellation") cancellation = OptionUtils.Get(options, "cancellation")
accessToken = OptionUtils.Get(options, "accessToken") accessToken = OptionUtils.Get(options, "accessToken")
disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false) disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
request = Innertube.CreateBrowseRequest(browserId, Innertube.ClientType.Tv, options) request = Innertube.CreateBrowseRequest(browseId, Innertube.ClientType.Tv, options)
if accessToken <> invalid if accessToken <> invalid
request.Header("Authorization", "Bearer " + accessToken) request.Header("Authorization", "Bearer " + accessToken)
@@ -360,6 +362,7 @@ namespace InnertubeService
feeds = Innertube.ParseResponseDataForFeeds(response.Json(), { feeds = Innertube.ParseResponseDataForFeeds(response.Json(), {
response: response response: response
disableShorts: disableShorts disableShorts: disableShorts
browseId: browseId
}) })
result = { result = {
@@ -521,7 +524,7 @@ namespace InnertubeService
return response.Json() return response.Json()
end if end if
result = Innertube.ParseChannelPageResponseData(response.Json(), response) result = Innertube.ParseChannelPageResponseData(channelId, response.Json(), response)
if result.authorId = invalid and result.error = invalid if result.authorId = invalid and result.error = invalid
result["authorId"] = channelId result["authorId"] = channelId
end if end if
@@ -663,7 +666,7 @@ namespace InnertubeService
return response.Json() return response.Json()
end if end if
result = Innertube.ParsePlaylistPageResponseData(response.Json(), response) result = Innertube.ParsePlaylistPageResponseData(playlistId, response.Json(), response)
if result.playlistId = invalid and result.error = invalid if result.playlistId = invalid and result.error = invalid
result["playlistId"] = playlistId result["playlistId"] = playlistId
@@ -276,6 +276,17 @@ namespace Innertube
end if end if
end if end if
if ValidString(context.browseId) = "FEwhat_to_watch"
' shelfs with a heroCarouselHeaderRenderer are usually big carousels at the top of the home page
' to advertise some paid content.
' They hijack the shelf we want to parse (e.g. Recommended videos).
heroCarouselHeader = ObjectUtils.Dig(nodeData, ["headerRenderer", "heroCarouselHeaderRenderer"])
if heroCarouselHeader <> invalid
LogInfo("Skipping shelf with heroCarouselHeaderRenderer")
return invalid
end if
end if
' TODO: handle shelfRenderer.title ' TODO: handle shelfRenderer.title
' TODO: handle shelfRenderer.headerRenderer.shelfHeaderRenderer.avatarLockup.avatarLockupRenderer.title ' TODO: handle shelfRenderer.headerRenderer.shelfHeaderRenderer.avatarLockup.avatarLockupRenderer.title
return nodeData["content"] return nodeData["content"]
@@ -1926,6 +1937,8 @@ namespace Innertube
function ParseCompactMovieRenderer(nodeData as object, context as object) as object function ParseCompactMovieRenderer(nodeData as object, context as object) as object
videoId = nodeData["videoId"] videoId = nodeData["videoId"]
if not IsString(videoId) if not IsString(videoId)
' TODO:P2 Can be a show, example
' {"badges":[{"metadataBadgeRenderer":{"accessibilityData":{"label":"Free with ads"},"label":"Free with ads","style":"BADGE_STYLE_TYPE_YPC","trackingParams":"CKQBEJaLARgJIhMI15bJgdLnkAMVoHtMCB0nGTYG"}},{"metadataBadgeRenderer":{"accessibilityData":{"label":"tv-g"},"label":"TV-G","style":"BADGE_STYLE_TYPE_MEDIA","trackingParams":"CKQBEJaLARgJIhMI15bJgdLnkAMVoHtMCB0nGTYG"}}],"navigationEndpoint":{"browseEndpoint":{"browseId":"SCLKZr4NmdhyFZXLCYhehRmg","params":"kgYcGhoSGFVDTEtacjRObWRoeUZaWExDWWhlaFJtZw%3D%3D"},"clickTrackingParams":"CKQBEJaLARgJIhMI15bJgdLnkAMVoHtMCB0nGTYGygEEl7wVRg==","commandMetadata":{"webCommandMetadata":{"apiUrl":"/youtubei/v1/browse","rootVe":6827,"url":"/show/SCLKZr4NmdhyFZXLCYhehRmg?sbp=GhoSGFVDTEtacjRObWRoeUZaWExDWWhlaFJtZw%253D%253D","webPageType":"WEB_PAGE_TYPE_BROWSE"}}},"thumbnail":{"thumbnails":[{"height":596,"url":"https://yt3.ggpht.com/KPRERPv8FmjHUtaEip00aL1RuIkU-0_YR4XrbzG_66s6kkm1sx9MtSJgzeYexpRVtXoN1P1OjQ=w1060-fcrop64=1,00000000ffffffff-k-c0xffffffff-no-nd-rj","width":1060}]},"thumbnailOverlays":[{"thumbnailOverlayBottomPanelRenderer":{"text":{"runs":[{"text":"4"},{"text":" seasons"}]}}}],"title":{"accessibility":{"accessibilityData":{"label":"Everything's Rosie 4 seasons"}},"simpleText":"Everything's Rosie"},"topMetadataItems":[{"simpleText":"Animation \u2022 2011"}],"trackingParams":"CKQBEJaLARgJIhMI15bJgdLnkAMVoHtMCB0nGTYG"}
Warning("Invalid videoId in compactMovieRenderer", nodeData, context) Warning("Invalid videoId in compactMovieRenderer", nodeData, context)
return invalid return invalid
end if end if
@@ -44,7 +44,7 @@ namespace Innertube
return context.feeds return context.feeds
end function end function
function ParseChannelPageResponseData(responseData as object, response as object) as object function ParseChannelPageResponseData(browseId as string, responseData as object, response as object) as object
if responseData = invalid if responseData = invalid
return { return {
error: "Invalid response data" error: "Invalid response data"
@@ -63,6 +63,9 @@ namespace Innertube
author = ObjectUtils.Dig(responseData, ["header", "pageHeaderRenderer", "pageTitle"]) author = ObjectUtils.Dig(responseData, ["header", "pageHeaderRenderer", "pageTitle"])
end if end if
authorId = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "externalId"]) authorId = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "externalId"])
if StringUtils.IsNullOrEmpty(authorId)
authorId = browseId
end if
thumbnails = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "avatar", "thumbnails"]) thumbnails = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "avatar", "thumbnails"])
if thumbnails = invalid if thumbnails = invalid
@@ -149,6 +152,7 @@ namespace Innertube
response: response response: response
"currentAuthor": author "currentAuthor": author
"currentAuthorId": authorId "currentAuthorId": authorId
browseId: browseId
}) })
if feeds.Count() > 0 if feeds.Count() > 0
items = ValidArray(feeds[0].items) items = ValidArray(feeds[0].items)
@@ -183,7 +187,7 @@ namespace Innertube
return channel return channel
end function end function
function ParsePlaylistPageResponseData(responseData as object, response as object) as object function ParsePlaylistPageResponseData(browseId as string, responseData as object, response as object) as object
if responseData = invalid if responseData = invalid
return { return {
error: "Invalid response data" error: "Invalid response data"
@@ -251,13 +255,16 @@ namespace Innertube
end if end if
end if end if
if StringUtils.IsNullOrEmpty(playlistId)
playlistId = browseId
end if
playlist = { playlist = {
"playlistId": playlistId
"videoCount": videoCount "videoCount": videoCount
"videos": [] "videos": []
} }
if playlistId <> invalid
playlist["playlistId"] = playlistId
end if
if title <> invalid if title <> invalid
playlist["title"] = title playlist["title"] = title
end if end if
@@ -279,6 +286,7 @@ namespace Innertube
feeds = ParseResponseDataForFeeds(responseData, { feeds = ParseResponseDataForFeeds(responseData, {
response: response response: response
browseId: browseId
}) })
if feeds.Count() > 0 if feeds.Count() > 0
playlist["videos"] = ValidArray(feeds[0].items) playlist["videos"] = ValidArray(feeds[0].items)
@@ -122,6 +122,7 @@ namespace Innertube
formats = TransformFormats(formats) formats = TransformFormats(formats)
parsedResponse["type"] = "video" parsedResponse["type"] = "video"
parsedResponse["parser"] = "playlet"
parsedResponse["videoId"] = videoDetails["videoId"] parsedResponse["videoId"] = videoDetails["videoId"]
parsedResponse["videoThumbnails"] = videoDetails["thumbnail"]["thumbnails"] parsedResponse["videoThumbnails"] = videoDetails["thumbnail"]["thumbnails"]
parsedResponse["storyboards"] = ParseStoryboards(payload, lengthSeconds) parsedResponse["storyboards"] = ParseStoryboards(payload, lengthSeconds)
@@ -453,7 +454,7 @@ namespace Innertube
LogDebug(`ReadAsciiFile("tmp:/sts_cache.json")`) LogDebug(`ReadAsciiFile("tmp:/sts_cache.json")`)
cache = ReadAsciiFile("tmp:/sts_cache.json") cache = ReadAsciiFile("tmp:/sts_cache.json")
if not StringUtils.IsNullOrEmpty(cache) if not StringUtils.IsNullOrEmpty(cache)
json = ParseJson(cache) json = StringUtils.ParseJsonSafe(cache)
return json["sts"] return json["sts"]
end if end if
@@ -649,6 +650,10 @@ namespace Innertube
return true return true
end if end if
if ValidBool(ObjectUtils.Dig(payload, ["videoDetails", "isPostLiveDvr"]))
return false
end if
adaptiveFormats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"])) adaptiveFormats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"]))
if FormatsHaveLiveStreamingData(adaptiveFormats) if FormatsHaveLiveStreamingData(adaptiveFormats)
return true return true
@@ -733,7 +738,7 @@ namespace Innertube
LogTelemetryEvent({ LogTelemetryEvent({
level: "error" level: "error"
message: msg + `\nVideoID: ${parsedResponse["videoId"]}\nUrl: ${url}\nHeaders: ${FormatJson(headers)}` message: msg + `\nVideoID: ${parsedResponse["videoId"]}\nUrl: ${url}\nHeaders: ${FormatJson(headers)}`
fingerprint: ["GetPostLiveDvrInfo Missing Post-Live DVR info in headers"] fingerprint: [msg]
}) })
end if end if
@@ -87,7 +87,7 @@ namespace Innertube
text = response.Text() text = response.Text()
text = text.Replace(`)]}'`, "") text = text.Replace(`)]}'`, "")
parsed = ParseJson(text) parsed = StringUtils.ParseJsonSafe(text)
if not IsArray(parsed) or parsed.Count() < 2 if not IsArray(parsed) or parsed.Count() < 2
return { return {
error: "Failed to parse search suggestions" error: "Failed to parse search suggestions"
@@ -46,7 +46,7 @@ namespace Innertube
text = response.Text() text = response.Text()
text = text.Replace(`)]}'`, "") text = text.Replace(`)]}'`, "")
json = ParseJson(text) json = StringUtils.ParseJsonSafe(text)
if json = invalid if json = invalid
return { return {
"error": "Failed to parse session data: " + text "error": "Failed to parse session data: " + text
@@ -78,7 +78,7 @@ namespace Innertube
return invalid return invalid
end if end if
sessionData = ParseJson(sessionData) sessionData = StringUtils.ParseJsonSafe(sessionData)
if sessionData = invalid if sessionData = invalid
RegistryUtils.Delete(RegistryUtils.INNERTUBE_SESSION_DATA) RegistryUtils.Delete(RegistryUtils.INNERTUBE_SESSION_DATA)
return invalid return invalid
@@ -1,7 +1,7 @@
import "InvidiousService.bs" import "InvidiousService.bs"
function Init() function Init()
m.top.apiDefinitions = ParseJson(ReadAsciiFile("libpkg:/config/invidious_video_api.yaml")) m.top.apiDefinitions = StringUtils.ParseJsonSafe(ReadAsciiFile("libpkg:/config/invidious_video_api.yaml"))
m.service = new Invidious.InvidiousService(m.top) m.service = new Invidious.InvidiousService(m.top)
end function end function
@@ -698,7 +698,7 @@ namespace Invidious
end function end function
function VerifyTokenScope(token as string) as boolean function VerifyTokenScope(token as string) as boolean
tokenObject = ParseJson(token) tokenObject = StringUtils.ParseJsonSafe(token)
if tokenObject = invalid if tokenObject = invalid
LogWarn("Failed to json parse token:", token) LogWarn("Failed to json parse token:", token)
return false return false
@@ -212,7 +212,7 @@ class LoungeApi
text = text.Mid(text.instr(`\n`) + 1) text = text.Mid(text.instr(`\n`) + 1)
messagesToSend = [] messagesToSend = []
commands = ParseJson(text) commands = StringUtils.ParseJsonSafe(text)
m.ProcessCommands(commands, messagesToSend) m.ProcessCommands(commands, messagesToSend)
m.SendMessages(messagesToSend) m.SendMessages(messagesToSend)
return true return true
@@ -268,7 +268,7 @@ class LoungeApi
payloadSize = chunk.Left(newLineIndex).trim() payloadSize = chunk.Left(newLineIndex).trim()
payloadSize = payloadSize.ToInt() payloadSize = payloadSize.ToInt()
payload = chunk.Mid(newLineIndex + 1, payloadSize) payload = chunk.Mid(newLineIndex + 1, payloadSize)
commands = ParseJson(payload) commands = StringUtils.ParseJsonSafe(payload)
m.ProcessCommands(commands, messagesToSend) m.ProcessCommands(commands, messagesToSend)
chunk = chunk.Mid(newLineIndex + payloadSize + 1) chunk = chunk.Mid(newLineIndex + payloadSize + 1)
newLineIndex = chunk.InStr(`\n`) newLineIndex = chunk.InStr(`\n`)
@@ -376,7 +376,7 @@ class LoungeApi
if not IsString(devices) if not IsString(devices)
return return
end if end if
devices = ParseJson(devices) devices = StringUtils.ParseJsonSafe(devices)
if devices = invalid if devices = invalid
return return
end if end if
@@ -618,7 +618,7 @@ class LoungeApi
RegistryUtils.Delete(RegistryUtils.LAST_LOUNGE_DATA) RegistryUtils.Delete(RegistryUtils.LAST_LOUNGE_DATA)
loungeData = ParseJson(loungeData) loungeData = StringUtils.ParseJsonSafe(loungeData)
if not IsAssociativeArray(loungeData) if not IsAssociativeArray(loungeData)
LogWarn("Can't disconnect from lounge. Invalid data:", loungeData) LogWarn("Can't disconnect from lounge. Invalid data:", loungeData)
return return
@@ -86,7 +86,7 @@ namespace LoungeVideoQueue
' - eventDetails is of the form {"eventType":"VIDEO_REMOVED","videoId":"<videoId>"} ' - eventDetails is of the form {"eventType":"VIDEO_REMOVED","videoId":"<videoId>"}
eventDetails = playlistData[FIELD_EVENT_DETAILS] eventDetails = playlistData[FIELD_EVENT_DETAILS]
if IsString(eventDetails) if IsString(eventDetails)
eventDetails = ParseJson(eventDetails) eventDetails = StringUtils.ParseJsonSafe(eventDetails)
end if end if
if eventDetails <> invalid and eventDetails["eventType"] = "VIDEO_ADDED" if eventDetails <> invalid and eventDetails["eventType"] = "VIDEO_ADDED"
eventVideoId = eventDetails[FIELD_VIDEO_ID] eventVideoId = eventDetails[FIELD_VIDEO_ID]
@@ -21,7 +21,7 @@ function Init()
end function end function
function LoadPreferencesFile() function LoadPreferencesFile()
m.top.prefsModel = ParseJson(ReadAsciiFile("libpkg:/config/preferences.json5")) m.top.prefsModel = StringUtils.ParseJsonSafe(ReadAsciiFile("libpkg:/config/preferences.json5"))
end function end function
function AddNodeFields() function AddNodeFields()
@@ -60,7 +60,7 @@ function LoadUserPreferencesFromRegistry()
if userPrefs = invalid if userPrefs = invalid
userPrefs = {} userPrefs = {}
else else
userPrefs = ParseJson(userPrefs) userPrefs = StringUtils.ParseJsonSafe(userPrefs)
end if end if
' Step 2: Migrate existing preferences to new format (if needed) ' Step 2: Migrate existing preferences to new format (if needed)
@@ -101,7 +101,7 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
if not StringUtils.IsNullOrEmpty(instances) if not StringUtils.IsNullOrEmpty(instances)
currentInstance = userPrefs["invidious.instance"] currentInstance = userPrefs["invidious.instance"]
if StringUtils.IsNullOrEmpty(currentInstance) if StringUtils.IsNullOrEmpty(currentInstance)
instances = ParseJson(instances) instances = StringUtils.ParseJsonSafe(instances)
if IsArray(instances) and instances.Count() > 0 if IsArray(instances) and instances.Count() > 0
instance = instances[0] instance = instances[0]
if not StringUtils.IsNullOrEmpty(instance) if not StringUtils.IsNullOrEmpty(instance)
@@ -31,7 +31,7 @@ function LoadProfilesFromRegistry()
currentProfile: invalid currentProfile: invalid
} }
else else
userProfiles = ParseJson(userProfiles) userProfiles = StringUtils.ParseJsonSafe(userProfiles)
end if end if
' Step 2: Migrate existing profiles to new format (if needed) ' Step 2: Migrate existing profiles to new format (if needed)
@@ -98,7 +98,7 @@ function MigrateExistingProfiles(userProfiles as object) as boolean
return false return false
end if end if
authToken = ParseJson(tokenPayload) authToken = StringUtils.ParseJsonSafe(tokenPayload)
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN) RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
if authToken = invalid or authToken.instance = invalid or authToken.token = invalid or authToken.username = invalid if authToken = invalid or authToken.instance = invalid or authToken.token = invalid or authToken.username = invalid
@@ -55,7 +55,7 @@ namespace SearchHistoryUtils
return [] return []
end if end if
history = ParseJson(history) history = StringUtils.ParseJsonSafe(history)
if not IsArray(history) if not IsArray(history)
return [] return []
end if end if
@@ -9,7 +9,7 @@ namespace SponsorBlock
class SponsorBlockService class SponsorBlockService
function new() function new()
' TODO:P2 this is being read and parsed on every skipped segment. It should be cached. ' TODO:P2 this is being read and parsed on every skipped segment. It should be cached.
m.sponsorBlockConfig = ParseJson(ReadAsciiFile("libpkg:/config/sponsorblock_config.json5")) m.sponsorBlockConfig = StringUtils.ParseJsonSafe(ReadAsciiFile("libpkg:/config/sponsorblock_config.json5"))
end function end function
function GetCategories() as object function GetCategories() as object
@@ -65,31 +65,9 @@ function ExecuteJob() as void
}) })
if not response.success if not response.success
if response.error = Invidious.ERROR_NOT_AUTHENTICATED if RemoveSingleFailedRow(response.error, feedSource, feedSources, feedContentNode)
if feedSources.Count() = 1 JobSuccess()
parent = feedContentNode.getParent() return
if parent <> invalid
parent.removeChild(feedContentNode)
end if
JobSuccess()
return
end if
continue while
end if
if response.error.instr("Administrator has disabled this endpoint.") > -1
LogWarnNoTelemetry(feedSource.endpoint, "feedSource not available:", response.error)
if feedSources.Count() = 1
parent = feedContentNode.getParent()
if parent <> invalid
parent.removeChild(feedContentNode)
end if
JobSuccess()
return
end if
continue while
end if end if
feedSource.state.loadState = FeedLoadState.Error feedSource.state.loadState = FeedLoadState.Error
@@ -243,6 +221,31 @@ function DeduplicateAppendAuthPlaylists(feedContentNode as object, itemNodes as
return nodesToAdd.Count() return nodesToAdd.Count()
end function end function
function RemoveSingleFailedRow(error as dynamic, feedSource as object, feedSources as object, feedContentNode as object) as boolean
error = ValidString(error)
LogWarnNoTelemetry(feedSource.id, "feedSource not available:", error)
if feedSources.Count() <> 1
return false
end if
isError = error = Invidious.ERROR_NOT_AUTHENTICATED
isError = isError or error.instr("Administrator has disabled this endpoint") <> -1
isError = isError or error.instr("API disabled") <> -1
isError = isError or feedSource.id.instr("inv_trending") <> -1
isError = isError or feedSource.id.instr("inv_popular") <> -1
if not isError
return false
end if
parent = feedContentNode.getParent()
if parent <> invalid
parent.removeChild(feedContentNode)
end if
return true
end function
function HandleFeedLoadErrorDialog(error as object, isCancelled as boolean, rowList as object) as void function HandleFeedLoadErrorDialog(error as object, isCancelled as boolean, rowList as object) as void
error = ErrorUtils.Format(error) error = ErrorUtils.Format(error)
if isCancelled if isCancelled
@@ -341,7 +341,7 @@ function SetCaptions(metadata as object, service as object, contentNode as objec
return return
end if end if
isoLanguageList = ParseJson(ReadAsciiFile("libpkg:/config/ISO-639-1-to-ISO-639-2T.json5")) isoLanguageList = StringUtils.ParseJsonSafe(ReadAsciiFile("libpkg:/config/ISO-639-1-to-ISO-639-2T.json5"))
instance = service.GetInstance() instance = service.GetInstance()
subtitleTracks = [] subtitleTracks = []
@@ -13,6 +13,18 @@ import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RemoteKeys.bs" import "pkg:/source/utils/RemoteKeys.bs"
enum DownloadErrors
Unknown = 900
TimeoutByCurl = 950
TimeoutBySelector = 951
Abort = 960
AbortByServer = 961
AbortBySelector = 962
AbortByParallel = 963
ParallelFragmentError = 964
BadMedia = 970
end enum
function Init() function Init()
SetPlayerStyle() SetPlayerStyle()
SetupAnimation() SetupAnimation()
@@ -66,7 +66,7 @@ namespace Http
return true return true
end if end if
feedSource = ParseJson(feedSource) feedSource = StringUtils.ParseJsonSafe(feedSource)
if feedSource = invalid if feedSource = invalid
response.Default(400, "Expected valid JSON for feed-source") response.Default(400, "Expected valid JSON for feed-source")
return true return true
@@ -804,7 +804,7 @@ namespace Http
' (such as "newest", "oldest", etc.), we'll ignore it, as it is not supported. ' (such as "newest", "oldest", etc.), we'll ignore it, as it is not supported.
sortBy = request.query.sort_by sortBy = request.query.sort_by
if not StringUtils.IsNullOrEmpty(sortBy) and sortBy.StartsWith("{") if not StringUtils.IsNullOrEmpty(sortBy) and sortBy.StartsWith("{")
sortBy = ParseJson(sortBy) sortBy = StringUtils.ParseJsonSafe(sortBy)
if IsAssociativeArray(sortBy) if IsAssociativeArray(sortBy)
if sortBy.DoesExist("params") if sortBy.DoesExist("params")
options.params = sortBy.params options.params = sortBy.params
@@ -19,7 +19,7 @@ namespace Http
saved = RegistryUtils.Read(RegistryUtils.PLAYLET_LIB_URLS) saved = RegistryUtils.Read(RegistryUtils.PLAYLET_LIB_URLS)
if saved <> invalid if saved <> invalid
saved = ParseJson(saved) saved = StringUtils.ParseJsonSafe(saved)
end if end if
response.Json({ response.Json({
@@ -272,7 +272,7 @@ namespace Http
return invalid return invalid
end if end if
m.body_json = ParseJson(text) m.body_json = StringUtils.ParseJsonSafe(text)
return m.body_json return m.body_json
end function end function
end class end class
@@ -11,7 +11,7 @@ namespace Http
if StringUtils.IsNullOrEmpty(json) if StringUtils.IsNullOrEmpty(json)
return "application/octet-stream" return "application/octet-stream"
end if end if
map = ParseJson(json) map = StringUtils.ParseJsonSafe(json)
if not IsAssociativeArray(map) if not IsAssociativeArray(map)
return "application/octet-stream" return "application/octet-stream"
end if end if
@@ -41,7 +41,7 @@ namespace Http
if StringUtils.IsNullOrEmpty(json) if StringUtils.IsNullOrEmpty(json)
return "" return ""
end if end if
map = ParseJson(json) map = StringUtils.ParseJsonSafe(json)
if not IsAssociativeArray(map) if not IsAssociativeArray(map)
return "" return ""
end if end if
@@ -11,7 +11,6 @@ trending:
region: region:
type: "#ISO3166" type: "#ISO3166"
default: GetUserCountryCode default: GetUserCountryCode
tryCount: 3 # trending is being phased out, sometimes it returns a 400 INVALID_ARGUMENT
popular: popular:
title: Popular title: Popular
+1 -1
View File
@@ -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=44 minor_version=44
build_version=00000 build_version=00003
ui_resolutions=hd ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p uri_resolution_autosub=$$RES$$,480p,720p,1080p
@@ -454,7 +454,7 @@ namespace HttpClient
backoffMs = 1000 + Rnd(2000) backoffMs = 1000 + Rnd(2000)
tryNumber = m._tryCount - triesLeft + 1 tryNumber = m._tryCount - triesLeft + 1
LogWarnNoTelemetry("Request failed ID:", m.urlTransfer.GetIdentity(), "ErrorMessage:", response.ErrorMessage(), `\nRetrying: (`, tryNumber, "/", m._tryCount, ") in", backoffMs, "ms") LogWarnNoTelemetry("Request failed ID:", m.urlTransfer.GetIdentity(), "ErrorMessage:", response.ErrorMessage(), `\nRetrying: (`, tryNumber, "/", m._tryCount, ") in", backoffMs, "ms")
LogWarnTelemetry(response.ErrorMessage()) LogWarnTelemetry(response.ErrorMessage() + `\n` + m.ToCurlCommand())
if IsFunction(m._retryCallback) if IsFunction(m._retryCallback)
try try
@@ -703,7 +703,7 @@ namespace HttpClient
if text = invalid if text = invalid
return invalid return invalid
end if end if
m._json = ParseJson(text) m._json = StringUtils.ParseJsonSafe(text)
return m._json return m._json
end function end function
@@ -813,7 +813,7 @@ namespace HttpClientCache
end if end if
metadataText = cacheText.Left(firstLineIndex) metadataText = cacheText.Left(firstLineIndex)
metadata = ParseJson(metadataText) metadata = StringUtils.ParseJsonSafe(metadataText)
if metadata = invalid if metadata = invalid
LogWarn("Failed to parse metadata from cache.") LogWarn("Failed to parse metadata from cache.")
Delete(request) Delete(request)
@@ -821,7 +821,7 @@ namespace HttpClientCache
end if end if
headersText = cacheText.Mid(firstLineIndex + 1, metadata.headers) headersText = cacheText.Mid(firstLineIndex + 1, metadata.headers)
headers = ParseJson(headersText) headers = StringUtils.ParseJsonSafe(headersText)
if headers = invalid if headers = invalid
LogWarn("Failed to parse headers from cache.") LogWarn("Failed to parse headers from cache.")
Delete(request) Delete(request)
@@ -29,5 +29,18 @@ namespace StringUtils
function RandomId() as string function RandomId() as string
return StrI(rnd(2147483647), 36) return StrI(rnd(2147483647), 36)
end function end function
function ParseJsonSafe(jsonString as dynamic) as dynamic
if IsNullOrEmpty(jsonString)
return invalid
end if
' bs:disable-next-line NO_PARSE_JSON
json = ParseJson(jsonString)
if json <> invalid
return json
end if
' bs:disable-next-line NO_PARSE_JSON
return ParseJson(jsonString.Replace("\u0000", ""))
end function
end namespace end namespace
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-web", "name": "playlet-web",
"version": "0.44.0", "version": "0.44.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-web", "name": "playlet-web",
"version": "0.44.0", "version": "0.44.3",
"devDependencies": { "devDependencies": {
"@sveltejs/vite-plugin-svelte": "^6.2.1", "@sveltejs/vite-plugin-svelte": "^6.2.1",
"@tailwindcss/postcss": "^4.1.17", "@tailwindcss/postcss": "^4.1.17",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-web", "name": "playlet-web",
"version": "0.44.0", "version": "0.44.3",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",