Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,14 @@ default_user_preferences:
##
#sort: published

##
## In the "Subscription" feed, Only show the videos, no shorts
Comment thread
Harm133 marked this conversation as resolved.
Outdated
## or livestreams.
##
## Accepted values: true, false
## Default: false
##
#hide_shorts_and_live: false

# -----------------------------
# Miscellaneous
Expand Down
1 change: 1 addition & 0 deletions locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/invidious/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/invidious/routes/preferences.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/invidious/user/preferences.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 20 additions & 6 deletions src/invidious/users.cr
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,18 @@ def get_subscription_feed(user, max_results = 40, page = 1)
else
values = "VALUES #{user.watched.map { |id| %(('#{id}')) }.join(",")}"
end
videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} WHERE NOT id = ANY (#{values}) ORDER BY ucid, published DESC", as: ChannelVideo)
if user.preferences.hide_shorts_and_live
videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} WHERE NOT id = ANY (#{values}) AND length_seconds > 0 ORDER BY ucid, published DESC", as: ChannelVideo)
else
videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} WHERE NOT id = ANY (#{values}) ORDER BY ucid, published DESC", as: ChannelVideo)
end
else
# Show latest video from each channel

videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} ORDER BY ucid, published DESC", as: ChannelVideo)
if user.preferences.hide_shorts_and_live
videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} WHERE length_seconds > 0 ORDER BY ucid, published DESC", as: ChannelVideo)
else
videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} ORDER BY ucid, published DESC", as: ChannelVideo)
end
end

videos.sort_by!(&.published).reverse!
Expand All @@ -75,11 +82,18 @@ def get_subscription_feed(user, max_results = 40, page = 1)
else
values = "VALUES #{user.watched.map { |id| %(('#{id}')) }.join(",")}"
end
videos = PG_DB.query_all("SELECT * FROM #{view_name} WHERE NOT id = ANY (#{values}) ORDER BY published DESC LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
if user.preferences.hide_shorts_and_live
videos = PG_DB.query_all("SELECT * FROM #{view_name} WHERE NOT id = ANY (#{values}) AND length_seconds > 0 ORDER BY published DESC LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
else
videos = PG_DB.query_all("SELECT * FROM #{view_name} WHERE NOT id = ANY (#{values}) ORDER BY published DESC LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
end
else
# Sort subscriptions as normal

videos = PG_DB.query_all("SELECT * FROM #{view_name} ORDER BY published DESC LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
if user.preferences.hide_shorts_and_live
videos = PG_DB.query_all("SELECT * FROM #{view_name} WHERE length_seconds > 0 ORDER BY published DESC LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
else
videos = PG_DB.query_all("SELECT * FROM #{view_name} ORDER BY published DESC LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
end
end
end

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

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

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