예제 #1
0
        /// <summary>
        ///     Begin download process.
        /// </summary>
        /// <param name="sender">The parameter is not used.</param>
        /// <param name="e">The parameter is not used.</param>
        private void OnDownloadButtonClicked(object sender, EventArgs e)
        {
            try
            {
                var progressDialog = new ProgressDialog();
                if (!progressDialog.Error && (ResponseType)progressDialog.Run() == ResponseType.Cancel)
                {
                    try
                    {
                        this.youtubeController.KillProcess();
                    }
                    catch (Exception ex)
                    {
                        progressDialog.Destroy();
                        using (var exceptionDialog = new ExceptionDialog(ex.GetType().Name, ex.Message))
                        {
                            exceptionDialog.Run();
                        }

                        this.log.Error($"Error stopping youtube-dl process: {ex}");
                    }
                }
            }
            catch (Exception ex)
            {
                using (var exceptionDialog = new ExceptionDialog(ex.GetType().Name, ex.Message))
                {
                    exceptionDialog.Run();
                }

                this.log.Error($"Error downloading: {ex}");
            }
        }
예제 #2
0
        private void OnShown(object sender, EventArgs e)
        {
            var youtubeDLController = YoutubeDLController.Instance();

            // Redirect stdout and stderr
            youtubeDLController.StandardError  += this.OnStandardError;
            youtubeDLController.StandardOutput += this.OnStandardOutput;

            Process youtubeProcess;

            try
            {
                youtubeProcess = youtubeDLController.Download();
            }
            catch (Exception ex)
            {
                using (var exceptionDialog = new ExceptionDialog(ex.GetType().Name, ex.Message))
                {
                    exceptionDialog.Run();
                }

                this.log.Error($"Error downloading: {ex}");
                this.Error = true;
                this.Destroy();
                return;
            }

            if (youtubeProcess != null)
            {
                // Context sensitive depending on whether process is still alive
                youtubeProcess.Exited += this.OnDownloadComplete;
            }

            this.processTextView.Buffer.Text += "Running the following command:\n" + youtubeDLController.RunCommand + "\n";
        }
예제 #3
0
        /// <summary>
        /// Raises the action activated event.
        /// </summary>
        /// <param name="sender">The parameter is not used.</param>
        /// <param name="e">The parameter is not used.</param>
        protected void OnUpdateYoutubeDlActionActivated(object sender, EventArgs e)
        {
            this.youtubeController.Update = true;
            var progressDialog = new ProgressDialog();

            if ((ResponseType)progressDialog.Run() == ResponseType.Cancel)
            {
                try
                {
                    this.youtubeController.KillProcess();
                }
                catch (Exception ex)
                {
                    using (var exceptionDialog = new ExceptionDialog(ex.GetType().Name, ex.Message))
                    {
                        exceptionDialog.Run();
                    }
                }
            }
        }