|
|
|
@ -13,17 +13,29 @@ namespace NzbDrone.Core.Parser
|
|
|
|
|
{
|
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
|
|
private static readonly Regex SourceRegex = new Regex(@"(?<bluray>BluRay)|
|
|
|
|
|
private static readonly Regex SourceRegex = new Regex(@"\b(?:
|
|
|
|
|
(?<bluray>BluRay)|
|
|
|
|
|
(?<webdl>WEB-DL|WEBDL|WEB\sDL|WEB\-DL|WebRip)|
|
|
|
|
|
(?<hdtv>HDTV)|
|
|
|
|
|
(?<bdrip>BDRiP)|(?<brrip>BRRip)|(?<dvd>\b(?:DVD|DVDRip|NTSC|PAL|xvidvd)\b)|
|
|
|
|
|
(?<dsr>WS\sDSR|WS_DSR|WS\.DSR|DSR)|(?<pdtv>PDTV)|(?<sdtv>SDTV)",
|
|
|
|
|
(?<bdrip>BDRiP)|
|
|
|
|
|
(?<brrip>BRRip)|
|
|
|
|
|
(?<dvd>DVD|DVDRip|NTSC|PAL|xvidvd)|
|
|
|
|
|
(?<dsr>WS\sDSR|WS_DSR|WS\.DSR|DSR)|
|
|
|
|
|
(?<pdtv>PDTV)|
|
|
|
|
|
(?<sdtv>SDTV)
|
|
|
|
|
)\b",
|
|
|
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
|
|
|
|
|
|
|
|
|
private static readonly Regex ResolutionRegex = new Regex(@"(?<_480p>480p)|(?<_720p>720p)|(?<_1080p>1080p)",
|
|
|
|
|
private static readonly Regex RawHDRegex = new Regex(@"\b(?<rawhd>TrollHD|RawHD)\b",
|
|
|
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
|
|
|
|
|
|
private static readonly Regex CodecRegex = new Regex(@"(?<x264>x264)|(?<h264>h264)|(?<xvidhd>XvidHD)|(?<xvid>Xvid)|(?<divx>divx)",
|
|
|
|
|
private static readonly Regex ProperRegex = new Regex(@"\b(?<proper>proper|repack)\b",
|
|
|
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
|
|
|
|
|
|
private static readonly Regex ResolutionRegex = new Regex(@"\b(?:(?<_480p>480p)|(?<_720p>720p)|(?<_1080p>1080p))\b",
|
|
|
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
|
|
|
|
|
|
private static readonly Regex CodecRegex = new Regex(@"\b(?:(?<x264>x264)|(?<h264>h264)|(?<xvidhd>XvidHD)|(?<xvid>Xvid)|(?<divx>divx))\b",
|
|
|
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
|
|
|
|
|
|
public static QualityModel ParseQuality(string name)
|
|
|
|
@ -31,19 +43,20 @@ namespace NzbDrone.Core.Parser
|
|
|
|
|
Logger.Debug("Trying to parse quality for {0}", name);
|
|
|
|
|
|
|
|
|
|
name = name.Trim();
|
|
|
|
|
var normalizedName = name.CleanSeriesTitle();
|
|
|
|
|
var normalizedName = name.Replace('_', ' ').Trim().ToLower();
|
|
|
|
|
var result = new QualityModel { Quality = Quality.Unknown };
|
|
|
|
|
result.Proper = (normalizedName.Contains("proper") || normalizedName.Contains("repack"));
|
|
|
|
|
|
|
|
|
|
if (normalizedName.Contains("trollhd") || normalizedName.Contains("rawhd"))
|
|
|
|
|
result.Proper = ProperRegex.IsMatch(normalizedName);
|
|
|
|
|
|
|
|
|
|
if (RawHDRegex.IsMatch(normalizedName))
|
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.RAWHD;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sourceMatch = SourceRegex.Match(name);
|
|
|
|
|
var resolution = ParseResolution(name);
|
|
|
|
|
var codecRegex = CodecRegex.Match(name);
|
|
|
|
|
var sourceMatch = SourceRegex.Match(normalizedName);
|
|
|
|
|
var resolution = ParseResolution(normalizedName);
|
|
|
|
|
var codecRegex = CodecRegex.Match(normalizedName);
|
|
|
|
|
|
|
|
|
|
if (sourceMatch.Groups["bluray"].Success)
|
|
|
|
|
{
|
|
|
|
|