switch to ExcludeArtistIds

This commit is contained in:
Luke Pulverenti 2016-07-22 18:10:39 -04:00
parent df5cfc0c25
commit 7475722ecf
6 changed files with 20 additions and 16 deletions

View file

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

View file

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

View file

@ -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)] [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 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)] [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; } public string ArtistIds { get; set; }

View file

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

View file

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

View file

@ -2883,15 +2883,19 @@ namespace MediaBrowser.Server.Implementations.Persistence
whereClauses.Add(clause); whereClauses.Add(clause);
} }
if (query.ExcludeArtistNames.Length > 0) if (query.ExcludeArtistIds.Length > 0)
{ {
var clauses = new List<string>(); var clauses = new List<string>();
var index = 0; 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)"); var artistItem = RetrieveItem(new Guid(artistId));
cmd.Parameters.Add(cmd, "@ExcludeArtistName" + index, DbType.String).Value = artist.RemoveDiacritics(); if (artistItem != null)
index++; {
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()) + ")"; var clause = "(" + string.Join(" AND ", clauses.ToArray()) + ")";
whereClauses.Add(clause); whereClauses.Add(clause);