mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-26 20:16:33 +00:00
Make MediaBrowser.MediaEncoding warnings free
This commit is contained in:
@@ -415,7 +415,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
|
||||
// FFmpeg automatically convert character encoding when it is UTF-16
|
||||
// If we specify character encoding, it rejects with "do not specify a character encoding" and "Unable to recode subtitle event"
|
||||
if ((inputPath.EndsWith(".smi") || inputPath.EndsWith(".sami")) &&
|
||||
if ((inputPath.EndsWith(".smi", StringComparison.Ordinal) || inputPath.EndsWith(".sami", StringComparison.Ordinal)) &&
|
||||
(encodingParam.Equals("UTF-16BE", StringComparison.OrdinalIgnoreCase) ||
|
||||
encodingParam.Equals("UTF-16LE", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
@@ -506,7 +506,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
string.Format(CultureInfo.InvariantCulture, "ffmpeg subtitle conversion failed for {0}", inputPath));
|
||||
}
|
||||
|
||||
await SetAssFont(outputPath).ConfigureAwait(false);
|
||||
await SetAssFont(outputPath, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
_logger.LogInformation("ffmpeg subtitle conversion succeeded for {Path}", inputPath);
|
||||
}
|
||||
@@ -668,7 +668,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
|
||||
if (string.Equals(outputCodec, "ass", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
await SetAssFont(outputPath).ConfigureAwait(false);
|
||||
await SetAssFont(outputPath, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,8 +676,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
/// Sets the ass font.
|
||||
/// </summary>
|
||||
/// <param name="file">The file.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <c>System.Threading.CancellationToken.None</c>.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private async Task SetAssFont(string file)
|
||||
private async Task SetAssFont(string file, CancellationToken cancellationToken = default)
|
||||
{
|
||||
_logger.LogInformation("Setting ass font within {File}", file);
|
||||
|
||||
@@ -692,14 +693,14 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
text = await reader.ReadToEndAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var newText = text.Replace(",Arial,", ",Arial Unicode MS,");
|
||||
var newText = text.Replace(",Arial,", ",Arial Unicode MS,", StringComparison.Ordinal);
|
||||
|
||||
if (!string.Equals(text, newText))
|
||||
if (!string.Equals(text, newText, StringComparison.Ordinal))
|
||||
{
|
||||
using (var fileStream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||
using (var writer = new StreamWriter(fileStream, encoding))
|
||||
{
|
||||
writer.Write(newText);
|
||||
await writer.WriteAsync(newText.AsMemory(), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -736,7 +737,7 @@ 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") || path.EndsWith(".srt"))
|
||||
if ((path.EndsWith(".ass", StringComparison.Ordinal) || path.EndsWith(".ssa", StringComparison.Ordinal) || path.EndsWith(".srt", StringComparison.Ordinal))
|
||||
&& (string.Equals(charset, "utf-16le", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(charset, "utf-16be", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user