From fe8084989b412557932376e131a8b3f37d28edb9 Mon Sep 17 00:00:00 2001 From: syeopite Date: Tue, 19 Sep 2023 13:25:06 -0700 Subject: [PATCH] Use short-hand block notation for parsing chapters --- src/invidious/videos/parser.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index 5feb02e4..3bd65556 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -424,11 +424,11 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any # Yes,`decoratedPlayerBarRenderer` is repeated twice. if player_bar = player_overlays.try &.dig?("decoratedPlayerBarRenderer", "decoratedPlayerBarRenderer", "playerBar") if markers = player_bar.dig?("multiMarkersPlayerBarRenderer", "markersMap") - potential_chapters_array = markers.as_a.find { |m| m["key"]? == "DESCRIPTION_CHAPTERS" } + potential_chapters_array = markers.as_a.find(&.["key"]?.try &.== "DESCRIPTION_CHAPTERS") - # Let manual chapters have higher precedence than automatically generated ones. + # Chapters that are manually created should have a higher precedence than automatically generated chapters if !potential_chapters_array - potential_chapters_array = markers.as_a.find { |m| m["key"]? == "AUTO_CHAPTERS" } + potential_chapters_array = markers.as_a.find(&.["key"]?.try &.== "AUTO_CHAPTERS") end if potential_chapters_array