From 5cd3276775461d96d912d47fbae6857b887b98d0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 8 Oct 2016 01:57:38 -0400 Subject: [PATCH] pass requested fields to data layer --- MediaBrowser.Api/FilterService.cs | 4 +- MediaBrowser.Api/GamesService.cs | 7 +- MediaBrowser.Api/ItemUpdateService.cs | 25 +- MediaBrowser.Api/MediaBrowser.Api.csproj | 5 +- MediaBrowser.Api/Movies/MoviesService.cs | 22 +- MediaBrowser.Api/PackageService.cs | 8 +- .../Playback/BaseStreamingService.cs | 3 - MediaBrowser.Api/Playback/StreamState.cs | 1 - .../Reports/Data/ReportBuilder.cs | 4 - .../Reports/Stat/ReportStatBuilder.cs | 25 - MediaBrowser.Api/SimilarItemsHelper.cs | 3 +- MediaBrowser.Api/StartupWizardService.cs | 2 + MediaBrowser.Api/TvShowsService.cs | 14 +- MediaBrowser.Api/UserLibrary/ItemsService.cs | 22 +- ...MediaBrowser.Common.Implementations.csproj | 8 +- .../Updates/InstallationManager.cs | 12 +- .../Updates/IInstallationManager.cs | 2 +- .../Entities/Audio/Audio.cs | 18 +- .../Entities/Audio/MusicArtist.cs | 9 +- MediaBrowser.Controller/Entities/BaseItem.cs | 2 + .../Entities/IArchivable.cs | 8 - .../Entities/IHasProductionLocations.cs | 34 - .../Entities/IHasTaglines.cs | 39 -- .../Entities/InternalItemsQuery.cs | 34 + .../Entities/Movies/Movie.cs | 4 +- .../Entities/MusicVideo.cs | 4 +- MediaBrowser.Controller/Entities/Photo.cs | 10 +- MediaBrowser.Controller/Entities/TV/Series.cs | 5 +- MediaBrowser.Controller/Entities/Trailer.cs | 12 +- .../Entities/UserViewBuilder.cs | 2 +- MediaBrowser.Controller/Entities/Video.cs | 18 +- .../LiveTv/ILiveTvManager.cs | 4 +- .../MediaBrowser.Controller.csproj | 3 - .../Providers/BaseItemXmlParser.cs | 17 +- .../Savers/XmlSaverHelpers.cs | 39 +- .../MediaBrowser.Model.Portable.csproj | 3 - .../MediaBrowser.Model.net35.csproj | 3 - .../Configuration/ServerConfiguration.cs | 2 + MediaBrowser.Model/Dto/BaseItemDto.cs | 6 +- MediaBrowser.Model/MediaBrowser.Model.csproj | 1 - MediaBrowser.Model/Querying/ItemFields.cs | 4 + MediaBrowser.Model/Updates/PackageInfo.cs | 6 +- MediaBrowser.Model/Updates/PackageType.cs | 21 - .../Manager/ItemImageProvider.cs | 6 - .../Manager/ProviderUtils.cs | 34 +- .../MediaInfo/AudioImageProvider.cs | 2 +- .../MediaInfo/FFProbeAudioInfo.cs | 7 - .../MediaInfo/FFProbeVideoInfo.cs | 7 - .../MediaInfo/VideoImageProvider.cs | 3 +- .../Movies/GenericMovieDbInfo.cs | 23 +- .../TV/SeriesPostScanTask.cs | 31 +- .../Dto/DtoService.cs | 45 +- .../HttpServer/HttpListenerHost.cs | 3 +- .../LiveTv/LiveTvManager.cs | 23 +- ...MediaBrowser.Server.Implementations.csproj | 5 +- .../Persistence/SqliteItemRepository.cs | 659 +++++++++++++----- .../app.config | 8 +- .../ApplicationHost.cs | 92 ++- .../MediaBrowser.Server.Startup.Common.csproj | 4 + .../Parsers/BaseNfoParser.cs | 25 +- .../Savers/BaseNfoSaver.cs | 22 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 64 files changed, 795 insertions(+), 689 deletions(-) delete mode 100644 MediaBrowser.Controller/Entities/IArchivable.cs delete mode 100644 MediaBrowser.Controller/Entities/IHasProductionLocations.cs delete mode 100644 MediaBrowser.Controller/Entities/IHasTaglines.cs delete mode 100644 MediaBrowser.Model/Updates/PackageType.cs diff --git a/MediaBrowser.Api/FilterService.cs b/MediaBrowser.Api/FilterService.cs index b3b75359a..557b1c625 100644 --- a/MediaBrowser.Api/FilterService.cs +++ b/MediaBrowser.Api/FilterService.cs @@ -4,6 +4,7 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Model.Querying; using ServiceStack; using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -104,7 +105,8 @@ namespace MediaBrowser.Api MediaTypes = request.GetMediaTypes(), IncludeItemTypes = request.GetIncludeItemTypes(), Recursive = true, - EnableTotalRecordCount = false + EnableTotalRecordCount = false, + Fields = new List { ItemFields.Genres, ItemFields.Tags } }; return query; diff --git a/MediaBrowser.Api/GamesService.cs b/MediaBrowser.Api/GamesService.cs index 0953b95e6..a2e065f30 100644 --- a/MediaBrowser.Api/GamesService.cs +++ b/MediaBrowser.Api/GamesService.cs @@ -200,6 +200,8 @@ namespace MediaBrowser.Api (!string.IsNullOrWhiteSpace(request.UserId) ? user.RootFolder : _libraryManager.RootFolder) : _libraryManager.GetItemById(request.Id); + var dtoOptions = GetDtoOptions(request); + var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user) { Limit = request.Limit, @@ -207,12 +209,11 @@ namespace MediaBrowser.Api { typeof(Game).Name }, - SimilarTo = item + SimilarTo = item, + Fields = dtoOptions.Fields }).ToList(); - var dtoOptions = GetDtoOptions(request); - var result = new QueryResult { Items = (await _dtoService.GetBaseItemDtos(itemsResult, dtoOptions, user).ConfigureAwait(false)).ToArray(), diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 64b6b18d6..687a21a46 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -274,10 +274,9 @@ namespace MediaBrowser.Api item.Tags = request.Tags; - var hasTaglines = item as IHasTaglines; - if (hasTaglines != null) + if (request.Taglines != null) { - hasTaglines.Taglines = request.Taglines; + item.Tagline = request.Taglines.FirstOrDefault(); } var hasShortOverview = item as IHasShortOverview; @@ -304,8 +303,6 @@ namespace MediaBrowser.Api item.OfficialRating = string.IsNullOrWhiteSpace(request.OfficialRating) ? null : request.OfficialRating; item.CustomRating = request.CustomRating; - SetProductionLocations(item, request); - item.PreferredMetadataCountryCode = request.PreferredMetadataCountryCode; item.PreferredMetadataLanguage = request.PreferredMetadataLanguage; @@ -413,23 +410,5 @@ namespace MediaBrowser.Api series.AirTime = request.AirTime; } } - - private void SetProductionLocations(BaseItem item, BaseItemDto request) - { - var hasProductionLocations = item as IHasProductionLocations; - - if (hasProductionLocations != null) - { - hasProductionLocations.ProductionLocations = request.ProductionLocations; - } - - var person = item as Person; - if (person != null) - { - person.PlaceOfBirth = request.ProductionLocations == null - ? null - : request.ProductionLocations.FirstOrDefault(); - } - } } } diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index 96d7874f0..d7091df56 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,9 +11,10 @@ MediaBrowser.Api 512 ..\ - v4.5 + v4.5.1 + true diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs index f153a0475..dac4e9b50 100644 --- a/MediaBrowser.Api/Movies/MoviesService.cs +++ b/MediaBrowser.Api/Movies/MoviesService.cs @@ -156,18 +156,19 @@ namespace MediaBrowser.Api.Movies itemTypes.Add(typeof(LiveTvProgram).Name); } + var dtoOptions = GetDtoOptions(request); + var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user) { Limit = request.Limit, IncludeItemTypes = itemTypes.ToArray(), IsMovie = true, SimilarTo = item, - EnableGroupByMetadataKey = true + EnableGroupByMetadataKey = true, + Fields = dtoOptions.Fields }).ToList(); - var dtoOptions = GetDtoOptions(request); - var result = new QueryResult { Items = (await _dtoService.GetBaseItemDtos(itemsResult, dtoOptions, user).ConfigureAwait(false)).ToArray(), @@ -198,7 +199,8 @@ namespace MediaBrowser.Api.Movies Limit = 7, ParentId = parentIdGuid, Recursive = true, - IsPlayed = true + IsPlayed = true, + Fields = dtoOptions.Fields }; var recentlyPlayedMovies = _libraryManager.GetItemList(query).ToList(); @@ -221,7 +223,8 @@ namespace MediaBrowser.Api.Movies ExcludeItemIds = recentlyPlayedMovies.Select(i => i.Id.ToString("N")).ToArray(), EnableGroupByMetadataKey = true, ParentId = parentIdGuid, - Recursive = true + Recursive = true, + Fields = dtoOptions.Fields }).ToList(); @@ -302,7 +305,8 @@ namespace MediaBrowser.Api.Movies PersonTypes = new[] { PersonType.Director }, IncludeItemTypes = itemTypes.ToArray(), IsMovie = true, - EnableGroupByMetadataKey = true + EnableGroupByMetadataKey = true, + Fields = dtoOptions.Fields }).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N")) .Take(itemLimit) @@ -339,7 +343,8 @@ namespace MediaBrowser.Api.Movies Limit = itemLimit + 2, IncludeItemTypes = itemTypes.ToArray(), IsMovie = true, - EnableGroupByMetadataKey = true + EnableGroupByMetadataKey = true, + Fields = dtoOptions.Fields }).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N")) .Take(itemLimit) @@ -375,7 +380,8 @@ namespace MediaBrowser.Api.Movies IncludeItemTypes = itemTypes.ToArray(), IsMovie = true, SimilarTo = item, - EnableGroupByMetadataKey = true + EnableGroupByMetadataKey = true, + Fields = dtoOptions.Fields }).ToList(); diff --git a/MediaBrowser.Api/PackageService.cs b/MediaBrowser.Api/PackageService.cs index 6d8378aae..dc7c4c6c1 100644 --- a/MediaBrowser.Api/PackageService.cs +++ b/MediaBrowser.Api/PackageService.cs @@ -46,7 +46,7 @@ namespace MediaBrowser.Api /// /// The name. [ApiMember(Name = "PackageType", Description = "Optional package type filter (System/UserInstalled)", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] - public PackageType? PackageType { get; set; } + public string PackageType { get; set; } [ApiMember(Name = "TargetSystems", Description = "Optional. Filter by target system type. Allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET", AllowMultiple = true)] public string TargetSystems { get; set; } @@ -72,7 +72,7 @@ namespace MediaBrowser.Api /// /// The name. [ApiMember(Name = "PackageType", Description = "Package type filter (System/UserInstalled)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")] - public PackageType PackageType { get; set; } + public string PackageType { get; set; } } /// @@ -149,12 +149,12 @@ namespace MediaBrowser.Api { var result = new List(); - if (request.PackageType == PackageType.UserInstalled || request.PackageType == PackageType.All) + if (string.Equals(request.PackageType, "UserInstalled", StringComparison.OrdinalIgnoreCase) || string.Equals(request.PackageType, "All", StringComparison.OrdinalIgnoreCase)) { result.AddRange(_installationManager.GetAvailablePluginUpdates(_appHost.ApplicationVersion, false, CancellationToken.None).Result.ToList()); } - else if (request.PackageType == PackageType.System || request.PackageType == PackageType.All) + else if (string.Equals(request.PackageType, "System", StringComparison.OrdinalIgnoreCase) || string.Equals(request.PackageType, "All", StringComparison.OrdinalIgnoreCase)) { var updateCheckResult = _appHost.CheckForApplicationUpdate(CancellationToken.None, new Progress()).Result; diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 056c1d7ae..b5bef1ce9 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1857,9 +1857,6 @@ namespace MediaBrowser.Api.Playback state.IsInputVideo = string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase); - var archivable = item as IArchivable; - state.IsInputArchive = archivable != null && archivable.IsArchive; - MediaSourceInfo mediaSource = null; if (string.IsNullOrWhiteSpace(request.LiveStreamId)) { diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index a59a7fe09..003599390 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -63,7 +63,6 @@ namespace MediaBrowser.Api.Playback get { return Request is VideoStreamRequest; } } public bool IsInputVideo { get; set; } - public bool IsInputArchive { get; set; } public VideoType VideoType { get; set; } public IsoType? IsoType { get; set; } diff --git a/MediaBrowser.Api/Reports/Data/ReportBuilder.cs b/MediaBrowser.Api/Reports/Data/ReportBuilder.cs index e4a560383..c9c63847c 100644 --- a/MediaBrowser.Api/Reports/Data/ReportBuilder.cs +++ b/MediaBrowser.Api/Reports/Data/ReportBuilder.cs @@ -517,10 +517,6 @@ namespace MediaBrowser.Api.Reports internalHeader = HeaderMetadata.Album; break; - case HeaderMetadata.Countries: - option.Column = (i, r) => this.GetListAsString(this.GetObject>(i, (x) => x.ProductionLocations)); - break; - case HeaderMetadata.Disc: option.Column = (i, r) => i.ParentIndexNumber; break; diff --git a/MediaBrowser.Api/Reports/Stat/ReportStatBuilder.cs b/MediaBrowser.Api/Reports/Stat/ReportStatBuilder.cs index 0da4857ac..52b095dee 100644 --- a/MediaBrowser.Api/Reports/Stat/ReportStatBuilder.cs +++ b/MediaBrowser.Api/Reports/Stat/ReportStatBuilder.cs @@ -36,7 +36,6 @@ namespace MediaBrowser.Api.Reports result = this.GetResultStudios(result, items, topItem); result = this.GetResultPersons(result, items, topItem); result = this.GetResultProductionYears(result, items, topItem); - result = this.GetResulProductionLocations(result, items, topItem); result = this.GetResultCommunityRatings(result, items, topItem); result = this.GetResultParentalRatings(result, items, topItem); @@ -100,30 +99,6 @@ namespace MediaBrowser.Api.Reports } } - /// Gets resul production locations. - /// The result. - /// The items. - /// The top item. - /// The resul production locations. - private ReportStatResult GetResulProductionLocations(ReportStatResult result, BaseItem[] items, int topItem = 5) - { - this.GetGroups(result, GetLocalizedHeader(HeaderMetadata.Countries), topItem, - items.OfType() - .Where(x => x.ProductionLocations != null) - .SelectMany(x => x.ProductionLocations) - .GroupBy(x => x) - .OrderByDescending(x => x.Count()) - .Take(topItem) - .Select(x => new ReportStatItem - { - Name = x.Key.ToString(), - Value = x.Count().ToString() - }) - ); - - return result; - } - /// Gets result community ratings. /// The result. /// The items. diff --git a/MediaBrowser.Api/SimilarItemsHelper.cs b/MediaBrowser.Api/SimilarItemsHelper.cs index 1621c8056..65cd3eaab 100644 --- a/MediaBrowser.Api/SimilarItemsHelper.cs +++ b/MediaBrowser.Api/SimilarItemsHelper.cs @@ -81,7 +81,8 @@ namespace MediaBrowser.Api var query = new InternalItemsQuery(user) { IncludeItemTypes = includeTypes.Select(i => i.Name).ToArray(), - Recursive = true + Recursive = true, + Fields = dtoOptions.Fields }; // ExcludeArtistIds diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 5caea2b15..d5158677c 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -117,6 +117,8 @@ namespace MediaBrowser.Api config.EnableFolderView = true; config.SchemaVersion = 109; config.EnableSimpleArtistDetection = true; + config.SkipDeserializationForBasicTypes = true; + config.SkipDeserializationForPrograms = true; } public void Post(UpdateStartupConfiguration request) diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index a0d69317c..8c5d1c2f5 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -302,6 +302,8 @@ namespace MediaBrowser.Api (!string.IsNullOrWhiteSpace(request.UserId) ? user.RootFolder : _libraryManager.RootFolder) : _libraryManager.GetItemById(request.Id); + var dtoOptions = GetDtoOptions(request); + var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user) { Limit = request.Limit, @@ -309,12 +311,11 @@ namespace MediaBrowser.Api { typeof(Series).Name }, - SimilarTo = item + SimilarTo = item, + Fields = dtoOptions.Fields }).ToList(); - var dtoOptions = GetDtoOptions(request); - var result = new QueryResult { Items = (await _dtoService.GetBaseItemDtos(itemsResult, dtoOptions, user).ConfigureAwait(false)).ToArray(), @@ -333,6 +334,8 @@ namespace MediaBrowser.Api var parentIdGuid = string.IsNullOrWhiteSpace(request.ParentId) ? (Guid?)null : new Guid(request.ParentId); + var options = GetDtoOptions(request); + var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user) { IncludeItemTypes = new[] { typeof(Episode).Name }, @@ -342,12 +345,11 @@ namespace MediaBrowser.Api StartIndex = request.StartIndex, Limit = request.Limit, ParentId = parentIdGuid, - Recursive = true + Recursive = true, + Fields = options.Fields }).ToList(); - var options = GetDtoOptions(request); - var returnItems = (await _dtoService.GetBaseItemDtos(itemsResult, options, user).ConfigureAwait(false)).ToArray(); var result = new ItemsResult diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 681624ba2..eabb2ab8f 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -99,8 +99,10 @@ namespace MediaBrowser.Api.UserLibrary private async Task GetItems(GetItems request) { var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null; - - var result = await GetQueryResult(request, user).ConfigureAwait(false); + + var dtoOptions = GetDtoOptions(request); + + var result = await GetQueryResult(request, dtoOptions, user).ConfigureAwait(false); if (result == null) { @@ -112,8 +114,6 @@ namespace MediaBrowser.Api.UserLibrary throw new InvalidOperationException("GetItemsToSerialize result.Items returned null"); } - var dtoOptions = GetDtoOptions(request); - var dtoList = await _dtoService.GetBaseItemDtos(result.Items, dtoOptions, user).ConfigureAwait(false); if (dtoList == null) @@ -131,10 +131,7 @@ namespace MediaBrowser.Api.UserLibrary /// /// Gets the items to serialize. /// - /// The request. - /// The user. - /// IEnumerable{BaseItem}. - private async Task> GetQueryResult(GetItems request, User user) + private async Task> GetQueryResult(GetItems request, DtoOptions dtoOptions, User user) { var item = string.IsNullOrEmpty(request.ParentId) ? user == null ? _libraryManager.RootFolder : user.RootFolder : @@ -159,14 +156,14 @@ namespace MediaBrowser.Api.UserLibrary if (request.Recursive || !string.IsNullOrEmpty(request.Ids) || user == null) { - return await folder.GetItems(GetItemsQuery(request, user)).ConfigureAwait(false); + return await folder.GetItems(GetItemsQuery(request, dtoOptions, user)).ConfigureAwait(false); } var userRoot = item as UserRootFolder; if (userRoot == null) { - return await folder.GetItems(GetItemsQuery(request, user)).ConfigureAwait(false); + return await folder.GetItems(GetItemsQuery(request, dtoOptions, user)).ConfigureAwait(false); } IEnumerable items = folder.GetChildren(user, true); @@ -180,7 +177,7 @@ namespace MediaBrowser.Api.UserLibrary }; } - private InternalItemsQuery GetItemsQuery(GetItems request, User user) + private InternalItemsQuery GetItemsQuery(GetItems request, DtoOptions dtoOptions, User user) { var query = new InternalItemsQuery(user) { @@ -241,7 +238,8 @@ namespace MediaBrowser.Api.UserLibrary AiredDuringSeason = request.AiredDuringSeason, AlbumArtistStartsWithOrGreater = request.AlbumArtistStartsWithOrGreater, EnableTotalRecordCount = request.EnableTotalRecordCount, - ExcludeItemIds = request.GetExcludeItemIds() + ExcludeItemIds = request.GetExcludeItemIds(), + Fields = dtoOptions.Fields }; if (!string.IsNullOrWhiteSpace(request.Ids)) diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj index 718e6b9f6..f3444f01b 100644 --- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj +++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj @@ -1,5 +1,5 @@  - + Debug @@ -14,6 +14,7 @@ 10.0.0 2.0 v4.5 + true @@ -23,7 +24,7 @@ DEBUG;TRACE prompt 4 - v4.5 + v4.5.1 none @@ -79,6 +80,9 @@ + + ..\ThirdParty\fastjsonparser\System.Text.Json.dll + ..\ThirdParty\ServiceStack.Text\ServiceStack.Text.dll diff --git a/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs b/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs index 8c7646209..9674199fe 100644 --- a/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs +++ b/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs @@ -148,14 +148,10 @@ namespace MediaBrowser.Common.Implementations.Updates /// /// Gets all available packages. /// - /// The cancellation token. - /// if set to true [with registration]. - /// Type of the package. - /// The application version. /// Task{List{PackageInfo}}. public async Task> GetAvailablePackages(CancellationToken cancellationToken, bool withRegistration = true, - PackageType? packageType = null, + string packageType = null, Version applicationVersion = null) { var data = new Dictionary @@ -293,7 +289,7 @@ namespace MediaBrowser.Common.Implementations.Updates return packages; } - protected IEnumerable FilterPackages(List packages, PackageType? packageType, Version applicationVersion) + protected IEnumerable FilterPackages(List packages, string packageType, Version applicationVersion) { foreach (var package in packages) { @@ -301,9 +297,9 @@ namespace MediaBrowser.Common.Implementations.Updates .OrderByDescending(GetPackageVersion).ToList(); } - if (packageType.HasValue) + if (!string.IsNullOrWhiteSpace(packageType)) { - packages = packages.Where(p => p.type == packageType.Value).ToList(); + packages = packages.Where(p => string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)).ToList(); } // If an app version was supplied, filter the versions for each package to only include supported versions diff --git a/MediaBrowser.Common/Updates/IInstallationManager.cs b/MediaBrowser.Common/Updates/IInstallationManager.cs index 68853f05e..f7a202f97 100644 --- a/MediaBrowser.Common/Updates/IInstallationManager.cs +++ b/MediaBrowser.Common/Updates/IInstallationManager.cs @@ -51,7 +51,7 @@ namespace MediaBrowser.Common.Updates /// Task{List{PackageInfo}}. Task> GetAvailablePackages(CancellationToken cancellationToken, bool withRegistration = true, - PackageType? packageType = null, + string packageType = null, Version applicationVersion = null); /// diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 599e72314..00657370e 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -23,8 +23,7 @@ namespace MediaBrowser.Controller.Entities.Audio IHasMusicGenres, IHasLookupInfo, IHasMediaSources, - IThemeMedia, - IArchivable + IThemeMedia { public List ChannelMediaSources { get; set; } @@ -84,21 +83,6 @@ namespace MediaBrowser.Controller.Entities.Audio } } - [IgnoreDataMember] - public bool IsArchive - { - get - { - if (string.IsNullOrWhiteSpace(Path)) - { - return false; - } - var ext = System.IO.Path.GetExtension(Path) ?? string.Empty; - - return new[] { ".zip", ".rar", ".7z" }.Contains(ext, StringComparer.OrdinalIgnoreCase); - } - } - public override bool CanDownload() { var locationType = LocationType; diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 81d1deaa2..076a7031a 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// /// Class MusicArtist /// - public class MusicArtist : Folder, IMetadataContainer, IItemByName, IHasMusicGenres, IHasDualAccess, IHasProductionLocations, IHasLookupInfo + public class MusicArtist : Folder, IMetadataContainer, IItemByName, IHasMusicGenres, IHasDualAccess, IHasLookupInfo { [IgnoreDataMember] public bool IsAccessedByName @@ -24,8 +24,6 @@ namespace MediaBrowser.Controller.Entities.Audio get { return ParentId == Guid.Empty; } } - public List ProductionLocations { get; set; } - [IgnoreDataMember] public override bool IsFolder { @@ -111,11 +109,6 @@ namespace MediaBrowser.Controller.Entities.Audio return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService); } - public MusicArtist() - { - ProductionLocations = new List(); - } - public override List GetUserDataKeys() { var list = base.GetUserDataKeys(); diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 90a22b217..eb84765fb 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -73,6 +73,8 @@ namespace MediaBrowser.Controller.Entities public long? Size { get; set; } public string Container { get; set; } public string ShortOverview { get; set; } + [IgnoreDataMember] + public string Tagline { get; set; } public List ImageInfos { get; set; } diff --git a/MediaBrowser.Controller/Entities/IArchivable.cs b/MediaBrowser.Controller/Entities/IArchivable.cs deleted file mode 100644 index 575d203a7..000000000 --- a/MediaBrowser.Controller/Entities/IArchivable.cs +++ /dev/null @@ -1,8 +0,0 @@ - -namespace MediaBrowser.Controller.Entities -{ - public interface IArchivable - { - bool IsArchive { get; } - } -} diff --git a/MediaBrowser.Controller/Entities/IHasProductionLocations.cs b/MediaBrowser.Controller/Entities/IHasProductionLocations.cs deleted file mode 100644 index e4652fa8d..000000000 --- a/MediaBrowser.Controller/Entities/IHasProductionLocations.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace MediaBrowser.Controller.Entities -{ - /// - /// Interface IHasProductionLocations - /// - public interface IHasProductionLocations - { - /// - /// Gets or sets the production locations. - /// - /// The production locations. - List ProductionLocations { get; set; } - } - - public static class ProductionLocationExtensions - { - public static void AddProductionLocation(this IHasProductionLocations item, string name) - { - if (string.IsNullOrWhiteSpace(name)) - { - throw new ArgumentNullException("name"); - } - - if (!item.ProductionLocations.Contains(name, StringComparer.OrdinalIgnoreCase)) - { - item.ProductionLocations.Add(name); - } - } - } -} diff --git a/MediaBrowser.Controller/Entities/IHasTaglines.cs b/MediaBrowser.Controller/Entities/IHasTaglines.cs deleted file mode 100644 index 8025d6b44..000000000 --- a/MediaBrowser.Controller/Entities/IHasTaglines.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace MediaBrowser.Controller.Entities -{ - /// - /// Interface IHasTaglines - /// - public interface IHasTaglines - { - /// - /// Gets or sets the taglines. - /// - /// The taglines. - List Taglines { get; set; } - } - - public static class TaglineExtensions - { - /// - /// Adds the tagline. - /// - /// The tagline. - /// tagline - public static void AddTagline(this IHasTaglines item, string tagline) - { - if (string.IsNullOrWhiteSpace(tagline)) - { - throw new ArgumentNullException("tagline"); - } - - if (!item.Taglines.Contains(tagline, StringComparer.OrdinalIgnoreCase)) - { - item.Taglines.Add(tagline); - } - } - } -} diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 89fe71d3c..0a857a477 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -2,6 +2,8 @@ using System; using System.Collections.Generic; using MediaBrowser.Model.Configuration; +using System.Linq; +using MediaBrowser.Model.Querying; namespace MediaBrowser.Controller.Entities { @@ -157,11 +159,43 @@ namespace MediaBrowser.Controller.Entities public DateTime? MinDateCreated { get; set; } public DateTime? MinDateLastSaved { get; set; } + public List Fields { get; set; } + + public bool HasField(ItemFields name) + { + switch (name) + { + case ItemFields.Keywords: + case ItemFields.Taglines: + case ItemFields.ShortOverview: + case ItemFields.CustomRating: + case ItemFields.DateCreated: + case ItemFields.SortName: + case ItemFields.Overview: + case ItemFields.OfficialRatingDescription: + case ItemFields.HomePageUrl: + case ItemFields.VoteCount: + case ItemFields.DisplayMediaType: + case ItemFields.ServiceName: + case ItemFields.Genres: + case ItemFields.Studios: + case ItemFields.Settings: + case ItemFields.OriginalTitle: + case ItemFields.Tags: + case ItemFields.DateLastMediaAdded: + case ItemFields.CriticRatingSummary: + return Fields.Count == 0 || Fields.Contains(name); + default: + return true; + } + } + public InternalItemsQuery() { GroupByPresentationUniqueKey = true; EnableTotalRecordCount = true; + Fields = new List(); AlbumNames = new string[] { }; ArtistNames = new string[] { }; ExcludeArtistIds = new string[] { }; diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index e1e336147..8120b0028 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -15,13 +15,12 @@ namespace MediaBrowser.Controller.Entities.Movies /// /// Class Movie /// - public class Movie : Video, IHasCriticRating, IHasSpecialFeatures, IHasProductionLocations, IHasBudget, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasAwards, IHasMetascore, IHasLookupInfo, ISupportsBoxSetGrouping, IHasOriginalTitle + public class Movie : Video, IHasCriticRating, IHasSpecialFeatures, IHasBudget, IHasTrailers, IHasThemeMedia, IHasAwards, IHasMetascore, IHasLookupInfo, ISupportsBoxSetGrouping, IHasOriginalTitle { public List SpecialFeatureIds { get; set; } public List ThemeSongIds { get; set; } public List ThemeVideoIds { get; set; } - public List ProductionLocations { get; set; } public Movie() { @@ -32,7 +31,6 @@ namespace MediaBrowser.Controller.Entities.Movies ThemeSongIds = new List(); ThemeVideoIds = new List(); Taglines = new List(); - ProductionLocations = new List(); } public string AwardSummary { get; set; } diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs index 9254802dd..6e632a26c 100644 --- a/MediaBrowser.Controller/Entities/MusicVideo.cs +++ b/MediaBrowser.Controller/Entities/MusicVideo.cs @@ -6,7 +6,7 @@ using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities { - public class MusicVideo : Video, IHasArtist, IHasMusicGenres, IHasProductionLocations, IHasBudget, IHasLookupInfo + public class MusicVideo : Video, IHasArtist, IHasMusicGenres, IHasBudget, IHasLookupInfo { /// /// Gets or sets the budget. @@ -19,12 +19,10 @@ namespace MediaBrowser.Controller.Entities /// /// The revenue. public double? Revenue { get; set; } - public List ProductionLocations { get; set; } public List Artists { get; set; } public MusicVideo() { - ProductionLocations = new List(); Artists = new List(); } diff --git a/MediaBrowser.Controller/Entities/Photo.cs b/MediaBrowser.Controller/Entities/Photo.cs index 965616eb5..41e25e406 100644 --- a/MediaBrowser.Controller/Entities/Photo.cs +++ b/MediaBrowser.Controller/Entities/Photo.cs @@ -1,19 +1,11 @@ using MediaBrowser.Model.Drawing; -using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities { - public class Photo : BaseItem, IHasTaglines + public class Photo : BaseItem { - public List Taglines { get; set; } - - public Photo() - { - Taglines = new List(); - } - [IgnoreDataMember] public override bool SupportsLocalMetadata { diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 7e8ba0516..39703f67a 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -17,17 +17,14 @@ namespace MediaBrowser.Controller.Entities.TV /// /// Class Series /// - public class Series : Folder, IHasTrailers, IHasDisplayOrder, IHasLookupInfo, IHasSpecialFeatures, IMetadataContainer, IHasOriginalTitle + public class Series : Folder, IHasTrailers, IHasDisplayOrder, IHasLookupInfo, IMetadataContainer, IHasOriginalTitle { - public List SpecialFeatureIds { get; set; } - public int? AnimeSeriesIndex { get; set; } public Series() { AirDays = new List(); - SpecialFeatureIds = new List(); RemoteTrailers = new List(); LocalTrailerIds = new List(); RemoteTrailerIds = new List(); diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index f68cd2c85..0bcd5c14e 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -10,16 +10,12 @@ namespace MediaBrowser.Controller.Entities /// /// Class Trailer /// - public class Trailer : Video, IHasCriticRating, IHasProductionLocations, IHasBudget, IHasTaglines, IHasMetascore, IHasOriginalTitle, IHasLookupInfo + public class Trailer : Video, IHasCriticRating, IHasBudget, IHasMetascore, IHasOriginalTitle, IHasLookupInfo { - public List ProductionLocations { get; set; } - public Trailer() { RemoteTrailers = new List(); - Taglines = new List(); Keywords = new List(); - ProductionLocations = new List(); TrailerTypes = new List { TrailerType.LocalTrailer }; } @@ -35,12 +31,6 @@ namespace MediaBrowser.Controller.Entities get { return TrailerTypes.Contains(TrailerType.LocalTrailer); } } - /// - /// Gets or sets the taglines. - /// - /// The taglines. - public List Taglines { get; set; } - /// /// Gets or sets the budget. /// diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 9f3acc3fc..8a64be714 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -96,7 +96,7 @@ namespace MediaBrowser.Controller.Entities Limit = query.Limit, IsAiring = true - }, CancellationToken.None).ConfigureAwait(false); + }, new Dto.DtoOptions(), CancellationToken.None).ConfigureAwait(false); return GetResult(result); } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index c64cdf57d..b94973e2b 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -25,8 +25,7 @@ namespace MediaBrowser.Controller.Entities ISupportsPlaceHolders, IHasMediaSources, IHasShortOverview, - IThemeMedia, - IArchivable + IThemeMedia { [IgnoreDataMember] public string PrimaryVersionId { get; set; } @@ -197,21 +196,6 @@ namespace MediaBrowser.Controller.Entities get { return LocalAlternateVersions.Count > 0; } } - [IgnoreDataMember] - public bool IsArchive - { - get - { - if (string.IsNullOrWhiteSpace(Path)) - { - return false; - } - var ext = System.IO.Path.GetExtension(Path) ?? string.Empty; - - return new[] { ".zip", ".rar", ".7z" }.Contains(ext, StringComparer.OrdinalIgnoreCase); - } - } - public IEnumerable GetAdditionalPartIds() { return AdditionalParts.Select(i => LibraryManager.GetNewItemId(i, typeof(Video))); diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index a381c7980..7e48f3d21 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -242,10 +242,8 @@ namespace MediaBrowser.Controller.LiveTv /// /// Gets the recommended programs internal. /// - /// The query. - /// The cancellation token. /// Task<QueryResult<LiveTvProgram>>. - Task> GetRecommendedProgramsInternal(RecommendedProgramQuery query, CancellationToken cancellationToken); + Task> GetRecommendedProgramsInternal(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken); /// /// Gets the live tv information. diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 7c1114e22..06ec43206 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -132,7 +132,6 @@ - @@ -144,14 +143,12 @@ - - diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index fccbd9211..d2125fd5e 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -893,14 +893,6 @@ namespace MediaBrowser.Controller.Providers if (!string.IsNullOrWhiteSpace(val)) { - var hasProductionLocations = item as IHasProductionLocations; - if (hasProductionLocations != null) - { - if (!string.IsNullOrWhiteSpace(val)) - { - hasProductionLocations.AddProductionLocation(val); - } - } } break; } @@ -934,14 +926,7 @@ namespace MediaBrowser.Controller.Providers if (!string.IsNullOrWhiteSpace(val)) { - var hasTaglines = item as IHasTaglines; - if (hasTaglines != null) - { - if (!string.IsNullOrWhiteSpace(val)) - { - hasTaglines.AddTagline(val); - } - } + item.Tagline = val; } break; } diff --git a/MediaBrowser.LocalMetadata/Savers/XmlSaverHelpers.cs b/MediaBrowser.LocalMetadata/Savers/XmlSaverHelpers.cs index ac4ebbefe..c9810b042 100644 --- a/MediaBrowser.LocalMetadata/Savers/XmlSaverHelpers.cs +++ b/MediaBrowser.LocalMetadata/Savers/XmlSaverHelpers.cs @@ -350,21 +350,17 @@ namespace MediaBrowser.LocalMetadata.Savers } } - var hasProductionLocations = item as IHasProductionLocations; - if (hasProductionLocations != null) - { - if (hasProductionLocations.ProductionLocations.Count > 0) - { - builder.Append(""); + //if (hasProductionLocations.ProductionLocations.Count > 0) + //{ + // builder.Append(""); - foreach (var name in hasProductionLocations.ProductionLocations) - { - builder.Append("" + SecurityElement.Escape(name) + ""); - } + // foreach (var name in hasProductionLocations.ProductionLocations) + // { + // builder.Append("" + SecurityElement.Escape(name) + ""); + // } - builder.Append(""); - } - } + // builder.Append(""); + //} var hasDisplayOrder = item as IHasDisplayOrder; if (hasDisplayOrder != null && !string.IsNullOrEmpty(hasDisplayOrder.DisplayOrder)) @@ -457,20 +453,11 @@ namespace MediaBrowser.LocalMetadata.Savers } } - var hasTagline = item as IHasTaglines; - if (hasTagline != null) + if (!string.IsNullOrWhiteSpace(item.Tagline)) { - if (hasTagline.Taglines.Count > 0) - { - builder.Append(""); - - foreach (var tagline in hasTagline.Taglines) - { - builder.Append("" + SecurityElement.Escape(tagline) + ""); - } - - builder.Append(""); - } + builder.Append(""); + builder.Append("" + SecurityElement.Escape(item.Tagline) + ""); + builder.Append(""); } if (item.Genres.Count > 0) diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index 59e29087c..fa1acdca9 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -1165,9 +1165,6 @@ Updates\PackageTargetSystem.cs - - Updates\PackageType.cs - Updates\PackageVersionClass.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index 47ebb3a92..3ad40e2f5 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -1128,9 +1128,6 @@ Updates\PackageTargetSystem.cs - - Updates\PackageType.cs - Updates\PackageVersionClass.cs diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index e7f8e6548..2cdd88775 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -168,6 +168,8 @@ namespace MediaBrowser.Model.Configuration public MetadataOptions[] MetadataOptions { get; set; } public bool EnableAutomaticRestart { get; set; } + public bool SkipDeserializationForBasicTypes { get; set; } + public bool SkipDeserializationForPrograms { get; set; } public PathSubstitution[] PathSubstitutions { get; set; } diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 19853fd2b..7d21f9861 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -787,11 +787,7 @@ namespace MediaBrowser.Model.Dto /// The home page URL. public string HomePageUrl { get; set; } - /// - /// Gets or sets the production locations. - /// - /// The production locations. - public List ProductionLocations { get; set; } + public string PlaceOfBirth { get; set; } /// /// Gets or sets the budget. diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 69754204e..b9b920588 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -396,7 +396,6 @@ - diff --git a/MediaBrowser.Model/Querying/ItemFields.cs b/MediaBrowser.Model/Querying/ItemFields.cs index 0400e374a..c25fba8cf 100644 --- a/MediaBrowser.Model/Querying/ItemFields.cs +++ b/MediaBrowser.Model/Querying/ItemFields.cs @@ -130,6 +130,8 @@ /// Metascore, + OfficialRatingDescription, + OriginalTitle, /// @@ -152,6 +154,8 @@ /// People, + PlaceOfBirth, + /// /// The production locations /// diff --git a/MediaBrowser.Model/Updates/PackageInfo.cs b/MediaBrowser.Model/Updates/PackageInfo.cs index 191deeb8f..208d5b784 100644 --- a/MediaBrowser.Model/Updates/PackageInfo.cs +++ b/MediaBrowser.Model/Updates/PackageInfo.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Model.Updates /// The internal id of this package. /// /// The id. - public int id { get; set; } + public string id { get; set; } /// /// Gets or sets the name. @@ -66,7 +66,7 @@ namespace MediaBrowser.Model.Updates /// Gets or sets the type. /// /// The type. - public PackageType type { get; set; } + public string type { get; set; } /// /// Gets or sets the target filename. @@ -127,7 +127,7 @@ namespace MediaBrowser.Model.Updates /// Gets or sets the total number of ratings for this package. /// /// The total ratings. - public int totalRatings { get; set; } + public int? totalRatings { get; set; } /// /// Gets or sets the average rating for this package . diff --git a/MediaBrowser.Model/Updates/PackageType.cs b/MediaBrowser.Model/Updates/PackageType.cs deleted file mode 100644 index a00196e71..000000000 --- a/MediaBrowser.Model/Updates/PackageType.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace MediaBrowser.Model.Updates -{ - /// - /// Enum PackageType - /// - public enum PackageType - { - /// - /// All - /// - All, - /// - /// The system - /// - System, - /// - /// The user installed - /// - UserInstalled - } -} \ No newline at end of file diff --git a/MediaBrowser.Providers/Manager/ItemImageProvider.cs b/MediaBrowser.Providers/Manager/ItemImageProvider.cs index 1d8ba85f8..87da835dc 100644 --- a/MediaBrowser.Providers/Manager/ItemImageProvider.cs +++ b/MediaBrowser.Providers/Manager/ItemImageProvider.cs @@ -555,12 +555,6 @@ namespace MediaBrowser.Providers.Manager return false; case ImageType.Thumb: return false; - case ImageType.Logo: - return false; - case ImageType.Backdrop: - return false; - case ImageType.Screenshot: - return false; default: return true; } diff --git a/MediaBrowser.Providers/Manager/ProviderUtils.cs b/MediaBrowser.Providers/Manager/ProviderUtils.cs index 5f23cf69c..d98b2e2b1 100644 --- a/MediaBrowser.Providers/Manager/ProviderUtils.cs +++ b/MediaBrowser.Providers/Manager/ProviderUtils.cs @@ -99,6 +99,11 @@ namespace MediaBrowser.Providers.Manager target.CustomRating = source.CustomRating; } + if (replaceData || string.IsNullOrEmpty(target.Tagline)) + { + target.Tagline = source.Tagline; + } + if (!lockedFields.Contains(MetadataFields.Overview)) { if (replaceData || string.IsNullOrEmpty(target.Overview)) @@ -165,20 +170,6 @@ namespace MediaBrowser.Providers.Manager } } - if (!lockedFields.Contains(MetadataFields.ProductionLocations)) - { - var sourceHasProductionLocations = source as IHasProductionLocations; - var targetHasProductionLocations = target as IHasProductionLocations; - - if (sourceHasProductionLocations != null && targetHasProductionLocations != null) - { - if (replaceData || targetHasProductionLocations.ProductionLocations.Count == 0) - { - targetHasProductionLocations.ProductionLocations = sourceHasProductionLocations.ProductionLocations; - } - } - } - if (replaceData || !target.VoteCount.HasValue) { target.VoteCount = source.VoteCount; @@ -200,7 +191,6 @@ namespace MediaBrowser.Providers.Manager MergeMetascore(source, target, lockedFields, replaceData); MergeCriticRating(source, target, lockedFields, replaceData); MergeAwards(source, target, lockedFields, replaceData); - MergeTaglines(source, target, lockedFields, replaceData); MergeTrailers(source, target, lockedFields, replaceData); MergeShortOverview(source, target, lockedFields, replaceData); @@ -330,20 +320,6 @@ namespace MediaBrowser.Providers.Manager } } - private static void MergeTaglines(BaseItem source, BaseItem target, List lockedFields, bool replaceData) - { - var sourceCast = source as IHasTaglines; - var targetCast = target as IHasTaglines; - - if (sourceCast != null && targetCast != null) - { - if (replaceData || targetCast.Taglines.Count == 0) - { - targetCast.Taglines = sourceCast.Taglines; - } - } - } - private static void MergeTrailers(BaseItem source, BaseItem target, List lockedFields, bool replaceData) { var sourceCast = source as IHasTrailers; diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs index 027341ee6..68fc80371 100644 --- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs @@ -162,7 +162,7 @@ namespace MediaBrowser.Providers.MediaInfo { var audio = item as Audio; - return item.LocationType == LocationType.FileSystem && audio != null && !audio.IsArchive; + return item.LocationType == LocationType.FileSystem && audio != null; } public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs index baa561487..afcf4b226 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs @@ -38,13 +38,6 @@ namespace MediaBrowser.Providers.MediaInfo public async Task Probe(T item, CancellationToken cancellationToken) where T : Audio { - if (item.IsArchive) - { - var ext = Path.GetExtension(item.Path) ?? string.Empty; - item.Container = ext.TrimStart('.'); - return ItemUpdateType.MetadataImport; - } - var result = await GetMediaInfo(item, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 8c87e991e..be0b2ca6d 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -72,13 +72,6 @@ namespace MediaBrowser.Providers.MediaInfo CancellationToken cancellationToken) where T : Video { - if (item.IsArchive) - { - var ext = Path.GetExtension(item.Path) ?? string.Empty; - item.Container = ext.TrimStart('.'); - return ItemUpdateType.MetadataImport; - } - var isoMount = await MountIsoIfNeeded(item, cancellationToken).ConfigureAwait(false); BlurayDiscInfo blurayDiscInfo = null; diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs index 6a934240a..45d1c3d80 100644 --- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs @@ -174,8 +174,7 @@ namespace MediaBrowser.Providers.MediaInfo { var video = item as Video; - if (item.LocationType == LocationType.FileSystem && video != null && !video.IsPlaceHolder && - !video.IsShortcut && !video.IsArchive) + if (item.LocationType == LocationType.FileSystem && video != null && !video.IsPlaceHolder && !video.IsShortcut) { return true; } diff --git a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs index be174868b..5360a58c8 100644 --- a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs +++ b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs @@ -143,24 +143,19 @@ namespace MediaBrowser.Providers.Movies if (!string.IsNullOrEmpty(movieData.tagline)) { - var hasTagline = movie as IHasTaglines; - if (hasTagline != null) - { - hasTagline.Taglines.Clear(); - hasTagline.AddTagline(movieData.tagline); - } + movie.Tagline = movieData.tagline; } if (movieData.production_countries != null) { - var hasProductionLocations = movie as IHasProductionLocations; - if (hasProductionLocations != null) - { - hasProductionLocations.ProductionLocations = movieData - .production_countries - .Select(i => i.name) - .ToList(); - } + //var hasProductionLocations = movie as IHasProductionLocations; + //if (hasProductionLocations != null) + //{ + // hasProductionLocations.ProductionLocations = movieData + // .production_countries + // .Select(i => i.name) + // .ToList(); + //} } movie.SetProviderId(MetadataProviders.Tmdb, movieData.id.ToString(_usCulture)); diff --git a/MediaBrowser.Providers/TV/SeriesPostScanTask.cs b/MediaBrowser.Providers/TV/SeriesPostScanTask.cs index d6ae84b91..e038a3d28 100644 --- a/MediaBrowser.Providers/TV/SeriesPostScanTask.cs +++ b/MediaBrowser.Providers/TV/SeriesPostScanTask.cs @@ -47,7 +47,7 @@ namespace MediaBrowser.Providers.TV return RunInternal(progress, cancellationToken); } - private async Task RunInternal(IProgress progress, CancellationToken cancellationToken) + private Task RunInternal(IProgress progress, CancellationToken cancellationToken) { var seriesList = _libraryManager.GetItemList(new InternalItemsQuery() { @@ -59,34 +59,7 @@ namespace MediaBrowser.Providers.TV var seriesGroups = FindSeriesGroups(seriesList).Where(g => !string.IsNullOrEmpty(g.Key)).ToList(); - await new MissingEpisodeProvider(_logger, _config, _libraryManager, _localization, _fileSystem) - .Run(seriesGroups, true, cancellationToken).ConfigureAwait(false); - - var numComplete = 0; - - foreach (var series in seriesList) - { - cancellationToken.ThrowIfCancellationRequested(); - - var episodes = series.GetRecursiveChildren(i => i is Episode) - .Cast() - .ToList(); - - var physicalEpisodes = episodes.Where(i => i.LocationType != LocationType.Virtual) - .ToList(); - - series.SpecialFeatureIds = physicalEpisodes - .Where(i => i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0) - .Select(i => i.Id) - .ToList(); - - numComplete++; - double percent = numComplete; - percent /= seriesList.Count; - percent *= 100; - - progress.Report(percent); - } + return new MissingEpisodeProvider(_logger, _config, _libraryManager, _localization, _fileSystem).Run(seriesGroups, true, cancellationToken); } internal static IEnumerable> FindSeriesGroups(List seriesList) diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 46ee29b63..ae204c892 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -907,9 +907,13 @@ namespace MediaBrowser.Server.Implementations.Dto dto.Keywords = item.Keywords; } - if (fields.Contains(ItemFields.ProductionLocations)) + if (fields.Contains(ItemFields.PlaceOfBirth)) { - SetProductionLocations(item, dto); + var person = item as Person; + if (person != null) + { + dto.PlaceOfBirth = person.PlaceOfBirth; + } } var hasAspectRatio = item as IHasAspectRatio; @@ -998,8 +1002,11 @@ namespace MediaBrowser.Server.Implementations.Dto } dto.Audio = item.Audio; - dto.PreferredMetadataCountryCode = item.PreferredMetadataCountryCode; - dto.PreferredMetadataLanguage = item.PreferredMetadataLanguage; + if (fields.Contains(ItemFields.Settings)) + { + dto.PreferredMetadataCountryCode = item.PreferredMetadataCountryCode; + dto.PreferredMetadataLanguage = item.PreferredMetadataLanguage; + } dto.CriticRating = item.CriticRating; @@ -1089,10 +1096,9 @@ namespace MediaBrowser.Server.Implementations.Dto if (fields.Contains(ItemFields.Taglines)) { - var hasTagline = item as IHasTaglines; - if (hasTagline != null) + if (!string.IsNullOrWhiteSpace(item.Tagline)) { - dto.Taglines = hasTagline.Taglines; + dto.Taglines = new List { item.Tagline }; } if (dto.Taglines == null) @@ -1529,31 +1535,6 @@ namespace MediaBrowser.Server.Implementations.Dto return path; } - private void SetProductionLocations(BaseItem item, BaseItemDto dto) - { - var hasProductionLocations = item as IHasProductionLocations; - - if (hasProductionLocations != null) - { - dto.ProductionLocations = hasProductionLocations.ProductionLocations; - } - - var person = item as Person; - if (person != null) - { - dto.ProductionLocations = new List(); - if (!string.IsNullOrEmpty(person.PlaceOfBirth)) - { - dto.ProductionLocations.Add(person.PlaceOfBirth); - } - } - - if (dto.ProductionLocations == null) - { - dto.ProductionLocations = new List(); - } - } - /// /// Attaches the primary image aspect ratio. /// diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 2ebeb0d44..9ec671908 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -91,10 +91,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer HostConfig.Instance.DebugMode = false; HostConfig.Instance.LogFactory = LogManager.LogFactory; + HostConfig.Instance.AllowJsonpRequests = false; // The Markdown feature causes slow startup times (5 mins+) on cold boots for some users // Custom format allows images - HostConfig.Instance.EnableFeatures = Feature.Html | Feature.Json | Feature.CustomFormat; + HostConfig.Instance.EnableFeatures = Feature.Html | Feature.Json | Feature.Xml | Feature.CustomFormat; container.Adapter = _containerAdapter; diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 60b5b023a..93d8f8ef4 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -869,7 +869,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv SortBy = query.SortBy, SortOrder = query.SortOrder ?? SortOrder.Ascending, EnableTotalRecordCount = query.EnableTotalRecordCount, - TopParentIds = new[] { topFolder.Id.ToString("N") } + TopParentIds = new[] { topFolder.Id.ToString("N") }, + Fields = options.Fields }; if (!string.IsNullOrWhiteSpace(query.SeriesTimerId)) @@ -920,7 +921,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return result; } - public async Task> GetRecommendedProgramsInternal(RecommendedProgramQuery query, CancellationToken cancellationToken) + public async Task> GetRecommendedProgramsInternal(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken) { var user = _userManager.GetUserById(query.UserId); @@ -937,7 +938,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv IsKids = query.IsKids, EnableTotalRecordCount = query.EnableTotalRecordCount, SortBy = new[] { ItemSortBy.StartDate }, - TopParentIds = new[] { topFolder.Id.ToString("N") } + TopParentIds = new[] { topFolder.Id.ToString("N") }, + Fields = options.Fields }; if (query.Limit.HasValue) @@ -987,7 +989,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv public async Task> GetRecommendedPrograms(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken) { - var internalResult = await GetRecommendedProgramsInternal(query, cancellationToken).ConfigureAwait(false); + var internalResult = await GetRecommendedProgramsInternal(query, options, cancellationToken).ConfigureAwait(false); var user = _userManager.GetUserById(query.UserId); @@ -1315,6 +1317,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv } } + _logger.Debug("Channel {0} has {1} new programs and {2} updated programs", currentChannel.Name, newPrograms.Count, updatedPrograms.Count); + if (newPrograms.Count > 0) { await _libraryManager.CreateItems(newPrograms, cancellationToken).ConfigureAwait(false); @@ -1476,7 +1480,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv } } - private QueryResult GetEmbyRecordings(RecordingQuery query, User user) + private QueryResult GetEmbyRecordings(RecordingQuery query, DtoOptions dtoOptions, User user) { if (user == null || (query.IsInProgress ?? false)) { @@ -1552,7 +1556,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv EnableTotalRecordCount = query.EnableTotalRecordCount, IncludeItemTypes = includeItemTypes.ToArray(), ExcludeItemTypes = excludeItemTypes.ToArray(), - Genres = genres.ToArray() + Genres = genres.ToArray(), + Fields = dtoOptions.Fields }); } @@ -1625,7 +1630,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (_services.Count == 1) { - return GetEmbyRecordings(query, user); + return GetEmbyRecordings(query, new DtoOptions(), user); } await RefreshRecordings(cancellationToken).ConfigureAwait(false); @@ -2717,7 +2722,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv public async Task SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true) { - info = (TunerHostInfo)_jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info), typeof(TunerHostInfo)); + info = _jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info)); var provider = _tunerHosts.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase)); @@ -2758,7 +2763,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv public async Task SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings) { - info = (ListingsProviderInfo)_jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info), typeof(ListingsProviderInfo)); + info = _jsonSerializer.DeserializeFromString< ListingsProviderInfo>(_jsonSerializer.SerializeToString(info)); var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase)); diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 78b04aaa5..73e6ce1a5 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,9 +11,10 @@ MediaBrowser.Server.Implementations 512 ..\ - v4.5 + v4.5.1 + true diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 8a8d0b749..8275b01b0 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -274,6 +274,11 @@ namespace MediaBrowser.Server.Implementations.Persistence _connection.AddColumn(Logger, "TypedBaseItems", "SeriesId", "GUID"); _connection.AddColumn(Logger, "TypedBaseItems", "SeriesSortName", "Text"); _connection.AddColumn(Logger, "TypedBaseItems", "ExternalSeriesId", "Text"); + _connection.AddColumn(Logger, "TypedBaseItems", "ShortOverview", "Text"); + _connection.AddColumn(Logger, "TypedBaseItems", "Tagline", "Text"); + _connection.AddColumn(Logger, "TypedBaseItems", "Keywords", "Text"); + _connection.AddColumn(Logger, "TypedBaseItems", "ProviderIds", "Text"); + _connection.AddColumn(Logger, "TypedBaseItems", "Images", "Text"); _connection.AddColumn(Logger, "UserDataKeys", "Priority", "INT"); _connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text"); @@ -418,7 +423,12 @@ namespace MediaBrowser.Server.Implementations.Persistence "PresentationUniqueKey", "InheritedParentalRatingValue", "InheritedTags", - "ExternalSeriesId" + "ExternalSeriesId", + "ShortOverview", + "Tagline", + "Keywords", + "ProviderIds", + "Images" }; private readonly string[] _mediaStreamSaveColumns = @@ -541,7 +551,12 @@ namespace MediaBrowser.Server.Implementations.Persistence "SeasonId", "SeriesId", "SeriesSortName", - "ExternalSeriesId" + "ExternalSeriesId", + "ShortOverview", + "Tagline", + "Keywords", + "ProviderIds", + "Images" }; _saveItemCommand = _connection.CreateCommand(); _saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values ("; @@ -982,6 +997,11 @@ namespace MediaBrowser.Server.Implementations.Persistence } _saveItemCommand.GetParameter(index++).Value = item.ExternalSeriesId; + _saveItemCommand.GetParameter(index++).Value = item.ShortOverview; + _saveItemCommand.GetParameter(index++).Value = item.Tagline; + _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Keywords.ToArray()); + _saveItemCommand.GetParameter(index++).Value = SerializeProviderIds(item); + _saveItemCommand.GetParameter(index++).Value = SerializeImages(item); _saveItemCommand.Transaction = transaction; @@ -1031,6 +1051,99 @@ namespace MediaBrowser.Server.Implementations.Persistence } } + private string SerializeProviderIds(BaseItem item) + { + var ids = item.ProviderIds.ToList(); + + if (ids.Count == 0) + { + return null; + } + + return string.Join("|", ids.Select(i => i.Key + "=" + i.Value).ToArray()); + } + + private void DeserializeProviderIds(string value, BaseItem item) + { + if (string.IsNullOrWhiteSpace(value)) + { + return; + } + + if (item.ProviderIds.Count > 0) + { + return; + } + + var parts = value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + + foreach (var part in parts) + { + var idParts = part.Split('='); + + item.SetProviderId(idParts[0], idParts[1]); + } + } + + private string SerializeImages(BaseItem item) + { + var images = item.ImageInfos.ToList(); + + if (images.Count == 0) + { + return null; + } + + return string.Join("|", images.Select(ToValueString).ToArray()); + } + + private void DeserializeImages(string value, BaseItem item) + { + if (string.IsNullOrWhiteSpace(value)) + { + return; + } + + if (item.ImageInfos.Count > 0) + { + return; + } + + var parts = value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + + foreach (var part in parts) + { + item.ImageInfos.Add(ItemImageInfoFromValueString(part)); + } + } + + public string ToValueString(ItemImageInfo image) + { + var delimeter = "*"; + + return (image.Path ?? string.Empty) + + delimeter + + image.DateModified.Ticks.ToString(CultureInfo.InvariantCulture) + + delimeter + + image.Type + + delimeter + + image.IsPlaceholder; + } + + public ItemImageInfo ItemImageInfoFromValueString(string value) + { + var parts = value.Split(new[] { '*' }, StringSplitOptions.RemoveEmptyEntries); + + var image = new ItemImageInfo(); + + image.Path = parts[0]; + image.DateModified = new DateTime(long.Parse(parts[1], CultureInfo.InvariantCulture), DateTimeKind.Utc); + image.Type = (ImageType)Enum.Parse(typeof(ImageType), parts[2], true); + image.IsPlaceholder = string.Equals(parts[3], true.ToString(), StringComparison.OrdinalIgnoreCase); + + return image; + } + /// /// Internal retrieve from items or users table /// @@ -1064,6 +1177,51 @@ namespace MediaBrowser.Server.Implementations.Persistence } private BaseItem GetItem(IDataReader reader) + { + return GetItem(reader, new InternalItemsQuery()); + } + + private bool TypeRequiresDeserialization(Type type) + { + if (_config.Configuration.SkipDeserializationForBasicTypes) + { + if (type == typeof(MusicGenre)) + { + return false; + } + if (type == typeof(GameGenre)) + { + return false; + } + if (type == typeof(Genre)) + { + return false; + } + if (type == typeof(Studio)) + { + return false; + } + if (type == typeof(Year)) + { + return false; + } + if (type == typeof(Book)) + { + return false; + } + } + if (_config.Configuration.SkipDeserializationForPrograms) + { + if (type == typeof(LiveTvProgram)) + { + return false; + } + } + + return true; + } + + private BaseItem GetItem(IDataReader reader, InternalItemsQuery query) { var typeString = reader.GetString(0); @@ -1078,32 +1236,35 @@ namespace MediaBrowser.Server.Implementations.Persistence BaseItem item = null; - using (var stream = reader.GetMemoryStream(1, _memoryStreamProvider)) + if (TypeRequiresDeserialization(type)) { - try - { - item = _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem; - } - catch (SerializationException ex) - { - Logger.ErrorException("Error deserializing item", ex); - } - - if (item == null) + using (var stream = reader.GetMemoryStream(1, _memoryStreamProvider)) { try { - item = Activator.CreateInstance(type) as BaseItem; + item = _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem; } - catch + catch (SerializationException ex) { + Logger.ErrorException("Error deserializing item", ex); } } + } - if (item == null) + if (item == null) + { + try { - return null; + item = Activator.CreateInstance(type) as BaseItem; } + catch + { + } + } + + if (item == null) + { + return null; } if (!reader.IsDBNull(2)) @@ -1179,195 +1340,276 @@ namespace MediaBrowser.Server.Implementations.Persistence } } - if (!reader.IsDBNull(15)) + var index = 15; + + if (!reader.IsDBNull(index)) { - item.CommunityRating = reader.GetFloat(15); + item.CommunityRating = reader.GetFloat(index); + } + index++; + + if (query.HasField(ItemFields.CustomRating)) + { + if (!reader.IsDBNull(index)) + { + item.CustomRating = reader.GetString(index); + } + index++; } - if (!reader.IsDBNull(16)) + if (!reader.IsDBNull(index)) { - item.CustomRating = reader.GetString(16); + item.IndexNumber = reader.GetInt32(index); + } + index++; + + if (query.HasField(ItemFields.Settings)) + { + if (!reader.IsDBNull(index)) + { + item.IsLocked = reader.GetBoolean(index); + } + index++; + + if (!reader.IsDBNull(index)) + { + item.PreferredMetadataLanguage = reader.GetString(index); + } + index++; + + if (!reader.IsDBNull(index)) + { + item.PreferredMetadataCountryCode = reader.GetString(index); + } + index++; } - if (!reader.IsDBNull(17)) + if (!reader.IsDBNull(index)) { - item.IndexNumber = reader.GetInt32(17); + item.IsHD = reader.GetBoolean(index); + } + index++; + + if (!reader.IsDBNull(index)) + { + item.ExternalEtag = reader.GetString(index); + } + index++; + + if (!reader.IsDBNull(index)) + { + item.DateLastRefreshed = reader.GetDateTime(index).ToUniversalTime(); + } + index++; + + if (!reader.IsDBNull(index)) + { + item.Name = reader.GetString(index); + } + index++; + + if (!reader.IsDBNull(index)) + { + item.Path = reader.GetString(index); + } + index++; + + if (!reader.IsDBNull(index)) + { + item.PremiereDate = reader.GetDateTime(index).ToUniversalTime(); + } + index++; + + if (query.HasField(ItemFields.Overview)) + { + if (!reader.IsDBNull(index)) + { + item.Overview = reader.GetString(index); + } + index++; } - if (!reader.IsDBNull(18)) + if (!reader.IsDBNull(index)) { - item.IsLocked = reader.GetBoolean(18); + item.ParentIndexNumber = reader.GetInt32(index); + } + index++; + + if (!reader.IsDBNull(index)) + { + item.ProductionYear = reader.GetInt32(index); + } + index++; + + if (!reader.IsDBNull(index)) + { + item.OfficialRating = reader.GetString(index); + } + index++; + + if (query.HasField(ItemFields.OfficialRatingDescription)) + { + if (!reader.IsDBNull(index)) + { + item.OfficialRatingDescription = reader.GetString(index); + } + index++; } - if (!reader.IsDBNull(19)) + if (query.HasField(ItemFields.HomePageUrl)) { - item.PreferredMetadataLanguage = reader.GetString(19); + if (!reader.IsDBNull(index)) + { + item.HomePageUrl = reader.GetString(index); + } + index++; } - if (!reader.IsDBNull(20)) + if (query.HasField(ItemFields.DisplayMediaType)) { - item.PreferredMetadataCountryCode = reader.GetString(20); + if (!reader.IsDBNull(index)) + { + item.DisplayMediaType = reader.GetString(index); + } + index++; } - if (!reader.IsDBNull(21)) + if (query.HasField(ItemFields.SortName)) { - item.IsHD = reader.GetBoolean(21); + if (!reader.IsDBNull(index)) + { + item.ForcedSortName = reader.GetString(index); + } + index++; } - if (!reader.IsDBNull(22)) + if (!reader.IsDBNull(index)) { - item.ExternalEtag = reader.GetString(22); + item.RunTimeTicks = reader.GetInt64(index); + } + index++; + + if (query.HasField(ItemFields.VoteCount)) + { + if (!reader.IsDBNull(index)) + { + item.VoteCount = reader.GetInt32(index); + } + index++; } - if (!reader.IsDBNull(23)) + if (query.HasField(ItemFields.DateCreated)) { - item.DateLastRefreshed = reader.GetDateTime(23).ToUniversalTime(); + if (!reader.IsDBNull(index)) + { + item.DateCreated = reader.GetDateTime(index).ToUniversalTime(); + } + index++; } - if (!reader.IsDBNull(24)) + if (!reader.IsDBNull(index)) { - item.Name = reader.GetString(24); + item.DateModified = reader.GetDateTime(index).ToUniversalTime(); + } + index++; + + item.Id = reader.GetGuid(index); + index++; + + if (query.HasField(ItemFields.Genres)) + { + if (!reader.IsDBNull(index)) + { + item.Genres = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(); + } + index++; } - if (!reader.IsDBNull(25)) + if (!reader.IsDBNull(index)) { - item.Path = reader.GetString(25); + item.ParentId = reader.GetGuid(index); + } + index++; + + if (!reader.IsDBNull(index)) + { + item.Audio = (ProgramAudio)Enum.Parse(typeof(ProgramAudio), reader.GetString(index), true); + } + index++; + + if (query.HasField(ItemFields.ServiceName)) + { + if (!reader.IsDBNull(index)) + { + item.ServiceName = reader.GetString(index); + } + index++; } - if (!reader.IsDBNull(26)) + if (!reader.IsDBNull(index)) { - item.PremiereDate = reader.GetDateTime(26).ToUniversalTime(); + item.IsInMixedFolder = reader.GetBoolean(index); + } + index++; + + if (!reader.IsDBNull(index)) + { + item.DateLastSaved = reader.GetDateTime(index).ToUniversalTime(); + } + index++; + + if (query.HasField(ItemFields.Settings)) + { + if (!reader.IsDBNull(index)) + { + item.LockedFields = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => (MetadataFields)Enum.Parse(typeof(MetadataFields), i, true)).ToList(); + } + index++; } - if (!reader.IsDBNull(27)) + if (query.HasField(ItemFields.Studios)) { - item.Overview = reader.GetString(27); + if (!reader.IsDBNull(index)) + { + item.Studios = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(); + } + index++; } - if (!reader.IsDBNull(28)) + if (query.HasField(ItemFields.Tags)) { - item.ParentIndexNumber = reader.GetInt32(28); + if (!reader.IsDBNull(index)) + { + item.Tags = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(); + } + index++; } - if (!reader.IsDBNull(29)) + if (!reader.IsDBNull(index)) { - item.ProductionYear = reader.GetInt32(29); - } - - if (!reader.IsDBNull(30)) - { - item.OfficialRating = reader.GetString(30); - } - - if (!reader.IsDBNull(31)) - { - item.OfficialRatingDescription = reader.GetString(31); - } - - if (!reader.IsDBNull(32)) - { - item.HomePageUrl = reader.GetString(32); - } - - if (!reader.IsDBNull(33)) - { - item.DisplayMediaType = reader.GetString(33); - } - - if (!reader.IsDBNull(34)) - { - item.ForcedSortName = reader.GetString(34); - } - - if (!reader.IsDBNull(35)) - { - item.RunTimeTicks = reader.GetInt64(35); - } - - if (!reader.IsDBNull(36)) - { - item.VoteCount = reader.GetInt32(36); - } - - if (!reader.IsDBNull(37)) - { - item.DateCreated = reader.GetDateTime(37).ToUniversalTime(); - } - - if (!reader.IsDBNull(38)) - { - item.DateModified = reader.GetDateTime(38).ToUniversalTime(); - } - - item.Id = reader.GetGuid(39); - - if (!reader.IsDBNull(40)) - { - item.Genres = reader.GetString(40).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(); - } - - if (!reader.IsDBNull(41)) - { - item.ParentId = reader.GetGuid(41); - } - - if (!reader.IsDBNull(42)) - { - item.Audio = (ProgramAudio)Enum.Parse(typeof(ProgramAudio), reader.GetString(42), true); - } - - if (!reader.IsDBNull(43)) - { - item.ServiceName = reader.GetString(43); - } - - if (!reader.IsDBNull(44)) - { - item.IsInMixedFolder = reader.GetBoolean(44); - } - - if (!reader.IsDBNull(45)) - { - item.DateLastSaved = reader.GetDateTime(45).ToUniversalTime(); - } - - if (!reader.IsDBNull(46)) - { - item.LockedFields = reader.GetString(46).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => (MetadataFields)Enum.Parse(typeof(MetadataFields), i, true)).ToList(); - } - - if (!reader.IsDBNull(47)) - { - item.Studios = reader.GetString(47).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(); - } - - if (!reader.IsDBNull(48)) - { - item.Tags = reader.GetString(48).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(); - } - - if (!reader.IsDBNull(49)) - { - item.SourceType = (SourceType)Enum.Parse(typeof(SourceType), reader.GetString(49), true); + item.SourceType = (SourceType)Enum.Parse(typeof(SourceType), reader.GetString(index), true); } + index++; var trailer = item as Trailer; if (trailer != null) { - if (!reader.IsDBNull(50)) + if (!reader.IsDBNull(index)) { - trailer.TrailerTypes = reader.GetString(50).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => (TrailerType)Enum.Parse(typeof(TrailerType), i, true)).ToList(); + trailer.TrailerTypes = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => (TrailerType)Enum.Parse(typeof(TrailerType), i, true)).ToList(); } } - - var index = 51; - - if (!reader.IsDBNull(index)) - { - item.OriginalTitle = reader.GetString(index); - } index++; + if (query.HasField(ItemFields.OriginalTitle)) + { + if (!reader.IsDBNull(index)) + { + item.OriginalTitle = reader.GetString(index); + } + index++; + } + var video = item as Video; if (video != null) { @@ -1378,12 +1620,15 @@ namespace MediaBrowser.Server.Implementations.Persistence } index++; - var folder = item as Folder; - if (folder != null && !reader.IsDBNull(index)) + if (query.HasField(ItemFields.DateLastMediaAdded)) { - folder.DateLastMediaAdded = reader.GetDateTime(index).ToUniversalTime(); + var folder = item as Folder; + if (folder != null && !reader.IsDBNull(index)) + { + folder.DateLastMediaAdded = reader.GetDateTime(index).ToUniversalTime(); + } + index++; } - index++; if (!reader.IsDBNull(index)) { @@ -1397,11 +1642,14 @@ namespace MediaBrowser.Server.Implementations.Persistence } index++; - if (!reader.IsDBNull(index)) + if (query.HasField(ItemFields.CriticRatingSummary)) { - item.CriticRatingSummary = reader.GetString(index); + if (!reader.IsDBNull(index)) + { + item.CriticRatingSummary = reader.GetString(index); + } + index++; } - index++; if (!reader.IsDBNull(index)) { @@ -1480,6 +1728,54 @@ namespace MediaBrowser.Server.Implementations.Persistence } index++; + if (query.HasField(ItemFields.ShortOverview)) + { + if (!reader.IsDBNull(index)) + { + item.ShortOverview = reader.GetString(index); + } + index++; + } + + if (query.HasField(ItemFields.Taglines)) + { + if (!reader.IsDBNull(index)) + { + item.Tagline = reader.GetString(index); + } + index++; + } + + if (query.HasField(ItemFields.Keywords)) + { + if (!reader.IsDBNull(index)) + { + item.Keywords = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(); + } + index++; + } + + if (!reader.IsDBNull(index)) + { + DeserializeProviderIds(reader.GetString(index), item); + } + index++; + + if (!reader.IsDBNull(index)) + { + DeserializeImages(reader.GetString(index), item); + } + index++; + + if (string.IsNullOrWhiteSpace(item.Tagline)) + { + var movie = item as Movie; + if (movie != null && movie.Taglines.Count > 0) + { + movie.Tagline = movie.Taglines[0]; + } + } + return item; } @@ -1796,10 +2092,47 @@ namespace MediaBrowser.Server.Implementations.Persistence return false; } + private List allFields = Enum.GetNames(typeof(ItemFields)) + .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) + .ToList(); + + private IEnumerable GetColumnNamesFromField(ItemFields field) + { + if (field == ItemFields.Settings) + { + return new[] { "IsLocked", "PreferredMetadataCountryCode", "PreferredMetadataLanguage", "LockedFields" }; + } + if (field == ItemFields.ServiceName) + { + return new[] { "ExternalServiceId" }; + } + if (field == ItemFields.SortName) + { + return new[] { "ForcedSortName" }; + } + if (field == ItemFields.Taglines) + { + return new[] { "Tagline" }; + } + + return new[] { field.ToString() }; + } + private string[] GetFinalColumnsToSelect(InternalItemsQuery query, string[] startColumns, IDbCommand cmd) { var list = startColumns.ToList(); + foreach (var field in allFields) + { + if (!query.HasField(field)) + { + foreach (var fieldToRemove in GetColumnNamesFromField(field).ToList()) + { + list.Remove(fieldToRemove); + } + } + } + if (EnableJoinUserData(query)) { list.Add("UserDataDb.UserData.UserId"); @@ -1954,7 +2287,7 @@ namespace MediaBrowser.Server.Implementations.Persistence while (reader.Read()) { - var item = GetItem(reader); + var item = GetItem(reader, query); if (item != null) { list.Add(item); @@ -2141,7 +2474,7 @@ namespace MediaBrowser.Server.Implementations.Persistence { while (reader.Read()) { - var item = GetItem(reader); + var item = GetItem(reader, query); if (item != null) { list.Add(item); @@ -2652,7 +2985,7 @@ namespace MediaBrowser.Server.Implementations.Persistence } if (programAttribtues.Count > 0) { - whereClauses.Add("("+string.Join(" OR ", programAttribtues.ToArray())+")"); + whereClauses.Add("(" + string.Join(" OR ", programAttribtues.ToArray()) + ")"); } } diff --git a/MediaBrowser.Server.Implementations/app.config b/MediaBrowser.Server.Implementations/app.config index 14f2f055f..77b8b9218 100644 --- a/MediaBrowser.Server.Implementations/app.config +++ b/MediaBrowser.Server.Implementations/app.config @@ -1,11 +1,11 @@ - + - - + + - \ No newline at end of file + diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 0ea50b39e..538e9a6f6 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -102,7 +102,12 @@ using System.Threading; using System.Threading.Tasks; using CommonIO; using MediaBrowser.Api.Playback; +using MediaBrowser.Common.Implementations.Serialization; using MediaBrowser.Common.Implementations.Updates; +using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Controller.Entities.Movies; +using MediaBrowser.Controller.Entities.TV; +using MediaBrowser.Model.Serialization; namespace MediaBrowser.Server.Startup.Common { @@ -363,6 +368,89 @@ namespace MediaBrowser.Server.Startup.Common LogManager.RemoveConsoleOutput(); } + protected override IJsonSerializer CreateJsonSerializer() + { + var result = base.CreateJsonSerializer(); + + ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ShortOverview" }; + ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "Taglines" }; + ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "Keywords" }; + ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ShortOverview" }; + ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ShortOverview" }; + + ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds" }; + ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds" }; + ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds" }; + ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds" }; + ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds" }; + ServiceStack.Text.JsConfig