diff options
| author | Bond_009 <bond.009@outlook.com> | 2023-05-22 22:48:09 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2023-06-28 17:07:57 +0200 |
| commit | b5f0760db8dba96e9edd67d4b9c914cf25c3d26a (patch) | |
| tree | a60f87f379ddbfe2436d03b3b1a8f48cbc3b7490 /MediaBrowser.Providers | |
| parent | f954dc5c969ef5654c31bec7a81b0b92b38637ae (diff) | |
Use RegexGenerator where possible
Diffstat (limited to 'MediaBrowser.Providers')
| -rw-r--r-- | MediaBrowser.Providers/MediaInfo/AudioFileProber.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs | 9 |
2 files changed, 10 insertions, 6 deletions
diff --git a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs index e1dcbc993..a7e8f774c 100644 --- a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs +++ b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.Providers.MediaInfo /// <summary> /// Probes audio files for metadata. /// </summary> - public class AudioFileProber + public partial class AudioFileProber { // Default LUFS value for use with the web interface, at -18db gain will be 1(no db gain). private const float DefaultLUFSValue = -18; @@ -58,6 +58,9 @@ namespace MediaBrowser.Providers.MediaInfo _mediaSourceManager = mediaSourceManager; } + [GeneratedRegex("I:\\s+(.*?)\\s+LUFS")] + private static partial Regex LUFSRegex(); + /// <summary> /// Probes the specified item for metadata. /// </summary> @@ -129,7 +132,7 @@ namespace MediaBrowser.Providers.MediaInfo output = await process.StandardError.ReadToEndAsync(cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); - MatchCollection split = Regex.Matches(output, @"I:\s+(.*?)\s+LUFS"); + MatchCollection split = LUFSRegex().Matches(output); if (split.Count != 0) { diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs b/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs index 516eee758..a7c93ac4c 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs @@ -11,10 +11,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb /// <summary> /// Utilities for the TMDb provider. /// </summary> - public static class TmdbUtils + public static partial class TmdbUtils { - private static readonly Regex _nonWords = new(@"[\W_]+", RegexOptions.Compiled); - /// <summary> /// URL of the TMDb instance to use. /// </summary> @@ -50,6 +48,9 @@ namespace MediaBrowser.Providers.Plugins.Tmdb PersonKind.Producer }; + [GeneratedRegex(@"[\W_]+")] + private static partial Regex NonWordRegex(); + /// <summary> /// Cleans the name according to TMDb requirements. /// </summary> @@ -58,7 +59,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb public static string CleanName(string name) { // TMDb expects a space separated list of words make sure that is the case - return _nonWords.Replace(name, " "); + return NonWordRegex().Replace(name, " "); } /// <summary> |
