aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/UserLibrary/ItemsService.cs
diff options
context:
space:
mode:
authorT. Adams <t.adams88@gmail.com>2015-03-13 21:57:10 -0700
committerT. Adams <t.adams88@gmail.com>2015-03-13 21:57:10 -0700
commiteff23da3737718c944a59078c24e3ccf19435b90 (patch)
tree68d1c42e2bcd4a4be0398c8f4c0f1ba88d42e56e /MediaBrowser.Api/UserLibrary/ItemsService.cs
parentb7b28ffd31892dac13004199766262126d2785c5 (diff)
parentdbb7fd61ff0545f8ebf7b9ece432f1408d43040c (diff)
Merge branch 'dev' into Video-Playlist-Controls
Diffstat (limited to 'MediaBrowser.Api/UserLibrary/ItemsService.cs')
-rw-r--r--MediaBrowser.Api/UserLibrary/ItemsService.cs77
1 files changed, 47 insertions, 30 deletions
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index 9b5ef3a98..bdaad49e6 100644
--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs
@@ -46,9 +46,6 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "PersonTypes", Description = "Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType. Allows multiple, comma-delimited", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string PersonTypes { get; set; }
- [ApiMember(Name = "AllGenres", Description = "Optional. If specified, results will be filtered based on genre. This allows multiple, pipe 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>
@@ -56,6 +53,9 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "Studios", 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 Studios { get; set; }
+ [ApiMember(Name = "StudioIds", 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 StudioIds { get; set; }
+
/// <summary>
/// Gets or sets the studios.
/// </summary>
@@ -63,6 +63,9 @@ 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; }
+ [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; }
+
[ApiMember(Name = "Albums", Description = "Optional. If specified, results will be filtered based on album. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string Albums { get; set; }
@@ -226,14 +229,14 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "CollapseBoxSetItems", Description = "Whether or not to hide items behind their boxsets.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool? CollapseBoxSetItems { get; set; }
- public string[] GetAllGenres()
+ public string[] GetStudios()
{
- return (AllGenres ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
+ return (Studios ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
}
- public string[] GetStudios()
+ public string[] GetStudioIds()
{
- return (Studios ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
+ return (StudioIds ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
}
public string[] GetPersonTypes()
@@ -241,7 +244,7 @@ namespace MediaBrowser.Api.UserLibrary
return (PersonTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
}
- public IEnumerable<VideoType> GetVideoTypes()
+ public VideoType[] GetVideoTypes()
{
var val = VideoTypes;
@@ -250,7 +253,7 @@ namespace MediaBrowser.Api.UserLibrary
return new VideoType[] { };
}
- return val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (VideoType)Enum.Parse(typeof(VideoType), v, true));
+ return val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (VideoType)Enum.Parse(typeof(VideoType), v, true)).ToArray();
}
}
@@ -471,8 +474,8 @@ namespace MediaBrowser.Api.UserLibrary
Tags = request.GetTags(),
OfficialRatings = request.GetOfficialRatings(),
Genres = request.GetGenres(),
- AllGenres = request.GetAllGenres(),
Studios = request.GetStudios(),
+ StudioIds = request.GetStudioIds(),
Person = request.Person,
PersonTypes = request.GetPersonTypes(),
Years = request.GetYears(),
@@ -609,6 +612,8 @@ namespace MediaBrowser.Api.UserLibrary
private bool ApplyAdditionalFilters(GetItems request, BaseItem i, User user, bool isPreFiltered, ILibraryManager libraryManager)
{
+ var video = i as Video;
+
if (!isPreFiltered)
{
var mediaTypes = request.GetMediaTypes();
@@ -656,7 +661,6 @@ namespace MediaBrowser.Api.UserLibrary
if (request.Is3D.HasValue)
{
var val = request.Is3D.Value;
- var video = i as Video;
if (video == null || val != video.Video3DFormat.HasValue)
{
@@ -667,7 +671,6 @@ namespace MediaBrowser.Api.UserLibrary
if (request.IsHD.HasValue)
{
var val = request.IsHD.Value;
- var video = i as Video;
if (video == null || val != video.IsHD)
{
@@ -809,8 +812,6 @@ namespace MediaBrowser.Api.UserLibrary
{
var val = request.HasSubtitles.Value;
- var video = i as Video;
-
if (video == null || val != video.HasSubtitles)
{
return false;
@@ -930,23 +931,11 @@ namespace MediaBrowser.Api.UserLibrary
return false;
}
- // Apply genre filter
- var allGenres = request.GetAllGenres();
- if (allGenres.Length > 0 && !allGenres.All(v => i.Genres.Contains(v, StringComparer.OrdinalIgnoreCase)))
- {
- return false;
- }
-
// Filter by VideoType
- if (!string.IsNullOrEmpty(request.VideoTypes))
+ var videoTypes = request.GetVideoTypes();
+ if (videoTypes.Length > 0 && (video == null || !videoTypes.Contains(video.VideoType)))
{
- var types = request.VideoTypes.Split(',');
-
- var video = i as Video;
- if (video == null || !types.Contains(video.VideoType.ToString(), StringComparer.OrdinalIgnoreCase))
- {
- return false;
- }
+ return false;
}
var imageTypes = request.GetImageTypes().ToList();
@@ -965,6 +954,17 @@ namespace MediaBrowser.Api.UserLibrary
return false;
}
+ // Apply studio filter
+ var studioIds = request.GetStudioIds();
+ if (studioIds.Length > 0 && !studioIds.Any(id =>
+ {
+ var studioItem = libraryManager.GetItemById(id);
+ return studioItem != null && i.Studios.Contains(studioItem.Name, StringComparer.OrdinalIgnoreCase);
+ }))
+ {
+ return false;
+ }
+
// Apply year filter
var years = request.GetYears();
if (years.Length > 0 && !(i.ProductionYear.HasValue && years.Contains(i.ProductionYear.Value)))
@@ -1031,13 +1031,30 @@ namespace MediaBrowser.Api.UserLibrary
}
// Artists
+ if (!string.IsNullOrEmpty(request.ArtistIds))
+ {
+ var artistIds = request.ArtistIds.Split('|');
+
+ var audio = i as IHasArtist;
+
+ if (!(audio != null && artistIds.Any(id =>
+ {
+ var artistItem = libraryManager.GetItemById(id);
+ return artistItem != null && audio.HasAnyArtist(artistItem.Name);
+ })))
+ {
+ return false;
+ }
+ }
+
+ // Artists
if (!string.IsNullOrEmpty(request.Artists))
{
var artists = request.Artists.Split('|');
var audio = i as IHasArtist;
- if (!(audio != null && artists.Any(audio.HasArtist)))
+ if (!(audio != null && artists.Any(audio.HasAnyArtist)))
{
return false;
}