mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-23 22:39:31 -05:00
Trending: fix mistakes from #3773
This commit is contained in:
parent
97e3938f5f
commit
384a8e200c
@ -20,6 +20,20 @@ def fetch_trending(trending_type, region, locale)
|
|||||||
|
|
||||||
items, _ = extract_items(initial_data)
|
items, _ = extract_items(initial_data)
|
||||||
|
|
||||||
# Return items, but ignore categories (e.g featured content)
|
extracted = [] of SearchItem
|
||||||
return items.reject!(Category), plid
|
|
||||||
|
items.each do |itm|
|
||||||
|
if itm.is_a?(Category)
|
||||||
|
# Ignore the smaller categories, as they generally contain a sponsored
|
||||||
|
# channel, which brings a lot of noise on the trending page.
|
||||||
|
# See: https://github.com/iv-org/invidious/issues/2989
|
||||||
|
next if itm.contents.size < 24
|
||||||
|
|
||||||
|
extracted.concat extract_category(itm)
|
||||||
|
else
|
||||||
|
extracted << itm
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return extracted, plid
|
||||||
end
|
end
|
||||||
|
@ -68,16 +68,17 @@ rescue ex
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
# This function extracts the SearchItems from a Category.
|
# This function extracts SearchVideo items from a Category.
|
||||||
# Categories are commonly returned in search results and trending pages.
|
# Categories are commonly returned in search results and trending pages.
|
||||||
def extract_category(category : Category) : Array(SearchVideo)
|
def extract_category(category : Category) : Array(SearchVideo)
|
||||||
items = [] of SearchItem
|
return category.contents.select(SearchVideo)
|
||||||
|
end
|
||||||
|
|
||||||
category.contents.each do |item|
|
# :ditto:
|
||||||
target << cate_i if item.is_a?(SearchItem)
|
def extract_category(category : Category, &)
|
||||||
|
category.contents.select(SearchVideo).each do |item|
|
||||||
|
yield item
|
||||||
end
|
end
|
||||||
|
|
||||||
return items
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_selected_tab(tabs)
|
def extract_selected_tab(tabs)
|
||||||
|
Loading…
Reference in New Issue
Block a user