add support for an external videoplayback proxy loaded from invidious-companion
Some checks failed
Invidious CI / build (push) Failing after 26s
Some checks failed
Invidious CI / build (push) Failing after 26s
This commit is contained in:
parent
3bc2312e39
commit
4041ee16f4
2 changed files with 18 additions and 0 deletions
|
@ -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"
|
||||
|
|
|
@ -211,11 +211,23 @@ module Invidious::Routes::Watch
|
|||
captions: video.captions
|
||||
)
|
||||
|
||||
begin
|
||||
video_url = fmt_stream[0]["url"].to_s
|
||||
rescue
|
||||
video_url = nil
|
||||
end
|
||||
|
||||
if companion_base_url = video.invidious_companion.try &.["baseUrl"].as_s
|
||||
env.response.headers["Content-Security-Policy"] =
|
||||
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"
|
||||
|
|
Loading…
Reference in a new issue