From e738e57e262e3b65930632e49d9988855abe8b36 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Tue, 12 Mar 2019 21:05:49 -0500 Subject: [PATCH] Add 'local' option to preferences --- locales/ar.json | 1 + locales/de.json | 1 + locales/en-US.json | 1 + locales/eu.json | 1 + locales/fr.json | 1 + locales/it.json | 1 + locales/nb_NO.json | 1 + locales/nl.json | 1 + locales/pl.json | 1 + locales/ru.json | 1 + src/invidious.cr | 5 +++++ src/invidious/users.cr | 5 +++++ src/invidious/videos.cr | 6 ++++-- src/invidious/views/preferences.ecr | 5 +++++ 14 files changed, 29 insertions(+), 2 deletions(-) diff --git a/locales/ar.json b/locales/ar.json index 6e0fef9f..18078836 100644 --- a/locales/ar.json +++ b/locales/ar.json @@ -50,6 +50,7 @@ "Autoplay: ": "تشغيل تلقائى: ", "Autoplay next video: ": "شغل الفيديو التالى تلقائى: ", "Listen by default: ": "تشغيل النسخة السمعية تلقائى: ", + "Proxy videos? ": "", "Default speed: ": "السرعة الإفتراضية: ", "Preferred video quality: ": "الجودة المفضلة للفيديوهات: ", "Player volume: ": "صوت المشغل: ", diff --git a/locales/de.json b/locales/de.json index 578a73d3..89bc09ea 100644 --- a/locales/de.json +++ b/locales/de.json @@ -50,6 +50,7 @@ "Autoplay: ": "Automatisch abspielen: ", "Autoplay next video: ": "nächstes Video automatisch abspielen: ", "Listen by default: ": "Nur Ton als Standard: ", + "Proxy videos? ": "", "Default speed: ": "Standardgeschwindigkeit: ", "Preferred video quality: ": "Bevorzugte Videoqualität: ", "Player volume: ": "Playerlautstärke: ", diff --git a/locales/en-US.json b/locales/en-US.json index 4e919ad1..68204a04 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -50,6 +50,7 @@ "Autoplay: ": "Autoplay: ", "Autoplay next video: ": "Autoplay next video: ", "Listen by default: ": "Listen by default: ", + "Proxy videos? ": "Proxy videos? ", "Default speed: ": "Default speed: ", "Preferred video quality: ": "Preferred video quality: ", "Player volume: ": "Player volume: ", diff --git a/locales/eu.json b/locales/eu.json index 6bbd73be..b71a163e 100644 --- a/locales/eu.json +++ b/locales/eu.json @@ -50,6 +50,7 @@ "Autoplay: ": "", "Autoplay next video: ": "", "Listen by default: ": "", + "Proxy videos? ": "", "Default speed: ": "", "Preferred video quality: ": "", "Player volume: ": "", diff --git a/locales/fr.json b/locales/fr.json index a459697d..7647be53 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -50,6 +50,7 @@ "Autoplay: ": "Lire Automatiquement : ", "Autoplay next video: ": "Lire automatiquement la vidéo suivante : ", "Listen by default: ": "Audio Uniquement par défaut : ", + "Proxy videos? ": "", "Default speed: ": "Vitesse par défaut : ", "Preferred video quality: ": "Qualité vidéo souhaitée : ", "Player volume: ": "Volume du lecteur : ", diff --git a/locales/it.json b/locales/it.json index e813c3bd..6fae1259 100644 --- a/locales/it.json +++ b/locales/it.json @@ -50,6 +50,7 @@ "Autoplay: ": "Riproduzione automatica: ", "Autoplay next video: ": "Riproduci automaticamente il prossimo video: ", "Listen by default: ": "Modalità solo audio come predefinita: ", + "Proxy videos? ": "", "Default speed: ": "Velocità di riproduzione predefinita: ", "Preferred video quality: ": "Preferenza sulla qualità video: ", "Player volume: ": "Volume di riproduzione: ", diff --git a/locales/nb_NO.json b/locales/nb_NO.json index 97812829..47670a73 100644 --- a/locales/nb_NO.json +++ b/locales/nb_NO.json @@ -50,6 +50,7 @@ "Autoplay: ": "Autoavspilling: ", "Autoplay next video: ": "Autospill neste video: ", "Listen by default: ": "Lytt som forvalg: ", + "Proxy videos? ": "", "Default speed: ": "Forvalgt hastighet: ", "Preferred video quality: ": "Foretrukket videokvalitet: ", "Player volume: ": "Avspillerlydstyrke: ", diff --git a/locales/nl.json b/locales/nl.json index 08df38db..3bfe0ac4 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -50,6 +50,7 @@ "Autoplay: ": "Automatisch afspelen: ", "Autoplay next video: ": "Automatisch volgende video afspelen: ", "Listen by default: ": "Standaard luisteren: ", + "Proxy videos? ": "", "Default speed: ": "Standaard snelheid: ", "Preferred video quality: ": "Video kwaliteit voorkeur: ", "Player volume: ": "Afspeler volume: ", diff --git a/locales/pl.json b/locales/pl.json index f2cfaeee..05332ca1 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -50,6 +50,7 @@ "Autoplay: ": "Autoodtwarzanie: ", "Autoplay next video: ": "Odtwórz następny film: ", "Listen by default: ": "Tryb dźwiękowy: ", + "Proxy videos? ": "", "Default speed: ": "Domyślna prędkość: ", "Preferred video quality: ": "Preferowana jakość filmów: ", "Player volume: ": "Głośność odtwarzacza: ", diff --git a/locales/ru.json b/locales/ru.json index d6db76d9..bfcd449e 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -50,6 +50,7 @@ "Autoplay: ": "Автовоспроизведение: ", "Autoplay next video: ": "Автовоспроизведение следующего видео: ", "Listen by default: ": "Режим \"только аудио\" по-умолчанию: ", + "Proxy videos? ": "", "Default speed: ": "Скорость по-умолчанию: ", "Preferred video quality: ": "Предпочтительное качество видео: ", "Player volume: ": "Громкость воспроизведения: ", diff --git a/src/invidious.cr b/src/invidious.cr index 1091b6ff..0e7a3ac1 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1231,6 +1231,10 @@ post "/preferences" do |env| listen ||= "off" listen = listen == "on" + local = env.params.body["local"]?.try &.as(String) + local ||= "off" + local = local == "on" + speed = env.params.body["speed"]?.try &.as(String).to_f? speed ||= DEFAULT_USER_PREFERENCES.speed @@ -1292,6 +1296,7 @@ post "/preferences" do |env| "autoplay" => autoplay, "continue" => continue, "listen" => listen, + "local" => local, "speed" => speed, "quality" => quality, "volume" => volume, diff --git a/src/invidious/users.cr b/src/invidious/users.cr index 42468228..308786c2 100644 --- a/src/invidious/users.cr +++ b/src/invidious/users.cr @@ -31,6 +31,7 @@ DEFAULT_USER_PREFERENCES = Preferences.from_json({ "video_loop" => false, "autoplay" => false, "continue" => false, + "local" => false, "listen" => false, "speed" => 1.0, "quality" => "hd720", @@ -80,6 +81,10 @@ class Preferences type: Bool, default: DEFAULT_USER_PREFERENCES.continue, }, + local: { + type: Bool, + default: DEFAULT_USER_PREFERENCES.local, + }, listen: { type: Bool, default: DEFAULT_USER_PREFERENCES.listen, diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 17d17d93..78dd1e5a 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -747,10 +747,11 @@ def process_video_params(query, preferences) # region ||= preferences.region autoplay ||= preferences.autoplay.to_unsafe continue ||= preferences.continue.to_unsafe - related_videos ||= preferences.related_videos.to_unsafe listen ||= preferences.listen.to_unsafe + local ||= preferences.local.to_unsafe preferred_captions ||= preferences.captions quality ||= preferences.quality + related_videos ||= preferences.related_videos.to_unsafe speed ||= preferences.speed video_loop ||= preferences.video_loop.to_unsafe volume ||= preferences.volume @@ -758,10 +759,11 @@ def process_video_params(query, preferences) autoplay ||= DEFAULT_USER_PREFERENCES.autoplay.to_unsafe continue ||= DEFAULT_USER_PREFERENCES.continue.to_unsafe - related_videos ||= DEFAULT_USER_PREFERENCES.related_videos.to_unsafe listen ||= DEFAULT_USER_PREFERENCES.listen.to_unsafe + local ||= DEFAULT_USER_PREFERENCES.local.to_unsafe preferred_captions ||= DEFAULT_USER_PREFERENCES.captions quality ||= DEFAULT_USER_PREFERENCES.quality + related_videos ||= DEFAULT_USER_PREFERENCES.related_videos.to_unsafe speed ||= DEFAULT_USER_PREFERENCES.speed video_loop ||= DEFAULT_USER_PREFERENCES.video_loop.to_unsafe volume ||= DEFAULT_USER_PREFERENCES.volume diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr index 20762bc5..d26b2179 100644 --- a/src/invidious/views/preferences.ecr +++ b/src/invidious/views/preferences.ecr @@ -28,6 +28,11 @@ function update_value(element) { checked<% end %>> +
+ + checked<% end %>> +
+
checked<% end %>>