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 Task <IDacpList> GetGenreArtistsAsync(string genreName) { var query = DacpQueryCollection.And(DacpQueryPredicate.Is("daap.songgenre", genreName), DacpQueryPredicate.IsNotEmpty("daap.songartist"), MediaKindQuery); DacpRequest request = GetGroupsRequest(query, true, "artists"); return(Client.GetAlphaGroupedListAsync(request, n => new Artist(this, n))); }
public Task <IDacpList> GetGenreSongsAsync(string genreName) { var query = DacpQueryCollection.And(DacpQueryPredicate.Is("daap.songgenre", genreName), MediaKindQuery); DacpRequest request = GetItemsRequest(query, "name", true); return(Client.GetAlphaGroupedListAsync(request, n => new Song(this, n))); }
public Task <IDacpList> GetUnwatchedMoviesAsync() { var query = DacpQueryCollection.And(DacpQueryPredicate.Is("daap.songuserplaycount", 0), MediaKindQuery); DacpRequest request = GetItemsRequest(query, "name", true); return(Client.GetAlphaGroupedListAsync(request, n => new Movie(this, n))); }
public Task <List <Album> > GetAlbumsAsync() { var query = DacpQueryCollection.And(GroupQuery, Container.GroupsQuery); DacpRequest request = Container.GetGroupsRequest(query); return(Client.GetListAsync(request, n => new Album(Container, n))); }
public async Task <bool> SendPlayItemCommandAsync(DacpItem item, PlayQueueMode mode = PlayQueueMode.Replace) { DacpRequest request; if (Client.ServerSupportsPlayQueue) { request = Database.GetPlayQueueEditRequest("add", DacpQueryPredicate.Is("dmap.itemid", item.ID), mode, "name"); request.QueryParameters["queuefilter"] = string.Format("genre:{0}", Uri.EscapeDataString(DacpUtility.EscapeSingleQuotes(Name))); } else { var items = await GetItemsAsync(); int index = items.FindIndex(i => i.ID == item.ID); if (index < 0) { return(false); } request = Database.GetCueSongRequest(DacpQueryCollection.And(GenreQuery, Container.MediaKindQuery), "name", index); } try { await Client.SendRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
internal DacpRequest GetGenresRequest(bool requestSortHeaders = false) { DacpRequest request = new DacpRequest("/databases/{0}/browse/genres", Database.ID); DacpQueryElement query = DacpQueryCollection.And(DacpQueryPredicate.IsNotEmpty("daap.songgenre"), MediaKindQuery); request.QueryParameters["filter"] = query.ToString(); if (requestSortHeaders) { request.QueryParameters["include-sort-headers"] = "1"; } return(request); }
public async Task <List <Audiobook> > SearchAudiobooksAsync(string searchString, CancellationToken cancellationToken) { DacpQueryElement query = DacpQueryCollection.And(DacpQueryPredicate.Is("daap.songalbum", searchString), MediaKindQuery); DacpRequest request = GetGroupsRequest(query, false, "albums"); request.CancellationToken = cancellationToken; try { var response = await Client.SendRequestAsync(request).ConfigureAwait(false); return(DacpUtility.GetItemsFromNodes(response.Nodes, n => new Audiobook(this, n)).ToList()); } catch { return(null); } }
public async Task <List <Song> > SearchSongsAsync(string searchString, CancellationToken cancellationToken) { DacpQueryElement query = DacpQueryCollection.And(DacpQueryPredicate.Is("dmap.itemname", searchString), MediaKindQuery); DacpRequest request = GetItemsRequest(query, "name", false); request.CancellationToken = cancellationToken; try { var response = await Client.SendRequestAsync(request).ConfigureAwait(false); return(DacpUtility.GetItemsFromNodes(response.Nodes, n => new Song(this, n)).ToList()); } catch { return(null); } }
public async Task <bool> SendPlaySongCommandAsync(Song song) { try { int index = IndexOf(song); DacpQueryElement query = DacpQueryCollection.And(DacpQueryPredicate.Is("dmap.itemname", _searchString), Database.MusicContainer.MediaKindQuery); DacpRequest request = Database.GetCueSongRequest(query, "name", index); await Database.Client.SendRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
public async Task <bool> SendPlayCommandAsync(PlayQueueMode mode = PlayQueueMode.Replace) { DacpRequest request; if (Client.ServerSupportsPlayQueue) { request = Database.GetPlayQueueEditRequest("add", GenreQuery, mode, "name"); } else { request = Database.GetCueSongRequest(DacpQueryCollection.And(GenreQuery, Container.MediaKindQuery), "name", 0); } try { await Client.SendRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
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); }
public Task <List <Podcast> > GetUnplayedShowsAsync() { var query = DacpQueryCollection.And(DacpQueryPredicate.Is("daap.songuserplaycount", 0), GroupsQuery); return(GetGroupsAsync(query, n => new Podcast(this, n))); }
public Task <List <iTunesUCourse> > GetUnplayedCoursesAsync() { var query = DacpQueryCollection.And(DacpQueryPredicate.Is("daap.songuserplaycount", 0), GroupsQuery); return(GetGroupsAsync(query, n => new iTunesUCourse(this, n))); }