private void btnDownloadFromWeb_Click(object sender, EventArgs e) { MessageBox.Show("Go to the Chrome Inspector, go to the Network tab, " + "and refresh the page. Look for a .mp4, .m3u, or .m3u8 url."); var url = InputBoxForm.GetStrInput("Enter the url that was seen,"); if (!String.IsNullOrEmpty(url)) { RunToolHelper.RunAndCatch(() => { downloadFromWeb(url); }); } }
private void doCustomEncode(string example, InputBoxHistory key) { var files = this.GetInputFiles(1); var cmd = InputBoxForm.GetStrInput("Command for the ffmpeg encoder:", example, key); if (String.IsNullOrEmpty(cmd)) { return; } else if (!cmd.Contains("%in%") && !Utils.AskToConfirm("Did not see '%in%', " + "won't process input files. Continue?")) { return; } if (!Utils.AskToConfirm("Run the command right now? (or copy the command line to the clipboard)")) { var s = ""; foreach (var file in files) { s += "\r\n\"" + CsDownloadVidFilepaths.GetFfmpeg() + "\" "; s += cmd.Replace("%in%", files[0]); } Clipboard.SetText(s); MessageBox.Show("Command was copied to the clipboard."); return; } RunToolHelper.RunAndCatch(() => { var infos = new List <ProcessStartInfo>(); foreach (var file in files) { var info = new ProcessStartInfo(); info.FileName = CsDownloadVidFilepaths.GetFfmpeg(); info.Arguments = cmd.Replace("%in%", file); info.CreateNoWindow = true; info.RedirectStandardError = true; info.RedirectStandardOutput = true; info.UseShellExecute = false; infos.Add(info); } _runner.RunProcesses(infos.ToArray(), "Custom encode"); }); }
// ask user for string input. public static string GetStrInput(string mesage, string currentSuggestion = null, InputBoxHistory historyKey = InputBoxHistory.None, string[] more = null, bool useClipboard = true, bool mustBeDirectory = false, bool taller = false) { using (InputBoxForm form = new InputBoxForm(historyKey)) { form._label.Text = mesage; form._btnBrowse.Visible = mustBeDirectory; form._btnBrowse.Click += (o, e) => form.OnBrowseClick(); if (taller) { form._comboBox.Top += form.Height - 40; form._btnOK.Top += form.Height - 40; form._btnCancel.Top += form.Height - 40; form._label.Height += form.Height - 40; form.Height *= 2; } // fill combo box with suggested input. form._comboBox.Items.Clear(); var suggestions = GetInputSuggestions(currentSuggestion, historyKey, form._mru, useClipboard, mustBeDirectory, more).ToArray(); foreach (var s in suggestions) { form._comboBox.Items.Add(s); } form._comboBox.Text = suggestions.Length > 0 ? suggestions[0] : ""; form.ShowDialog(); if (form.DialogResult != DialogResult.OK) { return(null); } if (mustBeDirectory && !Directory.Exists(form._comboBox.Text)) { Utils.MessageBox("Directory does not exist"); return(null); } // save to history form._mru.AddToHistory(form._comboBox.Text); return(form._comboBox.Text); } }