added optional SeasonUserData

This commit is contained in:
Luke Pulverenti 2014-12-27 00:08:39 -05:00
parent 2e53ff1fd0
commit 55b9bffabc
26 changed files with 157 additions and 192 deletions

View File

@ -28,17 +28,7 @@ namespace MediaBrowser.Api
options.ImageTypeLimit = request.ImageTypeLimit.Value; options.ImageTypeLimit = request.ImageTypeLimit.Value;
} }
if (string.IsNullOrWhiteSpace(request.EnableImageTypes)) if (!string.IsNullOrWhiteSpace(request.EnableImageTypes))
{
if (options.EnableImages)
{
// Get everything
options.ImageTypes = Enum.GetNames(typeof(ImageType))
.Select(i => (ImageType)Enum.Parse(typeof(ImageType), i, true))
.ToList();
}
}
else
{ {
options.ImageTypes = (request.EnableImageTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToList(); options.ImageTypes = (request.EnableImageTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToList();
} }

View File

@ -272,16 +272,13 @@ namespace MediaBrowser.Api.Library
items = items.Where(i => i.IsHidden == val).ToList(); items = items.Where(i => i.IsHidden == val).ToList();
} }
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var result = new ItemsResult var result = new ItemsResult
{ {
TotalRecordCount = items.Count, TotalRecordCount = items.Count,
Items = items.Select(i => _dtoService.GetBaseItemDto(i, fields)).ToArray() Items = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions)).ToArray()
}; };
return ToOptimizedResult(result); return ToOptimizedResult(result);
@ -347,10 +344,7 @@ namespace MediaBrowser.Api.Library
var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null; var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
BaseItem parent = item.Parent; BaseItem parent = item.Parent;
@ -361,7 +355,7 @@ namespace MediaBrowser.Api.Library
parent = TranslateParentItem(parent, user); parent = TranslateParentItem(parent, user);
} }
baseItemDtos.Add(_dtoService.GetBaseItemDto(parent, fields, user)); baseItemDtos.Add(_dtoService.GetBaseItemDto(parent, dtoOptions, user));
parent = parent.Parent; parent = parent.Parent;
} }
@ -583,11 +577,6 @@ namespace MediaBrowser.Api.Library
item = item.Parent; item = item.Parent;
} }
// Get everything
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var themeSongIds = GetThemeSongIds(item); var themeSongIds = GetThemeSongIds(item);
if (themeSongIds.Count == 0 && request.InheritFromParent) if (themeSongIds.Count == 0 && request.InheritFromParent)
@ -608,9 +597,11 @@ namespace MediaBrowser.Api.Library
} }
} }
var dtoOptions = new DtoOptions();
var dtos = themeSongIds.Select(_libraryManager.GetItemById) var dtos = themeSongIds.Select(_libraryManager.GetItemById)
.OrderBy(i => i.SortName) .OrderBy(i => i.SortName)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item)); .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));
var items = dtos.ToArray(); var items = dtos.ToArray();
@ -651,11 +642,6 @@ namespace MediaBrowser.Api.Library
item = item.Parent; item = item.Parent;
} }
// Get everything
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var themeVideoIds = GetThemeVideoIds(item); var themeVideoIds = GetThemeVideoIds(item);
if (themeVideoIds.Count == 0 && request.InheritFromParent) if (themeVideoIds.Count == 0 && request.InheritFromParent)
@ -681,9 +667,11 @@ namespace MediaBrowser.Api.Library
} }
} }
var dtoOptions = new DtoOptions();
var dtos = themeVideoIds.Select(_libraryManager.GetItemById) var dtos = themeVideoIds.Select(_libraryManager.GetItemById)
.OrderBy(i => i.SortName) .OrderBy(i => i.SortName)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item)); .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));
var items = dtos.ToArray(); var items = dtos.ToArray();
@ -754,10 +742,7 @@ namespace MediaBrowser.Api.Library
: (Folder)_libraryManager.RootFolder) : (Folder)_libraryManager.RootFolder)
: _libraryManager.GetItemById(id); : _libraryManager.GetItemById(id);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var dtos = GetSoundtrackSongIds(item, inheritFromParent) var dtos = GetSoundtrackSongIds(item, inheritFromParent)
.Select(_libraryManager.GetItemById) .Select(_libraryManager.GetItemById)
@ -765,7 +750,7 @@ namespace MediaBrowser.Api.Library
.SelectMany(i => i.RecursiveChildren) .SelectMany(i => i.RecursiveChildren)
.OfType<Audio>() .OfType<Audio>()
.OrderBy(i => i.SortName) .OrderBy(i => i.SortName)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item)); .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));
var items = dtos.ToArray(); var items = dtos.ToArray();

