Merge eb567904784ea9b60d017a2b0b7132cf986a23e4 into d10f2a48021f1768f2d6ff3bd1b9f3de4e0b2d22

This commit is contained in:
Cameron Radmore 2026-08-15 05:14:57 +02:00 committed by GitHub
commit e247db273a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -661,13 +661,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
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) } || Time.local
.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")
@ -680,7 +692,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,