From 9ae647d9d23bcd53ef34ba6eeffd0cf17248404d Mon Sep 17 00:00:00 2001 From: Bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Thu, 30 Mar 2023 13:09:33 -0500 Subject: [PATCH] QualityParser - Simplify new expression (IDE0090) --- src/NzbDrone.Core/Parser/QualityParser.cs | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/NzbDrone.Core/Parser/QualityParser.cs b/src/NzbDrone.Core/Parser/QualityParser.cs index dc9639d58..3afa9a722 100644 --- a/src/NzbDrone.Core/Parser/QualityParser.cs +++ b/src/NzbDrone.Core/Parser/QualityParser.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Parser { private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(QualityParser)); - private static readonly Regex SourceRegex = new Regex(@"\b(?: + private static readonly Regex SourceRegex = new (@"\b(?: (?BluRay|Blu-Ray|HD-?DVD|BDMux|BD(?!$))| (?WEB[-_. ]DL(?:mux)?|WEBDL|AmazonHD|AmazonSD|iTunesHD|MaxdomeHD|NetflixU?HD|WebHD|HBOMaxHD|DisneyHD|[. ]WEB[. ](?:[xh][ .]?26[45]|DDP?5[. ]1)|[. ](?-i:WEB)$|(?:720|1080|2160)p[-. ]WEB[-. ]|[-. ]WEB[-. ](?:720|1080|2160)p|\b\s\/\sWEB\s\/\s\b|(?:AMZN|NF|DP)[. -]WEB[. -](?!Rip))| (?WebRip|Web-Rip|WEBMux)| @@ -29,41 +29,41 @@ namespace NzbDrone.Core.Parser )(?:\b|$|[ .])", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); - private static readonly Regex RawHDRegex = new Regex(@"\b(?RawHD|Raw[-_. ]HD)\b", + private static readonly Regex RawHDRegex = new (@"\b(?RawHD|Raw[-_. ]HD)\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex MPEG2Regex = new Regex(@"\b(?MPEG[-_. ]?2)\b"); + private static readonly Regex MPEG2Regex = new (@"\b(?MPEG[-_. ]?2)\b"); - private static readonly Regex ProperRegex = new Regex(@"\b(?proper)\b", + private static readonly Regex ProperRegex = new (@"\b(?proper)\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex RepackRegex = new Regex(@"\b(?repack\d?|rerip\d?)\b", + private static readonly Regex RepackRegex = new (@"\b(?repack\d?|rerip\d?)\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex VersionRegex = new Regex(@"\d[-._ ]?v(?\d)[-._ ]|\[v(?\d)\]|repack(?\d)|rerip(?\d)", + private static readonly Regex VersionRegex = new (@"\d[-._ ]?v(?\d)[-._ ]|\[v(?\d)\]|repack(?\d)|rerip(?\d)", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex RealRegex = new Regex(@"\b(?REAL)\b", + private static readonly Regex RealRegex = new (@"\b(?REAL)\b", RegexOptions.Compiled); - private static readonly Regex ResolutionRegex = new Regex(@"\b(?:(?360p)|(?480p|640x480|848x480)|(?540p)|(?576p)|(?720p|1280x720|960p)|(?1080p|1920x1080|1440p|FHD|1080i|4kto1080p)|(?2160p|3840x2160|4k[-_. ](?:UHD|HEVC|BD|H265)|(?:UHD|HEVC|BD|H265)[-_. ]4k))\b", + private static readonly Regex ResolutionRegex = new (@"\b(?:(?360p)|(?480p|640x480|848x480)|(?540p)|(?576p)|(?720p|1280x720|960p)|(?1080p|1920x1080|1440p|FHD|1080i|4kto1080p)|(?2160p|3840x2160|4k[-_. ](?:UHD|HEVC|BD|H265)|(?:UHD|HEVC|BD|H265)[-_. ]4k))\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); // Handle cases where no resolution is in the release name (assume if UHD then 4k) or resolution is non-standard - private static readonly Regex AlternativeResolutionRegex = new Regex(@"\b(?UHD)\b|(?\[4K\])", + private static readonly Regex AlternativeResolutionRegex = new (@"\b(?UHD)\b|(?\[4K\])", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex CodecRegex = new Regex(@"\b(?:(?x264)|(?h264)|(?XvidHD)|(?Xvid)|(?divx))\b", + private static readonly Regex CodecRegex = new (@"\b(?:(?x264)|(?h264)|(?XvidHD)|(?Xvid)|(?divx))\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex OtherSourceRegex = new Regex(@"(?HD[-_. ]TV)|(?SD[-_. ]TV)", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex OtherSourceRegex = new (@"(?HD[-_. ]TV)|(?SD[-_. ]TV)", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex AnimeBlurayRegex = new Regex(@"bd(?:720|1080|2160)|(?<=[-_. (\[])bd(?=[-_. )\]])", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex AnimeWebDlRegex = new Regex(@"\[WEB\]|[\[\(]WEB[ .]", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex AnimeBlurayRegex = new (@"bd(?:720|1080|2160)|(?<=[-_. (\[])bd(?=[-_. )\]])", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex AnimeWebDlRegex = new (@"\[WEB\]|[\[\(]WEB[ .]", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex HighDefPdtvRegex = new Regex(@"hr[-_. ]ws", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex HighDefPdtvRegex = new (@"hr[-_. ]ws", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex RemuxRegex = new Regex(@"(?:[_. ]|\d{4}p-)(?(?:(BD|UHD)[-_. ]?)?Remux)\b|(?(?:(BD|UHD)[-_. ]?)?Remux[_. ]\d{4}p)", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex RemuxRegex = new (@"(?:[_. ]|\d{4}p-)(?(?:(BD|UHD)[-_. ]?)?Remux)\b|(?(?:(BD|UHD)[-_. ]?)?Remux[_. ]\d{4}p)", RegexOptions.Compiled | RegexOptions.IgnoreCase); public static QualityModel ParseQuality(string name) {