2013-09-01 02:44:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2016-10-10 20:36:58 +00:00
|
|
|
|
using System.Linq;
|
2013-09-01 02:44:55 +00:00
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using NLog;
|
2014-12-02 06:26:25 +00:00
|
|
|
|
using NzbDrone.Common.Extensions;
|
2016-06-02 17:04:41 +00:00
|
|
|
|
using NzbDrone.Common.Instrumentation;
|
2013-09-12 06:33:28 +00:00
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
2013-09-01 02:44:55 +00:00
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Parser
|
|
|
|
|
{
|
|
|
|
|
public class QualityParser
|
|
|
|
|
{
|
2016-06-02 17:04:41 +00:00
|
|
|
|
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(QualityParser));
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
2014-05-04 11:26:02 +00:00
|
|
|
|
private static readonly Regex SourceRegex = new Regex(@"\b(?:
|
2014-11-21 05:43:04 +00:00
|
|
|
|
(?<bluray>BluRay|Blu-Ray|HDDVD|BD)|
|
2016-06-14 21:13:50 +00:00
|
|
|
|
(?<webdl>WEB[-_. ]DL|WEBDL|WebRip|iTunesHD|WebHD|[. ]WEB[. ](?:[xh]26[45]|DD5[. ]1)|\d+0p[. ]WEB[. ])|
|
2013-09-01 02:44:55 +00:00
|
|
|
|
(?<hdtv>HDTV)|
|
2015-09-20 18:28:15 +00:00
|
|
|
|
(?<bdrip>BDRip)|
|
2014-05-04 11:26:02 +00:00
|
|
|
|
(?<brrip>BRRip)|
|
|
|
|
|
(?<dvd>DVD|DVDRip|NTSC|PAL|xvidvd)|
|
2014-06-16 14:57:55 +00:00
|
|
|
|
(?<dsr>WS[-_. ]DSR|DSR)|
|
2014-05-04 11:26:02 +00:00
|
|
|
|
(?<pdtv>PDTV)|
|
2015-09-20 18:28:15 +00:00
|
|
|
|
(?<sdtv>SDTV)|
|
|
|
|
|
(?<tvrip>TVRip)
|
2014-05-04 11:26:02 +00:00
|
|
|
|
)\b",
|
|
|
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
2017-01-16 21:51:45 +00:00
|
|
|
|
private static readonly Regex HardcodedSubsRegex = new Regex(@"\b(?<hcsub>(\w+SUB)\b)|(?<hc>(HC))\b", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
2017-01-06 13:38:52 +00:00
|
|
|
|
|
2016-03-26 19:44:46 +00:00
|
|
|
|
private static readonly Regex RawHDRegex = new Regex(@"\b(?<rawhd>RawHD|1080i[-_. ]HDTV|Raw[-_. ]HD|MPEG[-_. ]?2)\b",
|
2014-05-04 11:26:02 +00:00
|
|
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
2016-03-26 19:41:27 +00:00
|
|
|
|
private static readonly Regex ProperRegex = new Regex(@"\b(?<proper>proper|repack|rerip)\b",
|
2014-05-04 11:26:02 +00:00
|
|
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
|
|
2014-09-01 02:28:42 +00:00
|
|
|
|
private static readonly Regex VersionRegex = new Regex(@"\dv(?<version>\d)\b|\[v(?<version>\d)\]",
|
|
|
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
|
|
2015-08-21 05:50:26 +00:00
|
|
|
|
private static readonly Regex RealRegex = new Regex(@"\b(?<real>REAL)\b",
|
|
|
|
|
RegexOptions.Compiled);
|
2014-09-01 02:28:42 +00:00
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
private static readonly Regex ResolutionRegex = new Regex(@"\b(?:(?<R480p>480p|640x480|848x480)|(?<R576p>576p)|(?<R720p>720p|1280x720)|(?<R1080p>1080p|1920x1080)|(?<R2160p>2160p))\b",
|
2014-05-04 11:26:02 +00:00
|
|
|
|
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);
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
2014-06-16 14:57:55 +00:00
|
|
|
|
private static readonly Regex OtherSourceRegex = new Regex(@"(?<hdtv>HD[-_. ]TV)|(?<sdtv>SD[-_. ]TV)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
|
|
2014-08-22 20:27:14 +00:00
|
|
|
|
private static readonly Regex AnimeBlurayRegex = new Regex(@"bd(?:720|1080)|(?<=[-_. (\[])bd(?=[-_. )\]])", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
2014-05-19 19:14:41 +00:00
|
|
|
|
|
2014-07-09 05:45:19 +00:00
|
|
|
|
private static readonly Regex HighDefPdtvRegex = new Regex(@"hr[-_. ]ws", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
|
|
2013-09-01 02:44:55 +00:00
|
|
|
|
public static QualityModel ParseQuality(string name)
|
|
|
|
|
{
|
2014-03-13 20:12:42 +00:00
|
|
|
|
Logger.Debug("Trying to parse quality for {0}", name);
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
|
|
|
|
name = name.Trim();
|
2014-05-04 11:26:02 +00:00
|
|
|
|
var normalizedName = name.Replace('_', ' ').Trim().ToLower();
|
2015-08-21 05:50:26 +00:00
|
|
|
|
var result = ParseQualityModifiers(name, normalizedName);
|
2017-01-06 13:38:52 +00:00
|
|
|
|
var subMatch = HardcodedSubsRegex.Matches(normalizedName).OfType<Match>().LastOrDefault();
|
|
|
|
|
|
|
|
|
|
if (subMatch != null && subMatch.Success)
|
|
|
|
|
{
|
|
|
|
|
if (subMatch.Groups["hcsub"].Success)
|
|
|
|
|
{
|
|
|
|
|
result.HardcodedSubs = subMatch.Groups["hcsub"].Value;
|
|
|
|
|
}
|
|
|
|
|
else if (subMatch.Groups["hc"].Success)
|
|
|
|
|
{
|
|
|
|
|
result.HardcodedSubs = "Generic Hardcoded Subs";
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
2017-01-26 19:43:24 +00:00
|
|
|
|
//if (RawHDRegex.IsMatch(normalizedName))
|
|
|
|
|
//{
|
|
|
|
|
// result.Quality = Quality.RAWHD;
|
|
|
|
|
// return result;
|
|
|
|
|
//}
|
2016-10-10 20:36:58 +00:00
|
|
|
|
|
|
|
|
|
var sourceMatch = SourceRegex.Matches(normalizedName).OfType<Match>().LastOrDefault();
|
2014-05-04 11:26:02 +00:00
|
|
|
|
var resolution = ParseResolution(normalizedName);
|
|
|
|
|
var codecRegex = CodecRegex.Match(normalizedName);
|
2017-01-06 13:38:52 +00:00
|
|
|
|
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
2016-10-10 20:36:58 +00:00
|
|
|
|
if (sourceMatch != null && sourceMatch.Success)
|
2013-09-01 02:44:55 +00:00
|
|
|
|
{
|
2016-10-10 20:36:58 +00:00
|
|
|
|
if (sourceMatch.Groups["bluray"].Success)
|
2013-09-01 02:44:55 +00:00
|
|
|
|
{
|
2016-10-10 20:36:58 +00:00
|
|
|
|
if (codecRegex.Groups["xvid"].Success || codecRegex.Groups["divx"].Success)
|
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.DVD;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R2160p)
|
2016-10-10 20:36:58 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.Bluray2160p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2015-11-09 23:18:02 +00:00
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R1080p)
|
2016-10-10 20:36:58 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.Bluray1080p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R480P || resolution == Resolution.R576p)
|
2016-10-10 20:36:58 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.DVD;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Quality = Quality.Bluray720p;
|
2013-09-01 02:44:55 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-10 20:36:58 +00:00
|
|
|
|
if (sourceMatch.Groups["webdl"].Success)
|
2014-05-25 06:21:53 +00:00
|
|
|
|
{
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R2160p)
|
2016-10-10 20:36:58 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.WEBDL2160p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2014-05-25 06:21:53 +00:00
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R1080p)
|
2016-10-10 20:36:58 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.WEBDL1080p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R720p)
|
2016-10-10 20:36:58 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.WEBDL720p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2015-11-09 23:18:02 +00:00
|
|
|
|
|
2016-10-10 20:36:58 +00:00
|
|
|
|
if (name.Contains("[WEBDL]"))
|
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.WEBDL720p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
2016-10-10 20:36:58 +00:00
|
|
|
|
result.Quality = Quality.WEBDL480p;
|
2013-09-01 02:44:55 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-10 20:36:58 +00:00
|
|
|
|
if (sourceMatch.Groups["hdtv"].Success)
|
2013-09-01 02:44:55 +00:00
|
|
|
|
{
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R2160p)
|
2016-10-10 20:36:58 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.HDTV2160p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R1080p)
|
2016-10-10 20:36:58 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.HDTV1080p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R720p)
|
2016-10-10 20:36:58 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.HDTV720p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2015-11-09 23:18:02 +00:00
|
|
|
|
|
2016-10-10 20:36:58 +00:00
|
|
|
|
if (name.Contains("[HDTV]"))
|
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.HDTV720p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Quality = Quality.SDTV;
|
2013-09-01 02:44:55 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-10 20:36:58 +00:00
|
|
|
|
if (sourceMatch.Groups["bdrip"].Success ||
|
|
|
|
|
sourceMatch.Groups["brrip"].Success)
|
2013-09-01 02:44:55 +00:00
|
|
|
|
{
|
2016-10-10 20:36:58 +00:00
|
|
|
|
switch (resolution)
|
|
|
|
|
{
|
2016-12-09 06:16:58 +00:00
|
|
|
|
case Resolution.R720p:
|
2016-10-10 20:36:58 +00:00
|
|
|
|
result.Quality = Quality.Bluray720p;
|
|
|
|
|
return result;
|
2016-12-09 06:16:58 +00:00
|
|
|
|
case Resolution.R1080p:
|
2016-10-10 20:36:58 +00:00
|
|
|
|
result.Quality = Quality.Bluray1080p;
|
|
|
|
|
return result;
|
|
|
|
|
default:
|
|
|
|
|
result.Quality = Quality.DVD;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2013-09-01 02:44:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-10 20:36:58 +00:00
|
|
|
|
if (sourceMatch.Groups["dvd"].Success)
|
2013-09-01 02:44:55 +00:00
|
|
|
|
{
|
2016-10-10 20:36:58 +00:00
|
|
|
|
result.Quality = Quality.DVD;
|
2013-09-01 02:44:55 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-10 20:36:58 +00:00
|
|
|
|
if (sourceMatch.Groups["pdtv"].Success ||
|
|
|
|
|
sourceMatch.Groups["sdtv"].Success ||
|
|
|
|
|
sourceMatch.Groups["dsr"].Success ||
|
|
|
|
|
sourceMatch.Groups["tvrip"].Success)
|
2014-05-02 17:13:54 +00:00
|
|
|
|
{
|
2016-10-10 20:36:58 +00:00
|
|
|
|
if (HighDefPdtvRegex.IsMatch(normalizedName))
|
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.HDTV720p;
|
2014-12-07 07:23:11 +00:00
|
|
|
|
return result;
|
2016-10-10 20:36:58 +00:00
|
|
|
|
}
|
2014-05-02 17:13:54 +00:00
|
|
|
|
|
2016-10-10 20:36:58 +00:00
|
|
|
|
result.Quality = Quality.SDTV;
|
2014-07-09 05:45:19 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
2013-09-01 02:44:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-06 13:38:52 +00:00
|
|
|
|
|
|
|
|
|
|
2015-09-20 18:28:15 +00:00
|
|
|
|
|
2014-05-19 19:14:41 +00:00
|
|
|
|
//Anime Bluray matching
|
|
|
|
|
if (AnimeBlurayRegex.Match(normalizedName).Success)
|
|
|
|
|
{
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R480P || resolution == Resolution.R576p || normalizedName.Contains("480p"))
|
2014-05-19 19:14:41 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.DVD;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R1080p || normalizedName.Contains("1080p"))
|
2014-05-19 19:14:41 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.Bluray1080p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Quality = Quality.Bluray720p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R2160p)
|
2015-11-09 23:18:02 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.HDTV2160p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R1080p)
|
2013-09-01 02:44:55 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.HDTV1080p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R720p)
|
2013-09-01 02:44:55 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.HDTV720p;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (resolution == Resolution.R480P)
|
2014-05-19 19:14:41 +00:00
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.SDTV;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-01 02:44:55 +00:00
|
|
|
|
if (codecRegex.Groups["x264"].Success)
|
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.SDTV;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2014-05-19 19:14:41 +00:00
|
|
|
|
|
|
|
|
|
if (normalizedName.Contains("848x480"))
|
|
|
|
|
{
|
|
|
|
|
if (normalizedName.Contains("dvd"))
|
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.DVD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Quality = Quality.SDTV;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (normalizedName.Contains("1280x720"))
|
|
|
|
|
{
|
|
|
|
|
if (normalizedName.Contains("bluray"))
|
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.Bluray720p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Quality = Quality.HDTV720p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (normalizedName.Contains("1920x1080"))
|
|
|
|
|
{
|
|
|
|
|
if (normalizedName.Contains("bluray"))
|
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.Bluray1080p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Quality = Quality.HDTV1080p;
|
|
|
|
|
}
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
2014-05-17 06:01:36 +00:00
|
|
|
|
if (normalizedName.Contains("bluray720p"))
|
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.Bluray720p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (normalizedName.Contains("bluray1080p"))
|
|
|
|
|
{
|
|
|
|
|
result.Quality = Quality.Bluray1080p;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-16 14:57:55 +00:00
|
|
|
|
var otherSourceMatch = OtherSourceMatch(normalizedName);
|
|
|
|
|
|
|
|
|
|
if (otherSourceMatch != Quality.Unknown)
|
|
|
|
|
{
|
|
|
|
|
result.Quality = otherSourceMatch;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-01 02:44:55 +00:00
|
|
|
|
//Based on extension
|
|
|
|
|
if (result.Quality == Quality.Unknown && !name.ContainsInvalidPathChars())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2013-09-12 15:13:20 +00:00
|
|
|
|
result.Quality = MediaFileExtensions.GetQualityForExtension(Path.GetExtension(name));
|
2015-10-23 05:21:44 +00:00
|
|
|
|
result.QualitySource = QualitySource.Extension;
|
2013-09-01 02:44:55 +00:00
|
|
|
|
}
|
|
|
|
|
catch (ArgumentException)
|
|
|
|
|
{
|
2016-10-10 20:36:58 +00:00
|
|
|
|
//Swallow exception for cases where string contains illegal
|
2013-09-01 02:44:55 +00:00
|
|
|
|
//path characters.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 17:45:26 +00:00
|
|
|
|
private static Resolution ParseResolution(string name)
|
2013-09-01 02:44:55 +00:00
|
|
|
|
{
|
|
|
|
|
var match = ResolutionRegex.Match(name);
|
|
|
|
|
|
|
|
|
|
if (!match.Success) return Resolution.Unknown;
|
2016-12-09 06:16:58 +00:00
|
|
|
|
if (match.Groups["R480p"].Success) return Resolution.R480P;
|
|
|
|
|
if (match.Groups["R576p"].Success) return Resolution.R576p;
|
|
|
|
|
if (match.Groups["R720p"].Success) return Resolution.R720p;
|
|
|
|
|
if (match.Groups["R1080p"].Success) return Resolution.R1080p;
|
|
|
|
|
if (match.Groups["R2160p"].Success) return Resolution.R2160p;
|
2013-09-01 02:44:55 +00:00
|
|
|
|
|
|
|
|
|
return Resolution.Unknown;
|
|
|
|
|
}
|
2014-06-16 14:57:55 +00:00
|
|
|
|
|
2015-10-03 17:45:26 +00:00
|
|
|
|
private static Quality OtherSourceMatch(string name)
|
2014-06-16 14:57:55 +00:00
|
|
|
|
{
|
|
|
|
|
var match = OtherSourceRegex.Match(name);
|
|
|
|
|
|
|
|
|
|
if (!match.Success) return Quality.Unknown;
|
|
|
|
|
if (match.Groups["sdtv"].Success) return Quality.SDTV;
|
|
|
|
|
if (match.Groups["hdtv"].Success) return Quality.HDTV720p;
|
|
|
|
|
|
|
|
|
|
return Quality.Unknown;
|
|
|
|
|
}
|
2014-09-01 02:28:42 +00:00
|
|
|
|
|
2015-08-21 05:50:26 +00:00
|
|
|
|
private static QualityModel ParseQualityModifiers(string name, string normalizedName)
|
2014-09-01 02:28:42 +00:00
|
|
|
|
{
|
|
|
|
|
var result = new QualityModel { Quality = Quality.Unknown };
|
|
|
|
|
|
|
|
|
|
if (ProperRegex.IsMatch(normalizedName))
|
|
|
|
|
{
|
|
|
|
|
result.Revision.Version = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var versionRegexResult = VersionRegex.Match(normalizedName);
|
|
|
|
|
|
|
|
|
|
if (versionRegexResult.Success)
|
|
|
|
|
{
|
|
|
|
|
result.Revision.Version = Convert.ToInt32(versionRegexResult.Groups["version"].Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO: re-enable this when we have a reliable way to determine real
|
|
|
|
|
//TODO: Only treat it as a real if it comes AFTER the season/epsiode number
|
2015-08-21 05:50:26 +00:00
|
|
|
|
var realRegexResult = RealRegex.Matches(name);
|
|
|
|
|
|
|
|
|
|
if (realRegexResult.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
result.Revision.Real = realRegexResult.Count;
|
|
|
|
|
}
|
2014-09-01 02:28:42 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2013-09-01 02:44:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum Resolution
|
|
|
|
|
{
|
2016-12-09 06:16:58 +00:00
|
|
|
|
R480P,
|
|
|
|
|
R576p,
|
|
|
|
|
R720p,
|
|
|
|
|
R1080p,
|
|
|
|
|
R2160p,
|
2013-09-01 02:44:55 +00:00
|
|
|
|
Unknown
|
|
|
|
|
}
|
|
|
|
|
}
|