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 ## Disable proxying server-wide. Can be disable as a whole, or
## only for a single function. ## only for a single function.
## ##
## Accepted values: true, false, dash, livestreams, downloads, local ## Accepted values: true, false, dash, livestreams, downloads, local, hls
## Default: false ## Default: false
## ##
#disable_proxy: false #disable_proxy: false

View File

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

View File

@ -105,8 +105,12 @@ def process_video_params(query, preferences)
vr_mode = vr_mode == 1 vr_mode = vr_mode == 1
save_player_pos = save_player_pos == 1 save_player_pos = save_player_pos == 1
# 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" if CONFIG.disabled?("dash") && quality == "dash"
quality = "high" quality = "high"
break
end
end end
if CONFIG.disabled?("local") && local if CONFIG.disabled?("local") && local

View File

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

View File

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