diff --git a/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs b/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs index 21ddcd028..fef87788a 100644 --- a/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs +++ b/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs @@ -17,6 +17,13 @@ using System.Threading.Tasks; namespace MediaBrowser.Api.DefaultTheme { + [Route("/MBT/DefaultTheme/Games", "GET")] + public class GetGamesView : IReturn + { + [ApiMember(Name = "UserId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")] + public Guid UserId { get; set; } + } + [Route("/MBT/DefaultTheme/TV", "GET")] public class GetTvView : IReturn { @@ -104,6 +111,45 @@ namespace MediaBrowser.Api.DefaultTheme return view; } + public object Get(GetGamesView request) + { + var result = GetGamesView(request).Result; + + return ToOptimizedResult(result); + } + + private async Task GetGamesView(GetGamesView request) + { + var user = _userManager.GetUserById(request.UserId); + + var items = user.RootFolder.GetRecursiveChildren(user) + .Where(i => i is Game || string.Equals(i.GetType().Name, "GamePlatform", StringComparison.OrdinalIgnoreCase)) + .ToList(); + + var itemsWithBackdrops = FilterItemsForBackdropDisplay(items.Where(i => i.BackdropImagePaths.Count > 0)).ToList(); + + var view = new GamesView(); + + var fields = new List(); + + var spotlightItemTasks = itemsWithBackdrops + .OfType() + .OrderBy(i => Guid.NewGuid()) + .Take(50) + .Select(i => _dtoService.GetBaseItemDto(i, fields, user)); + + view.SpotlightItems = await Task.WhenAll(spotlightItemTasks).ConfigureAwait(false); + + return view; + } + + public object Get(GetMovieView request) + { + var result = GetMovieView(request).Result; + + return ToOptimizedResult(result); + } + public object Get(GetTvView request) { var result = GetTvView(request).Result; @@ -164,13 +210,6 @@ namespace MediaBrowser.Api.DefaultTheme return view; } - public object Get(GetMovieView request) - { - var result = GetMovieView(request).Result; - - return ToOptimizedResult(result); - } - private async Task GetMovieView(GetMovieView request) { var user = _userManager.GetUserById(request.UserId);