From ff185c61114d3bbd768ada643e85b7a6eda8f563 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 29 Apr 2023 16:41:33 -0500 Subject: [PATCH] QualityParser - Simplify new expression (IDE0090) Closes #8283 --- src/NzbDrone.Core/Parser/QualityParser.cs | 90 +++++++++++------------ 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/src/NzbDrone.Core/Parser/QualityParser.cs b/src/NzbDrone.Core/Parser/QualityParser.cs index e90a6bfba..90070151c 100644 --- a/src/NzbDrone.Core/Parser/QualityParser.cs +++ b/src/NzbDrone.Core/Parser/QualityParser.cs @@ -14,66 +14,66 @@ namespace NzbDrone.Core.Parser { private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(QualityParser)); - private static readonly Regex SourceRegex = new Regex(@"\b(?: - (?M?BluRay|Blu-Ray|HD.?DVD|BD(?!$)|UHDBD|UHD2BD|BDISO|BDMux|BD25|BD50|BR.?DISK)| - (?WEB[-_. ]DL(?:mux)?|WEBDL|AmazonHD|iTunesHD|MaxdomeHD|NetflixU?HD|WebHD|[. ]WEB[. ](?:[xh][ .]?26[45]|DDP?5[. ]1)|[. ](?-i:WEB)$|(?:\d{3,4}0p)[-. ]WEB[-. ]|[-. ]WEB[-. ]\d{3,4}0p|\b\s\/\sWEB\s\/\s\b|(?:AMZN|NF|DP)[. -]WEB[. -](?!Rip))| - (?WebRip|Web-Rip|WEBMux)| - (?HDTV)| - (?BDRip|BDLight)| - (?BRRip)| - (?DVD-R|DVDR|DVD5|DVD9)| - (?DVD(?!-R)|DVDRip|xvidvd)| - (?WS[-_. ]DSR|DSR)| - (?R[0-9]{1}|REGIONAL)| - (?SCR|SCREENER|DVDSCR|DVDSCREENER)| - (?TS[-_. ]|TELESYNC|HD-TS|HDTS|PDVD|TSRip|HDTSRip)| - (?TC|TELECINE|HD-TC|HDTC)| - (?CAMRIP|CAM|HD-?CAM(?:Rip)?|HQCAM)| - (?WORKPRINT|WP)| - (?PDTV)| - (?SDTV)| - (?TVRip) - )(?:\b|$|[ .])", - RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); + private static readonly Regex SourceRegex = new (@"\b(?: + (?M?BluRay|Blu-Ray|HD.?DVD|BD(?!$)|UHDBD|UHD2BD|BDISO|BDMux|BD25|BD50|BR.?DISK)| + (?WEB[-_. ]DL(?:mux)?|WEBDL|AmazonHD|iTunesHD|MaxdomeHD|NetflixU?HD|WebHD|[. ]WEB[. ](?:[xh][ .]?26[45]|DDP?5[. ]1)|[. ](?-i:WEB)$|(?:\d{3,4}0p)[-. ]WEB[-. ]|[-. ]WEB[-. ]\d{3,4}0p|\b\s\/\sWEB\s\/\s\b|(?:AMZN|NF|DP)[. -]WEB[. -](?!Rip))| + (?WebRip|Web-Rip|WEBMux)| + (?HDTV)| + (?BDRip|BDLight)| + (?BRRip)| + (?DVD-R|DVDR|DVD5|DVD9)| + (?DVD(?!-R)|DVDRip|xvidvd)| + (?WS[-_. ]DSR|DSR)| + (?R[0-9]{1}|REGIONAL)| + (?SCR|SCREENER|DVDSCR|DVDSCREENER)| + (?TS[-_. ]|TELESYNC|HD-TS|HDTS|PDVD|TSRip|HDTSRip)| + (?TC|TELECINE|HD-TC|HDTC)| + (?CAMRIP|CAM|HD-?CAM(?:Rip)?|HQCAM)| + (?WORKPRINT|WP)| + (?PDTV)| + (?SDTV)| + (?TVRip) + )(?:\b|$|[ .])", + RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); - private static readonly Regex RawHDRegex = new Regex(@"\b(?RawHD|Raw[-_. ]HD)\b", - RegexOptions.Compiled | RegexOptions.IgnoreCase); + 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 BRDISKRegex = new Regex(@"\b(COMPLETE|ISO|BDISO|BD25|BD50|BR.?DISK)\b", - RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex BRDISKRegex = new (@"\b(COMPLETE|ISO|BDISO|BD25|BD50|BR.?DISK)\b", + RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex ProperRegex = new Regex(@"\b(?proper)\b", - RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex ProperRegex = new (@"\b(?proper)\b", + RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex RepackRegex = new Regex(@"\b(?repack|rerip)\b", - RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex RepackRegex = new (@"\b(?repack|rerip)\b", + RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex VersionRegex = new Regex(@"\d[-._ ]?v(?\d)[-._ ]|\[v(?\d)\]", - RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex VersionRegex = new (@"\d[-._ ]?v(?\d)[-._ ]|\[v(?\d)\]", + RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex RealRegex = new Regex(@"\b(?REAL)\b", - RegexOptions.Compiled); + 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|H\.?265)|(?:UHD|HEVC|BD|H\.?265)[-_. ]4k))\b", - RegexOptions.Compiled | RegexOptions.IgnoreCase); + 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|H\.?265)|(?:UHD|HEVC|BD|H\.?265)[-_. ]4k))\b", + RegexOptions.Compiled | RegexOptions.IgnoreCase); // Handle cases where no resolution is in the release name; assume if UHD then 4k - private static readonly Regex ImpliedResolutionRegex = new Regex(@"\b(?UHD)\b", - RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex ImpliedResolutionRegex = new (@"\b(?UHD)\b", + RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex CodecRegex = new Regex(@"\b(?:(?x264)|(?h264)|(?XvidHD)|(?X-?vid)|(?divx))\b", - RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex CodecRegex = new (@"\b(?:(?x264)|(?h264)|(?XvidHD)|(?X-?vid)|(?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) {