forked from midou/invidious
Merge pull request #1945 from syeopite/trending-api-fix
Fix Trending API
This commit is contained in:
commit
be8a4013a7
@ -6,27 +6,25 @@ 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"]
|
||||||
tabs = initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"][0]["tabRenderer"]["content"]["sectionListRenderer"]["subMenu"]["channelListSubMenuRenderer"]["contents"].as_a
|
|
||||||
url = tabs.select { |tab| tab["channelListSubMenuAvatarRenderer"]["title"]["simpleText"] == trending_type }[0]?
|
|
||||||
|
|
||||||
if url
|
|
||||||
url["channelListSubMenuAvatarRenderer"]["navigationEndpoint"]["commandMetadata"]["webCommandMetadata"]["url"]
|
|
||||||
url = url["channelListSubMenuAvatarRenderer"]["navigationEndpoint"]["commandMetadata"]["webCommandMetadata"]["url"].as_s
|
|
||||||
url = "#{url}&gl=#{region}&hl=en"
|
url = "#{url}&gl=#{region}&hl=en"
|
||||||
|
|
||||||
trending = YT_POOL.client &.get(url).body
|
trending = YT_POOL.client &.get(url).body
|
||||||
plid = extract_plid(url)
|
plid = extract_plid(url)
|
||||||
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
|
||||||
else
|
|
||||||
trending = YT_POOL.client &.get("/feed/trending?gl=#{region}&hl=en").body
|
|
||||||
end
|
|
||||||
|
|
||||||
initial_data = extract_initial_data(trending)
|
initial_data = extract_initial_data(trending)
|
||||||
trending = extract_videos(initial_data)
|
trending = extract_videos(initial_data)
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1-3">
|
<div class="pure-u-1-3">
|
||||||
<div class="pure-g" style="text-align:right">
|
<div class="pure-g" style="text-align:right">
|
||||||
<% {"Default", "Music", "Gaming", "News", "Movies"}.each do |option| %>
|
<% {"Default", "Music", "Gaming", "Movies"}.each do |option| %>
|
||||||
<div class="pure-u-1 pure-md-1-3">
|
<div class="pure-u-1 pure-md-1-3">
|
||||||
<% if trending_type == option %>
|
<% if trending_type == option %>
|
||||||
<b><%= translate(locale, option) %></b>
|
<b><%= translate(locale, option) %></b>
|
||||||
|
Loading…
Reference in New Issue
Block a user