mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-08 03:12:08 +01:00
Add some analyzers to MediaBrowser.MediaEncoding
This commit is contained in:
@@ -34,6 +34,12 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
|
||||
/// <summary>
|
||||
/// The _semaphoreLocks.
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<string, SemaphoreSlim> _semaphoreLocks =
|
||||
new ConcurrentDictionary<string, SemaphoreSlim>();
|
||||
|
||||
public SubtitleEncoder(
|
||||
ILibraryManager libraryManager,
|
||||
ILogger<SubtitleEncoder> logger,
|
||||
@@ -269,25 +275,6 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
return new SubtitleInfo(subtitleStream.Path, protocol, currentFormat, true);
|
||||
}
|
||||
|
||||
private struct SubtitleInfo
|
||||
{
|
||||
public SubtitleInfo(string path, MediaProtocol protocol, string format, bool isExternal)
|
||||
{
|
||||
Path = path;
|
||||
Protocol = protocol;
|
||||
Format = format;
|
||||
IsExternal = isExternal;
|
||||
}
|
||||
|
||||
public string Path { get; set; }
|
||||
|
||||
public MediaProtocol Protocol { get; set; }
|
||||
|
||||
public string Format { get; set; }
|
||||
|
||||
public bool IsExternal { get; set; }
|
||||
}
|
||||
|
||||
private ISubtitleParser GetReader(string format, bool throwIfMissing)
|
||||
{
|
||||
if (string.IsNullOrEmpty(format))
|
||||
@@ -360,12 +347,6 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
throw new ArgumentException("Unsupported format: " + format);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _semaphoreLocks.
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<string, SemaphoreSlim> _semaphoreLocks =
|
||||
new ConcurrentDictionary<string, SemaphoreSlim>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lock.
|
||||
/// </summary>
|
||||
@@ -414,7 +395,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// The <c>inputPath</c> or <c>outputPath</c> is <c>null</c>
|
||||
/// The <c>inputPath</c> or <c>outputPath</c> is <c>null</c>.
|
||||
/// </exception>
|
||||
private async Task ConvertTextSubtitleToSrtInternal(string inputPath, string language, MediaProtocol inputProtocol, string outputPath, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -438,7 +419,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
(encodingParam.Equals("UTF-16BE", StringComparison.OrdinalIgnoreCase) ||
|
||||
encodingParam.Equals("UTF-16LE", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
encodingParam = "";
|
||||
encodingParam = string.Empty;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(encodingParam))
|
||||
{
|
||||
@@ -540,7 +521,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
/// <param name="outputPath">The output path.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
/// <exception cref="ArgumentException">Must use inputPath list overload</exception>
|
||||
/// <exception cref="ArgumentException">Must use inputPath list overload.</exception>
|
||||
private async Task ExtractTextSubtitle(
|
||||
string[] inputFiles,
|
||||
MediaProtocol protocol,
|
||||
@@ -759,7 +740,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
&& (string.Equals(charset, "utf-16le", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(charset, "utf-16be", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
charset = "";
|
||||
charset = string.Empty;
|
||||
}
|
||||
|
||||
_logger.LogDebug("charset {0} detected for {Path}", charset ?? "null", path);
|
||||
@@ -790,5 +771,24 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
throw new ArgumentOutOfRangeException(nameof(protocol));
|
||||
}
|
||||
}
|
||||
|
||||
private struct SubtitleInfo
|
||||
{
|
||||
public SubtitleInfo(string path, MediaProtocol protocol, string format, bool isExternal)
|
||||
{
|
||||
Path = path;
|
||||
Protocol = protocol;
|
||||
Format = format;
|
||||
IsExternal = isExternal;
|
||||
}
|
||||
|
||||
public string Path { get; set; }
|
||||
|
||||
public MediaProtocol Protocol { get; set; }
|
||||
|
||||
public string Format { get; set; }
|
||||
|
||||
public bool IsExternal { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user