fix(parser): parse published date and view count for collab videos (#5812)

This PR fixes parsing of view count and published metadata for lockupviews (that are collabs)

closes: #5740
This commit is contained in:
Cameron Radmore
2026-11-03 00:26:48 -05:00
committed by GitHub
parent 3df861696c
commit 47bb5ce93a

View File

@@ -710,13 +710,25 @@ private module Parsers
metadata = item_contents.dig("metadata", "lockupMetadataViewModel")
title = metadata.dig("title", "content").as_s
published = nil
view_count_text = nil
# 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
if (metadata_rows = metadata.dig("metadata", "contentMetadataViewModel", "metadataRows").try &.as_a)
metadata_rows.each do |row|
metadata_parts = row.dig("metadataParts").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
if view_count_text.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
end
if published.nil?
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) }
end
break if !view_count_text.nil? && !published.nil?
end
end
view_count = short_text_to_number(view_count_text || "0")
@@ -729,7 +741,7 @@ private module Parsers
id: video_id,
author: author_fallback.name,
ucid: author_fallback.id,
published: published,
published: published || Time.local,
views: view_count,
description_html: "",
length_seconds: length_seconds || 0,