2019-06-29 11:17:56 +09:00
|
|
|
def fetch_trending(trending_type, region, locale)
|
2018-11-21 02:18:12 +09:00
|
|
|
region ||= "US"
|
|
|
|
region = region.upcase
|
|
|
|
|
2019-04-15 09:04:10 +09:00
|
|
|
plid = nil
|
|
|
|
|
2023-02-11 22:41:26 +09:00
|
|
|
case trending_type.try &.downcase
|
|
|
|
when "music"
|
2021-06-24 07:08:40 +09:00
|
|
|
params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
|
2023-02-11 22:41:26 +09:00
|
|
|
when "gaming"
|
2021-06-24 07:08:40 +09:00
|
|
|
params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
|
2023-02-11 22:41:26 +09:00
|
|
|
when "movies"
|
2021-06-24 07:08:40 +09:00
|
|
|
params = "4gIKGgh0cmFpbGVycw%3D%3D"
|
|
|
|
else # Default
|
|
|
|
params = ""
|
2018-11-21 02:18:12 +09:00
|
|
|
end
|
|
|
|
|
2021-08-03 09:58:27 +09:00
|
|
|
client_config = YoutubeAPI::ClientConfig.new(region: region)
|
|
|
|
initial_data = YoutubeAPI.browse("FEtrending", params: params, client_config: client_config)
|
2018-11-21 02:18:12 +09:00
|
|
|
|
2023-04-29 00:23:40 +09:00
|
|
|
items, _ = extract_items(initial_data)
|
|
|
|
|
|
|
|
# Return items, but ignore categories (e.g featured content)
|
|
|
|
return items.reject!(Category), plid
|
2019-04-15 09:04:10 +09:00
|
|
|
end
|