forked from midou/invidious
Allow automatic instance redirect to be turned off
Instead the "switch invidious instance" link would bring users to redirect.invidious.io
This commit is contained in:
@@ -44,6 +44,7 @@ struct ConfigPreferences
|
||||
property quality_dash : String = "auto"
|
||||
property default_home : String? = "Popular"
|
||||
property feed_menu : Array(String) = ["Popular", "Trending", "Subscriptions", "Playlists"]
|
||||
property automatic_instance_redirect : Bool = true
|
||||
property related_videos : Bool = true
|
||||
property sort : String = "published"
|
||||
property speed : Float32 = 1.0_f32
|
||||
|
@@ -37,8 +37,13 @@ class Invidious::Routes::Misc < Invidious::Routes::BaseRoute
|
||||
end
|
||||
|
||||
def cross_instance_redirect(env)
|
||||
instance_url = fetch_random_instance
|
||||
referer = get_referer(env)
|
||||
|
||||
if !env.get("preferences").as(Preferences).automatic_instance_redirect
|
||||
return env.redirect("https://redirect.invidious.io#{referer}")
|
||||
end
|
||||
|
||||
instance_url = fetch_random_instance
|
||||
env.redirect "https://#{instance_url}#{referer}"
|
||||
end
|
||||
end
|
||||
|
@@ -92,6 +92,10 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute
|
||||
end
|
||||
end
|
||||
|
||||
automatic_instance_redirect = env.params.body["automatic_instance_redirect"]?.try &.as(String)
|
||||
automatic_instance_redirect ||= "off"
|
||||
automatic_instance_redirect = automatic_instance_redirect == "on"
|
||||
|
||||
locale = env.params.body["locale"]?.try &.as(String)
|
||||
locale ||= CONFIG.default_user_preferences.locale
|
||||
|
||||
@@ -141,6 +145,7 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute
|
||||
quality_dash: quality_dash,
|
||||
default_home: default_home,
|
||||
feed_menu: feed_menu,
|
||||
automatic_instance_redirect: automatic_instance_redirect,
|
||||
related_videos: related_videos,
|
||||
sort: sort,
|
||||
speed: speed,
|
||||
|
@@ -36,6 +36,7 @@ struct Preferences
|
||||
property annotations : Bool = CONFIG.default_user_preferences.annotations
|
||||
property annotations_subscribed : Bool = CONFIG.default_user_preferences.annotations_subscribed
|
||||
property autoplay : Bool = CONFIG.default_user_preferences.autoplay
|
||||
property automatic_instance_redirect : Bool = CONFIG.default_user_preferences.automatic_instance_redirect
|
||||
|
||||
@[JSON::Field(converter: Preferences::StringToArray)]
|
||||
@[YAML::Field(converter: Preferences::StringToArray)]
|
||||
|
@@ -176,6 +176,13 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<legend><%= translate(locale, "Miscellaneous preferences") %></legend>
|
||||
|
||||
<div class="pure-control-group">
|
||||
<label for="automatic_instance_redirect"><%= translate(locale, "Automatically redirect to another Instance: ") %></label>
|
||||
<input name="automatic_instance_redirect" id="automatic_instance_redirect" type="checkbox" <% if preferences.automatic_instance_redirect %>checked<% end %>>
|
||||
</div>
|
||||
|
||||
<% if env.get? "user" %>
|
||||
<legend><%= translate(locale, "Subscription preferences") %></legend>
|
||||
|
||||
|
Reference in New Issue
Block a user