From 5b47438b7112d46f7d19e899475e393c5eb0aa52 Mon Sep 17 00:00:00 2001 From: syeopite Date: Fri, 26 Mar 2021 18:35:28 -0700 Subject: [PATCH 01/25] Add helper function to fetch random instance --- src/invidious/helpers/utils.cr | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 66ad6961..8c893310 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -409,3 +409,19 @@ def convert_theme(theme) theme end end + +def fetch_random_instance() + instance_list = HTTP::Client.get "https://api.invidious.io/instances.json" + instance_list = JSON.parse(instance_list.body) + + filtered_instance_list = [] of String + instance_list.as_a.each do |data| + if data[1]["type"] == "https" + if data[1]["monitor"] + health = data[1]["monitor"].as_h["dailyRatios"][0].as_h["ratio"] + filtered_instance_list << data[0].as_s if health.to_s.to_f > 90 + end + end + end + return filtered_instance_list.sample(1)[0] +end From 31fa3dfd590b00e5c994103f0b2fb1f1969d9b9d Mon Sep 17 00:00:00 2001 From: syeopite Date: Fri, 26 Mar 2021 18:36:40 -0700 Subject: [PATCH 02/25] Add route to redirect to another instance --- src/invidious.cr | 1 + src/invidious/routes/misc.cr | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/invidious.cr b/src/invidious.cr index 7037ecfe..b1ee1525 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -314,6 +314,7 @@ Invidious::Routing.get "/shorts/:id", Invidious::Routes::Watch, :redirect Invidious::Routing.get "/w/:id", Invidious::Routes::Watch, :redirect Invidious::Routing.get "/v/:id", Invidious::Routes::Watch, :redirect Invidious::Routing.get "/e/:id", Invidious::Routes::Watch, :redirect +Invidious::Routing.get "/redirect", Invidious::Routes::Misc, :cross_instance_redirect Invidious::Routing.get "/embed/", Invidious::Routes::Embed, :redirect Invidious::Routing.get "/embed/:id", Invidious::Routes::Embed, :show diff --git a/src/invidious/routes/misc.cr b/src/invidious/routes/misc.cr index d32ba892..857d0596 100644 --- a/src/invidious/routes/misc.cr +++ b/src/invidious/routes/misc.cr @@ -35,4 +35,10 @@ class Invidious::Routes::Misc < Invidious::Routes::BaseRoute locale = LOCALES[env.get("preferences").as(Preferences).locale]? rendered "licenses" end + + def cross_instance_redirect(env) + id = env.params.query["id"] + instance_url = fetch_random_instance + env.redirect "https://#{instance_url}/watch?v=#{id}" + end end From f3bc55e37e6fe38ce202a7afa10efd748e6b7b15 Mon Sep 17 00:00:00 2001 From: syeopite Date: Fri, 26 Mar 2021 18:43:56 -0700 Subject: [PATCH 03/25] Expose instance redirect to frontend --- src/invidious/views/watch.ecr | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index baffa08b..67c116fb 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -109,6 +109,9 @@ we're going to need to do it here in order to allow for translations. <%= translate(locale, "Watch on YouTube") %> (<%= translate(locale, "Embed") %>) +

+ <%= translate(locale, "Watch on another Invidious Instance") %> +

From 008598b56ff0fcb84eb151338c6b834089f7c886 Mon Sep 17 00:00:00 2001 From: syeopite Date: Fri, 26 Mar 2021 18:47:07 -0700 Subject: [PATCH 04/25] Change wording of redirect hyperlink --- src/invidious/views/watch.ecr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 67c116fb..6bb59d20 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -110,7 +110,7 @@ we're going to need to do it here in order to allow for translations. (<%= translate(locale, "Embed") %>)

- <%= translate(locale, "Watch on another Invidious Instance") %> + <%= translate(locale, "Switch Invidious Instance") %>

From 37ff2ac2b9531e53bed05d8b4828614558418062 Mon Sep 17 00:00:00 2001 From: syeopite Date: Fri, 26 Mar 2021 20:48:46 -0700 Subject: [PATCH 07/25] Overhaul button icon html and styling --- src/invidious/views/components/item.ecr | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr index 929ba25f..0e379e8e 100644 --- a/src/invidious/views/components/item.ecr +++ b/src/invidious/views/components/item.ecr @@ -137,20 +137,22 @@ <% end %>

<%= HTML.escape(item.title) %>

-

+

<% if item.responds_to?(:premiere_timestamp) && item.premiere_timestamp.try &.> Time.utc %> From 311e7684b280e72d1155a320ef48c75105ab1e5d Mon Sep 17 00:00:00 2001 From: syeopite Date: Fri, 26 Mar 2021 21:22:46 -0700 Subject: [PATCH 08/25] Add instance redirect on empty/broken search --- locales/en-US.json | 1 + src/invidious/helpers/utils.cr | 24 ++--- src/invidious/routes/misc.cr | 7 +- src/invidious/views/search.ecr | 177 +++++++++++++++++---------------- 4 files changed, 111 insertions(+), 98 deletions(-) diff --git a/locales/en-US.json b/locales/en-US.json index 12663915..1f4cd8d6 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -162,6 +162,7 @@ "Show less": "Show less", "Watch on YouTube": "Watch on YouTube", "Switch Invidious Instance": "Switch Invidious Instance", + "Broken?": "Broken?", "Hide annotations": "Hide annotations", "Show annotations": "Show annotations", "Genre: ": "Genre: ", diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 8c893310..cb94b44a 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -410,18 +410,18 @@ def convert_theme(theme) end end -def fetch_random_instance() - instance_list = HTTP::Client.get "https://api.invidious.io/instances.json" - instance_list = JSON.parse(instance_list.body) +def fetch_random_instance + instance_list = HTTP::Client.get "https://api.invidious.io/instances.json" + instance_list = JSON.parse(instance_list.body) - filtered_instance_list = [] of String - instance_list.as_a.each do |data| - if data[1]["type"] == "https" - if data[1]["monitor"] - health = data[1]["monitor"].as_h["dailyRatios"][0].as_h["ratio"] - filtered_instance_list << data[0].as_s if health.to_s.to_f > 90 - end - end + filtered_instance_list = [] of String + instance_list.as_a.each do |data| + if data[1]["type"] == "https" + if data[1]["monitor"] + health = data[1]["monitor"].as_h["dailyRatios"][0].as_h["ratio"] + filtered_instance_list << data[0].as_s if health.to_s.to_f > 90 + end end - return filtered_instance_list.sample(1)[0] + end + return filtered_instance_list.sample(1)[0] end diff --git a/src/invidious/routes/misc.cr b/src/invidious/routes/misc.cr index 857d0596..c14e0e54 100644 --- a/src/invidious/routes/misc.cr +++ b/src/invidious/routes/misc.cr @@ -37,8 +37,13 @@ class Invidious::Routes::Misc < Invidious::Routes::BaseRoute end def cross_instance_redirect(env) + instance_url = fetch_random_instance + if env.params.query["id"]? id = env.params.query["id"] - instance_url = fetch_random_instance env.redirect "https://#{instance_url}/watch?v=#{id}" + elsif env.params.query["q"]? + query, page = env.params.query["q"], env.params.query["page"] + env.redirect "https://#{instance_url}/search?q=#{query}&page=#{page}" + end end end diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr index fefc9fbb..fdb9205c 100644 --- a/src/invidious/views/search.ecr +++ b/src/invidious/views/search.ecr @@ -2,92 +2,99 @@ <%= search_query.not_nil!.size > 30 ? HTML.escape(query.not_nil![0,30].rstrip(".") + "...") : HTML.escape(query.not_nil!) %> - Invidious <% end %> -
- -

<%= translate(locale, "filter") %>

-
-
-
- <%= translate(locale, "date") %> -
- <% ["hour", "today", "week", "month", "year"].each do |date| %> -
- <% if operator_hash.fetch("date", "all") == date %> - <%= translate(locale, date) %> - <% else %> - &page=<%= page %>"> - <%= translate(locale, date) %> - - <% end %> -
- <% end %> + +<% if count == 0 %> +

+ <%= translate(locale, "Broken?") %> <%= translate(locale, "Switch Invidious Instance") %> +

+<% else %> +
+ +

<%= translate(locale, "filter") %>

+
+
+
+ <%= translate(locale, "date") %> +
+ <% ["hour", "today", "week", "month", "year"].each do |date| %> +
+ <% if operator_hash.fetch("date", "all") == date %> + <%= translate(locale, date) %> + <% else %> + &page=<%= page %>"> + <%= translate(locale, date) %> + + <% end %> +
+ <% end %> +
+
+ <%= translate(locale, "content_type") %> +
+ <% ["video", "channel", "playlist", "movie", "show"].each do |content_type| %> +
+ <% if operator_hash.fetch("content_type", "all") == content_type %> + <%= translate(locale, content_type) %> + <% else %> + &page=<%= page %>"> + <%= translate(locale, content_type) %> + + <% end %> +
+ <% end %> +
+
+ <%= translate(locale, "duration") %> +
+ <% ["short", "long"].each do |duration| %> +
+ <% if operator_hash.fetch("duration", "all") == duration %> + <%= translate(locale, duration) %> + <% else %> + &page=<%= page %>"> + <%= translate(locale, duration) %> + + <% end %> +
+ <% end %> +
+
+ <%= translate(locale, "features") %> +
+ <% ["hd", "subtitles", "creative_commons", "3d", "live", "purchased", "4k", "360", "location", "hdr"].each do |feature| %> +
+ <% if operator_hash.fetch("features", "all").includes?(feature) %> + <%= translate(locale, feature) %> + <% elsif operator_hash.has_key?("features") %> + &page=<%= page %>"> + <%= translate(locale, feature) %> + + <% else %> + &page=<%= page %>"> + <%= translate(locale, feature) %> + + <% end %> +
+ <% end %> +
+
+ <%= translate(locale, "sort") %> +
+ <% ["relevance", "rating", "date", "views"].each do |sort| %> +
+ <% if operator_hash.fetch("sort", "relevance") == sort %> + <%= translate(locale, sort) %> + <% else %> + &page=<%= page %>"> + <%= translate(locale, sort) %> + + <% end %> +
+ <% end %> +
-
- <%= translate(locale, "content_type") %> -
- <% ["video", "channel", "playlist", "movie", "show"].each do |content_type| %> -
- <% if operator_hash.fetch("content_type", "all") == content_type %> - <%= translate(locale, content_type) %> - <% else %> - &page=<%= page %>"> - <%= translate(locale, content_type) %> - - <% end %> -
- <% end %> -
-
- <%= translate(locale, "duration") %> -
- <% ["short", "long"].each do |duration| %> -
- <% if operator_hash.fetch("duration", "all") == duration %> - <%= translate(locale, duration) %> - <% else %> - &page=<%= page %>"> - <%= translate(locale, duration) %> - - <% end %> -
- <% end %> -
-
- <%= translate(locale, "features") %> -
- <% ["hd", "subtitles", "creative_commons", "3d", "live", "purchased", "4k", "360", "location", "hdr"].each do |feature| %> -
- <% if operator_hash.fetch("features", "all").includes?(feature) %> - <%= translate(locale, feature) %> - <% elsif operator_hash.has_key?("features") %> - &page=<%= page %>"> - <%= translate(locale, feature) %> - - <% else %> - &page=<%= page %>"> - <%= translate(locale, feature) %> - - <% end %> -
- <% end %> -
-
- <%= translate(locale, "sort") %> -
- <% ["relevance", "rating", "date", "views"].each do |sort| %> -
- <% if operator_hash.fetch("sort", "relevance") == sort %> - <%= translate(locale, sort) %> - <% else %> - &page=<%= page %>"> - <%= translate(locale, sort) %> - - <% end %> -
- <% end %> -
-
-
+ +<% end %>
From f1782974522240cf4016b80a8accba223a8f7922 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sun, 28 Mar 2021 23:05:54 -0700 Subject: [PATCH 09/25] Generalize redirect route --- src/invidious/routes/misc.cr | 9 ++------- src/invidious/views/components/item.ecr | 2 +- src/invidious/views/search.ecr | 2 +- src/invidious/views/watch.ecr | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/invidious/routes/misc.cr b/src/invidious/routes/misc.cr index c14e0e54..13fc65bb 100644 --- a/src/invidious/routes/misc.cr +++ b/src/invidious/routes/misc.cr @@ -38,12 +38,7 @@ class Invidious::Routes::Misc < Invidious::Routes::BaseRoute def cross_instance_redirect(env) instance_url = fetch_random_instance - if env.params.query["id"]? - id = env.params.query["id"] - env.redirect "https://#{instance_url}/watch?v=#{id}" - elsif env.params.query["q"]? - query, page = env.params.query["q"], env.params.query["page"] - env.redirect "https://#{instance_url}/search?q=#{query}&page=#{page}" - end + referer = get_referer(env) + env.redirect "https://#{instance_url}#{referer}" end end diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr index 0e379e8e..532de6ac 100644 --- a/src/invidious/views/components/item.ecr +++ b/src/invidious/views/components/item.ecr @@ -148,7 +148,7 @@ " href="/watch?v=<%= item.id %>&listen=1"> - " href="/redirect?id=<%= item.id %>&listen=1"> + " href="/redirect?referer=<%= env.get?("current_page") %>"> diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr index fdb9205c..db0a8d56 100644 --- a/src/invidious/views/search.ecr +++ b/src/invidious/views/search.ecr @@ -5,7 +5,7 @@ <% if count == 0 %>

