aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/UserLibrary/ItemsService.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-16 19:35:11 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-16 19:35:11 -0400
commitca3a0c5dc9824844a4591b4b22822bb8351169ae (patch)
treed1fbdd496729dce7ffbfa01573cd3222ed998eea /MediaBrowser.Api/UserLibrary/ItemsService.cs
parentefeaa59512508b668fe568fcab583c9ea7457e91 (diff)
fixes #592 - Add options to import missing and future episodes
Diffstat (limited to 'MediaBrowser.Api/UserLibrary/ItemsService.cs')
-rw-r--r--MediaBrowser.Api/UserLibrary/ItemsService.cs59
1 files changed, 55 insertions, 4 deletions
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index aff12569f..cb01dae73 100644
--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Controller.Dto;
+using System.Globalization;
+using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
@@ -180,6 +181,21 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "IsHD", Description = "Optional filter by items that are HD or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool? IsHD { get; set; }
+ [ApiMember(Name = "ExcludeLocationTypes", Description = "Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
+ public string ExcludeLocationTypes { get; set; }
+
+ [ApiMember(Name = "LocationTypes", Description = "Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
+ public string LocationTypes { get; set; }
+
+ [ApiMember(Name = "MinPremiereDate", Description = "Optional. The minimum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
+ public string MinPremiereDate { get; set; }
+
+ [ApiMember(Name = "MaxPremiereDate", Description = "Optional. The maximum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
+ public string MaxPremiereDate { get; set; }
+
+ [ApiMember(Name = "HasPremiereDate", Description = "Optional filter by items with premiere dates.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public bool? HasPremiereDate { get; set; }
+
public bool IncludeIndexContainers { get; set; }
}
@@ -298,7 +314,7 @@ namespace MediaBrowser.Api.UserLibrary
else if (request.Recursive)
{
- items = ((Folder) item).GetRecursiveChildren(user);
+ items = ((Folder)item).GetRecursiveChildren(user);
}
else
{
@@ -577,6 +593,20 @@ namespace MediaBrowser.Api.UserLibrary
items = items.Where(f => vals.Contains(f.GetType().Name, StringComparer.OrdinalIgnoreCase));
}
+ // ExcludeLocationTypes
+ if (!string.IsNullOrEmpty(request.ExcludeLocationTypes))
+ {
+ var vals = request.ExcludeLocationTypes.Split(',');
+ items = items.Where(f => !vals.Contains(f.LocationType.ToString(), StringComparer.OrdinalIgnoreCase));
+ }
+
+ // LocationTypes
+ if (!string.IsNullOrEmpty(request.LocationTypes))
+ {
+ var vals = request.LocationTypes.Split(',');
+ items = items.Where(f => vals.Contains(f.LocationType.ToString(), StringComparer.OrdinalIgnoreCase));
+ }
+
if (!string.IsNullOrEmpty(request.NameStartsWithOrGreater))
{
items = items.Where(i => string.Compare(request.NameStartsWithOrGreater, i.SortName, StringComparison.CurrentCultureIgnoreCase) < 1);
@@ -645,7 +675,7 @@ namespace MediaBrowser.Api.UserLibrary
var vals = request.AllGenres.Split(',');
items = items.Where(f => vals.All(v => f.Genres.Contains(v, StringComparer.OrdinalIgnoreCase)));
}
-
+
// Apply studio filter
if (!string.IsNullOrEmpty(request.Studios))
{
@@ -818,11 +848,32 @@ namespace MediaBrowser.Api.UserLibrary
{
return song.ParentIndexNumber.HasValue && song.ParentIndexNumber.Value == filterValue;
}
-
+
return true;
});
}
+ if (!string.IsNullOrEmpty(request.MinPremiereDate))
+ {
+ var date = DateTime.ParseExact(request.MinPremiereDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
+
+ items = items.Where(i => !i.PremiereDate.HasValue || i.PremiereDate.Value >= date);
+ }
+
+ if (!string.IsNullOrEmpty(request.MaxPremiereDate))
+ {
+ var date = DateTime.ParseExact(request.MaxPremiereDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
+
+ items = items.Where(i => !i.PremiereDate.HasValue || i.PremiereDate.Value <= date);
+ }
+
+ if (request.HasPremiereDate.HasValue)
+ {
+ var val = request.HasPremiereDate.Value;
+
+ items = items.Where(i => i.PremiereDate.HasValue == val);
+ }
+
return items;
}