diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-10-17 12:32:57 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-17 12:32:57 -0400 |
| commit | fb9db5c3c36eca578369cb398c36efd6a15bbea9 (patch) | |
| tree | 98e41f78dd5d7c474ce763157eb3503a165088ed /MediaBrowser.Controller/Entities/BaseItem.cs | |
| parent | f8a248ffd805b810e90bc5ec0619e53f49ebcae5 (diff) | |
| parent | b0147c32f9122c6ce695d2919176ed8b50b94fda (diff) | |
Merge pull request #2240 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.Controller/Entities/BaseItem.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 95 |
1 files changed, 83 insertions, 12 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 7eb84fc80..3ebefa217 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1188,7 +1188,7 @@ namespace MediaBrowser.Controller.Entities var itemsChanged = !item.LocalTrailerIds.SequenceEqual(newItemIds); - var tasks = newItems.Select(i => i.RefreshMetadata(options, cancellationToken)); + var tasks = newItems.Select(i => RefreshMetadataForOwnedItem(i, true, options, cancellationToken)); await Task.WhenAll(tasks).ConfigureAwait(false); @@ -1197,7 +1197,7 @@ namespace MediaBrowser.Controller.Entities return itemsChanged; } - private static async Task<bool> RefreshThemeVideos(BaseItem item, MetadataRefreshOptions options, IEnumerable<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken) + private async Task<bool> RefreshThemeVideos(BaseItem item, MetadataRefreshOptions options, IEnumerable<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken) { var newThemeVideos = LoadThemeVideos(fileSystemChildren, options.DirectoryService).ToList(); @@ -1215,7 +1215,7 @@ namespace MediaBrowser.Controller.Entities subOptions.ForceSave = true; } - return i.RefreshMetadata(subOptions, cancellationToken); + return RefreshMetadataForOwnedItem(i, true, subOptions, cancellationToken); }); await Task.WhenAll(tasks).ConfigureAwait(false); @@ -1228,7 +1228,7 @@ namespace MediaBrowser.Controller.Entities /// <summary> /// Refreshes the theme songs. /// </summary> - private static async Task<bool> RefreshThemeSongs(BaseItem item, MetadataRefreshOptions options, List<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken) + private async Task<bool> RefreshThemeSongs(BaseItem item, MetadataRefreshOptions options, List<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken) { var newThemeSongs = LoadThemeSongs(fileSystemChildren, options.DirectoryService).ToList(); var newThemeSongIds = newThemeSongs.Select(i => i.Id).ToList(); @@ -1245,7 +1245,7 @@ namespace MediaBrowser.Controller.Entities subOptions.ForceSave = true; } - return i.RefreshMetadata(subOptions, cancellationToken); + return RefreshMetadataForOwnedItem(i, true, subOptions, cancellationToken); }); await Task.WhenAll(tasks).ConfigureAwait(false); @@ -2203,14 +2203,85 @@ namespace MediaBrowser.Controller.Entities return Task.FromResult(true); } - protected Task RefreshMetadataForOwnedVideo(MetadataRefreshOptions options, string path, CancellationToken cancellationToken) + protected Task RefreshMetadataForOwnedItem(BaseItem ownedItem, bool copyTitleMetadata, MetadataRefreshOptions options, CancellationToken cancellationToken) { - var newOptions = new MetadataRefreshOptions(options.DirectoryService) + var newOptions = new MetadataRefreshOptions(options); + newOptions.SearchResult = null; + + var item = this; + + if (copyTitleMetadata) { - ImageRefreshMode = options.ImageRefreshMode, - MetadataRefreshMode = options.MetadataRefreshMode, - ReplaceAllMetadata = options.ReplaceAllMetadata - }; + // Take some data from the main item, for querying purposes + if (!item.Genres.SequenceEqual(ownedItem.Genres, StringComparer.Ordinal)) + { + newOptions.ForceSave = true; + ownedItem.Genres = item.Genres.ToList(); + } + if (!item.Studios.SequenceEqual(ownedItem.Studios, StringComparer.Ordinal)) + { + newOptions.ForceSave = true; + ownedItem.Studios = item.Studios.ToList(); + } + if (!item.ProductionLocations.SequenceEqual(ownedItem.ProductionLocations, StringComparer.Ordinal)) + { + newOptions.ForceSave = true; + ownedItem.ProductionLocations = item.ProductionLocations.ToList(); + } + if (!item.Keywords.SequenceEqual(ownedItem.Keywords, StringComparer.Ordinal)) + { + newOptions.ForceSave = true; + ownedItem.Keywords = item.Keywords.ToList(); + } + if (item.CommunityRating != ownedItem.CommunityRating) + { + ownedItem.CommunityRating = item.CommunityRating; + newOptions.ForceSave = true; + } + if (item.CriticRating != ownedItem.CriticRating) + { + ownedItem.CriticRating = item.CriticRating; + newOptions.ForceSave = true; + } + if (!string.Equals(item.Overview, ownedItem.Overview, StringComparison.Ordinal)) + { + ownedItem.Overview = item.Overview; + newOptions.ForceSave = true; + } + if (!string.Equals(item.ShortOverview, ownedItem.ShortOverview, StringComparison.Ordinal)) + { + ownedItem.ShortOverview = item.ShortOverview; + newOptions.ForceSave = true; + } + if (!string.Equals(item.OfficialRating, ownedItem.OfficialRating, StringComparison.Ordinal)) + { + ownedItem.OfficialRating = item.OfficialRating; + newOptions.ForceSave = true; + } + if (!string.Equals(item.CustomRating, ownedItem.CustomRating, StringComparison.Ordinal)) + { + ownedItem.CustomRating = item.CustomRating; + newOptions.ForceSave = true; + } + if (!string.Equals(item.CriticRatingSummary, ownedItem.CriticRatingSummary, StringComparison.Ordinal)) + { + ownedItem.CriticRatingSummary = item.CriticRatingSummary; + newOptions.ForceSave = true; + } + if (!string.Equals(item.OfficialRatingDescription, ownedItem.OfficialRatingDescription, StringComparison.Ordinal)) + { + ownedItem.OfficialRatingDescription = item.OfficialRatingDescription; + newOptions.ForceSave = true; + } + } + + return ownedItem.RefreshMetadata(newOptions, cancellationToken); + } + + protected Task RefreshMetadataForOwnedVideo(MetadataRefreshOptions options, bool copyTitleMetadata, string path, CancellationToken cancellationToken) + { + var newOptions = new MetadataRefreshOptions(options); + newOptions.SearchResult = null; var id = LibraryManager.GetNewItemId(path, typeof(Video)); @@ -2229,7 +2300,7 @@ namespace MediaBrowser.Controller.Entities return Task.FromResult(true); } - return video.RefreshMetadata(newOptions, cancellationToken); + return RefreshMetadataForOwnedItem(video, copyTitleMetadata, newOptions, cancellationToken); } public string GetEtag(User user) |
