private async Task <List <Collection> > GetMovieRootItems(string id, CancellationToken cancellationToken) { Log.Information($"Asking for all root views for admin user with id {id}"); var rootItem = await _embyClient.GetRootFolderAsync(id, cancellationToken); var items = await _embyClient.GetItemsAsync(new ItemQuery { ParentId = rootItem.Id, UserId = id }, cancellationToken); return(items.Items.Where(x => x.CollectionType == "movies").Select(x => new Collection { Id = x.Id, Name = x.Name, Type = CollectionType.Movies, PrimaryImage = x.ImageTags.ContainsKey(ImageType.Primary) ? x.ImageTags.FirstOrDefault(y => y.Key == ImageType.Primary).Value : default(string) }).ToList()); }
public async Task <IReadOnlyCollection <IMovieIdentifier> > GetMovieIdentifiersAsync(IEmbyClient client, string libraryId) { var query = new ItemQuery { UserId = client.CurrentUserId, ParentId = libraryId, Filters = new[] { ItemFilter.IsNotFolder }, IncludeItemTypes = new[] { "Movie" }, Fields = new[] { ItemFields.Path }, Recursive = true }; var itemsResult = await client.GetItemsAsync(query); return(itemsResult.Items .Select(x => new MovieIdentifier { Filename = Path.GetFileName(x.Path), Id = x.Id }) .ToArray()); }
public async Task <IReadOnlyCollection <ICollectionIdentifier> > GetCollectionIdentifiersAsync(IEmbyClient client) { var query = new ItemQuery { UserId = client.CurrentUserId, // FYI: Collections are folders. Filters = new[] { ItemFilter.IsFolder }, IncludeItemTypes = new[] { "Boxset" }, Fields = new[] { ItemFields.Path }, Recursive = true }; var itemsResult = await client.GetItemsAsync(query); return(itemsResult.Items .Select(x => new CollectionIdentifier { Path = x.Path, Id = x.Id, Name = x.Name }) .ToArray()); }