routing: register playback routes with a function, rather than a macro
This commit is contained in:
parent
176247091d
commit
389ae7a573
|
@ -423,8 +423,8 @@ Invidious::Routing.get "/vi/:id/:name", Invidious::Routes::Images, :thumbnails
|
|||
Invidious::Routing.register_api_v1_routes
|
||||
|
||||
# Video playback (macros)
|
||||
define_api_manifest_routes()
|
||||
define_video_playback_routes()
|
||||
Invidious::Routing.register_api_manifest_routes
|
||||
Invidious::Routing.register_video_playback_routes
|
||||
|
||||
error 404 do |env|
|
||||
if md = env.request.path.match(/^\/(?<id>([a-zA-Z0-9_-]{11})|(\w+))$/)
|
||||
|
|
|
@ -44,6 +44,33 @@ module Invidious::Routing
|
|||
get "/subscription_manager", Routes::Subscriptions, :subscription_manager
|
||||
end
|
||||
|
||||
# -------------------
|
||||
# Youtube routes
|
||||
# -------------------
|
||||
|
||||
def register_api_manifest_routes
|
||||
get "/api/manifest/dash/id/:id", Routes::API::Manifest, :get_dash_video_id
|
||||
|
||||
get "/api/manifest/dash/id/videoplayback", Routes::API::Manifest, :get_dash_video_playback
|
||||
get "/api/manifest/dash/id/videoplayback/*", Routes::API::Manifest, :get_dash_video_playback_greedy
|
||||
|
||||
options "/api/manifest/dash/id/videoplayback", Routes::API::Manifest, :options_dash_video_playback
|
||||
options "/api/manifest/dash/id/videoplayback/*", Routes::API::Manifest, :options_dash_video_playback
|
||||
|
||||
get "/api/manifest/hls_playlist/*", Routes::API::Manifest, :get_hls_playlist
|
||||
get "/api/manifest/hls_variant/*", Routes::API::Manifest, :get_hls_variant
|
||||
end
|
||||
|
||||
def register_video_playback_routes
|
||||
get "/videoplayback", Routes::VideoPlayback, :get_video_playback
|
||||
get "/videoplayback/*", Routes::VideoPlayback, :get_video_playback_greedy
|
||||
|
||||
options "/videoplayback", Routes::VideoPlayback, :options_video_playback
|
||||
options "/videoplayback/*", Routes::VideoPlayback, :options_video_playback
|
||||
|
||||
get "/latest_version", Routes::VideoPlayback, :latest_version
|
||||
end
|
||||
|
||||
# -------------------
|
||||
# API routes
|
||||
# -------------------
|
||||
|
@ -116,26 +143,3 @@ module Invidious::Routing
|
|||
{% end %}
|
||||
end
|
||||
end
|
||||
|
||||
macro define_api_manifest_routes
|
||||
Invidious::Routing.get "/api/manifest/dash/id/:id", Invidious::Routes::API::Manifest, :get_dash_video_id
|
||||
|
||||
Invidious::Routing.get "/api/manifest/dash/id/videoplayback", Invidious::Routes::API::Manifest, :get_dash_video_playback
|
||||
Invidious::Routing.get "/api/manifest/dash/id/videoplayback/*", Invidious::Routes::API::Manifest, :get_dash_video_playback_greedy
|
||||
|
||||
Invidious::Routing.options "/api/manifest/dash/id/videoplayback", Invidious::Routes::API::Manifest, :options_dash_video_playback
|
||||
Invidious::Routing.options "/api/manifest/dash/id/videoplayback/*", Invidious::Routes::API::Manifest, :options_dash_video_playback
|
||||
|
||||
Invidious::Routing.get "/api/manifest/hls_playlist/*", Invidious::Routes::API::Manifest, :get_hls_playlist
|
||||
Invidious::Routing.get "/api/manifest/hls_variant/*", Invidious::Routes::API::Manifest, :get_hls_variant
|
||||
end
|
||||
|
||||
macro define_video_playback_routes
|
||||
Invidious::Routing.get "/videoplayback", Invidious::Routes::VideoPlayback, :get_video_playback
|
||||
Invidious::Routing.get "/videoplayback/*", Invidious::Routes::VideoPlayback, :get_video_playback_greedy
|
||||
|
||||
Invidious::Routing.options "/videoplayback", Invidious::Routes::VideoPlayback, :options_video_playback
|
||||
Invidious::Routing.options "/videoplayback/*", Invidious::Routes::VideoPlayback, :options_video_playback
|
||||
|
||||
Invidious::Routing.get "/latest_version", Invidious::Routes::VideoPlayback, :latest_version
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue