protected void ProcessEpisodes(IEnumerable <TVShowEpisode> episodes) { Episodes = episodes.OrderBy(e => e.EpisodeNumber).ToList(); GroupedEpisodes = GetGroupedEpisodes(Episodes); GroupedUnwatchedEpisodes = GetGroupedEpisodes(Episodes.Where(e => e.PlayedState != ItemPlayedState.HasBeenPlayed)); }
public async Task <List <Artist> > GetArtistsAsync() { if (_artists != null && _artistCacheRevision == Client.CurrentLibraryUpdateNumber) { return(_artists); } var query = DacpQueryCollection.And(DacpQueryPredicate.IsNotEmpty("daap.songartist"), MediaKindQuery); DacpRequest request = GetGroupsRequest(query, true, "artists"); try { var response = await Client.SendRequestAsync(request).ConfigureAwait(false); _groupedArtists = DacpUtility.GetAlphaGroupedDacpList(response.Nodes, n => new Artist(this, n), out _artists); _artistsByID = _artists.ToDictionary(a => a.ID); } catch { _artists = new List <Artist>(); _artistsByID = new Dictionary <int, Artist>(); _groupedArtists = new DacpList <Artist>(false); } _artistCacheRevision = Client.CurrentLibraryUpdateNumber; return(_artists); }
public async Task <List <Album> > GetAlbumsAsync() { if (_albums != null && _albumCacheRevision == Client.CurrentLibraryUpdateNumber) { return(_albums); } DacpRequest request = GetGroupsRequest(GroupsQuery, true); try { var response = await Client.SendRequestAsync(request).ConfigureAwait(false); _groupedAlbums = DacpUtility.GetAlphaGroupedDacpList(response.Nodes, n => new Album(this, n), out _albums); _albumsByID = _albums.ToDictionary(a => a.ID); _albumsByPersistentID = _albums.ToDictionary(a => a.PersistentID); } catch { _albums = new List <Album>(); _albumsByID = new Dictionary <int, Album>(); _albumsByPersistentID = new Dictionary <ulong, Album>(); _groupedAlbums = new DacpList <Album>(false); } _albumCacheRevision = Client.CurrentLibraryUpdateNumber; return(_albums); }
public async Task <IDacpList> GetGroupedGenresAsync() { if (_groupedGenres != null) { return(_groupedGenres); } DacpRequest request = GetGenresRequest(true); _groupedGenres = await Client.GetAlphaGroupedListAsync(request, d => new DacpGenre(this, d), "abgn").ConfigureAwait(false); return(_groupedGenres); }
public async Task <IDacpList> GetMoviesAsync() { if (_movies != null && _movieCacheRevision == Client.CurrentLibraryUpdateNumber) { return(_movies); } DacpRequest request = GetItemsRequest(MediaKindQuery, "name", true); _movies = await Client.GetAlphaGroupedListAsync(request, n => new Movie(this, n)); _movieCacheRevision = Client.CurrentLibraryUpdateNumber; return(_movies); }
public async Task <IDacpList> GetGroupedItemsAsync() { if (_groupedItems != null) { return(_groupedItems); } var query = DacpQueryCollection.And(DacpQueryPredicate.Is("daap.songgenre", Name), Container.MediaKindQuery); DacpRequest request = Container.GetItemsRequest(query, "name", true); try { var response = await Client.SendRequestAsync(request).ConfigureAwait(false); _groupedItems = DacpUtility.GetAlphaGroupedDacpList(response.Nodes, n => new DacpItem(Container, n), out _items); } catch { _items = new List <DacpItem>(); _groupedItems = new DacpList <DacpItem>(false); } return(_groupedItems); }