- <%= translate(locale, "Broken?") %> <%= translate(locale, "Switch Invidious Instance") %> + <%= translate(locale, "Broken?") %> "><%= translate(locale, "Switch Invidious Instance") %>

<% else %>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 6bb59d20..91e03725 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -110,7 +110,7 @@ we're going to need to do it here in order to allow for translations. (<%= translate(locale, "Embed") %>)

- <%= translate(locale, "Switch Invidious Instance") %> + "><%= translate(locale, "Switch Invidious Instance") %>

<%= translate(locale, "View channel on YouTube") %> + <% if !channel.auto_generated %>
<%= translate(locale, "Videos") %> From d06cf2a07b27f10b48717e5995dc39b0e7129cbf Mon Sep 17 00:00:00 2001 From: syeopite Date: Sun, 28 Mar 2021 23:48:45 -0700 Subject: [PATCH 11/25] Add playlist redirect --- src/invidious/views/playlist.ecr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/invidious/views/playlist.ecr b/src/invidious/views/playlist.ecr index 91156028..a19dd182 100644 --- a/src/invidious/views/playlist.ecr +++ b/src/invidious/views/playlist.ecr @@ -36,6 +36,11 @@ <%= translate(locale, "View playlist on YouTube") %> + | + "> + <%= translate(locale, "Switch Invidious Instance") %> + +
<% end %>
From cf72b34866e75677d854198a969f0263aed720c1 Mon Sep 17 00:00:00 2001 From: syeopite Date: Fri, 2 Apr 2021 16:17:31 -0700 Subject: [PATCH 12/25] Fix locale discrepancy for instance redirect btn --- locales/ar.json | 2 ++ locales/bn_BD.json | 2 ++ locales/cs.json | 2 ++ locales/da.json | 2 ++ locales/de.json | 2 ++ locales/el.json | 2 ++ locales/en-US.json | 2 +- locales/eo.json | 2 ++ locales/es.json | 2 ++ locales/eu.json | 2 ++ locales/fa.json | 2 ++ locales/fi.json | 2 ++ locales/fr.json | 2 ++ locales/he.json | 2 ++ locales/hr.json | 2 ++ locales/hu-HU.json | 2 ++ locales/id.json | 2 ++ locales/is.json | 2 ++ locales/it.json | 2 ++ locales/ja.json | 2 ++ locales/nb-NO.json | 2 ++ locales/nl.json | 2 ++ locales/pl.json | 2 ++ locales/pt-BR.json | 2 ++ locales/pt-PT.json | 2 ++ locales/ro.json | 2 ++ locales/ru.json | 2 ++ locales/si.json | 2 ++ locales/sk.json | 2 ++ locales/sr_Cyrl.json | 2 ++ locales/sv-SE.json | 2 ++ locales/tr.json | 2 ++ locales/uk.json | 2 ++ locales/zh-CN.json | 2 ++ locales/zh-TW.json | 2 ++ src/invidious/views/search.ecr | 2 +- 36 files changed, 70 insertions(+), 2 deletions(-) diff --git a/locales/ar.json b/locales/ar.json index 779ea61d..a14e4101 100644 --- a/locales/ar.json +++ b/locales/ar.json @@ -161,6 +161,8 @@ "Show more": "أظهر المزيد", "Show less": "عرض اقل", "Watch on YouTube": "مشاهدة الفيديو على اليوتيوب", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "إخفاء الملاحظات فى الفيديو", "Show annotations": "عرض الملاحظات فى الفيديو", "Genre: ": "النوع: ", diff --git a/locales/bn_BD.json b/locales/bn_BD.json index 2d3ace82..9b1df424 100644 --- a/locales/bn_BD.json +++ b/locales/bn_BD.json @@ -149,6 +149,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "", "Show annotations": "", "Genre: ": "", diff --git a/locales/cs.json b/locales/cs.json index 4cacf6b9..b85bcd10 100644 --- a/locales/cs.json +++ b/locales/cs.json @@ -161,6 +161,8 @@ "Show more": "Zobrazit více", "Show less": "Zobrazit méně", "Watch on YouTube": "Sledovat na YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Skrýt vysvětlivky", "Show annotations": "Zobrazit vysvětlivky", "Genre: ": "Žánr: ", diff --git a/locales/da.json b/locales/da.json index cf997bb9..525c9d0f 100644 --- a/locales/da.json +++ b/locales/da.json @@ -161,6 +161,8 @@ "Show more": "Vis mere", "Show less": "Vis mindre", "Watch on YouTube": "Se på YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Skjul annotationer", "Show annotations": "Vis annotationer", "Genre: ": "Genre: ", diff --git a/locales/de.json b/locales/de.json index 42e12815..2192fd97 100644 --- a/locales/de.json +++ b/locales/de.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "Video auf YouTube ansehen", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Anmerkungen ausblenden", "Show annotations": "Anmerkungen anzeigen", "Genre: ": "Genre: ", diff --git a/locales/el.json b/locales/el.json index c55db8ef..9192edf3 100644 --- a/locales/el.json +++ b/locales/el.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "Προβολή στο YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Απόκρυψη σημειώσεων", "Show annotations": "Προβολή σημειώσεων", "Genre: ": "Είδος: ", diff --git a/locales/en-US.json b/locales/en-US.json index 1f4cd8d6..6d6a88ea 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -162,7 +162,7 @@ "Show less": "Show less", "Watch on YouTube": "Watch on YouTube", "Switch Invidious Instance": "Switch Invidious Instance", - "Broken?": "Broken?", + "Broken? Try another Invidious Instance": "Broken? Try another Invidious Instance", "Hide annotations": "Hide annotations", "Show annotations": "Show annotations", "Genre: ": "Genre: ", diff --git a/locales/eo.json b/locales/eo.json index 23da15ab..5528845b 100644 --- a/locales/eo.json +++ b/locales/eo.json @@ -161,6 +161,8 @@ "Show more": "Montri pli", "Show less": "Montri malpli", "Watch on YouTube": "Vidi filmeton en JuTubo", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Kaŝi prinotojn", "Show annotations": "Montri prinotojn", "Genre: ": "Ĝenro: ", diff --git a/locales/es.json b/locales/es.json index 3727cb15..fa83d6dc 100644 --- a/locales/es.json +++ b/locales/es.json @@ -161,6 +161,8 @@ "Show more": "Mostrar más", "Show less": "Mostrar menos", "Watch on YouTube": "Ver el vídeo en Youtube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Ocultar anotaciones", "Show annotations": "Mostrar anotaciones", "Genre: ": "Género: ", diff --git a/locales/eu.json b/locales/eu.json index ff1c67b7..ec90b82e 100644 --- a/locales/eu.json +++ b/locales/eu.json @@ -143,6 +143,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "", "Show annotations": "", "Genre: ": "", diff --git a/locales/fa.json b/locales/fa.json index f8c33b8f..5bc99b60 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "تماشا در یوتیوب", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "مخفی کردن حاشیه نویسی ها", "Show annotations": "نمایش حاشیه نویسی ها", "Genre: ": "ژانر: ", diff --git a/locales/fi.json b/locales/fi.json index 2092e994..f4aeae2b 100644 --- a/locales/fi.json +++ b/locales/fi.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "Katso YouTubessa", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Piilota merkkaukset", "Show annotations": "Näytä merkkaukset", "Genre: ": "Genre: ", diff --git a/locales/fr.json b/locales/fr.json index e912f913..21dd2798 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "Voir la vidéo sur Youtube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Masquer les annotations", "Show annotations": "Afficher les annotations", "Genre: ": "Genre : ", diff --git a/locales/he.json b/locales/he.json index d924e11b..1645bd93 100644 --- a/locales/he.json +++ b/locales/he.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "צפייה ב־YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "", "Show annotations": "", "Genre: ": "Genre: ", diff --git a/locales/hr.json b/locales/hr.json index bebd3859..6c313666 100644 --- a/locales/hr.json +++ b/locales/hr.json @@ -161,6 +161,8 @@ "Show more": "Pokaži više", "Show less": "Pokaži manje", "Watch on YouTube": "Gledaj na YouTubeu", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Sakrij napomene", "Show annotations": "Prikaži napomene", "Genre: ": "Žanr: ", diff --git a/locales/hu-HU.json b/locales/hu-HU.json index 859fdef2..a25597d5 100644 --- a/locales/hu-HU.json +++ b/locales/hu-HU.json @@ -145,6 +145,8 @@ "Watch on YouTube": "Megtekintés a YouTube-on", "Hide annotations": "Szövegmagyarázat elrejtése", "Show annotations": "Szövegmagyarázat mutatása", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Genre: ": "Műfaj: ", "License: ": "Licensz: ", "Family friendly? ": "Családbarát? ", diff --git a/locales/id.json b/locales/id.json index ce98f87b..5cf3e65c 100644 --- a/locales/id.json +++ b/locales/id.json @@ -161,6 +161,8 @@ "Show more": "Tampilkan lainnya", "Show less": "Tampilkan lebih sedikit", "Watch on YouTube": "Tonton di YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Sembunyikan anotasi", "Show annotations": "Tampilkan anotasi", "Genre: ": "Genre: ", diff --git a/locales/is.json b/locales/is.json index a847080a..d80e10e2 100644 --- a/locales/is.json +++ b/locales/is.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "Horfa á YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Fela glósur", "Show annotations": "Sýna glósur", "Genre: ": "Tegund: ", diff --git a/locales/it.json b/locales/it.json index 09b5b447..e1446f8b 100644 --- a/locales/it.json +++ b/locales/it.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "Guarda su YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Nascondi annotazioni", "Show annotations": "Mostra annotazioni", "Genre: ": "Genere: ", diff --git a/locales/ja.json b/locales/ja.json index 41d727db..80cbdd81 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -161,6 +161,8 @@ "Show more": "表示を増やす", "Show less": "表示を減らす", "Watch on YouTube": "YouTube で視聴", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "アノテーションを隠す", "Show annotations": "アノテーションを表示", "Genre: ": "ジャンル: ", diff --git a/locales/nb-NO.json b/locales/nb-NO.json index cb95c2dc..55e0da68 100644 --- a/locales/nb-NO.json +++ b/locales/nb-NO.json @@ -161,6 +161,8 @@ "Show more": "Vis mer", "Show less": "Vis mindre", "Watch on YouTube": "Vis video på YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Skjul merknader", "Show annotations": "Vis merknader", "Genre: ": "Sjanger: ", diff --git a/locales/nl.json b/locales/nl.json index c9da1875..c73952ee 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -161,6 +161,8 @@ "Show more": "Toon meer", "Show less": "Toon minder", "Watch on YouTube": "Video bekijken op YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Annotaties verbergen", "Show annotations": "Annotaties tonen", "Genre: ": "Genre: ", diff --git a/locales/pl.json b/locales/pl.json index f31293d3..ac170c0a 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -161,6 +161,8 @@ "Show more": "Pokaż więcej", "Show less": "Pokaż mniej", "Watch on YouTube": "Zobacz film na YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Ukryj adnotacje", "Show annotations": "Pokaż adnotacje", "Genre: ": "Gatunek: ", diff --git a/locales/pt-BR.json b/locales/pt-BR.json index 04971d6c..8a112a8a 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -161,6 +161,8 @@ "Show more": "Mostrar mais", "Show less": "Mostrar menos", "Watch on YouTube": "Assistir no YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Ocultar anotações", "Show annotations": "Mostrar anotações", "Genre: ": "Gênero: ", diff --git a/locales/pt-PT.json b/locales/pt-PT.json index 43ffc7d8..4555f870 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "Ver no YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Ocultar anotações", "Show annotations": "Mostrar anotações", "Genre: ": "Género: ", diff --git a/locales/ro.json b/locales/ro.json index 498104d8..e021a622 100644 --- a/locales/ro.json +++ b/locales/ro.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "Urmăriți videoclipul pe YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Ascundeți adnotările", "Show annotations": "Afișați adnotările", "Genre: ": "Categorie: ", diff --git a/locales/ru.json b/locales/ru.json index 7d238cd0..db1be8ea 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "Смотреть на YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Скрыть аннотации", "Show annotations": "Показать аннотации", "Genre: ": "Жанр: ", diff --git a/locales/si.json b/locales/si.json index 57ed22a3..3ff9b4ed 100644 --- a/locales/si.json +++ b/locales/si.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "", "Show annotations": "", "Genre: ": "", diff --git a/locales/sk.json b/locales/sk.json index 30495e9a..eb696e5b 100644 --- a/locales/sk.json +++ b/locales/sk.json @@ -149,6 +149,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "", "Show annotations": "", "Genre: ": "", diff --git a/locales/sr_Cyrl.json b/locales/sr_Cyrl.json index 6c72c9ed..2f5a5f60 100644 --- a/locales/sr_Cyrl.json +++ b/locales/sr_Cyrl.json @@ -143,6 +143,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "Гледајте на YouTube-у", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Сакриј анотације", "Show annotations": "Прикажи анотације", "Genre: ": "Жанр: ", diff --git a/locales/sv-SE.json b/locales/sv-SE.json index 8b093e7d..8ecc5424 100644 --- a/locales/sv-SE.json +++ b/locales/sv-SE.json @@ -161,6 +161,8 @@ "Show more": "Visa mer", "Show less": "Visa mindre", "Watch on YouTube": "Titta på YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Dölj länkar-i-video", "Show annotations": "Visa länkar-i-video", "Genre: ": "Genre: ", diff --git a/locales/tr.json b/locales/tr.json index e16c1217..2314b4ab 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -161,6 +161,8 @@ "Show more": "Daha fazla göster", "Show less": "Daha az göster", "Watch on YouTube": "YouTube'da izle", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Ek açıklamaları gizle", "Show annotations": "Ek açıklamaları göster", "Genre: ": "Tür: ", diff --git a/locales/uk.json b/locales/uk.json index 371ecafa..ca44e3bb 100644 --- a/locales/uk.json +++ b/locales/uk.json @@ -161,6 +161,8 @@ "Show more": "", "Show less": "", "Watch on YouTube": "Дивитися на YouTube", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "Приховати анотації", "Show annotations": "Показати анотації", "Genre: ": "Жанр: ", diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 050e3071..28935e4a 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -161,6 +161,8 @@ "Show more": "显示更多", "Show less": "显示较少", "Watch on YouTube": "在 YouTube 观看", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "隐藏注释", "Show annotations": "显示注释", "Genre: ": "风格: ", diff --git a/locales/zh-TW.json b/locales/zh-TW.json index 1affeb3f..bdae7678 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -161,6 +161,8 @@ "Show more": "顯示更多", "Show less": "顯示較少", "Watch on YouTube": "在 YouTube 上觀看", + "Switch Invidious Instance": "", + "Broken? Try another Invidious Instance": "", "Hide annotations": "隱藏註釋", "Show annotations": "顯示註釋", "Genre: ": "風格: ", diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr index db0a8d56..f5e3e39b 100644 --- a/src/invidious/views/search.ecr +++ b/src/invidious/views/search.ecr @@ -5,7 +5,7 @@ <% if count == 0 %>

