mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-22 16:54:46 +03:00
de-normalize item by name data. create counts during library scan for fast access.
This commit is contained in:
@@ -22,28 +22,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GetArtistsItemCounts
|
||||
/// </summary>
|
||||
[Route("/Artists/{Name}/Counts", "GET")]
|
||||
[Api(Description = "Gets item counts of library items that an artist appears in")]
|
||||
public class GetArtistsItemCounts : IReturn<ItemByNameCounts>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
/// </summary>
|
||||
/// <value>The user id.</value>
|
||||
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
[ApiMember(Name = "Name", Description = "The artist name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Artists/{Name}", "GET")]
|
||||
[Api(Description = "Gets an artist, by name")]
|
||||
public class GetArtist : IReturn<BaseItemDto>
|
||||
@@ -114,49 +92,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetArtistsItemCounts request)
|
||||
{
|
||||
var name = DeSlugArtistName(request.Name, LibraryManager);
|
||||
|
||||
var items = GetItems(request.UserId).Where(i =>
|
||||
{
|
||||
var song = i as Audio;
|
||||
|
||||
if (song != null)
|
||||
{
|
||||
return song.HasArtist(name);
|
||||
}
|
||||
|
||||
var musicVideo = i as MusicVideo;
|
||||
|
||||
if (musicVideo != null)
|
||||
{
|
||||
return musicVideo.HasArtist(name);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}).ToList();
|
||||
|
||||
var counts = new ItemByNameCounts
|
||||
{
|
||||
TotalCount = items.Count,
|
||||
|
||||
SongCount = items.OfType<Audio>().Count(),
|
||||
|
||||
AlbumCount = items.Select(i => i.Parent).OfType<MusicAlbum>().Distinct().Count(),
|
||||
|
||||
MusicVideoCount = items.OfType<MusicVideo>().Count(i => i.HasArtist(name))
|
||||
};
|
||||
|
||||
return ToOptimizedResult(counts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
@@ -193,7 +128,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
return list;
|
||||
})
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Select(name => new IbnStub<Artist>(name, () => itemsList.Where(i => i.HasArtist(name)), GetEntity));
|
||||
.Select(name => new IbnStub<Artist>(name, GetEntity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
/// </summary>
|
||||
/// <typeparam name="TItemType">The type of the T item type.</typeparam>
|
||||
public abstract class BaseItemsByNameService<TItemType> : BaseApiService
|
||||
where TItemType : BaseItem
|
||||
where TItemType : BaseItem, IItemByName
|
||||
{
|
||||
/// <summary>
|
||||
/// The _user manager
|
||||
@@ -38,6 +38,8 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
/// <param name="userManager">The user manager.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="userDataRepository">The user data repository.</param>
|
||||
/// <param name="itemRepository">The item repository.</param>
|
||||
/// <param name="dtoService">The dto service.</param>
|
||||
protected BaseItemsByNameService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepository, IDtoService dtoService)
|
||||
{
|
||||
UserManager = userManager;
|
||||
@@ -292,7 +294,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
/// <returns>Task{DtoBaseItem}.</returns>
|
||||
private async Task<BaseItemDto> GetDto(IbnStub<TItemType> stub, User user, List<ItemFields> fields)
|
||||
{
|
||||
BaseItem item;
|
||||
TItemType item;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -307,14 +309,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
var dto = user == null ? await DtoService.GetBaseItemDto(item, fields).ConfigureAwait(false) :
|
||||
await DtoService.GetBaseItemDto(item, fields, user).ConfigureAwait(false);
|
||||
|
||||
if (fields.Contains(ItemFields.ItemCounts))
|
||||
{
|
||||
var items = stub.Items;
|
||||
|
||||
dto.ChildCount = items.Count;
|
||||
dto.RecentlyAddedItemCount = items.Count(i => i.IsRecentlyAdded());
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
@@ -367,9 +361,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
public class IbnStub<T>
|
||||
where T : BaseItem
|
||||
{
|
||||
private readonly Func<IEnumerable<BaseItem>> _childItemsFunction;
|
||||
private List<BaseItem> _childItems;
|
||||
|
||||
private readonly Func<string,Task<T>> _itemFunction;
|
||||
private Task<T> _itemTask;
|
||||
|
||||
@@ -377,11 +368,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
|
||||
private UserItemData _userData;
|
||||
|
||||
public List<BaseItem> Items
|
||||
{
|
||||
get { return _childItems ?? (_childItems = _childItemsFunction().ToList()); }
|
||||
}
|
||||
|
||||
public Task<T> GetItem()
|
||||
{
|
||||
return _itemTask ?? (_itemTask = _itemFunction(Name));
|
||||
@@ -394,10 +380,9 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
return _userData ?? (_userData = repo.GetUserData(userId, item.GetUserDataKey()));
|
||||
}
|
||||
|
||||
public IbnStub(string name, Func<IEnumerable<BaseItem>> childItems, Func<string,Task<T>> item)
|
||||
public IbnStub(string name, Func<string,Task<T>> item)
|
||||
{
|
||||
Name = name;
|
||||
_childItemsFunction = childItems;
|
||||
_itemFunction = item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,25 +23,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
}
|
||||
}
|
||||
|
||||
[Route("/GameGenres/{Name}/Counts", "GET")]
|
||||
[Api(Description = "Gets item counts of library items that a genre appears in")]
|
||||
public class GetGameGenreItemCounts : IReturn<ItemByNameCounts>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
/// </summary>
|
||||
/// <value>The user id.</value>
|
||||
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public Guid? UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
[ApiMember(Name = "Name", Description = "The genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
[Route("/GameGenres/{Name}", "GET")]
|
||||
[Api(Description = "Gets a Game genre, by name")]
|
||||
public class GetGameGenre : IReturn<BaseItemDto>
|
||||
@@ -127,7 +108,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
return itemsList
|
||||
.SelectMany(i => i.Genres)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Select(name => new IbnStub<GameGenre>(name, () => itemsList.Where(i => i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase)), GetEntity));
|
||||
.Select(name => new IbnStub<GameGenre>(name, GetEntity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -139,26 +120,5 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
return LibraryManager.GetGameGenre(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetGameGenreItemCounts request)
|
||||
{
|
||||
var name = DeSlugGameGenreName(request.Name, LibraryManager);
|
||||
|
||||
var items = GetItems(request.UserId).Where(i => i.Genres != null && i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase)).ToList();
|
||||
|
||||
var counts = new ItemByNameCounts
|
||||
{
|
||||
TotalCount = items.Count,
|
||||
|
||||
GameCount = items.OfType<Game>().Count()
|
||||
};
|
||||
|
||||
return ToOptimizedResult(counts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Dto;
|
||||
@@ -23,25 +21,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
}
|
||||
|
||||
[Route("/Genres/{Name}/Counts", "GET")]
|
||||
[Api(Description = "Gets item counts of library items that a genre appears in")]
|
||||
public class GetGenreItemCounts : IReturn<ItemByNameCounts>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
/// </summary>
|
||||
/// <value>The user id.</value>
|
||||
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public Guid? UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
[ApiMember(Name = "Name", Description = "The genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GetGenre
|
||||
/// </summary>
|
||||
@@ -133,7 +112,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
return itemsList
|
||||
.SelectMany(i => i.Genres)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Select(name => new IbnStub<Genre>(name, () => itemsList.Where(i => i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase)), GetEntity));
|
||||
.Select(name => new IbnStub<Genre>(name, GetEntity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -145,34 +124,5 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
return LibraryManager.GetGenre(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetGenreItemCounts request)
|
||||
{
|
||||
var name = DeSlugGenreName(request.Name, LibraryManager);
|
||||
|
||||
var items = GetItems(request.UserId).Where(i => i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase)).ToList();
|
||||
|
||||
var counts = new ItemByNameCounts
|
||||
{
|
||||
TotalCount = items.Count,
|
||||
|
||||
TrailerCount = items.OfType<Trailer>().Count(),
|
||||
|
||||
MovieCount = items.OfType<Movie>().Count(),
|
||||
|
||||
SeriesCount = items.OfType<Series>().Count(),
|
||||
|
||||
GameCount = items.OfType<Game>().Count(),
|
||||
|
||||
AdultVideoCount = items.OfType<AdultVideo>().Count()
|
||||
};
|
||||
|
||||
return ToOptimizedResult(counts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,28 +427,9 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
|
||||
items = items.Where(i =>
|
||||
{
|
||||
var audio = i as Audio;
|
||||
var audio = i as IHasArtist;
|
||||
|
||||
if (audio != null)
|
||||
{
|
||||
return artists.Any(audio.HasArtist);
|
||||
}
|
||||
|
||||
var album = i as MusicAlbum;
|
||||
|
||||
if (album != null)
|
||||
{
|
||||
return artists.Any(album.HasArtist);
|
||||
}
|
||||
|
||||
var musicVideo = i as MusicVideo;
|
||||
|
||||
if (musicVideo != null)
|
||||
{
|
||||
return artists.Any(musicVideo.HasArtist);
|
||||
}
|
||||
|
||||
return false;
|
||||
return audio != null && artists.Any(audio.HasArtist);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -23,25 +23,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
}
|
||||
}
|
||||
|
||||
[Route("/MusicGenres/{Name}/Counts", "GET")]
|
||||
[Api(Description = "Gets item counts of library items that a genre appears in")]
|
||||
public class GetMusicGenreItemCounts : IReturn<ItemByNameCounts>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
/// </summary>
|
||||
/// <value>The user id.</value>
|
||||
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public Guid? UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
[ApiMember(Name = "Name", Description = "The genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
[Route("/MusicGenres/{Name}", "GET")]
|
||||
[Api(Description = "Gets a music genre, by name")]
|
||||
public class GetMusicGenre : IReturn<BaseItemDto>
|
||||
@@ -127,7 +108,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
return itemsList
|
||||
.SelectMany(i => i.Genres)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Select(name => new IbnStub<MusicGenre>(name, () => itemsList.Where(i => i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase)), GetEntity));
|
||||
.Select(name => new IbnStub<MusicGenre>(name, GetEntity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -139,30 +120,5 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
return LibraryManager.GetMusicGenre(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetMusicGenreItemCounts request)
|
||||
{
|
||||
var name = DeSlugGenreName(request.Name, LibraryManager);
|
||||
|
||||
var items = GetItems(request.UserId).Where(i => i.Genres != null && i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase)).ToList();
|
||||
|
||||
var counts = new ItemByNameCounts
|
||||
{
|
||||
TotalCount = items.Count,
|
||||
|
||||
SongCount = items.OfType<Audio>().Count(),
|
||||
|
||||
AlbumCount = items.OfType<MusicAlbum>().Count(),
|
||||
|
||||
MusicVideoCount = items.OfType<MusicVideo>().Count()
|
||||
};
|
||||
|
||||
return ToOptimizedResult(counts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Dto;
|
||||
@@ -29,28 +26,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
public string PersonTypes { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GetPersonItemCounts
|
||||
/// </summary>
|
||||
[Route("/Persons/{Name}/Counts", "GET")]
|
||||
[Api(Description = "Gets item counts of library items that a person appears in")]
|
||||
public class GetPersonItemCounts : IReturn<ItemByNameCounts>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
/// </summary>
|
||||
/// <value>The user id.</value>
|
||||
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
[ApiMember(Name = "Name", Description = "The person name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GetPerson
|
||||
/// </summary>
|
||||
@@ -136,43 +111,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetPersonItemCounts request)
|
||||
{
|
||||
var name = DeSlugPersonName(request.Name, LibraryManager);
|
||||
|
||||
var items = GetItems(request.UserId).Where(i => i.People != null && i.People.Any(p => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase))).ToList();
|
||||
|
||||
var counts = new ItemByNameCounts
|
||||
{
|
||||
TotalCount = items.Count,
|
||||
|
||||
TrailerCount = items.OfType<Trailer>().Count(),
|
||||
|
||||
MovieCount = items.OfType<Movie>().Count(),
|
||||
|
||||
SeriesCount = items.OfType<Series>().Count(),
|
||||
|
||||
GameCount = items.OfType<Game>().Count(),
|
||||
|
||||
SongCount = items.OfType<Audio>().Count(),
|
||||
|
||||
AlbumCount = items.OfType<MusicAlbum>().Count(),
|
||||
|
||||
EpisodeCount = items.OfType<Episode>().Count(),
|
||||
|
||||
MusicVideoCount = items.OfType<MusicVideo>().Count(),
|
||||
|
||||
AdultVideoCount = items.OfType<AdultVideo>().Count()
|
||||
};
|
||||
|
||||
return ToOptimizedResult(counts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all items.
|
||||
/// </summary>
|
||||
@@ -193,15 +131,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
.Select(i => i.Name)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
|
||||
.Select(name => new IbnStub<Person>(name, () =>
|
||||
{
|
||||
if (personTypes.Length == 0)
|
||||
{
|
||||
return itemsList.Where(i => i.People.Any(p => p.Name.Equals(name, StringComparison.OrdinalIgnoreCase)));
|
||||
}
|
||||
|
||||
return itemsList.Where(i => i.People.Any(p => p.Name.Equals(name, StringComparison.OrdinalIgnoreCase) && (personTypes.Contains(p.Type ?? string.Empty, StringComparer.OrdinalIgnoreCase) || personTypes.Contains(p.Role ?? string.Empty, StringComparer.OrdinalIgnoreCase))));
|
||||
}, GetEntity)
|
||||
.Select(name => new IbnStub<Person>(name, GetEntity)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Dto;
|
||||
@@ -24,25 +21,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
}
|
||||
|
||||
[Route("/Studios/{Name}/Counts", "GET")]
|
||||
[Api(Description = "Gets item counts of library items that a studio appears in")]
|
||||
public class GetStudioItemCounts : IReturn<ItemByNameCounts>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
/// </summary>
|
||||
/// <value>The user id.</value>
|
||||
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
[ApiMember(Name = "Name", Description = "The studio name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GetStudio
|
||||
/// </summary>
|
||||
@@ -109,41 +87,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetStudioItemCounts request)
|
||||
{
|
||||
var name = DeSlugStudioName(request.Name, LibraryManager);
|
||||
|
||||
var items = GetItems(request.UserId).Where(i => i.Studios != null && i.Studios.Contains(name, StringComparer.OrdinalIgnoreCase)).ToList();
|
||||
|
||||
var counts = new ItemByNameCounts
|
||||
{
|
||||
TotalCount = items.Count,
|
||||
|
||||
TrailerCount = items.OfType<Trailer>().Count(),
|
||||
|
||||
MovieCount = items.OfType<Movie>().Count(),
|
||||
|
||||
SeriesCount = items.OfType<Series>().Count(),
|
||||
|
||||
GameCount = items.OfType<Game>().Count(),
|
||||
|
||||
SongCount = items.OfType<Audio>().Count(),
|
||||
|
||||
AlbumCount = items.OfType<MusicAlbum>().Count(),
|
||||
|
||||
MusicVideoCount = items.OfType<MusicVideo>().Count(),
|
||||
|
||||
AdultVideoCount = items.OfType<AdultVideo>().Count()
|
||||
};
|
||||
|
||||
return ToOptimizedResult(counts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
@@ -169,7 +112,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
return itemsList
|
||||
.SelectMany(i => i.Studios)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Select(name => new IbnStub<Studio>(name, () => itemsList.Where(i => i.Studios.Contains(name, StringComparer.OrdinalIgnoreCase)), GetEntity));
|
||||
.Select(name => new IbnStub<Studio>(name, GetEntity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
return itemsList
|
||||
.Select(i => i.ProductionYear.Value)
|
||||
.Distinct()
|
||||
.Select(year => new IbnStub<Year>(year.ToString(UsCulture), () => itemsList.Where(i => i.ProductionYear.HasValue && i.ProductionYear.Value == year), GetEntity));
|
||||
.Select(year => new IbnStub<Year>(year.ToString(UsCulture), GetEntity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user