From cea38de4ad734425ae5c23f43a01f7f9248d48be Mon Sep 17 00:00:00 2001 From: syeopite <70992037+syeopite@users.noreply.github.com> Date: Thu, 12 Aug 2021 12:26:50 -0700 Subject: [PATCH] Check for existance of "adaptiveFormats" in videos Combined from commits: - Check for existance of "adaptiveFormats" in videos - Remove usage of ternary conditional --- src/invidious/videos.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 27c54b14..851db0de 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -765,8 +765,8 @@ struct Video info["microformat"]?.try &.["playerMicroformatRenderer"]["isFamilySafe"]?.try &.as_bool || false end - def is_vr : Bool - info["streamingData"]?.try &.["adaptiveFormats"].as_a[0]?.try &.["projectionType"].as_s == "MESH" ? true : false || false + def is_vr : Bool? + info.dig?("streamingData", "adaptiveFormats", 0, "projectionType").try &.as_s == "MESH" end def wilson_score : Float64