- <%= translate(locale, "Broken?") %> "><%= translate(locale, "Switch Invidious Instance") %> + "><%= translate(locale, "Broken? Try another Invidious Instance!") %>

<% else %>
From b63bebb519c448df6576c7bd124f2ce7681cc203 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 15 May 2021 20:08:33 -0700 Subject: [PATCH 13/25] Allow automatic instance redirect to be turned off Instead the "switch invidious instance" link would bring users to redirect.invidious.io --- locales/ar.json | 4 +++- locales/bn_BD.json | 2 ++ locales/cs.json | 2 ++ locales/da.json | 2 ++ locales/de.json | 2 ++ locales/el.json | 2 ++ locales/en-US.json | 2 ++ locales/eo.json | 2 ++ locales/es.json | 2 ++ locales/eu.json | 2 ++ locales/fa.json | 2 ++ locales/fi.json | 2 ++ locales/fr.json | 2 ++ locales/he.json | 2 ++ locales/hr.json | 2 ++ locales/hu-HU.json | 2 ++ locales/id.json | 2 ++ locales/is.json | 2 ++ locales/it.json | 2 ++ locales/ja.json | 2 ++ locales/nb-NO.json | 2 ++ locales/nl.json | 4 +++- locales/pl.json | 2 ++ locales/pt-BR.json | 2 ++ locales/pt-PT.json | 2 ++ locales/ro.json | 4 +++- locales/ru.json | 4 +++- locales/si.json | 2 ++ locales/sk.json | 2 ++ locales/sr.json | 2 ++ locales/sr_Cyrl.json | 2 ++ locales/sv-SE.json | 2 ++ locales/tr.json | 2 ++ locales/uk.json | 4 +++- locales/zh-CN.json | 2 ++ locales/zh-TW.json | 2 ++ src/invidious/helpers/helpers.cr | 1 + src/invidious/routes/misc.cr | 7 ++++++- src/invidious/routes/preferences.cr | 5 +++++ src/invidious/users.cr | 1 + src/invidious/views/preferences.ecr | 7 +++++++ 41 files changed, 97 insertions(+), 6 deletions(-) diff --git a/locales/ar.json b/locales/ar.json index a14e4101..b12c4cb8 100644 --- a/locales/ar.json +++ b/locales/ar.json @@ -86,6 +86,8 @@ "dark": "غامق (اسود)", "light": "فاتح (ابيض)", "Thin mode: ": "الوضع الخفيف: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "تفضيلات الإشتراك", "Show annotations by default for subscribed channels: ": "عرض الملاحظات في الفيديوهات تلقائيا في القنوات المشترك بها فقط: ", "Redirect homepage to feed: ": "إعادة التوجية من الصفحة الرئيسية لصفحة المشتركين (لرؤية اخر فيديوهات المشتركين): ", @@ -418,4 +420,4 @@ "hdr": "وضع التباين العالي", "filter": "معامل الفرز", "Current version: ": "الإصدار الحالي: " -} +} \ No newline at end of file diff --git a/locales/bn_BD.json b/locales/bn_BD.json index 9b1df424..9de526d5 100644 --- a/locales/bn_BD.json +++ b/locales/bn_BD.json @@ -80,6 +80,8 @@ "dark": "", "light": "", "Thin mode: ": "", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "", "Show annotations by default for subscribed channels: ": "", "Redirect homepage to feed: ": "", diff --git a/locales/cs.json b/locales/cs.json index b85bcd10..3d59466a 100644 --- a/locales/cs.json +++ b/locales/cs.json @@ -86,6 +86,8 @@ "dark": "tmavý", "light": "světlý", "Thin mode: ": "Kompaktní režim: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Nastavení předplatných", "Show annotations by default for subscribed channels: ": "Ve výchozím nastavení zobrazovat poznámky u odebíraných kanálů: ", "Redirect homepage to feed: ": "Přesměrovávat domovskou stránku na informační kanál: ", diff --git a/locales/da.json b/locales/da.json index 525c9d0f..03b176f4 100644 --- a/locales/da.json +++ b/locales/da.json @@ -86,6 +86,8 @@ "dark": "mørk", "light": "lys", "Thin mode: ": "Tynd tilstand: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Abonnements præferencer", "Show annotations by default for subscribed channels: ": "Vis annotationer som standard for abonnerede kanaler: ", "Redirect homepage to feed: ": "Omdiriger startside til feed: ", diff --git a/locales/de.json b/locales/de.json index 2192fd97..606fbeb5 100644 --- a/locales/de.json +++ b/locales/de.json @@ -86,6 +86,8 @@ "dark": "Nachtmodus", "light": "heller Modus", "Thin mode: ": "Schlanker Modus: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Abonnementeinstellungen", "Show annotations by default for subscribed channels: ": "Anmerkungen für abonnierte Kanäle standardmäßig anzeigen? ", "Redirect homepage to feed: ": "Startseite zu Feed umleiten: ", diff --git a/locales/el.json b/locales/el.json index 9192edf3..94611e82 100644 --- a/locales/el.json +++ b/locales/el.json @@ -86,6 +86,8 @@ "dark": "σκοτεινό", "light": "φωτεινό", "Thin mode: ": "Ελαφριά λειτουργία: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Προτιμήσεις συνδρομών", "Show annotations by default for subscribed channels: ": "Προβολή σημειώσεων μόνο για κανάλια στα οποία είστε συνδρομητής; ", "Redirect homepage to feed: ": "Ανακατεύθυνση αρχικής στη ροή συνδρομών: ", diff --git a/locales/en-US.json b/locales/en-US.json index 6d6a88ea..29eae79e 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -86,6 +86,8 @@ "dark": "dark", "light": "light", "Thin mode: ": "Thin mode: ", + "Miscellaneous preferences": "Miscellaneous preferences", + "Automatically redirect to another Instance: ": "Automatically redirect to another Instance: ", "Subscription preferences": "Subscription preferences", "Show annotations by default for subscribed channels: ": "Show annotations by default for subscribed channels? ", "Redirect homepage to feed: ": "Redirect homepage to feed: ", diff --git a/locales/eo.json b/locales/eo.json index 5528845b..69811006 100644 --- a/locales/eo.json +++ b/locales/eo.json @@ -86,6 +86,8 @@ "dark": "malhela", "light": "hela", "Thin mode: ": "Maldika reĝimo: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Abonaj agordoj", "Show annotations by default for subscribed channels: ": "Ĉu montri prinotojn defaŭlte por abonitaj kanaloj? ", "Redirect homepage to feed: ": "Alidirekti hejmpâgon al fluo: ", diff --git a/locales/es.json b/locales/es.json index fa83d6dc..25329d40 100644 --- a/locales/es.json +++ b/locales/es.json @@ -86,6 +86,8 @@ "dark": "oscuro", "light": "claro", "Thin mode: ": "Modo compacto: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Preferencias de la suscripción", "Show annotations by default for subscribed channels: ": "¿Mostrar anotaciones por defecto para los canales suscritos? ", "Redirect homepage to feed: ": "Redirigir la página de inicio a la fuente: ", diff --git a/locales/eu.json b/locales/eu.json index ec90b82e..426d721f 100644 --- a/locales/eu.json +++ b/locales/eu.json @@ -77,6 +77,8 @@ "dark": "iluna", "light": "argia", "Thin mode: ": "", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Harpidetzen hobespenak", "Show annotations by default for subscribed channels: ": "", "Redirect homepage to feed: ": "", diff --git a/locales/fa.json b/locales/fa.json index 5bc99b60..6b40af62 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -86,6 +86,8 @@ "dark": "تاریک", "light": "روشن", "Thin mode: ": "حالت نازک: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "ترجیحات اشتراک", "Show annotations by default for subscribed channels: ": "نمایش حاشیه نویسی ها به طور پیشفرض برای کانال های مشترک شده: ", "Redirect homepage to feed: ": "تغییر مسیر صفحه خانه به خوراک: ", diff --git a/locales/fi.json b/locales/fi.json index f4aeae2b..24a4ec36 100644 --- a/locales/fi.json +++ b/locales/fi.json @@ -86,6 +86,8 @@ "dark": "tumma", "light": "vaalea", "Thin mode: ": "Kapea tila ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Tilausten asetukset", "Show annotations by default for subscribed channels: ": "Näytä oletuksena tilattujen kanavien huomautukset: ", "Redirect homepage to feed: ": "Uudelleenohjaa kotisivu syötteeseen: ", diff --git a/locales/fr.json b/locales/fr.json index 21dd2798..75cd2be0 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -87,6 +87,8 @@ "light": "clair", "Thin mode: ": "Mode léger : ", "Subscription preferences": "Préférences des abonnements", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Show annotations by default for subscribed channels: ": "Afficher les annotations par défaut sur les chaînes auxquelles vous êtes abonnés : ", "Redirect homepage to feed: ": "Rediriger la page d'accueil vers la page d'abonnements : ", "Number of videos shown in feed: ": "Nombre de vidéos affichées dans la page d'abonnements : ", diff --git a/locales/he.json b/locales/he.json index 1645bd93..368a7e08 100644 --- a/locales/he.json +++ b/locales/he.json @@ -86,6 +86,8 @@ "dark": "כהה", "light": "בהיר", "Thin mode: ": "", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "העדפות מינויים", "Show annotations by default for subscribed channels: ": "Show annotations by default for subscribed channels? ", "Redirect homepage to feed: ": "", diff --git a/locales/hr.json b/locales/hr.json index 6c313666..5cadab8f 100644 --- a/locales/hr.json +++ b/locales/hr.json @@ -86,6 +86,8 @@ "dark": "tamno", "light": "svijetlo", "Thin mode: ": "Pojednostavljen prikaz: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Postavke pretplata", "Show annotations by default for subscribed channels: ": "Standardno prikaži napomene za pretplaćene kanale: ", "Redirect homepage to feed: ": "Preusmjeri početnu stranicu na feed: ", diff --git a/locales/hu-HU.json b/locales/hu-HU.json index a25597d5..5c67b4e7 100644 --- a/locales/hu-HU.json +++ b/locales/hu-HU.json @@ -77,6 +77,8 @@ "dark": "sötét", "light": "világos", "Thin mode: ": "Vékony mód: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Feliratkozási beállítások", "Show annotations by default for subscribed channels: ": "Szövegmagyarázatok mutatása alapértelmezésben feliratkozott csatornák esetében: ", "Redirect homepage to feed: ": "Kezdő oldal átirányitása a feed-re: ", diff --git a/locales/id.json b/locales/id.json index 5cf3e65c..0ed116b8 100644 --- a/locales/id.json +++ b/locales/id.json @@ -86,6 +86,8 @@ "dark": "gelap", "light": "terang", "Thin mode: ": "Mode tipis: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Preferensi langganan", "Show annotations by default for subscribed channels: ": "Tampilkan anotasi secara default untuk kanal langganan: ", "Redirect homepage to feed: ": "Arahkan kembali laman beranda ke umpan: ", diff --git a/locales/is.json b/locales/is.json index d80e10e2..d9ec4105 100644 --- a/locales/is.json +++ b/locales/is.json @@ -86,6 +86,8 @@ "dark": "dimmt", "light": "ljóst", "Thin mode: ": "Þunnt ham: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Áskriftarstillingar", "Show annotations by default for subscribed channels: ": "Á að sýna glósur sjálfgefið fyrir áskriftarrásir? ", "Redirect homepage to feed: ": "Endurbeina heimasíðu að straumi: ", diff --git a/locales/it.json b/locales/it.json index e1446f8b..4105e83f 100644 --- a/locales/it.json +++ b/locales/it.json @@ -86,6 +86,8 @@ "dark": "scuro", "light": "chiaro", "Thin mode: ": "Modalità per connessioni lente: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Preferenze iscrizioni", "Show annotations by default for subscribed channels: ": "Mostrare annotazioni in modo predefinito per i canali sottoscritti: ", "Redirect homepage to feed: ": "Reindirizza la pagina principale a quella delle iscrizioni: ", diff --git a/locales/ja.json b/locales/ja.json index 80cbdd81..3c6efb77 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -86,6 +86,8 @@ "dark": "ダーク", "light": "ライト", "Thin mode: ": "最小モード: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "登録チャンネル設定", "Show annotations by default for subscribed channels: ": "デフォルトで登録チャンネルのアノテーションを表示しますか? ", "Redirect homepage to feed: ": "ホームからフィードにリダイレクト: ", diff --git a/locales/nb-NO.json b/locales/nb-NO.json index 55e0da68..4b5eabd0 100644 --- a/locales/nb-NO.json +++ b/locales/nb-NO.json @@ -86,6 +86,8 @@ "dark": "Mørk", "light": "Lys", "Thin mode: ": "Tynt modus: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Abonnementsinnstillinger", "Show annotations by default for subscribed channels: ": "Vis merknader som forvalg for kanaler det abonneres på? ", "Redirect homepage to feed: ": "Videresend hjemmeside til kilde: ", diff --git a/locales/nl.json b/locales/nl.json index c73952ee..16cdb427 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -86,6 +86,8 @@ "dark": "donker", "light": "licht", "Thin mode: ": "Smalle modus: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Abonnementsinstellingen", "Show annotations by default for subscribed channels: ": "Standaard annotaties tonen voor geabonneerde kanalen? ", "Redirect homepage to feed: ": "Startpagina omleiden naar feed: ", @@ -418,4 +420,4 @@ "hdr": "HDR", "filter": "verfijnen", "Current version: ": "Huidige versie: " -} +} \ No newline at end of file diff --git a/locales/pl.json b/locales/pl.json index ac170c0a..f8df837c 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -86,6 +86,8 @@ "dark": "ciemny", "light": "jasny", "Thin mode: ": "Tryb minimalny: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Preferencje subskrybcji", "Show annotations by default for subscribed channels: ": "Domyślnie wyświetlaj adnotacje dla subskrybowanych kanałów: ", "Redirect homepage to feed: ": "Przekieruj stronę główną do subskrybcji: ", diff --git a/locales/pt-BR.json b/locales/pt-BR.json index 8a112a8a..644aa34d 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -86,6 +86,8 @@ "dark": "escuro", "light": "claro", "Thin mode: ": "Modo compacto: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Preferências de inscrições", "Show annotations by default for subscribed channels: ": "Sempre mostrar anotações dos vídeos de canais inscritos: ", "Redirect homepage to feed: ": "Redirecionar página inicial para o feed: ", diff --git a/locales/pt-PT.json b/locales/pt-PT.json index 4555f870..c02ca58e 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -86,6 +86,8 @@ "dark": "escuro", "light": "claro", "Thin mode: ": "Modo compacto: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Preferências de subscrições", "Show annotations by default for subscribed channels: ": "Mostrar sempre anotações aos canais subscritos: ", "Redirect homepage to feed: ": "Redirecionar página inicial para subscrições: ", diff --git a/locales/ro.json b/locales/ro.json index e021a622..5c984ab5 100644 --- a/locales/ro.json +++ b/locales/ro.json @@ -86,6 +86,8 @@ "dark": "întunecat", "light": "luminos", "Thin mode: ": "Mod lejer: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Preferințele paginii de abonamente", "Show annotations by default for subscribed channels: ": "Afișați adnotările în mod implicit pentru canalele la care v-ați abonat: ", "Redirect homepage to feed: ": "Redirecționați pagina principală la pagina de abonamente: ", @@ -418,4 +420,4 @@ "hdr": "", "filter": "", "Current version: ": "Versiunea actuală: " -} +} \ No newline at end of file diff --git a/locales/ru.json b/locales/ru.json index db1be8ea..cd29f06a 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -86,6 +86,8 @@ "dark": "темная", "light": "светлая", "Thin mode: ": "Облегчённое оформление: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Настройки подписок", "Show annotations by default for subscribed channels: ": "Всегда показывать аннотации в видео каналов, на которые вы подписаны? ", "Redirect homepage to feed: ": "Отображать видео с каналов, на которые вы подписаны, как главную страницу: ", @@ -418,4 +420,4 @@ "hdr": "", "filter": "", "Current version: ": "Текущая версия: " -} +} \ No newline at end of file diff --git a/locales/si.json b/locales/si.json index 3ff9b4ed..23cacc1e 100644 --- a/locales/si.json +++ b/locales/si.json @@ -86,6 +86,8 @@ "dark": "", "light": "", "Thin mode: ": "", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "", "Show annotations by default for subscribed channels: ": "", "Redirect homepage to feed: ": "", diff --git a/locales/sk.json b/locales/sk.json index eb696e5b..ed82fae6 100644 --- a/locales/sk.json +++ b/locales/sk.json @@ -80,6 +80,8 @@ "dark": "tmavá", "light": "svetlá", "Thin mode: ": "Tenký režim: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Nastavenia predplatného", "Show annotations by default for subscribed channels: ": "Predvolene zobraziť anotácie odoberaných kanálov: ", "Redirect homepage to feed: ": "Presmerovanie domovskej stránky na informačný kanál: ", diff --git a/locales/sr.json b/locales/sr.json index 76f9fab6..0c64e176 100644 --- a/locales/sr.json +++ b/locales/sr.json @@ -86,6 +86,8 @@ "dark": "", "light": "", "Thin mode: ": "", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "", "Show annotations by default for subscribed channels: ": "", "Redirect homepage to feed: ": "", diff --git a/locales/sr_Cyrl.json b/locales/sr_Cyrl.json index 2f5a5f60..a76684b4 100644 --- a/locales/sr_Cyrl.json +++ b/locales/sr_Cyrl.json @@ -77,6 +77,8 @@ "dark": "тамна", "light": "светла", "Thin mode: ": "Узани режим: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Подешавања о праћењима", "Show annotations by default for subscribed channels: ": "Увек приказуј анотације за канале које пратим: ", "Redirect homepage to feed: ": "Прикажи праћења као почетну страницу: ", diff --git a/locales/sv-SE.json b/locales/sv-SE.json index 8ecc5424..fe12f8d1 100644 --- a/locales/sv-SE.json +++ b/locales/sv-SE.json @@ -86,6 +86,8 @@ "dark": "Mörkt", "light": "Ljust", "Thin mode: ": "Lättviktigt läge: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Prenumerationsinställningar", "Show annotations by default for subscribed channels: ": "Visa länkar-i-videor som förval för kanaler som prenumereras på? ", "Redirect homepage to feed: ": "Omdirigera hemsida till flöde: ", diff --git a/locales/tr.json b/locales/tr.json index 2314b4ab..ca36023a 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -86,6 +86,8 @@ "dark": "karanlık", "light": "aydınlık", "Thin mode: ": "İnce mod: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Abonelik tercihleri", "Show annotations by default for subscribed channels: ": "Abone olunan kanallar için ek açıklamaları öntanımlı olarak göster: ", "Redirect homepage to feed: ": "Ana sayfayı akışa yönlendir: ", diff --git a/locales/uk.json b/locales/uk.json index ca44e3bb..9e9239d1 100644 --- a/locales/uk.json +++ b/locales/uk.json @@ -86,6 +86,8 @@ "dark": "темна", "light": "Світла", "Thin mode: ": "Полегшене оформлення: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "Налаштування підписок", "Show annotations by default for subscribed channels: ": "Завжди показувати анотації у відео каналів, на які ви підписані? ", "Redirect homepage to feed: ": "Показувати відео з каналів, на які підписані, як головну сторінку: ", @@ -418,4 +420,4 @@ "hdr": "", "filter": "", "Current version: ": "Поточна версія: " -} +} \ No newline at end of file diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 28935e4a..7f58d67c 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -86,6 +86,8 @@ "dark": "暗色", "light": "亮色", "Thin mode: ": "窄页模式: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "订阅设置", "Show annotations by default for subscribed channels: ": "默认情况下显示已订阅频道的注释: ", "Redirect homepage to feed: ": "跳转主页到 feed: ", diff --git a/locales/zh-TW.json b/locales/zh-TW.json index bdae7678..61a9f118 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -86,6 +86,8 @@ "dark": "深色", "light": "淺色", "Thin mode: ": "精簡模式: ", + "Miscellaneous preferences": "", + "Automatically redirect to another Instance: ": "", "Subscription preferences": "訂閱偏好設定", "Show annotations by default for subscribed channels: ": "預設為已訂閱的頻道顯示註釋: ", "Redirect homepage to feed: ": "重新導向首頁至 feed: ", diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 1f92c4ce..b020d4fe 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -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 diff --git a/src/invidious/routes/misc.cr b/src/invidious/routes/misc.cr index 13fc65bb..336f7e33 100644 --- a/src/invidious/routes/misc.cr +++ b/src/invidious/routes/misc.cr @@ -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 diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr index f98c7a5e..20f68aea 100644 --- a/src/invidious/routes/preferences.cr +++ b/src/invidious/routes/preferences.cr @@ -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, diff --git a/src/invidious/users.cr b/src/invidious/users.cr index d774ee12..98ef8792 100644 --- a/src/invidious/users.cr +++ b/src/invidious/users.cr @@ -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)] diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr index 1e1e8cae..bc09ec79 100644 --- a/src/invidious/views/preferences.ecr +++ b/src/invidious/views/preferences.ecr @@ -176,6 +176,13 @@ <% end %>
+ <%= translate(locale, "Miscellaneous preferences") %> + +
+ + checked<% end %>> +
+ <% if env.get? "user" %> <%= translate(locale, "Subscription preferences") %> From 950c8f7104ca0973bc439e8e7707440869d0bb94 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 15 May 2021 20:15:09 -0700 Subject: [PATCH 14/25] Enhance fetch_random_instance func Handle cross-inst. redirect w/ broken health stats Add check for instance version in cross-redirect --- src/invidious/helpers/utils.cr | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index cb94b44a..7c573aba 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -417,9 +417,31 @@ def fetch_random_instance filtered_instance_list = [] of String instance_list.as_a.each do |data| if data[1]["type"] == "https" - if data[1]["monitor"] - health = data[1]["monitor"].as_h["dailyRatios"][0].as_h["ratio"] - filtered_instance_list << data[0].as_s if health.to_s.to_f > 90 + # Makes sure the instance isn't too outdated. + remote_version = data[1]["stats"]["software"]["version"] + remote_commit_date = remote_version.as_s.match(/\d{4}\.\d{2}\.\d{2}/) + next if !remote_commit_date + remote_commit_date = Time.parse(remote_commit_date[0], "%Y.%m.%d", Time::Location::UTC) + local_commit_date = Time.parse(CURRENT_VERSION, "%Y.%m.%d", Time::Location::UTC) + + if (remote_commit_date - local_commit_date).abs.days <= 30 + # as_nil? doesn't exist. Thus we'll have to handle the error rasied if + # as_nil fails. + begin + broken_health_monitoring = data[1]["monitor"].as_nil + broken_health_monitoring = true if broken_health_monitoring.nil? + rescue TypeCastError + broken_health_monitoring = false + end + + if !broken_health_monitoring + health = data[1]["monitor"].as_h["dailyRatios"][0].as_h["ratio"] + filtered_instance_list << data[0].as_s if health.to_s.to_f > 90 + else + # We can't check the health if the monitoring is broken. Thus we'll just add it to the list + # and move on + filtered_instance_list << data[0].as_s + end end end end From 173cd7c15ea3aa044c9852572f99691c943d64a0 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 15 May 2021 21:10:53 -0700 Subject: [PATCH 15/25] Fix switch invidious instance btn on videos --- src/invidious/helpers/utils.cr | 2 +- src/invidious/views/components/item.ecr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 7c573aba..ec8aee9e 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -435,7 +435,7 @@ def fetch_random_instance end if !broken_health_monitoring - health = data[1]["monitor"].as_h["dailyRatios"][0].as_h["ratio"] + health = data[1]["monitor"].as_h["dailyRatios"][0].as_h["ratio"] filtered_instance_list << data[0].as_s if health.to_s.to_f > 90 else # We can't check the health if the monitoring is broken. Thus we'll just add it to the list diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr index 532de6ac..6f027bee 100644 --- a/src/invidious/views/components/item.ecr +++ b/src/invidious/views/components/item.ecr @@ -148,7 +148,7 @@ " href="/watch?v=<%= item.id %>&listen=1"> - " href="/redirect?referer=<%= env.get?("current_page") %>"> + " href="/redirect?referer=<%=HTML.escape("watch?v=#{item.id}")%>"> From b9cd40fe1e095f72440bb64180314b71d4f3f185 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 15 May 2021 22:01:46 -0700 Subject: [PATCH 16/25] Add redirect buttons to error template --- locales/en-US.json | 5 ++++- src/invidious/helpers/errors.cr | 37 +++++++++++++++++++++++++++++++++ src/invidious/views/error.ecr | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/locales/en-US.json b/locales/en-US.json index 29eae79e..106bdcf2 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -419,5 +419,8 @@ "location": "Location", "hdr": "HDR", "filter": "Filter", - "Current version: ": "Current version: " + "Current version: ": "Current version: ", + "next_steps_error_message": "After which you should try to: ", + "next_steps_error_message_refresh": "Refresh", + "next_steps_error_message_go_to_youtube": "Go to Youtube" } diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr index 68ced430..714e0670 100644 --- a/src/invidious/helpers/errors.cr +++ b/src/invidious/helpers/errors.cr @@ -40,6 +40,9 @@ def error_template_helper(env : HTTP::Server::Context, locale : Hash(String, JSO and include the following text in your message:
#{issue_template}
END_HTML + + next_steps = error_redirect_helper(env, locale) + return templated "error" end @@ -47,6 +50,7 @@ def error_template_helper(env : HTTP::Server::Context, locale : Hash(String, JSO env.response.content_type = "text/html" env.response.status_code = status_code error_message = translate(locale, message) + next_steps = error_redirect_helper(env, locale) return templated "error" end @@ -103,3 +107,36 @@ end def error_json_helper(env : HTTP::Server::Context, locale : Hash(String, JSON::Any) | Nil, status_code : Int32, message : String) error_json_helper(env, locale, status_code, message, nil) end + +def error_redirect_helper(env : HTTP::Server::Context, locale : Hash(String, JSON::Any) | Nil) + request_path = env.request.path + + if request_path.starts_with?("/search") || request_path.starts_with?("/watch") || + request_path.starts_with?("/channel") || request_path.starts_with?("/playlist?list=PL") + + next_steps_text = translate(locale, "next_steps_error_message") + refresh = translate(locale, "next_steps_error_message_refresh") + go_to_youtube = translate(locale, "next_steps_error_message_go_to_youtube") + switch_instance = translate(locale, "Switch Invidious Instance") + + + return <<-END_HTML +

#{next_steps_text}

+ + END_HTML + + return next_step_html + else + return "" + end +end \ No newline at end of file diff --git a/src/invidious/views/error.ecr b/src/invidious/views/error.ecr index d0752e5b..04eb74d5 100644 --- a/src/invidious/views/error.ecr +++ b/src/invidious/views/error.ecr @@ -4,4 +4,5 @@
<%= error_message %> + <%= next_steps %>
From 2f54ec4e18d20a0d3a36e8e192389819b57d8dc3 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 15 May 2021 22:36:10 -0700 Subject: [PATCH 17/25] Fix locale consistency for err template redirects --- locales/ar.json | 5 +++- locales/bn_BD.json | 5 +++- locales/cs.json | 5 +++- locales/da.json | 5 +++- locales/de.json | 5 +++- locales/el.json | 5 +++- locales/eo.json | 5 +++- locales/es.json | 5 +++- locales/eu.json | 5 +++- locales/fa.json | 5 +++- locales/fi.json | 5 +++- locales/fr.json | 5 +++- locales/he.json | 5 +++- locales/hr.json | 5 +++- locales/hu-HU.json | 5 +++- locales/id.json | 5 +++- locales/is.json | 5 +++- locales/it.json | 5 +++- locales/ja.json | 5 +++- locales/nb-NO.json | 5 +++- locales/nl.json | 5 +++- locales/pl.json | 5 +++- locales/pt-BR.json | 5 +++- locales/pt-PT.json | 5 +++- locales/ro.json | 5 +++- locales/ru.json | 5 +++- locales/si.json | 5 +++- locales/sk.json | 5 +++- locales/sr.json | 5 +++- locales/sr_Cyrl.json | 5 +++- locales/sv-SE.json | 5 +++- locales/tr.json | 5 +++- locales/uk.json | 5 +++- locales/zh-CN.json | 5 +++- locales/zh-TW.json | 5 +++- src/invidious/helpers/errors.cr | 50 ++++++++++++++++----------------- 36 files changed, 164 insertions(+), 61 deletions(-) diff --git a/locales/ar.json b/locales/ar.json index b12c4cb8..bc0c6830 100644 --- a/locales/ar.json +++ b/locales/ar.json @@ -419,5 +419,8 @@ "location": "الاماكن", "hdr": "وضع التباين العالي", "filter": "معامل الفرز", - "Current version: ": "الإصدار الحالي: " + "Current version: ": "الإصدار الحالي: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } \ No newline at end of file diff --git a/locales/bn_BD.json b/locales/bn_BD.json index 9de526d5..83bd6555 100644 --- a/locales/bn_BD.json +++ b/locales/bn_BD.json @@ -358,5 +358,8 @@ "Videos": "", "Playlists": "", "Community": "", - "Current version: ": "" + "Current version: ": "", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/cs.json b/locales/cs.json index 3d59466a..c8320a07 100644 --- a/locales/cs.json +++ b/locales/cs.json @@ -419,5 +419,8 @@ "location": "umístění", "hdr": "HDR", "filter": "filtr", - "Current version: ": "" + "Current version: ": "", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/da.json b/locales/da.json index 03b176f4..d207939c 100644 --- a/locales/da.json +++ b/locales/da.json @@ -419,5 +419,8 @@ "location": "", "hdr": "", "filter": "", - "Current version: ": "" + "Current version: ": "", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/de.json b/locales/de.json index 606fbeb5..b602192b 100644 --- a/locales/de.json +++ b/locales/de.json @@ -419,5 +419,8 @@ "location": "Standort", "hdr": "HDR", "filter": "Filtern", - "Current version: ": "Aktuelle Version: " + "Current version: ": "Aktuelle Version: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/el.json b/locales/el.json index 94611e82..f7588c60 100644 --- a/locales/el.json +++ b/locales/el.json @@ -419,5 +419,8 @@ "location": "", "hdr": "", "filter": "", - "Current version: ": "Τρέχουσα έκδοση: " + "Current version: ": "Τρέχουσα έκδοση: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/eo.json b/locales/eo.json index 69811006..7ac38c35 100644 --- a/locales/eo.json +++ b/locales/eo.json @@ -419,5 +419,8 @@ "location": "loko", "hdr": "granddinamikgama", "filter": "filtri", - "Current version: ": "Nuna versio: " + "Current version: ": "Nuna versio: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/es.json b/locales/es.json index 25329d40..e160526e 100644 --- a/locales/es.json +++ b/locales/es.json @@ -419,5 +419,8 @@ "location": "ubicación", "hdr": "hdr", "filter": "filtro", - "Current version: ": "Versión actual: " + "Current version: ": "Versión actual: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/eu.json b/locales/eu.json index 426d721f..34820a50 100644 --- a/locales/eu.json +++ b/locales/eu.json @@ -341,5 +341,8 @@ "Videos": "", "Playlists": "", "Community": "", - "Current version: ": "" + "Current version: ": "", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/fa.json b/locales/fa.json index 6b40af62..611cc57d 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -419,5 +419,8 @@ "location": "", "hdr": "", "filter": "", - "Current version: ": "نسخه فعلی: " + "Current version: ": "نسخه فعلی: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/fi.json b/locales/fi.json index 24a4ec36..b446332c 100644 --- a/locales/fi.json +++ b/locales/fi.json @@ -419,5 +419,8 @@ "location": "", "hdr": "", "filter": "", - "Current version: ": "Tämänhetkinen versio: " + "Current version: ": "Tämänhetkinen versio: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/fr.json b/locales/fr.json index 75cd2be0..4a685d35 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -419,5 +419,8 @@ "location": "emplacement", "hdr": "HDR", "filter": "filtrer", - "Current version: ": "Version actuelle : " + "Current version: ": "Version actuelle : ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/he.json b/locales/he.json index 368a7e08..d4c70a36 100644 --- a/locales/he.json +++ b/locales/he.json @@ -419,5 +419,8 @@ "location": "מיקום", "hdr": "HDR", "filter": "סינון", - "Current version: ": "הגרסה הנוכחית: " + "Current version: ": "הגרסה הנוכחית: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/hr.json b/locales/hr.json index 5cadab8f..ab9dd54b 100644 --- a/locales/hr.json +++ b/locales/hr.json @@ -419,5 +419,8 @@ "location": "lokacija", "hdr": "hdr", "filter": "filtar", - "Current version: ": "Trenutačna verzija: " + "Current version: ": "Trenutačna verzija: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/hu-HU.json b/locales/hu-HU.json index 5c67b4e7..a0c6c17f 100644 --- a/locales/hu-HU.json +++ b/locales/hu-HU.json @@ -340,5 +340,8 @@ "Videos": "Videók", "Playlists": "Lejátszási listák", "Community": "Közösség", - "Current version: ": "Jelenlegi verzió: " + "Current version: ": "Jelenlegi verzió: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/id.json b/locales/id.json index 0ed116b8..07d252e6 100644 --- a/locales/id.json +++ b/locales/id.json @@ -419,5 +419,8 @@ "location": "lokasi", "hdr": "hdr", "filter": "saring", - "Current version: ": "Versi saat ini: " + "Current version: ": "Versi saat ini: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/is.json b/locales/is.json index d9ec4105..546d67f8 100644 --- a/locales/is.json +++ b/locales/is.json @@ -419,5 +419,8 @@ "location": "", "hdr": "", "filter": "", - "Current version: ": "Núverandi útgáfa: " + "Current version: ": "Núverandi útgáfa: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/it.json b/locales/it.json index 4105e83f..1a14f172 100644 --- a/locales/it.json +++ b/locales/it.json @@ -419,5 +419,8 @@ "location": "Posizione", "hdr": "HDR", "filter": "Filtra", - "Current version: ": "Versione attuale: " + "Current version: ": "Versione attuale: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/ja.json b/locales/ja.json index 3c6efb77..7a80955d 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -419,5 +419,8 @@ "location": "", "hdr": "HDR", "filter": "フィルタ", - "Current version: ": "現在のバージョン: " + "Current version: ": "現在のバージョン: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/nb-NO.json b/locales/nb-NO.json index 4b5eabd0..fec2637f 100644 --- a/locales/nb-NO.json +++ b/locales/nb-NO.json @@ -419,5 +419,8 @@ "location": "sted", "hdr": "HDR", "filter": "filtrer", - "Current version: ": "Gjeldende versjon: " + "Current version: ": "Gjeldende versjon: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/nl.json b/locales/nl.json index 16cdb427..30ddd49f 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -419,5 +419,8 @@ "location": "locatie", "hdr": "HDR", "filter": "verfijnen", - "Current version: ": "Huidige versie: " + "Current version: ": "Huidige versie: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } \ No newline at end of file diff --git a/locales/pl.json b/locales/pl.json index f8df837c..12177ce6 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -419,5 +419,8 @@ "location": "", "hdr": "hdr", "filter": "filtr", - "Current version: ": "Aktualna wersja: " + "Current version: ": "Aktualna wersja: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/pt-BR.json b/locales/pt-BR.json index 644aa34d..13f2c65f 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -419,5 +419,8 @@ "location": "localização", "hdr": "hdr", "filter": "filtro", - "Current version: ": "Versão atual: " + "Current version: ": "Versão atual: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/pt-PT.json b/locales/pt-PT.json index c02ca58e..acc08c65 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -419,5 +419,8 @@ "location": "", "hdr": "", "filter": "", - "Current version: ": "Versão atual: " + "Current version: ": "Versão atual: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/ro.json b/locales/ro.json index 5c984ab5..a1cbb270 100644 --- a/locales/ro.json +++ b/locales/ro.json @@ -419,5 +419,8 @@ "location": "", "hdr": "", "filter": "", - "Current version: ": "Versiunea actuală: " + "Current version: ": "Versiunea actuală: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } \ No newline at end of file diff --git a/locales/ru.json b/locales/ru.json index cd29f06a..9381c578 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -419,5 +419,8 @@ "location": "", "hdr": "", "filter": "", - "Current version: ": "Текущая версия: " + "Current version: ": "Текущая версия: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } \ No newline at end of file diff --git a/locales/si.json b/locales/si.json index 23cacc1e..cbc9bdde 100644 --- a/locales/si.json +++ b/locales/si.json @@ -419,5 +419,8 @@ "location": "", "hdr": "", "filter": "", - "Current version: ": "" + "Current version: ": "", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/sk.json b/locales/sk.json index ed82fae6..9330232e 100644 --- a/locales/sk.json +++ b/locales/sk.json @@ -358,5 +358,8 @@ "Videos": "", "Playlists": "", "Community": "", - "Current version: ": "" + "Current version: ": "", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/sr.json b/locales/sr.json index 0c64e176..4835e9a3 100644 --- a/locales/sr.json +++ b/locales/sr.json @@ -417,5 +417,8 @@ "location": "", "hdr": "", "filter": "", - "Current version: ": "" + "Current version: ": "", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/sr_Cyrl.json b/locales/sr_Cyrl.json index a76684b4..7ac90fc8 100644 --- a/locales/sr_Cyrl.json +++ b/locales/sr_Cyrl.json @@ -341,5 +341,8 @@ "Videos": "", "Playlists": "", "Community": "", - "Current version: ": "Тренутна верзија: " + "Current version: ": "Тренутна верзија: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/sv-SE.json b/locales/sv-SE.json index fe12f8d1..bc148143 100644 --- a/locales/sv-SE.json +++ b/locales/sv-SE.json @@ -419,5 +419,8 @@ "location": "plats", "hdr": "hdr", "filter": "", - "Current version: ": "Nuvarande version: " + "Current version: ": "Nuvarande version: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/tr.json b/locales/tr.json index ca36023a..6ada31b5 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -419,5 +419,8 @@ "location": "konum", "hdr": "HDR", "filter": "filtrele", - "Current version: ": "Şu anki sürüm: " + "Current version: ": "Şu anki sürüm: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/uk.json b/locales/uk.json index 9e9239d1..6580bb83 100644 --- a/locales/uk.json +++ b/locales/uk.json @@ -419,5 +419,8 @@ "location": "", "hdr": "", "filter": "", - "Current version: ": "Поточна версія: " + "Current version: ": "Поточна версія: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } \ No newline at end of file diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 7f58d67c..fdd87687 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -419,5 +419,8 @@ "location": "位置", "hdr": "hdr", "filter": "过滤器", - "Current version: ": "当前版本: " + "Current version: ": "当前版本: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/locales/zh-TW.json b/locales/zh-TW.json index 61a9f118..3a060e63 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -419,5 +419,8 @@ "location": "位置", "hdr": "HDR", "filter": "篩選條件", - "Current version: ": "目前版本: " + "Current version: ": "目前版本: ", + "next_steps_error_message": "", + "next_steps_error_message_refresh": "", + "next_steps_error_message_go_to_youtube": "" } diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr index 714e0670..e1d02563 100644 --- a/src/invidious/helpers/errors.cr +++ b/src/invidious/helpers/errors.cr @@ -108,35 +108,33 @@ def error_json_helper(env : HTTP::Server::Context, locale : Hash(String, JSON::A error_json_helper(env, locale, status_code, message, nil) end -def error_redirect_helper(env : HTTP::Server::Context, locale : Hash(String, JSON::Any) | Nil) +def error_redirect_helper(env : HTTP::Server::Context, locale : Hash(String, JSON::Any) | Nil) request_path = env.request.path - if request_path.starts_with?("/search") || request_path.starts_with?("/watch") || - request_path.starts_with?("/channel") || request_path.starts_with?("/playlist?list=PL") + if request_path.starts_with?("/search") || request_path.starts_with?("/watch") || + request_path.starts_with?("/channel") || request_path.starts_with?("/playlist?list=PL") + next_steps_text = translate(locale, "next_steps_error_message") + refresh = translate(locale, "next_steps_error_message_refresh") + go_to_youtube = translate(locale, "next_steps_error_message_go_to_youtube") + switch_instance = translate(locale, "Switch Invidious Instance") - next_steps_text = translate(locale, "next_steps_error_message") - refresh = translate(locale, "next_steps_error_message_refresh") - go_to_youtube = translate(locale, "next_steps_error_message_go_to_youtube") - switch_instance = translate(locale, "Switch Invidious Instance") - - - return <<-END_HTML -

