Make feat. chan page URL to compatible with yt

This commit is contained in:
syeopite 2021-05-08 02:41:16 -07:00
parent e93b7789f7
commit 0863d83574
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82
4 changed files with 25 additions and 16 deletions

View file

@ -323,7 +323,6 @@ end
Invidious::Routing.get "/channel/:ucid/playlists", Invidious::Routes::Channels, :playlists
Invidious::Routing.get "/channel/:ucid/community", Invidious::Routes::Channels, :community
Invidious::Routing.get "/channel/:ucid/channels", Invidious::Routes::Channels, :channels
Invidious::Routing.get "/channel/:ucid/channels/:param", Invidious::Routes::Channels, :featured_channel_category
Invidious::Routing.get "/channel/:ucid/about", Invidious::Routes::Channels, :about
["", "/videos", "/playlists", "/community", "/about"].each do |path|

View file

@ -235,6 +235,9 @@ class Category
property description_html : String
property badges : Array(Tuple(String, String))?
# Data unique to only specific types of categories.
property auxiliary_data : Hash(String, String)
def to_json(locale, json : JSON::Builder)
json.object do
json.field "title", self.title

View file

@ -113,17 +113,22 @@ module Invidious::Routes::Channels
# Previous continuation
previous_continuation = env.params.query["previous"]?
# Category title is not returned when using a continuation token.
title = env.params.query["title"]?
featured_channel_categories = fetch_channel_featured_channels(ucid, channel.tabs["channels"], nil, continuation, title).not_nil!
featured_channel_categories = fetch_channel_featured_channels(ucid, channel.tabs["channels"], nil, nil, continuation, current_category_title).not_nil!
elsif view && shelf_id
offset = env.params.query["offset"]?
if offset
offset = offset.to_i
else
offset = 0
end
featured_channel_categories = fetch_channel_featured_channels(ucid, channel.tabs["channels"], view, shelf_id, continuation, current_category_title).not_nil!
else
previous_continuation = nil
category_param = nil
offset = 0
title = nil
featured_channel_categories = fetch_channel_featured_channels(ucid, channel.tabs["channels"], nil, nil).not_nil!
featured_channel_categories = fetch_channel_featured_channels(ucid, channel.tabs["channels"], nil, nil, current_category_title).not_nil!
end
templated "channel/featured_channels", buffer_footer: true

View file

@ -14,8 +14,9 @@
<details open="">
<summary style="display: revert;">
<h3 class="category-heading">
<% if (category_request_param = category.browse_endpoint_data).is_a?(String) %>
<a href="/channel/<%=channel.ucid%>/channels/<%=HTML.escape(category_request_param)%>">
<% if category.auxiliary_data.has_key?("view") %>
<% category_url_param = "?view=#{category.auxiliary_data["view"]}&shelf_id=#{category.auxiliary_data["shelf_id"]}" %>
<a href="/channel/<%=channel.ucid%>/channels<%=HTML.escape(category_url_param)%>">
<%= category.title %>
</a>
<%else%>
@ -90,14 +91,15 @@
</div>
<% if !featured_channel_categories.empty? %>
<% base_url = "/channel/#{channel.ucid}/channels?view=#{view}&shelf_id=#{shelf_id}" %>
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-lg-1-5">
<% if previous_continuation %>
<a href="/channel/<%=channel.ucid%>/channels/<%=category_param%>?continuation=<%=HTML.escape(previous_continuation)%>&offset=<%=offset.not_nil!-1%>&title=<%=HTML.escape(title.not_nil!)%>">
<a href="<%= base_url %>&continuation=<%=HTML.escape(previous_continuation)%>&offset=<%=offset.not_nil!-1%>&title=<%=HTML.escape(current_category_title.not_nil!)%>">
<%= translate(locale, "Previous page") %>
</a>
<% elsif (offset - 1) == 0 %>
<a href="/channel/<%=channel.ucid%>/channels/<%=category_param%>">
<a href="<%= base_url %>">
<%= translate(locale, "Previous page") %>
</a>
<% end %>
@ -105,15 +107,15 @@
<div class="pure-u-1 pure-u-lg-3-5"></div>
<div class="pure-u-1 pure-u-lg-1-5" style="text-align:right">
<% if (next_cont_token = featured_channel_categories[0].continuation_token) %>
<% additional_url_param = ""%>
<% previous = ""%>
<% if continuation %>
<% additional_url_param = "&previous=#{HTML.escape(continuation)}"%>
<% previous = "&previous=#{HTML.escape(continuation)}"%>
<% end %>
<% if !title %>
<% title = featured_channel_categories[0].title %>
<% if !current_category_title %>
<% current_category_title = featured_channel_categories[0].title %>
<% end %>
<a href="/channel/<%=channel.ucid%>/channels/<%=category_param%>?continuation=<%=HTML.escape(next_cont_token)%>&offset=<%=offset.not_nil!+1%>&title=<%=HTML.escape(title)%><%=additional_url_param%>">
<a href="<%= base_url %>&continuation=<%=HTML.escape(next_cont_token)%>&offset=<%=offset.not_nil!+1%>&title=<%=HTML.escape(current_category_title)%><%=previous%>">
<%= translate(locale, "Next page") %>
</a>
<% end %>