Switching to a safer 'dig?' with an alternative code path in case 'metadataRows' is missing from the input data

This commit is contained in:
RadoslavL 2026-09-21 05:25:12 +03:00
parent 353d113efa
commit a9b9c49c55

View File

@ -662,7 +662,7 @@ 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_rows = metadata.dig("metadata", "contentMetadataViewModel", "metadataRows").try &.as_a
metadata_rows = metadata.dig?("metadata", "contentMetadataViewModel", "metadataRows").try &.as_a || Array(JSON::Any).new
view_count_text : String? = nil
published : Time = Time.local