diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/config.cr | 1 | ||||
| -rw-r--r-- | src/invidious/helpers/i18n.cr | 12 | ||||
| -rw-r--r-- | src/invidious/routes/feeds.cr | 2 | ||||
| -rw-r--r-- | src/invidious/routes/preferences.cr | 3 | ||||
| -rw-r--r-- | src/invidious/user/preferences.cr | 1 | ||||
| -rw-r--r-- | src/invidious/views/preferences.ecr | 9 |
6 files changed, 27 insertions, 1 deletions
diff --git a/src/invidious/config.cr b/src/invidious/config.cr index e2bc5722..bacdb4ac 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -31,6 +31,7 @@ struct ConfigPreferences property default_home : String? = "Popular" property feed_menu : Array(String) = ["Popular", "Trending", "Subscriptions", "Playlists"] property automatic_instance_redirect : Bool = false + property region : String = "US" property related_videos : Bool = true property sort : String = "published" property speed : Float32 = 1.0_f32 diff --git a/src/invidious/helpers/i18n.cr b/src/invidious/helpers/i18n.cr index 2ed4f150..9e42fad0 100644 --- a/src/invidious/helpers/i18n.cr +++ b/src/invidious/helpers/i18n.cr @@ -41,6 +41,18 @@ LOCALES = { "zh-TW" => load_locale("zh-TW"), # Chinese (Traditional) } +CONTENT_REGIONS = { + "AE", "AR", "AT", "AU", "AZ", "BA", "BD", "BE", "BG", "BH", "BO", "BR", "BY", + "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "DZ", "EC", "EE", + "EG", "ES", "FI", "FR", "GB", "GE", "GH", "GR", "GT", "HK", "HN", "HR", "HU", + "ID", "IE", "IL", "IN", "IQ", "IS", "IT", "JM", "JO", "JP", "KE", "KR", "KW", + "KZ", "LB", "LI", "LK", "LT", "LU", "LV", "LY", "MA", "ME", "MK", "MT", "MX", + "MY", "NG", "NI", "NL", "NO", "NP", "NZ", "OM", "PA", "PE", "PG", "PH", "PK", + "PL", "PR", "PT", "PY", "QA", "RO", "RS", "RU", "SA", "SE", "SG", "SI", "SK", + "SN", "SV", "TH", "TN", "TR", "TW", "TZ", "UA", "UG", "US", "UY", "VE", "VN", + "YE", "ZA", "ZW", +} + def load_locale(name) return JSON.parse(File.read("locales/#{name}.json")).as_h end diff --git a/src/invidious/routes/feeds.cr b/src/invidious/routes/feeds.cr index d9280529..40c41dc1 100644 --- a/src/invidious/routes/feeds.cr +++ b/src/invidious/routes/feeds.cr @@ -48,7 +48,7 @@ module Invidious::Routes::Feeds trending_type ||= "Default" region = env.params.query["region"]? - region ||= "US" + region ||= env.get("preferences").as(Preferences).region begin trending, plid = fetch_trending(trending_type, region, locale) diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr index ae5407dc..8793d4e9 100644 --- a/src/invidious/routes/preferences.cr +++ b/src/invidious/routes/preferences.cr @@ -102,6 +102,8 @@ module Invidious::Routes::PreferencesRoute automatic_instance_redirect ||= "off" automatic_instance_redirect = automatic_instance_redirect == "on" + region = env.params.body["region"]?.try &.as(String) + locale = env.params.body["locale"]?.try &.as(String) locale ||= CONFIG.default_user_preferences.locale @@ -152,6 +154,7 @@ module Invidious::Routes::PreferencesRoute default_home: default_home, feed_menu: feed_menu, automatic_instance_redirect: automatic_instance_redirect, + region: region, related_videos: related_videos, sort: sort, speed: speed, diff --git a/src/invidious/user/preferences.cr b/src/invidious/user/preferences.cr index 453a635e..c15876f5 100644 --- a/src/invidious/user/preferences.cr +++ b/src/invidious/user/preferences.cr @@ -28,6 +28,7 @@ struct Preferences @[JSON::Field(converter: Preferences::ProcessString)] property locale : String = CONFIG.default_user_preferences.locale + property region : String? = CONFIG.default_user_preferences.region @[JSON::Field(converter: Preferences::ClampInt)] property max_results : Int32 = CONFIG.default_user_preferences.max_results diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr index 345dc368..374edc99 100644 --- a/src/invidious/views/preferences.ecr +++ b/src/invidious/views/preferences.ecr @@ -128,6 +128,15 @@ </div> <div class="pure-control-group"> + <label for="region"><%= translate(locale, "preferences_region_label") %></label> + <select name="region" id="region"> + <% CONTENT_REGIONS.each do |option| %> + <option value="<%= option %>" <% if preferences.region == option %> selected <% end %>><%= option %></option> + <% end %> + </select> + </div> + + <div class="pure-control-group"> <label for="player_style"><%= translate(locale, "preferences_player_style_label") %></label> <select name="player_style" id="player_style"> <% {"invidious", "youtube"}.each do |option| %> |
