private static string GetYdlVersion(string binaryLocation) { // Get the version of the current youtube-dl binary. string currentVersion = string.Empty; using (ExecutableProcess process = new ExecutableProcess(binaryLocation, "--version", Path.GetDirectoryName(binaryLocation))) { process.OnReceived += (ee, data) => { currentVersion += data; }; process.Start(); process.WaitForExit(); } return(currentVersion.ToLower()); }
private void StartDownload() { BeginInvoke(((Action) delegate { lblStatus.Text = Localization.GetString("update_dialog.status.waiting", "Please wait..."); })); string currentVersion = GetYdlVersion(BinaryLocation); WriteLogLine(Localization.GetString("update_dialog.log.current_version", "Current version: {CurrentVersion}").Replace("{CurrentVersion}", currentVersion)); string checkingText = Localization.GetString("update_dialog.checking", "Checking for updates..."); BeginInvoke(((Action) delegate { lblStatus.Text = checkingText; })); WriteLogLine(checkingText); bool hasErrors = false; using (ExecutableProcess ep = new ExecutableProcess(BinaryLocation, "-U")) { ep.OnReceived += (s, data) => { if (data == null) { return; } if (data.IndexOf("ERROR", StringComparison.InvariantCultureIgnoreCase) != -1) { hasErrors = true; } WriteLogLine(data); }; ep.OnError += (s, data) => WriteLogLine(data); ep.Start(); ep.WaitForExit(); } UpdateCompleted(!hasErrors); }