Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"preferences_captions_label": "Default captions: ",
"Fallback captions: ": "Fallback captions: ",
"preferences_related_videos_label": "Show related videos: ",
"preferences_filter_short_videos_label": "Hide Shorts / videos under 1 minute: ",
"preferences_annotations_label": "Show annotations by default: ",
"preferences_extend_desc_label": "Automatically extend video description: ",
"preferences_vr_mode_label": "Interactive 360 degree videos (requires WebGL): ",
Expand Down
1 change: 1 addition & 0 deletions src/invidious/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct ConfigPreferences
property unseen_only : Bool = false
property video_loop : Bool = false
property extend_desc : Bool = false
property filter_short_videos : Bool = false
property volume : Int32 = 100
property vr_mode : Bool = true
property show_nick : Bool = true
Expand Down
4 changes: 4 additions & 0 deletions src/invidious/routes/search.cr
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ module Invidious::Routes::Search
else
items = query.process
end

if preferences.filter_short_videos
items = items.reject { |item| item.is_a?(SearchVideo) && item.as(SearchVideo).length_seconds < 60 }
end
rescue ex : ChannelSearchException
return error_template(404, "Unable to find channel with id of '#{HTML.escape(ex.channel)}'. Are you sure that's an actual channel id? It should look like 'UC4QobU6STFB0P71PMvOGN5A'.")
rescue ex
Expand Down
8 changes: 7 additions & 1 deletion src/invidious/search/processors.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module Invidious::Search
def subscriptions(query : Query, user : Invidious::User) : Array(ChannelVideo)
view_name = "subscriptions_#{sha256(user.email)}"

return PG_DB.query_all("
videos = PG_DB.query_all("
SELECT id,title,published,updated,ucid,author,length_seconds
FROM (
SELECT *,
Expand All @@ -51,6 +51,12 @@ module Invidious::Search
query.text, (query.page - 1) * 20,
as: ChannelVideo
)

if user.preferences.filter_short_videos
videos = videos.reject { |v| v.length_seconds < 60 }
end

return videos
end
end
end
1 change: 1 addition & 0 deletions src/invidious/user/preferences.cr
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct Preferences
property unseen_only : Bool = CONFIG.default_user_preferences.unseen_only
property video_loop : Bool = CONFIG.default_user_preferences.video_loop
property extend_desc : Bool = CONFIG.default_user_preferences.extend_desc
property filter_short_videos : Bool = CONFIG.default_user_preferences.filter_short_videos
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
Expand Down
5 changes: 5 additions & 0 deletions src/invidious/users.cr
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,10 @@ def get_subscription_feed(user, max_results = 40, page = 1)
videos = videos - notifications
end

if user.preferences.filter_short_videos
videos = videos.reject { |v| v.length_seconds < 60 }
notifications = notifications.reject { |v| v.length_seconds < 60 }
end

return videos, notifications
end
5 changes: 5 additions & 0 deletions src/invidious/views/user/preferences.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@
<input name="related_videos" id="related_videos" type="checkbox" <% if preferences.related_videos %>checked<% end %>>
</div>

<div class="pure-control-group">
<label for="filter_short_videos"><%= I18n.translate(locale, "preferences_filter_short_videos_label") %></label>
<input name="filter_short_videos" id="filter_short_videos" type="checkbox" <% if preferences.filter_short_videos %>checked<% end %>>
</div>

<div class="pure-control-group">
<label for="annotations"><%= I18n.translate(locale, "preferences_annotations_label") %></label>
<input name="annotations" id="annotations" type="checkbox" <% if preferences.annotations %>checked<% end %>>
Expand Down