Skip to content

Commit

Permalink
Allow hls to be disabled via disable_proxy config
Browse files Browse the repository at this point in the history
  • Loading branch information
syeopite committed Sep 28, 2023
1 parent b3285e3 commit 5685e70
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,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
Expand Down
2 changes: 1 addition & 1 deletion src/invidious/routes/video_playback.cr
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,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

Expand Down
8 changes: 6 additions & 2 deletions src/invidious/videos/video_preferences.cr
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,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
Expand Down
2 changes: 1 addition & 1 deletion src/invidious/views/components/player.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,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 %>
Expand Down
6 changes: 3 additions & 3 deletions src/invidious/views/user/preferences.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,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>
Expand Down

0 comments on commit 5685e70

Please sign in to comment.