From 1c6b47a5a6a33a73a980ccab648026a595dce469 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Wed, 21 May 2025 09:06:17 -0400 Subject: [PATCH] Handle TILE_CONTENT_TYPE_SHORTS --- CHANGELOG.md | 4 ++ .../components/Services/Innertube/Context.bs | 1 + .../Services/Innertube/NodesParser.bs | 40 +++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da4fcb28..c023e5c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +- Nothing worth mentioning yet. + ## [0.38.1] - 2025-05-20 ### Fixed diff --git a/playlet-lib/src/components/Services/Innertube/Context.bs b/playlet-lib/src/components/Services/Innertube/Context.bs index d5b00f25..44396627 100644 --- a/playlet-lib/src/components/Services/Innertube/Context.bs +++ b/playlet-lib/src/components/Services/Innertube/Context.bs @@ -147,6 +147,7 @@ namespace Innertube "clientFormFactor": "UNKNOWN_FORM_FACTOR" "webpSupport": false "tvAppInfo": { + ' "appQuality": "TV_APP_QUALITY_FULL_ANIMATION" "appQuality": "TV_APP_QUALITY_LIMITED_MEMORY" "useStartPlaybackPreviewCommand": false "supportsNativeScrolling": false diff --git a/playlet-lib/src/components/Services/Innertube/NodesParser.bs b/playlet-lib/src/components/Services/Innertube/NodesParser.bs index 04ddecf9..0805fc27 100644 --- a/playlet-lib/src/components/Services/Innertube/NodesParser.bs +++ b/playlet-lib/src/components/Services/Innertube/NodesParser.bs @@ -938,6 +938,8 @@ namespace Innertube if contentType = "TILE_CONTENT_TYPE_VIDEO" return TileRendererTypeVideo(nodeData, context) + else if contentType = "TILE_CONTENT_TYPE_SHORTS" + return TileRendererTypeShorts(nodeData, context) else if contentType = "TILE_CONTENT_TYPE_PLAYLIST" return TileRendererTypePlaylist(nodeData, context) end if @@ -1017,6 +1019,44 @@ namespace Innertube return invalid end function + function TileRendererTypeShorts(nodeData as object, context as object) as object + videoId = nodeData["contentId"] + if not IsString(videoId) + LogWarn("Invalid video ID", nodeData) + return invalid + end if + + if context.generateVideoThumbnails = true + videoThumbnails = GenerateVideoThumbnails(videoId) + else + videoThumbnails = ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnail", "thumbnails"]) + if videoThumbnails = invalid + videoThumbnails = GenerateVideoThumbnails(videoId) + end if + end if + + title = "" + thumbnailOverlays = ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnailOverlays"]) + if IsArray(thumbnailOverlays) + for each overlay in thumbnailOverlays + title = ParseText(ObjectUtils.Dig(overlay, ["tileMetadataRenderer", "title"])) + if title <> "" + exit for + end if + end for + end if + + video = { + "type": "video" + "videoId": videoId + "title": title + "videoThumbnails": videoThumbnails + } + + PushFeedItem(video, context) + return invalid + end function + function TileRendererTypePlaylist(nodeData as object, context as object) as object playlistId = nodeData["contentId"] if not IsString(playlistId)