Merge 32059f5767735425a0365529535ad9fc096e0b70 into e012334975059b14a110799024184680db5c1629

This commit is contained in:
Sushanth012 2026-05-01 17:59:57 -07:00 committed by GitHub
commit a457f024ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 24 additions and 1 deletions

View File

@ -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): ",

View File

@ -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

View File

@ -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

View File

@ -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 *,
@ -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

View File

@ -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

View File

@ -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

View File

@ -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 %>>