mirror of
https://github.com/iv-org/invidious
synced 2025-12-21 23:02:52 +01:00
Allow downloading via companion (#5561)
* Allow downloading via companion * post request where not proxied for the download companion which made it impossible to download with the companion enabled * Re-apply Channel to Channels rename which was pulled in * Update src/invidious/routes/companion.cr * doc: better comments for each route --------- Co-authored-by: Fijxu <fijxu@nadeko.net> Co-authored-by: Émilien (perso) <4016501+unixfox@users.noreply.github.com>
This commit is contained in:
parent
7a4b901846
commit
dbbaf51f1f
@ -1,5 +1,5 @@
|
||||
module Invidious::Routes::Companion
|
||||
# /companion
|
||||
# GET /companion
|
||||
def self.get_companion(env)
|
||||
url = env.request.path
|
||||
if env.request.query
|
||||
@ -16,6 +16,24 @@ module Invidious::Routes::Companion
|
||||
end
|
||||
end
|
||||
|
||||
# POST /companion
|
||||
def self.post_companion(env)
|
||||
url = env.request.path
|
||||
if env.request.query
|
||||
url += "?#{env.request.query}"
|
||||
end
|
||||
|
||||
begin
|
||||
COMPANION_POOL.client do |wrapper|
|
||||
wrapper.client.post(url, env.request.headers, env.request.body) do |resp|
|
||||
return self.proxy_companion(env, resp)
|
||||
end
|
||||
end
|
||||
rescue ex
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.options_companion(env)
|
||||
url = env.request.path
|
||||
if env.request.query
|
||||
|
||||
@ -227,6 +227,7 @@ module Invidious::Routing
|
||||
def register_companion_routes
|
||||
if CONFIG.invidious_companion.present?
|
||||
get "/companion/*", Routes::Companion, :get_companion
|
||||
post "/companion/*", Routes::Companion, :post_companion
|
||||
options "/companion/*", Routes::Companion, :options_companion
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user