View File

@ -2,6 +2,7 @@
using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Collections; using MediaBrowser.Model.Collections;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
using ServiceStack; using ServiceStack;
using System; using System;
@ -70,7 +71,9 @@ namespace MediaBrowser.Api.Movies
}).ConfigureAwait(false); }).ConfigureAwait(false);
var dto = _dtoService.GetBaseItemDto(item, new List<ItemFields>()); var dtoOptions = new DtoOptions();
var dto = _dtoService.GetBaseItemDto(item, dtoOptions);
return ToOptimizedResult(new CollectionCreationResult return ToOptimizedResult(new CollectionCreationResult
{ {

View File

@ -157,7 +157,11 @@ namespace MediaBrowser.Api.Movies
.DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString(), StringComparer.OrdinalIgnoreCase) .DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString(), StringComparer.OrdinalIgnoreCase)
.ToList(); .ToList();
var result = GetRecommendationCategories(user, listEligibleForCategories, listEligibleForSuggestion, request.CategoryLimit, request.ItemLimit, request.GetItemFields().ToList()); var dtoOptions = new DtoOptions();
dtoOptions.Fields = request.GetItemFields().ToList();
var result = GetRecommendationCategories(user, listEligibleForCategories, listEligibleForSuggestion, request.CategoryLimit, request.ItemLimit, dtoOptions);
return ToOptimizedResult(result); return ToOptimizedResult(result);
} }
@ -232,7 +236,7 @@ namespace MediaBrowser.Api.Movies
return result; return result;
} }
private IEnumerable<RecommendationDto> GetRecommendationCategories(User user, List<BaseItem> allMoviesForCategories, List<BaseItem> allMovies, int categoryLimit, int itemLimit, List<ItemFields> fields) private IEnumerable<RecommendationDto> GetRecommendationCategories(User user, List<BaseItem> allMoviesForCategories, List<BaseItem> allMovies, int categoryLimit, int itemLimit, DtoOptions dtoOptions)
{ {
var categories = new List<RecommendationDto>(); var categories = new List<RecommendationDto>();
@ -282,11 +286,11 @@ namespace MediaBrowser.Api.Movies
.OrderBy(i => Guid.NewGuid()) .OrderBy(i => Guid.NewGuid())
.ToList(); .ToList();
var similarToRecentlyPlayed = GetSimilarTo(user, allMovies, recentlyPlayedMovies.Take(7).OrderBy(i => Guid.NewGuid()), itemLimit, fields, RecommendationType.SimilarToRecentlyPlayed).GetEnumerator(); var similarToRecentlyPlayed = GetSimilarTo(user, allMovies, recentlyPlayedMovies.Take(7).OrderBy(i => Guid.NewGuid()), itemLimit, dtoOptions, RecommendationType.SimilarToRecentlyPlayed).GetEnumerator();
var similarToLiked = GetSimilarTo(user, allMovies, likedMovies, itemLimit, fields, RecommendationType.SimilarToLikedItem).GetEnumerator(); var similarToLiked = GetSimilarTo(user, allMovies, likedMovies, itemLimit, dtoOptions, RecommendationType.SimilarToLikedItem).GetEnumerator();
var hasDirectorFromRecentlyPlayed = GetWithDirector(user, allMovies, recentDirectors, itemLimit, fields, RecommendationType.HasDirectorFromRecentlyPlayed).GetEnumerator(); var hasDirectorFromRecentlyPlayed = GetWithDirector(user, allMovies, recentDirectors, itemLimit, dtoOptions, RecommendationType.HasDirectorFromRecentlyPlayed).GetEnumerator();
var hasActorFromRecentlyPlayed = GetWithActor(user, allMovies, recentActors, itemLimit, fields, RecommendationType.HasActorFromRecentlyPlayed).GetEnumerator(); var hasActorFromRecentlyPlayed = GetWithActor(user, allMovies, recentActors, itemLimit, dtoOptions, RecommendationType.HasActorFromRecentlyPlayed).GetEnumerator();
var categoryTypes = new List<IEnumerator<RecommendationDto>> var categoryTypes = new List<IEnumerator<RecommendationDto>>
{ {
@ -329,7 +333,7 @@ namespace MediaBrowser.Api.Movies
return categories.OrderBy(i => i.RecommendationType).ThenBy(i => Guid.NewGuid()); return categories.OrderBy(i => i.RecommendationType).ThenBy(i => Guid.NewGuid());
} }
private IEnumerable<RecommendationDto> GetWithDirector(User user, List<BaseItem> allMovies, IEnumerable<string> directors, int itemLimit, List<ItemFields> fields, RecommendationType type) private IEnumerable<RecommendationDto> GetWithDirector(User user, List<BaseItem> allMovies, IEnumerable<string> directors, int itemLimit, DtoOptions dtoOptions, RecommendationType type)
{ {
var userId = user.Id; var userId = user.Id;
@ -347,13 +351,13 @@ namespace MediaBrowser.Api.Movies
BaselineItemName = director, BaselineItemName = director,
CategoryId = director.GetMD5().ToString("N"), CategoryId = director.GetMD5().ToString("N"),
RecommendationType = type, RecommendationType = type,
Items = items.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray() Items = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray()
}; };
} }
} }
} }
private IEnumerable<RecommendationDto> GetWithActor(User user, List<BaseItem> allMovies, IEnumerable<string> names, int itemLimit, List<ItemFields> fields, RecommendationType type) private IEnumerable<RecommendationDto> GetWithActor(User user, List<BaseItem> allMovies, IEnumerable<string> names, int itemLimit, DtoOptions dtoOptions, RecommendationType type)
{ {
var userId = user.Id; var userId = user.Id;
@ -371,13 +375,13 @@ namespace MediaBrowser.Api.Movies
BaselineItemName = name, BaselineItemName = name,
CategoryId = name.GetMD5().ToString("N"), CategoryId = name.GetMD5().ToString("N"),
RecommendationType = type, RecommendationType = type,
Items = items.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray() Items = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray()
}; };
} }
} }
} }
private IEnumerable<RecommendationDto> GetSimilarTo(User user, List<BaseItem> allMovies, IEnumerable<BaseItem> baselineItems, int itemLimit, List<ItemFields> fields, RecommendationType type) private IEnumerable<RecommendationDto> GetSimilarTo(User user, List<BaseItem> allMovies, IEnumerable<BaseItem> baselineItems, int itemLimit, DtoOptions dtoOptions, RecommendationType type)
{ {
var userId = user.Id; var userId = user.Id;
@ -395,7 +399,7 @@ namespace MediaBrowser.Api.Movies
BaselineItemName = item.Name, BaselineItemName = item.Name,
CategoryId = item.Id.ToString("N"), CategoryId = item.Id.ToString("N"),
RecommendationType = type, RecommendationType = type,
Items = similar.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray() Items = similar.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray()
}; };
} }
} }

