Use short-hand block notation for parsing chapters

This commit is contained in:
syeopite 2023-09-19 13:25:06 -07:00
parent 6f62de36d7
commit 9535009864
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A

View File

@ -397,11 +397,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