mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-23 00:29:53 +05:30
Extractors: Add utility function to extract items from categories
This commit is contained in:
parent
7afa03d821
commit
3cfbc19ccc
@ -68,19 +68,16 @@ rescue ex
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_videos(initial_data : Hash(String, JSON::Any), author_fallback : String? = nil, author_id_fallback : String? = nil) : Array(SearchVideo)
|
# This function extracts the SearchItems from a Category.
|
||||||
extracted, _ = extract_items(initial_data, author_fallback, author_id_fallback)
|
# Categories are commonly returned in search results and trending pages.
|
||||||
|
def extract_category(category : Category) : Array(SearchVideo)
|
||||||
|
items = [] of SearchItem
|
||||||
|
|
||||||
target = [] of (SearchItem | Continuation)
|
category.contents.each do |item|
|
||||||
extracted.each do |i|
|
target << cate_i if item.is_a?(SearchItem)
|
||||||
if i.is_a?(Category)
|
|
||||||
i.contents.each { |cate_i| target << cate_i if !cate_i.is_a? Video }
|
|
||||||
else
|
|
||||||
target << i
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return target.select(SearchVideo)
|
return items
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_selected_tab(tabs)
|
def extract_selected_tab(tabs)
|
||||||
|
Loading…
Reference in New Issue
Block a user