Пример #1
0
        public override async Task ProcessInternal(long id, DirectoryInfo workDir, CancellationToken token, ILog log)
        {
            var vkAlbums = await vkApiUtils.GetAllPagesAsync(vkApiUtils.PhotoAlbums(id), int.MaxValue, token, log);

            var expandTasks = vkAlbums.Select(album => vkApiUtils.ExpandAlbum(album, token, log));
            var albums      = await Task.WhenAll(expandTasks);

            var allPhotos = await vkApiUtils.GetAllPagesAsync(vkApiUtils.Photos(id), 100, token, log);

            var photosInAlbums = albums
                                 .SelectMany(awp => awp.Photo.Select(photo => photo.Id.Value))
                                 .ToHashSet();
            var uniquePhotos = allPhotos
                               .Where(photo => !photosInAlbums.Contains(photo.Id.Value))
                               .ToList();
            var defaultAlbum = new AlbumWithPhoto(uniquePhotos);

            var allAlbums = albums.ToList();

            if (defaultAlbum.Photo.Any())
            {
                allAlbums.Add(defaultAlbum);
            }

            var allTasks = allAlbums
                           .OrderBy(p => p.Album.Created)
                           .Select(p => albumHandler.Process(p, workDir, token, log));
            await Task.WhenAll(allTasks);
        }
Пример #2
0
        public override async Task ProcessInternal(long id, DirectoryInfo workDir, CancellationToken token, ILog log)
        {
            var vkPlaylists = await vkApiUtils.GetAllPagesAsync(vkApiUtils.Playlists(id), 200, token, log);

            log.Debug($"Audio: {vkPlaylists.Count} playlists");
            var expandTasks = vkPlaylists.Select(p => vkApiUtils.ExpandPlaylist(p, token, log));
            var playlists   = await Task.WhenAll(expandTasks);

            log.Debug($"Audio: {playlists.Sum(p => p.Audio.Count)} in {playlists.Length} playlists");

            var allAudios = await vkApiUtils.GetAllPagesAsync(vkApiUtils.Audios(id), long.MaxValue, token, log);

            var audioInPlaylists = playlists
                                   .SelectMany(p => p.Audio.Select(t => t.Id))
                                   .ToHashSet();
            var uniqueAudios = allAudios
                               .Where(a => !audioInPlaylists.Contains(a.Id.Value))
                               .ToList();
            var defaultPlaylist = new PlaylistWithAudio(uniqueAudios);

            log.Debug($"Audio: {allAudios.Count} total, {defaultPlaylist.Audio.Count} unique in default playlist");

            var allPlaylists = playlists.ToList();

            allPlaylists.Add(defaultPlaylist);

            var allTasks = allPlaylists
                           .OrderBy(p => p.Playlist.CreateTime)
                           .Select(p => playlistHandler.Process(p, workDir, token, log));
            await Task.WhenAll(allTasks);
        }
Пример #3
0
        public override async Task ProcessInternal(long id, DirectoryInfo workDir, CancellationToken token, ILog log)
        {
            var allPosts = await vkApiUtils.GetAllPagesAsync(vkApiUtils.Posts(id), 100, token, log);

            log.Debug($"Wall has {allPosts.Count} posts");
            var allTasks = allPosts
                           .OrderBy(x => x.Date)
                           .Select(p => postHandler.Process(p, workDir, token, log));
            await Task.WhenAll(allTasks);
        }
        public override async Task ProcessInternal(Post post, DirectoryInfo workDir, CancellationToken token, ILog log)
        {
            var allComments = await vkApiUtils.GetAllPagesAsync(vkApiUtils.Comments(post), 100, token, log);

            log.Debug($"Post {post.Id} has {allComments.Count} comments");
            var byDate = allComments
                         .OrderBy(c => c.Date)
                         .ToList();
            await byDate.SaveHumanReadableText(filesystemTools, workDir, token, log);

            var commentTasks = byDate
                               .Where(c => c.Attachments.Count > 0)
                               .Select(c => commentHandler.Process(c, workDir, token, log));
            await Task.WhenAll(commentTasks);
        }