本文整理汇总了C#中MediaBrowser.Model.Querying.ItemQuery类的典型用法代码示例。如果您正苦于以下问题:C# ItemQuery类的具体用法?C# ItemQuery怎么用?C# ItemQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemQuery类属于MediaBrowser.Model.Querying命名空间,在下文中一共展示了ItemQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetItemsSection
protected async Task<IItemDetailSection> GetItemsSection(ItemsResult itemsResult, Func<ItemsResult, bool> listCondition, bool expandSingleItem = true)
{
if (itemsResult.Items.Length == 1 && expandSingleItem && itemsResult.Items[0].IsFolder) {
var query = new ItemQuery { ParentId = itemsResult.Items[0].Id, UserId = _sessionManager.CurrentUser.Id };
return await GetItemsSection(await _apiClient.GetItemsAsync(query), listCondition);
}
if (listCondition(itemsResult)) {
return new ItemsListViewModel(itemsResult, _apiClient, _imageManager, _serverEvents, _navigator, _playbackManager);
}
return new ItemsGridViewModel(itemsResult, _apiClient, _imageManager, _serverEvents, _navigator, _playbackManager);
}
示例2: GetMovies
private Task<ItemsResult> GetMovies()
{
var query = new ItemQuery {
UserId = _sessionManager.CurrentUser.Id,
IncludeItemTypes = new[] { "Movie" },
SortBy = new[] { ItemSortBy.SortName },
Fields = QueryFields,
Recursive = true
};
return _apiClient.GetItemsAsync(query);
}
示例3: GetLatestUnwatched
private async Task<bool> GetLatestUnwatched()
{
try
{
SetProgressBar("Getting latest unwatched items...");
var query = new ItemQuery
{
UserId = AuthenticationService.Current.LoggedInUser.Id,
SortBy = new[] {"DateCreated"},
SortOrder = SortOrder.Descending,
IncludeItemTypes = new[] {"Episode"},
Limit = 8,
Fields = new[] {ItemFields.PrimaryImageAspectRatio, ItemFields.ParentId},
Filters = new[] {ItemFilter.IsUnplayed},
Recursive = true
};
Log.Info("Getting next up items");
var itemResponse = await _apiClient.GetItemsAsync(query);
return SetLatestUnwatched(itemResponse);
}
catch (HttpException ex)
{
Log.ErrorException("GetLatestUnwatched()", ex);
}
SetProgressBar();
return false;
}
示例4: GetAllShows
private Task<ItemsResult> GetAllShows(ItemListViewModel viewModel, DisplayPreferences displayPreferences)
{
var query = new ItemQuery
{
Fields = FolderPage.QueryFields,
UserId = _sessionManager.CurrentUser.Id,
IncludeItemTypes = new[] { "Series" },
SortBy = !String.IsNullOrEmpty(displayPreferences.SortBy)
? new[] { displayPreferences.SortBy }
: new[] { ItemSortBy.SortName },
SortOrder = displayPreferences.SortOrder,
Recursive = true
};
return ApiClient.GetItemsAsync(query, CancellationToken.None);
}
示例5: GetSoundtracks
private Task<ItemsResult> GetSoundtracks(ItemListViewModel viewModel)
{
var item = ItemViewModel.Item;
var query = new ItemQuery
{
UserId = _sessionManager.LocalUserId,
Fields = new[]
{
ItemFields.PrimaryImageAspectRatio,
ItemFields.DateCreated
},
Ids = item.SoundtrackIds,
SortBy = new[] { ItemSortBy.SortName }
};
return _apiClient.GetItemsAsync(query, CancellationToken.None);
}
示例6: RetrieveMusicGenres
public IEnumerable<BaseItem> RetrieveMusicGenres(ItemQuery query)
{
var dtos = Kernel.ApiClient.GetMusicGenres(query);
return dtos == null ? new BaseItem[] {} : dtos.Items.Select(dto => GetItem(dto, dto.Type)).Where(item => item != null);
}
示例7: GetAlbums
private async Task<bool> GetAlbums()
{
try
{
var query = new ItemQuery
{
UserId = AuthenticationService.Current.LoggedInUser.Id,
Artists = new[] {SelectedArtist.Name},
Recursive = true,
Fields = new[] { ItemFields.ParentId,},
IncludeItemTypes = new[] {"MusicAlbum"}
};
Log.Info("Getting albums for artist [{0}] ({1})", SelectedArtist.Name, SelectedArtist.Id);
var items = await _apiClient.GetItemsAsync(query);
if (items != null && items.Items.Any())
{
//// Extract the album items from the results
//var albums = items.Items.Where(x => x.Type == "MusicAlbum").ToList();
//// Extract the track items from the results
//_artistTracks = items.Items.Where(y => y.Type == "Audio").ToList();
//var nameId = (from a in _artistTracks
// select new KeyValuePair<string, string>(a.Album, a.ParentId)).Distinct();
//// This sets the album names correctly based on what's in the track information (rather than folder name)
//foreach (var ni in nameId)
//{
// var item = albums.SingleOrDefault(x => x.Id == ni.Value);
// item.Name = ni.Key;
//}
foreach (var album in items.Items)
{
Albums.Add(album);
}
return true;
}
return false;
}
catch (Exception ex)
{
Log.ErrorException("GetAlbums()", ex);
return false;
}
}
示例8: GetAlbumTracks
private async Task GetAlbumTracks()
{
try
{
var query = new ItemQuery
{
ParentId = SelectedAlbum.Id,
IncludeItemTypes = new[] { "Audio" },
UserId = AuthenticationService.Current.LoggedInUserId
};
var tracks = await _apiClient.GetItemsAsync(query);
if (tracks.Items.IsNullOrEmpty())
{
return;
}
AlbumTracks = tracks.Items.OrderBy(x => x.ParentIndexNumber)
.ThenBy(x => x.IndexNumber).ToList();
}
catch (HttpException ex)
{
Log.ErrorException("GetAlbumTracks()", ex);
}
}
示例9: GetCollectionItems
private async Task<ItemsResult> GetCollectionItems(int limit)
{
var query = new ItemQuery
{
IncludeItemTypes = new[] {"Season", "Series", "Movie"},
Limit = limit,
SortBy = new[] {ItemSortBy.Random},
UserId = AuthenticationService.Current.LoggedInUserId,
ImageTypes = new []{ImageType.Primary},
Recursive = true
};
if (!string.IsNullOrEmpty(CollectionId))
{
query.ParentId = CollectionId;
}
var itemResponse = await _connectionManager.GetApiClient(App.ServerInfo.Id).GetItemsAsync(query);
return itemResponse;
}
示例10: GetLatestEpisodes
private async Task<ItemsResult> GetLatestEpisodes(ItemListViewModel viewModel)
{
var query = new ItemQuery
{
Fields = new[]
{
ItemFields.PrimaryImageAspectRatio,
ItemFields.DateCreated,
ItemFields.DisplayPreferencesId
},
UserId = _sessionManager.CurrentUser.Id,
SortBy = new[] { ItemSortBy.DateCreated },
SortOrder = SortOrder.Descending,
IncludeItemTypes = new[] { "Episode" },
ExcludeLocationTypes = new[] { LocationType.Virtual },
Filters = new[] { ItemFilter.IsUnplayed },
Limit = 9,
Recursive = true
};
var result = await ApiClient.GetItemsAsync(query);
ShowLatestEpisodes = result.TotalRecordCount > 0;
return result;
}
示例11: GetRecentlyPlayedAsync
private async Task<ItemsResult> GetRecentlyPlayedAsync(ItemListViewModel viewModel)
{
var query = new ItemQuery
{
Fields = new[]
{
ItemFields.PrimaryImageAspectRatio,
ItemFields.DateCreated,
ItemFields.DisplayPreferencesId
},
UserId = _sessionManager.CurrentUser.Id,
SortBy = new[] { ItemSortBy.DatePlayed },
SortOrder = SortOrder.Descending,
Filters = new[] { ItemFilter.IsPlayed },
IncludeItemTypes = new[] { "Game" },
Recursive = true,
Limit = 6
};
var result = await ApiClient.GetItemsAsync(query);
ShowRecentlyPlayed = result.Items.Length > 0;
return result;
}
示例12: GetGameSystems
private Task<ItemsResult> GetGameSystems(ItemListViewModel viewModel)
{
var query = new ItemQuery
{
Fields = new[]
{
ItemFields.PrimaryImageAspectRatio,
ItemFields.DateCreated,
ItemFields.DisplayPreferencesId
},
UserId = _sessionManager.CurrentUser.Id,
SortBy = new[] { ItemSortBy.SortName },
IncludeItemTypes = new[] { "GameSystem" },
Recursive = true
};
return ApiClient.GetItemsAsync(query);
}
示例13: GetLatestUnwatched
private async Task<bool> GetLatestUnwatched()
{
try
{
SetProgressBar(AppResources.SysTrayGettingUnwatchedItems);
var query = new ItemQuery
{
UserId = AuthenticationService.Current.LoggedInUserId,
SortBy = new[] {"DateCreated"},
SortOrder = SortOrder.Descending,
IncludeItemTypes = new[] {"Movie"},
Limit = 9,
Fields = new[] {ItemFields.PrimaryImageAspectRatio},
Filters = new[] {ItemFilter.IsUnplayed},
Recursive = true,
ImageTypeLimit = 1,
EnableImageTypes = new[] { ImageType.Backdrop, ImageType.Primary, }
};
Log.Info("Getting next up items");
var itemResponse = await ApiClient.GetItemsAsync(query);
return SetLatestUnwatched(itemResponse);
}
catch (HttpException ex)
{
Utils.HandleHttpException("GetLatestUnwatched()", ex, NavigationService, Log);
}
SetProgressBar();
return false;
}
示例14: GetBoxsets
private async Task<bool> GetBoxsets()
{
try
{
SetProgressBar(AppResources.SysTrayGettingBoxsets);
var query = new ItemQuery
{
UserId = AuthenticationService.Current.LoggedInUserId,
SortBy = new[] {"SortName"},
SortOrder = SortOrder.Ascending,
IncludeItemTypes = new[] {"BoxSet"},
Recursive = true,
ImageTypeLimit = 1,
EnableImageTypes = new[] { ImageType.Backdrop, ImageType.Primary, }
};
var itemResponse = await ApiClient.GetItemsAsync(query);
return await SetBoxsets(itemResponse);
}
catch (HttpException ex)
{
Utils.HandleHttpException("GetBoxsets()", ex, NavigationService, Log);
}
SetProgressBar();
return false;
}
示例15: GetItems
private async Task<bool> GetItems()
{
try
{
var query = new ItemQuery
{
UserId = AuthenticationService.Current.LoggedInUserId,
SortBy = new[] {ItemSortBy.SortName},
SortOrder = SortOrder.Ascending,
Fields = new[]
{
ItemFields.SortName,
ItemFields.Genres,
ItemFields.ProviderIds,
ItemFields.ParentId,
ItemFields.CumulativeRunTimeTicks
},
ExcludeItemTypes = SelectedFolder != null && SelectedFolder.Name.ToLower().Contains("recent") ? new[] {"Season", "Series"} : null,
ImageTypeLimit = 1,
EnableImageTypes = new[] { ImageType.Backdrop, ImageType.Primary, }
};
var isRecent = false;
if (SelectedPerson != null)
{
Log.Info("Getting items for {0}", SelectedPerson.Name);
PageTitle = SelectedPerson.Name.ToLower();
query.Person = SelectedPerson.Name;
query.PersonTypes = new[] {SelectedPerson.Type};
query.Recursive = true;
}
else
{
if (SelectedFolder.Name.Contains(AppResources.LabelRecent.ToLower()))
{
Log.Info("Getting recent items");
PageTitle = AppResources.LabelRecent.ToLower();
query = Utils.GetRecentItemsQuery(excludedItemTypes: new[] {"Photo", "Season", "Series"});
isRecent = true;
}
else if (SelectedFolder.Name.Equals(AppResources.Favourites.ToLower()))
{
Log.Info("Getting favourite items");
PageTitle = AppResources.Favourites.ToLower();
query.Filters = new[] {ItemFilter.IsFavorite};
query.Recursive = true;
}
else if (SelectedFolder.Type.StartsWith(AppResources.Genre))
{
Log.Info("Getting items for genre [{0}]", SelectedFolder.Name);
PageTitle = SelectedFolder.Name.ToLower();
query.Genres = new[] {SelectedFolder.Name};
query.Recursive = true;
if (SelectedFolder.Type.Contains(" - " + AppResources.LabelTv.ToUpper()))
{
query.IncludeItemTypes = new[] {"Series"};
}
else if (SelectedFolder.Type.Contains(" - " + AppResources.LabelMovies.ToUpper()))
{
query.ExcludeItemTypes = new[] { "Series" };
query.IncludeItemTypes = new[] {"Movie", "Trailer"};
}
}
else
{
Log.Info("Getting items for folder [{0}]", SelectedFolder.Name);
PageTitle = SelectedFolder.Name.ToLower();
query.ParentId = SelectedFolder.Id;
}
}
var items = await ApiClient.GetItemsAsync(query);
CurrentItems = isRecent ? await Utils.SortRecentItems(items.Items, App.SpecificSettings.IncludeTrailersInRecent) : items.Items.ToList();
return true;
}
catch (HttpException ex)
{
Utils.HandleHttpException("GetItems()", ex, NavigationService, Log);
App.ShowMessage(AppResources.ErrorGettingData);
return false;
}
}