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 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;
}
}
}

@ -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);

@ -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;

@ -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
{

@ -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."
}
Loading…
Cancel
Save