View File

@ -173,16 +173,18 @@ namespace MediaBrowser.Api.Sync
} }
else else
{ {
var dtoOptions = new DtoOptions
{
Fields = new List<ItemFields>
{
ItemFields.SyncInfo
}
};
var dtos = request.ItemIds.Split(',') var dtos = request.ItemIds.Split(',')
.Select(_libraryManager.GetItemById) .Select(_libraryManager.GetItemById)
.Where(i => i != null) .Where(i => i != null)
.Select(i => _dtoService.GetBaseItemDto(i, new DtoOptions .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions))
{
Fields = new List<ItemFields>
{
ItemFields.SyncInfo
}
}))
.ToList(); .ToList();
result.Options = SyncHelper.GetSyncOptions(dtos); result.Options = SyncHelper.GetSyncOptions(dtos);

View File

@ -83,17 +83,16 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var item = GetArtist(request.Name, LibraryManager); var item = GetArtist(request.Name, LibraryManager);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
if (request.UserId.HasValue) if (request.UserId.HasValue)
{ {
var user = UserManager.GetUserById(request.UserId.Value); var user = UserManager.GetUserById(request.UserId.Value);
return DtoService.GetBaseItemDto(item, fields.ToList(), user); return DtoService.GetBaseItemDto(item, dtoOptions, user);
} }
return DtoService.GetBaseItemDto(item, fields.ToList()); return DtoService.GetBaseItemDto(item, dtoOptions);
} }
/// <summary> /// <summary>

View File

