From 76b456d5e89415317c0556292057fdb1fe4bae9f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 21 Feb 2017 17:12:32 -0500 Subject: [PATCH] add setting to prefer filename or embedded title --- .../Configuration/LibraryOptions.cs | 1 + .../MediaInfo/FFProbeVideoInfo.cs | 21 ++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs index 24bc5dd117..7af0acc593 100644 --- a/MediaBrowser.Model/Configuration/LibraryOptions.cs +++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs @@ -14,6 +14,7 @@ public bool EnableInternetProviders { get; set; } public bool ImportMissingEpisodes { get; set; } public bool EnableAutomaticSeriesGrouping { get; set; } + public bool EnableEmbeddedTitles { get; set; } /// /// Gets or sets the preferred metadata language. diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 2270ad65ce..bc68b8c98a 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -195,8 +195,9 @@ namespace MediaBrowser.Providers.MediaInfo } await AddExternalSubtitles(video, mediaStreams, options, cancellationToken).ConfigureAwait(false); + var libraryOptions = _libraryManager.GetLibraryOptions(video); - FetchEmbeddedInfo(video, mediaInfo, options); + FetchEmbeddedInfo(video, mediaInfo, options, libraryOptions); await FetchPeople(video, mediaInfo, options).ConfigureAwait(false); video.IsHD = mediaStreams.Any(i => i.Type == MediaStreamType.Video && i.Width.HasValue && i.Width.Value >= 1260); @@ -222,7 +223,6 @@ namespace MediaBrowser.Providers.MediaInfo NormalizeChapterNames(chapters); - var libraryOptions = _libraryManager.GetLibraryOptions(video); var extractDuringScan = false; if (libraryOptions != null) { @@ -344,9 +344,9 @@ namespace MediaBrowser.Providers.MediaInfo } } - private void FetchEmbeddedInfo(Video video, Model.MediaInfo.MediaInfo data, MetadataRefreshOptions options) + private void FetchEmbeddedInfo(Video video, Model.MediaInfo.MediaInfo data, MetadataRefreshOptions refreshOptions, LibraryOptions libraryOptions) { - var isFullRefresh = options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh; + var isFullRefresh = refreshOptions.MetadataRefreshMode == MetadataRefreshMode.FullRefresh; if (!video.IsLocked && !video.LockedFields.Contains(MetadataFields.OfficialRating)) { @@ -418,15 +418,12 @@ namespace MediaBrowser.Providers.MediaInfo if (!video.IsLocked && !video.LockedFields.Contains(MetadataFields.Name)) { - if (!string.IsNullOrWhiteSpace(data.Name)) + if (!string.IsNullOrWhiteSpace(data.Name) && libraryOptions.EnableEmbeddedTitles) { - if (string.IsNullOrWhiteSpace(video.Name) || (string.Equals(video.Name, Path.GetFileNameWithoutExtension(video.Path), StringComparison.OrdinalIgnoreCase) && !video.ProviderIds.Any())) + // Don't use the embedded name for extras because it will often be the same name as the movie + if (!video.ExtraType.HasValue && !video.IsOwnedItem) { - // Don't use the embedded name for extras because it will often be the same name as the movie - if (!video.ExtraType.HasValue && !video.IsOwnedItem) - { - video.Name = data.Name; - } + video.Name = data.Name; } } } @@ -481,7 +478,7 @@ namespace MediaBrowser.Providers.MediaInfo /// /// The video. /// The current streams. - /// The options. + /// The refreshOptions. /// The cancellation token. /// Task. private async Task AddExternalSubtitles(Video video,