Example #1
0
        /// <summary>
        /// Imports playlist (uploads) items from youtube to redis
        /// </summary>
        /// <returns></returns>
        public async Task ImportUploadsPlaylistItems(IEnumerable<ChannelDto> channels)
        {
                _eventLog.Log("Importing uploads");
                var playlists = new PlaylistsServiceImporter(_task).GetUploadsPlaylist(channels.Select(x => x.RelatedPlaylists.UploadsId));
                await ImportPlaylistItems(playlists);

                _eventLog.Log("Finished importing uploads");
        }
Example #2
0
        /// <summary>
        /// Imports playlists from youtube to redis
        /// </summary>
        /// <param name="channels"></param>
        /// <returns></returns>
        public async Task<IEnumerable<PlaylistDto>> ImportPlaylists(List<ChannelDto> channels)
        {
            return await Task.Run<IEnumerable<PlaylistDto>>(() =>
            {
                _eventLog.Log("Importing playlists");
                var playlists = new PlaylistsServiceImporter(_task).GetPlaylists(channels.Select(x => x.Id));

                foreach (var channel in channels)
                {
                    channel.PlaylistsIds = playlists.Where(playlist => channel.Id == playlist.ChannelId)
                        .OrderByDescending(x => x.PublishedAt)
                        .Select(playlist => playlist.Id).ToList();
                }
                var channelService = new ChannelsService();
                channelService.SetChannels(channels);


                _eventLog.Log("Finished importing playlists");
                return playlists;
            }, _taskCancellationToken);
        }