2019-06-28 21:17:56 -05:00
|
|
|
def fetch_trending(trending_type, region, locale)
|
2018-11-20 11:18:12 -06:00
|
|
|
region ||= "US"
|
|
|
|
region = region.upcase
|
|
|
|
|
2019-04-14 19:04:10 -05:00
|
|
|
plid = nil
|
|
|
|
|
2021-06-24 00:08:40 +02:00
|
|
|
if trending_type == "Music"
|
|
|
|
params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
|
|
|
|
elsif trending_type == "Gaming"
|
|
|
|
params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
|
|
|
|
elsif trending_type == "Movies"
|
|
|
|
params = "4gIKGgh0cmFpbGVycw%3D%3D"
|
|
|
|
else # Default
|
|
|
|
params = ""
|
2018-11-20 11:18:12 -06:00
|
|
|
end
|
|
|
|
|
2021-08-03 02:58:27 +02:00
|
|
|
client_config = YoutubeAPI::ClientConfig.new(region: region)
|
|
|
|
initial_data = YoutubeAPI.browse("FEtrending", params: params, client_config: client_config)
|
2020-06-15 17:33:23 -05:00
|
|
|
trending = extract_videos(initial_data)
|
2018-11-20 11:18:12 -06:00
|
|
|
|
2019-04-14 19:04:10 -05:00
|
|
|
return {trending, plid}
|
|
|
|
end
|