@ -69,17 +69,16 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var item = GetGameGenre(request.Name, LibraryManager); var item = GetGameGenre(request.Name, LibraryManager);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
if (request.UserId.HasValue) if (request.UserId.HasValue)
{ {
var user = UserManager.GetUserById(request.UserId.Value); var user = UserManager.GetUserById(request.UserId.Value);
return DtoService.GetBaseItemDto(item, fields.ToList(), user); return DtoService.GetBaseItemDto(item, dtoOptions, user);
} }
return DtoService.GetBaseItemDto(item, fields.ToList()); return DtoService.GetBaseItemDto(item, dtoOptions);
} }
/// <summary> /// <summary>

View File

@ -74,17 +74,16 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var item = GetGenre(request.Name, LibraryManager); var item = GetGenre(request.Name, LibraryManager);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
if (request.UserId.HasValue) if (request.UserId.HasValue)
{ {
var user = UserManager.GetUserById(request.UserId.Value); var user = UserManager.GetUserById(request.UserId.Value);
return DtoService.GetBaseItemDto(item, fields.ToList(), user); return DtoService.GetBaseItemDto(item, dtoOptions, user);
} }
return DtoService.GetBaseItemDto(item, fields.ToList()); return DtoService.GetBaseItemDto(item, dtoOptions);
} }
/// <summary> /// <summary>

View File

@ -69,17 +69,16 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var item = GetMusicGenre(request.Name, LibraryManager); var item = GetMusicGenre(request.Name, LibraryManager);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
if (request.UserId.HasValue) if (request.UserId.HasValue)
{ {
var user = UserManager.GetUserById(request.UserId.Value); var user = UserManager.GetUserById(request.UserId.Value);
return DtoService.GetBaseItemDto(item, fields.ToList(), user); return DtoService.GetBaseItemDto(item, dtoOptions, user);
} }
return DtoService.GetBaseItemDto(item, fields.ToList()); return DtoService.GetBaseItemDto(item, dtoOptions);
} }
/// <summary> /// <summary>

View File

@ -86,17 +86,16 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var item = GetPerson(request.Name, LibraryManager); var item = GetPerson(request.Name, LibraryManager);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
if (request.UserId.HasValue) if (request.UserId.HasValue)
{ {
var user = UserManager.GetUserById(request.UserId.Value); var user = UserManager.GetUserById(request.UserId.Value);
return DtoService.GetBaseItemDto(item, fields.ToList(), user); return DtoService.GetBaseItemDto(item, dtoOptions, user);
} }
return DtoService.GetBaseItemDto(item, fields.ToList()); return DtoService.GetBaseItemDto(item, dtoOptions);
} }
/// <summary> /// <summary>

View File

@ -73,17 +73,16 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var item = GetStudio(request.Name, LibraryManager); var item = GetStudio(request.Name, LibraryManager);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
if (request.UserId.HasValue) if (request.UserId.HasValue)
{ {
var user = UserManager.GetUserById(request.UserId.Value); var user = UserManager.GetUserById(request.UserId.Value);
return DtoService.GetBaseItemDto(item, fields.ToList(), user); return DtoService.GetBaseItemDto(item, dtoOptions, user);
} }
return DtoService.GetBaseItemDto(item, fields.ToList()); return DtoService.GetBaseItemDto(item, dtoOptions);
} }
/// <summary> /// <summary>

View File

