Parse members only badges of videos

This commit is contained in:
syeopite 2025-03-26 14:04:57 -07:00
parent 409d12a81e
commit e1b2eb2a7b
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A
2 changed files with 6 additions and 0 deletions

View File

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

View File

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