private void DownloadUpdateAsync(Models.UpdateModel app, Action<bool> finishedCallback, Action<double> progressPercentageCallback) { FileDownloader fileDownloader = new FileDownloader(app.UpdateURL); fileDownloader.DownloadAsync(downloadedData => { string filename = Path.GetFileName(new Uri(app.UpdateURL).AbsolutePath); System.IO.File.WriteAllBytes(filename, downloadedData); finishedCallback(true); }, (progress) => { progressPercentageCallback((100 * (progress.Current / progress.Total))); }); }
public void CanDownloadAsyncFromRegisteredProtocol() { _downloader.DownloadAsync(TestUrl, "C:\\a".ToAbsoluteFilePath()); A.CallTo(() => _strategy.DownloadAsync(GetDownloadSpec(TestUrl, "C:\\a".ToAbsoluteFilePath()))) .MustHaveHappened(Repeated.Exactly.Once); }
public async Task DownloadAndInstallXbox360DriverAsync() { var tempPath = Path.Combine(TempPathRoot, "XBOX360DRV"); //const string args = "/install /passive /norestart"; if (Environment.Is64BitProcess) { var targetFile = Path.Combine(tempPath, "Xbox360_64Eng.exe"); switch (OsInfoHelper.OsParse(OsInfoHelper.OsInfo)) { case OsType.Vista: await XboxDrvVistaX64Downloader.DownloadAsync(targetFile); break; case OsType.Win7: await XboxDrvWin7X64Downloader.DownloadAsync(targetFile); break; } await Task.Run(() => { var process = Process.Start(targetFile); if (process != null) { process.WaitForExit(); } }); } else { var targetFile = Path.Combine(tempPath, "Xbox360_32Eng.exe"); switch (OsInfoHelper.OsParse(OsInfoHelper.OsInfo)) { case OsType.Vista: await XboxDrvVistaX86Downloader.DownloadAsync(targetFile); break; case OsType.Win7: await XboxDrvWin7X86Downloader.DownloadAsync(targetFile); break; } await Task.Run(() => { var process = Process.Start(targetFile); if (process != null) { process.WaitForExit(); } }); } }
public async Task CheckFFprobeWrapperFile() { var fileDownloader = new FileDownloader(); var downloadResult = await fileDownloader.DownloadAsync("ffmpeg"); var testVideoPath = await this.GetTestVideoPathAsync(); var videoAnalyzer = new VideoAnalyzer(downloadResult.FfprobePath); var analyzeResult = await videoAnalyzer.GetVideoInfoAsync(testVideoPath); Assert.IsTrue(analyzeResult.Successful, "Get VideoInfo is not successful"); Assert.AreEqual(120, analyzeResult.VideoInfo.Format.Duration); }
public async Task CheckFFprobeWrapperStream() { var fileDownloader = new FileDownloader(); var downloadResult = await fileDownloader.DownloadAsync("ffmpeg"); var testVideoPath = await this.GetTestVideoPathAsync(); var videoData = await File.ReadAllBytesAsync(testVideoPath); var videoAnalyzer = new VideoAnalyzer(downloadResult.FfprobePath); var analyzeResult = await videoAnalyzer.GetVideoInfoAsync(videoData); Assert.IsTrue(analyzeResult.Successful, $"Get VideoInfo is not successful {analyzeResult.ErrorMessage}"); Assert.AreEqual(120, analyzeResult.VideoInfo.Format.Duration); }
public async Task DownloadAndInstallDirectXRedistAsync() { // current users temporary directory var tempPath = Path.Combine(TempPathRoot, "DXSETUP"); // build setup path var targetFile = Path.Combine(tempPath, "directx_Jun2010_redist.exe"); // download file await DxRedistOfflineInstallerDownloader.DownloadAsync(targetFile); // extract setup await Task.Run(() => Process.Start(targetFile, string.Format("/Q /T:\"{0}\"", tempPath)).WaitForExit()); // run actual setup await Task.Run(() => Process.Start(Path.Combine(tempPath, "DXSETUP.exe"), "/silent").WaitForExit()); }
private async void GenerateConfigurationButton_Click(object sender, EventArgs e) { var filesToDownload = new[] { "build.sh", "launch.json", "tasks.json" }; var downloadedFiles = await _fileDownloader.DownloadAsync(_settingsContainer.RepositoryLink, filesToDownload); var filesWithReplacedContent = _fileContentReplacer.Replace(_settingsContainer, downloadedFiles); _fileSaver.SaveAsync(_settingsContainer.ProjectPath, filesWithReplacedContent); _settingsContainer.LocalConfigurationVersion = await _versionChecker.GetRemoteConfigurationVersion(_settingsContainer.RepositoryLink); await _settingsManager.SaveAsync(_settingsContainer); await UpdateRemoteConfigVersionLabels(); }
/// <summary> /// Downloads and installs the Visual C++ Redistributable Packages für Visual Studio 2013, depending on the hosts architecture. /// </summary> /// <returns>The async object.</returns> public async Task DownloadAndInstallMsvc2013Async() { var tempPath = Path.Combine(TempPathRoot, "MSVC2013"); const string args = "/install /passive /norestart"; if (Environment.Is64BitProcess) { var targetFile = Path.Combine(tempPath, "vcredist_x64.exe"); await Msvc2013X64Downloader.DownloadAsync(targetFile); await Task.Run(() => Process.Start(targetFile, args).WaitForExit()); } else { var targetFile = Path.Combine(tempPath, "vcredist_x86.exe"); await Msvc2013X86Downloader.DownloadAsync(targetFile); await Task.Run(() => Process.Start(targetFile, args).WaitForExit()); } }
public async Task DownloadFormat(string filename, IFormat format, IProgress <double> progress = null) { string fname = PrepareFilename(format, filename); try { // download if (format is CompFormat cf) { var ff = Merger(cf); //if (!ff.Available) if (ff == null) { LogWarning("ffmpeg or avconf is not installed, skipping " + cf.Id); return; } // we dont support merging yet, so just download both string aname = PrepareFilename(cf.AudioFormat, filename); FileDownloader l = FileDownloader.GetSuitableDownloader(cf.AudioFormat.Protocol); l.OnProgress += (sender, e) => { progress?.Report(e.Percent); ProgressBar(sender, e, cf.AudioFormat.Id, "Downloading"); }; Task atask = l.DownloadAsync(cf.AudioFormat, aname, true); //downloadTasks.Add(dTask1); cf.AudioFormat.FileName = aname; cf.AudioFormat.IsDownloaded = true; string vname = PrepareFilename(cf.VideoFormat, filename); FileDownloader l2 = FileDownloader.GetSuitableDownloader(cf.VideoFormat.Protocol); l2.OnProgress += (sender, e) => { progress?.Report(e.Percent); ProgressBar(sender, e, cf.VideoFormat.Id, "Downloading"); }; Task vtask = l2.DownloadAsync(cf.VideoFormat, vname, true); //downloadTasks.Add(dTask2); cf.VideoFormat.FileName = vname; cf.VideoFormat.IsDownloaded = true; await atask; await vtask; ff.OnLog += Log; ff.OnProgress += (sender, e) => { progress?.Report(e.Percent); ProgressBar(sender, e, cf.Id, "Merging", ConsoleColor.Cyan); }; await ff.ProcessAsync(cf, fname); LogDebug("Merged"); } else { FileDownloader l3 = FileDownloader.GetSuitableDownloader(format.Protocol); l3.OnProgress += (sender, e) => { progress?.Report(e.Percent); ProgressBar(sender, e, format.Id, "Downloading"); }; Task dTask = l3.DownloadAsync(format, fname, true); await dTask; format.FileName = fname; format.IsDownloaded = true; } } catch (Exception e) { LogError($"Failed to download format {format.Id}: {e.Message}"); return; } if (fname != "-") { // *check and fixup stretched aspect ratio* if (format is IVideoFormat vf && vf.StretchedRatio != null && vf.StretchedRatio != 1) { if (Options.Fixup == FixupPolicy.Warn) { LogWarning("Stretched Aspect Ratio detected"); } else if (Options.Fixup == FixupPolicy.DetectOrWarn) { LogWarning("Stretched Aspect Ratio detected"); FFMpegFixupAspectRatioPP pp = new FFMpegFixupAspectRatioPP(); pp.OnLog += Log; pp.OnProgress += (sender, e) => { progress?.Report(e.Percent); ProgressBar(sender, e, vf.Id, "Fixing Aspect Ratio", ConsoleColor.Magenta); }; await pp.ProcessAsync(vf, fname); } } // *manage DASH m4a format* // *manage M3U8 format* try { await PostProcess(fname, format); } catch (Exception ex) { LogError("postprocessing: " + ex.Message); } // *record_download_archive* } //LogWarning("ffmpeg or avconf is not installed."); }