add support for an external videoplayback proxy loaded from invidious-companion
All checks were successful
Invidious CI / build (push) Successful in 5m8s

This commit is contained in:
Fijxu 2024-12-15 14:20:45 -03:00
parent caa4d2f79c
commit b1278a4853
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
2 changed files with 12 additions and 0 deletions

View file

@ -208,6 +208,12 @@ module Invidious::Routes::Embed
env.response.headers["Content-Security-Policy"]
.gsub("media-src", "media-src #{companion_base_url}")
.gsub("connect-src", "connect-src #{companion_base_url}")
if external_videoplayback_proxy = video.invidious_companion.dig?("external_videoplayback_proxy").try &.as_s
env.response.headers["Content-Security-Policy"] =
env.response.headers["Content-Security-Policy"]
.gsub("media-src #{companion_base_url}", "media-src #{companion_base_url} #{external_videoplayback_proxy}")
.gsub("connect-src #{companion_base_url}", "connect-src #{companion_base_url} #{external_videoplayback_proxy}")
end
end
rendered "embed"

View file

@ -222,6 +222,12 @@ module Invidious::Routes::Watch
env.response.headers["Content-Security-Policy"]
.gsub("media-src", "media-src #{companion_base_url}")
.gsub("connect-src", "connect-src #{companion_base_url}")
if external_videoplayback_proxy = video.invidious_companion.dig?("external_videoplayback_proxy").try &.as_s
env.response.headers["Content-Security-Policy"] =
env.response.headers["Content-Security-Policy"]
.gsub("media-src #{companion_base_url}", "media-src #{companion_base_url} #{external_videoplayback_proxy}")
.gsub("connect-src #{companion_base_url}", "connect-src #{companion_base_url} #{external_videoplayback_proxy}")
end
end
templated "watch"