diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
index 0a2d6453af..293a9019e8 100644
--- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
+++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
@@ -1,8 +1,12 @@
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;
+using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
using ServiceStack.ServiceHost;
using System;
diff --git a/MediaBrowser.Api/UserLibrary/GenresService.cs b/MediaBrowser.Api/UserLibrary/GenresService.cs
index 87d996d504..19c5ef86fe 100644
--- a/MediaBrowser.Api/UserLibrary/GenresService.cs
+++ b/MediaBrowser.Api/UserLibrary/GenresService.cs
@@ -1,6 +1,11 @@
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;
+using MediaBrowser.Model.Entities;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
@@ -18,6 +23,28 @@ namespace MediaBrowser.Api.UserLibrary
public class GetGenres : GetItemsByName
{
}
+
+ ///
+ /// Class GetGenreItemCounts
+ ///
+ [Route("/Users/{UserId}/Genres/{Name}/Counts", "GET")]
+ [Api(Description = "Gets item counts of library items that a genre appears in")]
+ public class GetGenreItemCounts : IReturn
+ {
+ ///
+ /// Gets or sets the user id.
+ ///
+ /// The user id.
+ [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
+ public Guid UserId { get; set; }
+
+ ///
+ /// Gets or sets the name.
+ ///
+ /// The name.
+ [ApiMember(Name = "Name", Description = "The genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
+ public string Name { get; set; }
+ }
///
/// Class GenresService
@@ -29,6 +56,37 @@ namespace MediaBrowser.Api.UserLibrary
{
}
+ ///
+ /// Gets the specified request.
+ ///
+ /// The request.
+ /// System.Object.
+ public object Get(GetGenreItemCounts request)
+ {
+ var user = UserManager.GetUserById(request.UserId);
+
+ var items = user.RootFolder.GetRecursiveChildren(user).Where(i => i.Genres != null && i.Genres.Contains(request.Name, StringComparer.OrdinalIgnoreCase)).ToList();
+
+ var counts = new ItemByNameCounts
+ {
+ TotalCount = items.Count,
+
+ TrailerCount = items.OfType().Count(),
+
+ MovieCount = items.OfType().Count(),
+
+ SeriesCount = items.OfType().Count(),
+
+ GameCount = items.OfType().Count(),
+
+ SongCount = items.OfType().Count(),
+
+ AlbumCount = items.OfType().Count()
+ };
+
+ return ToOptimizedResult(counts);
+ }
+
///
/// Gets the specified request.
///
diff --git a/MediaBrowser.Api/UserLibrary/PersonsService.cs b/MediaBrowser.Api/UserLibrary/PersonsService.cs
index 52e241318b..93443db68f 100644
--- a/MediaBrowser.Api/UserLibrary/PersonsService.cs
+++ b/MediaBrowser.Api/UserLibrary/PersonsService.cs
@@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
@@ -39,12 +40,14 @@ namespace MediaBrowser.Api.UserLibrary
/// Gets or sets the user id.
///
/// The user id.
+ [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public Guid UserId { get; set; }
///
/// Gets or sets the name.
///
/// The name.
+ [ApiMember(Name = "Name", Description = "The person name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Name { get; set; }
}
@@ -91,12 +94,18 @@ namespace MediaBrowser.Api.UserLibrary
{
TotalCount = items.Count,
+ TrailerCount = items.OfType().Count(),
+
MovieCount = items.OfType().Count(),
SeriesCount = items.OfType().Count(),
GameCount = items.OfType().Count(),
+ SongCount = items.OfType().Count(),
+
+ AlbumCount = items.OfType().Count(),
+
EpisodeGuestStarCount = items.OfType().Count(i => i.People.Any(p => string.Equals(p.Name, request.Name, StringComparison.OrdinalIgnoreCase) && string.Equals(p.Type, PersonType.GuestStar)))
};
diff --git a/MediaBrowser.Api/UserLibrary/StudiosService.cs b/MediaBrowser.Api/UserLibrary/StudiosService.cs
index e2c1c4743f..4072311d76 100644
--- a/MediaBrowser.Api/UserLibrary/StudiosService.cs
+++ b/MediaBrowser.Api/UserLibrary/StudiosService.cs
@@ -1,6 +1,10 @@
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;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
@@ -18,7 +22,26 @@ namespace MediaBrowser.Api.UserLibrary
public class GetStudios : GetItemsByName
{
}
-
+
+ [Route("/Users/{UserId}/Studios/{Name}/Counts", "GET")]
+ [Api(Description = "Gets item counts of library items that a studio appears in")]
+ public class GetStudioItemCounts : IReturn
+ {
+ ///
+ /// Gets or sets the user id.
+ ///
+ /// The user id.
+ [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
+ public Guid UserId { get; set; }
+
+ ///
+ /// Gets or sets the name.
+ ///
+ /// The name.
+ [ApiMember(Name = "Name", Description = "The studio name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
+ public string Name { get; set; }
+ }
+
///
/// Class StudiosService
///
@@ -29,6 +52,37 @@ namespace MediaBrowser.Api.UserLibrary
{
}
+ ///
+ /// Gets the specified request.
+ ///
+ /// The request.
+ /// System.Object.
+ public object Get(GetStudioItemCounts request)
+ {
+ var user = UserManager.GetUserById(request.UserId);
+
+ var items = user.RootFolder.GetRecursiveChildren(user).Where(i => i.Studios != null && i.Studios.Contains(request.Name, StringComparer.OrdinalIgnoreCase)).ToList();
+
+ var counts = new ItemByNameCounts
+ {
+ TotalCount = items.Count,
+
+ TrailerCount = items.OfType().Count(),
+
+ MovieCount = items.OfType().Count(),
+
+ SeriesCount = items.OfType().Count(),
+
+ GameCount = items.OfType().Count(),
+
+ SongCount = items.OfType().Count(),
+
+ AlbumCount = items.OfType().Count()
+ };
+
+ return ToOptimizedResult(counts);
+ }
+
///
/// Gets the specified request.
///
diff --git a/MediaBrowser.Model/Dto/ItemByNameCounts.cs b/MediaBrowser.Model/Dto/ItemByNameCounts.cs
index 5175fa1588..b650eb5661 100644
--- a/MediaBrowser.Model/Dto/ItemByNameCounts.cs
+++ b/MediaBrowser.Model/Dto/ItemByNameCounts.cs
@@ -31,5 +31,20 @@ namespace MediaBrowser.Model.Dto
///
/// The game count.
public int GameCount { get; set; }
+ ///
+ /// Gets or sets the trailer count.
+ ///
+ /// The trailer count.
+ public int TrailerCount { get; set; }
+ ///
+ /// Gets or sets the song count.
+ ///
+ /// The song count.
+ public int SongCount { get; set; }
+ ///
+ /// Gets or sets the album count.
+ ///
+ /// The album count.
+ public int AlbumCount { get; set; }
}
}