/// <summary> /// Gets an instance of <var>YouTubeVideoSnippet</var> from the specified /// <var>JsonObject</var>. /// </summary> /// <param name="obj">The instance of <var>JsonObject</var> to parse.</param> public static YouTubeVideoSnippet Parse(JsonObject obj) { // Check whether "obj" is NULL if (obj == null) { return(null); } // Initialize the snippet object YouTubeVideoSnippet snippet = new YouTubeVideoSnippet(obj) { ChannelId = obj.GetString("channelId"), ChannelTitle = obj.GetString("channelTitle"), PublishedAt = obj.GetDateTime("publishedAt"), Title = obj.GetString("title"), Description = obj.GetString("description"), LiveBroadcastContent = obj.GetString("liveBroadcastContent") }; return(snippet); }
/// <summary> /// Gets an instance of <code>YouTubeVideoSnippet</code> from the specified <code>JsonObject</code>. /// </summary> /// <param name="obj">The instance of <code>JsonObject</code> to parse.</param> public static YouTubeVideoSnippet Parse(JsonObject obj) { // Check whether "obj" is NULL if (obj == null) return null; // Parse the "liveBroadcastContent" property YouTubeVideoLiveBroadcastContent broadcast; string strBroadcast = obj.GetString("liveBroadcastContent"); if (!Enum.TryParse(strBroadcast, true, out broadcast)) { throw new Exception("Unknown value for liveBroadcastContent \"" + strBroadcast + "\" - please create an issue so it can be fixed https://github.com/abjerner/Skybrud.Social/issues/new"); } // Get the array of tags (may not be present) JsonArray tags = obj.GetArray("tags"); // Initialize the snippet object YouTubeVideoSnippet snippet = new YouTubeVideoSnippet(obj) { PublishedAt = obj.GetDateTime("publishedAt"), ChannelId = obj.GetString("channelId"), Title = obj.GetString("title"), Description = obj.GetString("description"), Thumbnails = obj.GetObject("thumbnails", YouTubeVideoThumbnails.Parse), ChannelTitle = obj.GetString("channelTitle"), Tags = tags == null ? new string[0] : obj.GetArray("tags").Cast<string>(), CategoryId = obj.GetString("categoryId"), LiveBroadcastContent = broadcast }; return snippet; }