mirror of
https://github.com/iv-org/invidious.git
synced 2025-04-22 16:29:10 -04:00
Add separate handler for /profile endpoint
This commit is contained in:
parent
bf6b9a0b86
commit
6d8e8c4c79
@ -319,7 +319,7 @@ Invidious::Routing.get "/channel/:ucid/about", Invidious::Routes::Channels, :abo
|
||||
Invidious::Routing.get "/c/:user#{path}", Invidious::Routes::Channels, :brand_redirect
|
||||
Invidious::Routing.get "/user/:user#{path}", Invidious::Routes::Channels, :brand_redirect
|
||||
Invidious::Routing.get "/attribution_link#{path}", Invidious::Routes::Channels, :brand_redirect
|
||||
Invidious::Routing.get "/profile/:user#{path}", Invidious::Routes::Channels, :brand_redirect
|
||||
Invidious::Routing.get "/profile/#{path}", Invidious::Routes::Channels, :profile
|
||||
end
|
||||
|
||||
Invidious::Routing.get "/watch", Invidious::Routes::Watch, :handle
|
||||
|
@ -105,7 +105,6 @@ class Invidious::Routes::Channels < Invidious::Routes::BaseRoute
|
||||
def brand_redirect(env)
|
||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||
|
||||
# /profile endpoint uses the `user` parameter
|
||||
# /attribution_link endpoint needs both the `a` and `u` parameter
|
||||
# and in order to avoid detection from YouTube we should only send the required ones
|
||||
# without any of the additional url parameters that only Invidious uses.
|
||||
@ -132,6 +131,22 @@ class Invidious::Routes::Channels < Invidious::Routes::BaseRoute
|
||||
env.redirect url
|
||||
end
|
||||
|
||||
# Handles redirects for the /profile endpoint
|
||||
def profile(env)
|
||||
# The /profile endpoint is special. If passed into the resolve_url
|
||||
# endpoint YouTube would return a sign in page instead of an /channel/:ucid
|
||||
# thus we'll add an edge case and handle it here.
|
||||
|
||||
uri_params = env.params.query.size > 0 ? "?#{env.params.query}" : ""
|
||||
|
||||
user = env.params.query["user"]?
|
||||
if !user
|
||||
raise InfoException.new("This channel does not exist.")
|
||||
else
|
||||
env.redirect "/user/#{user}#{uri_params}"
|
||||
end
|
||||
end
|
||||
|
||||
private def fetch_basic_information(env)
|
||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user