updated mbt endpoints
This commit is contained in:
parent
6aa0ed7113
commit
39186cc2da
|
@ -64,16 +64,18 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
private readonly IDtoService _dtoService;
|
private readonly IDtoService _dtoService;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
private readonly IUserDataManager _userDataManager;
|
||||||
|
|
||||||
private readonly IImageProcessor _imageProcessor;
|
private readonly IImageProcessor _imageProcessor;
|
||||||
|
|
||||||
public DefaultThemeService(IUserManager userManager, IDtoService dtoService, ILogger logger, ILibraryManager libraryManager, IImageProcessor imageProcessor)
|
public DefaultThemeService(IUserManager userManager, IDtoService dtoService, ILogger logger, ILibraryManager libraryManager, IImageProcessor imageProcessor, IUserDataManager userDataManager)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_dtoService = dtoService;
|
_dtoService = dtoService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_imageProcessor = imageProcessor;
|
_imageProcessor = imageProcessor;
|
||||||
|
_userDataManager = userDataManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetHomeView request)
|
public object Get(GetHomeView request)
|
||||||
|
@ -124,6 +126,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var gamesWithImages = items.OfType<Game>().Where(i => !string.IsNullOrEmpty(i.PrimaryImagePath)).ToList();
|
var gamesWithImages = items.OfType<Game>().Where(i => !string.IsNullOrEmpty(i.PrimaryImagePath)).ToList();
|
||||||
|
|
||||||
var itemsWithBackdrops = FilterItemsForBackdropDisplay(items.Where(i => i.BackdropImagePaths.Count > 0)).ToList();
|
var itemsWithBackdrops = FilterItemsForBackdropDisplay(items.Where(i => i.BackdropImagePaths.Count > 0)).ToList();
|
||||||
|
|
||||||
var view = new GamesView();
|
var view = new GamesView();
|
||||||
|
@ -143,9 +146,16 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Select(i => GetItemStub(i, ImageType.Primary))
|
.Select(i => GetItemStub(i, ImageType.Primary))
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
view.MiniSpotlights = itemsWithBackdrops
|
||||||
|
.OfType<Game>()
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(3)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +200,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var romanceGenres = request.RomanceGenre.Split(',').ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
var romanceGenres = request.RomanceGenre.Split(',').ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
||||||
|
@ -201,7 +211,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
view.ComedyItems = seriesWithBackdrops
|
view.ComedyItems = seriesWithBackdrops
|
||||||
|
@ -209,10 +219,16 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
view.ActorItems = GetActors(series);
|
view.ActorItems = GetActors(series, user.Id);
|
||||||
|
|
||||||
|
view.MiniSpotlights = seriesWithBackdrops
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(3)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -262,7 +278,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
view.TrailerItems = items
|
view.TrailerItems = items
|
||||||
|
@ -271,7 +287,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Select(i => GetItemStub(i, ImageType.Primary))
|
.Select(i => GetItemStub(i, ImageType.Primary))
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
view.BoxSetItems = items
|
view.BoxSetItems = items
|
||||||
|
@ -280,7 +296,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
view.ThreeDItems = moviesWithBackdrops
|
view.ThreeDItems = moviesWithBackdrops
|
||||||
|
@ -288,7 +304,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var romanceGenres = request.RomanceGenre.Split(',').ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
var romanceGenres = request.RomanceGenre.Split(',').ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
||||||
|
@ -299,7 +315,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
view.ComedyItems = moviesWithBackdrops
|
view.ComedyItems = moviesWithBackdrops
|
||||||
|
@ -307,7 +323,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
view.HDItems = hdMovies
|
view.HDItems = hdMovies
|
||||||
|
@ -315,7 +331,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
view.FamilyMovies = familyMovies
|
view.FamilyMovies = familyMovies
|
||||||
|
@ -323,10 +339,16 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
.Select(i => GetItemStub(i, ImageType.Backdrop))
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
view.PeopleItems = GetActors(items);
|
view.PeopleItems = GetActors(items, user.Id);
|
||||||
|
|
||||||
|
view.MiniSpotlights = moviesWithBackdrops
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(3)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -366,7 +388,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ItemStub> GetActors(IEnumerable<BaseItem> mediaItems)
|
private List<ItemStub> GetActors(IEnumerable<BaseItem> mediaItems, Guid userId)
|
||||||
{
|
{
|
||||||
var actors = mediaItems.SelectMany(i => i.People)
|
var actors = mediaItems.SelectMany(i => i.People)
|
||||||
.Select(i => i.Name)
|
.Select(i => i.Name)
|
||||||
|
@ -374,7 +396,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return actors.Select(actor =>
|
var result = actors.Select(actor =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -382,7 +404,12 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(person.PrimaryImagePath))
|
if (!string.IsNullOrEmpty(person.PrimaryImagePath))
|
||||||
{
|
{
|
||||||
return GetItemStub(person, ImageType.Primary);
|
var userdata = _userDataManager.GetUserData(userId, person.GetUserDataKey());
|
||||||
|
|
||||||
|
if (userdata.IsFavorite || (userdata.Likes ?? false))
|
||||||
|
{
|
||||||
|
return GetItemStub(person, ImageType.Primary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -393,8 +420,35 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Take(3)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
if (result.Count == 0)
|
||||||
|
{
|
||||||
|
result = actors.Select(actor =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var person = _libraryManager.GetPerson(actor);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(person.PrimaryImagePath))
|
||||||
|
{
|
||||||
|
return GetItemStub(person, ImageType.Primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error getting person {0}", ex, actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
})
|
||||||
|
.Where(i => i != null)
|
||||||
|
.Take(1)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStub GetItemStub(BaseItem item, ImageType imageType)
|
private ItemStub GetItemStub(BaseItem item, ImageType imageType)
|
||||||
|
|
|
@ -13,9 +13,8 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
public ImageType ImageType { get; set; }
|
public ImageType ImageType { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MoviesView
|
public class MoviesView : BaseView
|
||||||
{
|
{
|
||||||
public List<BaseItemDto> SpotlightItems { get; set; }
|
|
||||||
public List<ItemStub> MovieItems { get; set; }
|
public List<ItemStub> MovieItems { get; set; }
|
||||||
public List<ItemStub> PeopleItems { get; set; }
|
public List<ItemStub> PeopleItems { get; set; }
|
||||||
|
|
||||||
|
@ -34,9 +33,8 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
public double HDMoviePercentage { get; set; }
|
public double HDMoviePercentage { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TvView
|
public class TvView : BaseView
|
||||||
{
|
{
|
||||||
public List<BaseItemDto> SpotlightItems { get; set; }
|
|
||||||
public List<ItemStub> ShowsItems { get; set; }
|
public List<ItemStub> ShowsItems { get; set; }
|
||||||
public List<ItemStub> ActorItems { get; set; }
|
public List<ItemStub> ActorItems { get; set; }
|
||||||
|
|
||||||
|
@ -44,10 +42,17 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
public List<ItemStub> ComedyItems { get; set; }
|
public List<ItemStub> ComedyItems { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GamesView
|
public class GamesView : BaseView
|
||||||
|
{
|
||||||
|
public List<ItemStub> MultiPlayerItems { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BaseView
|
||||||
{
|
{
|
||||||
public List<BaseItemDto> SpotlightItems { get; set; }
|
public List<BaseItemDto> SpotlightItems { get; set; }
|
||||||
public List<ItemStub> MultiPlayerItems { get; set; }
|
|
||||||
|
public List<BaseItemDto> MiniSpotlights { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HomeView
|
public class HomeView
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optimization to avoid running these tests against Seasons
|
// Optimization to avoid running these tests against Seasons
|
||||||
if (args.Parent is Series || args.Parent is MusicArtist || args.Parent is MusicAlbum || args.Parent is BoxSet)
|
if (args.Parent is Series || args.Parent is MusicArtist || args.Parent is MusicAlbum)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,8 +459,10 @@ namespace MediaBrowser.ServerApplication
|
||||||
{
|
{
|
||||||
ServerManager.Start(HttpServerUrlPrefix, ServerConfigurationManager.Configuration.EnableHttpLevelLogging);
|
ServerManager.Start(HttpServerUrlPrefix, ServerConfigurationManager.Configuration.EnableHttpLevelLogging);
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Logger.ErrorException("Error starting http server", ex);
|
||||||
|
|
||||||
if (retryOnFailure)
|
if (retryOnFailure)
|
||||||
{
|
{
|
||||||
RegisterServerWithAdministratorAccess();
|
RegisterServerWithAdministratorAccess();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user