From d3a9e8554cdeafdeb5d5be10f2aeb8e121fe25ef Mon Sep 17 00:00:00 2001 From: syeopite Date: Mon, 24 May 2021 11:09:23 -0700 Subject: [PATCH] Extract items from category for search in frontend --- src/invidious/search.cr | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/invidious/search.cr b/src/invidious/search.cr index 60d95bcd..b2b0eee0 100644 --- a/src/invidious/search.cr +++ b/src/invidious/search.cr @@ -231,5 +231,20 @@ def process_search_query(url_params, query, page, user, region) count, items = search(search_query, search_params, region).as(Tuple) end - {search_query, count, items, url_params} + # Light processing to extract items from categories. + # Categories should ideally be supported in the frontend in the future + extracted_items = [] of SearchItem | ChannelVideo + items.each do |i| + if i.is_a? Category + i.contents.each do |cate_items| + if cate_items.is_a? (SearchVideo | SearchPlaylist | SearchChannel) + extracted_items << cate_items + end + end + else + extracted_items << i + end + end + + {search_query, count, extracted_items, url_params} end