diff --git a/MediaBrowser.Api/UserLibrary/ArtistsService.cs b/MediaBrowser.Api/UserLibrary/ArtistsService.cs
index c5f7f492a..ad1007a31 100644
--- a/MediaBrowser.Api/UserLibrary/ArtistsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ArtistsService.cs
@@ -20,6 +20,11 @@ namespace MediaBrowser.Api.UserLibrary
[Api(Description = "Gets all artists from a given item, folder, or the entire library")]
public class GetArtists : GetItemsByName
{
+ ///
+ /// Filter by artists that are on tour, or not
+ ///
+ /// null if [is on tour] contains no value, true if [is on tour]; otherwise, false.
+ public bool? IsOnTour { get; set; }
}
///
@@ -148,6 +153,26 @@ namespace MediaBrowser.Api.UserLibrary
return ToOptimizedResult(result);
}
+ ///
+ /// Filters the items.
+ ///
+ /// The request.
+ /// The items.
+ /// IEnumerable{BaseItem}.
+ protected override IEnumerable FilterItems(GetItemsByName request, IEnumerable items)
+ {
+ items = base.FilterItems(request, items);
+
+ var getArtists = (GetArtists) request;
+
+ if (getArtists.IsOnTour.HasValue)
+ {
+ items = items.OfType().Where(i => i.IsOnTour == getArtists.IsOnTour.Value);
+ }
+
+ return items;
+ }
+
///
/// Gets all items.
///
diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
index 8f2264c6a..7305dfe3b 100644
--- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
+++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
@@ -204,7 +204,7 @@ namespace MediaBrowser.Api.UserLibrary
/// The request.
/// The items.
/// IEnumerable{BaseItem}.
- private IEnumerable FilterItems(GetItemsByName request, IEnumerable items)
+ protected virtual IEnumerable FilterItems(GetItemsByName request, IEnumerable items)
{
// Exclude item types
if (!string.IsNullOrEmpty(request.ExcludeItemTypes))
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index 7d3581846..d3b905746 100644
--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs
@@ -1,5 +1,6 @@
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization;
@@ -76,6 +77,13 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "Studios", Description = "Optional. If specified, results will be filtered based on studio. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string Studios { get; set; }
+ ///
+ /// Gets or sets the studios.
+ ///
+ /// The studios.
+ [ApiMember(Name = "Artists", 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 Artists { get; set; }
+
///
/// Limit results to items containing specific years
///
@@ -87,21 +95,21 @@ namespace MediaBrowser.Api.UserLibrary
/// Gets or sets the image types.
///
/// The image types.
- [ApiMember(Name = "ImageTypes", Description = "Optional. If specified, results will be filtered based on those containing image types. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
+ [ApiMember(Name = "ImageTypes", Description = "Optional. If specified, results will be filtered based on those containing image types. This allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string ImageTypes { get; set; }
///
/// Gets or sets the item ids.
///
/// The item ids.
- [ApiMember(Name = "Ids", Description = "Optional. If specific items are needed, specify a list of item id's to retrieve. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
+ [ApiMember(Name = "Ids", Description = "Optional. If specific items are needed, specify a list of item id's to retrieve. This allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string Ids { get; set; }
///
/// Gets or sets the media types.
///
/// The media types.
- [ApiMember(Name = "MediaTypes", Description = "Optional filter by MediaType. Allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
+ [ApiMember(Name = "MediaTypes", Description = "Optional filter by MediaType. Allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string MediaTypes { get; set; }
///
@@ -379,6 +387,31 @@ namespace MediaBrowser.Api.UserLibrary
/// IEnumerable{BaseItem}.
internal static IEnumerable ApplyAdditionalFilters(GetItems request, IEnumerable items)
{
+ // Artists
+ if (!string.IsNullOrEmpty(request.Artists))
+ {
+ var artists = request.Artists.Split('|');
+
+ items = items.Where(i =>
+ {
+ var audio = i as Audio;
+
+ if (audio != null)
+ {
+ return artists.Any(audio.HasArtist);
+ }
+
+ var album = i as MusicAlbum;
+
+ if (album != null)
+ {
+ return artists.Any(album.HasArtist);
+ }
+
+ return false;
+ });
+ }
+
// Min official rating
if (!string.IsNullOrEmpty(request.MinOfficalRating))
{
diff --git a/MediaBrowser.Controller/Entities/Audio/Artist.cs b/MediaBrowser.Controller/Entities/Audio/Artist.cs
index 567b67868..6052a277e 100644
--- a/MediaBrowser.Controller/Entities/Audio/Artist.cs
+++ b/MediaBrowser.Controller/Entities/Audio/Artist.cs
@@ -14,5 +14,11 @@ namespace MediaBrowser.Controller.Entities.Audio
{
return "Artist-" + Name;
}
+
+ ///
+ /// Gets or sets a value indicating whether this instance is on tour.
+ ///
+ /// true if this instance is on tour; otherwise, false.
+ public bool IsOnTour { get; set; }
}
}
diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs
index d93aec94c..859910ae6 100644
--- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs
+++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs
@@ -139,5 +139,15 @@ namespace MediaBrowser.Controller.Entities.Audio
base.Images = value;
}
}
+
+ ///
+ /// Determines whether the specified artist has artist.
+ ///
+ /// The artist.
+ /// true if the specified artist has artist; otherwise, false.
+ public bool HasArtist(string artist)
+ {
+ return Children.OfType
/// The fields.
public ItemFields[] Fields { get; set; }
- ///
- /// Gets or sets the person types.
- ///
- /// The person types.
- public string[] PersonTypes { get; set; }
///
/// Initializes a new instance of the class.
@@ -54,8 +49,6 @@ namespace MediaBrowser.Model.Querying
public ItemsByNameQuery()
{
Fields = new ItemFields[] {};
-
- PersonTypes = new string[] {};
}
}
}
diff --git a/MediaBrowser.Model/Querying/PersonsQuery.cs b/MediaBrowser.Model/Querying/PersonsQuery.cs
new file mode 100644
index 000000000..a4b7eab71
--- /dev/null
+++ b/MediaBrowser.Model/Querying/PersonsQuery.cs
@@ -0,0 +1,23 @@
+
+namespace MediaBrowser.Model.Querying
+{
+ ///
+ /// Class PersonsQuery
+ ///
+ public class PersonsQuery : ItemsByNameQuery
+ {
+ ///
+ /// Gets or sets the person types.
+ ///
+ /// The person types.
+ public string[] PersonTypes { get; set; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public PersonsQuery()
+ {
+ PersonTypes = new string[] { };
+ }
+ }
+}