mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-17 22:43:07 +03:00
Use RegexGenerator where possible
This commit is contained in:
@@ -10,7 +10,7 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.Encoder
|
||||
{
|
||||
public class EncoderValidator
|
||||
public partial class EncoderValidator
|
||||
{
|
||||
private static readonly string[] _requiredDecoders = new[]
|
||||
{
|
||||
@@ -160,6 +160,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
|
||||
public static Version? MaxVersion { get; } = null;
|
||||
|
||||
[GeneratedRegex(@"^ffmpeg version n?((?:[0-9]+\.?)+)")]
|
||||
private static partial Regex FfmpegVersionRegex();
|
||||
|
||||
[GeneratedRegex(@"((?<name>lib\w+)\s+(?<major>[0-9]+)\.\s*(?<minor>[0-9]+))", RegexOptions.Multiline)]
|
||||
private static partial Regex LibraryRegex();
|
||||
|
||||
public bool ValidateVersion()
|
||||
{
|
||||
string output;
|
||||
@@ -278,7 +284,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
internal Version? GetFFmpegVersionInternal(string output)
|
||||
{
|
||||
// For pre-built binaries the FFmpeg version should be mentioned at the very start of the output
|
||||
var match = Regex.Match(output, @"^ffmpeg version n?((?:[0-9]+\.?)+)");
|
||||
var match = FfmpegVersionRegex().Match(output);
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
@@ -326,10 +332,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
{
|
||||
var map = new Dictionary<string, Version>();
|
||||
|
||||
foreach (Match match in Regex.Matches(
|
||||
output,
|
||||
@"((?<name>lib\w+)\s+(?<major>[0-9]+)\.\s*(?<minor>[0-9]+))",
|
||||
RegexOptions.Multiline))
|
||||
foreach (Match match in LibraryRegex().Matches(output))
|
||||
{
|
||||
var version = new Version(
|
||||
int.Parse(match.Groups["major"].ValueSpan, CultureInfo.InvariantCulture),
|
||||
|
||||
Reference in New Issue
Block a user