public override async Task ProcessInternal(PlaylistWithAudio playlistWithAudio, DirectoryInfo workDir, CancellationToken token, ILog log) { if (!string.IsNullOrWhiteSpace(playlistWithAudio.Playlist.Description)) { var text = filesystemTools.CreateFile(workDir, $"__description.txt", CreateMode.OverwriteExisting); await File.WriteAllTextAsync(text.FullName, playlistWithAudio.Playlist.Description, token); } if (playlistWithAudio.Playlist.Cover != null) { await attachmentProcessor.ProcessAttachment(playlistWithAudio.Playlist.Cover, workDir, token, log); } var attachmentTasks = playlistWithAudio.Audio.Select((a, i) => attachmentProcessor.ProcessAttachment(a, i + 1, workDir, token, log)); await Task.WhenAll(attachmentTasks); }
public override async Task ProcessInternal(AlbumWithPhoto albumWithPhoto, DirectoryInfo workDir, CancellationToken token, ILog log) { if (!string.IsNullOrWhiteSpace(albumWithPhoto.Album.Description)) { var text = filesystemTools.CreateFile(workDir, $"__description.txt", CreateMode.OverwriteExisting); await File.WriteAllTextAsync(text.FullName, albumWithPhoto.Album.Description, token); } if (albumWithPhoto.Album.ThumbId != null) { var cover = albumWithPhoto.Photo.FirstOrDefault(x => x.Id == albumWithPhoto.Album.ThumbId); if (cover != null) { await attachmentProcessor.ProcessAttachment(cover, -1, workDir, token, log); } } var attachmentTasks = albumWithPhoto.Photo.Select((a, i) => attachmentProcessor.ProcessAttachment(a, i + 1, workDir, token, log)); await Task.WhenAll(attachmentTasks); }
public override async Task ProcessInternal(Post post, DirectoryInfo workDir, CancellationToken token, ILog log) { if (!string.IsNullOrWhiteSpace(post.Text)) { var postText = filesystemTools.CreateFile(workDir, $"text.txt", CreateMode.OverwriteExisting); await File.WriteAllTextAsync(postText.FullName, post.Text, token); } var attachmentTasks = post.Attachments.Select((a, i) => attachmentProcessor.ProcessAttachment(a, i + 1, workDir, token, log)); await Task.WhenAll(attachmentTasks); if (post.Comments?.Count > 0) { await commentsHandler.Process(post, workDir, token, log); } // recursively walk reposts var allRepostTasks = post.CopyHistory .OrderBy(x => x.Date) .Select(repost => Process(repost, workDir, token, log)); await Task.WhenAll(allRepostTasks); }
public override async Task ProcessInternal(Comment comment, DirectoryInfo workDir, CancellationToken token, ILog log) { var attachmentTasks = comment.Attachments.Select((a, i) => attachmentProcessor.ProcessAttachment(a, i + 1, workDir, token, log)); await Task.WhenAll(attachmentTasks); }