mirror of
https://github.com/iv-org/invidious.git
synced 2025-10-29 04:08:31 -05:00
This commit adds a new parser for YT's shelfRenderers which are typically used to denote different categories.The code for featured channels parsing has also been moved to use the new parser but some additional refactoring are needed there. The ContinuationExtractor has also been improved and is now capable of extraction continuation data that is packaged under "appendContinuationItemsAction" In additional this commit adds some useful helper functions to extract the current selected tab the continuation token. This is to mainly reduce code size and repetition.
123 lines
6.7 KiB
Plaintext
123 lines
6.7 KiB
Plaintext
<% content_for "header" do %>
|
|
<title><%= channel.author %> - Invidious</title>
|
|
<link rel="stylesheet" href="/css/channel.css?v=<%= ASSET_COMMIT %>">
|
|
<% end %>
|
|
|
|
<% content_type = 4 %>
|
|
<% sort_options = Tuple.new %>
|
|
<%= rendered "components/channel-information" %>
|
|
|
|
<div class="pure-g h-box">
|
|
<% if !featured_channel_categories.empty? %>
|
|
<% featured_channel_categories.each do | category | %>
|
|
<div class="channel-section pure-u-1">
|
|
<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)%>">
|
|
<%= category.title %>
|
|
</a>
|
|
<%else%>
|
|
<%= category.title %>
|
|
<%end%>
|
|
</h3>
|
|
</summary>
|
|
<% contents = category.contents%>
|
|
<div class="pure-g section-contents">
|
|
<% if contents.is_a?(Array) %>
|
|
<% contents.each do |item|%>
|
|
<% if !item.is_a?(SearchChannel)%>
|
|
<% next %>
|
|
<% end %>
|
|
|
|
<div class="channel-profile pure-u-1 pure-u-sm-1-2 pure-u-md-1-3 pure-u-lg-1-4 pure-u-xl-1-5">
|
|
<a class="featured-channel-icon" href="/channel/<%= item.ucid %>">
|
|
<% if !env.get("preferences").as(Preferences).thin_mode %>
|
|
<img src="/ggpht<%= URI.parse(item.author_thumbnail).request_target.gsub(/=s\d+/, "=s176") %>"/>
|
|
<% end %>
|
|
</a>
|
|
<div class="featured-channel-about">
|
|
<p class="featured-channel-title"><a href="/channel/<%= item.ucid %>"><%= item.author %></a></p>
|
|
<div class="featured-channel-metadata">
|
|
<p><%= translate(locale, "`x` subscribers", number_with_separator(item.subscriber_count)) %></p>
|
|
<p><%= translate(locale, "`x` videos", number_with_separator(item.video_count)) %></p>
|
|
</div>
|
|
|
|
<% ucid = item.ucid %>
|
|
<% author = item.author %>
|
|
<% sub_count_text = number_to_short_text(item.subscriber_count) %>
|
|
<%= rendered "components/subscribe_widget" %>
|
|
</div>
|
|
</div>
|
|
<%end%>
|
|
<% elsif contents.is_a?(SearchItem) %>
|
|
<% if !contents.is_a?(SearchChannel)%>
|
|
<% next %>
|
|
<% end %>
|
|
|
|
<%item = contents %>
|
|
<div class="channel-profile large-featured-channel pure-u-1">
|
|
<a class="featured-channel-icon" href="/channel/<%= item.ucid %>">
|
|
<% if !env.get("preferences").as(Preferences).thin_mode %>
|
|
<img src="/ggpht<%= URI.parse(item.author_thumbnail).request_target.gsub(/=s\d+/, "=s176") %>"/>
|
|
<% end %>
|
|
</a>
|
|
<div class="featured-channel-about">
|
|
<p class="featured-channel-title"><a href="/channel/<%= item.ucid %>"><%= item.author %></a></p>
|
|
<div class="featured-channel-metadata">
|
|
<span><%= translate(locale, "`x` subscribers", number_with_separator(item.subscriber_count)) %></span>
|
|
<span class="seperator"> | </span>
|
|
<span><%= translate(locale, "`x` videos", number_with_separator(item.video_count)) %></span>
|
|
</div>
|
|
<p class="featured-channel-description"><%= item.description_html %></p>
|
|
|
|
<% ucid = contents.ucid %>
|
|
<% author = contents.author %>
|
|
<% sub_count_text = number_to_short_text(contents.subscriber_count) %>
|
|
<%= rendered "components/subscribe_widget" %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</details>
|
|
</div>
|
|
<% end %>
|
|
<% else %>
|
|
<h3 class="pure-u-1">
|
|
<%= translate(locale, "This channel doesn't feature any other channels.")%>
|
|
</h3>
|
|
<% end %>
|
|
</div>
|
|
|
|
<% if !featured_channel_categories.empty? %>
|
|
<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!)%>">
|
|
<%= translate(locale, "Previous page") %>
|
|
</a>
|
|
<% elsif (offset - 1) == 0 %>
|
|
<a href="/channel/<%=channel.ucid%>/channels/<%=category_param%>">
|
|
<%= translate(locale, "Previous page") %>
|
|
</a>
|
|
<% end %>
|
|
</div>
|
|
<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 = ""%>
|
|
<% if continuation %>
|
|
<% additional_url_param = "&previous=#{HTML.escape(continuation)}"%>
|
|
<% end %>
|
|
<% if !title %>
|
|
<% 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%>">
|
|
<%= translate(locale, "Next page") %>
|
|
</a>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|