@ -407,9 +407,6 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var user = _userManager.GetUserById(request.UserId); var user = _userManager.GetUserById(request.UserId);
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
var query = new UserViewQuery var query = new UserViewQuery
{ {
UserId = request.UserId UserId = request.UserId
@ -423,7 +420,9 @@ namespace MediaBrowser.Api.UserLibrary
var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false); var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false);
var dtos = folders.Select(i => _dtoService.GetBaseItemDto(i, fields, user)) var dtoOptions = new DtoOptions();
var dtos = folders.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user))
.ToArray(); .ToArray();
var result = new QueryResult<BaseItemDto> var result = new QueryResult<BaseItemDto>
@ -443,14 +442,16 @@ namespace MediaBrowser.Api.UserLibrary
user.RootFolder : user.RootFolder :
_libraryManager.GetItemById(request.Id); _libraryManager.GetItemById(request.Id);
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
var series = item as Series; var series = item as Series;
// Get them from the child tree // Get them from the child tree
if (series != null) if (series != null)
{ {
var dtoOptions = new DtoOptions();
// Avoid implicitly captured closure
var currentUser = user;
var dtos = series var dtos = series
.GetRecursiveChildren() .GetRecursiveChildren()
.Where(i => i is Episode && i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0) .Where(i => i is Episode && i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0)
@ -468,7 +469,7 @@ namespace MediaBrowser.Api.UserLibrary
return DateTime.MinValue; return DateTime.MinValue;
}) })
.ThenBy(i => i.SortName) .ThenBy(i => i.SortName)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user)); .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, currentUser));
return dtos.ToList(); return dtos.ToList();
} }
@ -478,10 +479,12 @@ namespace MediaBrowser.Api.UserLibrary
// Get them from the db // Get them from the db
if (movie != null) if (movie != null)
{ {
var dtoOptions = new DtoOptions();
var dtos = movie.SpecialFeatureIds var dtos = movie.SpecialFeatureIds
.Select(_libraryManager.GetItemById) .Select(_libraryManager.GetItemById)
.OrderBy(i => i.SortName) .OrderBy(i => i.SortName)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item)); .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));
return dtos.ToList(); return dtos.ToList();
} }
@ -507,9 +510,6 @@ namespace MediaBrowser.Api.UserLibrary
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _libraryManager.GetItemById(request.Id); var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _libraryManager.GetItemById(request.Id);
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
var trailerIds = new List<Guid>(); var trailerIds = new List<Guid>();
var hasTrailers = item as IHasTrailers; var hasTrailers = item as IHasTrailers;
@ -518,10 +518,12 @@ namespace MediaBrowser.Api.UserLibrary
trailerIds = hasTrailers.GetTrailerIds(); trailerIds = hasTrailers.GetTrailerIds();
} }
var dtoOptions = new DtoOptions();
var dtos = trailerIds var dtos = trailerIds
.Select(_libraryManager.GetItemById) .Select(_libraryManager.GetItemById)
.OrderBy(i => i.SortName) .OrderBy(i => i.SortName)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item)); .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));
return dtos.ToList(); return dtos.ToList();
} }
@ -537,10 +539,9 @@ namespace MediaBrowser.Api.UserLibrary
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _libraryManager.GetItemById(request.Id); var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _libraryManager.GetItemById(request.Id);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
var result = _dtoService.GetBaseItemDto(item, fields, user); var result = _dtoService.GetBaseItemDto(item, dtoOptions, user);
return ToOptimizedSerializedResultUsingCache(result); return ToOptimizedSerializedResultUsingCache(result);
} }
@ -556,10 +557,9 @@ namespace MediaBrowser.Api.UserLibrary
var item = user.RootFolder; var item = user.RootFolder;
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
var result = _dtoService.GetBaseItemDto(item, fields, user); var result = _dtoService.GetBaseItemDto(item, dtoOptions, user);
return ToOptimizedSerializedResultUsingCache(result); return ToOptimizedSerializedResultUsingCache(result);
} }
@ -577,12 +577,9 @@ namespace MediaBrowser.Api.UserLibrary
var items = await _libraryManager.GetIntros(item, user).ConfigureAwait(false); var items = await _libraryManager.GetIntros(item, user).ConfigureAwait(false);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var dtos = items.Select(i => _dtoService.GetBaseItemDto(i, fields, user)) var dtos = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user))
.ToArray(); .ToArray();
var result = new ItemsResult var result = new ItemsResult

View File

@ -73,17 +73,16 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var item = LibraryManager.GetYear(request.Year); var item = LibraryManager.GetYear(request.Year);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
if (request.UserId.HasValue) if (request.UserId.HasValue)
{ {
var user = UserManager.GetUserById(request.UserId.Value); var user = UserManager.GetUserById(request.UserId.Value);
return DtoService.GetBaseItemDto(item, fields.ToList(), user); return DtoService.GetBaseItemDto(item, dtoOptions, user);
} }
return DtoService.GetBaseItemDto(item, fields.ToList()); return DtoService.GetBaseItemDto(item, dtoOptions);
} }
/// <summary> /// <summary>

View File

@ -5,6 +5,7 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
using ServiceStack; using ServiceStack;
using System; using System;
@ -79,15 +80,12 @@ namespace MediaBrowser.Api
: _libraryManager.RootFolder) : _libraryManager.RootFolder)
: _libraryManager.GetItemById(request.Id); : _libraryManager.GetItemById(request.Id);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var video = (Video)item; var video = (Video)item;
var items = video.GetAdditionalParts() var items = video.GetAdditionalParts()
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, video)) .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, video))
.ToArray(); .ToArray();
var result = new ItemsResult var result = new ItemsResult

View File

