mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-08-14.git
synced 2024-08-15 00:53:20 +00:00
Fix trending API
This commit is contained in:
parent
533c6cefee
commit
a7624d4724
1 changed files with 11 additions and 13 deletions
|
@ -6,24 +6,22 @@ def fetch_trending(trending_type, region, locale)
|
||||||
plid = nil
|
plid = nil
|
||||||
|
|
||||||
if trending_type && trending_type != "Default"
|
if trending_type && trending_type != "Default"
|
||||||
trending_type = trending_type.downcase.capitalize
|
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
|
response = YT_POOL.client &.get("/feed/trending?gl=#{region}&hl=en").body
|
||||||
|
|
||||||
initial_data = extract_initial_data(response)
|
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"
|
||||||
|
|
||||||
tabs = initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"][0]["tabRenderer"]["content"]["sectionListRenderer"]["subMenu"]["channelListSubMenuRenderer"]["contents"].as_a
|
trending = YT_POOL.client &.get(url).body
|
||||||
url = tabs.select { |tab| tab["channelListSubMenuAvatarRenderer"]["title"]["simpleText"] == trending_type }[0]?
|
plid = extract_plid(url)
|
||||||
|
|
||||||
if url
|
|
||||||
url["channelListSubMenuAvatarRenderer"]["navigationEndpoint"]["commandMetadata"]["webCommandMetadata"]["url"]
|
|
||||||
url = url["channelListSubMenuAvatarRenderer"]["navigationEndpoint"]["commandMetadata"]["webCommandMetadata"]["url"].as_s
|
|
||||||
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
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
trending = YT_POOL.client &.get("/feed/trending?gl=#{region}&hl=en").body
|
trending = YT_POOL.client &.get("/feed/trending?gl=#{region}&hl=en").body
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue