Example #1
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");
                }
            }
        }
Example #2
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 #3
0
 //http://gdata.youtube.com/feeds/api/playlists/6B4AA5F8DE307567?v=2
 private void button5_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(textBox3.Text))
     {
         YouTubeRequest  request       = new YouTubeRequest(settings);
         Feed <Playlist> userPlaylists = request.GetPlaylistsFeed(textBox3.Text);
         foreach (Playlist pl in userPlaylists.Entries)
         {
             temp = pl.Id.Split(':');
             cmbSubService.Items.Add(pl.Title);
         }
     }
 }
Example #4
0
    public static IEnumerable <Playlist> PlayLists()
    {
        Feed <Playlist> feed    = null;
        YouTubeRequest  request = GetRequest();

        try
        {
            feed = request.GetPlaylistsFeed(null);
        }
        catch (GDataRequestException gdre)
        {
            HttpWebResponse response = (HttpWebResponse)gdre.Response;
        }
        return(feed != null ? feed.Entries : null);
    }
Example #5
0
        static void Main(string[] args)
        {
            YouTubeRequest request = new YouTubeRequest(new YouTubeRequestSettings(AppName, DevKey));

            var playlists = request.GetPlaylistsFeed("QualityCartoons");

            foreach (var playlistItem in playlists.Entries)
            {
                LoadPlaylist(request, playlistItem);
                //var query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
                //query.Author = "QualityCartoons";
                //query.SafeSearch = YouTubeQuery.SafeSearchValues.None;

                //Feed<Video> videoFeed = request.Get<Video>(query);
            }

            Console.ReadKey(true);
        }
Example #6
0
        public override List <ContextMenuEntry> GetContextMenuEntries(Category selectedCategory, VideoInfo selectedItem)
        {
            List <ContextMenuEntry> result = new List <ContextMenuEntry>();

            if (selectedItem != null)
            {
                result.Add(new ContextMenuEntry()
                {
                    DisplayText = Translation.Instance.RelatedVideos, Action = ContextMenuEntry.UIAction.Execute
                });

                MyYouTubeEntry ytEntry = selectedItem.Other as MyYouTubeEntry;
                if (ytEntry != null && ytEntry.YouTubeEntry != null)
                {
                    if (ytEntry.YouTubeEntry.Uploader != null && !string.IsNullOrEmpty(ytEntry.YouTubeEntry.Uploader.Value))
                    {
                        result.Add(new ContextMenuEntry()
                        {
                            DisplayText = Translation.Instance.UploadsBy + " [" + ytEntry.YouTubeEntry.Uploader.Value + "]", Action = ContextMenuEntry.UIAction.Execute
                        });
                        result.Add(new ContextMenuEntry()
                        {
                            DisplayText = Translation.Instance.Playlists + " [" + ytEntry.YouTubeEntry.Uploader.Value + "]", Action = ContextMenuEntry.UIAction.Execute
                        });
                    }
                    if (selectedCategory != null && selectedCategory.Other as string == "Login" && selectedCategory.Name == string.Format("{0}'s {1}", accountname, Translation.Instance.Favourites))
                    {
                        result.Add(new ContextMenuEntry()
                        {
                            DisplayText = Translation.Instance.RemoveFromFavorites + " (" + Settings.Name + ")", Action = ContextMenuEntry.UIAction.Execute
                        });
                    }
                    else if (!string.IsNullOrEmpty(accountname) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(accountname))
                    {
                        result.Add(new ContextMenuEntry()
                        {
                            DisplayText = Translation.Instance.AddToFavourites + " (" + Settings.Name + ")", Action = ContextMenuEntry.UIAction.Execute
                        });
                    }
                    if (!string.IsNullOrEmpty(accountname) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(accountname))
                    {
                        // comment
                        result.Add(new ContextMenuEntry()
                        {
                            DisplayText = Translation.Instance.AddComment, Action = ContextMenuEntry.UIAction.GetText
                        });
                        // rate (YouTube uses a 1-5 rating system in which 1 is the lowest rating that can be given)
                        var rCtx = new ContextMenuEntry()
                        {
                            DisplayText = Translation.Instance.RateVideo, Action = ContextMenuEntry.UIAction.ShowList
                        };
                        for (int i = 1; i <= 5; i++)
                        {
                            rCtx.SubEntries.Add(new ContextMenuEntry()
                            {
                                DisplayText = i.ToString()
                            });
                        }
                        result.Add(rCtx);
                        // add to playlist
                        var plCtx = new ContextMenuEntry()
                        {
                            DisplayText = Translation.Instance.AddToPlaylist, Action = ContextMenuEntry.UIAction.ShowList
                        };
                        plCtx.SubEntries.Add(new ContextMenuEntry()
                        {
                            DisplayText = Translation.Instance.CreateNewPlaylist, Action = ContextMenuEntry.UIAction.GetText
                        });
                        foreach (var pl in request.GetPlaylistsFeed(accountname).Entries)
                        {
                            plCtx.SubEntries.Add(new ContextMenuEntry()
                            {
                                DisplayText = pl.Title, Other = pl.PlaylistsEntry.Content.Src.Content
                            });
                        }
                        result.Add(plCtx);
                        if (selectedCategory != null && selectedCategory.ParentCategory != null && !(selectedCategory.ParentCategory is RssLink) && selectedCategory.ParentCategory.Name == string.Format("{0}'s {1}", accountname, Translation.Instance.Playlists))
                        {
                            result.Add(new ContextMenuEntry()
                            {
                                DisplayText = Translation.Instance.RemoveFromPlaylist, Other = (selectedCategory as RssLink).Url
                            });
                        }
                    }
                }
            }
            else
            {
                if (selectedCategory != null && selectedCategory.ParentCategory != null && !(selectedCategory.ParentCategory is RssLink) && selectedCategory.ParentCategory.Name == string.Format("{0}'s {1}", accountname, Translation.Instance.Playlists))
                {
                    result.Add(new ContextMenuEntry()
                    {
                        DisplayText = Translation.Instance.DeletePlaylist, Other = (selectedCategory as RssLink).Url
                    });
                }
                else if (selectedCategory != null && selectedCategory.ParentCategory != null && !(selectedCategory.ParentCategory is RssLink) && selectedCategory.ParentCategory.Name == string.Format("{0}'s {1}", accountname, Translation.Instance.Subscriptions))
                {
                    result.Add(new ContextMenuEntry()
                    {
                        DisplayText = Translation.Instance.UploadsBy + " [" + selectedCategory.Name + "]", Action = ContextMenuEntry.UIAction.Execute
                    });
                    result.Add(new ContextMenuEntry()
                    {
                        DisplayText = Translation.Instance.Playlists + " [" + selectedCategory.Name + "]", Action = ContextMenuEntry.UIAction.Execute
                    });
                }
            }
            return(result);
        }
        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 #9
0
 //http://gdata.youtube.com/feeds/api/playlists/6B4AA5F8DE307567?v=2
 private void button5_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(textBox3.Text))
     {
         YouTubeRequest request = new YouTubeRequest(settings);
         Feed<Playlist> userPlaylists = request.GetPlaylistsFeed(textBox3.Text);
         foreach (Playlist pl in userPlaylists.Entries)
         {
             temp = pl.Id.Split(':');
             cmbSubService.Items.Add(pl.Title);
         }
     }
 }