浏览代码

Update dependency UTF.Unknown to 2.6.0 (#14599)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Bond_009 <bond.009@outlook.com>
renovate[bot] 1 周之前
父节点
当前提交
dea500b26b
共有 2 个文件被更改,包括 8 次插入6 次删除
  1. 1 1
      Directory.Packages.props
  2. 7 5
      MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs

+ 1 - 1
Directory.Packages.props

@@ -87,7 +87,7 @@
     <PackageVersion Include="TagLibSharp" Version="2.3.0" />
     <PackageVersion Include="TagLibSharp" Version="2.3.0" />
     <PackageVersion Include="z440.atl.core" Version="7.3.0" />
     <PackageVersion Include="z440.atl.core" Version="7.3.0" />
     <PackageVersion Include="TMDbLib" Version="2.2.0" />
     <PackageVersion Include="TMDbLib" Version="2.2.0" />
-    <PackageVersion Include="UTF.Unknown" Version="2.5.1" />
+    <PackageVersion Include="UTF.Unknown" Version="2.6.0" />
     <PackageVersion Include="Xunit.Priority" Version="1.1.6" />
     <PackageVersion Include="Xunit.Priority" Version="1.1.6" />
     <PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
     <PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
     <PackageVersion Include="Xunit.SkippableFact" Version="1.5.23" />
     <PackageVersion Include="Xunit.SkippableFact" Version="1.5.23" />

+ 7 - 5
MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs

@@ -171,14 +171,15 @@ namespace MediaBrowser.MediaEncoding.Subtitles
             {
             {
                 using (var stream = await GetStream(fileInfo.Path, fileInfo.Protocol, cancellationToken).ConfigureAwait(false))
                 using (var stream = await GetStream(fileInfo.Path, fileInfo.Protocol, cancellationToken).ConfigureAwait(false))
                 {
                 {
-                    var result = CharsetDetector.DetectFromStream(stream).Detected;
+                    var result = await CharsetDetector.DetectFromStreamAsync(stream, cancellationToken).ConfigureAwait(false);
+                    var detected = result.Detected;
                     stream.Position = 0;
                     stream.Position = 0;
 
 
-                    if (result is not null)
+                    if (detected is not null)
                     {
                     {
-                        _logger.LogDebug("charset {CharSet} detected for {Path}", result.EncodingName, fileInfo.Path);
+                        _logger.LogDebug("charset {CharSet} detected for {Path}", detected.EncodingName, fileInfo.Path);
 
 
-                        using var reader = new StreamReader(stream, result.Encoding);
+                        using var reader = new StreamReader(stream, detected.Encoding);
                         var text = await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false);
                         var text = await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false);
 
 
                         return new MemoryStream(Encoding.UTF8.GetBytes(text));
                         return new MemoryStream(Encoding.UTF8.GetBytes(text));
@@ -938,7 +939,8 @@ namespace MediaBrowser.MediaEncoding.Subtitles
 
 
             using (var stream = await GetStream(path, mediaSource.Protocol, cancellationToken).ConfigureAwait(false))
             using (var stream = await GetStream(path, mediaSource.Protocol, cancellationToken).ConfigureAwait(false))
             {
             {
-                var charset = CharsetDetector.DetectFromStream(stream).Detected?.EncodingName ?? string.Empty;
+                var result = await CharsetDetector.DetectFromStreamAsync(stream, cancellationToken).ConfigureAwait(false);
+                var charset = result.Detected?.EncodingName ?? string.Empty;
 
 
                 // UTF16 is automatically converted to UTF8 by FFmpeg, do not specify a character encoding
                 // UTF16 is automatically converted to UTF8 by FFmpeg, do not specify a character encoding
                 if ((path.EndsWith(".ass", StringComparison.Ordinal) || path.EndsWith(".ssa", StringComparison.Ordinal) || path.EndsWith(".srt", StringComparison.Ordinal))
                 if ((path.EndsWith(".ass", StringComparison.Ordinal) || path.EndsWith(".ssa", StringComparison.Ordinal) || path.EndsWith(".srt", StringComparison.Ordinal))