private void button1_Click(object sender, EventArgs e) { Uri ur = new Uri("http://gdata.youtube.com/feeds/api/videos/fSgGV1llVHM&f=gdata_playlists&c=ytapi-DukaIstvan-MyYouTubeVideosF-d1ogtvf7-0&d=U1YkMvELc_arPNsH4kYosmD9LlbsOl3qUImVMV6ramM"); YouTubeQuery query = new YouTubeQuery("http://gdata.youtube.com/feeds/api/channels?q=vevo"); YouTubeFeed videoFeed = service.Query(query); YouTubeEntry en = (YouTubeEntry)videoFeed.Entries[0]; Video video = request.Retrieve <Video>(new Uri("http://gdata.youtube.com/feeds/api/videos/" + en.VideoId)); Feed <Comment> comments = request.GetComments(video); string cm = ""; foreach (Comment c in comments.Entries) { cm += c.Content + "\n------------------------------------------\n"; } VideoInfo info = new VideoInfo(); info.Get("yUHNUjEs7rQ"); //Video v = request.Retrieve<Video>(videoEntryUrl); //Feed<Comment> comments = request.GetComments(v); //string cm = ""; //foreach (Comment c in comments.Entries) //{ // cm += c.Author + c.Content + "------------------------------------------"; //} }
public void YouTubePageSizeTest() { Tracing.TraceMsg("Entering YouTubePageSizeTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd); settings.PageSize = 15; YouTubeRequest f = new YouTubeRequest(settings); Feed <Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular); int iCount = 0; // this will get you just the first 15 videos. foreach (Video v in feed.Entries) { iCount++; f.Settings.PageSize = 5; Feed <Comment> list = f.GetComments(v); int i = 0; foreach (Comment c in list.Entries) { i++; } Assert.IsTrue(i <= 5, "the count should be smaller/equal 5"); Assert.IsTrue(list.PageSize == -1 || list.PageSize == 5, "the returned pagesize should be 5 or -1 as well"); } Assert.AreEqual(iCount, 15, "the outer feed should count 15"); Assert.AreEqual(feed.PageSize, 15, "outer feed pagesize should be 15"); }
public void YouTubeUnAuthenticatedRequestTest() { Tracing.TraceMsg("Entering YouTubeUnAuthenticatedRequestTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey); settings.AutoPaging = true; settings.Maximum = 50; YouTubeRequest f = new YouTubeRequest(settings); Feed <Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular); // this will get you the first 25 videos, let's retrieve comments for the first one only foreach (Video v in feed.Entries) { Feed <Comment> list = f.GetComments(v); foreach (Comment c in list.Entries) { Assert.IsTrue(c.AtomEntry != null); Assert.IsTrue(c.Title != null); } break; } }
private void button1_Click(object sender, EventArgs e) { Uri ur = new Uri( "http://gdata.youtube.com/feeds/api/videos/fSgGV1llVHM&f=gdata_playlists&c=ytapi-DukaIstvan-MyYouTubeVideosF-d1ogtvf7-0&d=U1YkMvELc_arPNsH4kYosmD9LlbsOl3qUImVMV6ramM"); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); //order results by the number of views (most viewed first) query.OrderBy = "viewCount"; //exclude restricted content from the search query.SafeSearch = YouTubeQuery.SafeSearchValues.None; //string ss = YouTubeQuery.TopRatedVideo; //http://gdata.youtube.com/feeds/api/standardfeeds/top_rated //search for puppies! query.Query = textBox1.Text; query.Categories.Add(new QueryCategory("Music", QueryCategoryOperator.AND)); YouTubeFeed videoFeed = service.Query(query); YouTubeEntry en = (YouTubeEntry)videoFeed.Entries[0]; string s = en.Summary.Text; string s1 = en.Media.Description.Value; Google.GData.YouTube.MediaGroup gr = en.Media; Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + en.VideoId); Video video = request.Retrieve <Video>(videoEntryUrl); Feed <Comment> comments = request.GetComments(video); string cm = ""; foreach (Comment c in comments.Entries) { cm += c.Content + "\n------------------------------------------\n"; } VideoInfo info = new VideoInfo(); info.Get("yUHNUjEs7rQ"); //Video v = request.Retrieve<Video>(videoEntryUrl); //Feed<Comment> comments = request.GetComments(v); //string cm = ""; //foreach (Comment c in comments.Entries) //{ // cm += c.Author + c.Content + "------------------------------------------"; //} }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>runs a test on the YouTube factory object</summary> ////////////////////////////////////////////////////////////////////// [Test] public void YouTubeCommentRequestTest() { Tracing.TraceMsg("Entering YouTubeCommentRequestTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd); YouTubeRequest f = new YouTubeRequest(settings); Feed <Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular); // this will get you just the first 25 videos. foreach (Video v in feed.Entries) { Feed <Comment> list = f.GetComments(v); foreach (Comment c in list.Entries) { Assert.IsTrue(c.AtomEntry != null); Assert.IsTrue(c.Title != null); } } }
///////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////// /// <summary>runs a test on the YouTube factory object</summary> ////////////////////////////////////////////////////////////////////// [Test] public void YouTubePageSizeTest() { Tracing.TraceMsg("Entering YouTubePageSizeTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd); settings.PageSize = 15; YouTubeRequest f = new YouTubeRequest(settings); Feed<Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular); int iCount = 0; // this will get you just the first 15 videos. foreach (Video v in feed.Entries) { iCount++; f.Settings.PageSize = 5; Feed<Comment> list = f.GetComments(v); int i = 0; foreach (Comment c in list.Entries) { i++; } Assert.IsTrue(i <= 5, "the count should be smaller/equal 5"); Assert.IsTrue(list.PageSize == -1 || list.PageSize == 5, "the returned pagesize should be 5 or -1 as well"); } Assert.AreEqual(iCount, 15, "the outer feed should count 15"); Assert.AreEqual(feed.PageSize, 15, "outer feed pagesize should be 15"); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>runs a test on the YouTube factory object</summary> ////////////////////////////////////////////////////////////////////// [Test] public void YouTubeUnAuthenticatedRequestTest() { Tracing.TraceMsg("Entering YouTubeUnAuthenticatedRequestTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey); settings.AutoPaging = true; settings.Maximum = 50; YouTubeRequest f = new YouTubeRequest(settings); Feed<Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular); // this will get you just the first 25 videos. foreach (Video v in feed.Entries) { Feed<Comment> list= f.GetComments(v); foreach (Comment c in list.Entries) { Assert.IsTrue(c.AtomEntry != null); Assert.IsTrue(c.Title != null); } } }
public void YouTubeCommentRequestTest() { Tracing.TraceMsg("Entering YouTubeCommentRequestTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd); YouTubeRequest f = new YouTubeRequest(settings); Feed<Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular); // this will get you the first 25 videos, let's retrieve comments for the first one only foreach (Video v in feed.Entries) { Feed<Comment> list = f.GetComments(v); foreach (Comment c in list.Entries) { Assert.IsTrue(c.AtomEntry != null); Assert.IsTrue(c.Title != null); } break; } }
private void updateCommentBw_DoWork(object sender, DoWorkEventArgs e) { YouTubeRequest req = new YouTubeRequest(new YouTubeRequestSettings("YoutubeUploader", MainWindow.DEV_KEY)); Uri videoEntryUrl = new Uri(string.Format("{0}/{1}", Google.GData.YouTube.YouTubeQuery.DefaultVideoUri, videoId)); Google.YouTube.Video newVideo = req.Retrieve<Google.YouTube.Video>(videoEntryUrl); Feed<Comment> comments = req.GetComments(newVideo); List<object> arg = new List<object>(); arg.Add(comments); e.Result = arg; }