mirror of
https://github.com/iv-org/invidious.git
synced 2026-09-06 00:52:45 -05:00
Fall back to first metadata row when no views/published row found
This commit is contained in:
parent
a937fe1707
commit
f6436e7286
@ -664,10 +664,10 @@ private module Parsers
|
||||
# Contains the views of the video and the published time of the video.
|
||||
# For collaboration videos, the first row contains the author names
|
||||
# instead, so we scan all rows for the one with view/publish info.
|
||||
metadata_parts = metadata.dig?("metadata", "contentMetadataViewModel", "metadataRows")
|
||||
.try &.as_a
|
||||
.compact_map { |row| row.dig?("metadataParts").try &.as_a }
|
||||
.find { |parts| parts.any? { |item| item.dig?("text", "content").try &.as_s.includes?("views") || item.dig?("text", "content").try &.as_s.includes?("ago") } }
|
||||
all_rows = metadata.dig?("metadata", "contentMetadataViewModel", "metadataRows")
|
||||
.try &.as_a.compact_map { |row| row.dig?("metadataParts").try &.as_a }
|
||||
metadata_parts = all_rows.try &.find { |parts| parts.any? { |item| item.dig?("text", "content").try &.as_s.includes?("views") || item.dig?("text", "content").try &.as_s.includes?("ago") } }
|
||||
metadata_parts ||= all_rows.try &.first?
|
||||
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user