Merge remote-tracking branch 'upstream/master' into remove-common-process

This commit is contained in:
Mark Monteiro
2020-04-03 20:22:03 -04:00
188 changed files with 1333 additions and 834 deletions

View File

@@ -732,6 +732,14 @@ namespace MediaBrowser.MediaEncoding.Subtitles
{
var charset = CharsetDetector.DetectFromStream(stream).Detected?.EncodingName;
// UTF16 is automatically converted to UTF8 by FFmpeg, do not specify a character encoding
if ((path.EndsWith(".ass") || path.EndsWith(".ssa"))
&& (string.Equals(charset, "utf-16le", StringComparison.OrdinalIgnoreCase)
|| string.Equals(charset, "utf-16be", StringComparison.OrdinalIgnoreCase)))
{
charset = "";
}
_logger.LogDebug("charset {0} detected for {Path}", charset ?? "null", path);
return charset;
@@ -754,10 +762,10 @@ namespace MediaBrowser.MediaEncoding.Subtitles
return _httpClient.Get(opts);
case MediaProtocol.File:
return Task.FromResult<Stream>(File.OpenRead(path));
default:
throw new ArgumentOutOfRangeException(nameof(protocol));
case MediaProtocol.File:
return Task.FromResult<Stream>(File.OpenRead(path));
default:
throw new ArgumentOutOfRangeException(nameof(protocol));
}
}
}