@ -3,11 +3,11 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Users;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using MediaBrowser.Model.Users;
namespace MediaBrowser.Controller.Entities.TV namespace MediaBrowser.Controller.Entities.TV
{ {
@ -88,7 +88,17 @@ namespace MediaBrowser.Controller.Entities.TV
/// Gets or sets the date last episode added. /// Gets or sets the date last episode added.
/// </summary> /// </summary>
/// <value>The date last episode added.</value> /// <value>The date last episode added.</value>
public DateTime DateLastEpisodeAdded { get; set; } [IgnoreDataMember]
public DateTime DateLastEpisodeAdded
{
get
{
return RecursiveChildren.OfType<Episode>()
.Select(i => i.DateCreated)
.OrderByDescending(i => i)
.FirstOrDefault();
}
}
/// <summary> /// <summary>
/// Series aren't included directly in indices - Their Episodes will roll up to them /// Series aren't included directly in indices - Their Episodes will roll up to them

View File

@ -366,6 +366,11 @@ namespace MediaBrowser.Model.Dto
/// </summary> /// </summary>
/// <value>The user data.</value> /// <value>The user data.</value>
public UserItemDataDto UserData { get; set; } public UserItemDataDto UserData { get; set; }
/// <summary>
/// Gets or sets the season user data.
/// </summary>
/// <value>The season user data.</value>
public UserItemDataDto SeasonUserData { get; set; }
/// <summary> /// <summary>
/// Gets or sets the recursive item count. /// Gets or sets the recursive item count.

View File

@ -1,11 +1,18 @@
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Model.Dto namespace MediaBrowser.Model.Dto
{ {
public class DtoOptions public class DtoOptions
{ {
private static readonly List<ItemFields> DefaultExcludedFields = new List<ItemFields>
{
ItemFields.SeasonUserData
};
public List<ItemFields> Fields { get; set; } public List<ItemFields> Fields { get; set; }
public List<ImageType> ImageTypes { get; set; } public List<ImageType> ImageTypes { get; set; }
public int ImageTypeLimit { get; set; } public int ImageTypeLimit { get; set; }
@ -14,9 +21,17 @@ namespace MediaBrowser.Model.Dto
public DtoOptions() public DtoOptions()
{ {
Fields = new List<ItemFields>(); Fields = new List<ItemFields>();
ImageTypes = new List<ImageType>();
ImageTypeLimit = int.MaxValue; ImageTypeLimit = int.MaxValue;
EnableImages = true; EnableImages = true;
Fields = Enum.GetNames(typeof (ItemFields))
.Select(i => (ItemFields) Enum.Parse(typeof (ItemFields), i, true))
.Except(DefaultExcludedFields)
.ToList();
ImageTypes = Enum.GetNames(typeof(ImageType))
.Select(i => (ImageType)Enum.Parse(typeof(ImageType), i, true))
.ToList();
} }
public int GetImageLimit(ImageType type) public int GetImageLimit(ImageType type)

View File

@ -234,6 +234,11 @@ namespace MediaBrowser.Model.Querying
/// <summary> /// <summary>
/// The media streams /// The media streams
/// </summary> /// </summary>
MediaStreams MediaStreams,
/// <summary>
/// The season user data
/// </summary>
SeasonUserData
} }
} }

View File

@ -7,7 +7,6 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Providers.Manager; using MediaBrowser.Providers.Manager;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Providers.TV namespace MediaBrowser.Providers.TV
{ {
@ -54,29 +53,5 @@ namespace MediaBrowser.Providers.TV
target.DisplaySpecialsWithSeasons = source.DisplaySpecialsWithSeasons; target.DisplaySpecialsWithSeasons = source.DisplaySpecialsWithSeasons;
} }
} }
protected override ItemUpdateType BeforeSave(Series item)
{
var updateType = base.BeforeSave(item);
var episodes = item.RecursiveChildren
.OfType<Episode>()
.ToList();
var dateLastEpisodeAdded = item.DateLastEpisodeAdded;
item.DateLastEpisodeAdded = episodes
.Where(i => i.LocationType != LocationType.Virtual)
.Select(i => i.DateCreated)
.OrderByDescending(i => i)
.FirstOrDefault();
if (dateLastEpisodeAdded != item.DateLastEpisodeAdded)
{
updateType = updateType | ItemUpdateType.MetadataImport;
}
return updateType;
}
} }
} }

View File

