Example #1
0
        private void ExportTXT_Click(object sender, EventArgs e)
        {
            if (ExportTXTSaveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                Log("\nEmporting txt to: " + ExportTXTSaveFileDialog.FileName);
                StreamWriter exportsw = new StreamWriter(ExportTXTSaveFileDialog.FileName);
                for (int i = 0; i < VideosTextBox.Lines.Length; i++)
                {
                    exportsw.Write(VideosTextBox.Lines[i]);
                    if (i < VideosTextBox.Lines.Length - 1)
                    {
                        exportsw.Write("\r\n");
                    }
                }
                exportsw.Close();
            }
            catch (IOException ioe)
            {
                Log("\nError during export txt: " + ioe.Message);
                MessageBox.Show("Error:\n\n" + ioe.ToString(), "Error exportando vídeos a txt", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Cursor.Current = Cursors.Default;
        }
Example #2
0
        private void ExportFromPlaylist_Click(object sender, EventArgs e)
        {
            if (ExportTXTSaveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            try
            {
                Log("\nExporting txt from playlist/channel to: " + ExportTXTSaveFileDialog.FileName);

                Cursor.Current = Cursors.WaitCursor;
                DownloadProgressBar.Maximum = 2;

                InitializeProcess(PlaylistProcess);
                PlaylistProcess.StartInfo.Arguments = PlaylistTextBox.Text + " -i --get-id";
                DownloadingPlaylist = PlaylistProcess.Start();

                List <string> ExportResult = new List <string>();

                StreamReader sr = PlaylistProcess.StandardOutput;
                DownloadingPlaylist = true;

                int Videos         = 0;
                int ExportedVideos = 0;

                DownloadProgressBar.Value = 1;
                for (int i = 0; !PlaylistProcess.HasExited; i++)
                {
                    string dLine = sr.ReadLine();

                    if (dLine == null)
                    {
                        continue;
                    }

                    if (dLine.StartsWith("WARNING"))
                    {
                        continue;
                    }
                    Videos++;
                    if (dLine.StartsWith("ERROR"))
                    {
                        continue;
                    }
                    ExportResult.Add("https://youtube.com/watch?v=" + dLine);
                    ExportedVideos++;
                }
                sr.Close();
                DownloadingPlaylist = false;
                ;
                File.WriteAllLines(ExportTXTSaveFileDialog.FileName, ExportResult.ToArray());

                DownloadProgressBar.Value = 2;

                Log("\nExported videos successfully: " + ExportedVideos + "/" + Videos);
                MessageBox.Show("Vídeos exportados con éxito: " + ExportedVideos + "/" + Videos, "Resultado de Exportar a txt", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                Log("\nError during export txt from playlist/channel: " + ex.Message);
                MessageBox.Show("Error:\n\n" + ex.ToString(), "Error exportando a txt", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Cursor.Current            = Cursors.Default;
            DownloadProgressBar.Value = 0;
        }