Example #1
0
        public void YouTubePlaylistBatchTest()
        {
            Tracing.TraceMsg("Entering YouTubePlaylistBatchTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd);

            YouTubeRequest f = new YouTubeRequest(settings);
            // GetVideoFeed get's you a users video feed
            Feed <Playlist> feed = f.GetPlaylistsFeed(null);
            // this will get you just the first 25 playlists.

            List <Playlist> list = new List <Playlist>();
            int             i    = 0;

            foreach (Playlist p in feed.Entries)
            {
                list.Add(p);        // add everything you want to do here...
            }

            Feed <PlayListMember> videos = f.GetPlaylist(list[0]);

            List <PlayListMember> lvideo = new List <PlayListMember>();

            foreach (PlayListMember v in videos.Entries)
            {
                lvideo.Add(v);        // add everything you want to do here...
            }

            List <PlayListMember> batch = new List <PlayListMember>();

            PlayListMember toBatch = new PlayListMember();

            toBatch.Id             = lvideo[1].Id;
            toBatch.VideoId        = lvideo[1].VideoId;
            toBatch.BatchData      = new GDataBatchEntryData();
            toBatch.BatchData.Id   = "NEWGUY";
            toBatch.BatchData.Type = GDataBatchOperationType.insert;
            batch.Add(toBatch);

            toBatch                = lvideo[1];
            toBatch.BatchData      = new GDataBatchEntryData();
            toBatch.BatchData.Id   = "DELETEGUY";
            toBatch.BatchData.Type = GDataBatchOperationType.delete;
            batch.Add(toBatch);

            toBatch                = lvideo[0];
            toBatch.Position       = 1;
            toBatch.BatchData      = new GDataBatchEntryData();
            toBatch.BatchData.Id   = "UPDATEGUY";
            toBatch.BatchData.Type = GDataBatchOperationType.update;
            batch.Add(toBatch);


            Feed <PlayListMember> updatedVideos = f.Batch(batch, videos);

            foreach (Video v in updatedVideos.Entries)
            {
                Assert.IsTrue(v.BatchData.Status.Code < 300, "one batch operation failed: " + v.BatchData.Status.Reason);
            }
        }
Example #2
0
        public void YouTubePlaylistRequestTest()
        {
            Tracing.TraceMsg("Entering YouTubePlaylistRequestTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd);

            YouTubeRequest f = new YouTubeRequest(settings);
            // GetVideoFeed gets you a users video feed
            Feed <Playlist> feed = f.GetPlaylistsFeed(null);

            // this will get you just the first 25 videos.
            foreach (Playlist p in feed.Entries)
            {
                Assert.IsTrue(p.AtomEntry != null);
                Assert.IsTrue(p.Title != null);
                Feed <PlayListMember> list = f.GetPlaylist(p);
                foreach (PlayListMember v in list.Entries)
                {
                    Assert.IsTrue(v.AtomEntry != null, "There should be an atomentry");
                    Assert.IsTrue(v.Title != null, "There should be a title");
                    Assert.IsTrue(v.VideoId != null, "There should be a videoID");
                    // there might be no watchpage (not published yet)
                    // Assert.IsTrue(v.WatchPage != null, "There should be a watchpage");
                }
            }
        }
        public void YouTubePlaylistBatchTest()
        {
            Tracing.TraceMsg("Entering YouTubePlaylistBatchTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd);

            YouTubeRequest f = new YouTubeRequest(settings);
            // GetVideoFeed get's you a users video feed
            Feed<Playlist> feed = f.GetPlaylistsFeed(null);
            // this will get you just the first 25 playlists. 

            List<Playlist> list = new List<Playlist>();
            int i = 0; 
            foreach (Playlist p in feed.Entries)
            {
                list.Add(p);        // add everything you want to do here... 
            }

            Feed<PlayListMember> videos = f.GetPlaylist(list[0]);

            List<PlayListMember> lvideo = new List<PlayListMember>();

            foreach (PlayListMember v in videos.Entries)
            {
                lvideo.Add(v);        // add everything you want to do here... 
            }

            List<PlayListMember> batch = new List<PlayListMember>();

            PlayListMember toBatch = new PlayListMember();
            toBatch.Id = lvideo[1].Id;
            toBatch.VideoId = lvideo[1].VideoId;
            toBatch.BatchData = new GDataBatchEntryData();
            toBatch.BatchData.Id = "NEWGUY";
            toBatch.BatchData.Type = GDataBatchOperationType.insert;
            batch.Add(toBatch);

            toBatch = lvideo[1];
            toBatch.BatchData = new GDataBatchEntryData();
            toBatch.BatchData.Id = "DELETEGUY";
            toBatch.BatchData.Type = GDataBatchOperationType.delete;
            batch.Add(toBatch);

            toBatch = lvideo[0];
            toBatch.Position = 1; 
            toBatch.BatchData = new GDataBatchEntryData();
            toBatch.BatchData.Id = "UPDATEGUY";
            toBatch.BatchData.Type = GDataBatchOperationType.update;
            batch.Add(toBatch);


            Feed<PlayListMember> updatedVideos = f.Batch(batch, videos);

            foreach (Video v in updatedVideos.Entries)
            {
                Assert.IsTrue(v.BatchData.Status.Code < 300, "one batch operation failed: " + v.BatchData.Status.Reason);
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        // 

        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube factory object</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubePlaylistRequestTest()
        {
            Tracing.TraceMsg("Entering YouTubePlaylistRequestTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd);

            YouTubeRequest f = new YouTubeRequest(settings);
            // GetVideoFeed get's you a users video feed
            Feed<Playlist> feed = f.GetPlaylistsFeed(null);

              // this will get you just the first 25 videos. 
            foreach (Playlist p in feed.Entries)
            {
                Assert.IsTrue(p.AtomEntry != null);
                Assert.IsTrue(p.Title != null);
                Feed<PlayListMember> list = f.GetPlaylist(p);
                foreach (PlayListMember v in list.Entries)
                {
                    Assert.IsTrue(v.AtomEntry != null, "There should be an atomentry");
                    Assert.IsTrue(v.Title != null, "There should be a title");
                    Assert.IsTrue(v.VideoId != null, "There should be a videoID"); 
                    // there might be no watchpage (not published yet)
                    // Assert.IsTrue(v.WatchPage != null, "There should be a watchpage");

        
                }
            }

           
	

        }
Example #5
0
 public void GetMyPlaylist()
 {
     try
     {
         if (isLoggedIn == false) return;
         YouTubeRequestSettings settings = new YouTubeRequestSettings(APP_NAME, DEV_KEY, USERNAME, PASSWORD);
         YouTubeRequest reqeuest = new YouTubeRequest(settings);
         Feed<Playlist> pl_feeds = reqeuest.Get<Playlist>(new Uri("https://gdata.youtube.com/feeds/api/users/default/playlists?v=2"));
         List<List<VideoBase>> list = new List<List<VideoBase>>();
         List<string> playlistName = new List<string>();
         foreach (Playlist pl in pl_feeds.Entries)
         {
             playlistName.Add(pl.Title + " " + pl.CountHint + " video(s)");
             myPlaylistIDs.Add(new PlaylistId(pl.Id));
             Feed<PlayListMember> video_list = reqeuest.GetPlaylist(pl);
             Playlist certain_pl = new Playlist();
             certain_pl = pl;
             List<VideoBase> subVideo = new List<VideoBase>();
             foreach (Video video in video_list.Entries)
             {
                 subVideo.Add(ConvertToVideoBase(video));
             }
             list.Add(subVideo);
         }
         MyPlaylistsName = playlistName;
         MyPlaylistVideo = list;
         MyPlaylist = pl_feeds.Entries.ToList();
     }
     catch
     {
     }
 }