fix(channel): parse views/published of collab videos in lockupViewModel

Collaboration videos have an additional metadata row containing the
names of every channel involved, which means the views and published
data cannot be assumed to be located in metadataRows[0].

Iterate every metadata row instead of hardcoding the first one, using
the same approach already used by the playlist branch of this parser.

Fixes #5740
This commit is contained in:
soygeitoyt-lgtm 2026-08-22 03:02:07 -04:00
parent eff609d0cd
commit bcd0c3adc3
2 changed files with 69 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@ -662,7 +662,12 @@ private module Parsers
metadata = item_contents.dig("metadata", "lockupMetadataViewModel")
title = metadata.dig("title", "content").as_s
# 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
# NOTE: Collaboration videos have an additional metadata row containing
# the names of every channel involved, which means that the views and
# published data cannot be assumed to be located in the first row.
# See: https://github.com/iv-org/invidious/issues/5740
metadata_parts = metadata.dig?("metadata", "contentMetadataViewModel", "metadataRows")
.try &.as_a.try(&.flat_map { |row| row.dig?("metadataParts").try(&.as_a) || [] of JSON::Any })
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