Merge 3f81fcaff8e129248d51aae36cd545d0d365cf33 into 59bb97cdc3011b37cbcd9e85f2f708f009978893

This commit is contained in:
Cameron Radmore 2026-07-25 05:38:53 +09:00 committed by GitHub
commit 9bb533a03d
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") metadata = item_contents.dig("metadata", "lockupMetadataViewModel")
title = metadata.dig("title", "content").as_s 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. # 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") } 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 .try &.dig("text", "content").as_s
end if
if published.nil?
published = metadata_parts.try &.find { |item| item["icon"]?.nil? && item.dig?("text", "content").try &.as_s.includes?("ago") } 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") view_count = short_text_to_number(view_count_text || "0")
@ -680,7 +692,7 @@ private module Parsers
id: video_id, id: video_id,
author: author_fallback.name, author: author_fallback.name,
ucid: author_fallback.id, ucid: author_fallback.id,
published: published, published: published || Time.local,
views: view_count, views: view_count,
description_html: "", description_html: "",
length_seconds: length_seconds || 0, length_seconds: length_seconds || 0,