Browse Source

added AllGenres filter

Luke Pulverenti 11 years ago
parent
commit
5d837309e4

+ 21 - 19
MediaBrowser.Api/UserLibrary/ItemsService.cs

@@ -63,6 +63,9 @@ namespace MediaBrowser.Api.UserLibrary
         [ApiMember(Name = "Genres", Description = "Optional. If specified, results will be filtered based on genre. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
         public string Genres { get; set; }
 
+        [ApiMember(Name = "AllGenres", Description = "Optional. If specified, results will be filtered based on genre. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
+        public string AllGenres { get; set; }
+
         /// <summary>
         /// Limit results to items containing specific studios
         /// </summary>
@@ -608,43 +611,42 @@ namespace MediaBrowser.Api.UserLibrary
                 items = items.Where(item => imageTypes.Any(imageType => HasImage(item, imageType)));
             }
 
-            var genres = request.Genres;
-
             // Apply genre filter
-            if (!string.IsNullOrEmpty(genres))
+            if (!string.IsNullOrEmpty(request.Genres))
             {
-                var vals = genres.Split(',');
-                items = items.Where(f => f.Genres != null && vals.Any(v => f.Genres.Contains(v, StringComparer.OrdinalIgnoreCase)));
+                var vals = request.Genres.Split(',');
+                items = items.Where(f => vals.Any(v => f.Genres.Contains(v, StringComparer.OrdinalIgnoreCase)));
             }
 
-            var studios = request.Studios;
-
+            // Apply genre filter
+            if (!string.IsNullOrEmpty(request.AllGenres))
+            {
+                var vals = request.AllGenres.Split(',');
+                items = items.Where(f => vals.All(v => f.Genres.Contains(v, StringComparer.OrdinalIgnoreCase)));
+            }
+            
             // Apply studio filter
-            if (!string.IsNullOrEmpty(studios))
+            if (!string.IsNullOrEmpty(request.Studios))
             {
-                var vals = studios.Split(',');
-                items = items.Where(f => f.Studios != null && vals.Any(v => f.Studios.Contains(v, StringComparer.OrdinalIgnoreCase)));
+                var vals = request.Studios.Split(',');
+                items = items.Where(f => vals.Any(v => f.Studios.Contains(v, StringComparer.OrdinalIgnoreCase)));
             }
 
-            var years = request.Years;
-
             // Apply year filter
-            if (!string.IsNullOrEmpty(years))
+            if (!string.IsNullOrEmpty(request.Years))
             {
-                var vals = years.Split(',').Select(int.Parse);
+                var vals = request.Years.Split(',').Select(int.Parse).ToList();
                 items = items.Where(f => f.ProductionYear.HasValue && vals.Contains(f.ProductionYear.Value));
             }
 
-            var personName = request.Person;
-
             // Apply person filter
-            if (!string.IsNullOrEmpty(personName))
+            if (!string.IsNullOrEmpty(request.Person))
             {
                 var personTypes = request.PersonTypes;
 
                 if (string.IsNullOrEmpty(personTypes))
                 {
-                    items = items.Where(item => item.People != null && item.People.Any(p => string.Equals(p.Name, personName, StringComparison.OrdinalIgnoreCase)));
+                    items = items.Where(item => item.People != null && item.People.Any(p => string.Equals(p.Name, request.Person, StringComparison.OrdinalIgnoreCase)));
                 }
                 else
                 {
@@ -653,7 +655,7 @@ namespace MediaBrowser.Api.UserLibrary
                     items = items.Where(item =>
                             item.People != null &&
                             item.People.Any(p =>
-                                p.Name.Equals(personName, StringComparison.OrdinalIgnoreCase) && (types.Contains(p.Type, StringComparer.OrdinalIgnoreCase) || types.Contains(p.Role, StringComparer.OrdinalIgnoreCase))));
+                                p.Name.Equals(request.Person, StringComparison.OrdinalIgnoreCase) && (types.Contains(p.Type, StringComparer.OrdinalIgnoreCase) || types.Contains(p.Role, StringComparer.OrdinalIgnoreCase))));
                 }
             }
 

+ 6 - 0
MediaBrowser.Model/Querying/ItemQuery.cs

@@ -92,6 +92,12 @@ namespace MediaBrowser.Model.Querying
         /// <value>The genres.</value>
         public string[] Genres { get; set; }
 
+        /// <summary>
+        /// Limit results to items containing specific genres
+        /// </summary>
+        /// <value>The genres.</value>
+        public string[] AllGenres { get; set; }
+        
         /// <summary>
         /// Limit results to items containing specific studios
         /// </summary>

+ 2 - 2
Nuget/MediaBrowser.Common.Internal.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Common.Internal</id>
-        <version>3.0.205</version>
+        <version>3.0.206</version>
         <title>MediaBrowser.Common.Internal</title>
         <authors>Luke</authors>
         <owners>ebr,Luke,scottisafool</owners>
@@ -12,7 +12,7 @@
         <description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
         <copyright>Copyright © Media Browser 2013</copyright>
         <dependencies>
-            <dependency id="MediaBrowser.Common" version="3.0.205" />
+            <dependency id="MediaBrowser.Common" version="3.0.206" />
             <dependency id="NLog" version="2.0.1.2" />
             <dependency id="ServiceStack.Text" version="3.9.58" />
             <dependency id="SimpleInjector" version="2.3.2" />

+ 1 - 1
Nuget/MediaBrowser.Common.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Common</id>
-        <version>3.0.205</version>
+        <version>3.0.206</version>
         <title>MediaBrowser.Common</title>
         <authors>Media Browser Team</authors>
         <owners>ebr,Luke,scottisafool</owners>

+ 2 - 2
Nuget/MediaBrowser.Server.Core.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Server.Core</id>
-        <version>3.0.205</version>
+        <version>3.0.206</version>
         <title>Media Browser.Server.Core</title>
         <authors>Media Browser Team</authors>
         <owners>ebr,Luke,scottisafool</owners>
@@ -12,7 +12,7 @@
         <description>Contains core components required to build plugins for Media Browser Server.</description>
         <copyright>Copyright © Media Browser 2013</copyright>
         <dependencies>
-            <dependency id="MediaBrowser.Common" version="3.0.205" />
+            <dependency id="MediaBrowser.Common" version="3.0.206" />
         </dependencies>
     </metadata>
     <files>