mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2026-01-06 23:11:26 +00:00
26 lines
686 B
Crystal
26 lines
686 B
Crystal
def fetch_trending(trending_type, region, locale)
|
|
region ||= "US"
|
|
region = region.upcase
|
|
|
|
plid = nil
|
|
|
|
case trending_type.try &.downcase
|
|
when "music"
|
|
params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
|
|
when "gaming"
|
|
params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
|
|
when "movies"
|
|
params = "4gIKGgh0cmFpbGVycw%3D%3D"
|
|
else # Default
|
|
params = ""
|
|
end
|
|
|
|
client_config = YoutubeAPI::ClientConfig.new(region: region)
|
|
initial_data = YoutubeAPI.browse("FEtrending", params: params, client_config: client_config)
|
|
|
|
items, _ = extract_items(initial_data)
|
|
|
|
# Return items, but ignore categories (e.g featured content)
|
|
return items.reject!(Category), plid
|
|
end
|