public async Task <SmartPlaylistDto[]> GetAllSmartPlaylistsAsync() { using (PerfLogger.Create("GetAllSmartPlaylistsFromStore")) { return(await _decorated.GetAllSmartPlaylistsAsync().ConfigureAwait(false)); } }
public async Task <SmartPlaylistDto[]> GetAllSmartPlaylistsAsync() { var smartPlaylists = await _decorated.GetAllSmartPlaylistsAsync().ConfigureAwait(false); smartPlaylists.ToList().ForEach(CleanupSmartPlaylist); return(smartPlaylists); }
private async Task <SmartPlaylistDto[]> GetAllCachedSmartPlaylistAsync() { return((await _memCache.GetOrCreateManyAsync(async() => { return (await _decorated.GetAllSmartPlaylistsAsync() .ConfigureAwait(false)) .ToDictionary(x => (object)x.Id, y => (object)y); }, Const.GetAllSmartPlaylistsCacheExpiration).ConfigureAwait(false)) .OfType <SmartPlaylistDto>() .ToArray()); }
public Task Execute(CancellationToken cancellationToken, IProgress <double> progress) { var dtos = _plStore.GetAllSmartPlaylistsAsync(); dtos.Wait(); foreach (var dto in dtos.Result) { SmartPlaylist smart_playlist = new SmartPlaylist(dto); var user = _userManager.GetUserByName(smart_playlist.User); List <Playlist> p; try { var playlists = _playlistManager.GetPlaylists(user.Id); p = playlists.Where(x => x.Id.ToString().Replace("-", "") == dto.Id).ToList(); } catch (NullReferenceException ex) { _logger.LogError(ex, "No user named {0} found, please fix playlist {1}", dto.User, dto.Name); continue; } if (dto.Id == null | p.Count() == 0) { _logger.LogInformation("Playlist ID not set, creating new playlist"); var plid = CreateNewPlaylist(dto, user); dto.Id = plid; _plStore.Save(dto); var playlists = _playlistManager.GetPlaylists(user.Id); p = playlists.Where(x => x.Id.ToString().Replace("-", "") == dto.Id).ToList(); } var new_items = smart_playlist.FilterPlaylistItems(GetAllUserMedia(user), _libraryManager, user); var playlist = p.First(); var query = new InternalItemsQuery(user) { IncludeItemTypes = SupportedItemTypeNames, Recursive = true, }; var plitems = playlist.GetChildren(user, false, query).ToList(); var toremove = plitems.Select(x => x.Id.ToString()).ToList(); RemoveFromPlaylist(playlist.Id.ToString(), toremove); _playlistManager.AddToPlaylistAsync(playlist.Id, new_items.ToArray(), user.Id); } return(Task.CompletedTask); }
public async Task <Domain.SmartPlaylist[]> GetAllUpdateableSmartPlaylistsAsync() { var smartPlaylistDtos = await _smartPlaylistStore.GetAllSmartPlaylistsAsync().ConfigureAwait(false); return(SmartPlaylistAdapter.Adapt(smartPlaylistDtos).Where(x => x.CanUpdatePlaylist).ToArray()); }