aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/UserLibrary/ArtistsService.cs25
-rw-r--r--MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs2
-rw-r--r--MediaBrowser.Api/UserLibrary/ItemsService.cs39
-rw-r--r--MediaBrowser.Controller/Entities/Audio/Artist.cs6
-rw-r--r--MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs10
-rw-r--r--MediaBrowser.Controller/Providers/Music/LastfmHelper.cs8
-rw-r--r--MediaBrowser.Model/MediaBrowser.Model.csproj2
-rw-r--r--MediaBrowser.Model/Querying/ArtistsQuery.cs15
-rw-r--r--MediaBrowser.Model/Querying/ItemQuery.cs7
-rw-r--r--MediaBrowser.Model/Querying/ItemsByNameQuery.cs7
-rw-r--r--MediaBrowser.Model/Querying/PersonsQuery.cs23
11 files changed, 133 insertions, 11 deletions
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
{
+ /// <summary>
+ /// Filter by artists that are on tour, or not
+ /// </summary>
+ /// <value><c>null</c> if [is on tour] contains no value, <c>true</c> if [is on tour]; otherwise, <c>false</c>.</value>
+ public bool? IsOnTour { get; set; }
}
/// <summary>
@@ -149,6 +154,26 @@ namespace MediaBrowser.Api.UserLibrary
}
/// <summary>
+ /// Filters the items.
+ /// </summary>
+ /// <param name="request">The request.</param>
+ /// <param name="items">The items.</param>
+ /// <returns>IEnumerable{BaseItem}.</returns>
+ protected override IEnumerable<BaseItem> FilterItems(GetItemsByName request, IEnumerable<BaseItem> items)
+ {
+ items = base.FilterItems(request, items);
+
+ var getArtists = (GetArtists) request;
+
+ if (getArtists.IsOnTour.HasValue)
+ {
+ items = items.OfType<Artist>().Where(i => i.IsOnTour == getArtists.IsOnTour.Value);
+ }
+
+ return items;
+ }
+
+ /// <summary>
/// Gets all items.
/// </summary>
/// <param name="request">The request.</param>
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
/// <param name="request">The request.</param>
/// <param name="items">The items.</param>
/// <returns>IEnumerable{BaseItem}.</returns>
- private IEnumerable<BaseItem> FilterItems(GetItemsByName request, IEnumerable<BaseItem> items)
+ protected virtual IEnumerable<BaseItem> FilterItems(GetItemsByName request, IEnumerable<BaseItem> 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;
@@ -77,6 +78,13 @@ namespace MediaBrowser.Api.UserLibrary
public string Studios { get; set; }
/// <summary>
+ /// Gets or sets the studios.
+ /// </summary>
+ /// <value>The studios.</value>
+ [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; }
+
+ /// <summary>
/// Limit results to items containing specific years
/// </summary>
/// <value>The years.</value>
@@ -87,21 +95,21 @@ namespace MediaBrowser.Api.UserLibrary
/// Gets or sets the image types.
/// </summary>
/// <value>The image types.</value>
- [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; }
/// <summary>
/// Gets or sets the item ids.
/// </summary>
/// <value>The item ids.</value>
- [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; }
/// <summary>
/// Gets or sets the media types.
/// </summary>
/// <value>The media types.</value>
- [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; }
/// <summary>
@@ -379,6 +387,31 @@ namespace MediaBrowser.Api.UserLibrary
/// <returns>IEnumerable{BaseItem}.</returns>
internal static IEnumerable<BaseItem> ApplyAdditionalFilters(GetItems request, IEnumerable<BaseItem> 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;
}
+
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is on tour.
+ /// </summary>
+ /// <value><c>true</c> if this instance is on tour; otherwise, <c>false</c>.</value>
+ 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;
}
}
+
+ /// <summary>
+ /// Determines whether the specified artist has artist.
+ /// </summary>
+ /// <param name="artist">The artist.</param>
+ /// <returns><c>true</c> if the specified artist has artist; otherwise, <c>false</c>.</returns>
+ public bool HasArtist(string artist)
+ {
+ return Children.OfType<Audio>().Any(i => i.HasArtist(artist));
+ }
}
}
diff --git a/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs b/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs
index 442dd4b69..1a4cf407b 100644
--- a/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs
+++ b/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs
@@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Model.Entities;
using System;
@@ -31,6 +32,13 @@ namespace MediaBrowser.Controller.Providers.Music
{
AddGenres(artist, data.tags);
}
+
+ var entity = artist as Artist;
+
+ if (entity != null)
+ {
+ entity.IsOnTour = string.Equals(data.ontour, "1");
+ }
}
public static void ProcessAlbumData(BaseItem item, LastfmAlbum data)
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index e60fe9c2d..41aa86693 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -50,6 +50,7 @@
<Compile Include="Net\WebSocketMessage.cs" />
<Compile Include="Net\WebSocketMessageType.cs" />
<Compile Include="Net\WebSocketState.cs" />
+ <Compile Include="Querying\ArtistsQuery.cs" />
<Compile Include="Querying\ItemsByNameQuery.cs" />
<Compile Include="Entities\BaseItemInfo.cs" />
<Compile Include="Connectivity\ClientConnectionInfo.cs" />
@@ -82,6 +83,7 @@
<Compile Include="Net\HttpException.cs" />
<Compile Include="Net\NetworkShare.cs" />
<Compile Include="Net\NetworkShareType.cs" />
+ <Compile Include="Querying\PersonsQuery.cs" />
<Compile Include="Serialization\IJsonSerializer.cs" />
<Compile Include="Serialization\IXmlSerializer.cs" />
<Compile Include="Updates\CheckForUpdateResult.cs" />
diff --git a/MediaBrowser.Model/Querying/ArtistsQuery.cs b/MediaBrowser.Model/Querying/ArtistsQuery.cs
new file mode 100644
index 000000000..4d52eaf4b
--- /dev/null
+++ b/MediaBrowser.Model/Querying/ArtistsQuery.cs
@@ -0,0 +1,15 @@
+
+namespace MediaBrowser.Model.Querying
+{
+ /// <summary>
+ /// Class ArtistsQuery
+ /// </summary>
+ public class ArtistsQuery : ItemsByNameQuery
+ {
+ /// <summary>
+ /// Filter by artists that are on tour, or not
+ /// </summary>
+ /// <value><c>null</c> if [is on tour] contains no value, <c>true</c> if [is on tour]; otherwise, <c>false</c>.</value>
+ public bool? IsOnTour { get; set; }
+ }
+}
diff --git a/MediaBrowser.Model/Querying/ItemQuery.cs b/MediaBrowser.Model/Querying/ItemQuery.cs
index 80ec350a7..dfb2cad74 100644
--- a/MediaBrowser.Model/Querying/ItemQuery.cs
+++ b/MediaBrowser.Model/Querying/ItemQuery.cs
@@ -39,6 +39,12 @@ namespace MediaBrowser.Model.Querying
public string[] SortBy { get; set; }
/// <summary>
+ /// Filter by artists
+ /// </summary>
+ /// <value>The artists.</value>
+ public string[] Artists { get; set; }
+
+ /// <summary>
/// The sort order to return results with
/// </summary>
/// <value>The sort order.</value>
@@ -194,6 +200,7 @@ namespace MediaBrowser.Model.Querying
Years = new int[] { };
PersonTypes = new string[] { };
Ids = new string[] { };
+ Artists = new string[] { };
ImageTypes = new ImageType[] { };
AirDays = new DayOfWeek[] { };
diff --git a/MediaBrowser.Model/Querying/ItemsByNameQuery.cs b/MediaBrowser.Model/Querying/ItemsByNameQuery.cs
index 4569e32c0..354bc0e0f 100644
--- a/MediaBrowser.Model/Querying/ItemsByNameQuery.cs
+++ b/MediaBrowser.Model/Querying/ItemsByNameQuery.cs
@@ -42,11 +42,6 @@ namespace MediaBrowser.Model.Querying
/// </summary>
/// <value>The fields.</value>
public ItemFields[] Fields { get; set; }
- /// <summary>
- /// Gets or sets the person types.
- /// </summary>
- /// <value>The person types.</value>
- public string[] PersonTypes { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ItemsByNameQuery"/> 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
+{
+ /// <summary>
+ /// Class PersonsQuery
+ /// </summary>
+ public class PersonsQuery : ItemsByNameQuery
+ {
+ /// <summary>
+ /// Gets or sets the person types.
+ /// </summary>
+ /// <value>The person types.</value>
+ public string[] PersonTypes { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PersonsQuery"/> class.
+ /// </summary>
+ public PersonsQuery()
+ {
+ PersonTypes = new string[] { };
+ }
+ }
+}