summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2022-08-10 00:14:26 +0200
committerSamantaz Fox <coding@samantaz.fr>2022-08-10 00:14:26 +0200
commit3ac4390d11d7eecbd49e3db79376942e8706783b (patch)
treeb5d72bd2c8444cdb865ea561a8341b833a62c479
parent389ae7a57395f1b3fbf540deebbad73d0674e715 (diff)
downloadinvidious-3ac4390d11d7eecbd49e3db79376942e8706783b.tar.gz
invidious-3ac4390d11d7eecbd49e3db79376942e8706783b.tar.bz2
invidious-3ac4390d11d7eecbd49e3db79376942e8706783b.zip
routing: move channel routes registration to Invidious::Routing
-rw-r--r--src/invidious.cr21
-rw-r--r--src/invidious/routing.cr23
2 files changed, 24 insertions, 20 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index f244cea5..969804a6 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -334,26 +334,7 @@ end
Invidious::Routing.get "/privacy", Invidious::Routes::Misc, :privacy
Invidious::Routing.get "/licenses", Invidious::Routes::Misc, :licenses
- Invidious::Routing.get "/channel/:ucid", Invidious::Routes::Channels, :home
- Invidious::Routing.get "/channel/:ucid/home", Invidious::Routes::Channels, :home
- Invidious::Routing.get "/channel/:ucid/videos", Invidious::Routes::Channels, :videos
- Invidious::Routing.get "/channel/:ucid/playlists", Invidious::Routes::Channels, :playlists
- Invidious::Routing.get "/channel/:ucid/community", Invidious::Routes::Channels, :community
- Invidious::Routing.get "/channel/:ucid/about", Invidious::Routes::Channels, :about
- Invidious::Routing.get "/channel/:ucid/live", Invidious::Routes::Channels, :live
- Invidious::Routing.get "/user/:user/live", Invidious::Routes::Channels, :live
- Invidious::Routing.get "/c/:user/live", Invidious::Routes::Channels, :live
-
- ["", "/videos", "/playlists", "/community", "/about"].each do |path|
- # /c/LinusTechTips
- Invidious::Routing.get "/c/:user#{path}", Invidious::Routes::Channels, :brand_redirect
- # /user/linustechtips | Not always the same as /c/
- Invidious::Routing.get "/user/:user#{path}", Invidious::Routes::Channels, :brand_redirect
- # /attribution_link?a=anything&u=/channel/UCZYTClx2T1of7BRZ86-8fow
- Invidious::Routing.get "/attribution_link#{path}", Invidious::Routes::Channels, :brand_redirect
- # /profile?user=linustechtips
- Invidious::Routing.get "/profile/#{path}", Invidious::Routes::Channels, :profile
- end
+ Invidious::Routing.register_channel_routes
Invidious::Routing.get "/watch", Invidious::Routes::Watch, :handle
Invidious::Routing.post "/watch_ajax", Invidious::Routes::Watch, :mark_watched
diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr
index 25cbfa48..203aa024 100644
--- a/src/invidious/routing.cr
+++ b/src/invidious/routing.cr
@@ -48,6 +48,29 @@ module Invidious::Routing
# Youtube routes
# -------------------
+ def register_channel_routes
+ get "/channel/:ucid", Routes::Channels, :home
+ get "/channel/:ucid/home", Routes::Channels, :home
+ get "/channel/:ucid/videos", Routes::Channels, :videos
+ get "/channel/:ucid/playlists", Routes::Channels, :playlists
+ get "/channel/:ucid/community", Routes::Channels, :community
+ get "/channel/:ucid/about", Routes::Channels, :about
+ get "/channel/:ucid/live", Routes::Channels, :live
+ get "/user/:user/live", Routes::Channels, :live
+ get "/c/:user/live", Routes::Channels, :live
+
+ ["", "/videos", "/playlists", "/community", "/about"].each do |path|
+ # /c/LinusTechTips
+ get "/c/:user#{path}", Routes::Channels, :brand_redirect
+ # /user/linustechtips | Not always the same as /c/
+ get "/user/:user#{path}", Routes::Channels, :brand_redirect
+ # /attribution_link?a=anything&u=/channel/UCZYTClx2T1of7BRZ86-8fow
+ get "/attribution_link#{path}", Routes::Channels, :brand_redirect
+ # /profile?user=linustechtips
+ get "/profile/#{path}", Routes::Channels, :profile
+ end
+ end
+
def register_api_manifest_routes
get "/api/manifest/dash/id/:id", Routes::API::Manifest, :get_dash_video_id