mirror of
https://github.com/iv-org/invidious.git
synced 2025-06-28 09:38:31 +00:00
Add support for "members first" badge
This commit is contained in:
parent
2a50d20715
commit
789b561c76
@ -503,5 +503,6 @@
|
|||||||
"carousel_skip": "Skip the Carousel",
|
"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",
|
"video_badges_members_only": "Members only",
|
||||||
|
"video_badges_members_first": "Members first",
|
||||||
"preferences_exclude_members_only_videos_label": "Hide channel member-only videos"
|
"preferences_exclude_members_only_videos_label": "Hide channel member-only videos"
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ enum VideoBadges
|
|||||||
VR360
|
VR360
|
||||||
ClosedCaptions
|
ClosedCaptions
|
||||||
MembersOnly
|
MembersOnly
|
||||||
|
MembersFirst
|
||||||
end
|
end
|
||||||
|
|
||||||
struct SearchVideo
|
struct SearchVideo
|
||||||
@ -152,6 +153,13 @@ struct SearchVideo
|
|||||||
def upcoming?
|
def upcoming?
|
||||||
premiere_timestamp ? true : false
|
premiere_timestamp ? true : false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Shorthand to check whether the video is restricted to only channel members
|
||||||
|
#
|
||||||
|
# Whether as an early access video ("members first") or only for members ("members only")
|
||||||
|
def restricted_to_members?
|
||||||
|
return badges.members_only? || badges.members_first?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
struct SearchPlaylistVideo
|
struct SearchPlaylistVideo
|
||||||
|
@ -208,6 +208,9 @@
|
|||||||
<% if item.badges.members_only? %>
|
<% if item.badges.members_only? %>
|
||||||
<span><i class="icon ion ion-md-lock"></i><%=translate(locale, "video_badges_members_only")%></span>
|
<span><i class="icon ion ion-md-lock"></i><%=translate(locale, "video_badges_members_only")%></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if item.badges.members_first? %>
|
||||||
|
<span><i class="icon ion ion-md-lock"></i><%=translate(locale, "video_badges_members_first")%></span>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<%end%>
|
<%end%>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<%- items.each do |item| -%>
|
<%- items.each do |item| -%>
|
||||||
<% next if exclude_members_only_videos && item.responds_to?(:badges) &&
|
<% next if exclude_members_only_videos && item.responds_to?(:restricted_to_members?) && item.restricted_to_members? %>
|
||||||
item.is_a? SearchVideo && item.badges.members_only? %>
|
|
||||||
<%= rendered "components/item" %>
|
<%= rendered "components/item" %>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
</div>
|
</div>
|
||||||
|
@ -136,9 +136,9 @@ private module Parsers
|
|||||||
# TODO: Potentially available as item_contents["topStandaloneBadge"]["metadataBadgeRenderer"]
|
# TODO: Potentially available as item_contents["topStandaloneBadge"]["metadataBadgeRenderer"]
|
||||||
badges |= VideoBadges::Premium
|
badges |= VideoBadges::Premium
|
||||||
when "Members only"
|
when "Members only"
|
||||||
# TODO: Identify based on style attribute instead of label
|
|
||||||
# It should be more resistant to Youtube changes.
|
|
||||||
badges |= VideoBadges::MembersOnly
|
badges |= VideoBadges::MembersOnly
|
||||||
|
when "Members first"
|
||||||
|
badges |= VideoBadges::MembersFirst
|
||||||
else nil # Ignore
|
else nil # Ignore
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user