diff options
Diffstat (limited to 'MediaBrowser.MediaEncoding')
9 files changed, 67 insertions, 110 deletions
diff --git a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs index 22abf93ac..db177ff76 100644 --- a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs +++ b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs @@ -62,14 +62,14 @@ namespace MediaBrowser.MediaEncoding.Attachments var mediaSources = await _mediaSourceManager.GetPlaybackMediaSources(item, null, true, false, cancellationToken).ConfigureAwait(false); var mediaSource = mediaSources .FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase)); - if (mediaSource == null) + if (mediaSource is null) { throw new ResourceNotFoundException($"MediaSource {mediaSourceId} not found"); } var mediaAttachment = mediaSource.MediaAttachments .FirstOrDefault(i => i.Index == attachmentStreamIndex); - if (mediaAttachment == null) + if (mediaAttachment is null) { throw new ResourceNotFoundException($"MediaSource {mediaSourceId} has no attachment with stream index {attachmentStreamIndex}"); } @@ -145,15 +145,8 @@ namespace MediaBrowser.MediaEncoding.Attachments bool isExternal, CancellationToken cancellationToken) { - if (string.IsNullOrEmpty(inputPath)) - { - throw new ArgumentNullException(nameof(inputPath)); - } - - if (string.IsNullOrEmpty(outputPath)) - { - throw new ArgumentNullException(nameof(outputPath)); - } + ArgumentException.ThrowIfNullOrEmpty(inputPath); + ArgumentException.ThrowIfNullOrEmpty(outputPath); Directory.CreateDirectory(outputPath); @@ -300,15 +293,9 @@ namespace MediaBrowser.MediaEncoding.Attachments string outputPath, CancellationToken cancellationToken) { - if (string.IsNullOrEmpty(inputPath)) - { - throw new ArgumentNullException(nameof(inputPath)); - } + ArgumentException.ThrowIfNullOrEmpty(inputPath); - if (string.IsNullOrEmpty(outputPath)) - { - throw new ArgumentNullException(nameof(outputPath)); - } + ArgumentException.ThrowIfNullOrEmpty(outputPath); Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs index 409379c35..7e026b42e 100644 --- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs +++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs @@ -34,7 +34,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo get { var parentFolder = System.IO.Path.GetDirectoryName(_impl.FullName); - if (parentFolder != null) + if (parentFolder is not null) { return new BdInfoDirectoryInfo(_fileSystem, parentFolder); } diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs index 6ebaa4fff..3e53cbf29 100644 --- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs +++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo MediaStreams = Array.Empty<MediaStream>() }; - if (playlist == null) + if (playlist is null) { return outputStream; } @@ -89,7 +89,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo outputStream.PlaylistName = playlist.Name; - if (playlist.StreamClips != null && playlist.StreamClips.Any()) + if (playlist.StreamClips is not null && playlist.StreamClips.Any()) { // Get the files in the playlist outputStream.Files = playlist.StreamClips.Select(i => i.StreamFile.Name).ToArray(); diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index 8c8fc6b0f..8479b7d50 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -188,11 +188,11 @@ namespace MediaBrowser.MediaEncoding.Encoder // Work out what the version under test is var version = GetFFmpegVersionInternal(versionOutput); - _logger.LogInformation("Found ffmpeg version {Version}", version != null ? version.ToString() : "unknown"); + _logger.LogInformation("Found ffmpeg version {Version}", version is not null ? version.ToString() : "unknown"); - if (version == null) + if (version is null) { - if (MaxVersion != null) // Version is unknown + if (MaxVersion is not null) // Version is unknown { if (MinVersion == MaxVersion) { @@ -215,7 +215,7 @@ namespace MediaBrowser.MediaEncoding.Encoder _logger.LogWarning("FFmpeg validation: The minimum recommended version is {MinVersion}", MinVersion); return false; } - else if (MaxVersion != null && version > MaxVersion) // Version is above what we recommend + else if (MaxVersion is not null && version > MaxVersion) // Version is above what we recommend { _logger.LogWarning("FFmpeg validation: The maximum recommended version is {MaxVersion}", MaxVersion); return false; diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index b7c49ed99..91bf42b15 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -75,7 +75,8 @@ namespace MediaBrowser.MediaEncoding.Encoder private bool _isVaapiDeviceInteli965 = false; private bool _isVaapiDeviceSupportVulkanFmtModifier = false; - private static string[] _vulkanFmtModifierExts = { + private static string[] _vulkanFmtModifierExts = + { "VK_KHR_sampler_ycbcr_conversion", "VK_EXT_image_drm_format_modifier", "VK_KHR_external_memory_fd", @@ -156,7 +157,7 @@ namespace MediaBrowser.MediaEncoding.Encoder _configurationManager.SaveConfiguration("encoding", options); // Only if mpeg path is set, try and set path to probe - if (_ffmpegPath != null) + if (_ffmpegPath is not null) { // Determine a probe path from the mpeg path _ffprobePath = Regex.Replace(_ffmpegPath, @"[^\/\\]+?(\.[^\/\\\n.]+)?$", @"ffprobe$1"); @@ -414,8 +415,6 @@ namespace MediaBrowser.MediaEncoding.Encoder analyzeDuration = "-analyzeduration " + ffmpegAnalyzeDuration; } - var forceEnableLogging = request.MediaSource.Protocol != MediaProtocol.File; - return GetMediaInfoInternal( GetInputArgument(inputFile, request.MediaSource), request.MediaSource.Path, @@ -424,7 +423,6 @@ namespace MediaBrowser.MediaEncoding.Encoder analyzeDuration, request.MediaType == DlnaProfileType.Audio, request.MediaSource.VideoType, - forceEnableLogging, cancellationToken); } @@ -472,7 +470,6 @@ namespace MediaBrowser.MediaEncoding.Encoder string probeSizeArgument, bool isAudio, VideoType? videoType, - bool forceEnableLogging, CancellationToken cancellationToken) { var args = extractChapters @@ -487,7 +484,7 @@ namespace MediaBrowser.MediaEncoding.Encoder CreateNoWindow = true, UseShellExecute = false, - // Must consume both or ffmpeg may hang due to deadlocks. See comments below. + // Must consume both or ffmpeg may hang due to deadlocks. RedirectStandardOutput = true, FileName = _ffprobePath, @@ -499,21 +496,13 @@ namespace MediaBrowser.MediaEncoding.Encoder EnableRaisingEvents = true }; - if (forceEnableLogging) - { - _logger.LogInformation("{ProcessFileName} {ProcessArgs}", process.StartInfo.FileName, process.StartInfo.Arguments); - } - else - { - _logger.LogDebug("{ProcessFileName} {ProcessArgs}", process.StartInfo.FileName, process.StartInfo.Arguments); - } + _logger.LogInformation("Starting {ProcessFileName} with args {ProcessArgs}", _ffprobePath, args); using (var processWrapper = new ProcessWrapper(process, this)) { await using var memoryStream = new MemoryStream(); - _logger.LogDebug("Starting ffprobe with args {Args}", args); StartProcess(processWrapper); - await process.StandardOutput.BaseStream.CopyToAsync(memoryStream, cancellationToken: cancellationToken); + await process.StandardOutput.BaseStream.CopyToAsync(memoryStream, cancellationToken); memoryStream.Seek(0, SeekOrigin.Begin); InternalMediaInfoResult result; try @@ -521,7 +510,7 @@ namespace MediaBrowser.MediaEncoding.Encoder result = await JsonSerializer.DeserializeAsync<InternalMediaInfoResult>( memoryStream, _jsonSerializerOptions, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken).ConfigureAwait(false); } catch { @@ -530,12 +519,12 @@ namespace MediaBrowser.MediaEncoding.Encoder throw; } - if (result == null || (result.Streams == null && result.Format == null)) + if (result is null || (result.Streams is null && result.Format is null)) { throw new FfmpegException("ffprobe failed - streams and format are both null."); } - if (result.Streams != null) + if (result.Streams is not null) { // Normalize aspect ratio if invalid foreach (var stream in result.Streams) @@ -634,13 +623,9 @@ namespace MediaBrowser.MediaEncoding.Encoder return imageResolutionParameter; } - private async Task<string> ExtractImageInternal(string inputPath, string container, MediaStream videoStream, int? imageStreamIndex, Video3DFormat? threedFormat, TimeSpan? offset, bool useIFrame, ImageFormat? targetFormat, CancellationToken cancellationToken) { - if (string.IsNullOrEmpty(inputPath)) - { - throw new ArgumentNullException(nameof(inputPath)); - } + ArgumentException.ThrowIfNullOrEmpty(inputPath); var outputExtension = targetFormat switch { @@ -660,7 +645,7 @@ namespace MediaBrowser.MediaEncoding.Encoder var filters = new List<string>(); // deinterlace using bwdif algorithm for video stream. - if (videoStream != null && videoStream.IsInterlaced) + if (videoStream is not null && videoStream.IsInterlaced) { filters.Add("bwdif=0:-1:0"); } @@ -1017,7 +1002,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { if (!_disposed) { - if (Process != null) + if (Process is not null) { Process.Exited -= OnProcessExited; DisposeProcess(Process); diff --git a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj index afe4ff4e7..375041490 100644 --- a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj +++ b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj @@ -6,13 +6,13 @@ </PropertyGroup> <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> + <TargetFramework>net7.0</TargetFramework> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateDocumentationFile>true</GenerateDocumentationFile> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> - <TreatWarningsAsErrors>false</TreatWarningsAsErrors> + <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors> </PropertyGroup> <ItemGroup> @@ -28,8 +28,8 @@ <ItemGroup> <PackageReference Include="BDInfo" Version="0.7.6.2" /> <PackageReference Include="libse" Version="3.6.5" /> - <PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" /> - <PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" /> + <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" /> + <PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" /> <PackageReference Include="UTF.Unknown" Version="2.5.1" /> </ItemGroup> diff --git a/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs b/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs index 205e84153..1b5b5262a 100644 --- a/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs +++ b/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs @@ -17,17 +17,17 @@ namespace MediaBrowser.MediaEncoding.Probing { ArgumentNullException.ThrowIfNull(result); - if (result.Format?.Tags != null) + if (result.Format?.Tags is not null) { result.Format.Tags = ConvertDictionaryToCaseInsensitive(result.Format.Tags); } - if (result.Streams != null) + if (result.Streams is not null) { // Convert all dictionaries to case insensitive foreach (var stream in result.Streams) { - if (stream.Tags != null) + if (stream.Tags is not null) { stream.Tags = ConvertDictionaryToCaseInsensitive(stream.Tags); } diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index 417f1520f..7a3462b97 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -83,16 +83,16 @@ namespace MediaBrowser.MediaEncoding.Probing var internalStreams = data.Streams ?? Array.Empty<MediaStreamInfo>(); info.MediaStreams = internalStreams.Select(s => GetMediaStream(isAudio, s, data.Format)) - .Where(i => i != null) + .Where(i => i is not null) // Drop subtitle streams if we don't know the codec because it will just cause failures if we don't know how to handle them .Where(i => i.Type != MediaStreamType.Subtitle || !string.IsNullOrWhiteSpace(i.Codec)) .ToList(); info.MediaAttachments = internalStreams.Select(GetMediaAttachment) - .Where(i => i != null) + .Where(i => i is not null) .ToList(); - if (data.Format != null) + if (data.Format is not null) { info.Container = NormalizeFormat(data.Format.FormatName); @@ -110,7 +110,7 @@ namespace MediaBrowser.MediaEncoding.Probing var tagStream = data.Streams?.FirstOrDefault(i => string.Equals(i.CodecType, tagStreamType, StringComparison.OrdinalIgnoreCase)); - if (tagStream?.Tags != null) + if (tagStream?.Tags is not null) { foreach (var (key, value) in tagStream.Tags) { @@ -118,7 +118,7 @@ namespace MediaBrowser.MediaEncoding.Probing } } - if (data.Format?.Tags != null) + if (data.Format?.Tags is not null) { foreach (var (key, value) in data.Format.Tags) { @@ -156,7 +156,7 @@ namespace MediaBrowser.MediaEncoding.Probing else { var artist = tags.GetFirstNotNullNorWhiteSpaceValue("artist"); - info.Artists = artist == null + info.Artists = artist is null ? Array.Empty<string>() : SplitDistinctArtists(artist, _nameDelimiters, true).ToArray(); } @@ -182,7 +182,7 @@ namespace MediaBrowser.MediaEncoding.Probing FetchStudios(info, tags, "copyright"); var iTunExtc = tags.GetFirstNotNullNorWhiteSpaceValue("iTunEXTC"); - if (iTunExtc != null) + if (iTunExtc is not null) { var parts = iTunExtc.Split('|', StringSplitOptions.RemoveEmptyEntries); // Example @@ -199,19 +199,19 @@ namespace MediaBrowser.MediaEncoding.Probing } var iTunXml = tags.GetFirstNotNullNorWhiteSpaceValue("iTunMOVI"); - if (iTunXml != null) + if (iTunXml is not null) { FetchFromItunesInfo(iTunXml, info); } - if (data.Format != null && !string.IsNullOrEmpty(data.Format.Duration)) + if (data.Format is not null && !string.IsNullOrEmpty(data.Format.Duration)) { info.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.Format.Duration, CultureInfo.InvariantCulture)).Ticks; } FetchWtvInfo(info, data); - if (data.Chapters != null) + if (data.Chapters is not null) { info.Chapters = data.Chapters.Select(GetChapterInfo).ToArray(); } @@ -459,7 +459,7 @@ namespace MediaBrowser.MediaEncoding.Probing using (var subtree = reader.ReadSubtree()) { var dict = GetNameValuePair(subtree); - if (dict != null) + if (dict is not null) { pairs.Add(dict); } @@ -614,7 +614,7 @@ namespace MediaBrowser.MediaEncoding.Probing attachment.CodecTag = streamInfo.CodecTagString; } - if (streamInfo.Tags != null) + if (streamInfo.Tags is not null) { attachment.FileName = GetDictionaryValue(streamInfo.Tags, "filename"); attachment.MimeType = GetDictionaryValue(streamInfo.Tags, "mimetype"); @@ -680,7 +680,7 @@ namespace MediaBrowser.MediaEncoding.Probing stream.CodecTag = streamInfo.CodecTagString; } - if (streamInfo.Tags != null) + if (streamInfo.Tags is not null) { stream.Language = GetDictionaryValue(streamInfo.Tags, "language"); stream.Comment = GetDictionaryValue(streamInfo.Tags, "comment"); @@ -855,7 +855,7 @@ namespace MediaBrowser.MediaEncoding.Probing stream.ColorPrimaries = streamInfo.ColorPrimaries; } - if (streamInfo.SideDataList != null) + if (streamInfo.SideDataList is not null) { foreach (var data in streamInfo.SideDataList) { @@ -899,7 +899,7 @@ namespace MediaBrowser.MediaEncoding.Probing // The bitrate info of FLAC musics and some videos is included in formatInfo. if (bitrate == 0 - && formatInfo != null + && formatInfo is not null && !string.IsNullOrEmpty(formatInfo.BitRate) && (stream.Type == MediaStreamType.Video || (isAudio && stream.Type == MediaStreamType.Audio))) { @@ -934,7 +934,7 @@ namespace MediaBrowser.MediaEncoding.Probing { var durationInSeconds = GetRuntimeSecondsFromTags(streamInfo); var bytes = GetNumberOfBytesFromTags(streamInfo); - if (durationInSeconds != null && bytes != null) + if (durationInSeconds is not null && bytes is not null) { var bps = Convert.ToInt32(bytes * 8 / durationInSeconds, CultureInfo.InvariantCulture); if (bps > 0) @@ -945,7 +945,7 @@ namespace MediaBrowser.MediaEncoding.Probing } var disposition = streamInfo.Disposition; - if (disposition != null) + if (disposition is not null) { if (disposition.GetValueOrDefault("default") == 1) { @@ -989,7 +989,7 @@ namespace MediaBrowser.MediaEncoding.Probing /// <returns>System.String.</returns> private string GetDictionaryValue(IReadOnlyDictionary<string, string> tags, string key) { - if (tags == null) + if (tags is null) { return null; } @@ -1121,7 +1121,7 @@ namespace MediaBrowser.MediaEncoding.Probing { // Get the first info stream var stream = result.Streams?.FirstOrDefault(s => string.Equals(s.CodecType, "audio", StringComparison.OrdinalIgnoreCase)); - if (stream == null) + if (stream is null) { return; } @@ -1144,7 +1144,7 @@ namespace MediaBrowser.MediaEncoding.Probing private int? GetBPSFromTags(MediaStreamInfo streamInfo) { - if (streamInfo?.Tags == null) + if (streamInfo?.Tags is null) { return null; } @@ -1161,7 +1161,7 @@ namespace MediaBrowser.MediaEncoding.Probing private double? GetRuntimeSecondsFromTags(MediaStreamInfo streamInfo) { - if (streamInfo?.Tags == null) + if (streamInfo?.Tags is null) { return null; } @@ -1177,7 +1177,7 @@ namespace MediaBrowser.MediaEncoding.Probing private long? GetNumberOfBytesFromTags(MediaStreamInfo streamInfo) { - if (streamInfo?.Tags == null) + if (streamInfo?.Tags is null) { return null; } @@ -1195,7 +1195,7 @@ namespace MediaBrowser.MediaEncoding.Probing private void SetSize(InternalMediaInfoResult data, MediaInfo info) { - if (data.Format == null) + if (data.Format is null) { return; } @@ -1294,7 +1294,7 @@ namespace MediaBrowser.MediaEncoding.Probing // Set album artist var albumArtist = tags.GetFirstNotNullNorWhiteSpaceValue("albumartist", "album artist", "album_artist"); - audio.AlbumArtists = albumArtist != null + audio.AlbumArtists = albumArtist is not null ? SplitDistinctArtists(albumArtist, _nameDelimiters, true).ToArray() : Array.Empty<string>(); @@ -1489,7 +1489,7 @@ namespace MediaBrowser.MediaEncoding.Probing { var info = new ChapterInfo(); - if (chapter.Tags != null && chapter.Tags.TryGetValue("title", out string name)) + if (chapter.Tags is not null && chapter.Tags.TryGetValue("title", out string name)) { info.Name = name; } @@ -1510,7 +1510,7 @@ namespace MediaBrowser.MediaEncoding.Probing { var tags = data.Format?.Tags; - if (tags == null) + if (tags is null) { return; } diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index 9185faf67..b7c2fd7b1 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -174,12 +174,12 @@ namespace MediaBrowser.MediaEncoding.Subtitles var result = CharsetDetector.DetectFromStream(stream).Detected; stream.Position = 0; - if (result != null) + if (result is not null) { _logger.LogDebug("charset {CharSet} detected for {Path}", result.EncodingName, fileInfo.Path); using var reader = new StreamReader(stream, result.Encoding); - var text = await reader.ReadToEndAsync().ConfigureAwait(false); + var text = await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false); return new MemoryStream(Encoding.UTF8.GetBytes(text)); } @@ -249,17 +249,14 @@ namespace MediaBrowser.MediaEncoding.Subtitles private bool TryGetWriter(string format, [NotNullWhen(true)] out ISubtitleWriter? value) { + ArgumentException.ThrowIfNullOrEmpty(format); + if (string.Equals(format, SubtitleFormat.ASS, StringComparison.OrdinalIgnoreCase)) { value = new AssWriter(); return true; } - if (string.IsNullOrEmpty(format)) - { - throw new ArgumentNullException(nameof(format)); - } - if (string.Equals(format, "json", StringComparison.OrdinalIgnoreCase)) { value = new JsonWriter(); @@ -355,15 +352,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles private async Task ConvertTextSubtitleToSrtInternal(MediaStream subtitleStream, MediaSourceInfo mediaSource, string outputPath, CancellationToken cancellationToken) { var inputPath = subtitleStream.Path; - if (string.IsNullOrEmpty(inputPath)) - { - throw new ArgumentNullException(nameof(inputPath)); - } + ArgumentException.ThrowIfNullOrEmpty(inputPath); - if (string.IsNullOrEmpty(outputPath)) - { - throw new ArgumentNullException(nameof(outputPath)); - } + ArgumentException.ThrowIfNullOrEmpty(outputPath); Directory.CreateDirectory(Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(outputPath))); @@ -522,15 +513,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles string outputPath, CancellationToken cancellationToken) { - if (string.IsNullOrEmpty(inputPath)) - { - throw new ArgumentNullException(nameof(inputPath)); - } + ArgumentException.ThrowIfNullOrEmpty(inputPath); - if (string.IsNullOrEmpty(outputPath)) - { - throw new ArgumentNullException(nameof(outputPath)); - } + ArgumentException.ThrowIfNullOrEmpty(outputPath); Directory.CreateDirectory(Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(outputPath))); @@ -650,7 +635,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles { encoding = reader.CurrentEncoding; - text = await reader.ReadToEndAsync().ConfigureAwait(false); + text = await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false); } var newText = text.Replace(",Arial,", ",Arial Unicode MS,", StringComparison.Ordinal); |
