public void YouTubeSubscriptionsTest() { Tracing.TraceMsg("Entering YouTubeSubscriptionsTest"); string playlistID = "4A3A73D5172EB90A"; YouTubeRequestSettings settings = new YouTubeRequestSettings(this.ApplicationName, this.ytDevKey, this.ytUser, this.ytPwd); // settings.PageSize = 15; YouTubeRequest f = new YouTubeRequest(settings); // this returns the server default answer Feed <Subscription> feed = f.GetSubscriptionsFeed(null); foreach (Subscription s in feed.Entries) { Assert.IsTrue(s.PlaylistId != null, "There should be a PlaylistId"); Assert.IsTrue(s.PlaylistTitle != null, "There should be a PlaylistTitle"); if (s.PlaylistId == playlistID) { f.Delete(s); } } Subscription sub = new Subscription(); sub.Type = SubscriptionEntry.SubscriptionType.playlist; sub.PlaylistId = playlistID; f.Insert(feed, sub); // this returns the server default answer feed = f.GetSubscriptionsFeed(null); List <Subscription> list = new List <Subscription>(); foreach (Subscription s in feed.Entries) { Assert.IsTrue(s.PlaylistId != null, "There should be a PlaylistId"); Assert.IsTrue(s.PlaylistTitle != null, "There should be a PlaylistTitle"); if (s.PlaylistId == playlistID) { list.Add(s); } } Assert.IsTrue(list.Count > 0, "There should be one subscription matching"); foreach (Subscription s in list) { f.Delete(s); } foreach (Subscription s in feed.Entries) { Assert.IsTrue(s.PlaylistId != null, "There should be a PlaylistId"); Assert.IsTrue(s.PlaylistTitle != null, "There should be a PlaylistTitle"); Assert.IsFalse(s.PlaylistId == playlistID, "They should be gone"); } }
public void YouTubeSubscriptionsTest() { Tracing.TraceMsg("Entering YouTubeSubscriptionsTest"); string channelUsername = "******"; YouTubeRequestSettings settings = new YouTubeRequestSettings(this.ApplicationName, this.ytDevKey, this.ytUser, this.ytPwd); YouTubeRequest f = new YouTubeRequest(settings); // this returns the server default answer Feed <Subscription> feed = f.GetSubscriptionsFeed(null); foreach (Subscription s in feed.Entries) { if (!string.IsNullOrEmpty(s.UserName) && s.UserName == channelUsername) { f.Delete(s); } } Subscription sub = new Subscription(); sub.Type = SubscriptionEntry.SubscriptionType.channel; sub.UserName = "******"; f.Insert(feed, sub); // this returns the server default answer feed = f.GetSubscriptionsFeed(null); List <Subscription> list = new List <Subscription>(); foreach (Subscription s in feed.Entries) { if (!string.IsNullOrEmpty(s.UserName) && s.UserName == channelUsername) { list.Add(s); } } Assert.IsTrue(list.Count > 0, "There should be one subscription matching"); foreach (Subscription s in list) { f.Delete(s); } feed = f.GetSubscriptionsFeed(null); int iCount = 0; foreach (Subscription s in feed.Entries) { iCount++; } Assert.IsTrue(iCount == 0, "There should be no subscriptions in the feed"); }
public void YouTubeRequestInsertTest() { Tracing.TraceMsg("Entering YouTubeRequestInsertTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd); YouTubeRequest f = new YouTubeRequest(settings); Video v = new Video(); v.Title = "Sample upload"; v.Description = "This is a test with and & in it"; MediaCategory category = new MediaCategory("Nonprofit"); category.Attributes["scheme"] = YouTubeService.DefaultCategory; v.Tags.Add(category); v.Keywords = "math"; v.YouTubeEntry.MediaSource = new MediaFileSource(Path.Combine(this.resourcePath, "test_movie.mov"), "video/quicktime"); Video newVideo = f.Upload(this.ytUser, v); newVideo.Title = "This test upload will soon be deleted"; Video updatedVideo = f.Update(newVideo); Assert.AreEqual(updatedVideo.Description, newVideo.Description, "Description should be equal"); Assert.AreEqual(updatedVideo.Keywords, newVideo.Keywords, "Keywords should be equal"); newVideo.YouTubeEntry.MediaSource = new MediaFileSource(Path.Combine(this.resourcePath, "test.mp4"), "video/mp4"); Video last = f.Update(updatedVideo); f.Delete(last); }
public void YouTubeSubscriptionsTest() { Tracing.TraceMsg("Entering YouTubeSubscriptionsTest"); string playlistID = "4A3A73D5172EB90A"; YouTubeRequestSettings settings = new YouTubeRequestSettings(this.ApplicationName, this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd); // settings.PageSize = 15; YouTubeRequest f = new YouTubeRequest(settings); // this returns the server default answer Feed<Subscription> feed = f.GetSubscriptionsFeed(null); foreach (Subscription s in feed.Entries) { Assert.IsTrue(s.PlaylistId != null, "There should be a PlaylistId"); Assert.IsTrue(s.PlaylistTitle != null, "There should be a PlaylistTitle"); if (s.PlaylistId == playlistID) { f.Delete(s); } } Subscription sub = new Subscription(); sub.Type = SubscriptionEntry.SubscriptionType.playlist; sub.PlaylistId = playlistID; f.Insert(feed, sub); // this returns the server default answer feed = f.GetSubscriptionsFeed(null); List<Subscription> list = new List<Subscription>(); foreach (Subscription s in feed.Entries) { Assert.IsTrue(s.PlaylistId != null, "There should be a PlaylistId"); Assert.IsTrue(s.PlaylistTitle != null, "There should be a PlaylistTitle"); if (s.PlaylistId == playlistID) { list.Add(s); } } Assert.IsTrue(list.Count > 0, "There should be one subscription matching"); foreach (Subscription s in list) { f.Delete(s); } foreach (Subscription s in feed.Entries) { Assert.IsTrue(s.PlaylistId != null, "There should be a PlaylistId"); Assert.IsTrue(s.PlaylistTitle != null, "There should be a PlaylistTitle"); Assert.IsFalse(s.PlaylistId == playlistID, "They should be gone"); } }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>runs a test on the YouTube Feed object</summary> ////////////////////////////////////////////////////////////////////// [Test] public void YouTubeRequestInsertTest() { Tracing.TraceMsg("Entering YouTubeRequestInsertTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd); YouTubeRequest f = new YouTubeRequest(settings); Video v = new Video(); v.Title = "Sample upload"; v.Description = "This is a test with and & in it"; MediaCategory category = new MediaCategory("Nonprofit"); category.Attributes["scheme"] = YouTubeService.DefaultCategory; v.Tags.Add(category); v.Keywords = "math"; v.YouTubeEntry.MediaSource = new MediaFileSource(this.resourcePath + "test_movie.mov", "video/quicktime"); Video newVideo = f.Upload(this.ytUser, v); newVideo.Title = "This test upload will soon be deleted"; Video updatedVideo = f.Update(newVideo); Assert.AreEqual(updatedVideo.Description, newVideo.Description, "Description should be equal"); Assert.AreEqual(updatedVideo.Keywords, newVideo.Keywords, "Keywords should be equal"); newVideo.YouTubeEntry.MediaSource = new MediaFileSource(this.resourcePath + "test.mp4", "video/mp4"); Video last = f.Update(updatedVideo); f.Delete(last); }
public void YouTubeAccessControlTest() { Tracing.TraceMsg("Entering YouTubeAccessControlTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd); YouTubeRequest f = new YouTubeRequest(settings); Video v = new Video(); v.Title = "Sample upload"; v.Description = "This is a test with different access control values"; MediaCategory category = new MediaCategory("Nonprofit"); category.Attributes["scheme"] = YouTubeService.DefaultCategory; v.Tags.Add(category); v.Keywords = "math"; v.YouTubeEntry.MediaSource = new MediaFileSource(Path.Combine(this.resourcePath, "test_movie.mov"), "video/quicktime"); v.YouTubeEntry.AccessControls.Add(new YtAccessControl(YtAccessControl.RateAction, YtAccessControl.DeniedPermission)); v.YouTubeEntry.AccessControls.Add(new YtAccessControl(YtAccessControl.CommentAction, YtAccessControl.ModeratedPermission)); Video newVideo = f.Upload(this.ytUser, v); ExtensionCollection <YtAccessControl> acl = newVideo.YouTubeEntry.AccessControls; for (int i = 0; i < acl.Count; i++) { YtAccessControl ac = acl[i]; switch (ac.Action) { case YtAccessControl.RateAction: Assert.AreEqual(ac.Permission, YtAccessControl.DeniedPermission, "Rating should be denied"); break; case YtAccessControl.CommentAction: Assert.AreEqual(ac.Permission, YtAccessControl.ModeratedPermission, "Comments should be moderated"); break; case YtAccessControl.CommentVoteAction: Assert.AreEqual(ac.Permission, YtAccessControl.AllowedPermission, "Comment rating should be allowed"); break; case YtAccessControl.VideoRespondAction: Assert.AreEqual(ac.Permission, YtAccessControl.ModeratedPermission, "Video responses should be moderated"); break; case YtAccessControl.ListAction: Assert.AreEqual(ac.Permission, YtAccessControl.AllowedPermission, "Video listing should be allowed"); break; case YtAccessControl.EmbedAction: Assert.AreEqual(ac.Permission, YtAccessControl.AllowedPermission, "Video embed should be allowed"); break; case YtAccessControl.SyndicateAction: Assert.AreEqual(ac.Permission, YtAccessControl.AllowedPermission, "Video syndicate should be allowed"); break; } } f.Delete(newVideo); }
public void YouTubeAccessControlTest() { Tracing.TraceMsg("Entering YouTubeAccessControlTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd); YouTubeRequest f = new YouTubeRequest(settings); Video v = new Video(); v.Title = "Sample upload"; v.Description = "This is a test with different access control values"; MediaCategory category = new MediaCategory("Nonprofit"); category.Attributes["scheme"] = YouTubeService.DefaultCategory; v.Tags.Add(category); v.Keywords = "math"; v.YouTubeEntry.MediaSource = new MediaFileSource(Path.Combine(this.resourcePath, "test_movie.mov"), "video/quicktime"); v.YouTubeEntry.AccessControls.Add(new YtAccessControl(YtAccessControl.RateAction, YtAccessControl.DeniedPermission)); v.YouTubeEntry.AccessControls.Add(new YtAccessControl(YtAccessControl.CommentAction, YtAccessControl.ModeratedPermission)); Video newVideo = f.Upload(this.ytUser, v); ExtensionCollection<YtAccessControl> acl = newVideo.YouTubeEntry.AccessControls; for (int i = 0; i < acl.Count; i++) { YtAccessControl ac = acl[i]; switch (ac.Action) { case YtAccessControl.RateAction: Assert.AreEqual(ac.Permission, YtAccessControl.DeniedPermission, "Rating should be denied"); break; case YtAccessControl.CommentAction: Assert.AreEqual(ac.Permission, YtAccessControl.ModeratedPermission, "Comments should be moderated"); break; case YtAccessControl.CommentVoteAction: Assert.AreEqual(ac.Permission, YtAccessControl.AllowedPermission, "Comment rating should be allowed"); break; case YtAccessControl.VideoRespondAction: Assert.AreEqual(ac.Permission, YtAccessControl.ModeratedPermission, "Video responses should be moderated"); break; case YtAccessControl.ListAction: Assert.AreEqual(ac.Permission, YtAccessControl.AllowedPermission, "Video listing should be allowed"); break; case YtAccessControl.EmbedAction: Assert.AreEqual(ac.Permission, YtAccessControl.AllowedPermission, "Video embed should be allowed"); break; case YtAccessControl.SyndicateAction: Assert.AreEqual(ac.Permission, YtAccessControl.AllowedPermission, "Video syndicate should be allowed"); break; } } f.Delete(newVideo); }
public void YouTubeSubscriptionsTest() { Tracing.TraceMsg("Entering YouTubeSubscriptionsTest"); string channelUsername = "******"; YouTubeRequestSettings settings = new YouTubeRequestSettings(this.ApplicationName, this.ytDevKey, this.ytUser, this.ytPwd); YouTubeRequest f = new YouTubeRequest(settings); // this returns the server default answer Feed<Subscription> feed = f.GetSubscriptionsFeed(null); foreach (Subscription s in feed.Entries) { if (!string.IsNullOrEmpty(s.UserName) && s.UserName == channelUsername) { f.Delete(s); } } Subscription sub = new Subscription(); sub.Type = SubscriptionEntry.SubscriptionType.channel; sub.UserName = "******"; f.Insert(feed, sub); // this returns the server default answer feed = f.GetSubscriptionsFeed(null); List<Subscription> list = new List<Subscription>(); foreach (Subscription s in feed.Entries) { if (!string.IsNullOrEmpty(s.UserName) && s.UserName == channelUsername) { list.Add(s); } } Assert.IsTrue(list.Count > 0, "There should be one subscription matching"); foreach (Subscription s in list) { f.Delete(s); } feed = f.GetSubscriptionsFeed(null); int iCount = 0; foreach (Subscription s in feed.Entries) { iCount++; } Assert.IsTrue(iCount == 0, "There should be no subscriptions in the feed"); }
public void Remove(string uploader, string videoID) { YouTubeRequestSettings settings = new YouTubeRequestSettings("ControlTower", knt_devkey, knt_hadi, knt_hsifresi); bool s = true; string vidid = ""; try { YouTubeRequest request = new YouTubeRequest(settings); Uri uri = new Uri(String.Format("http://gdata.YouTube.com/feeds/api/users/{0}/uploads/{1}", uploader, videoID)); Video a = request.Retrieve<Video>(uri); request.Delete(a); vidid = a.VideoId; } catch { s = false; } if (s) AppendText(richTextBox1, Color.Chocolate, " Silindi: " + videoID + " " + DateTime.Now.ToString()); }
private void btnDelete_Click(object sender, EventArgs e) { //Should delete work on local files, or let the user do that manually? if (MessageBox.Show("WARNING: Deleting this file will delete it locally!", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes && listVideosView.FocusedItem.SubItems.Count > 1) { YouTubeRequestSettings settings = new YouTubeRequestSettings("Deprecated", key, Youtube_Uploader.Properties.Settings.Default.UsernameYT, Youtube_Uploader.Properties.Settings.Default.PasswordYT); YouTubeRequest request = new YouTubeRequest(settings); Uri videoEntryUrl = new Uri(String.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads/{1}", TrimEmail(Youtube_Uploader.Properties.Settings.Default.UsernameYT), listVideosView.FocusedItem.SubItems[2].Text)); Video video = request.Retrieve<Video>(videoEntryUrl); request.Delete(video); VideoFilename.RemoveAt(VideoId.IndexOf(video.VideoId)); VideoStatus.RemoveAt(VideoId.IndexOf(video.VideoId)); VideoId.RemoveAt(VideoId.IndexOf(video.VideoId)); File.Delete(includeTextBox.Text + "\\" + textBox_UploadFile.Text); drawVideoList(); } }
public void Remove(Video video) { YouTubeRequestSettings settings = new YouTubeRequestSettings("zohaan", "AI39si49oz87UsNqVvW32H5Ve3eJkrdPnctL0Q8kfbpGoqBpowKskuoYSC9iW_6_EVlxzXUpa0oPjZgHTYtXrEfTShULt3d1Dw", "*****@*****.**", "6528yayla"); YouTubeRequest request = new YouTubeRequest(settings); request.Delete(video); }