diff --git a/src/invidious.cr b/src/invidious.cr index 3fee0a36..79968448 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -4667,6 +4667,12 @@ get "/videoplayback" do |env| end if url.includes? "&file=seg.ts" + if CONFIG.disabled?("livestreams") + env.response.status_code = 403 + error_message = "Administrator has disabled this endpoint." + next templated "error" + end + begin client = make_client(URI.parse(host), region) client.get(url, headers) do |response| @@ -4694,6 +4700,13 @@ get "/videoplayback" do |env| rescue ex end else + if query_params["title"]? && CONFIG.disabled?("downloads") || + CONFIG.disabled?("dash") + env.response.status_code = 403 + error_message = "Administrator has disabled this endpoint." + next templated "error" + end + content_length = nil first_chunk = true range_start, range_end = parse_range(env.request.headers["Range"]?) diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 89fdfe91..43255972 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -96,6 +96,19 @@ struct Config end end + def disabled?(option) + case disabled = CONFIG.disable_proxy + when Bool + return disabled + when Array + if disabled.includes? option + return true + else + return false + end + end + end + YAML.mapping({ channel_threads: Int32, # Number of threads to use for crawling videos from channels (for updating subscriptions) feed_threads: Int32, # Number of threads to use for updating feeds @@ -118,11 +131,12 @@ struct Config default: Preferences.new(*ConfigPreferences.from_yaml("").to_tuple), converter: ConfigPreferencesConverter, }, - dmca_content: {type: Array(String), default: [] of String}, # For compliance with DMCA, disables download widget using list of video IDs - check_tables: {type: Bool, default: false}, # Check table integrity, automatically try to add any missing columns, create tables, etc. - cache_annotations: {type: Bool, default: false}, # Cache annotations requested from IA, will not cache empty annotations or annotations that only contain cards - banner: {type: String?, default: nil}, # Optional banner to be displayed along top of page for announcements, etc. - hsts: {type: Bool?, default: true}, # Enables 'Strict-Transport-Security'. Ensure that `domain` and all subdomains are served securely + dmca_content: {type: Array(String), default: [] of String}, # For compliance with DMCA, disables download widget using list of video IDs + check_tables: {type: Bool, default: false}, # Check table integrity, automatically try to add any missing columns, create tables, etc. + cache_annotations: {type: Bool, default: false}, # Cache annotations requested from IA, will not cache empty annotations or annotations that only contain cards + banner: {type: String?, default: nil}, # Optional banner to be displayed along top of page for announcements, etc. + hsts: {type: Bool?, default: true}, # Enables 'Strict-Transport-Security'. Ensure that `domain` and all subdomains are served securely + disable_proxy: {type: Bool? | Array(String)?, default: false}, # Disable proxying server-wide: options: 'dash', 'livestreams', 'downloads', 'local' }) end diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index dfaecbb2..b54e65b8 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -1292,6 +1292,14 @@ def process_video_params(query, preferences) related_videos = related_videos == 1 video_loop = video_loop == 1 + if CONFIG.disabled?("dash") && quality == "dash" + quality = "high" + end + + if CONFIG.disabled?("local") && local + local = false + end + if query["t"]? video_start = decode_time(query["t"]) end diff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecr index d128b0f6..491e8fb1 100644 --- a/src/invidious/views/components/player.ecr +++ b/src/invidious/views/components/player.ecr @@ -6,7 +6,7 @@ <% if params.autoplay %>autoplay<% end %> <% if params.video_loop %>loop<% end %> <% if params.controls %>controls<% end %>> - <% if hlsvp %> + <% if hlsvp && !CONFIG.disabled?("livestreams") %>
- <% if CONFIG.dmca_content.includes? video.id %> + <% if CONFIG.dmca_content.includes?(video.id) || CONFIG.disabled?("downloads") %><%= translate(locale, "Download is disabled.") %>
<% else %>