mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-12 11:15:43 +02:00
Better quality parse
This commit is contained in:
parent
bbdad5844f
commit
4cc240a7e0
Binary file not shown.
@ -38,7 +38,7 @@ public class InventoryProviderTest : TestBase
|
||||
EpisodeTitle = "EpisodeTitle",
|
||||
Language = LanguageType.English,
|
||||
Proper = true,
|
||||
Quality = QualityTypes.Bluray720,
|
||||
Quality = QualityTypes.Bluray720p,
|
||||
EpisodeNumbers = new List<int> { 3, 4 },
|
||||
SeasonNumber = 12,
|
||||
AirDate = DateTime.Now.AddDays(-12).Date
|
||||
@ -50,7 +50,7 @@ public class InventoryProviderTest : TestBase
|
||||
EpisodeTitle = "EpisodeTitle",
|
||||
Language = LanguageType.English,
|
||||
Proper = true,
|
||||
Quality = QualityTypes.Bluray720,
|
||||
Quality = QualityTypes.Bluray720p,
|
||||
EpisodeNumbers = new List<int> { 3 },
|
||||
SeasonNumber = 12,
|
||||
AirDate = DateTime.Now.AddDays(-12).Date
|
||||
|
@ -68,11 +68,13 @@ public void file_path_parse(string path, int season, int episode)
|
||||
|
||||
[Test]
|
||||
[Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.DVD)]
|
||||
[Row("WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", QualityTypes.DVD)]
|
||||
[Row("WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.DVD)]
|
||||
[Row("Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", QualityTypes.HDTV)]
|
||||
[Row("this has no extention or periods HDTV", QualityTypes.SDTV)]
|
||||
[Row("Chuck.S04E05.HDTV.XviD-LOL", QualityTypes.SDTV)]
|
||||
[Row("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", QualityTypes.DVD)]
|
||||
[Row("The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", QualityTypes.DVD)]
|
||||
[Row("The.Girls.Next.Door.S03E06.HDTV-WiDE", QualityTypes.SDTV)]
|
||||
[Row("Degrassi.S10E27.WS.DSR.XviD-2HD", QualityTypes.SDTV)]
|
||||
[Row("Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", QualityTypes.WEBDL)]
|
||||
@ -84,14 +86,15 @@ public void file_path_parse(string path, int season, int episode)
|
||||
[Row("Sonny.With.a.Chance.S02E15", QualityTypes.Unknown)]
|
||||
[Row("Chuck - S01E04 - So Old - Playdate - 720p TV.mkv", QualityTypes.HDTV)]
|
||||
[Row("Chuck - S22E03 - MoneyBART - HD TV.mkv", QualityTypes.HDTV)]
|
||||
[Row("Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", QualityTypes.Bluray720)]
|
||||
[Row("Chuck - S01E03 - Come Fly With Me - 1080p BluRay.mkv", QualityTypes.Bluray1080)]
|
||||
[Row("Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", QualityTypes.Bluray720p)]
|
||||
[Row("Chuck - S01E03 - Come Fly With Me - 1080p BluRay.mkv", QualityTypes.Bluray1080p)]
|
||||
[Row("Chuck - S11E06 - D-Yikes! - 720p WEB-DL.mkv", QualityTypes.WEBDL)]
|
||||
[Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD)]
|
||||
[Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD)]
|
||||
[Row("Law & Order: Special Victims Unit - 11x11 - Quickie", QualityTypes.Unknown)]
|
||||
[Row("(<a href=\"http://www.newzbin.com/browse/post/6076286/nzb/\">NZB</a>)", QualityTypes.Unknown)]
|
||||
[Row("S07E23 - [HDTV].mkv ", QualityTypes.HDTV)]
|
||||
[Row("S07E23 - [WEBDL].mkv ", QualityTypes.WEBDL)]
|
||||
[Row("S07E23.mkv ", QualityTypes.HDTV)]
|
||||
[Row("S07E23 .avi ", QualityTypes.SDTV)]
|
||||
public void quality_parse(string postTitle, object quality)
|
||||
@ -100,6 +103,29 @@ public void quality_parse(string postTitle, object quality)
|
||||
Assert.AreEqual(quality, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void parsing_our_own_quality_enum()
|
||||
{
|
||||
var qualityEnums = Enum.GetValues(typeof(QualityTypes));
|
||||
|
||||
|
||||
foreach (var qualityEnum in qualityEnums)
|
||||
{
|
||||
if (qualityEnum.ToString() == QualityTypes.Unknown.ToString()) continue;
|
||||
|
||||
var extention = "mkv";
|
||||
|
||||
if (qualityEnum.ToString() ==QualityTypes.SDTV.ToString() || qualityEnum.ToString() ==QualityTypes.DVD.ToString())
|
||||
{
|
||||
extention = "avi";
|
||||
}
|
||||
|
||||
var fileName = String.Format("My series S01E01 [{0}].{1}", qualityEnum,extention);
|
||||
var result = Parser.ParseQuality(fileName);
|
||||
Assert.AreEqual(qualityEnum, result);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Timeout(1)]
|
||||
[Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", "WEEDS", 3, new[] { 1, 2, 3, 4, 5, 6 }, 6)]
|
||||
|
Binary file not shown.
@ -191,7 +191,7 @@ private static void SetupDefaultQualityProfiles(IRepository repository)
|
||||
{
|
||||
Name = "HD",
|
||||
Allowed =
|
||||
new List<QualityTypes> { QualityTypes.HDTV, QualityTypes.WEBDL, QualityTypes.Bluray720 },
|
||||
new List<QualityTypes> { QualityTypes.HDTV, QualityTypes.WEBDL, QualityTypes.Bluray720p },
|
||||
Cutoff = QualityTypes.HDTV
|
||||
};
|
||||
|
||||
|
@ -204,17 +204,18 @@ internal static QualityTypes ParseQuality(string name)
|
||||
{
|
||||
Logger.Trace("Trying to parse quality for {0}", name);
|
||||
|
||||
name = name.Trim();
|
||||
var normilizedName = NormalizeTitle(name);
|
||||
var result = QualityTypes.Unknown;
|
||||
name = name.ToLowerInvariant().Trim();
|
||||
|
||||
if (name.Contains("dvd") || name.Contains("bdrip") || name.Contains("brrip"))
|
||||
if (normilizedName.Contains("dvd") || normilizedName.Contains("bdrip") || normilizedName.Contains("brrip"))
|
||||
{
|
||||
return QualityTypes.DVD;
|
||||
}
|
||||
|
||||
if (name.Contains("xvid") || name.Contains("divx"))
|
||||
if (normilizedName.Contains("xvid") || normilizedName.Contains("divx"))
|
||||
{
|
||||
if (name.Contains("bluray"))
|
||||
if (normilizedName.Contains("bluray"))
|
||||
{
|
||||
return QualityTypes.DVD;
|
||||
}
|
||||
@ -222,19 +223,19 @@ internal static QualityTypes ParseQuality(string name)
|
||||
return QualityTypes.SDTV;
|
||||
}
|
||||
|
||||
if (name.Contains("bluray"))
|
||||
if (normilizedName.Contains("bluray"))
|
||||
{
|
||||
if (name.Contains("720p"))
|
||||
return QualityTypes.Bluray720;
|
||||
if (normilizedName.Contains("720p"))
|
||||
return QualityTypes.Bluray720p;
|
||||
|
||||
if (name.Contains("1080p"))
|
||||
return QualityTypes.Bluray1080;
|
||||
if (normilizedName.Contains("1080p"))
|
||||
return QualityTypes.Bluray1080p;
|
||||
|
||||
return QualityTypes.Bluray720;
|
||||
return QualityTypes.Bluray720p;
|
||||
}
|
||||
if (name.Contains("web-dl"))
|
||||
if (normilizedName.Contains("webdl"))
|
||||
return QualityTypes.WEBDL;
|
||||
if (name.Contains("x264") || name.Contains("h264") || name.Contains("720p"))
|
||||
if (normilizedName.Contains("x264") || normilizedName.Contains("h264") || normilizedName.Contains("720p"))
|
||||
return QualityTypes.HDTV;
|
||||
|
||||
//Based on extension
|
||||
@ -269,7 +270,7 @@ internal static QualityTypes ParseQuality(string name)
|
||||
}
|
||||
}
|
||||
|
||||
if (result == QualityTypes.Unknown && name.Contains("hdtv"))
|
||||
if (normilizedName.Contains("sdtv") || (result == QualityTypes.Unknown && normilizedName.Contains("hdtv")))
|
||||
{
|
||||
return QualityTypes.SDTV;
|
||||
}
|
||||
|
@ -34,11 +34,11 @@ public enum QualityTypes
|
||||
/// <summary>
|
||||
/// HD File (720p Blu-ray Source)
|
||||
/// </summary>
|
||||
Bluray720 = 6,
|
||||
Bluray720p = 6,
|
||||
|
||||
/// <summary>
|
||||
/// HD File (1080p Blu-ray Source)
|
||||
/// </summary>
|
||||
Bluray1080 = 7,
|
||||
Bluray1080p = 7,
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user