From 1ae58d90ead9ea3dae967ec18b8abd516d9444dd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 5 Nov 2013 13:20:24 -0500 Subject: [PATCH] updated mbt api --- .../DefaultTheme/DefaultThemeService.cs | 26 +++++++++++++++++-- MediaBrowser.Api/DefaultTheme/Models.cs | 3 +++ .../Movies/MovieDbPersonProvider.cs | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs b/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs index e553378d8..c0992a749 100644 --- a/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs +++ b/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs @@ -62,6 +62,12 @@ namespace MediaBrowser.Api.DefaultTheme [ApiMember(Name = "RomanceGenre", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string RomanceGenre { get; set; } + + [ApiMember(Name = "LatestMoviesLimit", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int LatestMoviesLimit { get; set; } + + [ApiMember(Name = "LatestTrailersLimit", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int LatestTrailersLimit { get; set; } } [Route("/MBT/DefaultTheme/Favorites", "GET")] @@ -481,6 +487,9 @@ namespace MediaBrowser.Api.DefaultTheme var movies = items.OfType() .ToList(); + var trailers = items.OfType() + .ToList(); + var hdMovies = movies.Where(i => i.IsHD).ToList(); var familyGenres = request.FamilyGenre.Split(',').ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); @@ -515,8 +524,7 @@ namespace MediaBrowser.Api.DefaultTheme .Take(1) .ToList(); - view.TrailerItems = items - .OfType() + view.TrailerItems = trailers .Where(i => !string.IsNullOrEmpty(i.PrimaryImagePath)) .OrderBy(i => Guid.NewGuid()) .Select(i => GetItemStub(i, ImageType.Primary)) @@ -623,6 +631,20 @@ namespace MediaBrowser.Api.DefaultTheme .Select(i => _dtoService.GetBaseItemDto(i, fields, user)) .ToList(); + view.LatestMovies = movies + .OrderByDescending(i => i.DateCreated) + .Where(i => !_userDataManager.GetUserData(user.Id, i.GetUserDataKey()).Played) + .Take(request.LatestMoviesLimit) + .Select(i => _dtoService.GetBaseItemDto(i, fields, user)) + .ToList(); + + view.LatestTrailers = trailers + .OrderByDescending(i => i.DateCreated) + .Where(i => !_userDataManager.GetUserData(user.Id, i.GetUserDataKey()).Played) + .Take(request.LatestTrailersLimit) + .Select(i => _dtoService.GetBaseItemDto(i, fields, user)) + .ToList(); + return ToOptimizedResult(view); } diff --git a/MediaBrowser.Api/DefaultTheme/Models.cs b/MediaBrowser.Api/DefaultTheme/Models.cs index 9f5546013..6dbd6b562 100644 --- a/MediaBrowser.Api/DefaultTheme/Models.cs +++ b/MediaBrowser.Api/DefaultTheme/Models.cs @@ -31,6 +31,9 @@ namespace MediaBrowser.Api.DefaultTheme public double FamilyMoviePercentage { get; set; } public double HDMoviePercentage { get; set; } + + public List LatestTrailers { get; set; } + public List LatestMovies { get; set; } } public class TvView : BaseView diff --git a/MediaBrowser.Providers/Movies/MovieDbPersonProvider.cs b/MediaBrowser.Providers/Movies/MovieDbPersonProvider.cs index 773f9bd25..e8f8c0416 100644 --- a/MediaBrowser.Providers/Movies/MovieDbPersonProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbPersonProvider.cs @@ -80,7 +80,7 @@ namespace MediaBrowser.Providers.Movies { get { - return ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataDownload; + return ItemUpdateType.MetadataDownload; } }