Channels: Support YouTube's change to from /community to /posts (#5183)

This commit is contained in:
syeopite 2025-02-26 14:13:22 -08:00
commit 58ad848d56
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A
5 changed files with 9 additions and 3 deletions

View File

@ -496,6 +496,7 @@
"channel_tab_courses_label": "Courses",
"channel_tab_playlists_label": "Playlists",
"channel_tab_community_label": "Community",
"channel_tab_posts_label": "Posts",
"channel_tab_channels_label": "Channels",
"toggle_theme": "Toggle Theme",
"carousel_slide": "Slide {{current}} of {{total}}",

View File

@ -9,7 +9,7 @@ module Invidious::Frontend::ChannelPage
Releases
Courses
Playlists
Community
Posts
Channels
end

View File

@ -218,6 +218,8 @@ module Invidious::Routes::Channels
end
def self.community(env)
return env.redirect env.request.path.sub("posts", "community") if env.request.path.split("/").last == "posts"
data = self.fetch_basic_information(env)
if !data.is_a?(Tuple)
return data
@ -234,7 +236,7 @@ module Invidious::Routes::Channels
continuation = env.params.query["continuation"]?
if !channel.tabs.includes? "community"
if !channel.tabs.includes? "community" && "posts"
return env.redirect "/channel/#{channel.ucid}"
end
@ -328,6 +330,7 @@ module Invidious::Routes::Channels
private KNOWN_TABS = {
"home", "videos", "shorts", "streams", "podcasts",
"releases", "courses", "playlists", "community", "channels", "about",
"posts",
}
# Redirects brand url channels to a normal /channel/:ucid route

View File

@ -123,6 +123,7 @@ module Invidious::Routing
get "/channel/:ucid/courses", Routes::Channels, :courses
get "/channel/:ucid/playlists", Routes::Channels, :playlists
get "/channel/:ucid/community", Routes::Channels, :community
get "/channel/:ucid/posts", Routes::Channels, :community
get "/channel/:ucid/channels", Routes::Channels, :channels
get "/channel/:ucid/about", Routes::Channels, :about
@ -254,6 +255,7 @@ module Invidious::Routing
get "/api/v1/channels/:ucid/courses", {{namespace}}::Channels, :courses
get "/api/v1/channels/:ucid/playlists", {{namespace}}::Channels, :playlists
get "/api/v1/channels/:ucid/community", {{namespace}}::Channels, :community
get "/api/v1/channels/:ucid/posts", {{namespace}}::Channels, :community
get "/api/v1/channels/:ucid/channels", {{namespace}}::Channels, :channels
get "/api/v1/channels/:ucid/search", {{namespace}}::Channels, :search

View File

@ -7,7 +7,7 @@
youtube_url = "https://www.youtube.com#{relative_url}"
redirect_url = Invidious::Frontend::Misc.redirect_url(env)
selected_tab = Invidious::Frontend::ChannelPage::TabsAvailable::Community
selected_tab = Invidious::Frontend::ChannelPage::TabsAvailable::Posts
-%>
<% content_for "header" do %>