From abda6840d5bfe58f845128bdd1a3f4916dd3bb84 Mon Sep 17 00:00:00 2001 From: syeopite Date: Fri, 25 Jun 2021 18:59:27 -0700 Subject: [PATCH] Fix missing search results in extraction --- src/invidious/helpers/extractors.cr | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/invidious/helpers/extractors.cr b/src/invidious/helpers/extractors.cr index 3d3d88ab..9f5b1059 100644 --- a/src/invidious/helpers/extractors.cr +++ b/src/invidious/helpers/extractors.cr @@ -332,10 +332,15 @@ private class SearchResultsExtractor < ItemsContainerExtractor end private def extract(target) - raw_items = [] of JSON::Any + raw_items = [] of Array(JSON::Any) content = target["primaryContents"] - renderer = content["sectionListRenderer"]["contents"].as_a[0]["itemSectionRenderer"] - raw_items = renderer["contents"].as_a + renderer = content["sectionListRenderer"]["contents"].as_a.each do |node| + if node = node["itemSectionRenderer"]? + raw_items << node["contents"].as_a + end + end + + raw_items = raw_items.flatten return SearchResults.new({contents: raw_items}) end