1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

more kosher regex group names.

This commit is contained in:
Keivan Beigi 2016-12-08 22:16:58 -08:00
parent 327536b684
commit c42e4d682c

View File

@ -40,7 +40,7 @@ public class QualityParser
private static readonly Regex RealRegex = new Regex(@"\b(?<real>REAL)\b", private static readonly Regex RealRegex = new Regex(@"\b(?<real>REAL)\b",
RegexOptions.Compiled); RegexOptions.Compiled);
private static readonly Regex ResolutionRegex = new Regex(@"\b(?:(?<_480p>480p|640x480|848x480)|(?<_576p>576p)|(?<_720p>720p|1280x720)|(?<_1080p>1080p|1920x1080)|(?<_2160p>2160p))\b", private static readonly Regex ResolutionRegex = new Regex(@"\b(?:(?<R480p>480p|640x480|848x480)|(?<R576p>576p)|(?<R720p>720p|1280x720)|(?<R1080p>1080p|1920x1080)|(?<R2160p>2160p))\b",
RegexOptions.Compiled | RegexOptions.IgnoreCase); RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex CodecRegex = new Regex(@"\b(?:(?<x264>x264)|(?<h264>h264)|(?<xvidhd>XvidHD)|(?<xvid>Xvid)|(?<divx>divx))\b", private static readonly Regex CodecRegex = new Regex(@"\b(?:(?<x264>x264)|(?<h264>h264)|(?<xvidhd>XvidHD)|(?<xvid>Xvid)|(?<divx>divx))\b",
@ -80,19 +80,19 @@ public static QualityModel ParseQuality(string name)
return result; return result;
} }
if (resolution == Resolution._2160p) if (resolution == Resolution.R2160p)
{ {
result.Quality = Quality.Bluray2160p; result.Quality = Quality.Bluray2160p;
return result; return result;
} }
if (resolution == Resolution._1080p) if (resolution == Resolution.R1080p)
{ {
result.Quality = Quality.Bluray1080p; result.Quality = Quality.Bluray1080p;
return result; return result;
} }
if (resolution == Resolution._480p || resolution == Resolution._576p) if (resolution == Resolution.R480P || resolution == Resolution.R576p)
{ {
result.Quality = Quality.DVD; result.Quality = Quality.DVD;
return result; return result;
@ -104,19 +104,19 @@ public static QualityModel ParseQuality(string name)
if (sourceMatch.Groups["webdl"].Success) if (sourceMatch.Groups["webdl"].Success)
{ {
if (resolution == Resolution._2160p) if (resolution == Resolution.R2160p)
{ {
result.Quality = Quality.WEBDL2160p; result.Quality = Quality.WEBDL2160p;
return result; return result;
} }
if (resolution == Resolution._1080p) if (resolution == Resolution.R1080p)
{ {
result.Quality = Quality.WEBDL1080p; result.Quality = Quality.WEBDL1080p;
return result; return result;
} }
if (resolution == Resolution._720p) if (resolution == Resolution.R720p)
{ {
result.Quality = Quality.WEBDL720p; result.Quality = Quality.WEBDL720p;
return result; return result;
@ -134,19 +134,19 @@ public static QualityModel ParseQuality(string name)
if (sourceMatch.Groups["hdtv"].Success) if (sourceMatch.Groups["hdtv"].Success)
{ {
if (resolution == Resolution._2160p) if (resolution == Resolution.R2160p)
{ {
result.Quality = Quality.HDTV2160p; result.Quality = Quality.HDTV2160p;
return result; return result;
} }
if (resolution == Resolution._1080p) if (resolution == Resolution.R1080p)
{ {
result.Quality = Quality.HDTV1080p; result.Quality = Quality.HDTV1080p;
return result; return result;
} }
if (resolution == Resolution._720p) if (resolution == Resolution.R720p)
{ {
result.Quality = Quality.HDTV720p; result.Quality = Quality.HDTV720p;
return result; return result;
@ -167,10 +167,10 @@ public static QualityModel ParseQuality(string name)
{ {
switch (resolution) switch (resolution)
{ {
case Resolution._720p: case Resolution.R720p:
result.Quality = Quality.Bluray720p; result.Quality = Quality.Bluray720p;
return result; return result;
case Resolution._1080p: case Resolution.R1080p:
result.Quality = Quality.Bluray1080p; result.Quality = Quality.Bluray1080p;
return result; return result;
default: default:
@ -205,13 +205,13 @@ public static QualityModel ParseQuality(string name)
//Anime Bluray matching //Anime Bluray matching
if (AnimeBlurayRegex.Match(normalizedName).Success) if (AnimeBlurayRegex.Match(normalizedName).Success)
{ {
if (resolution == Resolution._480p || resolution == Resolution._576p || normalizedName.Contains("480p")) if (resolution == Resolution.R480P || resolution == Resolution.R576p || normalizedName.Contains("480p"))
{ {
result.Quality = Quality.DVD; result.Quality = Quality.DVD;
return result; return result;
} }
if (resolution == Resolution._1080p || normalizedName.Contains("1080p")) if (resolution == Resolution.R1080p || normalizedName.Contains("1080p"))
{ {
result.Quality = Quality.Bluray1080p; result.Quality = Quality.Bluray1080p;
return result; return result;
@ -221,25 +221,25 @@ public static QualityModel ParseQuality(string name)
return result; return result;
} }
if (resolution == Resolution._2160p) if (resolution == Resolution.R2160p)
{ {
result.Quality = Quality.HDTV2160p; result.Quality = Quality.HDTV2160p;
return result; return result;
} }
if (resolution == Resolution._1080p) if (resolution == Resolution.R1080p)
{ {
result.Quality = Quality.HDTV1080p; result.Quality = Quality.HDTV1080p;
return result; return result;
} }
if (resolution == Resolution._720p) if (resolution == Resolution.R720p)
{ {
result.Quality = Quality.HDTV720p; result.Quality = Quality.HDTV720p;
return result; return result;
} }
if (resolution == Resolution._480p) if (resolution == Resolution.R480P)
{ {
result.Quality = Quality.SDTV; result.Quality = Quality.SDTV;
return result; return result;
@ -321,11 +321,11 @@ private static Resolution ParseResolution(string name)
var match = ResolutionRegex.Match(name); var match = ResolutionRegex.Match(name);
if (!match.Success) return Resolution.Unknown; if (!match.Success) return Resolution.Unknown;
if (match.Groups["_480p"].Success) return Resolution._480p; if (match.Groups["R480p"].Success) return Resolution.R480P;
if (match.Groups["_576p"].Success) return Resolution._576p; if (match.Groups["R576p"].Success) return Resolution.R576p;
if (match.Groups["_720p"].Success) return Resolution._720p; if (match.Groups["R720p"].Success) return Resolution.R720p;
if (match.Groups["_1080p"].Success) return Resolution._1080p; if (match.Groups["R1080p"].Success) return Resolution.R1080p;
if (match.Groups["_2160p"].Success) return Resolution._2160p; if (match.Groups["R2160p"].Success) return Resolution.R2160p;
return Resolution.Unknown; return Resolution.Unknown;
} }
@ -372,11 +372,11 @@ private static QualityModel ParseQualityModifiers(string name, string normalized
public enum Resolution public enum Resolution
{ {
_480p, R480P,
_576p, R576p,
_720p, R720p,
_1080p, R1080p,
_2160p, R2160p,
Unknown Unknown
} }
} }