Added newzbing tests, fixed quality parse bugs

pull/3113/head
kay.one 14 years ago
parent ae8465834b
commit 5be99200c6

@ -43,6 +43,12 @@ namespace NzbDrone.Core.Test
var parseResults = mocker.Resolve<MockIndexer>().Fetch(); var parseResults = mocker.Resolve<MockIndexer>().Fetch();
foreach (var episodeParseResult in parseResults)
{
var Uri = new Uri(episodeParseResult.NzbUrl);
Assert.DoesNotContain(Uri.PathAndQuery, "//");
}
Assert.IsNotEmpty(parseResults); Assert.IsNotEmpty(parseResults);
ExceptionVerification.ExcpectedWarns(warns); ExceptionVerification.ExcpectedWarns(warns);
@ -50,6 +56,38 @@ namespace NzbDrone.Core.Test
[Test]
public void newzbin()
{
var mocker = new AutoMoqer();
mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\newzbin.xml"));
var fakeSettings = Builder<IndexerSetting>.CreateNew().Build();
mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings);
var parseResults = mocker.Resolve<Newzbin>().Fetch();
foreach (var episodeParseResult in parseResults)
{
var Uri = new Uri(episodeParseResult.NzbUrl);
Assert.DoesNotContain(Uri.PathAndQuery, "//");
}
Assert.IsNotEmpty(parseResults);
ExceptionVerification.ExcpectedWarns(1);
}
[Test] [Test]
[Row("Adventure.Inc.S03E19.DVDRip.XviD-OSiTV", 3, 19, QualityTypes.DVD)] [Row("Adventure.Inc.S03E19.DVDRip.XviD-OSiTV", 3, 19, QualityTypes.DVD)]
public void custome_parser_partial_success(string title, int season, int episode, QualityTypes quality) public void custome_parser_partial_success(string title, int season, int episode, QualityTypes quality)

@ -70,8 +70,10 @@ namespace NzbDrone.Core.Test
[Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.BDRip)] [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.BDRip)]
[Row("WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.BDRip)] [Row("WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.BDRip)]
[Row("Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", QualityTypes.HDTV)] [Row("Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", QualityTypes.HDTV)]
[Row("this has no extention or periods HDTV", QualityTypes.TV)]
[Row("Chuck.S04E05.HDTV.XviD-LOL", QualityTypes.TV)] [Row("Chuck.S04E05.HDTV.XviD-LOL", QualityTypes.TV)]
[Row("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", QualityTypes.DVD)] [Row("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", QualityTypes.DVD)]
[Row("The.Girls.Next.Door.S03E06.HDTV-WiDE", QualityTypes.TV)]
[Row("Degrassi.S10E27.WS.DSR.XviD-2HD", QualityTypes.TV)] [Row("Degrassi.S10E27.WS.DSR.XviD-2HD", QualityTypes.TV)]
[Row("Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", QualityTypes.WEBDL)] [Row("Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", QualityTypes.WEBDL)]
[Row("Sonny.With.a.Chance.S02E15.720p", QualityTypes.HDTV)] [Row("Sonny.With.a.Chance.S02E15.720p", QualityTypes.HDTV)]
@ -88,9 +90,10 @@ namespace NzbDrone.Core.Test
[Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.BDRip)] [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.BDRip)]
[Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.BDRip)] [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.BDRip)]
[Row("Law & Order: Special Victims Unit - 11x11 - Quickie", QualityTypes.Unknown)] [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)]
public void quality_parse(string postTitle, object quality) public void quality_parse(string postTitle, object quality)
{ {
var result = Parser.ParseEpisodeInfo(postTitle).Quality; var result = Parser.ParseQuality(postTitle);
Assert.AreEqual(quality, result); Assert.AreEqual(quality, result);
} }

@ -239,7 +239,12 @@ namespace NzbDrone.Core
return QualityTypes.HDTV; return QualityTypes.HDTV;
//Based on extension //Based on extension
if (result == QualityTypes.Unknown && Path.HasExtension(name))
if (result == QualityTypes.Unknown)
{
try
{ {
switch (Path.GetExtension(name).ToLower()) switch (Path.GetExtension(name).ToLower())
{ {
@ -258,6 +263,16 @@ namespace NzbDrone.Core
} }
} }
} }
catch (ArgumentException)
{
//Swallow exception for cases where string contains illegal
//path characters.
}
}
if (name.Contains("hdtv"))
{
return QualityTypes.TV;
}
Logger.Trace("Quality Parsed:{0} Title:", result, name); Logger.Trace("Quality Parsed:{0} Title:", result, name);
return result; return result;

@ -9,7 +9,8 @@ namespace NzbDrone.Core.Providers.Indexer
{ {
public class Newzbin : IndexerBase public class Newzbin : IndexerBase
{ {
public Newzbin(HttpProvider httpProvider, ConfigProvider configProvider, IndexerProvider indexerProvider) : base(httpProvider, configProvider, indexerProvider) public Newzbin(HttpProvider httpProvider, ConfigProvider configProvider, IndexerProvider indexerProvider)
: base(httpProvider, configProvider, indexerProvider)
{ {
} }
@ -36,17 +37,19 @@ namespace NzbDrone.Core.Providers.Indexer
protected override string NzbDownloadUrl(SyndicationItem item) protected override string NzbDownloadUrl(SyndicationItem item)
{ {
return item.Id + "/nzb"; return item.Id + "nzb";
} }
protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult) protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult)
{
if (currentResult != null)
{ {
var quality = Parser.ParseQuality(item.Summary.Text); var quality = Parser.ParseQuality(item.Summary.Text);
var proper = Parser.ParseProper(item.Summary.Text); var proper = Parser.ParseProper(item.Summary.Text);
currentResult.Quality = quality; currentResult.Quality = quality;
currentResult.Proper = proper; currentResult.Proper = proper;
}
return currentResult; return currentResult;
} }

Loading…
Cancel
Save