add additional subtitle setting

pull/702/head
Luke Pulverenti 10 years ago
parent 37b66c5b10
commit 0b7e398772

@ -318,7 +318,8 @@ namespace MediaBrowser.Model.Configuration
public class SubtitleOptions public class SubtitleOptions
{ {
public bool RequireTextSubtitles { get; set; } public bool SkipIfGraphicalSubtitlesPresent { get; set; }
public bool SkipIfAudioTrackMatches { get; set; }
public string[] DownloadLanguages { get; set; } public string[] DownloadLanguages { get; set; }
public bool DownloadMovieSubtitles { get; set; } public bool DownloadMovieSubtitles { get; set; }
public bool DownloadEpisodeSubtitles { get; set; } public bool DownloadEpisodeSubtitles { get; set; }
@ -329,6 +330,8 @@ namespace MediaBrowser.Model.Configuration
public SubtitleOptions() public SubtitleOptions()
{ {
DownloadLanguages = new string[] { }; DownloadLanguages = new string[] { };
SkipIfAudioTrackMatches = true;
} }
} }
} }

@ -472,7 +472,8 @@ namespace MediaBrowser.Providers.MediaInfo
.DownloadSubtitles(video, .DownloadSubtitles(video,
currentStreams, currentStreams,
externalSubtitleStreams, externalSubtitleStreams,
_config.Configuration.SubtitleOptions.RequireTextSubtitles, _config.Configuration.SubtitleOptions.SkipIfGraphicalSubtitlesPresent,
_config.Configuration.SubtitleOptions.SkipIfAudioTrackMatches,
_config.Configuration.SubtitleOptions.DownloadLanguages, _config.Configuration.SubtitleOptions.DownloadLanguages,
cancellationToken).ConfigureAwait(false); cancellationToken).ConfigureAwait(false);

@ -26,7 +26,8 @@ namespace MediaBrowser.Providers.MediaInfo
public async Task<List<string>> DownloadSubtitles(Video video, public async Task<List<string>> DownloadSubtitles(Video video,
List<MediaStream> internalMediaStreams, List<MediaStream> internalMediaStreams,
List<MediaStream> externalSubtitleStreams, List<MediaStream> externalSubtitleStreams,
bool forceExternal, bool skipIfGraphicalSubtitlesPresent,
bool skipIfAudioTrackMatches,
IEnumerable<string> languages, IEnumerable<string> languages,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
@ -58,7 +59,7 @@ namespace MediaBrowser.Providers.MediaInfo
{ {
try 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); .ConfigureAwait(false);
if (downloaded) if (downloaded)
@ -78,7 +79,8 @@ namespace MediaBrowser.Providers.MediaInfo
private async Task<bool> DownloadSubtitles(Video video, private async Task<bool> DownloadSubtitles(Video video,
List<MediaStream> internalMediaStreams, List<MediaStream> internalMediaStreams,
IEnumerable<MediaStream> externalSubtitleStreams, IEnumerable<MediaStream> externalSubtitleStreams,
bool forceExternal, bool skipIfGraphicalSubtitlesPresent,
bool skipIfAudioTrackMatches,
string language, string language,
SubtitleMediaType mediaType, SubtitleMediaType mediaType,
CancellationToken cancellationToken) CancellationToken cancellationToken)
@ -90,13 +92,14 @@ namespace MediaBrowser.Providers.MediaInfo
} }
// There's already an audio stream for this language // 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; return false;
} }
// There's an internal subtitle stream for this language // 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))) internalMediaStreams.Any(i => i.Type == MediaStreamType.Subtitle && string.Equals(i.Language, language, StringComparison.OrdinalIgnoreCase)))
{ {
return false; return false;

@ -1,4 +1,5 @@
using MediaBrowser.Common.Events; using MediaBrowser.Common.Events;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Security; using MediaBrowser.Controller.Security;
@ -115,8 +116,14 @@ namespace MediaBrowser.Providers.Subtitles
throw new ApplicationException("Invalid response type"); throw new ApplicationException("Invalid response type");
} }
var res = ((MethodResponseSubtitleDownload)resultDownLoad).Results.First(); var results = ((MethodResponseSubtitleDownload)resultDownLoad).Results;
var data = Convert.FromBase64String(res.Data);
if (results.Count == 0)
{
throw new ResourceNotFoundException("Subtitle with Id " + ossId + " was not found.");
}
var data = Convert.FromBase64String(results.First().Data);
return new SubtitleResponse return new SubtitleResponse
{ {

@ -707,13 +707,14 @@
"OptionReportByteRangeSeekingWhenTranscodingHelp": "This is required for some devices that don't time seek very well.", "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.", "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:", "HeaderDownloadSubtitlesFor": "Download subtitles for:",
"LabelRequireTextSubtitles": "Download even if the video already contains graphical subtitles", "LabelSkipIfGraphicalSubsPresent": "Skip if the video already contains graphical subtitles",
"LabelRequireTextSubtitlesHelp": "Keeping text versions of subtitles will result in more efficient delivery to mobile clients.", "LabelSkipIfGraphicalSubsPresentHelp": "Keeping text versions of subtitles will result in more efficient delivery to mobile clients.",
"TabSubtitles": "Subtitles", "TabSubtitles": "Subtitles",
"LabelOpenSubtitlesUsername": "Open Subtitles username:", "LabelOpenSubtitlesUsername": "Open Subtitles username:",
"LabelOpenSubtitlesPassword": "Open Subtitles password:", "LabelOpenSubtitlesPassword": "Open Subtitles password:",
"LabelAudioLanguagePreferenceHelp": "If empty, the default audio track will be selected, regardless of language.", "LabelAudioLanguagePreferenceHelp": "If empty, the default audio track will be selected, regardless of language.",
"LabelDownloadLanguages": "Download languages:", "LabelDownloadLanguages": "Download languages:",
"ButtonRegister": "Register", "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."
} }
Loading…
Cancel
Save