mirror of
https://github.com/iv-org/invidious.git
synced 2026-05-02 02:59:38 -05:00
feat: add option to filter Shorts / videos under 1 minute (#5688)
This commit is contained in:
parent
afea61bb8f
commit
32059f5767
@ -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): ",
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 %>>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user