瀏覽代碼

switch to ExcludeArtistIds

Luke Pulverenti 9 年之前
父節點
當前提交
7475722ecf

+ 1 - 1
MediaBrowser.Api/Library/LibraryService.cs

@@ -351,7 +351,7 @@ namespace MediaBrowser.Api.Library
                     Id = request.Id,
                     Limit = request.Limit,
                     UserId = request.UserId,
-                    ExcludeArtistNames = request.ExcludeArtistNames
+                    ExcludeArtistIds = request.ExcludeArtistIds
                 });
             }
             if (item is MusicArtist)

+ 4 - 4
MediaBrowser.Api/SimilarItemsHelper.cs

@@ -26,7 +26,7 @@ namespace MediaBrowser.Api
         [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
         public string Id { get; set; }
 
-        public string ExcludeArtistNames { get; set; }
+        public string ExcludeArtistIds { get; set; }
     }
 
     public class BaseGetSimilarItems : IReturn<ItemsResult>, IHasItemFields
@@ -72,10 +72,10 @@ namespace MediaBrowser.Api
                 Recursive = true
             };
 
-            // ExcludeArtistNames
-            if (!string.IsNullOrEmpty(request.ExcludeArtistNames))
+            // ExcludeArtistIds
+            if (!string.IsNullOrEmpty(request.ExcludeArtistIds))
             {
-                query.ExcludeArtistNames = request.ExcludeArtistNames.Split('|');
+                query.ExcludeArtistIds = request.ExcludeArtistIds.Split('|');
             }
 
             var inputItems = libraryManager.GetItemList(query);

+ 1 - 1
MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs

@@ -266,7 +266,7 @@ namespace MediaBrowser.Api.UserLibrary
         [ApiMember(Name = "Artists", Description = "Optional. If specified, results will be filtered based on artist. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
         public string Artists { get; set; }
 
-        public string ExcludeArtistNames { get; set; }
+        public string ExcludeArtistIds { get; set; }
 
         [ApiMember(Name = "ArtistIds", Description = "Optional. If specified, results will be filtered based on artist. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
         public string ArtistIds { get; set; }

+ 3 - 3
MediaBrowser.Api/UserLibrary/ItemsService.cs

@@ -368,10 +368,10 @@ namespace MediaBrowser.Api.UserLibrary
                 query.ArtistNames = request.Artists.Split('|');
             }
 
-            // ExcludeArtistNames
-            if (!string.IsNullOrEmpty(request.ExcludeArtistNames))
+            // ExcludeArtistIds
+            if (!string.IsNullOrEmpty(request.ExcludeArtistIds))
             {
-                query.ExcludeArtistNames = request.ExcludeArtistNames.Split('|');
+                query.ExcludeArtistIds = request.ExcludeArtistIds.Split('|');
             }
 
             // Albums

+ 2 - 2
MediaBrowser.Controller/Entities/InternalItemsQuery.cs

@@ -138,7 +138,7 @@ namespace MediaBrowser.Controller.Entities
 
         public string[] AlbumNames { get; set; }
         public string[] ArtistNames { get; set; }
-        public string[] ExcludeArtistNames { get; set; }
+        public string[] ExcludeArtistIds { get; set; }
         public string AncestorWithPresentationUniqueKey { get; set; }
 
         public bool GroupByPresentationUniqueKey { get; set; }
@@ -154,7 +154,7 @@ namespace MediaBrowser.Controller.Entities
 
             AlbumNames = new string[] { };
             ArtistNames = new string[] { };
-            ExcludeArtistNames = new string[] { };
+            ExcludeArtistIds = new string[] { };
             ExcludeProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 
             BlockUnratedItems = new UnratedItem[] { };

+ 9 - 5
MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs

@@ -2883,15 +2883,19 @@ namespace MediaBrowser.Server.Implementations.Persistence
                 whereClauses.Add(clause);
             }
 
-            if (query.ExcludeArtistNames.Length > 0)
+            if (query.ExcludeArtistIds.Length > 0)
             {
                 var clauses = new List<string>();
                 var index = 0;
-                foreach (var artist in query.ExcludeArtistNames)
+                foreach (var artistId in query.ExcludeArtistIds)
                 {
-                    clauses.Add("@ExcludeArtistName" + index + " not in (select CleanValue from itemvalues where ItemId=Guid and Type <= 1)");
-                    cmd.Parameters.Add(cmd, "@ExcludeArtistName" + index, DbType.String).Value = artist.RemoveDiacritics();
-                    index++;
+                    var artistItem = RetrieveItem(new Guid(artistId));
+                    if (artistItem != null)
+                    {
+                        clauses.Add("@ExcludeArtistName" + index + " not in (select CleanValue from itemvalues where ItemId=Guid and Type <= 1)");
+                        cmd.Parameters.Add(cmd, "@ExcludeArtistName" + index, DbType.String).Value = artistItem.Name.RemoveDiacritics();
+                        index++;
+                    }
                 }
                 var clause = "(" + string.Join(" AND ", clauses.ToArray()) + ")";
                 whereClauses.Add(clause);