From b84ce6a5568429ffa30d993a8cd0410cfb72449b Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 1 May 2022 21:11:12 +0200 Subject: [PATCH] Fix "cast from Nil to Bool failed" --- src/invidious/videos.cr | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index b16955b1..7c1f68a8 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -614,7 +614,7 @@ struct Video end def author_verified : Bool - info["authorVerified"].try &.as_bool || false + info["authorVerified"]?.try &.as_bool || false end def sub_count_text : String @@ -1093,7 +1093,8 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ author_thumbnail = author_info.try &.dig?("thumbnail", "thumbnails", 0, "url") author_verified_badge = author_info.try &.dig?("badges", 0, "metadataBadgeRenderer", "tooltip") - params["authorVerified"] = JSON::Any.new((author_verified_badge && author_verified_badge == "Verified")) + author_verified = (!author_verified_badge.nil? && author_verified_badge == "Verified") + params["authorVerified"] = JSON::Any.new(author_verified) params["authorThumbnail"] = JSON::Any.new(author_thumbnail.try &.as_s || "")