From 71d9409ecae742f66cc45dc4ee182720f53cc928 Mon Sep 17 00:00:00 2001 From: mateea326 Date: Thu, 20 Aug 2026 16:06:24 +0300 Subject: [PATCH] Extract published time and view count from all metadata rows in LockupViewModel --- src/invidious/yt_backend/extractors.cr | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index b2226e74d..ba7f02835 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -661,8 +661,9 @@ 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 + # Contains the views of the video and the published time of the video (supports multiple creators). + metadata_rows = metadata.dig?("metadata", "contentMetadataViewModel", "metadataRows").try &.as_a + metadata_parts = metadata_rows.try &.flat_map { |row| row.dig?("metadataParts").try &.as_a || [] of JSON::Any } 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