The Free Software Media System - Server Backend & API
add additional subtitle setting
Luke Pulverenti0b7e39877295
diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.csindex e92d33574b..b2c499b9a9 100644--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs@@ -318,7 +318,8 @@ namespace MediaBrowser.Model.Configurationpublic class SubtitleOptions{- public bool RequireTextSubtitles { get; set; }+ public bool SkipIfGraphicalSubtitlesPresent { get; set; }+ public bool SkipIfAudioTrackMatches { get; set; }public string[] DownloadLanguages { get; set; }public bool DownloadMovieSubtitles { get; set; }public bool DownloadEpisodeSubtitles { get; set; }@@ -329,6 +330,8 @@ namespace MediaBrowser.Model.Configurationpublic SubtitleOptions(){DownloadLanguages = new string[] { };++ SkipIfAudioTrackMatches = true;}}}diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.csindex a78c27aa43..d2f8de8e4f 100644--- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs+++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs@@ -472,7 +472,8 @@ namespace MediaBrowser.Providers.MediaInfo.DownloadSubtitles(video,currentStreams,externalSubtitleStreams,- _config.Configuration.SubtitleOptions.RequireTextSubtitles,+ _config.Configuration.SubtitleOptions.SkipIfGraphicalSubtitlesPresent,+ _config.Configuration.SubtitleOptions.SkipIfAudioTrackMatches,_config.Configuration.SubtitleOptions.DownloadLanguages,cancellationToken).ConfigureAwait(false);diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.csindex a20dc4d299..3e11fd85e3 100644--- a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs+++ b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs@@ -26,7 +26,8 @@ namespace MediaBrowser.Providers.MediaInfopublic async Task<List<string>> DownloadSubtitles(Video video,List<MediaStream> internalMediaStreams,List<MediaStream> externalSubtitleStreams,- bool forceExternal,+ bool skipIfGraphicalSubtitlesPresent,+ bool skipIfAudioTrackMatches,IEnumerable<string> languages,CancellationToken cancellationToken){@@ -58,7 +59,7 @@ namespace MediaBrowser.Providers.MediaInfo{try{- var downloaded = await DownloadSubtitles(video, internalMediaStreams, externalSubtitleStreams, forceExternal, lang, mediaType, cancellationToken)+ var downloaded = await DownloadSubtitles(video, internalMediaStreams, externalSubtitleStreams, skipIfGraphicalSubtitlesPresent, skipIfAudioTrackMatches, lang, mediaType, cancellationToken).ConfigureAwait(false);if (downloaded)@@ -78,7 +79,8 @@ namespace MediaBrowser.Providers.MediaInfoprivate async Task<bool> DownloadSubtitles(Video video,List<MediaStream> internalMediaStreams,IEnumerable<MediaStream> externalSubtitleStreams,- bool forceExternal,+ bool skipIfGraphicalSubtitlesPresent,+ bool skipIfAudioTrackMatches,string language,SubtitleMediaType mediaType,CancellationToken cancellationToken)@@ -90,13 +92,14 @@ namespace MediaBrowser.Providers.MediaInfo}// There's already an audio stream for this language- if (internalMediaStreams.Any(i => i.Type == MediaStreamType.Audio && string.Equals(i.Language, language, StringComparison.OrdinalIgnoreCase)))+ if (skipIfAudioTrackMatches &&+ internalMediaStreams.Any(i => i.Type == MediaStreamType.Audio && string.Equals(i.Language, language, StringComparison.OrdinalIgnoreCase))){return false;}// There's an internal subtitle stream for this language- if (!forceExternal &&+ if (skipIfGraphicalSubtitlesPresent &&internalMediaStreams.Any(i => i.Type == MediaStreamType.Subtitle && string.Equals(i.Language, language, StringComparison.OrdinalIgnoreCase))){return false;diff --git a/MediaBrowser.Providers/Subtitles/OpenSubtitleDownloader.cs b/MediaBrowser.Providers/Subtitles/OpenSubtitleDownloader.csindex ac0439737b..cfb322bc6f 100644--- a/MediaBrowser.Providers/Subtitles/OpenSubtitleDownloader.cs+++ b/MediaBrowser.Providers/Subtitles/OpenSubtitleDownloader.cs@@ -1,4 +1,5 @@using MediaBrowser.Common.Events;+using MediaBrowser.Common.Extensions;using MediaBrowser.Common.Net;using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Security;@@ -115,8 +116,14 @@ namespace MediaBrowser.Providers.Subtitlesthrow new ApplicationException("Invalid response type");}- var res = ((MethodResponseSubtitleDownload)resultDownLoad).Results.First();- var data = Convert.FromBase64String(res.Data);+ var results = ((MethodResponseSubtitleDownload)resultDownLoad).Results;++ if (results.Count == 0)+ {+ throw new ResourceNotFoundException("Subtitle with Id " + ossId + " was not found.");+ }++ var data = Convert.FromBase64String(results.First().Data);return new SubtitleResponse{diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.jsonindex fcdb0bf83e..8963bc0afe 100644--- a/MediaBrowser.Server.Implementations/Localization/Server/server.json+++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json@@ -707,13 +707,14 @@"OptionReportByteRangeSeekingWhenTranscodingHelp": "This is required for some devices that don't time seek very well.","HeaderSubtitleDownloadingHelp": "When Media Browser scans your video files it can search for missing subtitles, and download them using a subtitle provider such as OpenSubtitles.org.","HeaderDownloadSubtitlesFor": "Download subtitles for:",- "LabelRequireTextSubtitles": "Download even if the video already contains graphical subtitles",- "LabelRequireTextSubtitlesHelp": "Keeping text versions of subtitles will result in more efficient delivery to mobile clients.",+ "LabelSkipIfGraphicalSubsPresent": "Skip if the video already contains graphical subtitles",+ "LabelSkipIfGraphicalSubsPresentHelp": "Keeping text versions of subtitles will result in more efficient delivery to mobile clients.","TabSubtitles": "Subtitles","LabelOpenSubtitlesUsername": "Open Subtitles username:","LabelOpenSubtitlesPassword": "Open Subtitles password:","LabelAudioLanguagePreferenceHelp": "If empty, the default audio track will be selected, regardless of language.","LabelDownloadLanguages": "Download languages:","ButtonRegister": "Register",- "HeaderSubtitleDownloadingMoreHelp": "Subtitles are considered missing when the audio track is in a foreign language, and there are no subtitles available in the preferred language."+ "LabelSkipIfAudioTrackPresent": "Skip if the video has an audio track with the download language",+ "LabelSkipIfAudioTrackPresentHelp": "Uncheck this to ensure all videos have subtitles, regardless of audio language."}\ No newline at end of file