mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-21 18:38:50 +00:00
Use youtubei API for trending
This commit is contained in:
@@ -2,31 +2,19 @@ def fetch_trending(trending_type, region, locale)
|
||||
region ||= "US"
|
||||
region = region.upcase
|
||||
|
||||
trending = ""
|
||||
plid = nil
|
||||
|
||||
if trending_type && trending_type != "Default"
|
||||
if trending_type == "Music"
|
||||
trending_type = 1
|
||||
elsif trending_type == "Gaming"
|
||||
trending_type = 2
|
||||
elsif trending_type == "Movies"
|
||||
trending_type = 3
|
||||
end
|
||||
|
||||
response = YT_POOL.client &.get("/feed/trending?gl=#{region}&hl=en").body
|
||||
|
||||
initial_data = extract_initial_data(response)
|
||||
url = initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"][trending_type]["tabRenderer"]["endpoint"]["commandMetadata"]["webCommandMetadata"]["url"]
|
||||
url = "#{url}&gl=#{region}&hl=en"
|
||||
|
||||
trending = YT_POOL.client &.get(url).body
|
||||
plid = extract_plid(url)
|
||||
else
|
||||
trending = YT_POOL.client &.get("/feed/trending?gl=#{region}&hl=en").body
|
||||
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 = ""
|
||||
end
|
||||
|
||||
initial_data = extract_initial_data(trending)
|
||||
initial_data = request_youtube_api_browse("FEtrending", params: params, region: region)
|
||||
trending = extract_videos(initial_data)
|
||||
|
||||
return {trending, plid}
|
||||
|
||||
Reference in New Issue
Block a user