diff --git a/CHANGELOG.md b/CHANGELOG.md
index d26893de..9bfa2a45 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,8 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Built-in Playlet backend, which supports channels, playlists, and search
- - This backend is not finished, and provides the bare minimum to watch videos.
- - More features to come.
+ - This backend is experimental, and has a few missing features.
+ - To use it, set the Invidious instance to an empty string.
### Fixed
diff --git a/playlet-lib/src/components/ChannelView/ChannelView.bs b/playlet-lib/src/components/ChannelView/ChannelView.bs
index 72d8612c..39e45da4 100644
--- a/playlet-lib/src/components/ChannelView/ChannelView.bs
+++ b/playlet-lib/src/components/ChannelView/ChannelView.bs
@@ -66,7 +66,13 @@ function OnContentSet() as void
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.authorLabel.text = content._author
- m.subCountLabel.text = content.subCountText
+
+ subCountText = content.authorSubTitle
+ if StringUtils.IsNullOrEmpty(subCountText)
+ subCountText = content.subCountText
+ end if
+ m.subCountLabel.text = subCountText
+
m.banner.uri = content.banner
if StringUtils.IsNullOrEmpty(content.thumbnail)
m.thumbnail.uri = ""
diff --git a/playlet-lib/src/components/ContentNode/ChannelContentNode.xml b/playlet-lib/src/components/ContentNode/ChannelContentNode.xml
index ac6ffc8a..ec1e7474 100644
--- a/playlet-lib/src/components/ContentNode/ChannelContentNode.xml
+++ b/playlet-lib/src/components/ContentNode/ChannelContentNode.xml
@@ -10,6 +10,7 @@
+
diff --git a/playlet-lib/src/components/ContentNode/PlaylistContentNode.xml b/playlet-lib/src/components/ContentNode/PlaylistContentNode.xml
index eb1904a6..3aade21b 100644
--- a/playlet-lib/src/components/ContentNode/PlaylistContentNode.xml
+++ b/playlet-lib/src/components/ContentNode/PlaylistContentNode.xml
@@ -39,5 +39,6 @@
+
\ No newline at end of file
diff --git a/playlet-lib/src/components/MainScene.bs b/playlet-lib/src/components/MainScene.bs
index c49731db..2a6a9fa3 100644
--- a/playlet-lib/src/components/MainScene.bs
+++ b/playlet-lib/src/components/MainScene.bs
@@ -2,6 +2,7 @@ import "pkg:/components/EcpArgs.bs"
import "pkg:/components/parts/AutoBind/AutoBind.part.bs"
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/source/utils/LoadingScreen.bs"
+import "pkg:/source/utils/Locale.bs"
function Init()
m.scene = m.top.getScene()
@@ -18,6 +19,7 @@ function MainSceneContainerChanged()
InitEcpArgs()
m.scene.signalBeacon("AppLaunchComplete")
CopyLoadingMessagesToCache()
+ ShowAnnouncement()
end function
function StartWebServer()
@@ -30,3 +32,24 @@ function StartWebServer()
m.dialServer = m.top.findNode("DialServer")
m.dialServer@.StartServer()
end function
+
+function ShowAnnouncement()
+ title = "Announcement - Playlet backend"
+ message = [
+ "An experimental built-in backend has been added to Playlet."
+ "This allows you to access YouTube content without the need for an Invidious instance."
+ "To use it, go to the Settings > Invidious > Instance and set the field to empty (Edit, and delete the url)."
+ "Please note that it's missing some features and may not work as expected."
+ "Thank you for using Playlet!"
+ ]
+
+ buttons = [Tr(Locale.Buttons.OK)]
+ dialog = CreateObject("roSGNode", "SimpleDialog")
+ dialog.title = title
+ dialog.message = message
+ dialog.buttons = buttons
+ deviceInfo = CreateObject("roDeviceInfo")
+ displaySize = deviceInfo.GetDisplaySize()
+ dialog.width = displaySize.w - 180
+ m.top.getScene().dialog = dialog
+end function
diff --git a/playlet-lib/src/components/MainScene.transpiled.brs b/playlet-lib/src/components/MainScene.transpiled.brs
index 3cf9c0f9..52b116f5 100644
--- a/playlet-lib/src/components/MainScene.transpiled.brs
+++ b/playlet-lib/src/components/MainScene.transpiled.brs
@@ -2,6 +2,7 @@
'import "pkg:/components/parts/AutoBind/AutoBind.part.bs"
'import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
'import "pkg:/source/utils/LoadingScreen.bs"
+'import "pkg:/source/utils/Locale.bs"
function Init()
InitializeBindings() ' auto-generated!
@@ -19,6 +20,7 @@ function MainSceneContainerChanged()
InitEcpArgs()
m.scene.signalBeacon("AppLaunchComplete")
CopyLoadingMessagesToCache()
+ ShowAnnouncement()
end function
function StartWebServer()
@@ -29,4 +31,26 @@ function StartWebServer()
m.dialServer = m.top.findNode("DialServer")
m.dialServer.callfunc("StartServer", invalid)
end function
+
+function ShowAnnouncement()
+ title = "Announcement - Playlet backend"
+ message = [
+ "An experimental built-in backend has been added to Playlet."
+ "This allows you to access YouTube content without the need for an Invidious instance."
+ "To use it, go to the Settings > Invidious > Instance and set the field to empty (Edit, and delete the url)."
+ "Please note that it's missing some features and may not work as expected."
+ "Thank you for using Playlet!"
+ ]
+ buttons = [
+ Tr("OK")
+ ]
+ dialog = CreateObject("roSGNode", "SimpleDialog")
+ dialog.title = title
+ dialog.message = message
+ dialog.buttons = buttons
+ deviceInfo = CreateObject("roDeviceInfo")
+ displaySize = deviceInfo.GetDisplaySize()
+ dialog.width = displaySize.w - 180
+ m.top.getScene().dialog = dialog
+end function
'//# sourceMappingURL=./MainScene.brs.map
\ No newline at end of file
diff --git a/playlet-lib/src/components/PlaylistView/PlaylistView.bs b/playlet-lib/src/components/PlaylistView/PlaylistView.bs
index b4c308b0..b7db1754 100644
--- a/playlet-lib/src/components/PlaylistView/PlaylistView.bs
+++ b/playlet-lib/src/components/PlaylistView/PlaylistView.bs
@@ -46,8 +46,13 @@ function OnContentSet() as void
if content.playlistId.StartsWith("RD")
m.subtitleLabel.text = ""
else
- ' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
- m.subtitleLabel.text = `${content._author} • ${content.videoCountText} • ${content.viewCountText}`
+ statsText = content.statsText
+ if statsText.Len() > 0
+ m.subtitleLabel.text = statsText
+ else
+ ' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
+ m.subtitleLabel.text = `${content._author} • ${content.videoCountText} • ${content.viewCountText}`
+ end if
end if
m.updatedLabel.text = content.updatedText
m.descriptionLabel.text = content.description
diff --git a/playlet-lib/src/components/Services/Innertube/NodesParser.bs b/playlet-lib/src/components/Services/Innertube/NodesParser.bs
index 9f4d934c..0107394d 100644
--- a/playlet-lib/src/components/Services/Innertube/NodesParser.bs
+++ b/playlet-lib/src/components/Services/Innertube/NodesParser.bs
@@ -47,6 +47,7 @@ namespace Innertube
"playlistVideoRenderer": ParsePlaylistVideoRenderer
"channelRenderer": ParseChannelRenderer
"gridChannelRenderer": ParseGridChannelRenderer
+ "playlistRenderer": ParsePlaylistRenderer
"lockupViewModel": ParseLockupViewModel
"shortsLockupViewModel": ParseShortsLockupViewModel
"tvBrowseRenderer": ParseTvBrowseRenderer
@@ -135,6 +136,32 @@ namespace Innertube
return invalid
end if
+ author = invalid
+ authorId = invalid
+ authorPossibleNodes = ["ownerText", "shortBylineText", "longBylineText"]
+ for each authorPossibleNode in authorPossibleNodes
+ node = nodeData[authorPossibleNode]
+ author = ParseText(node)
+ authorId = ObjectUtils.Dig(node, ["runs", 0, "navigationEndpoint", "browseEndpoint", "browseId"])
+ if author <> "" and authorId <> invalid
+ exit for
+ end if
+ end for
+ if StringUtils.IsNullOrEmpty(author) and StringUtils.IsNullOrEmpty(authorId)
+ if IsString(context.currentAuthor) and IsString(context.currentAuthorId)
+ author = context.currentAuthor
+ authorId = context.currentAuthorId
+ end if
+ end if
+
+ viewCountText = ParseText(nodeData["shortViewCountText"])
+ if viewCountText = ""
+ viewCountText = ParseText(nodeData["viewCountText"])
+ end if
+
+ publishedText = ParseText(nodeData["publishedTimeText"])
+ lengthText = ParseText(nodeData["lengthText"])
+
if context.generateVideoThumbnails = true
videoThumbnails = GenerateVideoThumbnails(videoId)
else
@@ -144,13 +171,51 @@ namespace Innertube
end if
end if
+ liveNow = ValidString(ObjectUtils.Dig(nodeData, ["badges", 0, "metadataBadgeRenderer", "icon", "iconType"])) = "LIVE"
+ if not liveNow
+ thumbnailOverlays = nodeData["thumbnailOverlays"]
+ if IsArray(thumbnailOverlays)
+ for each overlay in thumbnailOverlays
+ if ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "LIVE"
+ liveNow = true
+ exit for
+ end if
+ end for
+ end if
+ end if
+
+ isUpcoming = false
+ premiereTimestamp = ObjectUtils.Dig(nodeData, ["upcomingEventData", "startTime"])
+ if IsString(premiereTimestamp)
+ premiereTimestamp = premiereTimestamp.ToInt()
+ isUpcoming = true
+ end if
+
video = {
"type": "video"
"videoId": videoId
+ "author": author
+ "authorId": authorId
"title": ParseText(nodeData["title"])
"videoThumbnails": videoThumbnails
+ "viewCountText": viewCountText
+ "publishedText": publishedText
+ "lengthText": lengthText
+ "liveNow": liveNow
}
+ if author <> ""
+ video["author"] = author
+ end if
+ if authorId <> invalid
+ video["authorId"] = authorId
+ end if
+
+ if isUpcoming
+ video["isUpcoming"] = true
+ video["premiereTimestamp"] = premiereTimestamp
+ end if
+
PushFeedItem(video, context)
return invalid
end function
@@ -162,6 +227,44 @@ namespace Innertube
return invalid
end if
+ author = invalid
+ authorId = invalid
+ authorPossibleNodes = ["ownerText", "shortBylineText", "longBylineText"]
+ for each authorPossibleNode in authorPossibleNodes
+ node = nodeData[authorPossibleNode]
+ author = ParseText(node)
+ authorId = ObjectUtils.Dig(node, ["runs", 0, "navigationEndpoint", "browseEndpoint", "browseId"])
+ if author <> "" and authorId <> invalid
+ exit for
+ end if
+ end for
+ if StringUtils.IsNullOrEmpty(author) and StringUtils.IsNullOrEmpty(authorId)
+ if IsString(context.currentAuthor) and IsString(context.currentAuthorId)
+ author = context.currentAuthor
+ authorId = context.currentAuthorId
+ end if
+ end if
+
+ viewCountText = ParseText(nodeData["shortViewCountText"])
+ if viewCountText = ""
+ viewCountText = ParseText(nodeData["viewCountText"])
+ end if
+
+ publishedText = ParseText(nodeData["publishedTimeText"])
+
+ lengthText = ParseText(nodeData["lengthText"])
+ if lengthText = ""
+ thumbnailOverlays = nodeData["thumbnailOverlays"]
+ if IsArray(thumbnailOverlays)
+ for each overlay in thumbnailOverlays
+ lengthText = ParseText(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "text"]))
+ if lengthText <> ""
+ exit for
+ end if
+ end for
+ end if
+ end if
+
if context.generateVideoThumbnails = true
videoThumbnails = GenerateVideoThumbnails(videoId)
else
@@ -171,13 +274,30 @@ namespace Innertube
end if
end if
+ isUpcoming = false
+ premiereTimestamp = ObjectUtils.Dig(nodeData, ["upcomingEventData", "startTime"])
+ if IsString(premiereTimestamp)
+ premiereTimestamp = premiereTimestamp.ToInt()
+ isUpcoming = true
+ end if
+
video = {
"type": "video"
"videoId": videoId
+ "author": author
+ "authorId": authorId
"title": ParseText(nodeData["title"])
"videoThumbnails": videoThumbnails
+ "publishedText": publishedText
+ "viewCountText": viewCountText
+ "lengthText": lengthText
}
+ if isUpcoming
+ video["isUpcoming"] = true
+ video["premiereTimestamp"] = premiereTimestamp
+ end if
+
PushFeedItem(video, context)
return invalid
end function
@@ -189,11 +309,22 @@ namespace Innertube
return invalid
end if
+ author = invalid
+ authorId = invalid
+ if IsString(context.currentAuthor) and IsString(context.currentAuthorId)
+ author = context.currentAuthor
+ authorId = context.currentAuthorId
+ end if
+
video = {
"type": "video"
"videoId": videoId
+ "author": author
+ "authorId": authorId
"title": ParseText(nodeData["title"])
"videoThumbnails": GenerateVideoThumbnails(videoId)
+ "viewCountText": ParseText(nodeData["viewCountText"])
+ "publishedText": ParseText(nodeData["publishedTimeText"])
}
PushFeedItem(video, context)
@@ -207,6 +338,21 @@ namespace Innertube
return invalid
end if
+ lengthText = ParseText(nodeData["lengthText"])
+ lengthSeconds = ValidString(nodeData["lengthSeconds"]).ToInt()
+
+ author = invalid
+ authorId = invalid
+ authorPossibleNodes = ["shortBylineText", "ownerText", "longBylineText"]
+ for each authorPossibleNode in authorPossibleNodes
+ node = nodeData[authorPossibleNode]
+ author = ParseText(node)
+ authorId = ObjectUtils.Dig(node, ["runs", 0, "navigationEndpoint", "browseEndpoint", "browseId"])
+ if author <> "" and authorId <> invalid
+ exit for
+ end if
+ end for
+
if context.generateVideoThumbnails = true
videoThumbnails = GenerateVideoThumbnails(videoId)
else
@@ -219,9 +365,13 @@ namespace Innertube
video = {
"type": "video"
"videoId": videoId
+ "author": author
+ "authorId": authorId
"title": ParseText(nodeData["title"])
"videoThumbnails": videoThumbnails
"index": ParseText(nodeData["index"]).ToInt()
+ "lengthText": lengthText
+ "lengthSeconds": lengthSeconds
}
PushFeedItem(video, context)
@@ -240,6 +390,8 @@ namespace Innertube
"authorId": channelId
"author": ParseText(nodeData["title"])
"authorThumbnails": ObjectUtils.Dig(nodeData, ["thumbnail", "thumbnails"])
+ "subCountText": ParseText(nodeData["subscriberCountText"])
+ "videoCountText": ParseText(nodeData["videoCountText"])
}
PushFeedItem(channel, context)
@@ -258,21 +410,75 @@ namespace Innertube
"authorId": channelId
"author": ParseText(nodeData["title"])
"authorThumbnails": ObjectUtils.Dig(nodeData, ["thumbnail", "thumbnails"])
+ "subCountText": ParseText(nodeData["subscriberCountText"])
+ "videoCountText": ParseText(nodeData["videoCountText"])
}
PushFeedItem(channel, context)
return invalid
end function
+ function ParsePlaylistRenderer(nodeData as object, context as object) as object
+ playlistId = nodeData["playlistId"]
+ if not IsString(playlistId)
+ LogWarn("Invalid playlist ID", nodeData)
+ return invalid
+ end if
+
+ author = invalid
+ authorId = invalid
+ authorPossibleNodes = ["shortBylineText", "ownerText", "longBylineText"]
+ for each authorPossibleNode in authorPossibleNodes
+ node = nodeData[authorPossibleNode]
+ author = ParseText(node)
+ authorId = ObjectUtils.Dig(node, ["runs", 0, "navigationEndpoint", "browseEndpoint", "browseId"])
+ if author <> "" and authorId <> invalid
+ exit for
+ end if
+ end for
+
+ videoCountText = ""
+ thumbnailOverlays = nodeData["thumbnailOverlays"]
+ if IsArray(thumbnailOverlays)
+ for each overlay in thumbnailOverlays
+ videoCountText = ParseText(ObjectUtils.Dig(overlay, ["thumbnailOverlayBottomPanelRenderer", "text"]))
+ if videoCountText <> ""
+ exit for
+ end if
+ end for
+ end if
+ if videoCountText = ""
+ videoCountText = ParseText(nodeData["videoCountText"])
+ end if
+
+ videoCount = ParseText(nodeData["videoCount"]).ToInt()
+
+ playlist = {
+ "type": "playlist"
+ "playlistId": playlistId
+ "title": ParseText(nodeData["title"])
+ "playlistThumbnail": ObjectUtils.Dig(nodeData, ["thumbnails", 0, "thumbnails", 0, "url"])
+ "author": author
+ "authorId": authorId
+ "videoCount": videoCount
+ "videoCountText": videoCountText
+ }
+
+ PushFeedItem(playlist, context)
+ return invalid
+ end function
+
function ParseLockupViewModel(nodeData as object, context as object) as object
contentType = ValidString(nodeData["contentType"])
if contentType = "LOCKUP_CONTENT_TYPE_PLAYLIST"
return LockupViewModelTypePlaylist(nodeData, context)
else if contentType = "LOCKUP_CONTENT_TYPE_PODCAST"
return LockupViewModelTypePodcast(nodeData, context)
+ else if contentType = "LOCKUP_CONTENT_TYPE_ALBUM"
+ return LockupViewModelTypeAlbum(nodeData, context)
end if
- LogWarn("Unknown content type:", nodeData)
+ LogWarn("Unknown content type:", contentType, `\n`, nodeData)
return invalid
end function
@@ -286,13 +492,31 @@ namespace Innertube
metadata = ObjectUtils.Dig(nodeData, ["metadata", "lockupMetadataViewModel"])
title = ObjectUtils.Dig(metadata, ["title", "content"])
- thumbnail = ObjectUtils.Dig(nodeData, ["contentImage", "collectionThumbnailViewModel", "primaryThumbnail", "thumbnailViewModel", "image", "sources", 0, "url"])
+ thumbnailViewModel = ObjectUtils.Dig(nodeData, ["contentImage", "collectionThumbnailViewModel", "primaryThumbnail", "thumbnailViewModel"])
+ thumbnail = ObjectUtils.Dig(thumbnailViewModel, ["image", "sources", 0, "url"])
+ videoCountText = ObjectUtils.Dig(thumbnailViewModel, ["overlays", 0, "thumbnailOverlayBadgeViewModel", "thumbnailBadges", 0, "thumbnailBadgeViewModel", "text"])
+
+ author = invalid
+ authorId = invalid
+
+ maybeAuthorNode = ObjectUtils.Dig(nodeData, ["metadata", "lockupMetadataViewModel", "metadata", "contentMetadataViewModel", "metadataRows", 0, "metadataParts", 0, "text"])
+ maybeAuthorId = ObjectUtils.Dig(maybeAuthorNode, ["commandRuns", 0, "onTap", "innertubeCommand", "browseEndpoint", "browseId"])
+ if IsString(maybeAuthorId) and maybeAuthorId.StartsWith("UC")
+ authorId = maybeAuthorId
+ author = ValidString(maybeAuthorNode["content"])
+ else if IsString(context.currentAuthor) and IsString(context.currentAuthorId)
+ author = context.currentAuthor
+ authorId = context.currentAuthorId
+ end if
playlist = {
"type": "playlist"
"playlistId": playlistId
"title": title
+ "author": author
+ "authorId": authorId
"playlistThumbnail": thumbnail
+ "videoCountText": videoCountText
}
PushFeedItem(playlist, context)
@@ -309,13 +533,60 @@ namespace Innertube
metadata = ObjectUtils.Dig(nodeData, ["metadata", "lockupMetadataViewModel"])
title = ObjectUtils.Dig(metadata, ["title", "content"])
- thumbnail = ObjectUtils.Dig(nodeData, ["contentImage", "collectionThumbnailViewModel", "primaryThumbnail", "thumbnailViewModel", "image", "sources", 0, "url"])
+ thumbnailViewModel = ObjectUtils.Dig(nodeData, ["contentImage", "collectionThumbnailViewModel", "primaryThumbnail", "thumbnailViewModel"])
+ thumbnail = ObjectUtils.Dig(thumbnailViewModel, ["image", "sources", 0, "url"])
+ videoCountText = ObjectUtils.Dig(thumbnailViewModel, ["overlays", 0, "thumbnailOverlayBadgeViewModel", "thumbnailBadges", 0, "thumbnailBadgeViewModel", "text"])
+
+ author = invalid
+ authorId = invalid
+ if IsString(context.currentAuthor) and IsString(context.currentAuthorId)
+ author = context.currentAuthor
+ authorId = context.currentAuthorId
+ end if
playlist = {
"type": "playlist"
"playlistId": playlistId
"title": title
+ "author": author
+ "authorId": authorId
"playlistThumbnail": thumbnail
+ "videoCountText": videoCountText
+ }
+
+ PushFeedItem(playlist, context)
+ return invalid
+ end function
+
+ function LockupViewModelTypeAlbum(nodeData as object, context as object) as object
+ playlistId = nodeData["contentId"]
+ if not IsString(playlistId)
+ LogWarn("Invalid playlist ID", nodeData)
+ return invalid
+ end if
+
+ metadata = ObjectUtils.Dig(nodeData, ["metadata", "lockupMetadataViewModel"])
+
+ title = ObjectUtils.Dig(metadata, ["title", "content"])
+ thumbnailViewModel = ObjectUtils.Dig(nodeData, ["contentImage", "collectionThumbnailViewModel", "primaryThumbnail", "thumbnailViewModel"])
+ thumbnail = ObjectUtils.Dig(thumbnailViewModel, ["image", "sources", 0, "url"])
+ videoCountText = ObjectUtils.Dig(thumbnailViewModel, ["overlays", 0, "thumbnailOverlayBadgeViewModel", "thumbnailBadges", 0, "thumbnailBadgeViewModel", "text"])
+
+ author = invalid
+ authorId = invalid
+ if IsString(context.currentAuthor) and IsString(context.currentAuthorId)
+ author = context.currentAuthor
+ authorId = context.currentAuthorId
+ end if
+
+ playlist = {
+ "type": "playlist"
+ "playlistId": playlistId
+ "title": title
+ "author": author
+ "authorId": authorId
+ "playlistThumbnail": thumbnail
+ "videoCountText": videoCountText
}
PushFeedItem(playlist, context)
@@ -338,11 +609,20 @@ namespace Innertube
end if
end if
+ author = invalid
+ authorId = invalid
+ if IsString(context.currentAuthor) and IsString(context.currentAuthorId)
+ author = context.currentAuthor
+ authorId = context.currentAuthorId
+ end if
video = {
"type": "video"
"videoId": videoId
+ "author": author
+ "authorId": authorId
"title": ObjectUtils.Dig(nodeData, ["overlayMetadata", "primaryText", "content"])
+ "viewCountText": ObjectUtils.Dig(nodeData, ["overlayMetadata", "secondaryText", "content"])
"videoThumbnails": videoThumbnails
}
@@ -375,7 +655,7 @@ namespace Innertube
return TileRendererTypePlaylist(nodeData, context)
end if
- LogWarn("Unknown content type:", nodeData)
+ LogWarn("Unknown content type:", contentType, `\n`, nodeData)
return invalid
end function
diff --git a/playlet-lib/src/components/Services/Innertube/Parser.bs b/playlet-lib/src/components/Services/Innertube/Parser.bs
index d318c726..79e82178 100644
--- a/playlet-lib/src/components/Services/Innertube/Parser.bs
+++ b/playlet-lib/src/components/Services/Innertube/Parser.bs
@@ -4,7 +4,7 @@ import "pkg:/source/utils/StringUtils.bs"
namespace Innertube
- function ParseResponse(responseData as object) as object
+ function ParseResponse(responseData as object, context = invalid as object) as object
if responseData = invalid
return []
end if
@@ -14,7 +14,11 @@ namespace Innertube
return []
end if
- context = {
+ if context = invalid
+ context = {}
+ end if
+
+ context.Append({
directives: Innertube.GetParsingDirectives()
feeds: []
@@ -23,7 +27,7 @@ namespace Innertube
items: []
}
generateVideoThumbnails: true
- }
+ })
Innertube.ParseNode(data, context)
@@ -46,7 +50,8 @@ namespace Innertube
}
end if
- title = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "title"])
+ author = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "title"])
+ authorId = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "externalId"])
thumbnails = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "avatar", "thumbnails"])
if thumbnails = invalid
@@ -59,7 +64,6 @@ namespace Innertube
end if
end if
- ucid = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "externalId"])
banners = ObjectUtils.Dig(responseData, ["header", "pageHeaderRenderer", "content", "pageHeaderViewModel", "banner", "imageBannerViewModel", "image", "sources"])
if banners = invalid
banners = []
@@ -123,14 +127,14 @@ namespace Innertube
end if
items = []
- feeds = ParseResponse(responseData)
+ feeds = ParseResponse(responseData, { "currentAuthor": author, "currentAuthorId": authorId })
if feeds.Count() > 0
items = ValidArray(feeds[0].items)
end if
return {
- "author": title
- "authorId": ucid
+ "author": author
+ "authorId": authorId
"authorThumbnails": thumbnails
"authorBanners": banners
"authorSubTitle": authorSubTitle
@@ -155,19 +159,40 @@ namespace Innertube
playlistSidebarRendererItems = ObjectUtils.Dig(responseData, ["sidebar", "playlistSidebarRenderer", "items"])
primaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [0, "playlistSidebarPrimaryInfoRenderer"])
- ' secondaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [1, "playlistSidebarSecondaryInfoRenderer"])
+ secondaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [1, "playlistSidebarSecondaryInfoRenderer"])
+ playlistId = ObjectUtils.Dig(primaryInfo, ["navigationEndpoint", "watchEndpoint", "playlistId"])
title = ParseText(ObjectUtils.Dig(primaryInfo, ["title"]))
description = ParseText(ObjectUtils.Dig(primaryInfo, ["description"]))
videoCount = ParseText(ObjectUtils.Dig(primaryInfo, ["stats", 0, "runs", 0, "text"])).ToInt()
thumbnail = ObjectUtils.Dig(primaryInfo, ["thumbnailRenderer", "playlistVideoThumbnailRenderer", "thumbnail", "thumbnails", 0, "url"])
+ author = ParseText(ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "title"]))
+ authorId = ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "navigationEndpoint", "browseEndpoint", "browseId"])
+
+ statsText = ""
+ stats = ObjectUtils.Dig(primaryInfo, ["stats"])
+ if IsArray(stats)
+ statsTexts = []
+ for each stat in stats
+ statText = ParseText(stat)
+ if statText <> ""
+ statsTexts.Push(statText)
+ end if
+ end for
+ statsText = statsTexts.Join(" • ")
+ end if
+
playlist = {
+ "playlistId": playlistId
"title": title
+ "author": author
+ "authorId": authorId
"description": description
"videoCount": videoCount
"thumbnail": thumbnail
"videos": []
+ "statsText": statsText
}
feeds = ParseResponse(responseData)
diff --git a/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs b/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs
index 5960f908..011e977f 100644
--- a/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs
+++ b/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs
@@ -40,7 +40,7 @@ namespace InvidiousContent
SetIfExists(node, "_author", item, "author")
SetIfExists(node, "authorId", item, "authorId")
SetIfExists(node, "lengthSeconds", item, "lengthSeconds")
- node.lengthText = TimeUtils.GetFormattedTime(item.lengthSeconds)
+ node.lengthText = VideoGetLengthText(item)
node.liveNow = VideoIsLive(item)
VideoSetPremiereTimestampText(node, item)
node.publishedText = VideoGetPublishedText(item)
@@ -75,6 +75,7 @@ namespace InvidiousContent
node.viewCountText = PlaylistGetViewCountText(item)
SetIfExists(node, "updated", item, "updated")
node.updatedText = PlaylistGetUpdatedText(item)
+ SetIfExists(node, "statsText", item, "statsText")
if item.videos <> invalid
childCount = node.getChildCount()
@@ -116,6 +117,7 @@ namespace InvidiousContent
SetIfExists(node, "channelHandle", item, "channelHandle")
SetIfExists(node, "description", item, "description")
SetIfExists(node, "subCount", item, "subCount")
+ SetIfExists(node, "authorSubTitle", item, "authorSubTitle")
node.subCountText = GetChannelSubCountText(item)
SetIfExists(node, "videoCount", item, "videoCount")
node.videoCountText = GetVideoCountText(item)
@@ -232,6 +234,11 @@ namespace InvidiousContent
end function
function VideoGetViewCountText(videoItem as object) as string
+ viewCountText = videoItem.viewCountText
+ if not StringUtils.IsNullOrEmpty(viewCountText)
+ return viewCountText
+ end if
+
viewCount = videoItem.viewCount
if viewCount = invalid
return ""
@@ -285,6 +292,9 @@ namespace InvidiousContent
end function
function GetVideoCountText(item as object) as string
+ if not StringUtils.IsNullOrEmpty(item.videoCountText)
+ return item.videoCountText
+ end if
videoCount = ValidInt(item.videoCount)
return LocaleUtils.GetPluralString(videoCount, Locale.RowCell.ZeroVideos, Locale.RowCell.OneVideo, Locale.RowCell.NVideos)
end function
@@ -356,6 +366,13 @@ namespace InvidiousContent
end if
end function
+ function VideoGetLengthText(videoItem as object) as string
+ if not StringUtils.IsNullOrEmpty(videoItem.lengthText)
+ return videoItem.lengthText
+ end if
+ return TimeUtils.GetFormattedTime(videoItem.lengthSeconds)
+ end function
+
function PlaylistGetUpdatedText(playlistItem as object) as string
updated = playlistItem.updated
if not IsInt(updated)
diff --git a/playlet-lib/src/components/VideoFeed/VideoRowCell/ChannelRowCell.bs b/playlet-lib/src/components/VideoFeed/VideoRowCell/ChannelRowCell.bs
index 139a2570..93aa6887 100644
--- a/playlet-lib/src/components/VideoFeed/VideoRowCell/ChannelRowCell.bs
+++ b/playlet-lib/src/components/VideoFeed/VideoRowCell/ChannelRowCell.bs
@@ -1,3 +1,5 @@
+import "pkg:/source/utils/StringUtils.bs"
+
function OnContentSet() as void
content = m.top.itemContent
@@ -7,7 +9,21 @@ function OnContentSet() as void
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.top._author = content._author
- m.top.subCountText = content.subCountText
+ subCountText = content.authorSubTitle
+ if StringUtils.IsNullOrEmpty(subCountText)
+ if content.subCount > 0
+ subCountText = content.subCountText
+ if StringUtils.IsNullOrEmpty(subCountText)
+ subCountText = content.videoCountText
+ end if
+ else
+ subCountText = content.videoCountText
+ if StringUtils.IsNullOrEmpty(subCountText)
+ subCountText = content.subCountText
+ end if
+ end if
+ end if
+ m.top.subCountText = subCountText
m.top.channelHandle = content.channelHandle
m.top.thumbnail = content.thumbnail
end function
diff --git a/playlet-lib/src/components/VideoFeed/VideoRowCell/ChannelRowCell.xml b/playlet-lib/src/components/VideoFeed/VideoRowCell/ChannelRowCell.xml
index 6cd45b9e..ca57a98f 100644
--- a/playlet-lib/src/components/VideoFeed/VideoRowCell/ChannelRowCell.xml
+++ b/playlet-lib/src/components/VideoFeed/VideoRowCell/ChannelRowCell.xml
@@ -20,13 +20,14 @@
+ wrap="true"
+ font="font:SmallestBoldSystemFont" />