From 64a913fb8e893ef226a8e81f2c628a6c74c385af Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 29 Feb 2012 08:32:58 -0800 Subject: [PATCH] Fix: Newzbin custom parser will now reject full DVD reports. Fixes bug: ND-31 --- .../Files/RSS/newzbin_full_dvd.xml | 78 +++++++++++++++++++ NzbDrone.Core.Test/IndexerTests.cs | 16 ++++ NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 3 + NzbDrone.Core/Providers/Indexer/Newzbin.cs | 7 ++ 4 files changed, 104 insertions(+) create mode 100644 NzbDrone.Core.Test/Files/RSS/newzbin_full_dvd.xml diff --git a/NzbDrone.Core.Test/Files/RSS/newzbin_full_dvd.xml b/NzbDrone.Core.Test/Files/RSS/newzbin_full_dvd.xml new file mode 100644 index 000000000..5abdb2e95 --- /dev/null +++ b/NzbDrone.Core.Test/Files/RSS/newzbin_full_dvd.xml @@ -0,0 +1,78 @@ + + + + www.newzbin.com (reports) + http://www.newzbin.com/browse/category/p/tv/ + Newzbin Reports Feed + Mon, 25 Apr 2011 16:08:24 GMT + 42 + www.newzbin.com - Usenet Search + Copyright (c) 2002 - 2007 Newzbin Limited. All Rights Reserved. + + http://www.newzbin.com/m/i/logo/newzbinv3.png + http://www.newzbin.com/browse/category/p/tv/ + www.newzbin.com + Visit Newzbin.com - The Ultimate In Usenet Indexing + + + Last Man Standing - Season 1 [DVD 1] + https://newzbin2.es/browse/post/6514817/ + https://newzbin2.es/browse/post/6514817/ + https://newzbin2.es/browse/post/6514817/#CommentsPH + + +
  • + ID: 6514817 + (Bookmark) + (NZB) + (NFO) + (More Info) + (Size: 5,056.7MiB) +
  • +
  • + Attributes: + Category - TV + | Region System - NTSC | Video Source - DVD | Video Format - DVD | Video Genre - Comedy | Language - English | Subtitled Language - Dutch +
  • +
  • Groups: alt.binaries.boneless
  • +
  • Poster: CPP-gebruiker@domein.nl (Darkling)
  • +
  • PostDate: Saturday 25 Feb 2012, 06:57AM PST
  • + ]]> +
    + 6514817 + TV + + NTSC + DVD + DVD + Comedy + English + Dutch + + + alt.binaries.boneless + + Report is complete + http://tvrage.com/Last_Man_Standing/episode_list/1 + + 0 + + + + https://newzbin2.es/browse/post/6514817/nzb/ + CPP-gebruiker@domein.nl (Darkling) + 5302349730 + Sat, 25 Feb 2012 14:57:21 GMT + + 3 + 0 + + + Mon, 27 Feb 2012 17:42:50 GMT +
    +
    +
    \ No newline at end of file diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 05e0fc562..ac1ccdfae 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -458,6 +458,22 @@ public void nzbmatrix_should_use_age_from_custom() parseResults[0].Age.Should().Be(expectedAge); } + [Test] + public void newzbin_should_mark_full_dvd_report_as_unknown() + { + WithConfiguredIndexers(); + + Mocker.GetMock() + .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) + .Returns(File.OpenRead(".\\Files\\Rss\\newzbin_full_dvd.xml")); + + //Act + var parseResults = Mocker.Resolve().FetchRss(); + + parseResults.Should().HaveCount(1); + parseResults[0].Quality.QualityType.Should().Be(QualityTypes.Unknown); + } + private static void Mark500Inconclusive() { ExceptionVerification.MarkInconclusive(typeof(WebException)); diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index dbdf1a558..79f973958 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -205,6 +205,9 @@ Always + + Always + Always diff --git a/NzbDrone.Core/Providers/Indexer/Newzbin.cs b/NzbDrone.Core/Providers/Indexer/Newzbin.cs index f5c5e0d39..faa88df3d 100644 --- a/NzbDrone.Core/Providers/Indexer/Newzbin.cs +++ b/NzbDrone.Core/Providers/Indexer/Newzbin.cs @@ -7,6 +7,7 @@ using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; +using NzbDrone.Core.Repository.Quality; namespace NzbDrone.Core.Providers.Indexer { @@ -107,6 +108,12 @@ protected override EpisodeParseResult CustomParser(SyndicationItem item, Episode var quality = Parser.ParseQuality(item.Summary.Text); currentResult.Quality = quality; + if (Regex.IsMatch(item.Summary.Text, @"\|\s+Video Format - DVD\s+\|", RegexOptions.Compiled | RegexOptions.IgnoreCase)) + { + _logger.Trace("Report is a full DVD, setting Quality to False"); + currentResult.Quality = new Quality(QualityTypes.Unknown, false); + } + var languageString = Regex.Match(item.Summary.Text, @"Language - \w*", RegexOptions.IgnoreCase).Value; currentResult.Language = Parser.ParseLanguage(languageString);