mirror of
https://github.com/iv-org/invidious.git
synced 2026-07-27 16:06:47 -05:00
fix(parser): parse published date and view count for collab videos
This commit is contained in:
parent
e5bde4bc60
commit
3f81fcaff8
@ -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,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user