@ -76,10 +76,6 @@ namespace MediaBrowser.Providers.TV
.Select(i => i.Id) .Select(i => i.Id)
.ToList(); .ToList();
series.DateLastEpisodeAdded = physicalEpisodes.Select(i => i.DateCreated)
.OrderByDescending(i => i)
.FirstOrDefault();
numComplete++; numComplete++;
double percent = numComplete; double percent = numComplete;
percent /= seriesList.Count; percent /= seriesList.Count;

View File

@ -179,12 +179,9 @@ namespace MediaBrowser.Server.Implementations.Channels
var internalResult = await GetChannelsInternal(query, cancellationToken).ConfigureAwait(false); var internalResult = await GetChannelsInternal(query, cancellationToken).ConfigureAwait(false);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var returnItems = internalResult.Items.Select(i => _dtoService.GetBaseItemDto(i, fields, user)) var returnItems = internalResult.Items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user))
.ToArray(); .ToArray();
var result = new QueryResult<BaseItemDto> var result = new QueryResult<BaseItemDto>
@ -544,11 +541,6 @@ namespace MediaBrowser.Server.Implementations.Channels
var internalResult = await GetLatestChannelItemsInternal(query, cancellationToken).ConfigureAwait(false); var internalResult = await GetLatestChannelItemsInternal(query, cancellationToken).ConfigureAwait(false);
// Get everything
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var items = internalResult.Items; var items = internalResult.Items;
var totalRecordCount = internalResult.TotalRecordCount; var totalRecordCount = internalResult.TotalRecordCount;
@ -563,7 +555,9 @@ namespace MediaBrowser.Server.Implementations.Channels
totalRecordCount = items.Length; totalRecordCount = items.Length;
} }
var returnItems = items.Select(i => _dtoService.GetBaseItemDto(i, fields, user)) var dtoOptions = new DtoOptions();
var returnItems = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user))
.ToArray(); .ToArray();
var result = new QueryResult<BaseItemDto> var result = new QueryResult<BaseItemDto>
@ -828,12 +822,9 @@ namespace MediaBrowser.Server.Implementations.Channels
await RefreshIfNeeded(internalResult.Items, new Progress<double>(), cancellationToken).ConfigureAwait(false); await RefreshIfNeeded(internalResult.Items, new Progress<double>(), cancellationToken).ConfigureAwait(false);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var returnItems = internalResult.Items.Select(i => _dtoService.GetBaseItemDto(i, fields, user)) var returnItems = internalResult.Items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user))
.ToArray(); .ToArray();
var result = new QueryResult<BaseItemDto> var result = new QueryResult<BaseItemDto>
@ -980,12 +971,9 @@ namespace MediaBrowser.Server.Implementations.Channels
var internalResult = await GetChannelItemsInternal(query, new Progress<double>(), cancellationToken).ConfigureAwait(false); var internalResult = await GetChannelItemsInternal(query, new Progress<double>(), cancellationToken).ConfigureAwait(false);
// Get everything var dtoOptions = new DtoOptions();
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var returnItems = internalResult.Items.Select(i => _dtoService.GetBaseItemDto(i, fields, user)) var returnItems = internalResult.Items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user))
.ToArray(); .ToArray();
var result = new QueryResult<BaseItemDto> var result = new QueryResult<BaseItemDto>
@ -1407,12 +1395,9 @@ namespace MediaBrowser.Server.Implementations.Channels
{ {
var user = string.IsNullOrEmpty(userId) ? null : _userManager.GetUserById(userId); var user = string.IsNullOrEmpty(userId) ? null : _userManager.GetUserById(userId);
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
var folder = await GetInternalChannelFolder(userId, cancellationToken).ConfigureAwait(false); var folder = await GetInternalChannelFolder(userId, cancellationToken).ConfigureAwait(false);
return _dtoService.GetBaseItemDto(folder, fields, user); return _dtoService.GetBaseItemDto(folder, new DtoOptions(), user);
} }
public async Task<Folder> GetInternalChannelFolder(string userId, CancellationToken cancellationToken) public async Task<Folder> GetInternalChannelFolder(string userId, CancellationToken cancellationToken)

View File