#{next_steps_text}

- - END_HTML - - return next_step_html + return <<-END_HTML +

#{next_steps_text}

+ + END_HTML + + return next_step_html else return "" end -end \ No newline at end of file +end From d793d4ba78e331e17690940fcc1a53d65b09ee22 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 15 May 2021 22:45:14 -0700 Subject: [PATCH 18/25] Add switch invidious instance btn to all chan tabs --- src/invidious/views/community.ecr | 3 +++ src/invidious/views/playlists.ecr | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr index 3c4eaabb..b0092e5f 100644 --- a/src/invidious/views/community.ecr +++ b/src/invidious/views/community.ecr @@ -40,6 +40,9 @@
<%= translate(locale, "View channel on YouTube") %> + <% if !channel.auto_generated %>
<%= translate(locale, "Videos") %> diff --git a/src/invidious/views/playlists.ecr b/src/invidious/views/playlists.ecr index 44bdb94d..975ccd6c 100644 --- a/src/invidious/views/playlists.ecr +++ b/src/invidious/views/playlists.ecr @@ -42,6 +42,11 @@ + + + From 4a095eb98ef9f3d819d2561877f3ed127a767d71 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 15 May 2021 23:01:21 -0700 Subject: [PATCH 19/25] Fix
styling on empty search page --- src/invidious/routes/preferences.cr | 56 ++++++++++++++--------------- src/invidious/views/search.ecr | 6 +++- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr index 20f68aea..d6002ffd 100644 --- a/src/invidious/routes/preferences.cr +++ b/src/invidious/routes/preferences.cr @@ -126,35 +126,35 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute # Convert to JSON and back again to take advantage of converters used for compatability preferences = Preferences.from_json({ - annotations: annotations, - annotations_subscribed: annotations_subscribed, - autoplay: autoplay, - captions: captions, - comments: comments, - continue: continue, - continue_autoplay: continue_autoplay, - dark_mode: dark_mode, - latest_only: latest_only, - listen: listen, - local: local, - locale: locale, - max_results: max_results, - notifications_only: notifications_only, - player_style: player_style, - quality: quality, - quality_dash: quality_dash, - default_home: default_home, - feed_menu: feed_menu, + annotations: annotations, + annotations_subscribed: annotations_subscribed, + autoplay: autoplay, + captions: captions, + comments: comments, + continue: continue, + continue_autoplay: continue_autoplay, + dark_mode: dark_mode, + latest_only: latest_only, + listen: listen, + local: local, + locale: locale, + max_results: max_results, + notifications_only: notifications_only, + player_style: player_style, + quality: quality, + 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, - thin_mode: thin_mode, - unseen_only: unseen_only, - video_loop: video_loop, - volume: volume, - extend_desc: extend_desc, - vr_mode: vr_mode, + related_videos: related_videos, + sort: sort, + speed: speed, + thin_mode: thin_mode, + unseen_only: unseen_only, + video_loop: video_loop, + volume: volume, + extend_desc: extend_desc, + vr_mode: vr_mode, }.to_json).to_json if user = env.get? "user" diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr index f5e3e39b..15389dce 100644 --- a/src/invidious/views/search.ecr +++ b/src/invidious/views/search.ecr @@ -96,7 +96,11 @@
<% end %> -
+<% if count == 0 %> +
+<% else %> +
+<% end %>
From b393e31b766d5fa2156befe61eb2ba023a845208 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 12 Jun 2021 15:35:30 -0700 Subject: [PATCH 20/25] Fix inst. fetching for inst w/ disabled stats/err --- src/invidious/helpers/utils.cr | 51 ++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index ec8aee9e..72cb1b1d 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -415,35 +415,52 @@ def fetch_random_instance instance_list = JSON.parse(instance_list.body) filtered_instance_list = [] of String - instance_list.as_a.each do |data| - if data[1]["type"] == "https" - # Makes sure the instance isn't too outdated. - remote_version = data[1]["stats"]["software"]["version"] - remote_commit_date = remote_version.as_s.match(/\d{4}\.\d{2}\.\d{2}/) - next if !remote_commit_date - remote_commit_date = Time.parse(remote_commit_date[0], "%Y.%m.%d", Time::Location::UTC) - local_commit_date = Time.parse(CURRENT_VERSION, "%Y.%m.%d", Time::Location::UTC) - if (remote_commit_date - local_commit_date).abs.days <= 30 + instance_list.as_a.each do |data| + # TODO Check if current URL is onion instance and use .onion types if so. + if data[1]["type"] == "https" + # Instances can have statisitics disabled, which is an requirement of version validation. + begin + data[1]["stats"].as_nil + statistics_disabled = true + next + rescue TypeCastError + statistics_disabled = false + end + + # stats endpoint could also lack the software dict. + next if statistics_disabled || data[1]["stats"]["software"]?.nil? + + # Makes sure the instance isn't too outdated. + if remote_version = data[1]["stats"]?.try &.["software"]?.try &.["version"] + remote_commit_date = remote_version.as_s.match(/\d{4}\.\d{2}\.\d{2}/) + next if !remote_commit_date + + remote_commit_date = Time.parse(remote_commit_date[0], "%Y.%m.%d", Time::Location::UTC) + local_commit_date = Time.parse(CURRENT_VERSION, "%Y.%m.%d", Time::Location::UTC) + + next if (remote_commit_date - local_commit_date).abs.days > 30 + # as_nil? doesn't exist. Thus we'll have to handle the error rasied if # as_nil fails. begin broken_health_monitoring = data[1]["monitor"].as_nil - broken_health_monitoring = true if broken_health_monitoring.nil? - rescue TypeCastError - broken_health_monitoring = false - end - - if !broken_health_monitoring health = data[1]["monitor"].as_h["dailyRatios"][0].as_h["ratio"] filtered_instance_list << data[0].as_s if health.to_s.to_f > 90 - else + rescue TypeCastError # We can't check the health if the monitoring is broken. Thus we'll just add it to the list - # and move on + # and move on. Ideally we'll ignore any instance that has broken health monitoring but due to the fact that + # it's an error that often occurs with all the instances at the same time, we have to just skip the check. filtered_instance_list << data[0].as_s end end end end + + # If for some reason no instances managed to get fetched successfully then we'll just redirect to redirect.invidious.io + if filtered_instance_list.size == 0 + return "redirect.invidious.io" + end + return filtered_instance_list.sample(1)[0] end From eb911de92842ecfdb2005822dbaa94d82855f191 Mon Sep 17 00:00:00 2001 From: syeopite Date: Mon, 14 Jun 2021 02:31:51 -0700 Subject: [PATCH 21/25] Handle if inst. api is down for rand inst fetch --- src/invidious/helpers/utils.cr | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 72cb1b1d..32359e9a 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -411,12 +411,22 @@ def convert_theme(theme) end def fetch_random_instance - instance_list = HTTP::Client.get "https://api.invidious.io/instances.json" - instance_list = JSON.parse(instance_list.body) + begin + instance_api_client = HTTP::Client.new("api.invidious.io") + + # Timeouts + instance_api_client.connect_timeout = 10.seconds + instance_api_client.dns_timeout = 10.seconds + + instance_list = JSON.parse(instance_api_client.get("/instances.json").body).as_a + instance_api_client.close + rescue Socket::ConnectError | IO::TimeoutError | JSON::ParseException + instance_list = [] of JSON::Any + end filtered_instance_list = [] of String - instance_list.as_a.each do |data| + instance_list.each do |data| # TODO Check if current URL is onion instance and use .onion types if so. if data[1]["type"] == "https" # Instances can have statisitics disabled, which is an requirement of version validation. From 45e57f1ad30bd2fe731bc70ac099a6ce68255180 Mon Sep 17 00:00:00 2001 From: syeopite Date: Mon, 14 Jun 2021 02:53:53 -0700 Subject: [PATCH 22/25] Refactor fetch_random_instance --- src/invidious/helpers/utils.cr | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 32359e9a..c53d5ee0 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -430,16 +430,15 @@ def fetch_random_instance # TODO Check if current URL is onion instance and use .onion types if so. if data[1]["type"] == "https" # Instances can have statisitics disabled, which is an requirement of version validation. + # as_nil? doesn't exist. Thus we'll have to handle the error rasied if as_nil fails. begin data[1]["stats"].as_nil - statistics_disabled = true next rescue TypeCastError - statistics_disabled = false end # stats endpoint could also lack the software dict. - next if statistics_disabled || data[1]["stats"]["software"]?.nil? + next if data[1]["stats"]["software"]?.nil? # Makes sure the instance isn't too outdated. if remote_version = data[1]["stats"]?.try &.["software"]?.try &.["version"] @@ -451,10 +450,8 @@ def fetch_random_instance next if (remote_commit_date - local_commit_date).abs.days > 30 - # as_nil? doesn't exist. Thus we'll have to handle the error rasied if - # as_nil fails. begin - broken_health_monitoring = data[1]["monitor"].as_nil + data[1]["monitor"].as_nil health = data[1]["monitor"].as_h["dailyRatios"][0].as_h["ratio"] filtered_instance_list << data[0].as_s if health.to_s.to_f > 90 rescue TypeCastError From 7c49a0ba7a92a8c6e527a1fbb75c37980bec0586 Mon Sep 17 00:00:00 2001 From: syeopite Date: Mon, 14 Jun 2021 03:00:07 -0700 Subject: [PATCH 23/25] Rephrase auto instance redirect preference --- locales/ar.json | 4 ++-- locales/de.json | 2 +- locales/el.json | 2 +- locales/en-US.json | 2 +- locales/eo.json | 2 +- locales/es.json | 2 +- locales/fa.json | 2 +- locales/fi.json | 2 +- locales/fr.json | 2 +- locales/he.json | 2 +- locales/hr.json | 2 +- locales/id.json | 2 +- locales/is.json | 2 +- locales/it.json | 2 +- locales/ja.json | 2 +- locales/nb-NO.json | 2 +- locales/nl.json | 4 ++-- locales/pl.json | 2 +- locales/pt-BR.json | 2 +- locales/pt-PT.json | 2 +- locales/ro.json | 4 ++-- locales/ru.json | 4 ++-- locales/sv-SE.json | 2 +- locales/tr.json | 2 +- locales/uk.json | 4 ++-- locales/zh-CN.json | 2 +- locales/zh-TW.json | 2 +- src/invidious/views/preferences.ecr | 2 +- 28 files changed, 33 insertions(+), 33 deletions(-) diff --git a/locales/ar.json b/locales/ar.json index bc0c6830..119c36e4 100644 --- a/locales/ar.json +++ b/locales/ar.json @@ -87,7 +87,7 @@ "light": "فاتح (ابيض)", "Thin mode: ": "الوضع الخفيف: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "تفضيلات الإشتراك", "Show annotations by default for subscribed channels: ": "عرض الملاحظات في الفيديوهات تلقائيا في القنوات المشترك بها فقط: ", "Redirect homepage to feed: ": "إعادة التوجية من الصفحة الرئيسية لصفحة المشتركين (لرؤية اخر فيديوهات المشتركين): ", @@ -423,4 +423,4 @@ "next_steps_error_message": "", "next_steps_error_message_refresh": "", "next_steps_error_message_go_to_youtube": "" -} \ No newline at end of file +} diff --git a/locales/de.json b/locales/de.json index b602192b..1a8870ec 100644 --- a/locales/de.json +++ b/locales/de.json @@ -87,7 +87,7 @@ "light": "heller Modus", "Thin mode: ": "Schlanker Modus: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Abonnementeinstellungen", "Show annotations by default for subscribed channels: ": "Anmerkungen für abonnierte Kanäle standardmäßig anzeigen? ", "Redirect homepage to feed: ": "Startseite zu Feed umleiten: ", diff --git a/locales/el.json b/locales/el.json index f7588c60..e6aec01a 100644 --- a/locales/el.json +++ b/locales/el.json @@ -87,7 +87,7 @@ "light": "φωτεινό", "Thin mode: ": "Ελαφριά λειτουργία: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Προτιμήσεις συνδρομών", "Show annotations by default for subscribed channels: ": "Προβολή σημειώσεων μόνο για κανάλια στα οποία είστε συνδρομητής; ", "Redirect homepage to feed: ": "Ανακατεύθυνση αρχικής στη ροή συνδρομών: ", diff --git a/locales/en-US.json b/locales/en-US.json index 106bdcf2..0cddb4c0 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -87,7 +87,7 @@ "light": "light", "Thin mode: ": "Thin mode: ", "Miscellaneous preferences": "Miscellaneous preferences", - "Automatically redirect to another Instance: ": "Automatically redirect to another Instance: ", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "Automaticatic instance redirection (fallback to redirect.invidious.io): ", "Subscription preferences": "Subscription preferences", "Show annotations by default for subscribed channels: ": "Show annotations by default for subscribed channels? ", "Redirect homepage to feed: ": "Redirect homepage to feed: ", diff --git a/locales/eo.json b/locales/eo.json index 7ac38c35..8be07305 100644 --- a/locales/eo.json +++ b/locales/eo.json @@ -87,7 +87,7 @@ "light": "hela", "Thin mode: ": "Maldika reĝimo: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Abonaj agordoj", "Show annotations by default for subscribed channels: ": "Ĉu montri prinotojn defaŭlte por abonitaj kanaloj? ", "Redirect homepage to feed: ": "Alidirekti hejmpâgon al fluo: ", diff --git a/locales/es.json b/locales/es.json index e160526e..fa377151 100644 --- a/locales/es.json +++ b/locales/es.json @@ -87,7 +87,7 @@ "light": "claro", "Thin mode: ": "Modo compacto: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Preferencias de la suscripción", "Show annotations by default for subscribed channels: ": "¿Mostrar anotaciones por defecto para los canales suscritos? ", "Redirect homepage to feed: ": "Redirigir la página de inicio a la fuente: ", diff --git a/locales/fa.json b/locales/fa.json index 611cc57d..145479ad 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -87,7 +87,7 @@ "light": "روشن", "Thin mode: ": "حالت نازک: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "ترجیحات اشتراک", "Show annotations by default for subscribed channels: ": "نمایش حاشیه نویسی ها به طور پیشفرض برای کانال های مشترک شده: ", "Redirect homepage to feed: ": "تغییر مسیر صفحه خانه به خوراک: ", diff --git a/locales/fi.json b/locales/fi.json index b446332c..e9cee129 100644 --- a/locales/fi.json +++ b/locales/fi.json @@ -87,7 +87,7 @@ "light": "vaalea", "Thin mode: ": "Kapea tila ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Tilausten asetukset", "Show annotations by default for subscribed channels: ": "Näytä oletuksena tilattujen kanavien huomautukset: ", "Redirect homepage to feed: ": "Uudelleenohjaa kotisivu syötteeseen: ", diff --git a/locales/fr.json b/locales/fr.json index 4a685d35..9bb2fe16 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -87,8 +87,8 @@ "light": "clair", "Thin mode: ": "Mode léger : ", "Subscription preferences": "Préférences des abonnements", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", "Show annotations by default for subscribed channels: ": "Afficher les annotations par défaut sur les chaînes auxquelles vous êtes abonnés : ", "Redirect homepage to feed: ": "Rediriger la page d'accueil vers la page d'abonnements : ", "Number of videos shown in feed: ": "Nombre de vidéos affichées dans la page d'abonnements : ", diff --git a/locales/he.json b/locales/he.json index d4c70a36..5345b93d 100644 --- a/locales/he.json +++ b/locales/he.json @@ -87,7 +87,7 @@ "light": "בהיר", "Thin mode: ": "", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "העדפות מינויים", "Show annotations by default for subscribed channels: ": "Show annotations by default for subscribed channels? ", "Redirect homepage to feed: ": "", diff --git a/locales/hr.json b/locales/hr.json index ab9dd54b..2f78469b 100644 --- a/locales/hr.json +++ b/locales/hr.json @@ -87,7 +87,7 @@ "light": "svijetlo", "Thin mode: ": "Pojednostavljen prikaz: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Postavke pretplata", "Show annotations by default for subscribed channels: ": "Standardno prikaži napomene za pretplaćene kanale: ", "Redirect homepage to feed: ": "Preusmjeri početnu stranicu na feed: ", diff --git a/locales/id.json b/locales/id.json index 07d252e6..679a3403 100644 --- a/locales/id.json +++ b/locales/id.json @@ -87,7 +87,7 @@ "light": "terang", "Thin mode: ": "Mode tipis: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Preferensi langganan", "Show annotations by default for subscribed channels: ": "Tampilkan anotasi secara default untuk kanal langganan: ", "Redirect homepage to feed: ": "Arahkan kembali laman beranda ke umpan: ", diff --git a/locales/is.json b/locales/is.json index 546d67f8..05893333 100644 --- a/locales/is.json +++ b/locales/is.json @@ -87,7 +87,7 @@ "light": "ljóst", "Thin mode: ": "Þunnt ham: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Áskriftarstillingar", "Show annotations by default for subscribed channels: ": "Á að sýna glósur sjálfgefið fyrir áskriftarrásir? ", "Redirect homepage to feed: ": "Endurbeina heimasíðu að straumi: ", diff --git a/locales/it.json b/locales/it.json index 1a14f172..ec45d2eb 100644 --- a/locales/it.json +++ b/locales/it.json @@ -87,7 +87,7 @@ "light": "chiaro", "Thin mode: ": "Modalità per connessioni lente: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Preferenze iscrizioni", "Show annotations by default for subscribed channels: ": "Mostrare annotazioni in modo predefinito per i canali sottoscritti: ", "Redirect homepage to feed: ": "Reindirizza la pagina principale a quella delle iscrizioni: ", diff --git a/locales/ja.json b/locales/ja.json index 7a80955d..af5dac7a 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -87,7 +87,7 @@ "light": "ライト", "Thin mode: ": "最小モード: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "登録チャンネル設定", "Show annotations by default for subscribed channels: ": "デフォルトで登録チャンネルのアノテーションを表示しますか? ", "Redirect homepage to feed: ": "ホームからフィードにリダイレクト: ", diff --git a/locales/nb-NO.json b/locales/nb-NO.json index fec2637f..6d66527d 100644 --- a/locales/nb-NO.json +++ b/locales/nb-NO.json @@ -87,7 +87,7 @@ "light": "Lys", "Thin mode: ": "Tynt modus: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Abonnementsinnstillinger", "Show annotations by default for subscribed channels: ": "Vis merknader som forvalg for kanaler det abonneres på? ", "Redirect homepage to feed: ": "Videresend hjemmeside til kilde: ", diff --git a/locales/nl.json b/locales/nl.json index 30ddd49f..5f2fa265 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -87,7 +87,7 @@ "light": "licht", "Thin mode: ": "Smalle modus: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Abonnementsinstellingen", "Show annotations by default for subscribed channels: ": "Standaard annotaties tonen voor geabonneerde kanalen? ", "Redirect homepage to feed: ": "Startpagina omleiden naar feed: ", @@ -423,4 +423,4 @@ "next_steps_error_message": "", "next_steps_error_message_refresh": "", "next_steps_error_message_go_to_youtube": "" -} \ No newline at end of file +} diff --git a/locales/pl.json b/locales/pl.json index 12177ce6..227a9cbb 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -87,7 +87,7 @@ "light": "jasny", "Thin mode: ": "Tryb minimalny: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Preferencje subskrybcji", "Show annotations by default for subscribed channels: ": "Domyślnie wyświetlaj adnotacje dla subskrybowanych kanałów: ", "Redirect homepage to feed: ": "Przekieruj stronę główną do subskrybcji: ", diff --git a/locales/pt-BR.json b/locales/pt-BR.json index 13f2c65f..7810671e 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -87,7 +87,7 @@ "light": "claro", "Thin mode: ": "Modo compacto: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Preferências de inscrições", "Show annotations by default for subscribed channels: ": "Sempre mostrar anotações dos vídeos de canais inscritos: ", "Redirect homepage to feed: ": "Redirecionar página inicial para o feed: ", diff --git a/locales/pt-PT.json b/locales/pt-PT.json index acc08c65..0aa19d3f 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -87,7 +87,7 @@ "light": "claro", "Thin mode: ": "Modo compacto: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Preferências de subscrições", "Show annotations by default for subscribed channels: ": "Mostrar sempre anotações aos canais subscritos: ", "Redirect homepage to feed: ": "Redirecionar página inicial para subscrições: ", diff --git a/locales/ro.json b/locales/ro.json index a1cbb270..71e50ca5 100644 --- a/locales/ro.json +++ b/locales/ro.json @@ -87,7 +87,7 @@ "light": "luminos", "Thin mode: ": "Mod lejer: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Preferințele paginii de abonamente", "Show annotations by default for subscribed channels: ": "Afișați adnotările în mod implicit pentru canalele la care v-ați abonat: ", "Redirect homepage to feed: ": "Redirecționați pagina principală la pagina de abonamente: ", @@ -423,4 +423,4 @@ "next_steps_error_message": "", "next_steps_error_message_refresh": "", "next_steps_error_message_go_to_youtube": "" -} \ No newline at end of file +} diff --git a/locales/ru.json b/locales/ru.json index 9381c578..15d97862 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -87,7 +87,7 @@ "light": "светлая", "Thin mode: ": "Облегчённое оформление: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Настройки подписок", "Show annotations by default for subscribed channels: ": "Всегда показывать аннотации в видео каналов, на которые вы подписаны? ", "Redirect homepage to feed: ": "Отображать видео с каналов, на которые вы подписаны, как главную страницу: ", @@ -423,4 +423,4 @@ "next_steps_error_message": "", "next_steps_error_message_refresh": "", "next_steps_error_message_go_to_youtube": "" -} \ No newline at end of file +} diff --git a/locales/sv-SE.json b/locales/sv-SE.json index bc148143..911df096 100644 --- a/locales/sv-SE.json +++ b/locales/sv-SE.json @@ -87,7 +87,7 @@ "light": "Ljust", "Thin mode: ": "Lättviktigt läge: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Prenumerationsinställningar", "Show annotations by default for subscribed channels: ": "Visa länkar-i-videor som förval för kanaler som prenumereras på? ", "Redirect homepage to feed: ": "Omdirigera hemsida till flöde: ", diff --git a/locales/tr.json b/locales/tr.json index 6ada31b5..436cb512 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -87,7 +87,7 @@ "light": "aydınlık", "Thin mode: ": "İnce mod: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Abonelik tercihleri", "Show annotations by default for subscribed channels: ": "Abone olunan kanallar için ek açıklamaları öntanımlı olarak göster: ", "Redirect homepage to feed: ": "Ana sayfayı akışa yönlendir: ", diff --git a/locales/uk.json b/locales/uk.json index 6580bb83..91ac8626 100644 --- a/locales/uk.json +++ b/locales/uk.json @@ -87,7 +87,7 @@ "light": "Світла", "Thin mode: ": "Полегшене оформлення: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "Налаштування підписок", "Show annotations by default for subscribed channels: ": "Завжди показувати анотації у відео каналів, на які ви підписані? ", "Redirect homepage to feed: ": "Показувати відео з каналів, на які підписані, як головну сторінку: ", @@ -423,4 +423,4 @@ "next_steps_error_message": "", "next_steps_error_message_refresh": "", "next_steps_error_message_go_to_youtube": "" -} \ No newline at end of file +} diff --git a/locales/zh-CN.json b/locales/zh-CN.json index fdd87687..e7150627 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -87,7 +87,7 @@ "light": "亮色", "Thin mode: ": "窄页模式: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "订阅设置", "Show annotations by default for subscribed channels: ": "默认情况下显示已订阅频道的注释: ", "Redirect homepage to feed: ": "跳转主页到 feed: ", diff --git a/locales/zh-TW.json b/locales/zh-TW.json index 3a060e63..d9a486ef 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -87,7 +87,7 @@ "light": "淺色", "Thin mode: ": "精簡模式: ", "Miscellaneous preferences": "", - "Automatically redirect to another Instance: ": "", + "Automaticatic instance redirection (fallback to redirect.invidious.io): ": "", "Subscription preferences": "訂閱偏好設定", "Show annotations by default for subscribed channels: ": "預設為已訂閱的頻道顯示註釋: ", "Redirect homepage to feed: ": "重新導向首頁至 feed: ", diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr index bc09ec79..c5b64ad6 100644 --- a/src/invidious/views/preferences.ecr +++ b/src/invidious/views/preferences.ecr @@ -179,7 +179,7 @@ <%= translate(locale, "Miscellaneous preferences") %>
- + checked<% end %>>
From 09f7e38eed63f37e0a2a07c4acd48a5339589b7f Mon Sep 17 00:00:00 2001 From: syeopite <70992037+syeopite@users.noreply.github.com> Date: Mon, 14 Jun 2021 04:59:36 -0700 Subject: [PATCH 24/25] Disable automatic instance redirection by default --- src/invidious/helpers/helpers.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index b020d4fe..0c70cb02 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -44,7 +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 automatic_instance_redirect : Bool = false property related_videos : Bool = true property sort : String = "published" property speed : Float32 = 1.0_f32 From cb525af0a28aa8e8d3394eb3074eee39ae0b594a Mon Sep 17 00:00:00 2001 From: syeopite Date: Wed, 16 Jun 2021 01:32:33 -0700 Subject: [PATCH 25/25] Connect to api.invidious.io with https --- src/invidious/helpers/utils.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index c53d5ee0..6ee07d7a 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -412,7 +412,7 @@ end def fetch_random_instance begin - instance_api_client = HTTP::Client.new("api.invidious.io") + instance_api_client = HTTP::Client.new(URI.parse("https://api.invidious.io")) # Timeouts instance_api_client.connect_timeout = 10.seconds