The Free Software Media System - Server Backend & API
fixes #553 - Support locking OfficialRating field
Luke Pulverentib54240f6798d
diff --git a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs b/MediaBrowser.Controller/Providers/BaseMetadataProvider.csindex 39c999e82a..a8dc8788f1 100644--- a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs+++ b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs@@ -202,6 +202,18 @@ namespace MediaBrowser.Controller.Providersreturn NeedsRefreshInternal(item, data);}+ /// <summary>+ /// Gets a value indicating whether [enforce dont fetch metadata].+ /// </summary>+ /// <value><c>true</c> if [enforce dont fetch metadata]; otherwise, <c>false</c>.</value>+ public virtual bool EnforceDontFetchMetadata+ {+ get+ {+ return true;+ }+ }+/// <summary>/// Needses the refresh internal./// </summary>diff --git a/MediaBrowser.Model/Entities/MetadataFields.cs b/MediaBrowser.Model/Entities/MetadataFields.csindex a432e11248..85f2da31e0 100644--- a/MediaBrowser.Model/Entities/MetadataFields.cs+++ b/MediaBrowser.Model/Entities/MetadataFields.cs@@ -37,6 +37,10 @@ namespace MediaBrowser.Model.Entities/// <summary>/// The runtime/// </summary>- Runtime+ Runtime,+ /// <summary>+ /// The official rating+ /// </summary>+ OfficialRating}}diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.csindex 59c3d75e52..690c9b3ffe 100644--- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs+++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs@@ -384,7 +384,10 @@ namespace MediaBrowser.Providers.MediaInfoif (!string.IsNullOrWhiteSpace(officialRating)){- video.OfficialRating = officialRating;+ if (!video.LockedFields.Contains(MetadataFields.OfficialRating))+ {+ video.OfficialRating = officialRating;+ }}}diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.csindex 751712c71e..4741008555 100644--- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs+++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs@@ -317,7 +317,7 @@ namespace MediaBrowser.Providers.Moviesvar boxset = item as BoxSet;if (boxset != null){- // See if any movies have a collection id already+ // See if any movies have a collection id alreadyvar collId = boxset.Children.Concat(boxset.GetLinkedChildren()).OfType<Video>().Select(i => i.GetProviderId(MetadataProviders.TmdbCollection)).FirstOrDefault(i => i != null);@@ -462,7 +462,7 @@ namespace MediaBrowser.Providers.MoviesLogger.Info("MoviedbProvider: Ignoring " + item.Name + " because ID forced blank.");return;}-+item.SetProviderId(MetadataProviders.Tmdb, id);var mainResult = await FetchMainResult(item, id, cancellationToken).ConfigureAwait(false);@@ -586,14 +586,18 @@ namespace MediaBrowser.Providers.Moviesvar ourRelease = movieData.releases.countries.FirstOrDefault(c => c.iso_3166_1.Equals(ConfigurationManager.Configuration.MetadataCountryCode, StringComparison.OrdinalIgnoreCase)) ?? new Country();var usRelease = movieData.releases.countries.FirstOrDefault(c => c.iso_3166_1.Equals("US", StringComparison.OrdinalIgnoreCase)) ?? new Country();var minimunRelease = movieData.releases.countries.OrderBy(c => c.release_date).FirstOrDefault() ?? new Country();- var ratingPrefix = ConfigurationManager.Configuration.MetadataCountryCode.Equals("us", StringComparison.OrdinalIgnoreCase) ? "" : ConfigurationManager.Configuration.MetadataCountryCode + "-";- movie.OfficialRating = !string.IsNullOrEmpty(ourRelease.certification)- ? ratingPrefix + ourRelease.certification- : !string.IsNullOrEmpty(usRelease.certification)- ? usRelease.certification- : !string.IsNullOrEmpty(minimunRelease.certification)- ? minimunRelease.iso_3166_1 + "-" + minimunRelease.certification- : null;++ if (!movie.LockedFields.Contains(MetadataFields.OfficialRating))+ {+ var ratingPrefix = ConfigurationManager.Configuration.MetadataCountryCode.Equals("us", StringComparison.OrdinalIgnoreCase) ? "" : ConfigurationManager.Configuration.MetadataCountryCode + "-";+ movie.OfficialRating = !string.IsNullOrEmpty(ourRelease.certification)+ ? ratingPrefix + ourRelease.certification+ : !string.IsNullOrEmpty(usRelease.certification)+ ? usRelease.certification+ : !string.IsNullOrEmpty(minimunRelease.certification)+ ? minimunRelease.iso_3166_1 + "-" + minimunRelease.certification+ : null;+ }if (ourRelease.release_date != default(DateTime)){@@ -632,7 +636,7 @@ namespace MediaBrowser.Providers.Movies}//if that didn't find a rating and we are a boxset, use the one from our first child- if (movie.OfficialRating == null && movie is BoxSet)+ if (movie.OfficialRating == null && movie is BoxSet && !movie.LockedFields.Contains(MetadataFields.OfficialRating)){var boxset = movie as BoxSet;Logger.Info("MovieDbProvider - Using rating of first child of boxset...");diff --git a/MediaBrowser.Providers/TV/RemoteSeriesProvider.cs b/MediaBrowser.Providers/TV/RemoteSeriesProvider.csindex 99e160c050..a250c90602 100644--- a/MediaBrowser.Providers/TV/RemoteSeriesProvider.cs+++ b/MediaBrowser.Providers/TV/RemoteSeriesProvider.cs@@ -153,6 +153,15 @@ namespace MediaBrowser.Providers.TV}}+ public override bool EnforceDontFetchMetadata+ {+ get+ {+ // Other providers depend on the xml downloaded here+ return false;+ }+ }+protected override DateTime CompareDate(BaseItem item){var seriesId = item.GetProviderId(MetadataProviders.Tvdb);@@ -440,7 +449,10 @@ namespace MediaBrowser.Providers.TVif (!string.IsNullOrWhiteSpace(val)){- item.OfficialRating = val;+ if (!item.LockedFields.Contains(MetadataFields.OfficialRating))+ {+ item.OfficialRating = val;+ }}break;}diff --git a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs b/MediaBrowser.Server.Implementations/Providers/ProviderManager.csindex 9276311448..7d5a581d5e 100644--- a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs+++ b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs@@ -128,7 +128,7 @@ namespace MediaBrowser.Server.Implementations.Providers// Put this check below the await because the needs refresh of the next tier of providers may depend on the previous ones running// This is the case for the fan art provider which depends on the movie and tv providers having run before them- if (provider.RequiresInternet && item.DontFetchMeta)+ if (provider.RequiresInternet && item.DontFetchMeta && provider.EnforceDontFetchMetadata){continue;}