Ejemplo n.º 1
0
        public static YoutubeCommentThread TextFormat(this YoutubeCommentThread commentThread, TextFormat format)
        {
            var settings = commentThread.Settings.Clone();

            settings.TextFormat = format;
            return(CommentThread(settings, commentThread.PartTypes.ToArray()));
        }
Ejemplo n.º 2
0
        public static YoutubeCommentThread SearchTerms(this YoutubeCommentThread commentThread, string s)
        {
            var settings = commentThread.Settings.Clone();

            settings.SearchTerms = s;
            return(CommentThread(settings, commentThread.PartTypes.ToArray()));
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
 public static YoutubeCommentThread RequestAllParts(this YoutubeCommentThread commentThread)
 {
     return(commentThread.RequestReplies().RequestSnippet());
 }
Ejemplo n.º 5
0
 public static YoutubeCommentThread RequestSnippet(this YoutubeCommentThread commentThread)
 {
     return(commentThread.RequestPart(PartType.Snippet));
 }
Ejemplo n.º 6
0
 public static YoutubeCommentThread RequestReplies(this YoutubeCommentThread commentThread)
 {
     return(commentThread.RequestPart(PartType.Replies));
 }
Ejemplo n.º 7
0
 public static YoutubeCommentThread RequestPart(this YoutubeCommentThread commentThread, PartType partType)
 {
     return(CommentThread(commentThread.Settings.Clone(), commentThread.PartTypes.Append(partType).ToArray()));
 }
Ejemplo n.º 8
0
 public static YoutubeChannel Channel(this YoutubeCommentThread commentThread)
 {
     return(commentThread.TopLevelComment.Channel());
 }
Ejemplo n.º 9
0
 public static YoutubeVideo Video(this YoutubeCommentThread commentThread)
 {
     return(commentThread.TopLevelComment.Video());
 }
Ejemplo n.º 10
0
 public static YoutubeCommentThread FormatPlainText(this YoutubeCommentThread commentThread)
 {
     return(commentThread.TextFormat(Enums.TextFormat.PlainText));
 }
Ejemplo n.º 11
0
 public static YoutubeCommentThread FormatHtml(this YoutubeCommentThread commentThread)
 {
     return(commentThread.TextFormat(Enums.TextFormat.Html));
 }