mirror of
https://github.com/iv-org/invidious.git
synced 2025-04-06 21:13:45 -04:00
Merge 643675490d45101b29411a94234a9cbde336c0ed into 0c07e9d27ac773d8423143c11bbcd36eaae0f8e4
This commit is contained in:
commit
09a2fa390c
@ -550,6 +550,11 @@ span > select {
|
||||
color: #565d64;
|
||||
}
|
||||
|
||||
.light-theme .video-badges > span {
|
||||
background: rgb(235, 235, 235);
|
||||
color: #828282;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
.no-theme a:hover,
|
||||
.no-theme a:active,
|
||||
@ -596,6 +601,11 @@ span > select {
|
||||
.light-theme .pure-menu-heading {
|
||||
color: #565d64;
|
||||
}
|
||||
|
||||
.no-theme .video-badges > span {
|
||||
background: rgb(235, 235, 235);
|
||||
color: #828282;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -658,6 +668,12 @@ body.dark-theme {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.dark-theme .video-badges > span {
|
||||
background: rgb(50, 50, 50);
|
||||
color: #9e9e9e;
|
||||
}
|
||||
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.no-theme a:hover,
|
||||
.no-theme a:active,
|
||||
@ -719,6 +735,11 @@ body.dark-theme {
|
||||
.no-theme footer a {
|
||||
color: #adadad !important;
|
||||
}
|
||||
|
||||
.no-theme .video-badges > span {
|
||||
background: rgb(50, 50, 50);
|
||||
color: #9e9e9e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -816,3 +837,19 @@ h1, h2, h3, h4, h5, p,
|
||||
#download_widget {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.video-badges > span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
|
||||
padding: 2px 10px;
|
||||
border-radius: 10px;
|
||||
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.video-badges > i {
|
||||
margin-right: 5px;
|
||||
}
|
@ -501,5 +501,7 @@
|
||||
"toggle_theme": "Toggle Theme",
|
||||
"carousel_slide": "Slide {{current}} of {{total}}",
|
||||
"carousel_skip": "Skip the Carousel",
|
||||
"carousel_go_to": "Go to slide `x`"
|
||||
"carousel_go_to": "Go to slide `x`",
|
||||
"video_badges_members_only": "Members only",
|
||||
"preferences_exclude_members_only_videos_label": "Hide channel member-only videos"
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ struct ConfigPreferences
|
||||
property vr_mode : Bool = true
|
||||
property show_nick : Bool = true
|
||||
property save_player_pos : Bool = false
|
||||
property exclude_members_only_videos : Bool = false
|
||||
|
||||
def to_tuple
|
||||
{% begin %}
|
||||
|
@ -9,6 +9,7 @@ enum VideoBadges
|
||||
VR180
|
||||
VR360
|
||||
ClosedCaptions
|
||||
MembersOnly
|
||||
end
|
||||
|
||||
struct SearchVideo
|
||||
@ -133,6 +134,7 @@ struct SearchVideo
|
||||
json.field "isVr360", self.badges.vr360?
|
||||
json.field "is3d", self.badges.three_d?
|
||||
json.field "hasCaptions", self.badges.closed_captions?
|
||||
json.field "isMembersOnly", self.badges.members_only?
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -144,6 +144,10 @@ module Invidious::Routes::PreferencesRoute
|
||||
notifications_only ||= "off"
|
||||
notifications_only = notifications_only == "on"
|
||||
|
||||
exclude_members_only_videos = env.params.body["exclude_members_only_videos"]?.try &.as(String)
|
||||
exclude_members_only_videos ||= "off"
|
||||
exclude_members_only_videos = exclude_members_only_videos == "on"
|
||||
|
||||
# Convert to JSON and back again to take advantage of converters used for compatibility
|
||||
preferences = Preferences.from_json({
|
||||
annotations: annotations,
|
||||
@ -180,6 +184,7 @@ module Invidious::Routes::PreferencesRoute
|
||||
vr_mode: vr_mode,
|
||||
show_nick: show_nick,
|
||||
save_player_pos: save_player_pos,
|
||||
exclude_members_only_videos: exclude_members_only_videos,
|
||||
}.to_json)
|
||||
|
||||
if user = env.get? "user"
|
||||
|
@ -57,6 +57,8 @@ struct Preferences
|
||||
property volume : Int32 = CONFIG.default_user_preferences.volume
|
||||
property save_player_pos : Bool = CONFIG.default_user_preferences.save_player_pos
|
||||
|
||||
property exclude_members_only_videos : Bool = CONFIG.default_user_preferences.exclude_members_only_videos
|
||||
|
||||
module BoolToString
|
||||
def self.to_json(value : String, json : JSON::Builder)
|
||||
json.string value
|
||||
|
@ -200,6 +200,16 @@
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if item.responds_to?(:badges) && !item.badges.none? %>
|
||||
<div class="video-card-row flexible video-badges">
|
||||
<%
|
||||
# TODO Other types of badges
|
||||
%>
|
||||
<% if item.badges.members_only? %>
|
||||
<span><i class="icon ion ion-md-lock"></i><%=translate(locale, "video_badges_members_only")%></span>
|
||||
<% end %>
|
||||
</div>
|
||||
<%end%>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,7 +1,10 @@
|
||||
<%= page_nav_html %>
|
||||
<% exclude_members_only_videos = env.get("preferences").as(Preferences).exclude_members_only_videos %>
|
||||
|
||||
<div class="pure-g">
|
||||
<%- items.each do |item| -%>
|
||||
<% next if exclude_members_only_videos && item.responds_to?(:badges) &&
|
||||
item.is_a? SearchVideo && item.badges.members_only? %>
|
||||
<%= rendered "components/item" %>
|
||||
<%- end -%>
|
||||
</div>
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
<div class="pure-g">
|
||||
<% trending.each do |item| %>
|
||||
<% next %>
|
||||
<%= rendered "components/item" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -194,6 +194,12 @@
|
||||
</select>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group">
|
||||
<label for="exclude_members_only_videos"><%= translate(locale, "preferences_exclude_members_only_videos_label") %></label>
|
||||
<input name="exclude_members_only_videos" id="exclude_members_only_videos" type="checkbox" <% if preferences.exclude_members_only_videos %>checked<% end %>>
|
||||
</div>
|
||||
|
||||
<% if env.get? "user" %>
|
||||
<div class="pure-control-group">
|
||||
<label for="show_nick"><%= translate(locale, "preferences_show_nick_label") %></label>
|
||||
|
@ -135,6 +135,10 @@ private module Parsers
|
||||
when "Premium"
|
||||
# TODO: Potentially available as item_contents["topStandaloneBadge"]["metadataBadgeRenderer"]
|
||||
badges |= VideoBadges::Premium
|
||||
when "Members only"
|
||||
# TODO: Identify based on style attribute instead of label
|
||||
# It should be more resistant to Youtube changes.
|
||||
badges |= VideoBadges::MembersOnly
|
||||
else nil # Ignore
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user