|
|
@ -1,6 +1,7 @@
|
|
|
|
using MediaBrowser.Controller;
|
|
|
|
using MediaBrowser.Controller;
|
|
|
|
using MediaBrowser.Controller.Dto;
|
|
|
|
using MediaBrowser.Controller.Dto;
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
@ -21,6 +22,12 @@ namespace MediaBrowser.Api.DefaultTheme
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[ApiMember(Name = "UserId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
|
|
|
[ApiMember(Name = "UserId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ApiMember(Name = "ComedyGenre", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
|
|
|
|
|
|
|
public string ComedyGenre { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ApiMember(Name = "RomanceGenre", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
|
|
|
|
|
|
|
public string RomanceGenre { get; set; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Route("/MBT/DefaultTheme/Movies", "GET")]
|
|
|
|
[Route("/MBT/DefaultTheme/Movies", "GET")]
|
|
|
@ -31,6 +38,19 @@ namespace MediaBrowser.Api.DefaultTheme
|
|
|
|
|
|
|
|
|
|
|
|
[ApiMember(Name = "FamilyRating", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
|
|
|
[ApiMember(Name = "FamilyRating", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
|
|
|
public string FamilyRating { get; set; }
|
|
|
|
public string FamilyRating { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ApiMember(Name = "ComedyGenre", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
|
|
|
|
|
|
|
public string ComedyGenre { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ApiMember(Name = "RomanceGenre", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
|
|
|
|
|
|
|
public string RomanceGenre { get; set; }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Route("/MBT/DefaultTheme/Home", "GET")]
|
|
|
|
|
|
|
|
public class GetHomeView : IReturn<HomeView>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
[ApiMember(Name = "UserId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
|
|
|
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class DefaultThemeService : BaseApiService
|
|
|
|
public class DefaultThemeService : BaseApiService
|
|
|
@ -51,6 +71,39 @@ namespace MediaBrowser.Api.DefaultTheme
|
|
|
|
_localization = localization;
|
|
|
|
_localization = localization;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public object Get(GetHomeView request)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var result = GetHomeView(request).Result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task<HomeView> GetHomeView(GetHomeView request)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var allItems = user.RootFolder.GetRecursiveChildren(user)
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var itemsWithBackdrops = allItems.Where(i => i.BackdropImagePaths.Count > 0).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var view = new HomeView();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fields = new List<ItemFields>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var eligibleSpotlightItems = itemsWithBackdrops
|
|
|
|
|
|
|
|
.Where(i => i is Game || i is Movie || i is Series || i is MusicArtist);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var spotlightItemTasks = FilterItemsForBackdropDisplay(eligibleSpotlightItems)
|
|
|
|
|
|
|
|
.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(GetTvView request)
|
|
|
|
public object Get(GetTvView request)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var result = GetTvView(request).Result;
|
|
|
|
var result = GetTvView(request).Result;
|
|
|
@ -72,10 +125,9 @@ namespace MediaBrowser.Api.DefaultTheme
|
|
|
|
|
|
|
|
|
|
|
|
var fields = new List<ItemFields>();
|
|
|
|
var fields = new List<ItemFields>();
|
|
|
|
|
|
|
|
|
|
|
|
var spotlightItemTasks = seriesWithBackdrops
|
|
|
|
var spotlightItemTasks = FilterItemsForBackdropDisplay(seriesWithBackdrops)
|
|
|
|
.OrderByDescending(i => GetResolution(i, i.BackdropImagePaths[0]))
|
|
|
|
|
|
|
|
.Take(60)
|
|
|
|
|
|
|
|
.OrderBy(i => Guid.NewGuid())
|
|
|
|
.OrderBy(i => Guid.NewGuid())
|
|
|
|
|
|
|
|
.Take(50)
|
|
|
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
|
|
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
|
|
|
|
|
|
|
|
|
|
|
view.SpotlightItems = await Task.WhenAll(spotlightItemTasks).ConfigureAwait(false);
|
|
|
|
view.SpotlightItems = await Task.WhenAll(spotlightItemTasks).ConfigureAwait(false);
|
|
|
@ -88,6 +140,25 @@ namespace MediaBrowser.Api.DefaultTheme
|
|
|
|
.Take(3)
|
|
|
|
.Take(3)
|
|
|
|
.ToArray();
|
|
|
|
.ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var romanceGenres = request.RomanceGenre.Split(',').ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
var comedyGenres = request.ComedyGenre.Split(',').ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.RomanceItems = seriesWithBackdrops
|
|
|
|
|
|
|
|
.Where(i => i.Genres.Any(romanceGenres.ContainsKey))
|
|
|
|
|
|
|
|
.OrderBy(i => Guid.NewGuid())
|
|
|
|
|
|
|
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
|
|
|
|
|
|
|
.Where(i => i != null)
|
|
|
|
|
|
|
|
.Take(3)
|
|
|
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.ComedyItems = seriesWithBackdrops
|
|
|
|
|
|
|
|
.Where(i => i.Genres.Any(comedyGenres.ContainsKey))
|
|
|
|
|
|
|
|
.OrderBy(i => Guid.NewGuid())
|
|
|
|
|
|
|
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
|
|
|
|
|
|
|
.Where(i => i != null)
|
|
|
|
|
|
|
|
.Take(3)
|
|
|
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
view.ActorItems = await GetActors(series).ConfigureAwait(false);
|
|
|
|
view.ActorItems = await GetActors(series).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
return view;
|
|
|
|
return view;
|
|
|
@ -137,10 +208,9 @@ namespace MediaBrowser.Api.DefaultTheme
|
|
|
|
|
|
|
|
|
|
|
|
var fields = new List<ItemFields>();
|
|
|
|
var fields = new List<ItemFields>();
|
|
|
|
|
|
|
|
|
|
|
|
var spotlightItemTasks = itemsWithBackdrops
|
|
|
|
var spotlightItemTasks = FilterItemsForBackdropDisplay(itemsWithBackdrops)
|
|
|
|
.OrderByDescending(i => GetResolution(i, i.BackdropImagePaths[0]))
|
|
|
|
|
|
|
|
.Take(60)
|
|
|
|
|
|
|
|
.OrderBy(i => Guid.NewGuid())
|
|
|
|
.OrderBy(i => Guid.NewGuid())
|
|
|
|
|
|
|
|
.Take(50)
|
|
|
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
|
|
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
|
|
|
|
|
|
|
|
|
|
|
view.SpotlightItems = await Task.WhenAll(spotlightItemTasks).ConfigureAwait(false);
|
|
|
|
view.SpotlightItems = await Task.WhenAll(spotlightItemTasks).ConfigureAwait(false);
|
|
|
@ -178,9 +248,10 @@ namespace MediaBrowser.Api.DefaultTheme
|
|
|
|
.Take(3)
|
|
|
|
.Take(3)
|
|
|
|
.ToArray();
|
|
|
|
.ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
var romanceGenres = new[] { "romance" }.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
|
|
|
var romanceGenres = request.RomanceGenre.Split(',').ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
var comedyGenres = request.ComedyGenre.Split(',').ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
|
|
|
|
view.RomanticItems = moviesWithBackdrops
|
|
|
|
view.RomanceItems = moviesWithBackdrops
|
|
|
|
.Where(i => i.Genres.Any(romanceGenres.ContainsKey))
|
|
|
|
.Where(i => i.Genres.Any(romanceGenres.ContainsKey))
|
|
|
|
.OrderBy(i => Guid.NewGuid())
|
|
|
|
.OrderBy(i => Guid.NewGuid())
|
|
|
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
|
|
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
|
|
@ -188,6 +259,14 @@ namespace MediaBrowser.Api.DefaultTheme
|
|
|
|
.Take(3)
|
|
|
|
.Take(3)
|
|
|
|
.ToArray();
|
|
|
|
.ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.ComedyItems = moviesWithBackdrops
|
|
|
|
|
|
|
|
.Where(i => i.Genres.Any(comedyGenres.ContainsKey))
|
|
|
|
|
|
|
|
.OrderBy(i => Guid.NewGuid())
|
|
|
|
|
|
|
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
|
|
|
|
|
|
|
.Where(i => i != null)
|
|
|
|
|
|
|
|
.Take(3)
|
|
|
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
view.HDItems = hdMovies
|
|
|
|
view.HDItems = hdMovies
|
|
|
|
.Where(i => i.BackdropImagePaths.Count > 0)
|
|
|
|
.Where(i => i.BackdropImagePaths.Count > 0)
|
|
|
|
.OrderBy(i => Guid.NewGuid())
|
|
|
|
.OrderBy(i => Guid.NewGuid())
|
|
|
@ -209,6 +288,25 @@ namespace MediaBrowser.Api.DefaultTheme
|
|
|
|
return view;
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private IEnumerable<BaseItem> FilterItemsForBackdropDisplay(IEnumerable<BaseItem> items)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var tuples = items
|
|
|
|
|
|
|
|
.Select(i => new Tuple<BaseItem, double>(i, GetResolution(i, i.BackdropImagePaths[0])))
|
|
|
|
|
|
|
|
.Where(i => i.Item2 > 0)
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var topItems = tuples
|
|
|
|
|
|
|
|
.Where(i => i.Item2 >= 1920)
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (topItems.Count >= 10)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return topItems.Select(i => i.Item1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return tuples.Select(i => i.Item1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private double GetResolution(BaseItem item, string path)
|
|
|
|
private double GetResolution(BaseItem item, string path)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|