diff --git a/config/config.example.yml b/config/config.example.yml index 7cc480c64..45d8f8619 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -939,6 +939,14 @@ default_user_preferences: ## #sort: published + ## + ## In the "Subscription" feed, Only show the videos, no shorts + ## or livestreams. + ## + ## Accepted values: true, false + ## Default: false + ## + #hide_shorts_and_live: false # ----------------------------- # Miscellaneous diff --git a/locales/en-US.json b/locales/en-US.json index 5b2ef8d0e..1a0b19ee1 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -133,6 +133,7 @@ "Only show latest video from channel: ": "Only show latest video from channel: ", "Only show latest unwatched video from channel: ": "Only show latest unwatched video from channel: ", "preferences_unseen_only_label": "Only show unwatched: ", + "preferences_hide_shorts_and_live_label": "Hide shorts and live streams: ", "preferences_notifications_only_label": "Only show notifications (if there are any): ", "Enable web notifications": "Enable web notifications", "`x` uploaded a video": "`x` uploaded a video", diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 7853d9a3b..ab2612ee7 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -47,6 +47,7 @@ struct ConfigPreferences property thin_mode : Bool = false property unseen_only : Bool = false property video_loop : Bool = false + property hide_shorts_and_live : Bool = false property extend_desc : Bool = false property volume : Int32 = 100 property vr_mode : Bool = true diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr index d9fad1b18..10c00c3a9 100644 --- a/src/invidious/routes/preferences.cr +++ b/src/invidious/routes/preferences.cr @@ -143,6 +143,10 @@ module Invidious::Routes::PreferencesRoute notifications_only ||= "off" notifications_only = notifications_only == "on" + hide_shorts_and_live = env.params.body["hide_shorts_and_live"]?.try &.as(String) + hide_shorts_and_live ||= "off" + hide_shorts_and_live = hide_shorts_and_live == "on" + default_playlist = env.params.body["default_playlist"]?.try &.as(String) # Convert to JSON and back again to take advantage of converters used for compatibility @@ -182,6 +186,7 @@ module Invidious::Routes::PreferencesRoute show_nick: show_nick, save_player_pos: save_player_pos, default_playlist: default_playlist, + hide_shorts_and_live: hide_shorts_and_live, }.to_json) if user = env.get? "user" diff --git a/src/invidious/user/preferences.cr b/src/invidious/user/preferences.cr index df195dd69..d1099e095 100644 --- a/src/invidious/user/preferences.cr +++ b/src/invidious/user/preferences.cr @@ -57,6 +57,7 @@ struct Preferences property volume : Int32 = CONFIG.default_user_preferences.volume property save_player_pos : Bool = CONFIG.default_user_preferences.save_player_pos property default_playlist : String? = nil + property hide_shorts_and_live : Bool = CONFIG.default_user_preferences.hide_shorts_and_live module BoolToString def self.to_json(value : String, json : JSON::Builder) diff --git a/src/invidious/users.cr b/src/invidious/users.cr index 65566d207..963e93bda 100644 --- a/src/invidious/users.cr +++ b/src/invidious/users.cr @@ -83,6 +83,10 @@ def get_subscription_feed(user, max_results = 40, page = 1) end end + if user.preferences.hide_shorts_and_live + videos = videos.select { |v| v.length_seconds > 0 } + end + case user.preferences.sort when "published - reverse" videos.sort_by!(&.published) diff --git a/src/invidious/views/user/preferences.ecr b/src/invidious/views/user/preferences.ecr index 23cb89f69..c714775c5 100644 --- a/src/invidious/views/user/preferences.ecr +++ b/src/invidious/views/user/preferences.ecr @@ -229,6 +229,11 @@ checked<% end %>> +
+ + checked<% end %>> +
+
checked<% end %>>