Fixed: Quality parser now properly deals with releases with underscores as delimiter.

pull/3113/head
Taloth Saldono 11 years ago
parent bf7180f9ac
commit 388943ea1b

@ -55,6 +55,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", false)]
[TestCase("The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", false)]
[TestCase("the.shield.1x13.circles.ws.xvidvd-tns", false)]
[TestCase("the_x-files.9x18.sunshine_days.ac3.ws_dvdrip_xvid-fov.avi", false)]
public void should_parse_dvd_quality(string title, bool proper)
{
ParseAndVerifyQuality(title, Quality.DVD, proper);

@ -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)
{

Loading…
Cancel
Save