added more info to user library counts
This commit is contained in:
parent
2456a66e85
commit
a3a658e820
|
@ -51,8 +51,8 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
public string RomanceGenre { get; set; }
|
public string RomanceGenre { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/MBT/DefaultTheme/Home", "GET")]
|
[Route("/MBT/DefaultTheme/Favorites", "GET")]
|
||||||
public class GetHomeView : IReturn<HomeView>
|
public class GetFavoritesView : IReturn<FavoritesView>
|
||||||
{
|
{
|
||||||
[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; }
|
||||||
|
@ -78,47 +78,103 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
_userDataManager = userDataManager;
|
_userDataManager = userDataManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetHomeView request)
|
public object Get(GetFavoritesView request)
|
||||||
{
|
|
||||||
var result = GetHomeView(request);
|
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HomeView GetHomeView(GetHomeView request)
|
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(request.UserId);
|
var user = _userManager.GetUserById(request.UserId);
|
||||||
|
|
||||||
var allItems = user.RootFolder.GetRecursiveChildren(user)
|
var allItems = user.RootFolder.GetRecursiveChildren(user, i => _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var itemsWithBackdrops = allItems.Where(i => i.BackdropImagePaths.Count > 0).ToList();
|
var itemsWithImages = allItems.Where(i => !string.IsNullOrEmpty(i.PrimaryImagePath))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
var view = new HomeView();
|
var itemsWithBackdrops = allItems.Where(i => i.BackdropImagePaths.Count > 0)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var view = new FavoritesView();
|
||||||
|
|
||||||
var fields = new List<ItemFields>();
|
var fields = new List<ItemFields>();
|
||||||
|
|
||||||
var eligibleSpotlightItems = itemsWithBackdrops
|
view.BackdropItems = FilterItemsForBackdropDisplay(itemsWithBackdrops.OrderBy(i => Guid.NewGuid()))
|
||||||
.Where(i => i is Game || i is Movie || i is Series || i is MusicArtist);
|
.Take(10)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
var dtos = FilterItemsForBackdropDisplay(eligibleSpotlightItems)
|
var spotlightItems = itemsWithBackdrops.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(10)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
view.SpotlightItems = spotlightItems
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
view.Albums = itemsWithImages
|
||||||
|
.OfType<MusicAlbum>()
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Take(50)
|
.Take(4)
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
view.SpotlightItems = dtos.ToList();
|
view.Books = itemsWithImages
|
||||||
|
.OfType<Book>()
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(6)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
return view;
|
view.Episodes = itemsWithImages
|
||||||
|
.OfType<Episode>()
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(6)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
view.Games = itemsWithImages
|
||||||
|
.OfType<Game>()
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(6)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
view.Movies = itemsWithImages
|
||||||
|
.OfType<Movie>()
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(6)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
view.Series = itemsWithImages
|
||||||
|
.OfType<Series>()
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(6)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
view.Songs = itemsWithImages
|
||||||
|
.OfType<Audio>()
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(4)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
view.Artists = itemsWithImages
|
||||||
|
.OfType<MusicArtist>()
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(4)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
view.MiniSpotlights = itemsWithBackdrops
|
||||||
|
.Except(spotlightItems)
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(5)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return ToOptimizedResult(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetGamesView request)
|
public object Get(GetGamesView request)
|
||||||
{
|
|
||||||
var result = GetGamesView(request);
|
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private GamesView GetGamesView(GetGamesView request)
|
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(request.UserId);
|
var user = _userManager.GetUserById(request.UserId);
|
||||||
|
|
||||||
|
@ -129,17 +185,23 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
|
|
||||||
var itemsWithBackdrops = FilterItemsForBackdropDisplay(items.Where(i => i.BackdropImagePaths.Count > 0)).ToList();
|
var itemsWithBackdrops = FilterItemsForBackdropDisplay(items.Where(i => i.BackdropImagePaths.Count > 0)).ToList();
|
||||||
|
|
||||||
|
var gamesWithBackdrops = itemsWithBackdrops.OfType<Game>().ToList();
|
||||||
|
|
||||||
var view = new GamesView();
|
var view = new GamesView();
|
||||||
|
|
||||||
var fields = new List<ItemFields>();
|
var fields = new List<ItemFields>();
|
||||||
|
|
||||||
var dtos = itemsWithBackdrops
|
view.BackdropItems = gamesWithBackdrops
|
||||||
.OfType<Game>()
|
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Take(50)
|
.Take(10)
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
view.SpotlightItems = dtos.ToList();
|
view.SpotlightItems = gamesWithBackdrops
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(10)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
view.MultiPlayerItems = gamesWithImages
|
view.MultiPlayerItems = gamesWithImages
|
||||||
.Where(i => i.PlayersSupported.HasValue && i.PlayersSupported.Value > 1)
|
.Where(i => i.PlayersSupported.HasValue && i.PlayersSupported.Value > 1)
|
||||||
|
@ -149,31 +211,16 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.Take(1)
|
.Take(1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
view.MiniSpotlights = itemsWithBackdrops
|
view.MiniSpotlights = gamesWithBackdrops
|
||||||
.OfType<Game>()
|
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Take(3)
|
.Take(5)
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object Get(GetMovieView request)
|
return ToOptimizedResult(view);
|
||||||
{
|
|
||||||
var result = GetMovieView(request);
|
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetTvView request)
|
public object Get(GetTvView request)
|
||||||
{
|
|
||||||
var result = GetTvView(request);
|
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TvView GetTvView(GetTvView request)
|
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(request.UserId);
|
var user = _userManager.GetUserById(request.UserId);
|
||||||
|
|
||||||
|
@ -187,13 +234,14 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
|
|
||||||
var fields = new List<ItemFields>();
|
var fields = new List<ItemFields>();
|
||||||
|
|
||||||
var dtos = FilterItemsForBackdropDisplay(seriesWithBackdrops)
|
var seriesWithBestBackdrops = FilterItemsForBackdropDisplay(seriesWithBackdrops).ToList();
|
||||||
.OrderBy(i => Guid.NewGuid())
|
|
||||||
.Take(50)
|
|
||||||
.AsParallel()
|
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
|
||||||
|
|
||||||
view.SpotlightItems = dtos.ToList();
|
view.BackdropItems = seriesWithBestBackdrops
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(10)
|
||||||
|
.AsParallel()
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
view.ShowsItems = series
|
view.ShowsItems = series
|
||||||
.Where(i => i.BackdropImagePaths.Count > 0)
|
.Where(i => i.BackdropImagePaths.Count > 0)
|
||||||
|
@ -224,16 +272,45 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
|
|
||||||
view.ActorItems = GetActors(series, user.Id);
|
view.ActorItems = GetActors(series, user.Id);
|
||||||
|
|
||||||
view.MiniSpotlights = seriesWithBackdrops
|
var spotlightSeries = seriesWithBestBackdrops
|
||||||
|
.Where(i => i.CommunityRating.HasValue && i.CommunityRating >= 8.5)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (spotlightSeries.Count < 20)
|
||||||
|
{
|
||||||
|
spotlightSeries = seriesWithBestBackdrops;
|
||||||
|
}
|
||||||
|
|
||||||
|
spotlightSeries = spotlightSeries
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(10)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
view.SpotlightItems = spotlightSeries
|
||||||
|
.AsParallel()
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var miniSpotlightItems = seriesWithBackdrops
|
||||||
|
.Except(spotlightSeries.OfType<Series>())
|
||||||
|
.Where(i => i.CommunityRating.HasValue && i.CommunityRating >= 8)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (miniSpotlightItems.Count < 15)
|
||||||
|
{
|
||||||
|
miniSpotlightItems = seriesWithBackdrops;
|
||||||
|
}
|
||||||
|
|
||||||
|
view.MiniSpotlights = miniSpotlightItems
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Take(3)
|
.Take(5)
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return view;
|
return ToOptimizedResult(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MoviesView GetMovieView(GetMovieView request)
|
public object Get(GetMovieView request)
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(request.UserId);
|
var user = _userManager.GetUserById(request.UserId);
|
||||||
|
|
||||||
|
@ -241,7 +318,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Exclude trailers from backdrops because they're not always 1080p
|
// Exclude trailers from backdrops because they're not always 1080p
|
||||||
var itemsWithBackdrops = items.Where(i => i.BackdropImagePaths.Count > 0 && !(i is Trailer))
|
var itemsWithBackdrops = items.Where(i => i.BackdropImagePaths.Count > 0)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var view = new MoviesView();
|
var view = new MoviesView();
|
||||||
|
@ -267,12 +344,14 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
|
|
||||||
var fields = new List<ItemFields>();
|
var fields = new List<ItemFields>();
|
||||||
|
|
||||||
var dtos = FilterItemsForBackdropDisplay(itemsWithBackdrops)
|
var itemsWithTopBackdrops = FilterItemsForBackdropDisplay(itemsWithBackdrops).ToList();
|
||||||
.OrderBy(i => Guid.NewGuid())
|
|
||||||
.Take(50)
|
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
|
||||||
|
|
||||||
view.SpotlightItems = dtos.ToList();
|
view.BackdropItems = itemsWithTopBackdrops
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(10)
|
||||||
|
.AsParallel()
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
view.MovieItems = moviesWithBackdrops
|
view.MovieItems = moviesWithBackdrops
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
@ -344,13 +423,52 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
|
|
||||||
view.PeopleItems = GetActors(items, user.Id);
|
view.PeopleItems = GetActors(items, user.Id);
|
||||||
|
|
||||||
view.MiniSpotlights = moviesWithBackdrops
|
var spotlightItems = itemsWithTopBackdrops
|
||||||
|
.Where(i => i.CommunityRating.HasValue && i.CommunityRating >= 8)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (spotlightItems.Count < 20)
|
||||||
|
{
|
||||||
|
spotlightItems = itemsWithTopBackdrops;
|
||||||
|
}
|
||||||
|
|
||||||
|
spotlightItems = spotlightItems
|
||||||
|
.OrderBy(i => Guid.NewGuid())
|
||||||
|
.Take(10)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
view.SpotlightItems = spotlightItems
|
||||||
|
.AsParallel()
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var miniSpotlightItems = moviesWithBackdrops
|
||||||
|
.Except(spotlightItems)
|
||||||
|
.Where(i => i.CommunityRating.HasValue && i.CommunityRating >= 7.5)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (miniSpotlightItems.Count < 15)
|
||||||
|
{
|
||||||
|
miniSpotlightItems = itemsWithTopBackdrops;
|
||||||
|
}
|
||||||
|
|
||||||
|
miniSpotlightItems = miniSpotlightItems
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.Take(3)
|
.ToList();
|
||||||
|
|
||||||
|
// Avoid implicitly captured closure
|
||||||
|
var currentUserId = user.Id;
|
||||||
|
miniSpotlightItems.InsertRange(2, moviesWithBackdrops
|
||||||
|
.Where(i => _userDataManager.GetUserData(currentUserId, i.GetUserDataKey()).PlaybackPositionTicks > 0)
|
||||||
|
.OrderByDescending(i => _userDataManager.GetUserData(currentUserId, i.GetUserDataKey()).LastPlayedDate ?? DateTime.MaxValue)
|
||||||
|
.Take(3));
|
||||||
|
|
||||||
|
view.MiniSpotlights = miniSpotlightItems
|
||||||
|
.Take(5)
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return view;
|
return ToOptimizedResult(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<BaseItem> FilterItemsForBackdropDisplay(IEnumerable<BaseItem> items)
|
private IEnumerable<BaseItem> FilterItemsForBackdropDisplay(IEnumerable<BaseItem> items)
|
||||||
|
|
|
@ -50,13 +50,20 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
|
|
||||||
public class BaseView
|
public class BaseView
|
||||||
{
|
{
|
||||||
|
public List<BaseItemDto> BackdropItems { get; set; }
|
||||||
public List<BaseItemDto> SpotlightItems { get; set; }
|
public List<BaseItemDto> SpotlightItems { get; set; }
|
||||||
|
|
||||||
public List<BaseItemDto> MiniSpotlights { get; set; }
|
public List<BaseItemDto> MiniSpotlights { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HomeView
|
public class FavoritesView : BaseView
|
||||||
{
|
{
|
||||||
public List<BaseItemDto> SpotlightItems { get; set; }
|
public List<BaseItemDto> Movies { get; set; }
|
||||||
|
public List<BaseItemDto> Series { get; set; }
|
||||||
|
public List<BaseItemDto> Episodes { get; set; }
|
||||||
|
public List<BaseItemDto> Games { get; set; }
|
||||||
|
public List<BaseItemDto> Books { get; set; }
|
||||||
|
public List<BaseItemDto> Albums { get; set; }
|
||||||
|
public List<BaseItemDto> Songs { get; set; }
|
||||||
|
public List<BaseItemDto> Artists { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,6 +204,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly IUserDataManager _userDataManager;
|
||||||
|
|
||||||
private readonly IDtoService _dtoService;
|
private readonly IDtoService _dtoService;
|
||||||
|
|
||||||
|
@ -211,12 +212,13 @@ namespace MediaBrowser.Api
|
||||||
/// Initializes a new instance of the <see cref="LibraryService" /> class.
|
/// Initializes a new instance of the <see cref="LibraryService" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager,
|
public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager,
|
||||||
IDtoService dtoService)
|
IDtoService dtoService, IUserDataManager userDataManager)
|
||||||
{
|
{
|
||||||
_itemRepo = itemRepo;
|
_itemRepo = itemRepo;
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_dtoService = dtoService;
|
_dtoService = dtoService;
|
||||||
|
_userDataManager = userDataManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetFile request)
|
public object Get(GetFile request)
|
||||||
|
@ -332,27 +334,59 @@ namespace MediaBrowser.Api
|
||||||
{
|
{
|
||||||
var items = GetAllLibraryItems(request.UserId, _userManager, _libraryManager).ToList();
|
var items = GetAllLibraryItems(request.UserId, _userManager, _libraryManager).ToList();
|
||||||
|
|
||||||
|
var albums = items.OfType<MusicAlbum>().ToList();
|
||||||
|
var episodes = items.OfType<Episode>().ToList();
|
||||||
|
var games = items.OfType<Game>().ToList();
|
||||||
|
var movies = items.OfType<Movie>().ToList();
|
||||||
|
var musicVideos = items.OfType<MusicVideo>().ToList();
|
||||||
|
var adultVideos = items.OfType<AdultVideo>().ToList();
|
||||||
|
var boxsets = items.OfType<BoxSet>().ToList();
|
||||||
|
var books = items.OfType<Book>().ToList();
|
||||||
|
var songs = items.OfType<Audio>().ToList();
|
||||||
|
var series = items.OfType<Series>().ToList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var counts = new ItemCounts
|
var counts = new ItemCounts
|
||||||
{
|
{
|
||||||
AlbumCount = items.OfType<MusicAlbum>().Count(),
|
AlbumCount = albums.Count,
|
||||||
EpisodeCount = items.OfType<Episode>().Count(),
|
EpisodeCount = episodes.Count,
|
||||||
GameCount = items.OfType<Game>().Count(),
|
GameCount = games.Count,
|
||||||
GameSystemCount = items.OfType<GameSystem>().Count(),
|
GameSystemCount = items.OfType<GameSystem>().Count(),
|
||||||
MovieCount = items.OfType<Movie>().Count(),
|
MovieCount = movies.Count,
|
||||||
SeriesCount = items.OfType<Series>().Count(),
|
SeriesCount = series.Count,
|
||||||
SongCount = items.OfType<Audio>().Count(),
|
SongCount = songs.Count,
|
||||||
TrailerCount = items.OfType<Trailer>().Count(),
|
TrailerCount = items.OfType<Trailer>().Count(),
|
||||||
MusicVideoCount = items.OfType<MusicVideo>().Count(),
|
MusicVideoCount = musicVideos.Count,
|
||||||
AdultVideoCount = items.OfType<AdultVideo>().Count(),
|
AdultVideoCount = adultVideos.Count,
|
||||||
BoxSetCount = items.OfType<BoxSet>().Count(),
|
BoxSetCount = boxsets.Count,
|
||||||
BookCount = items.OfType<Book>().Count(),
|
BookCount = books.Count,
|
||||||
|
|
||||||
UniqueTypes = items.Select(i => i.GetType().Name).Distinct().ToList()
|
UniqueTypes = items.Select(i => i.GetType().Name).Distinct().ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (request.UserId.HasValue)
|
||||||
|
{
|
||||||
|
counts.FavoriteAlbumCount = FavoriteCount(albums, request.UserId.Value);
|
||||||
|
counts.FavoriteEpisodeCount = FavoriteCount(episodes, request.UserId.Value);
|
||||||
|
counts.FavoriteGameCount = FavoriteCount(games, request.UserId.Value);
|
||||||
|
counts.FavoriteMovieCount = FavoriteCount(movies, request.UserId.Value);
|
||||||
|
counts.FavoriteMusicVideoCount = FavoriteCount(musicVideos, request.UserId.Value);
|
||||||
|
counts.FavoriteAdultVideoCount = FavoriteCount(adultVideos, request.UserId.Value);
|
||||||
|
counts.FavoriteBoxSetCount = FavoriteCount(boxsets, request.UserId.Value);
|
||||||
|
counts.FavoriteBookCount = FavoriteCount(books, request.UserId.Value);
|
||||||
|
counts.FavoriteSongCount = FavoriteCount(songs, request.UserId.Value);
|
||||||
|
counts.FavoriteSeriesCount = FavoriteCount(series, request.UserId.Value);
|
||||||
|
}
|
||||||
|
|
||||||
return ToOptimizedResult(counts);
|
return ToOptimizedResult(counts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int FavoriteCount(IEnumerable<BaseItem> items, Guid userId)
|
||||||
|
{
|
||||||
|
return items.Count(i => _userDataManager.GetUserData(userId, i.GetUserDataKey()).IsFavorite);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Posts the specified request.
|
/// Posts the specified request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -87,24 +87,6 @@ namespace MediaBrowser.Model.Configuration
|
||||||
/// <value>The metadata country code.</value>
|
/// <value>The metadata country code.</value>
|
||||||
public string MetadataCountryCode { get; set; }
|
public string MetadataCountryCode { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the size of the TMDB fetched poster.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The size of the TMDB fetched poster.</value>
|
|
||||||
public string TmdbFetchedPosterSize { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the size of the TMDB fetched profile.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The size of the TMDB fetched profile.</value>
|
|
||||||
public string TmdbFetchedProfileSize { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the size of the TMDB fetched backdrop.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The size of the TMDB fetched backdrop.</value>
|
|
||||||
public string TmdbFetchedBackdropSize { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the max backdrops.
|
/// Gets or sets the max backdrops.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -274,9 +256,6 @@ namespace MediaBrowser.Model.Configuration
|
||||||
MetadataRefreshDays = 30;
|
MetadataRefreshDays = 30;
|
||||||
PreferredMetadataLanguage = "en";
|
PreferredMetadataLanguage = "en";
|
||||||
MetadataCountryCode = "US";
|
MetadataCountryCode = "US";
|
||||||
TmdbFetchedProfileSize = "original"; //w185 w45 h632 or original
|
|
||||||
TmdbFetchedPosterSize = "original"; //w500, w342, w185 or original
|
|
||||||
TmdbFetchedBackdropSize = "original"; //w1280, w780 or original
|
|
||||||
DownloadMovieImages = new ImageDownloadOptions();
|
DownloadMovieImages = new ImageDownloadOptions();
|
||||||
DownloadSeriesImages = new ImageDownloadOptions();
|
DownloadSeriesImages = new ImageDownloadOptions();
|
||||||
DownloadSeasonImages = new ImageDownloadOptions();
|
DownloadSeasonImages = new ImageDownloadOptions();
|
||||||
|
|
|
@ -70,6 +70,56 @@ namespace MediaBrowser.Model.Dto
|
||||||
/// <value>The unique types.</value>
|
/// <value>The unique types.</value>
|
||||||
public List<string> UniqueTypes { get; set; }
|
public List<string> UniqueTypes { get; set; }
|
||||||
|
|
||||||
|
public int FavoriteAdultVideoCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the movie count.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The movie count.</value>
|
||||||
|
public int FavoriteMovieCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the series count.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The series count.</value>
|
||||||
|
public int FavoriteSeriesCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the episode count.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The episode count.</value>
|
||||||
|
public int FavoriteEpisodeCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the game count.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The game count.</value>
|
||||||
|
public int FavoriteGameCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the song count.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The song count.</value>
|
||||||
|
public int FavoriteSongCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the album count.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The album count.</value>
|
||||||
|
public int FavoriteAlbumCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the music video count.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The music video count.</value>
|
||||||
|
public int FavoriteMusicVideoCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the box set count.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The box set count.</value>
|
||||||
|
public int FavoriteBoxSetCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the book count.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The book count.</value>
|
||||||
|
public int FavoriteBookCount { get; set; }
|
||||||
|
|
||||||
|
public int FavoritePersonCount { get; set; }
|
||||||
|
public int FavoriteArtistCount { get; set; }
|
||||||
|
|
||||||
public ItemCounts()
|
public ItemCounts()
|
||||||
{
|
{
|
||||||
UniqueTypes = new List<string>();
|
UniqueTypes = new List<string>();
|
||||||
|
|
|
@ -246,8 +246,10 @@ namespace MediaBrowser.Providers
|
||||||
image = GetImage(item, args, "show");
|
image = GetImage(item, args, "show");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isFileSystemItem = item.LocationType == LocationType.FileSystem;
|
||||||
|
|
||||||
// Support plex/xbmc convention
|
// Support plex/xbmc convention
|
||||||
if (image == null && item is Season && item.IndexNumber.HasValue)
|
if (image == null && item is Season && item.IndexNumber.HasValue && isFileSystemItem)
|
||||||
{
|
{
|
||||||
var seasonMarker = item.IndexNumber.Value == 0
|
var seasonMarker = item.IndexNumber.Value == 0
|
||||||
? "-specials"
|
? "-specials"
|
||||||
|
@ -275,7 +277,7 @@ namespace MediaBrowser.Providers
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for a file with the same name as the item
|
// Look for a file with the same name as the item
|
||||||
if (image == null)
|
if (image == null && isFileSystemItem)
|
||||||
{
|
{
|
||||||
var name = Path.GetFileNameWithoutExtension(item.Path);
|
var name = Path.GetFileNameWithoutExtension(item.Path);
|
||||||
|
|
||||||
|
@ -305,7 +307,7 @@ namespace MediaBrowser.Providers
|
||||||
if (image == null)
|
if (image == null)
|
||||||
{
|
{
|
||||||
// Supprt xbmc conventions
|
// Supprt xbmc conventions
|
||||||
if (item is Season && item.IndexNumber.HasValue)
|
if (item is Season && item.IndexNumber.HasValue && item.LocationType == LocationType.FileSystem)
|
||||||
{
|
{
|
||||||
var seasonMarker = item.IndexNumber.Value == 0
|
var seasonMarker = item.IndexNumber.Value == 0
|
||||||
? "-specials"
|
? "-specials"
|
||||||
|
@ -346,7 +348,7 @@ namespace MediaBrowser.Providers
|
||||||
if (image == null)
|
if (image == null)
|
||||||
{
|
{
|
||||||
// Supprt xbmc conventions
|
// Supprt xbmc conventions
|
||||||
if (item is Season && item.IndexNumber.HasValue)
|
if (item is Season && item.IndexNumber.HasValue && item.LocationType == LocationType.FileSystem)
|
||||||
{
|
{
|
||||||
var seasonMarker = item.IndexNumber.Value == 0
|
var seasonMarker = item.IndexNumber.Value == 0
|
||||||
? "-specials"
|
? "-specials"
|
||||||
|
@ -391,7 +393,9 @@ namespace MediaBrowser.Providers
|
||||||
PopulateBackdrops(item, args, backdropFiles, "background", "background-");
|
PopulateBackdrops(item, args, backdropFiles, "background", "background-");
|
||||||
PopulateBackdrops(item, args, backdropFiles, "art", "art-");
|
PopulateBackdrops(item, args, backdropFiles, "art", "art-");
|
||||||
|
|
||||||
if (item is Season && item.IndexNumber.HasValue)
|
var isFileSystemItem = item.LocationType == LocationType.FileSystem;
|
||||||
|
|
||||||
|
if (item is Season && item.IndexNumber.HasValue && isFileSystemItem)
|
||||||
{
|
{
|
||||||
var seasonMarker = item.IndexNumber.Value == 0
|
var seasonMarker = item.IndexNumber.Value == 0
|
||||||
? "-specials"
|
? "-specials"
|
||||||
|
@ -412,7 +416,10 @@ namespace MediaBrowser.Providers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PopulateBackdropsFromExtraFanart(args, backdropFiles);
|
if (isFileSystemItem)
|
||||||
|
{
|
||||||
|
PopulateBackdropsFromExtraFanart(args, backdropFiles);
|
||||||
|
}
|
||||||
|
|
||||||
if (backdropFiles.Count > 0)
|
if (backdropFiles.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -207,7 +207,7 @@ namespace MediaBrowser.Providers.Movies
|
||||||
{
|
{
|
||||||
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
|
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedPosterSize;
|
var tmdbImageUrl = tmdbSettings.images.base_url + "original";
|
||||||
// get highest rated poster for our language
|
// get highest rated poster for our language
|
||||||
|
|
||||||
var postersSortedByVote = images.posters.OrderByDescending(i => i.vote_average);
|
var postersSortedByVote = images.posters.OrderByDescending(i => i.vote_average);
|
||||||
|
@ -250,7 +250,7 @@ namespace MediaBrowser.Providers.Movies
|
||||||
{
|
{
|
||||||
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
|
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedBackdropSize;
|
var tmdbImageUrl = tmdbSettings.images.base_url + "original";
|
||||||
|
|
||||||
for (var i = 0; i < images.backdrops.Count; i++)
|
for (var i = 0; i < images.backdrops.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,9 +73,9 @@ namespace MediaBrowser.Providers.Movies
|
||||||
|
|
||||||
progress.Report(80);
|
progress.Report(80);
|
||||||
|
|
||||||
innerProgress = new ActionableProgress<double>();
|
//innerProgress = new ActionableProgress<double>();
|
||||||
innerProgress.RegisterAction(pct => progress.Report(80 + pct * .2));
|
//innerProgress.RegisterAction(pct => progress.Report(80 + pct * .2));
|
||||||
await Run(innerProgress, true, cancellationToken).ConfigureAwait(false);
|
//await Run(innerProgress, true, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,7 +360,7 @@ namespace MediaBrowser.Providers.Movies
|
||||||
{
|
{
|
||||||
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
|
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
await DownloadAndSaveImage(person, tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedProfileSize + profile.file_path,
|
await DownloadAndSaveImage(person, tmdbSettings.images.base_url + "original" + profile.file_path,
|
||||||
MimeTypes.GetMimeType(profile.file_path), cancellationToken).ConfigureAwait(false);
|
MimeTypes.GetMimeType(profile.file_path), cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Common.Internal</id>
|
<id>MediaBrowser.Common.Internal</id>
|
||||||
<version>3.0.227</version>
|
<version>3.0.228</version>
|
||||||
<title>MediaBrowser.Common.Internal</title>
|
<title>MediaBrowser.Common.Internal</title>
|
||||||
<authors>Luke</authors>
|
<authors>Luke</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
|
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
|
||||||
<copyright>Copyright © Media Browser 2013</copyright>
|
<copyright>Copyright © Media Browser 2013</copyright>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency id="MediaBrowser.Common" version="3.0.227" />
|
<dependency id="MediaBrowser.Common" version="3.0.228" />
|
||||||
<dependency id="NLog" version="2.1.0" />
|
<dependency id="NLog" version="2.1.0" />
|
||||||
<dependency id="ServiceStack.Text" version="3.9.58" />
|
<dependency id="ServiceStack.Text" version="3.9.58" />
|
||||||
<dependency id="SimpleInjector" version="2.3.2" />
|
<dependency id="SimpleInjector" version="2.3.2" />
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Common</id>
|
<id>MediaBrowser.Common</id>
|
||||||
<version>3.0.227</version>
|
<version>3.0.228</version>
|
||||||
<title>MediaBrowser.Common</title>
|
<title>MediaBrowser.Common</title>
|
||||||
<authors>Media Browser Team</authors>
|
<authors>Media Browser Team</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Server.Core</id>
|
<id>MediaBrowser.Server.Core</id>
|
||||||
<version>3.0.227</version>
|
<version>3.0.228</version>
|
||||||
<title>Media Browser.Server.Core</title>
|
<title>Media Browser.Server.Core</title>
|
||||||
<authors>Media Browser Team</authors>
|
<authors>Media Browser Team</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
||||||
<copyright>Copyright © Media Browser 2013</copyright>
|
<copyright>Copyright © Media Browser 2013</copyright>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency id="MediaBrowser.Common" version="3.0.227" />
|
<dependency id="MediaBrowser.Common" version="3.0.228" />
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user