public static YoutubeCommentThread TextFormat(this YoutubeCommentThread commentThread, TextFormat format) { var settings = commentThread.Settings.Clone(); settings.TextFormat = format; return(CommentThread(settings, commentThread.PartTypes.ToArray())); }
public static YoutubeCommentThread SearchTerms(this YoutubeCommentThread commentThread, string s) { var settings = commentThread.Settings.Clone(); settings.SearchTerms = s; return(CommentThread(settings, commentThread.PartTypes.ToArray())); }
public static List <Item> GetItems(string url) { try { string videoId = url.Split('=')[1]; string pageToken = "&pageToken="; string token = ""; List <Item> items = new List <Item>(); HttpClient client = new HttpClient(); client.BaseAddress = new Uri(YouTubeAPIUrl); // Add an Accept header for JSON format. client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); do { // List data response. HttpResponseMessage response = client.GetAsync(UrlParameters + videoId + pageToken + token).Result; if (response.IsSuccessStatusCode) { // Parse the response body. object dataObjects = response.Content.ReadAsAsync <object>().Result; YoutubeCommentThread commentThread = JsonConvert.DeserializeObject <YoutubeCommentThread>(dataObjects.ToString()); Parallel.ForEach(commentThread.items, i => items.Add(i)); token = commentThread.nextPageToken; } else { Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); } } while (!string.IsNullOrWhiteSpace(token)); ; client.Dispose(); return(items); } catch (Exception ex) { throw new SystemException("Error at " + System.Reflection.MethodBase.GetCurrentMethod().Name + " : " + ex.Message + " : " + ex.InnerException); } }
public static YoutubeCommentThread RequestAllParts(this YoutubeCommentThread commentThread) { return(commentThread.RequestReplies().RequestSnippet()); }
public static YoutubeCommentThread RequestSnippet(this YoutubeCommentThread commentThread) { return(commentThread.RequestPart(PartType.Snippet)); }
public static YoutubeCommentThread RequestReplies(this YoutubeCommentThread commentThread) { return(commentThread.RequestPart(PartType.Replies)); }
public static YoutubeCommentThread RequestPart(this YoutubeCommentThread commentThread, PartType partType) { return(CommentThread(commentThread.Settings.Clone(), commentThread.PartTypes.Append(partType).ToArray())); }
public static YoutubeChannel Channel(this YoutubeCommentThread commentThread) { return(commentThread.TopLevelComment.Channel()); }
public static YoutubeVideo Video(this YoutubeCommentThread commentThread) { return(commentThread.TopLevelComment.Video()); }
public static YoutubeCommentThread FormatPlainText(this YoutubeCommentThread commentThread) { return(commentThread.TextFormat(Enums.TextFormat.PlainText)); }
public static YoutubeCommentThread FormatHtml(this YoutubeCommentThread commentThread) { return(commentThread.TextFormat(Enums.TextFormat.Html)); }