mirror of
https://github.com/iv-org/invidious.git
synced 2026-09-07 17:42:46 -05:00
Fix published date and views for collaboration videos in lockupViewModel
For collaboration videos, YouTube adds a second metadata row with the author names before the row containing view count and publish date. The LockupViewModelParser only checked metadataRows[0], so it missed the actual data on rows 1+. Scan all metadata rows for the one containing views/publish info.
This commit is contained in:
parent
6e04e743be
commit
a937fe1707
@ -662,7 +662,12 @@ 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
|
||||||
# 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
|
# 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") } }
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user