@ -74,11 +74,6 @@ namespace MediaBrowser.Server.Implementations.Dto
Fields = fields Fields = fields
}; };
// Get everything
options.ImageTypes = Enum.GetNames(typeof(ImageType))
.Select(i => (ImageType)Enum.Parse(typeof(ImageType), i, true))
.ToList();
return GetBaseItemDto(item, options, user, owner); return GetBaseItemDto(item, options, user, owner);
} }
@ -273,6 +268,21 @@ namespace MediaBrowser.Server.Implementations.Dto
} }
dto.PlayAccess = item.GetPlayAccess(user); dto.PlayAccess = item.GetPlayAccess(user);
if (fields.Contains(ItemFields.SeasonUserData))
{
var episode = item as Episode;
if (episode != null)
{
var season = episode.Season;
if (season != null)
{
dto.SeasonUserData = _userDataRepository.GetUserDataDto(season, user);
}
}
}
} }
private int GetChildCount(Folder folder, User user) private int GetChildCount(Folder folder, User user)

View File

@ -1872,12 +1872,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{ {
var user = string.IsNullOrEmpty(userId) ? null : _userManager.GetUserById(userId); var user = string.IsNullOrEmpty(userId) ? null : _userManager.GetUserById(userId);
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
var folder = await GetInternalLiveTvFolder(userId, cancellationToken).ConfigureAwait(false); var folder = await GetInternalLiveTvFolder(userId, cancellationToken).ConfigureAwait(false);
return _dtoService.GetBaseItemDto(folder, fields, user); return _dtoService.GetBaseItemDto(folder, new DtoOptions(), user);
} }
public async Task<Folder> GetInternalLiveTvFolder(string userId, CancellationToken cancellationToken) public async Task<Folder> GetInternalLiveTvFolder(string userId, CancellationToken cancellationToken)

View File

@ -597,6 +597,7 @@
"WebClientTourMobile2": "and easily controls other devices and Media Browser apps", "WebClientTourMobile2": "and easily controls other devices and Media Browser apps",
"MessageEnjoyYourStay": "Enjoy your stay", "MessageEnjoyYourStay": "Enjoy your stay",
"DashboardTourDashboard": "The server dashboard allows you to monitor your server and your users. You'll always know who is doing what and where they are.", "DashboardTourDashboard": "The server dashboard allows you to monitor your server and your users. You'll always know who is doing what and where they are.",
"DashboardTourHelp": "In-app help provides easy buttons to open wiki pages relating to the on-screen content.",
"DashboardTourUsers": "Easily create user accounts for your friends and family, each with their own permissions, library access, parental controls and more.", "DashboardTourUsers": "Easily create user accounts for your friends and family, each with their own permissions, library access, parental controls and more.",
"DashboardTourCinemaMode": "Cinema mode brings the theater experience straight to your living room with the ability to play trailers and custom intros before the main feature.", "DashboardTourCinemaMode": "Cinema mode brings the theater experience straight to your living room with the ability to play trailers and custom intros before the main feature.",
"DashboardTourChapters": "Enable chapter image generation for your videos for a more pleasing presentation while viewing.", "DashboardTourChapters": "Enable chapter image generation for your videos for a more pleasing presentation while viewing.",

View File

@ -1273,7 +1273,7 @@
"HeaderTrailerReel": "Trailer Reel", "HeaderTrailerReel": "Trailer Reel",
"OptionPlayUnwatchedTrailersOnly": "Play only unwatched trailers", "OptionPlayUnwatchedTrailersOnly": "Play only unwatched trailers",
"HeaderTrailerReelHelp": "Start a trailer reel to play a long running playlist of trailers.", "HeaderTrailerReelHelp": "Start a trailer reel to play a long running playlist of trailers.",
"MessageNoTrailersFound": "No trailers found. Install the Trailer channel plugin to import a library of internet trailers.", "MessageNoTrailersFound": "No trailers found. Install the Trailer channel to enhance your movie experience by adding a library of internet trailers.",
"HeaderNewUsers": "New Users", "HeaderNewUsers": "New Users",
"ButtonSignUp": "Sign up", "ButtonSignUp": "Sign up",
"ButtonForgotPassword": "Forgot password?", "ButtonForgotPassword": "Forgot password?",

View File

@ -332,13 +332,7 @@ namespace MediaBrowser.Server.Implementations.Sync
UserId = job.UserId UserId = job.UserId
}; };
// Get everything syncedItem.Item = _dtoService.GetBaseItemDto(libraryItem, new DtoOptions());
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
syncedItem.Item = _dtoService.GetBaseItemDto(libraryItem, new DtoOptions
{
Fields = fields
});
// TODO: this should be the media source of the transcoded output // TODO: this should be the media source of the transcoded output
syncedItem.Item.MediaSources = syncedItem.Item.MediaSources syncedItem.Item.MediaSources = syncedItem.Item.MediaSources