private async void btn_verify_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //TODO: work out why any string passed authenticates my user account
                var username = await YouTubeServiceBuilder.GetAccountUsername("email_here");

                tb_email.Visibility    = Visibility.Collapsed;
                btn_verify.Visibility  = Visibility.Collapsed;
                tb_username.Text       = username;
                vb_username.Visibility = Visibility.Visible;

                playlists = await YouTubeServiceBuilder.GetUserPlaylists();

                foreach (var item in playlists)
                {
                    cb_playlists.Items.Add(item.Name);
                }
                ButtonsEnabled(true);
            }
            catch (System.Net.Http.HttpRequestException)
            {
                System.Windows.MessageBox.Show("Please check your internet connection and try again.", "No internet connection detected", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private async void btn_fetch_Click(object sender, RoutedEventArgs e)
        {
            ButtonsEnabled(false);
            if (first)
            {
                first = false;
            }
            if (!first)
            {
                ResetVariables();
            }
            ClearVideoList();
            img_loader.Visibility = Visibility.Visible;
            img_loader.StartAnimation();

            try
            {
                playlists = await YouTubeServiceBuilder.GetUserPlaylists();

                playlistVideos = await YouTubeServiceBuilder.GetPlaylistVideos(playlists, cb_playlists.Text);
            }
            catch (System.Net.Http.HttpRequestException)
            {
                System.Windows.MessageBox.Show("Please check your internet connect and try again.", "No Internet Connection Detected", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (InvalidOperationException)
            {
                System.Windows.MessageBox.Show("Please select a playlist.", "No Playlist Selected", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            img_loader.StopAnimation();
            img_loader.Visibility = Visibility.Hidden;
            PopulateVideoList();
            ButtonsEnabled(true);
        }
Exemple #3
0
        public async Task <IYouTubeVideos> GetPlaylistVideos(IYouTubePlaylists playlists, string playlistName)
        {
            string playlistId = GetPlaylistsId(playlists, playlistName);

            try
            {
                return(await services.GetPlaylistVideos(playlistId));
            }
            catch (AggregateException ex)
            {
                foreach (var e in ex.InnerExceptions)
                {
                    Console.WriteLine("|| ERROR || " + e);
                }
            }
            return(null);
        }
Exemple #4
0
        private async void btn_verify_Click(object sender, EventArgs e)
        {
            try
            {
                lbl_username.Text = await YouTubeServiceBuilder.GetAccountUsername("email_here");

                playlists = await YouTubeServiceBuilder.GetUserPlaylists();

                foreach (var item in playlists)
                {
                    cb_playlists.Items.Add(item.Name);
                }
                ButtonsEnabled(true);
                Controls.Remove(pnl_verify);
            }
            catch (System.Net.Http.HttpRequestException)
            {
                MessageBox.Show("Please check your internet connect and try again.", "No internet connection detected", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #5
0
        private async void btn_fetch_Click(object sender, EventArgs e)
        {
            ButtonsEnabled(false);
            if (first)
            {
                first = false;
            }
            if (!first)
            {
                resetVariables();
            }
            clearVideoList();

            PictureBox loader = new PictureBox();

            loader.Image     = Image.FromFile("img/loader.gif");
            loader.SizeMode  = PictureBoxSizeMode.AutoSize;
            loader.BackColor = Color.Transparent;
            loader.Location  = new Point(pnl_videos.Width / 2, 200);
            pnl_videos.Controls.Add(loader);

            try
            {
                playlists = await YouTubeServiceBuilder.GetUserPlaylists();

                playlistVideos = await YouTubeServiceBuilder.GetPlaylistVideos(playlists, cb_playlists.Text);
            }
            catch (System.Net.Http.HttpRequestException)
            {
                MessageBox.Show("Please check your internet connect and try again.", "No Internet Connection Detected", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Please select a playlist.", "No Playlist Selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            pnl_videos.Controls.Remove(loader);

            populateVideoList();
            ButtonsEnabled(true);
        }
 private void ResetVariables()
 {
     playlists      = DependencyManager.Resolve <IYouTubePlaylists>();
     playlistVideos = DependencyManager.Resolve <IYouTubeVideos>();
 }
Exemple #7
0
 private string GetPlaylistsId(IYouTubePlaylists playlists, string playlistName)
 {
     return((from p in playlists where p.Name == playlistName select p.Id).First());
 }