mirror of
https://github.com/iv-org/invidious.git
synced 2026-09-06 00:52:45 -05:00
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:
parent
eff609d0cd
commit
bcd0c3adc3
63
spec/invidious/videos/lockup_videos_extract_spec.cr
Normal file
63
spec/invidious/videos/lockup_videos_extract_spec.cr
Normal file
File diff suppressed because one or more lines are too long
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user