From 353d113efa39a38edc48b4886dd4d6a118510fd0 Mon Sep 17 00:00:00 2001 From: RadoslavL Date: Mon, 21 Sep 2026 03:54:10 +0300 Subject: [PATCH 1/3] Fixed missing video information for collaboration videos --- src/invidious/yt_backend/extractors.cr | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index b2226e74d..82c5cce51 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -662,14 +662,26 @@ 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 + metadata_rows = metadata.dig("metadata", "contentMetadataViewModel", "metadataRows").try &.as_a - 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 - published = metadata_parts.try &.find { |item| item["icon"]?.nil? && item.dig?("text", "content").try &.as_s.includes?("ago") } - .try { |item| decode_date(item.dig("text", "content").as_s) } || Time.local + view_count_text : String? = nil + published : Time = Time.local + view_count : Int64 = 0_i64 - view_count = short_text_to_number(view_count_text || "0") + metadata_rows.each do |row| + metadata_parts = row.dig?("metadataParts").try &.as_a + next unless metadata_parts + + 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 + published = metadata_parts.try &.find { |item| item["icon"]?.nil? && item.dig?("text", "content").try &.as_s.includes?("ago") } + .try { |item| decode_date(item.dig("text", "content").as_s) } || Time.local + + view_count = short_text_to_number(view_count_text || "0") + if view_count_text + break + end + end length = thumbnail_view_model.dig("overlays", 0, "thumbnailBottomOverlayViewModel", "badges", 0, "thumbnailBadgeViewModel", "text").try &.as_s From a9b9c49c55a4a7c97c1d80ebb561ef0d42eeae6c Mon Sep 17 00:00:00 2001 From: RadoslavL Date: Mon, 21 Sep 2026 05:25:12 +0300 Subject: [PATCH 2/3] Switching to a safer 'dig?' with an alternative code path in case 'metadataRows' is missing from the input data --- src/invidious/yt_backend/extractors.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index 82c5cce51..bf1dc152c 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -662,7 +662,7 @@ 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_rows = metadata.dig("metadata", "contentMetadataViewModel", "metadataRows").try &.as_a + metadata_rows = metadata.dig?("metadata", "contentMetadataViewModel", "metadataRows").try &.as_a || Array(JSON::Any).new view_count_text : String? = nil published : Time = Time.local From b96ecbab4dd6f707b9f341f6f469c8c23949df59 Mon Sep 17 00:00:00 2001 From: RadoslavL Date: Mon, 21 Sep 2026 05:27:37 +0300 Subject: [PATCH 3/3] Fixed formatting --- src/invidious/yt_backend/extractors.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index bf1dc152c..4a247eaed 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -662,7 +662,7 @@ 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_rows = metadata.dig?("metadata", "contentMetadataViewModel", "metadataRows").try &.as_a || Array(JSON::Any).new + metadata_rows = metadata.dig?("metadata", "contentMetadataViewModel", "metadataRows").try &.as_a || Array(JSON::Any).new view_count_text : String? = nil published : Time = Time.local