feat: Detect videoplayback proxy from invidious-companion and add it to the CSP header
All checks were successful
Invidious CI / build (push) Successful in 7m36s
All checks were successful
Invidious CI / build (push) Successful in 7m36s
This commit is contained in:
parent
50fa7de901
commit
4ae9517be8
4 changed files with 40 additions and 0 deletions
|
@ -223,6 +223,10 @@ else
|
||||||
LOGGER.info("jobs: Disabling RefreshSessionTokens job. Invidious will use the tokens that are on the configuration file")
|
LOGGER.info("jobs: Disabling RefreshSessionTokens job. Invidious will use the tokens that are on the configuration file")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if CONFIG.invidious_companion.present?
|
||||||
|
Invidious::Jobs.register Invidious::Jobs::CheckBackend.new
|
||||||
|
end
|
||||||
|
|
||||||
Invidious::Jobs.start_all
|
Invidious::Jobs.start_all
|
||||||
|
|
||||||
def popular_videos
|
def popular_videos
|
||||||
|
|
17
src/invidious/helpers/backend_info.cr
Normal file
17
src/invidious/helpers/backend_info.cr
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
module BackendInfo
|
||||||
|
extend self
|
||||||
|
@@exvpp_url : String = ""
|
||||||
|
|
||||||
|
def get_videoplayback_proxy
|
||||||
|
begin
|
||||||
|
response = HTTP::Client.get "#{CONFIG.invidious_companion.sample.private_url}/info"
|
||||||
|
exvpp_url = JSON.parse(response.body)["external_videoplayback_proxy"].to_s
|
||||||
|
@@exvpp_url = exvpp_url
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_exvpp
|
||||||
|
return @@exvpp_url
|
||||||
|
end
|
||||||
|
end
|
14
src/invidious/jobs/cbackend_checker.cr
Normal file
14
src/invidious/jobs/cbackend_checker.cr
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
class Invidious::Jobs::CheckBackend < Invidious::Jobs::BaseJob
|
||||||
|
def initialize
|
||||||
|
end
|
||||||
|
|
||||||
|
def begin
|
||||||
|
loop do
|
||||||
|
# BackendInfo.check_backends
|
||||||
|
BackendInfo.get_videoplayback_proxy
|
||||||
|
LOGGER.info("Backend Checker: Done, sleeping for 60 seconds")
|
||||||
|
sleep 60.seconds
|
||||||
|
Fiber.yield
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -26,6 +26,11 @@ module Invidious::Routes::BeforeAll
|
||||||
if CONFIG.invidious_companion.present?
|
if CONFIG.invidious_companion.present?
|
||||||
extra_media_csp = " #{CONFIG.invidious_companion.sample.public_url}"
|
extra_media_csp = " #{CONFIG.invidious_companion.sample.public_url}"
|
||||||
extra_connect_csp = " #{CONFIG.invidious_companion.sample.public_url}"
|
extra_connect_csp = " #{CONFIG.invidious_companion.sample.public_url}"
|
||||||
|
exvpp_url = BackendInfo.get_exvpp
|
||||||
|
if !exvpp_url.empty?
|
||||||
|
extra_media_csp += " #{exvpp_url}"
|
||||||
|
extra_connect_csp += " #{exvpp_url}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if !CONFIG.external_videoplayback_proxy.empty?
|
if !CONFIG.external_videoplayback_proxy.empty?
|
||||||
|
|
Loading…
Add table
Reference in a new issue