From d7824af24770acf87da5e6f57077fc5a8ea36a38 Mon Sep 17 00:00:00 2001 From: campbell Date: Tue, 11 Aug 2026 22:59:44 +0900 Subject: [PATCH] fix(parser): parse published date and view count for collab videos Fixes #5740 --- src/invidious/yt_backend/extractors.cr | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index b2226e74..ef079868 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -661,13 +661,24 @@ 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 + view_count_text = nil + published = nil - 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 + # Contains the views of the video and the published time of the video. + # Collaboration videos have multiple authors in the first row, so we check all rows. + if metadata_rows = metadata.dig?("metadata", "contentMetadataViewModel", "metadataRows").try &.as_a + metadata_rows.each do |row| + row.dig?("metadataParts").try &.as_a.each do |item| + next if item["icon"]? + if text = item.dig?("text", "content").try &.as_s + view_count_text ||= text if text.includes?("views") + published ||= decode_date(text) if text.includes?("ago") + end + end + end + end + + published ||= Time.local view_count = short_text_to_number(view_count_text || "0")