public async Task RunAsync() { ClipDownloader downloader = new ClipDownloader(DownloadOptions); Progress <ProgressReport> progress = new Progress <ProgressReport>(); progress.ProgressChanged += Progress_ProgressChanged; Status = TwitchTaskStatus.Running; OnPropertyChanged("Status"); try { await downloader.DownloadAsync(); if (TokenSource.IsCancellationRequested) { Status = TwitchTaskStatus.Cancelled; OnPropertyChanged("Status"); } else { Progress = 100; OnPropertyChanged("Progress"); Status = TwitchTaskStatus.Finished; OnPropertyChanged("Status"); } } catch { Status = TwitchTaskStatus.Failed; OnPropertyChanged("Status"); } }
private static void DownloadClip(Options inputOptions) { ClipDownloadOptions downloadOptions = new ClipDownloadOptions(); if (inputOptions.Id == "" || inputOptions.Id.All(Char.IsDigit)) { Console.WriteLine("[ERROR] - Invalid Clip ID, unable to parse."); Environment.Exit(1); } downloadOptions.Id = inputOptions.Id; downloadOptions.Filename = inputOptions.OutputFile; downloadOptions.Quality = inputOptions.Quality; ClipDownloader clipDownloader = new ClipDownloader(downloadOptions); clipDownloader.DownloadAsync().Wait(); }