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();
foreach (var episodeParseResult in parseResults)
{
var Uri = new Uri(episodeParseResult.NzbUrl);
Assert.DoesNotContain(Uri.PathAndQuery, "//");
}
Assert.IsNotEmpty(parseResults);
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]
[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)

@ -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.AC3.-HELLYWOOD", QualityTypes.BDRip)]
[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("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("Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", QualityTypes.WEBDL)]
[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("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)
{
var result = Parser.ParseEpisodeInfo(postTitle).Quality;
var result = Parser.ParseQuality(postTitle);
Assert.AreEqual(quality, result);
}

@ -239,24 +239,39 @@ namespace NzbDrone.Core
return QualityTypes.HDTV;
//Based on extension
if (result == QualityTypes.Unknown && Path.HasExtension(name))
if (result == QualityTypes.Unknown)
{
switch (Path.GetExtension(name).ToLower())
try
{
case ".avi":
case ".xvid":
case ".wmv":
case ".mp4":
{
result = QualityTypes.TV;
break;
}
case ".mkv":
{
result = QualityTypes.HDTV;
break;
}
switch (Path.GetExtension(name).ToLower())
{
case ".avi":
case ".xvid":
case ".wmv":
case ".mp4":
{
result = QualityTypes.TV;
break;
}
case ".mkv":
{
result = QualityTypes.HDTV;
break;
}
}
}
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);

@ -9,7 +9,8 @@ namespace NzbDrone.Core.Providers.Indexer
{
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)
{
return item.Id + "/nzb";
return item.Id + "nzb";
}
protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult)
{
var quality = Parser.ParseQuality(item.Summary.Text);
var proper = Parser.ParseProper(item.Summary.Text);
currentResult.Quality = quality;
currentResult.Proper = proper;
if (currentResult != null)
{
var quality = Parser.ParseQuality(item.Summary.Text);
var proper = Parser.ParseProper(item.Summary.Text);
currentResult.Quality = quality;
currentResult.Proper = proper;
}
return currentResult;
}

Loading…
Cancel
Save