diff --git a/src/invidious.cr b/src/invidious.cr index c771d406..0316b10d 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -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| diff --git a/src/invidious/helpers/serialized_yt_data.cr b/src/invidious/helpers/serialized_yt_data.cr index 61356555..20ef7267 100644 --- a/src/invidious/helpers/serialized_yt_data.cr +++ b/src/invidious/helpers/serialized_yt_data.cr @@ -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 diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index 1d2ab2c6..b64fb7a8 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -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 diff --git a/src/invidious/views/channel/featured_channels.ecr b/src/invidious/views/channel/featured_channels.ecr index e2e49d24..a936a01a 100644 --- a/src/invidious/views/channel/featured_channels.ecr +++ b/src/invidious/views/channel/featured_channels.ecr @@ -14,8 +14,9 @@

- <% if (category_request_param = category.browse_endpoint_data).is_a?(String) %> - + <% if category.auxiliary_data.has_key?("view") %> + <% category_url_param = "?view=#{category.auxiliary_data["view"]}&shelf_id=#{category.auxiliary_data["shelf_id"]}" %> + <%= category.title %> <%else%> @@ -90,14 +91,15 @@ <% if !featured_channel_categories.empty? %> + <% base_url = "/channel/#{channel.ucid}/channels?view=#{view}&shelf_id=#{shelf_id}" %>
<% if previous_continuation %> - + <%= translate(locale, "Previous page") %> <% elsif (offset - 1) == 0 %> - + <%= translate(locale, "Previous page") %> <% end %> @@ -105,15 +107,15 @@
<% 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 %> - + <%= translate(locale, "Next page") %> <% end %>