Replace channel tab param fetch with hardcoded ones

This commit is contained in:
syeopite 2021-06-24 18:12:07 -07:00
parent a082fad184
commit aaff30e6d2
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82
3 changed files with 9 additions and 14 deletions

View file

@ -16,7 +16,7 @@ struct AboutChannel
property is_family_friendly : Bool
property allowed_regions : Array(String)
property related_channels : Array(AboutRelatedChannel)
property tabs : Hash(String, Tuple(Int32, String)) # TabName => {TabiZZndex, browseEndpoint params}
property tabs : Array(String)
property links : Array(Tuple(String, String, String))
end
@ -124,7 +124,7 @@ def get_about_info(ucid, locale)
country = ""
total_views = 0_i64
joined = Time.unix(0)
tabs = {} of String => Tuple(Int32, String) # TabName => {TabiZZndex, browseEndpoint params}
tabs = [] of String
links = [] of {String, String, String}
tabs_json = initdata["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]?.try &.as_a?
@ -175,14 +175,9 @@ def get_about_info(ucid, locale)
auto_generated = true
end
end
if node["tabRenderer"]?
tab_names << node["tabRenderer"]["title"].as_s.downcase
tab_data << {i, node["tabRenderer"]["endpoint"]["browseEndpoint"]["params"].as_s}
end
end
tabs = Hash.zip(tab_names, tab_data)
tabs = tabs_json.reject { |node| node["tabRenderer"]?.nil? }.map { |node| node["tabRenderer"]["title"].as_s.downcase }
end
sub_count = initdata["header"]["c4TabbedHeaderRenderer"]?.try &.["subscriberCountText"]?.try &.["simpleText"]?.try &.as_s?

View file

@ -87,7 +87,7 @@ module Invidious::Routes::Channels
continuation = env.params.query["continuation"]?
# sort_by = env.params.query["sort_by"]?.try &.downcase
if !channel.tabs.has_key?("community")
if !channel.tabs.includes?("community")
return env.redirect "/channel/#{channel.ucid}"
end
@ -110,7 +110,7 @@ module Invidious::Routes::Channels
end
locale, user, subscriptions, continuation, ucid, channel = data
if !channel.tabs.has_key?("channels")
if !channel.tabs.includes?("channels")
return env.redirect "/channel/#{channel.ucid}"
end
@ -126,7 +126,7 @@ module Invidious::Routes::Channels
# Previous continuation
previous_continuation = env.params.query["previous"]?
featured_channel_categories, continuation_token = fetch_channel_featured_channels(ucid, channel.tabs["channels"], nil, nil, continuation, current_category_title).not_nil!
featured_channel_categories, continuation_token = fetch_channel_featured_channels(ucid, "EghjaGFubmVscw%3D%3D", nil, nil, continuation, current_category_title).not_nil!
elsif view && shelf_id
offset = env.params.query["offset"]?
if offset
@ -135,12 +135,12 @@ module Invidious::Routes::Channels
offset = 0
end
featured_channel_categories, continuation_token = fetch_channel_featured_channels(ucid, channel.tabs["channels"], view, shelf_id, continuation, current_category_title).not_nil!
featured_channel_categories, continuation_token = fetch_channel_featured_channels(ucid, "EghjaGFubmVscw%3D%3D", view, shelf_id, continuation, current_category_title).not_nil!
else
previous_continuation = nil
offset = 0
featured_channel_categories, continuation_token = fetch_channel_featured_channels(ucid, channel.tabs["channels"], nil, nil, current_category_title).not_nil!
featured_channel_categories, continuation_token = fetch_channel_featured_channels(ucid, "EghjaGFubmVscw%3D%3D", nil, nil, current_category_title).not_nil!
end
templated "channel/featured_channels", buffer_footer: true

View file

@ -104,7 +104,7 @@
</li>
<% end %>
<% if channel.tabs.has_key?("community") %>
<% if channel.tabs.includes?("community") %>
<% if content_type == 3 %>
<li class="pure-menu-item pure-menu-selected">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/community">