From 7a070fa710b7807cdda061d413ca9369a0962353 Mon Sep 17 00:00:00 2001 From: Emilien <4016501+unixfox@users.noreply.github.com> Date: Mon, 18 Nov 2024 12:30:37 +0100 Subject: [PATCH] invidious companion always used so always add CSP and redirect latest_version --- src/invidious/routes/embed.cr | 2 +- src/invidious/routes/watch.cr | 2 +- src/invidious/views/components/player.ecr | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/invidious/routes/embed.cr b/src/invidious/routes/embed.cr index 23f2bbe1..df697001 100644 --- a/src/invidious/routes/embed.cr +++ b/src/invidious/routes/embed.cr @@ -201,7 +201,7 @@ module Invidious::Routes::Embed return env.redirect url end - if (!CONFIG.invidious_companion.empty? && (preferences.local || preferences.quality == "dash")) + if (!CONFIG.invidious_companion.empty?) env.response.headers["Content-Security-Policy"] = env.response.headers["Content-Security-Policy"] .gsub("media-src", "media-src " + video.invidious_companion.not_nil!["baseUrl"].as_s) diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr index 740a15b2..b42ee12d 100644 --- a/src/invidious/routes/watch.cr +++ b/src/invidious/routes/watch.cr @@ -190,7 +190,7 @@ module Invidious::Routes::Watch captions: video.captions ) - if (!CONFIG.invidious_companion.empty? && (preferences.local || preferences.quality == "dash")) + if (!CONFIG.invidious_companion.empty?) env.response.headers["Content-Security-Policy"] = env.response.headers["Content-Security-Policy"] .gsub("media-src", "media-src " + video.invidious_companion.not_nil!["baseUrl"].as_s) diff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecr index 59f43239..46c00137 100644 --- a/src/invidious/views/components/player.ecr +++ b/src/invidious/views/components/player.ecr @@ -22,7 +22,7 @@ audio_streams.each_with_index do |fmt, i| src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}" src_url += "&local=true" if params.local - src_url = video.invidious_companion.not_nil!["baseUrl"].as_s + src_url if (!CONFIG.invidious_companion.empty? && params.local) + src_url = video.invidious_companion.not_nil!["baseUrl"].as_s + src_url if (!CONFIG.invidious_companion.empty?) bitrate = fmt["bitrate"] mimetype = HTML.escape(fmt["mimeType"].as_s) @@ -48,7 +48,7 @@ fmt_stream.each_with_index do |fmt, i| src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}" src_url += "&local=true" if params.local - src_url = video.invidious_companion.not_nil!["baseUrl"].as_s + src_url if (!CONFIG.invidious_companion.empty? && params.local) + src_url = video.invidious_companion.not_nil!["baseUrl"].as_s + src_url if (!CONFIG.invidious_companion.empty?) quality = fmt["quality"] mimetype = HTML.escape(fmt["mimeType"].as_s)