mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-13 16:18:29 +00:00
Update channel routing logic to use a module
This commit is contained in:
parent
e8ab18f0e8
commit
f735e87756
@ -1,9 +1,9 @@
|
|||||||
class Invidious::Routes::Channels < Invidious::Routes::BaseRoute
|
module Invidious::Routes::Channels
|
||||||
def home(env)
|
def self.home(env)
|
||||||
self.videos(env)
|
self.videos(env)
|
||||||
end
|
end
|
||||||
|
|
||||||
def videos(env)
|
def self.videos(env)
|
||||||
data = self.fetch_basic_information(env)
|
data = self.fetch_basic_information(env)
|
||||||
if !data.is_a?(Tuple)
|
if !data.is_a?(Tuple)
|
||||||
return data
|
return data
|
||||||
@ -40,7 +40,7 @@ class Invidious::Routes::Channels < Invidious::Routes::BaseRoute
|
|||||||
templated "channel"
|
templated "channel"
|
||||||
end
|
end
|
||||||
|
|
||||||
def playlists(env)
|
def self.playlists(env)
|
||||||
data = self.fetch_basic_information(env)
|
data = self.fetch_basic_information(env)
|
||||||
if !data.is_a?(Tuple)
|
if !data.is_a?(Tuple)
|
||||||
return data
|
return data
|
||||||
@ -62,7 +62,7 @@ class Invidious::Routes::Channels < Invidious::Routes::BaseRoute
|
|||||||
templated "playlists"
|
templated "playlists"
|
||||||
end
|
end
|
||||||
|
|
||||||
def community(env)
|
def self.community(env)
|
||||||
data = self.fetch_basic_information(env)
|
data = self.fetch_basic_information(env)
|
||||||
if !data.is_a?(Tuple)
|
if !data.is_a?(Tuple)
|
||||||
return data
|
return data
|
||||||
@ -91,7 +91,7 @@ class Invidious::Routes::Channels < Invidious::Routes::BaseRoute
|
|||||||
templated "community"
|
templated "community"
|
||||||
end
|
end
|
||||||
|
|
||||||
def about(env)
|
def self.about(env)
|
||||||
data = self.fetch_basic_information(env)
|
data = self.fetch_basic_information(env)
|
||||||
if !data.is_a?(Tuple)
|
if !data.is_a?(Tuple)
|
||||||
return data
|
return data
|
||||||
@ -102,7 +102,7 @@ class Invidious::Routes::Channels < Invidious::Routes::BaseRoute
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Redirects brand url channels to a normal /channel/:ucid route
|
# Redirects brand url channels to a normal /channel/:ucid route
|
||||||
def brand_redirect(env)
|
def self.brand_redirect(env)
|
||||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||||
|
|
||||||
# /attribution_link endpoint needs both the `a` and `u` parameter
|
# /attribution_link endpoint needs both the `a` and `u` parameter
|
||||||
@ -131,7 +131,7 @@ class Invidious::Routes::Channels < Invidious::Routes::BaseRoute
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Handles redirects for the /profile endpoint
|
# Handles redirects for the /profile endpoint
|
||||||
def profile(env)
|
def self.profile(env)
|
||||||
# The /profile endpoint is special. If passed into the resolve_url
|
# The /profile endpoint is special. If passed into the resolve_url
|
||||||
# endpoint YouTube would return a sign in page instead of an /channel/:ucid
|
# endpoint YouTube would return a sign in page instead of an /channel/:ucid
|
||||||
# thus we'll add an edge case and handle it here.
|
# thus we'll add an edge case and handle it here.
|
||||||
@ -146,7 +146,7 @@ class Invidious::Routes::Channels < Invidious::Routes::BaseRoute
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private def fetch_basic_information(env)
|
private def self.fetch_basic_information(env)
|
||||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||||
|
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
|
Loading…
Reference in New Issue
Block a user