mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-14 17:15:09 +00:00
switch to enum flag instead of adding lots of properties to SearchVideo
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
@[Flags]
|
||||
enum VideoBadges
|
||||
LiveNow
|
||||
Premium
|
||||
ThreeD
|
||||
FourK
|
||||
New
|
||||
EightK
|
||||
VR180
|
||||
VR360
|
||||
CCommons
|
||||
end
|
||||
|
||||
struct SearchVideo
|
||||
include DB::Serializable
|
||||
|
||||
@@ -9,17 +22,9 @@ struct SearchVideo
|
||||
property views : Int64
|
||||
property description_html : String
|
||||
property length_seconds : Int32
|
||||
property live_now : Bool
|
||||
property premium : Bool
|
||||
property premiere_timestamp : Time?
|
||||
property author_verified : Bool
|
||||
property is_new : Bool
|
||||
property is_4k : Bool
|
||||
property is_8k : Bool
|
||||
property is_vr180 : Bool
|
||||
property is_vr360 : Bool
|
||||
property is_3d : Bool
|
||||
property has_captions : Bool
|
||||
property badges : VideoBadges
|
||||
|
||||
def to_xml(auto_generated, query_params, xml : XML::Builder)
|
||||
query_params["v"] = self.id
|
||||
@@ -95,20 +100,20 @@ struct SearchVideo
|
||||
json.field "published", self.published.to_unix
|
||||
json.field "publishedText", translate(locale, "`x` ago", recode_date(self.published, locale))
|
||||
json.field "lengthSeconds", self.length_seconds
|
||||
json.field "liveNow", self.live_now
|
||||
json.field "premium", self.premium
|
||||
json.field "liveNow", self.badges.live_now?
|
||||
json.field "premium", self.badges.premium?
|
||||
json.field "isUpcoming", self.upcoming?
|
||||
|
||||
if self.premiere_timestamp
|
||||
json.field "premiereTimestamp", self.premiere_timestamp.try &.to_unix
|
||||
end
|
||||
json.field "isNew", self.is_new
|
||||
json.field "is4k", self.is_4k
|
||||
json.field "is8k", self.is_8k
|
||||
json.field "isVR180", is_vr180
|
||||
json.field "isVR360", is_vr360
|
||||
json.field "is3d", is_3d
|
||||
json.field "hasCaptions", self.has_captions
|
||||
json.field "isNew", self.badges.new?
|
||||
json.field "is4k", self.badges.four_k?
|
||||
json.field "is8k", self.badges.eight_k?
|
||||
json.field "isVr180", self.badges.vr180?
|
||||
json.field "isVr360", self.badges.vr360?
|
||||
json.field "is3d", self.badges.three_d?
|
||||
json.field "hasCaptions", self.badges.c_commons?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user