simplify check for continuationItemRenderer

Co-Authored-By: syeopite <70992037+syeopite@users.noreply.github.com>
Co-Authored-By: Samantaz Fox <coding@samantaz.fr>
This commit is contained in:
ChunkyProgrammer 2023-10-22 19:09:02 -04:00
parent 4627dbbe1c
commit 4119cecf75

View File

@ -717,14 +717,14 @@ private module Extractors
end end
private def self.extract(target) private def self.extract(target)
raw_items = [] of Array(JSON::Any) raw_items = [] of JSON::Any
target.dig("primaryContents", "sectionListRenderer", "contents").as_a.each do |node| target.dig("primaryContents", "sectionListRenderer", "contents").as_a.each do |node|
if new_node = node["itemSectionRenderer"]? if new_node = node["itemSectionRenderer"]?
raw_items << new_node["contents"].as_a raw_items += new_node["contents"].as_a
end elsif node["continuationItemRenderer"]?
if node["continuationItemRenderer"]? # we put the node in an array so the ContinuationItemRendererParser is able to parse it
raw_items.push([node]) raw_items << node
end end
end end