From 0cb442d40ece54b40da1f8415d874c18a1f7f9b5 Mon Sep 17 00:00:00 2001 From: Andrew Zhao Date: Tue, 8 Dec 2020 00:47:26 -0500 Subject: [PATCH] do not proxy hls on supported browser --- assets/js/player.js | 8 ++++++++ src/invidious.cr | 1 + src/invidious/views/components/player.ecr | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/assets/js/player.js b/assets/js/player.js index f79fbbf32..a6b35d359 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -41,8 +41,16 @@ var shareOptions = { embedCode: "" } +videojs.Hls.xhr.beforeRequest = function(options) { + if (options.uri.indexOf('local=true') === -1) { + options.uri = options.uri + '?local=true'; + } + return options; +}; + var player = videojs('player', options); + if (location.pathname.startsWith('/embed/')) { player.overlay({ overlays: [{ diff --git a/src/invidious.cr b/src/invidious.cr index c4ca9c08a..cdf646962 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -197,6 +197,7 @@ before_all do |env| extra_media_csp = "" if CONFIG.disabled?("local") || !preferences.local extra_media_csp += " https://*.googlevideo.com:443" + extra_media_csp += " https://*.youtube.com:443" end # TODO: Remove style-src's 'unsafe-inline', requires to remove all inline styles (, style=" [..] ") env.response.headers["Content-Security-Policy"] = "default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; manifest-src 'self'; media-src 'self' blob:#{extra_media_csp}" diff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecr index 0e6664fa3..625c6feeb 100644 --- a/src/invidious/views/components/player.ecr +++ b/src/invidious/views/components/player.ecr @@ -4,7 +4,7 @@ <% if params.video_loop %>loop<% end %> <% if params.controls %>controls<% end %>> <% if (hlsvp = video.hls_manifest_url) && !CONFIG.disabled?("livestreams") %> - + <% else %> <% if params.listen %> <% audio_streams.each_with_index do |fmt, i| %>