|
|
|
@ -13,37 +13,50 @@ 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)",
|
|
|
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
|
|
|
|
(?<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)",
|
|
|
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
|
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)",
|
|
|
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|