private async Task DownloadChapterImpl(DownloadChapterRequest task, IProgress <string> progress, CancellationToken cancellationToken) { progress.Report("Starting..."); var plugin = pluginManager.GetPlugin(task.Url); var images = await plugin.GetImages(task.Url, new Progress <string>(count => { progress.Report(count.ToString()); }), cancellationToken); var tempFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); var index = 1; foreach (var image in images) { progress.Report($"Download: {index}/{images.Count()}"); await downloader.GetFileAsync(image, tempFolder, cancellationToken); index++; } foreach (var format in task.Formats) { var factory = outputFactory.Create(format); factory.Save(tempFolder, task.SaveToFolder); } progress.Report("Done"); }
public Task <string> GetFileAsync(string url, string folder, CancellationToken cancellationToken) { logger.Info($"> DownloadToFolder: {url}. Folder: {folder}"); return(downloader.GetFileAsync(url, folder, cancellationToken)); }