From b5f0760db8dba96e9edd67d4b9c914cf25c3d26a Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Mon, 22 May 2023 22:48:09 +0200 Subject: Use RegexGenerator where possible --- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs') diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 4e63d205c..0885fbe92 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.MediaEncoding.Encoder /// /// Class MediaEncoder. /// - public class MediaEncoder : IMediaEncoder, IDisposable + public partial class MediaEncoder : IMediaEncoder, IDisposable { /// /// The default SDR image extraction timeout in milliseconds. @@ -142,6 +142,9 @@ namespace MediaBrowser.MediaEncoding.Encoder /// public bool IsVaapiDeviceSupportVulkanFmtModifier => _isVaapiDeviceSupportVulkanFmtModifier; + [GeneratedRegex(@"[^\/\\]+?(\.[^\/\\\n.]+)?$")] + private static partial Regex FfprobePathRegex(); + /// /// Run at startup or if the user removes a Custom path from transcode page. /// Sets global variables FFmpegPath. @@ -176,7 +179,7 @@ namespace MediaBrowser.MediaEncoding.Encoder if (_ffmpegPath is not null) { // Determine a probe path from the mpeg path - _ffprobePath = Regex.Replace(_ffmpegPath, @"[^\/\\]+?(\.[^\/\\\n.]+)?$", @"ffprobe$1"); + _ffprobePath = FfprobePathRegex().Replace(_ffmpegPath, @"ffprobe$1"); // Interrogate to understand what coders are supported var validator = new EncoderValidator(_logger, _ffmpegPath); @@ -416,8 +419,8 @@ namespace MediaBrowser.MediaEncoding.Encoder public Task GetMediaInfo(MediaInfoRequest request, CancellationToken cancellationToken) { var extractChapters = request.MediaType == DlnaProfileType.Video && request.ExtractChapters; - string analyzeDuration = string.Empty; - string ffmpegAnalyzeDuration = _config.GetFFmpegAnalyzeDuration() ?? string.Empty; + var analyzeDuration = string.Empty; + var ffmpegAnalyzeDuration = _config.GetFFmpegAnalyzeDuration() ?? string.Empty; if (request.MediaSource.AnalyzeDurationMs > 0) { -- cgit v1.2.3