diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index 256ae3625..b188d701f 100644
--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs
@@ -53,6 +53,9 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "Studios", Description = "Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string Studios { get; set; }
+ [ApiMember(Name = "StudioIds", Description = "Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
+ public string StudioIds { get; set; }
+
///
/// Gets or sets the studios.
///
@@ -231,6 +234,11 @@ namespace MediaBrowser.Api.UserLibrary
return (Studios ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
}
+ public string[] GetStudioIds()
+ {
+ return (StudioIds ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
+ }
+
public string[] GetPersonTypes()
{
return (PersonTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
@@ -467,6 +475,7 @@ namespace MediaBrowser.Api.UserLibrary
OfficialRatings = request.GetOfficialRatings(),
Genres = request.GetGenres(),
Studios = request.GetStudios(),
+ StudioIds = request.GetStudioIds(),
Person = request.Person,
PersonTypes = request.GetPersonTypes(),
Years = request.GetYears(),
@@ -945,6 +954,17 @@ namespace MediaBrowser.Api.UserLibrary
return false;
}
+ // Apply studio filter
+ var studioIds = request.GetStudioIds();
+ if (studioIds.Length > 0 && !studioIds.Any(id =>
+ {
+ var studioItem = libraryManager.GetItemById(id);
+ return studioItem != null && i.Studios.Contains(studioItem.Name, StringComparer.OrdinalIgnoreCase);
+ }))
+ {
+ return false;
+ }
+
// Apply year filter
var years = request.GetYears();
if (years.Length > 0 && !(i.ProductionYear.HasValue && years.Contains(i.ProductionYear.Value)))
@@ -1019,14 +1039,8 @@ namespace MediaBrowser.Api.UserLibrary
if (!(audio != null && artistIds.Any(id =>
{
- try
- {
- return audio.HasAnyArtist(libraryManager.GetItemById(id).Name);
- }
- catch (Exception ex)
- {
- return false;
- }
+ var artistItem = libraryManager.GetItemById(id);
+ return artistItem != null && audio.HasAnyArtist(artistItem.Name);
})))
{
return false;
diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
index ccd499a57..e1344009f 100644
--- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
+++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
@@ -65,6 +65,7 @@ namespace MediaBrowser.Controller.Entities
public bool? HasParentalRating { get; set; }
public string[] Studios { get; set; }
+ public string[] StudioIds { get; set; }
public ImageType[] ImageTypes { get; set; }
public VideoType[] VideoTypes { get; set; }
public int[] Years { get; set; }
@@ -81,6 +82,7 @@ namespace MediaBrowser.Controller.Entities
ExcludeItemTypes = new string[] { };
Genres = new string[] { };
Studios = new string[] { };
+ StudioIds = new string[] { };
ImageTypes = new ImageType[] { };
VideoTypes = new VideoType[] { };
Years = new int[] { };
diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
index c8f9339da..121a9685d 100644
--- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs
+++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
@@ -1045,6 +1045,11 @@ namespace MediaBrowser.Controller.Entities
return false;
}
+ if (request.StudioIds.Length > 0)
+ {
+ return false;
+ }
+
if (request.VideoTypes.Length > 0)
{
return false;
@@ -1585,6 +1590,16 @@ namespace MediaBrowser.Controller.Entities
return false;
}
+ // Apply studio filter
+ if (query.StudioIds.Length > 0 && !query.StudioIds.Any(id =>
+ {
+ var studioItem = libraryManager.GetItemById(id);
+ return studioItem != null && item.Studios.Contains(studioItem.Name, StringComparer.OrdinalIgnoreCase);
+ }))
+ {
+ return false;
+ }
+
// Apply year filter
if (query.Years.Length > 0)
{
diff --git a/MediaBrowser.Model/Querying/ItemQuery.cs b/MediaBrowser.Model/Querying/ItemQuery.cs
index 1fde6d62d..6d26a2c0a 100644
--- a/MediaBrowser.Model/Querying/ItemQuery.cs
+++ b/MediaBrowser.Model/Querying/ItemQuery.cs
@@ -93,10 +93,10 @@ namespace MediaBrowser.Model.Querying
public string[] Genres { get; set; }
///
- /// Limit results to items containing specific studios
+ /// Gets or sets the studio ids.
///
- /// The studios.
- public string[] Studios { get; set; }
+ /// The studio ids.
+ public string[] StudioIds { get; set; }
///
/// Gets or sets the exclude item types.
@@ -300,7 +300,7 @@ namespace MediaBrowser.Model.Querying
VideoTypes = new VideoType[] { };
Genres = new string[] { };
- Studios = new string[] { };
+ StudioIds = new string[] { };
IncludeItemTypes = new string[] { };
ExcludeItemTypes = new string[] { };
Years = new int[] { };