aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs4
-rw-r--r--MediaBrowser.Api/UserLibrary/GenresService.cs58
-rw-r--r--MediaBrowser.Api/UserLibrary/PersonsService.cs9
-rw-r--r--MediaBrowser.Api/UserLibrary/StudiosService.cs56
-rw-r--r--MediaBrowser.Model/Dto/ItemByNameCounts.cs15
5 files changed, 141 insertions, 1 deletions
diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
index 0a2d6453a..293a9019e 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 87d996d50..19c5ef86f 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
{
}
+
+ /// <summary>
+ /// Class GetGenreItemCounts
+ /// </summary>
+ [Route("/Users/{UserId}/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 = 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 genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
+ public string Name { get; set; }
+ }
/// <summary>
/// Class GenresService
@@ -34,6 +61,37 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
/// <param name="request">The request.</param>
/// <returns>System.Object.</returns>
+ 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<Trailer>().Count(),
+
+ MovieCount = items.OfType<Movie>().Count(),
+
+ SeriesCount = items.OfType<Series>().Count(),
+
+ GameCount = items.OfType<BaseGame>().Count(),
+
+ SongCount = items.OfType<AudioCodecs>().Count(),
+
+ AlbumCount = items.OfType<MusicAlbum>().Count()
+ };
+
+ return ToOptimizedResult(counts);
+ }
+
+ /// <summary>
+ /// Gets the specified request.
+ /// </summary>
+ /// <param name="request">The request.</param>
+ /// <returns>System.Object.</returns>
public object Get(GetGenres request)
{
var result = GetResult(request).Result;
diff --git a/MediaBrowser.Api/UserLibrary/PersonsService.cs b/MediaBrowser.Api/UserLibrary/PersonsService.cs
index 52e241318..93443db68 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.
/// </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; }
}
@@ -91,12 +94,18 @@ namespace MediaBrowser.Api.UserLibrary
{
TotalCount = items.Count,
+ TrailerCount = items.OfType<Trailer>().Count(),
+
MovieCount = items.OfType<Movie>().Count(),
SeriesCount = items.OfType<Series>().Count(),
GameCount = items.OfType<BaseGame>().Count(),
+ SongCount = items.OfType<AudioCodecs>().Count(),
+
+ AlbumCount = items.OfType<MusicAlbum>().Count(),
+
EpisodeGuestStarCount = items.OfType<Episode>().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 e2c1c4743..4072311d7 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<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 StudiosService
/// </summary>
@@ -34,6 +57,37 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
/// <param name="request">The request.</param>
/// <returns>System.Object.</returns>
+ 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<Trailer>().Count(),
+
+ MovieCount = items.OfType<Movie>().Count(),
+
+ SeriesCount = items.OfType<Series>().Count(),
+
+ GameCount = items.OfType<BaseGame>().Count(),
+
+ SongCount = items.OfType<AudioCodecs>().Count(),
+
+ AlbumCount = items.OfType<MusicAlbum>().Count()
+ };
+
+ return ToOptimizedResult(counts);
+ }
+
+ /// <summary>
+ /// Gets the specified request.
+ /// </summary>
+ /// <param name="request">The request.</param>
+ /// <returns>System.Object.</returns>
public object Get(GetStudios request)
{
var result = GetResult(request).Result;
diff --git a/MediaBrowser.Model/Dto/ItemByNameCounts.cs b/MediaBrowser.Model/Dto/ItemByNameCounts.cs
index 5175fa158..b650eb566 100644
--- a/MediaBrowser.Model/Dto/ItemByNameCounts.cs
+++ b/MediaBrowser.Model/Dto/ItemByNameCounts.cs
@@ -31,5 +31,20 @@ namespace MediaBrowser.Model.Dto
/// </summary>
/// <value>The game count.</value>
public int GameCount { get; set; }
+ /// <summary>
+ /// Gets or sets the trailer count.
+ /// </summary>
+ /// <value>The trailer count.</value>
+ public int TrailerCount { get; set; }
+ /// <summary>
+ /// Gets or sets the song count.
+ /// </summary>
+ /// <value>The song count.</value>
+ public int SongCount { get; set; }
+ /// <summary>
+ /// Gets or sets the album count.
+ /// </summary>
+ /// <value>The album count.</value>
+ public int AlbumCount { get; set; }
}
}