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:
Jeroen Boersma 2025-12-19 15:09:22 +01:00 committed by GitHub
parent 7a4b901846
commit dbbaf51f1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -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