Merge pull request #7054 from matthew-jones-uk/disable-embedded-subs

This commit is contained in:
Cody Robibero 2022-02-11 13:20:37 -07:00 committed by GitHub
commit 603b6fe173
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 0 deletions

View File

@ -217,3 +217,4 @@
- [olsh](https://github.com/olsh) - [olsh](https://github.com/olsh)
- [lbenini](https://github.com/lbenini) - [lbenini](https://github.com/lbenini)
- [gnuyent](https://github.com/gnuyent) - [gnuyent](https://github.com/gnuyent)
- [Matthew Jones](https://github.com/matthew-jones-uk)

View File

@ -0,0 +1,30 @@
namespace MediaBrowser.Model.Configuration
{
/// <summary>
/// An enum representing the options to disable embedded subs.
/// </summary>
public enum EmbeddedSubtitleOptions
{
/// <summary>
/// Allow all embedded subs.
/// </summary>
AllowAll = 0,
/// <summary>
/// Allow only embedded subs that are text based.
/// </summary>
AllowText = 1,
/// <summary>
/// Allow only embedded subs that are image based.
/// </summary>
AllowImage = 2,
/// <summary>
/// Disable all embedded subs.
/// </summary>
AllowNone = 3,
}
}

View File

@ -15,6 +15,7 @@ namespace MediaBrowser.Model.Configuration
SkipSubtitlesIfAudioTrackMatches = true; SkipSubtitlesIfAudioTrackMatches = true;
RequirePerfectSubtitleMatch = true; RequirePerfectSubtitleMatch = true;
AllowEmbeddedSubtitles = EmbeddedSubtitleOptions.AllowAll;
AutomaticallyAddToCollection = true; AutomaticallyAddToCollection = true;
EnablePhotos = true; EnablePhotos = true;
@ -84,6 +85,8 @@ namespace MediaBrowser.Model.Configuration
public bool AutomaticallyAddToCollection { get; set; } public bool AutomaticallyAddToCollection { get; set; }
public EmbeddedSubtitleOptions AllowEmbeddedSubtitles { get; set; }
public TypeOptions[] TypeOptions { get; set; } public TypeOptions[] TypeOptions { get; set; }
public TypeOptions? GetTypeOptions(string type) public TypeOptions? GetTypeOptions(string type)

View File

@ -229,6 +229,18 @@ namespace MediaBrowser.Providers.MediaInfo
video.Video3DFormat ??= mediaInfo.Video3DFormat; video.Video3DFormat ??= mediaInfo.Video3DFormat;
} }
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.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);
}
var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video); var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
video.Height = videoStream?.Height ?? 0; video.Height = videoStream?.Height ?? 0;