public static SingleChannel.RootObject ChannelDetails(Http http, string id) { string url = API_URL + "channels" + API_KEY + "&part=statistics,contentDetails" + "&id=" + id; string RS = http.GET(url, "", new CookieContainer(), null, null, Http.HttpAccept.ACCEPT_JSON); if (RS == "[[[ERROR]]]") { return(null); } SingleChannel.RootObject rb = JsonConvert.DeserializeObject <SingleChannel.RootObject>(RS); return(rb); }
private VideoDetails FillVideoDetails(SingleVideo.RootObject core, VideoComments.RootObject comments, SingleChannel.RootObject channel) { if (core == null || core.items.Count <= 0) { return(null); } var C = core.items[0]; var v = new VideoDetails(); v.CommentCount = C.statistics.commentCount; v.Description = C.snippet.description; if (comments != null && comments.items.Count > 0) { v.LastCommentDate = DateTime.Parse(comments.items[0].snippet.topLevelComment.snippet.publishedAt); } v.Likes = C.statistics.likeCount; v.Dislikes = C.statistics.dislikeCount; v.Title = C.snippet.title; v.UploadedDate = DateTime.Parse(C.snippet.publishedAt); v.VideoDuration = System.Xml.XmlConvert.ToTimeSpan(C.contentDetails.duration); v.VideoURL = "https://youtube.com/watch?v=" + C.id; v.ViewCount = C.statistics.viewCount; v.Subscribers = channel.items.Count > 0 ? int.Parse(channel.items[0].statistics.subscriberCount) : 0; v.ChannelURL = "https://www.youtube.com/channel/" + C.snippet.channelId + "/"; v.NumLinks = Regex.Matches(v.Description, "http").Count; return(v); }