Allow hls to be disabled via disable_proxy config

This commit is contained in:
syeopite 2023-09-27 18:49:57 -04:00
parent 2b1a940298
commit 4ea606e3c0
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A
5 changed files with 12 additions and 8 deletions

View File

@ -139,7 +139,7 @@ https_only: false
## Disable proxying server-wide. Can be disable as a whole, or
## only for a single function.
##
## Accepted values: true, false, dash, livestreams, downloads, local
## Accepted values: true, false, dash, livestreams, downloads, local, hls
## Default: false
##
#disable_proxy: false

View File

@ -91,7 +91,7 @@ module Invidious::Routes::VideoPlayback
end
if url.includes? "&file=seg.ts"
if CONFIG.disabled?("livestreams")
if CONFIG.disabled?("livestreams") || CONFIG.disabled?("hls")
return error_template(403, "Administrator has disabled this endpoint.")
end

View File

@ -105,8 +105,12 @@ def process_video_params(query, preferences)
vr_mode = vr_mode == 1
save_player_pos = save_player_pos == 1
if CONFIG.disabled?("dash") && quality == "dash"
quality = "high"
# Force set quality to "high" if dash or hls has been disabled by the server
{"dash", "hls"}.each do |disabled_quality|
if CONFIG.disabled?("dash") && quality == "dash"
quality = "high"
break
end
end
if CONFIG.disabled?("local") && local

View File

@ -6,7 +6,7 @@
<% if params.controls %>controls<% end %>>
<% if (hlsvp = video.hls_manifest_url) && video.live_now && !CONFIG.disabled?("livestreams") %>
<source src="<%= URI.parse(hlsvp).request_target %><% if params.local %>?local=true<% end %>" type="application/x-mpegURL" label="livestream">
<% elsif (hlsvp = video.hls_manifest_url) && params.quality == "hls" %>
<% elsif (hlsvp = video.hls_manifest_url) && params.quality == "hls" && !CONFIG.disabled?("hls") %>
<source src="<%= URI.parse(hlsvp).request_target %><% if params.local %>?local=true<% end %>" type="application/x-mpegURL" label="HLS">
<% else %>
<% if params.listen %>

View File

@ -55,9 +55,9 @@
<label for="quality"><%= translate(locale, "preferences_quality_label") %></label>
<select name="quality" id="quality">
<% {"hls", "dash", "hd720", "medium", "small"}.each do |option| %>
<% if !(option == "dash" && CONFIG.disabled?("dash")) %>
<option value="<%= option %>" <% if preferences.quality == option %> selected <% end %>><%= translate(locale, "preferences_quality_option_" + option) %></option>
<% end %>
<% next if (option == "dash" && CONFIG.disabled?("dash"))%>
<% next if (option == "hls" && CONFIG.disabled?("hls"))%>
<option value="<%= option %>" <% if preferences.quality == option %> selected <% end %>><%= translate(locale, "preferences_quality_option_" + option) %></option>
<% end %>
</select>
</div>