From a937fe17077c44b587759bb53adc225a734f584f Mon Sep 17 00:00:00 2001 From: Luvi-1 Date: Sun, 23 Aug 2026 21:43:14 -0700 Subject: [PATCH] Fix published date and views for collaboration videos in lockupViewModel For collaboration videos, YouTube adds a second metadata row with the author names before the row containing view count and publish date. The LockupViewModelParser only checked metadataRows[0], so it missed the actual data on rows 1+. Scan all metadata rows for the one containing views/publish info. --- src/invidious/yt_backend/extractors.cr | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index b2226e74d..9c813522e 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -662,7 +662,12 @@ private module Parsers metadata = item_contents.dig("metadata", "lockupMetadataViewModel") title = metadata.dig("title", "content").as_s # Contains the views of the video and the published time of the video. - metadata_parts = metadata.dig("metadata", "contentMetadataViewModel", "metadataRows", 0, "metadataParts").try &.as_a + # For collaboration videos, the first row contains the author names + # instead, so we scan all rows for the one with view/publish info. + metadata_parts = metadata.dig?("metadata", "contentMetadataViewModel", "metadataRows") + .try &.as_a + .compact_map { |row| row.dig?("metadataParts").try &.as_a } + .find { |parts| parts.any? { |item| item.dig?("text", "content").try &.as_s.includes?("views") || item.dig?("text", "content").try &.as_s.includes?("ago") } } view_count_text = metadata_parts.try &.find { |item| item["icon"]?.nil? && item.dig?("text", "content").try &.as_s.includes?("views") } .try &.dig("text", "content").as_s