aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-05-07 22:16:11 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-05-07 22:16:11 -0400
commit0b7e39877295bc6b879a95b8572b5fa62179b8c0 (patch)
tree676d9b72543c8a0801e8d879070f471abd8af0e6
parent37b66c5b10cc6e076880dce4269a84d1da6ed259 (diff)
add additional subtitle setting
-rw-r--r--MediaBrowser.Model/Configuration/ServerConfiguration.cs5
-rw-r--r--MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs3
-rw-r--r--MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs13
-rw-r--r--MediaBrowser.Providers/Subtitles/OpenSubtitleDownloader.cs11
-rw-r--r--MediaBrowser.Server.Implementations/Localization/Server/server.json7
5 files changed, 27 insertions, 12 deletions
diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
index e92d33574..b2c499b9a 100644
--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs
+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
@@ -318,7 +318,8 @@ namespace MediaBrowser.Model.Configuration
public 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.Configuration
public SubtitleOptions()
{
DownloadLanguages = new string[] { };
+
+ SkipIfAudioTrackMatches = true;
}
}
}
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
index a78c27aa4..d2f8de8e4 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.cs
index a20dc4d29..3e11fd85e 100644
--- a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs
+++ b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs
@@ -26,7 +26,8 @@ namespace MediaBrowser.Providers.MediaInfo
public 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.MediaInfo
private 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.cs
index ac0439737..cfb322bc6 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.Subtitles
throw 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.json
index fcdb0bf83..8963bc0af 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