From b49b5fbda90a7fc9923af27a870504be976d55e9 Mon Sep 17 00:00:00 2001 From: syeopite Date: Wed, 13 Oct 2021 11:32:27 -0700 Subject: [PATCH 1/2] Support empty categories --- src/invidious/helpers/extractors.cr | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/invidious/helpers/extractors.cr b/src/invidious/helpers/extractors.cr index c8a6cd4a..73b07fd2 100644 --- a/src/invidious/helpers/extractors.cr +++ b/src/invidious/helpers/extractors.cr @@ -321,11 +321,13 @@ private module Parsers content_container = item_contents["contents"] end - raw_contents = content_container["items"].as_a - raw_contents.each do |item| - result = extract_item(item) - if !result.nil? - contents << result + raw_contents = content_container["items"]?.try &.as_a + if !raw_contents.nil? + raw_contents.each do |item| + result = extract_item(item) + if !result.nil? + contents << result + end end end From 4d44b2c3a422abb3e989a9010c082cfb6a52fb12 Mon Sep 17 00:00:00 2001 From: syeopite Date: Wed, 13 Oct 2021 11:33:04 -0700 Subject: [PATCH 2/2] Handle YT tabs without any content --- src/invidious/helpers/extractors.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/helpers/extractors.cr b/src/invidious/helpers/extractors.cr index 73b07fd2..6af40de5 100644 --- a/src/invidious/helpers/extractors.cr +++ b/src/invidious/helpers/extractors.cr @@ -401,7 +401,7 @@ private module Extractors items_container = renderer_container_contents end - items_container["items"].as_a.each do |item| + items_container["items"]?.try &.as_a.each do |item| raw_items << item end end