From 16203c52b4855b8474d5393ceebe1b7d85ce37fc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 22 Nov 2013 10:33:14 -0500 Subject: Added specialized episodes endpoint, updated nuget. --- MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs | 28 +---------------- MediaBrowser.Api/UserLibrary/ItemsService.cs | 39 +----------------------- 2 files changed, 2 insertions(+), 65 deletions(-) (limited to 'MediaBrowser.Api/UserLibrary') diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index eba36d8568..6aa87e499d 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -7,7 +7,7 @@ using System; namespace MediaBrowser.Api.UserLibrary { - public abstract class BaseItemsRequest + public abstract class BaseItemsRequest : IHasItemFields { /// /// Skips over a given number of items within the results. Use for paging. @@ -109,32 +109,6 @@ namespace MediaBrowser.Api.UserLibrary return val.Split(',').Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)); } - /// - /// Gets the item fields. - /// - /// IEnumerable{ItemFields}. - public IEnumerable GetItemFields() - { - var val = Fields; - - if (string.IsNullOrEmpty(val)) - { - return new ItemFields[] { }; - } - - return val.Split(',').Select(v => - { - ItemFields value; - - if (Enum.TryParse(v, true, out value)) - { - return (ItemFields?)value; - } - return null; - - }).Where(i => i.HasValue).Select(i => i.Value); - } - /// /// Gets the image types. /// diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 3936014c5c..cae74cc2f4 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -1012,7 +1012,7 @@ namespace MediaBrowser.Api.UserLibrary if (request.AiredDuringSeason.HasValue) { - items = FilterByAiredDuringSeason(items, request.AiredDuringSeason.Value); + items = TvShowsService.FilterEpisodesBySeason(items.OfType(), request.AiredDuringSeason.Value, true); } if (!string.IsNullOrEmpty(request.MinPremiereDate)) @@ -1032,43 +1032,6 @@ namespace MediaBrowser.Api.UserLibrary return items; } - private IEnumerable FilterByAiredDuringSeason(IEnumerable items, int seasonNumber) - { - var episodes = items.OfType().ToList(); - - // We can only enforce the air date requirement if the episodes have air dates - var enforceAirDate = episodes.Any(i => i.PremiereDate.HasValue); - - return episodes.Where(i => - { - var episode = i; - - if (episode != null) - { - var currentSeasonNumber = episode.AirsAfterSeasonNumber ?? episode.AirsBeforeSeasonNumber ?? episode.ParentIndexNumber; - - // If this produced nothing, try and get it from the parent folder - if (!currentSeasonNumber.HasValue) - { - var season = episode.Parent as Season; - if (season != null) - { - currentSeasonNumber = season.IndexNumber; - } - } - - if (enforceAirDate && !episode.PremiereDate.HasValue) - { - return false; - } - - return currentSeasonNumber.HasValue && currentSeasonNumber.Value == seasonNumber; - } - - return false; - }); - } - /// /// Determines whether the specified item has image. /// -- cgit v1.2.3