Explorar o código

query for content by studio id

Luke Pulverenti %!s(int64=10) %!d(string=hai) anos
pai
achega
1735300bcf

+ 22 - 8
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; }
+        
         /// <summary>
         /// Gets or sets the studios.
         /// </summary>
@@ -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;

+ 2 - 0
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[] { };

+ 15 - 0
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)
             {

+ 4 - 4
MediaBrowser.Model/Querying/ItemQuery.cs

@@ -93,10 +93,10 @@ namespace MediaBrowser.Model.Querying
         public string[] Genres { get; set; }
 
         /// <summary>
-        /// Limit results to items containing specific studios
+        /// Gets or sets the studio ids.
         /// </summary>
-        /// <value>The studios.</value>
-        public string[] Studios { get; set; }
+        /// <value>The studio ids.</value>
+        public string[] StudioIds { get; set; }
 
         /// <summary>
         /// 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[] { };