From 4df7590e52ba3501312bb901e9891fefe6812382 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Sun, 26 Dec 2021 16:18:25 +0000 Subject: [PATCH 1/7] Add DisableEmbeddedSubtitles setting Disables embedded subs being added to metadata --- MediaBrowser.Model/Configuration/LibraryOptions.cs | 2 ++ MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs index d3ce6aa7f..5b77d22fa 100644 --- a/MediaBrowser.Model/Configuration/LibraryOptions.cs +++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs @@ -84,6 +84,8 @@ namespace MediaBrowser.Model.Configuration public bool AutomaticallyAddToCollection { get; set; } + public bool DisableEmbeddedSubtitles { get; set; } + public TypeOptions[] TypeOptions { get; set; } public TypeOptions? GetTypeOptions(string type) diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 77372e063..bfe66ca9f 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -229,6 +229,12 @@ namespace MediaBrowser.Providers.MediaInfo video.Video3DFormat ??= mediaInfo.Video3DFormat; } + if (libraryOptions.DisableEmbeddedSubtitles) + { + _logger.LogInformation("Disabling embedded subtitles due to DisableEmbeddedSubtitles setting."); + mediaStreams.RemoveAll(i => i.Type == MediaStreamType.Subtitle && !i.IsExternal); + } + var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video); video.Height = videoStream?.Height ?? 0; From aeed255bbf0e0bd4cf3e1f757bcf5b0916b963a9 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Sun, 26 Dec 2021 16:25:55 +0000 Subject: [PATCH 2/7] Update CONTRIBUTORS.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d52e13324..f70b713de 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -217,3 +217,4 @@ - [olsh](https://github.com/olsh) - [lbenini](https://github.com/lbenini) - [gnuyent](https://github.com/gnuyent) + - [Matthew Jones](https://github.com/matthew-jones-uk) From 3f7bd7b63eaae40112e7d23944a9961b7e1902b8 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Sun, 26 Dec 2021 17:43:45 +0000 Subject: [PATCH 3/7] Changed DisableEmbeddedSubtitles logging to debug --- MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index bfe66ca9f..fbdd657e3 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -231,7 +231,7 @@ namespace MediaBrowser.Providers.MediaInfo if (libraryOptions.DisableEmbeddedSubtitles) { - _logger.LogInformation("Disabling embedded subtitles due to DisableEmbeddedSubtitles setting."); + _logger.LogDebug("Disabling embedded subtitles due to DisableEmbeddedSubtitles setting"); mediaStreams.RemoveAll(i => i.Type == MediaStreamType.Subtitle && !i.IsExternal); } From 126274c4ea7c664b21f7c0edc37a90579f4a6f76 Mon Sep 17 00:00:00 2001 From: Matt <7196594+matthew-jones-uk@users.noreply.github.com> Date: Sun, 26 Dec 2021 18:03:03 +0000 Subject: [PATCH 4/7] Add video path to DisableEmbeddedSubtitles log Co-authored-by: Cody Robibero --- MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index fbdd657e3..747376823 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -231,7 +231,7 @@ namespace MediaBrowser.Providers.MediaInfo if (libraryOptions.DisableEmbeddedSubtitles) { - _logger.LogDebug("Disabling embedded subtitles due to DisableEmbeddedSubtitles setting"); + _logger.LogDebug("Disabling embedded subtitles for {Path} due to DisableEmbeddedSubtitles setting", video.Path); mediaStreams.RemoveAll(i => i.Type == MediaStreamType.Subtitle && !i.IsExternal); } From 61d8d40a4a2bcdfd72d810f1c22247dfc53d6d53 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Fri, 14 Jan 2022 11:24:25 +0000 Subject: [PATCH 5/7] Added type options to disable embedded subs --- MediaBrowser.Model/Configuration/LibraryOptions.cs | 4 +++- MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs index 5b77d22fa..efa63b5e1 100644 --- a/MediaBrowser.Model/Configuration/LibraryOptions.cs +++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs @@ -84,7 +84,9 @@ namespace MediaBrowser.Model.Configuration public bool AutomaticallyAddToCollection { get; set; } - public bool DisableEmbeddedSubtitles { get; set; } + public bool DisableEmbeddedTextSubtitles { get; set; } + + public bool DisableEmbeddedImageSubtitles { get; set; } public TypeOptions[] TypeOptions { get; set; } diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 747376823..c1145f8a2 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -229,10 +229,16 @@ namespace MediaBrowser.Providers.MediaInfo video.Video3DFormat ??= mediaInfo.Video3DFormat; } - if (libraryOptions.DisableEmbeddedSubtitles) + if (libraryOptions.DisableEmbeddedImageSubtitles) { - _logger.LogDebug("Disabling embedded subtitles for {Path} due to DisableEmbeddedSubtitles setting", video.Path); - mediaStreams.RemoveAll(i => i.Type == MediaStreamType.Subtitle && !i.IsExternal); + _logger.LogDebug("Disabling embedded image subtitles for {Path} due to DisableEmbeddedImageSubtitles setting", video.Path); + mediaStreams.RemoveAll(i => i.Type == MediaStreamType.Subtitle && !i.IsExternal && !i.IsTextSubtitleStream); + } + + if (libraryOptions.DisableEmbeddedTextSubtitles) + { + _logger.LogDebug("Disabling embedded text subtitles for {Path} due to DisableEmbeddedTextSubtitles setting", video.Path); + mediaStreams.RemoveAll(i => i.Type == MediaStreamType.Subtitle && !i.IsExternal && i.IsTextSubtitleStream); } var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video); From 91d143d6ee25a309efadf1575a1efc432adb81cf Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 26 Jan 2022 16:09:05 +0000 Subject: [PATCH 6/7] Changed boolean options to enums --- .../Configuration/EmbeddedSubtitleOptions.cs | 30 +++++++++++++++++++ .../Configuration/LibraryOptions.cs | 5 ++-- .../MediaInfo/FFProbeVideoInfo.cs | 4 +-- 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 MediaBrowser.Model/Configuration/EmbeddedSubtitleOptions.cs diff --git a/MediaBrowser.Model/Configuration/EmbeddedSubtitleOptions.cs b/MediaBrowser.Model/Configuration/EmbeddedSubtitleOptions.cs new file mode 100644 index 000000000..948027603 --- /dev/null +++ b/MediaBrowser.Model/Configuration/EmbeddedSubtitleOptions.cs @@ -0,0 +1,30 @@ +namespace MediaBrowser.Model.Configuration +{ + /// + /// An enum representing the options to disable embedded subs. + /// + public enum EmbeddedSubtitleOptions + { + + /// + /// Allow all embedded subs. + /// + AllowAll, + + /// + /// Allow only embedded subs that are text based. + /// + AllowText, + + /// + /// Allow only embedded subs that are image based. + /// + AllowImage, + + /// + /// Disable all embedded subs. + /// + AllowNone, + } + +} diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs index efa63b5e1..ad3bce86e 100644 --- a/MediaBrowser.Model/Configuration/LibraryOptions.cs +++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs @@ -15,6 +15,7 @@ namespace MediaBrowser.Model.Configuration SkipSubtitlesIfAudioTrackMatches = true; RequirePerfectSubtitleMatch = true; + AllowEmbeddedSubtitles = EmbeddedSubtitleOptions.AllowAll; AutomaticallyAddToCollection = true; EnablePhotos = true; @@ -84,9 +85,7 @@ namespace MediaBrowser.Model.Configuration public bool AutomaticallyAddToCollection { get; set; } - public bool DisableEmbeddedTextSubtitles { get; set; } - - public bool DisableEmbeddedImageSubtitles { get; set; } + public EmbeddedSubtitleOptions AllowEmbeddedSubtitles { get; set; } public TypeOptions[] TypeOptions { get; set; } diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index c1145f8a2..71cdc5bff 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -229,13 +229,13 @@ namespace MediaBrowser.Providers.MediaInfo video.Video3DFormat ??= mediaInfo.Video3DFormat; } - if (libraryOptions.DisableEmbeddedImageSubtitles) + if (libraryOptions.AllowEmbeddedSubtitles == EmbeddedSubtitleOptions.AllowText || libraryOptions.AllowEmbeddedSubtitles == EmbeddedSubtitleOptions.AllowNone) { _logger.LogDebug("Disabling embedded image subtitles for {Path} due to DisableEmbeddedImageSubtitles setting", video.Path); mediaStreams.RemoveAll(i => i.Type == MediaStreamType.Subtitle && !i.IsExternal && !i.IsTextSubtitleStream); } - if (libraryOptions.DisableEmbeddedTextSubtitles) + if (libraryOptions.AllowEmbeddedSubtitles == EmbeddedSubtitleOptions.AllowImage || libraryOptions.AllowEmbeddedSubtitles == EmbeddedSubtitleOptions.AllowNone) { _logger.LogDebug("Disabling embedded text subtitles for {Path} due to DisableEmbeddedTextSubtitles setting", video.Path); mediaStreams.RemoveAll(i => i.Type == MediaStreamType.Subtitle && !i.IsExternal && i.IsTextSubtitleStream); From b7cab46b4ac3da712c63e34bdac3559bdd53ad98 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 9 Feb 2022 23:33:46 +0000 Subject: [PATCH 7/7] Added values to EmbeddedSubtitleOptions enum --- .../Configuration/EmbeddedSubtitleOptions.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Model/Configuration/EmbeddedSubtitleOptions.cs b/MediaBrowser.Model/Configuration/EmbeddedSubtitleOptions.cs index 948027603..42f07dbff 100644 --- a/MediaBrowser.Model/Configuration/EmbeddedSubtitleOptions.cs +++ b/MediaBrowser.Model/Configuration/EmbeddedSubtitleOptions.cs @@ -9,22 +9,22 @@ namespace MediaBrowser.Model.Configuration /// /// Allow all embedded subs. /// - AllowAll, + AllowAll = 0, /// /// Allow only embedded subs that are text based. /// - AllowText, + AllowText = 1, /// /// Allow only embedded subs that are image based. /// - AllowImage, + AllowImage = 2, /// /// Disable all embedded subs. /// - AllowNone, + AllowNone = 3, } }