Skip to content

Commit

Permalink
Channels: Support YouTube's change to from /community to /posts (#5183)
Browse files Browse the repository at this point in the history
  • Loading branch information
syeopite committed Feb 26, 2025
2 parents f9b9e85 + d706815 commit 58ad848
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}",
Expand Down
2 changes: 1 addition & 1 deletion src/invidious/frontend/channel_page.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Invidious::Frontend::ChannelPage
Releases
Courses
Playlists
Community
Posts
Channels
end

Expand Down
5 changes: 4 additions & 1 deletion src/invidious/routes/channels.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/invidious/routing.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/invidious/views/community.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down

0 comments on commit 58ad848

Please sign in to comment.