Invidious is an alternative front-end to YouTube
Parse more metadata badges for SearchVideos
ChunkyProgrammer2e649363d2c9
diff --git a/src/invidious/helpers/serialized_yt_data.cr b/src/invidious/helpers/serialized_yt_data.crindex 463d5557..c0ca789e 100644--- a/src/invidious/helpers/serialized_yt_data.cr+++ b/src/invidious/helpers/serialized_yt_data.cr@@ -13,6 +13,13 @@ struct SearchVideoproperty premium : Boolproperty 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 : Booldef to_xml(auto_generated, query_params, xml : XML::Builder)query_params["v"] = self.id@@ -95,6 +102,13 @@ struct SearchVideoif self.premiere_timestampjson.field "premiereTimestamp", self.premiere_timestamp.try &.to_unixend+ 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_captionsendenddiff --git a/src/invidious/routes/feeds.cr b/src/invidious/routes/feeds.crindex e20a7139..b76aeb46 100644--- a/src/invidious/routes/feeds.cr+++ b/src/invidious/routes/feeds.cr@@ -197,6 +197,13 @@ module Invidious::Routes::Feedspremium: false,premiere_timestamp: nil,author_verified: false,+ is_new: false,+ is_4k: false,+ is_8k: false,+ is_vr180: false,+ is_vr360: false,+ is_3d: false,+ has_captions: false,})enddiff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.crindex 38dc2c04..48c2155b 100644--- a/src/invidious/yt_backend/extractors.cr+++ b/src/invidious/yt_backend/extractors.cr@@ -110,6 +110,13 @@ private module Parserslive_now = falsepremium = false+ is_new = false+ is_4k = false+ is_8k = false+ is_vr180 = false+ is_vr360 = false+ is_3d = false+ has_captions = falsepremiere_timestamp = item_contents.dig?("upcomingEventData", "startTime").try { |t| Time.unix(t.as_s.to_i64) }@@ -118,12 +125,25 @@ private module Parserscase b["label"].as_swhen "LIVE NOW"live_now = true- when "New", "4K", "CC"- # TODO+ when "New"+ is_new = true+ when "4K"+ is_4k = true+ when "8K"+ is_8k = true+ when "VR180"+ is_vr180 = true+ when "360°"+ is_vr360 = true+ when "3D"+ is_3d = true+ when "CC"+ has_captions = truewhen "Premium"# TODO: Potentially available as item_contents["topStandaloneBadge"]["metadataBadgeRenderer"]premium = true- else nil # Ignore+ else # Ignore+ puts b["label"].as_sendend@@ -140,6 +160,13 @@ private module Parserspremium: premium,premiere_timestamp: premiere_timestamp,author_verified: author_verified,+ is_new: is_new,+ is_4k: is_4k,+ is_8k: is_8k,+ is_vr180: is_vr180,+ is_vr360: is_vr360,+ is_3d: is_3d,+ has_captions: has_captions,})end@@ -567,6 +594,13 @@ private module Parserspremium: false,premiere_timestamp: Time.unix(0),author_verified: false,+ is_new: false,+ is_4k: false,+ is_8k: false,+ is_vr180: false,+ is_vr360: false,+ is_3d: false,+ has_captions: false,})end