aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/BaseItem.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-10-16 13:11:32 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-10-16 13:11:32 -0400
commit55f47d21204bd166ab214256c7b8dd05c4d7ccd4 (patch)
tree3446513c681a5f80088baca360f04b50fc73aacc /MediaBrowser.Controller/Entities/BaseItem.cs
parent401dc39e4cfa9d9eea51003187a39ea5c7f1aba8 (diff)
update recording defaults
Diffstat (limited to 'MediaBrowser.Controller/Entities/BaseItem.cs')
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs95
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)