1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

broke episodeparseresult into filenameparseresult and indexerparseresult

This commit is contained in:
kay.one 2013-04-07 12:01:24 -07:00
parent 89f261eddf
commit 7c1e81a70e
61 changed files with 248 additions and 251 deletions

View File

@ -21,8 +21,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public class AcceptableSizeSpecificationFixture : CoreTest
{
private EpisodeParseResult parseResultMulti;
private EpisodeParseResult parseResultSingle;
private IndexerParseResult parseResultMulti;
private IndexerParseResult parseResultSingle;
private Series series30minutes;
private Series series60minutes;
private QualitySize qualityType;
@ -30,7 +30,7 @@ public class AcceptableSizeSpecificationFixture : CoreTest
[SetUp]
public void Setup()
{
parseResultMulti = new EpisodeParseResult
parseResultMulti = new IndexerParseResult
{
SeriesTitle = "Title",
Language = LanguageType.English,
@ -40,7 +40,7 @@ public void Setup()
AirDate = DateTime.Now.AddDays(-12).Date
};
parseResultSingle = new EpisodeParseResult
parseResultSingle = new IndexerParseResult
{
SeriesTitle = "Title",
Language = LanguageType.English,
@ -392,7 +392,7 @@ public void IsAcceptableSize_should_treat_daily_series_as_single_episode()
[Test]
public void should_return_true_if_RAWHD()
{
var parseResult = new EpisodeParseResult
var parseResult = new IndexerParseResult
{
Quality = new QualityModel(Quality.RAWHD, false)
};

View File

@ -12,7 +12,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[TestFixture]
public class AllowedDownloadSpecificationFixture : CoreTest<DownloadDecisionMaker>
{
private List<EpisodeParseResult> _parseResults;
private List<IndexerParseResult> _parseResults;
private Mock<IDecisionEngineSpecification> _pass1;
private Mock<IDecisionEngineSpecification> _pass2;
@ -33,15 +33,15 @@ public void Setup()
_fail2 = new Mock<IDecisionEngineSpecification>();
_fail3 = new Mock<IDecisionEngineSpecification>();
_pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(true);
_pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(true);
_pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(true);
_pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<IndexerParseResult>())).Returns(true);
_pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<IndexerParseResult>())).Returns(true);
_pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<IndexerParseResult>())).Returns(true);
_fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(false);
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(false);
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(false);
_fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<IndexerParseResult>())).Returns(false);
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<IndexerParseResult>())).Returns(false);
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<IndexerParseResult>())).Returns(false);
_parseResults = new List<EpisodeParseResult>() { new EpisodeParseResult() };
_parseResults = new List<IndexerParseResult>() { new IndexerParseResult() };
}

View File

@ -14,12 +14,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public class AllowedReleaseGroupSpecificationFixture : CoreTest<AllowedReleaseGroupSpecification>
{
private EpisodeParseResult parseResult;
private IndexerParseResult parseResult;
[SetUp]
public void Setup()
{
parseResult = new EpisodeParseResult
parseResult = new IndexerParseResult
{
SeriesTitle = "Title",
Language = LanguageType.English,

View File

@ -23,8 +23,8 @@ public class CustomStartDateSpecificationFixture : CoreTest
{
private CustomStartDateSpecification _customStartDateSpecification;
private EpisodeParseResult parseResultMulti;
private EpisodeParseResult parseResultSingle;
private IndexerParseResult parseResultMulti;
private IndexerParseResult parseResultSingle;
private Series fakeSeries;
private Episode firstEpisode;
private Episode secondEpisode;
@ -42,7 +42,7 @@ public void Setup()
.With(c => c.CustomStartDate = null)
.Build();
parseResultMulti = new EpisodeParseResult
parseResultMulti = new IndexerParseResult
{
SeriesTitle = "Title",
Series = fakeSeries,
@ -51,7 +51,7 @@ public void Setup()
Episodes = new List<Episode> { firstEpisode, secondEpisode }
};
parseResultSingle = new EpisodeParseResult
parseResultSingle = new IndexerParseResult
{
SeriesTitle = "Title",
Series = fakeSeries,

View File

@ -20,11 +20,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public class LanguageSpecificationFixture : CoreTest
{
private EpisodeParseResult parseResult;
private IndexerParseResult parseResult;
private void WithEnglishRelease()
{
parseResult = Builder<EpisodeParseResult>
parseResult = Builder<IndexerParseResult>
.CreateNew()
.With(p => p.Language = LanguageType.English)
.Build();
@ -32,7 +32,7 @@ private void WithEnglishRelease()
private void WithGermanRelease()
{
parseResult = Builder<EpisodeParseResult>
parseResult = Builder<IndexerParseResult>
.CreateNew()
.With(p => p.Language = LanguageType.German)
.Build();

View File

@ -23,8 +23,8 @@ public class MonitoredEpisodeSpecificationFixture : CoreTest
{
private MonitoredEpisodeSpecification monitoredEpisodeSpecification;
private EpisodeParseResult parseResultMulti;
private EpisodeParseResult parseResultSingle;
private IndexerParseResult parseResultMulti;
private IndexerParseResult parseResultSingle;
private Series fakeSeries;
private Episode firstEpisode;
private Episode secondEpisode;
@ -38,7 +38,7 @@ public void Setup()
.With(c => c.Monitored = true)
.Build();
parseResultMulti = new EpisodeParseResult
parseResultMulti = new IndexerParseResult
{
SeriesTitle = "Title",
Series = fakeSeries,
@ -46,7 +46,7 @@ public void Setup()
SeasonNumber = 12,
};
parseResultSingle = new EpisodeParseResult
parseResultSingle = new IndexerParseResult
{
SeriesTitle = "Title",
Series = fakeSeries,

View File

@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public class QualityAllowedByProfileSpecificationFixture : CoreTest
{
private QualityAllowedByProfileSpecification _qualityAllowedByProfile;
private EpisodeParseResult parseResult;
private IndexerParseResult parseResult;
public static object[] AllowedTestCases =
{
@ -45,7 +45,7 @@ public void Setup()
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.Bluray1080p })
.Build();
parseResult = new EpisodeParseResult
parseResult = new IndexerParseResult
{
Series = fakeSeries,
Quality = new QualityModel(Quality.DVD, true),

View File

@ -23,14 +23,14 @@ public class RetentionSpecificationFixture : CoreTest
{
private RetentionSpecification retentionSpecification;
private EpisodeParseResult parseResult;
private IndexerParseResult parseResult;
[SetUp]
public void Setup()
{
retentionSpecification = Mocker.Resolve<RetentionSpecification>();
parseResult = new EpisodeParseResult
parseResult = new IndexerParseResult
{
Age = 100
};

View File

@ -24,8 +24,8 @@ public class UpgradeDiskSpecificationFixture : CoreTest
{
private UpgradeDiskSpecification _upgradeDisk;
private EpisodeParseResult parseResultMulti;
private EpisodeParseResult parseResultSingle;
private IndexerParseResult parseResultMulti;
private IndexerParseResult parseResultSingle;
private EpisodeFile firstFile;
private EpisodeFile secondFile;
@ -45,7 +45,7 @@ public void Setup()
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.Bluray1080p })
.Build();
parseResultMulti = new EpisodeParseResult
parseResultMulti = new IndexerParseResult
{
Series = fakeSeries,
Quality = new QualityModel(Quality.DVD, true),
@ -54,7 +54,7 @@ public void Setup()
Episodes = doubleEpisodeList
};
parseResultSingle = new EpisodeParseResult
parseResultSingle = new IndexerParseResult
{
Series = fakeSeries,
Quality = new QualityModel(Quality.DVD, true),

View File

@ -22,8 +22,8 @@ public class UpgradeHistorySpecificationFixture : CoreTest
{
private UpgradeHistorySpecification _upgradeHistory;
private EpisodeParseResult _parseResultMulti;
private EpisodeParseResult _parseResultSingle;
private IndexerParseResult _parseResultMulti;
private IndexerParseResult _parseResultSingle;
private QualityModel _upgradableQuality;
private QualityModel _notupgradableQuality;
private Series _fakeSeries;
@ -45,7 +45,7 @@ public void Setup()
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.Bluray1080p })
.Build();
_parseResultMulti = new EpisodeParseResult
_parseResultMulti = new IndexerParseResult
{
Series = _fakeSeries,
Quality = new QualityModel(Quality.DVD, true),
@ -54,7 +54,7 @@ public void Setup()
Episodes = doubleEpisodeList
};
_parseResultSingle = new EpisodeParseResult
_parseResultSingle = new IndexerParseResult
{
Series = _fakeSeries,
Quality = new QualityModel(Quality.DVD, true),

View File

@ -116,7 +116,7 @@ public void is_in_queue_should_find_if_exact_episode_is_in_queue()
{
WithFullQueue();
var parseResult = new EpisodeParseResult
var parseResult = new IndexerParseResult
{
EpisodeTitle = "Title",
EpisodeNumbers = new List<int> { 5 },
@ -136,7 +136,7 @@ public void is_in_queue_should_find_if_exact_daily_episode_is_in_queue()
{
WithFullQueue();
var parseResult = new EpisodeParseResult
var parseResult = new IndexerParseResult
{
Quality = new QualityModel { Quality = Quality.Bluray720p, Proper = false },
AirDate = new DateTime(2011, 12, 01),
@ -155,7 +155,7 @@ public void is_in_queue_should_find_if_exact_full_season_release_is_in_queue()
WithFullQueue();
var parseResult = new EpisodeParseResult
var parseResult = new IndexerParseResult
{
Quality = new QualityModel { Quality = Quality.Bluray720p, Proper = false },
FullSeason = true,
@ -184,7 +184,7 @@ public void IsInQueue_should_not_find_diffrent_episode_queue(int season, int[] e
{
WithFullQueue();
var parseResult = new EpisodeParseResult
var parseResult = new IndexerParseResult
{
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
@ -213,7 +213,7 @@ public void IsInQueue_should_find_same_or_lower_quality_episode_queue(int season
{
WithFullQueue();
var parseResult = new EpisodeParseResult
var parseResult = new IndexerParseResult
{
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
@ -240,7 +240,7 @@ public void IsInQueue_should_find_items_marked_as_duplicate(int season, int[] ep
{
WithFullQueue();
var parseResult = new EpisodeParseResult
var parseResult = new IndexerParseResult
{
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
@ -267,7 +267,7 @@ public void IsInQueue_should_find_double_episodes_(int season, int[] episodes, s
{
WithFullQueue();
var parseResult = new EpisodeParseResult
var parseResult = new IndexerParseResult
{
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
@ -286,7 +286,7 @@ public void IsInQueue_should_return_false_if_queue_is_empty()
{
WithEmptyQueue();
var parseResult = new EpisodeParseResult
var parseResult = new IndexerParseResult
{
EpisodeTitle = "Title",
EpisodeNumbers = new List<int> { 1 },

View File

@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.Download
[TestFixture]
public class DownloadServiceFixture : CoreTest<DownloadService>
{
private EpisodeParseResult _parseResult;
private IndexerParseResult _parseResult;
[SetUp]
public void Setup()
@ -29,7 +29,7 @@ public void Setup()
.All().With(s => s.SeriesId = 5)
.Build().ToList();
_parseResult = Builder<EpisodeParseResult>.CreateNew()
_parseResult = Builder<IndexerParseResult>.CreateNew()
.With(c => c.Quality = new QualityModel(Quality.DVD, false))
.With(c => c.Series = Builder<Series>.CreateNew().Build())
.With(c => c.EpisodeNumbers = new List<int> { 2 })

View File

@ -18,7 +18,7 @@ public class EpisodeParseResultTest : CoreTest
[Test]
public void tostring_single_season_episode()
{
var parseResult = new EpisodeParseResult();
var parseResult = new IndexerParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.EpisodeNumbers = new List<int> { 3 };
@ -33,7 +33,7 @@ public void tostring_single_season_episode()
[Test]
public void tostring_single_season_episode_proper()
{
var parseResult = new EpisodeParseResult();
var parseResult = new IndexerParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.EpisodeNumbers = new List<int> { 3 };
@ -48,7 +48,7 @@ public void tostring_single_season_episode_proper()
[Test]
public void tostring_multi_season_episode()
{
var parseResult = new EpisodeParseResult();
var parseResult = new IndexerParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
@ -63,7 +63,7 @@ public void tostring_multi_season_episode()
[Test]
public void tostring_multi_season_episode_proper()
{
var parseResult = new EpisodeParseResult();
var parseResult = new IndexerParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
@ -79,7 +79,7 @@ public void tostring_multi_season_episode_proper()
[Test]
public void tostring_full_season()
{
var parseResult = new EpisodeParseResult();
var parseResult = new IndexerParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
@ -94,7 +94,7 @@ public void tostring_full_season()
[Test]
public void tostring_full_season_proper()
{
var parseResult = new EpisodeParseResult();
var parseResult = new IndexerParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
@ -108,7 +108,7 @@ public void tostring_full_season_proper()
[Test]
public void tostring_daily_show()
{
var parseResult = new EpisodeParseResult();
var parseResult = new IndexerParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
@ -122,7 +122,7 @@ public void tostring_daily_show()
[Test]
public void tostring_daily_show_proper()
{
var parseResult = new EpisodeParseResult();
var parseResult = new IndexerParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
@ -162,7 +162,7 @@ public void create_proper_sab_titles(int seasons, int[] episodes, string title,
.With(e => e.Title = title)
.Build());
var parsResult = new EpisodeParseResult()
var parsResult = new IndexerParseResult()
{
AirDate = DateTime.Now,
EpisodeNumbers = episodes.ToList(),
@ -184,7 +184,7 @@ public string create_proper_sab_season_title(bool proper)
.With(c => c.Title = "My Series Name")
.Build();
var parsResult = new EpisodeParseResult()
var parsResult = new IndexerParseResult()
{
AirDate = DateTime.Now,
Quality = new QualityModel(Quality.Bluray720p, proper),
@ -210,7 +210,7 @@ public string create_proper_sab_daily_titles(bool proper)
.With(e => e.Title = "My Episode Title")
.Build();
var parsResult = new EpisodeParseResult
var parsResult = new IndexerParseResult
{
AirDate = new DateTime(2011, 12, 1),
Quality = new QualityModel(Quality.Bluray720p, proper),
@ -238,7 +238,7 @@ public void should_not_repeat_the_same_episode_title()
.With(e => e.Title = "My Episode Title (2)")
.Build();
var parsResult = new EpisodeParseResult
var parsResult = new IndexerParseResult
{
AirDate = DateTime.Now,
EpisodeNumbers = new List<int> { 10, 11 },

View File

@ -10,7 +10,7 @@
namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
public class ParserFixture : CoreTest
{
@ -78,7 +78,7 @@ public class ParserFixture : CoreTest
[TestCase("Portlandia.S03E10.Alexandra.720p.WEB-DL.AAC2.0.H.264-CROM.mkv", "Portlandia", 3, 10)]
public void ParseTitle_single(string postTitle, string title, int seasonNumber, int episodeNumber)
{
var result = Parser.ParseTitle(postTitle);
var result = Parser.ParseTitle<IndexerParseResult>(postTitle);
result.Should().NotBeNull();
result.EpisodeNumbers.Should().HaveCount(1);
result.SeasonNumber.Should().Be(seasonNumber);
@ -113,7 +113,7 @@ public void PathParse_tests(string path, int season, int episode)
public void unparsable_path_should_report_the_path()
{
Parser.ParsePath("C:\\").Should().BeNull();
MockedRestProvider.Verify(c => c.PostData(It.IsAny<string>(), It.IsAny<ParseErrorReport>()), Times.Exactly(2));
ExceptionVerification.IgnoreWarns();
@ -124,7 +124,7 @@ public void unparsable_title_should_report_title()
{
const string TITLE = "SOMETHING";
Parser.ParseTitle(TITLE).Should().BeNull();
Parser.ParseTitle<ParseResult>(TITLE).Should().BeNull();
MockedRestProvider.Verify(c => c.PostData(It.IsAny<string>(), It.Is<ParseErrorReport>(r => r.Title == TITLE)), Times.Once());
@ -144,7 +144,7 @@ public void unparsable_title_should_report_title()
[TestCase("S07E22 - 7x23 - And Lots of Security.. [HDTV-720p].mkv", "", 7, new[] { 22, 23 })]
[TestCase("2x04x05.720p.BluRay-FUTV", "", 2, new[] { 4, 5 })]
[TestCase("S02E04E05.720p.BluRay-FUTV", "", 2, new[] { 4, 5 })]
[TestCase("S02E03-04-05.720p.BluRay-FUTV", "", 2, new[] { 3,4,5 })]
[TestCase("S02E03-04-05.720p.BluRay-FUTV", "", 2, new[] { 3, 4, 5 })]
[TestCase("Breakout.Kings.S02E09-E10.HDTV.x264-ASAP", "Breakout Kings", 2, new[] { 9, 10 })]
[TestCase("Breakout Kings - 2x9-2x10 - Served Cold [SDTV] ", "Breakout Kings", 2, new[] { 9, 10 })]
[TestCase("Breakout Kings - 2x09-2x10 - Served Cold [SDTV] ", "Breakout Kings", 2, new[] { 9, 10 })]
@ -152,7 +152,7 @@ public void unparsable_title_should_report_title()
[TestCase("Hell.on.Wheels.S02E09-E10.720p.HDTV.x264-EVOLVE", "Hell on Wheels", 2, new[] { 9, 10 })]
public void TitleParse_multi(string postTitle, string title, int season, int[] episodes)
{
var result = Parser.ParseTitle(postTitle);
var result = Parser.ParseTitle<ParseResult>(postTitle);
result.SeasonNumber.Should().Be(season);
result.EpisodeNumbers.Should().BeEquivalentTo(episodes);
result.CleanTitle.Should().Be(Parser.NormalizeTitle(title));
@ -167,12 +167,12 @@ public void TitleParse_multi(string postTitle, string title, int season, int[] e
[TestCase("2011.01.10 - Denis Leary - HD TV.mkv", "", 2011, 1, 10)]
[TestCase("2011.03.13 - Denis Leary - HD TV.mkv", "", 2011, 3, 13)]
[TestCase("The Tonight Show with Jay Leno - 2011-06-16 - Larry David, \"Bachelorette\" Ashley Hebert, Pitbull with Ne-Yo", "The Tonight Show with Jay Leno", 2011, 6, 16)]
[TestCase("2020.NZ.2012.16.02.PDTV.XviD-C4TV","2020nz", 2012,2, 16)]
[TestCase("2020.NZ.2012.13.02.PDTV.XviD-C4TV","2020nz", 2012,2, 13)]
[TestCase("2020.NZ.2011.12.02.PDTV.XviD-C4TV","2020nz", 2011,12, 2)]
[TestCase("2020.NZ.2012.16.02.PDTV.XviD-C4TV", "2020nz", 2012, 2, 16)]
[TestCase("2020.NZ.2012.13.02.PDTV.XviD-C4TV", "2020nz", 2012, 2, 13)]
[TestCase("2020.NZ.2011.12.02.PDTV.XviD-C4TV", "2020nz", 2011, 12, 2)]
public void parse_daily_episodes(string postTitle, string title, int year, int month, int day)
{
var result = Parser.ParseTitle(postTitle);
var result = Parser.ParseTitle<ParseResult>(postTitle);
var airDate = new DateTime(year, month, day);
result.Should().NotBeNull();
result.CleanTitle.Should().Be(Parser.NormalizeTitle(title));
@ -186,7 +186,7 @@ public void parse_daily_should_fail_if_episode_is_far_in_future()
{
var title = string.Format("{0:yyyy.MM.dd} - Denis Leary - HD TV.mkv", DateTime.Now.AddDays(2));
Parser.ParseTitle(title).Should().BeNull();
Parser.ParseTitle<ParseResult>(title).Should().BeNull();
}
@ -197,7 +197,7 @@ public void parse_daily_should_fail_if_episode_is_far_in_future()
[TestCase("Adventure Time S02 720p HDTV x264 CRON", "Adventure Time", 2)]
public void full_season_release_parse(string postTitle, string title, int season)
{
var result = Parser.ParseTitle(postTitle);
var result = Parser.ParseTitle<ParseResult>(postTitle);
result.SeasonNumber.Should().Be(season);
result.CleanTitle.Should().Be(Parser.NormalizeTitle(title));
result.EpisodeNumbers.Count.Should().Be(0);
@ -338,7 +338,7 @@ public void parse_language(string postTitle, LanguageType language)
[TestCase("Doctor Who Confidential Season 3", "Doctor Who Confidential", 3)]
public void parse_season_info(string postTitle, string seriesName, int seasonNumber)
{
var result = Parser.ParseTitle(postTitle);
var result = Parser.ParseTitle<ParseResult>(postTitle);
result.CleanTitle.Should().Be(Parser.NormalizeTitle(seriesName));
result.SeasonNumber.Should().Be(seasonNumber);
@ -364,7 +364,7 @@ public void parse_size(string sizeString, long expectedSize)
[TestCase("Instant Star S03 EXTRAS DVDRip XviD OSiTV")]
public void parse_season_extras(string postTitle)
{
var result = Parser.ParseTitle(postTitle);
var result = Parser.ParseTitle<ParseResult>(postTitle);
result.Should().BeNull();
}
@ -374,7 +374,7 @@ public void parse_season_extras(string postTitle)
[TestCase("CSI.S11.SUBPACK.DVDRip.XviD-REWARD")]
public void parse_season_subpack(string postTitle)
{
var result = Parser.ParseTitle(postTitle);
var result = Parser.ParseTitle<ParseResult>(postTitle);
result.Should().BeNull();
}
@ -382,22 +382,11 @@ public void parse_season_subpack(string postTitle)
[TestCase("Fussball Bundesliga 10e2011e30 Spieltag FC Bayern Muenchen vs Bayer 04 Leverkusen German WS dTV XviD WoGS")]
public void unparsable_should_log_error_but_not_throw(string title)
{
Parser.ParseTitle(title);
Parser.ParseTitle<ParseResult>(title);
ExceptionVerification.IgnoreWarns();
ExceptionVerification.ExpectedErrors(1);
}
[TestCase("Castle.2009.S01E14.English.HDTV.XviD-LOL", "LOL")]
[TestCase("Castle 2009 S01E14 English HDTV XviD LOL", "LOL")]
[TestCase("Acropolis Now S05 EXTRAS DVDRip XviD RUNNER", "RUNNER")]
[TestCase("Punky.Brewster.S01.EXTRAS.DVDRip.XviD-RUNNER", "RUNNER")]
[TestCase("2020.NZ.2011.12.02.PDTV.XviD-C4TV", "C4TV")]
[TestCase("The.Office.S03E115.DVDRip.XviD-OSiTV", "OSiTV")]
public void parse_releaseGroup(string title, string expected)
{
Parser.ParseReleaseGroup(title).Should().Be(expected);
}
[TestCase("[112461]-[FULL]-[#a.b.teevee@EFNet]-[ 666.Park.Avenue.S01E03.720p.HDTV.X264-DIMENSION ]-[02/31] - \"the.devils.address.103.720p-dimension.par2\" yEnc", "666.Park.Avenue.S01E03.720p.HDTV.X264-DIMENSION")]
[TestCase("[112438]-[FULL]-[#a.b.teevee@EFNet]-[ Downton_Abbey.3x05.HDTV_x264-FoV ]-[01/26] - \"downton_abbey.3x05.hdtv_x264-fov.nfo\" yEnc", "Downton_Abbey.3x05.HDTV_x264-FoV")]
[TestCase("[ 21154 ] - [ TrollHD ] - [ 00/73 ] - \"MythBusters S03E20 Escape Slide Parachute 1080i HDTV-UPSCALE DD5.1 MPEG2-TrollHD.nzb\" yEnc", "MythBusters S03E20 Escape Slide Parachute 1080i HDTV-UPSCALE DD5.1 MPEG2-TrollHD.nzb")]
@ -409,7 +398,7 @@ public void parse_header(string title, string expected)
[TestCase("password - \"bdc435cb-93c4-4902-97ea-ca00568c3887.337\" yEnc")]
public void should_not_parse_encypted_posts(string title)
{
Parser.ParseTitle(title).Should().BeNull();
Parser.ParseTitle<ParseResult>(title).Should().BeNull();
ExceptionVerification.IgnoreWarns();
}
}

View File

@ -68,7 +68,7 @@ public void import_new_file_should_succeed()
.Returns(false);
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>())).Returns(new List<Episode> { fakeEpisode });
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, newFile);
@ -95,7 +95,7 @@ public void import_new_file_with_better_same_quality_should_succeed(Quality curr
With80MBFile();
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>())).Returns(new List<Episode> { fakeEpisode });
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, newFile);
@ -125,7 +125,7 @@ public void import_new_file_episode_has_same_or_better_quality_should_skip(strin
.Returns(false);
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>())).Returns(new List<Episode> { fakeEpisode });
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
@ -195,7 +195,7 @@ public void import_file_with_no_episode_in_db_should_skip()
.Returns(false);
Mocker.GetMock<IEpisodeService>()
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>()))
.Returns(new List<Episode>());
@ -226,7 +226,7 @@ public void import_new_file_episode_has_better_quality_than_existing(string file
.Returns(false);
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>())).Returns(new List<Episode> { fakeEpisode });
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
@ -258,7 +258,7 @@ public void import_new_multi_part_file_episode_has_equal_or_better_quality_than_
.Returns(false);
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(fakeEpisodes);
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>())).Returns(fakeEpisodes);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
@ -291,7 +291,7 @@ public void skip_import_new_multi_part_file_episode_existing_has_better_quality(
.Returns(false);
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(fakeEpisodes);
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>())).Returns(fakeEpisodes);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
@ -329,7 +329,7 @@ public void import_new_multi_part_file_episode_replace_two_files()
.Returns(false);
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode1, fakeEpisode2 });
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>())).Returns(new List<Episode> { fakeEpisode1, fakeEpisode2 });
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
@ -358,7 +358,7 @@ public void should_import_new_episode_no_existing_episode_file()
.Returns(false);
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>())).Returns(new List<Episode> { fakeEpisode });
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
@ -380,7 +380,7 @@ public void should_set_parseResult_SceneSource_if_not_in_series_Path()
With80MBFile();
Mocker.GetMock<IEpisodeService>().Setup(s => s.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
Mocker.GetMock<IEpisodeService>().Setup(s => s.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>()))
.Returns(new List<Episode>());
Mocker.GetMock<DiskProvider>().Setup(s => s.IsChildOfPath(path, series.Path))
@ -388,7 +388,7 @@ public void should_set_parseResult_SceneSource_if_not_in_series_Path()
Mocker.Resolve<DiskScanProvider>().ImportFile(series, path);
Mocker.Verify<IEpisodeService>(s => s.GetEpisodesByParseResult(It.Is<EpisodeParseResult>(p => p.SceneSource)), Times.Once());
Mocker.Verify<IEpisodeService>(s => s.GetEpisodesByParseResult(It.Is<IndexerParseResult>(p => p.SceneSource)), Times.Once());
}
[Test]
@ -403,7 +403,7 @@ public void should_not_set_parseResult_SceneSource_if_in_series_Path()
With80MBFile();
Mocker.GetMock<IEpisodeService>().Setup(s => s.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
Mocker.GetMock<IEpisodeService>().Setup(s => s.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>()))
.Returns(new List<Episode>());
Mocker.GetMock<DiskProvider>().Setup(s => s.IsChildOfPath(path, series.Path))
@ -411,7 +411,7 @@ public void should_not_set_parseResult_SceneSource_if_in_series_Path()
Mocker.Resolve<DiskScanProvider>().ImportFile(series, path);
Mocker.Verify<IEpisodeService>(s => s.GetEpisodesByParseResult(It.Is<EpisodeParseResult>(p => p.SceneSource == false)), Times.Once());
Mocker.Verify<IEpisodeService>(s => s.GetEpisodesByParseResult(It.Is<IndexerParseResult>(p => p.SceneSource == false)), Times.Once());
}
[Test]
@ -455,7 +455,7 @@ public void should_import_if_file_size_is_under_70MB_but_runTime_over_3_minutes(
.Returns(600);
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>())).Returns(new List<Episode> { fakeEpisode });
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(_series, path);
@ -482,7 +482,7 @@ public void should_import_if_file_size_is_over_70MB_but_runTime_under_3_minutes(
.Returns(60);
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>())).Returns(new List<Episode> { fakeEpisode });
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(_series, path);
@ -513,7 +513,7 @@ public void should_import_special_even_if_file_size_is_under_70MB_and_runTime_un
.Returns(60);
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<IndexerParseResult>())).Returns(new List<Episode> { fakeEpisode });
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(_series, path);

View File

@ -6,7 +6,7 @@ namespace NzbDrone.Core.DecisionEngine
{
public class DownloadDecision
{
public EpisodeParseResult ParseResult { get; private set; }
public IndexerParseResult ParseResult { get; private set; }
public IEnumerable<string> Rejections { get; private set; }
public bool Approved
@ -17,14 +17,14 @@ public bool Approved
}
}
public DownloadDecision(EpisodeParseResult parseResult, params string[] rejections)
public DownloadDecision(IndexerParseResult parseResult, params string[] rejections)
{
ParseResult = parseResult;
Rejections = rejections.ToList();
}
public static EpisodeParseResult PickBestReport(IEnumerable<DownloadDecision> downloadDecisions)
public static IndexerParseResult PickBestReport(IEnumerable<DownloadDecision> downloadDecisions)
{
var reports = downloadDecisions
.Where(c => c.Approved)

View File

@ -8,8 +8,8 @@ namespace NzbDrone.Core.DecisionEngine
{
public interface IMakeDownloadDecision
{
IEnumerable<DownloadDecision> GetRssDecision(IEnumerable<EpisodeParseResult> episodeParseResults);
IEnumerable<DownloadDecision> GetSearchDecision(IEnumerable<EpisodeParseResult> episodeParseResult, SearchDefinitionBase searchDefinitionBase);
IEnumerable<DownloadDecision> GetRssDecision(IEnumerable<IndexerParseResult> episodeParseResults);
IEnumerable<DownloadDecision> GetSearchDecision(IEnumerable<IndexerParseResult> episodeParseResult, SearchDefinitionBase searchDefinitionBase);
}
public class DownloadDecisionMaker : IMakeDownloadDecision
@ -21,7 +21,7 @@ public DownloadDecisionMaker(IEnumerable<IRejectWithReason> specifications)
_specifications = specifications;
}
public IEnumerable<DownloadDecision> GetRssDecision(IEnumerable<EpisodeParseResult> episodeParseResults)
public IEnumerable<DownloadDecision> GetRssDecision(IEnumerable<IndexerParseResult> episodeParseResults)
{
foreach (var parseResult in episodeParseResults)
{
@ -31,7 +31,7 @@ public IEnumerable<DownloadDecision> GetRssDecision(IEnumerable<EpisodeParseResu
}
public IEnumerable<DownloadDecision> GetSearchDecision(IEnumerable<EpisodeParseResult> episodeParseResults, SearchDefinitionBase searchDefinitionBase)
public IEnumerable<DownloadDecision> GetSearchDecision(IEnumerable<IndexerParseResult> episodeParseResults, SearchDefinitionBase searchDefinitionBase)
{
foreach (var parseResult in episodeParseResults)
{
@ -45,19 +45,19 @@ public IEnumerable<DownloadDecision> GetSearchDecision(IEnumerable<EpisodeParseR
}
private IEnumerable<string> GetGeneralRejectionReasons(EpisodeParseResult episodeParseResult)
private IEnumerable<string> GetGeneralRejectionReasons(IndexerParseResult indexerParseResult)
{
return _specifications
.OfType<IDecisionEngineSpecification>()
.Where(spec => !spec.IsSatisfiedBy(episodeParseResult))
.Where(spec => !spec.IsSatisfiedBy(indexerParseResult))
.Select(spec => spec.RejectionReason);
}
private IEnumerable<string> GetSearchRejectionReasons(EpisodeParseResult episodeParseResult, SearchDefinitionBase searchDefinitionBase)
private IEnumerable<string> GetSearchRejectionReasons(IndexerParseResult indexerParseResult, SearchDefinitionBase searchDefinitionBase)
{
return _specifications
.OfType<IDecisionEngineSearchSpecification>()
.Where(spec => !spec.IsSatisfiedBy(episodeParseResult, searchDefinitionBase))
.Where(spec => !spec.IsSatisfiedBy(indexerParseResult, searchDefinitionBase))
.Select(spec => spec.RejectionReason);
}
}

View File

@ -4,6 +4,6 @@ namespace NzbDrone.Core.DecisionEngine
{
public interface IDecisionEngineSpecification : IRejectWithReason
{
bool IsSatisfiedBy(EpisodeParseResult subject);
bool IsSatisfiedBy(IndexerParseResult subject);
}
}

View File

@ -23,7 +23,7 @@ public string RejectionReason
get { return "File size too big or small"; }
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
public virtual bool IsSatisfiedBy(IndexerParseResult subject)
{
_logger.Trace("Beginning size check for: {0}", subject);

View File

@ -25,7 +25,7 @@ public string RejectionReason
}
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
public virtual bool IsSatisfiedBy(IndexerParseResult subject)
{
_logger.Trace("Beginning release group check for: {0}", subject);

View File

@ -22,7 +22,7 @@ public string RejectionReason
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
public virtual bool IsSatisfiedBy(IndexerParseResult subject)
{
if (!subject.Series.CustomStartDate.HasValue)
{

View File

@ -20,7 +20,7 @@ public string RejectionReason
}
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
public virtual bool IsSatisfiedBy(IndexerParseResult subject)
{
_logger.Trace("Checking if report meets language requirements. {0}", subject.Language);
if (subject.Language != LanguageType.English)

View File

@ -26,7 +26,7 @@ public string RejectionReason
}
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
public virtual bool IsSatisfiedBy(IndexerParseResult subject)
{
var series = _seriesRepository.GetByTitle(subject.CleanTitle);

View File

@ -21,7 +21,7 @@ public string RejectionReason
}
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
public virtual bool IsSatisfiedBy(IndexerParseResult subject)
{
return !_downloadClientProvider.GetDownloadClient().IsInQueue(subject);
}

View File

@ -20,7 +20,7 @@ public string RejectionReason
}
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
public virtual bool IsSatisfiedBy(IndexerParseResult subject)
{
_logger.Trace("Checking if report meets quality requirements. {0}", subject.Quality);
if (!subject.Series.QualityProfile.Allowed.Contains(subject.Quality.Quality))

View File

@ -24,7 +24,7 @@ public string RejectionReason
}
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
public virtual bool IsSatisfiedBy(IndexerParseResult subject)
{
_logger.Trace("Checking if report meets retention requirements. {0}", subject.Age);
if (_configService.Retention > 0 && subject.Age > _configService.Retention)

View File

@ -23,7 +23,7 @@ public string RejectionReason
return "Episode doesn't match";
}
}
public bool IsSatisfiedBy(EpisodeParseResult episodeParseResult, SearchDefinitionBase searchDefinitionBase)
public bool IsSatisfiedBy(IndexerParseResult indexerParseResult, SearchDefinitionBase searchDefinitionBase)
{
var dailySearchSpec = searchDefinitionBase as DailyEpisodeSearchDefinition;
@ -31,7 +31,7 @@ public bool IsSatisfiedBy(EpisodeParseResult episodeParseResult, SearchDefinitio
var episode = _episodeService.GetEpisode(dailySearchSpec.SeriesId, dailySearchSpec.Airtime);
if (!episodeParseResult.AirDate.HasValue || episodeParseResult.AirDate.Value != episode.AirDate.Value)
if (!indexerParseResult.AirDate.HasValue || indexerParseResult.AirDate.Value != episode.AirDate.Value)
{
_logger.Trace("Episode AirDate does not match searched episode number, skipping.");
return false;

View File

@ -6,6 +6,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
{
public interface IDecisionEngineSearchSpecification : IRejectWithReason
{
bool IsSatisfiedBy(EpisodeParseResult subject, SearchDefinitionBase searchDefinitionBase);
bool IsSatisfiedBy(IndexerParseResult indexerParseResult, SearchDefinitionBase searchDefinitionBase);
}
}

View File

@ -21,12 +21,12 @@ public string RejectionReason
}
}
public bool IsSatisfiedBy(EpisodeParseResult episodeParseResult, SearchDefinitionBase searchDefinitionBase)
public bool IsSatisfiedBy(IndexerParseResult indexerParseResult, SearchDefinitionBase searchDefinitionBase)
{
var singleEpisodeSpec = searchDefinitionBase as SeasonSearchDefinition;
if (singleEpisodeSpec == null) return true;
if (singleEpisodeSpec.SeasonNumber != episodeParseResult.SeasonNumber)
if (singleEpisodeSpec.SeasonNumber != indexerParseResult.SeasonNumber)
{
_logger.Trace("Season number does not match searched season number, skipping.");
return false;

View File

@ -21,18 +21,18 @@ public string RejectionReason
}
}
public bool IsSatisfiedBy(EpisodeParseResult episodeParseResult, SearchDefinitionBase searchDefinitionBase)
public bool IsSatisfiedBy(IndexerParseResult indexerParseResult, SearchDefinitionBase searchDefinitionBase)
{
var singleEpisodeSpec = searchDefinitionBase as SingleEpisodeSearchDefinition;
if (singleEpisodeSpec == null) return true;
if (singleEpisodeSpec.SeasonNumber != episodeParseResult.SeasonNumber)
if (singleEpisodeSpec.SeasonNumber != indexerParseResult.SeasonNumber)
{
_logger.Trace("Season number does not match searched season number, skipping.");
return false;
}
if (!episodeParseResult.EpisodeNumbers.Contains(singleEpisodeSpec.EpisodeNumber))
if (!indexerParseResult.EpisodeNumbers.Contains(singleEpisodeSpec.EpisodeNumber))
{
_logger.Trace("Episode number does not match searched episode number, skipping.");
return false;

View File

@ -25,7 +25,7 @@ public string RejectionReason
}
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
public virtual bool IsSatisfiedBy(IndexerParseResult subject)
{
foreach (var file in subject.Episodes.Select(c => c.EpisodeFile).Where(c => c != null))
{

View File

@ -25,7 +25,7 @@ public string RejectionReason
}
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
public virtual bool IsSatisfiedBy(IndexerParseResult subject)
{
foreach (var episode in subject.Episodes)
{

View File

@ -59,7 +59,7 @@ public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
}
}
public virtual bool IsInQueue(EpisodeParseResult newParseResult)
public virtual bool IsInQueue(IndexerParseResult newParseResult)
{
return !_upgradeHistorySpecification.IsSatisfiedBy(newParseResult);
}

View File

@ -27,7 +27,7 @@ public NzbgetProvider()
{
}
public virtual bool IsInQueue(EpisodeParseResult newParseResult)
public virtual bool IsInQueue(IndexerParseResult newParseResult)
{
try
{

View File

@ -18,7 +18,7 @@ public string Title
set
{
_title = value;
ParseResult = Parser.ParseTitle(value.Replace("DUPLICATE / ", String.Empty));
ParseResult = Parser.ParseTitle<ParseResult>(value.Replace("DUPLICATE / ", String.Empty));
}
}
@ -26,6 +26,6 @@ public string Title
public Int32 FileSizeMb { get; set; }
public Int32 RemainingSizeMb { get; set; }
public EpisodeParseResult ParseResult { private set; get; }
public ParseResult ParseResult { private set; get; }
}
}

View File

@ -33,7 +33,7 @@ public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
try
{
//Todo: Allow full season releases
if (Parser.ParseTitle(title).FullSeason)
if (Parser.ParseTitle<ParseResult>(title).FullSeason)
{
logger.Info("Skipping Full Season Release: {0}", title);
return false;
@ -58,7 +58,7 @@ public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
var contents = String.Format("plugin://plugin.program.pneumatic/?mode=strm&type=add_file&nzb={0}&nzbname={1}", filename, title);
_diskProvider.WriteAllText(Path.Combine(_configService.DownloadClientTvDirectory, title + ".strm"), contents);
return true;
}
catch (Exception ex)
@ -68,7 +68,7 @@ public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
}
}
public virtual bool IsInQueue(EpisodeParseResult newParseResult)
public virtual bool IsInQueue(IndexerParseResult newParseResult)
{
return false;
}

View File

@ -31,7 +31,7 @@ public SabProvider()
{
}
public virtual bool IsInQueue(EpisodeParseResult newParseResult)
public virtual bool IsInQueue(IndexerParseResult newParseResult)
{
try
{

View File

@ -1,8 +1,6 @@
using System;
using System.Linq;
using Newtonsoft.Json;
using NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
namespace NzbDrone.Core.Download.Clients.Sabnzbd
@ -27,7 +25,7 @@ public string Title
set
{
_title = value;
ParseResult = Parser.ParseTitle(value.Replace("DUPLICATE / ", String.Empty));
ParseResult = Parser.ParseTitle<ParseResult>(value.Replace("DUPLICATE / ", String.Empty));
}
}
@ -45,6 +43,6 @@ public string Title
[JsonProperty(PropertyName = "nzo_id")]
public string Id { get; set; }
public EpisodeParseResult ParseResult { private set; get; }
public ParseResult ParseResult { private set; get; }
}
}

View File

@ -12,7 +12,7 @@ namespace NzbDrone.Core.Download
{
public interface IDownloadService
{
bool DownloadReport(EpisodeParseResult parseResult);
bool DownloadReport(IndexerParseResult parseResult);
}
public class DownloadService : IDownloadService
@ -32,7 +32,7 @@ public DownloadService(IProvideDownloadClient downloadClientProvider, IConfigSer
_logger = logger;
}
public bool DownloadReport(EpisodeParseResult parseResult)
public bool DownloadReport(IndexerParseResult parseResult)
{
var downloadTitle = parseResult.OriginalString;
if (!_configService.DownloadClientUseSceneName)
@ -54,7 +54,7 @@ public bool DownloadReport(EpisodeParseResult parseResult)
return success;
}
private static bool ContainsRecentEpisode(EpisodeParseResult parseResult)
private static bool ContainsRecentEpisode(IndexerParseResult parseResult)
{
return parseResult.Episodes.Any(e => e.AirDate >= DateTime.Today.AddDays(-7));
}

View File

@ -5,9 +5,9 @@ namespace NzbDrone.Core.Download
{
public class EpisodeGrabbedEvent : IEvent
{
public EpisodeParseResult ParseResult { get; private set; }
public IndexerParseResult ParseResult { get; private set; }
public EpisodeGrabbedEvent(EpisodeParseResult parseResult)
public EpisodeGrabbedEvent(IndexerParseResult parseResult)
{
ParseResult = parseResult;
}

View File

@ -5,7 +5,7 @@ namespace NzbDrone.Core.Download
{
public interface IDownloadClient
{
bool IsInQueue(EpisodeParseResult newParseResult);
bool IsInQueue(IndexerParseResult newParseResult);
bool DownloadNzb(string url, string title, bool recentlyAired);
}
}

View File

@ -100,7 +100,7 @@ public void Handle(EpisodeDownloadedEvent message)
try
{
_logger.Trace("Sending download notification to {0}", Name);
OnDownload(message.ParseResult.GetDownloadTitle(), message.ParseResult.Series);
OnDownload(message.ParseResult.ToString(), message.ParseResult.Series);
}
catch (Exception e)
{

View File

@ -105,10 +105,10 @@ private List<DownloadDecision> PartialSeasonSearch(SeasonSearchDefinition search
return spec;
}
private List<DownloadDecision> Dispatch(Func<IIndexerBase, IEnumerable<EpisodeParseResult>> searchAction, SearchDefinitionBase definitionBase)
private List<DownloadDecision> Dispatch(Func<IIndexerBase, IEnumerable<IndexerParseResult>> searchAction, SearchDefinitionBase definitionBase)
{
var indexers = _indexerService.GetAvailableIndexers();
var parseResults = new List<EpisodeParseResult>();
var parseResults = new List<IndexerParseResult>();
Parallel.ForEach(indexers, indexer =>
{

View File

@ -9,7 +9,7 @@ namespace NzbDrone.Core.Indexers
{
public interface IParseFeed
{
IEnumerable<EpisodeParseResult> Process(Stream source);
IEnumerable<IndexerParseResult> Process(Stream source);
}
public class BasicRssParser : IParseFeed
@ -21,12 +21,12 @@ public BasicRssParser()
_logger = LogManager.GetCurrentClassLogger();
}
public IEnumerable<EpisodeParseResult> Process(Stream source)
public IEnumerable<IndexerParseResult> Process(Stream source)
{
var reader = new SyndicationFeedXmlReader(source);
var feed = SyndicationFeed.Load(reader).Items;
var result = new List<EpisodeParseResult>();
var result = new List<IndexerParseResult>();
foreach (var syndicationItem in feed)
{
@ -66,26 +66,46 @@ protected virtual string GetNzbInfoUrl(SyndicationItem item)
return string.Empty;
}
protected virtual EpisodeParseResult PostProcessor(SyndicationItem item, EpisodeParseResult currentResult)
protected virtual IndexerParseResult PostProcessor(SyndicationItem item, IndexerParseResult currentResult)
{
return currentResult;
}
private EpisodeParseResult ParseFeed(SyndicationItem item)
private IndexerParseResult ParseFeed(SyndicationItem item)
{
var title = GetTitle(item);
var episodeParseResult = Parser.ParseTitle(title);
var episodeParseResult = Parser.ParseTitle<IndexerParseResult>(title);
if (episodeParseResult != null)
{
episodeParseResult.Age = DateTime.Now.Date.Subtract(item.PublishDate.Date).Days;
episodeParseResult.OriginalString = title;
episodeParseResult.SceneSource = true;
episodeParseResult.ReleaseGroup = ParseReleaseGroup(title);
}
_logger.Trace("Parsed: {0} from: {1}", episodeParseResult, item.Title.Text);
return PostProcessor(item, episodeParseResult);
}
private static string ParseReleaseGroup(string title)
{
title = title.Trim();
var index = title.LastIndexOf('-');
if (index < 0)
index = title.LastIndexOf(' ');
if (index < 0)
return String.Empty;
var group = title.Substring(index + 1);
if (group.Length == title.Length)
return String.Empty;
return group;
}
}
}

View File

@ -10,7 +10,7 @@ protected override string GetNzbInfoUrl(SyndicationItem item)
return item.Id;
}
protected override EpisodeParseResult PostProcessor(SyndicationItem item, EpisodeParseResult currentResult)
protected override IndexerParseResult PostProcessor(SyndicationItem item, IndexerParseResult currentResult)
{
if (currentResult != null)
{

View File

@ -10,12 +10,12 @@ namespace NzbDrone.Core.Indexers
{
public interface IFetchFeedFromIndexers
{
IList<EpisodeParseResult> FetchRss(IIndexerBase indexer);
IList<IndexerParseResult> FetchRss(IIndexerBase indexer);
IList<EpisodeParseResult> Fetch(IIndexerBase indexer, SeasonSearchDefinition searchDefinition);
IList<EpisodeParseResult> Fetch(IIndexerBase indexer, SingleEpisodeSearchDefinition searchDefinition);
IList<EpisodeParseResult> Fetch(IIndexerBase indexer, PartialSeasonSearchDefinition searchDefinition);
IList<EpisodeParseResult> Fetch(IIndexerBase indexer, DailyEpisodeSearchDefinition searchDefinition);
IList<IndexerParseResult> Fetch(IIndexerBase indexer, SeasonSearchDefinition searchDefinition);
IList<IndexerParseResult> Fetch(IIndexerBase indexer, SingleEpisodeSearchDefinition searchDefinition);
IList<IndexerParseResult> Fetch(IIndexerBase indexer, PartialSeasonSearchDefinition searchDefinition);
IList<IndexerParseResult> Fetch(IIndexerBase indexer, DailyEpisodeSearchDefinition searchDefinition);
}
public class FetchFeedService : IFetchFeedFromIndexers
@ -31,7 +31,7 @@ protected FetchFeedService(HttpProvider httpProvider, Logger logger)
}
public virtual IList<EpisodeParseResult> FetchRss(IIndexerBase indexer)
public virtual IList<IndexerParseResult> FetchRss(IIndexerBase indexer)
{
_logger.Debug("Fetching feeds from " + indexer.Name);
@ -42,7 +42,7 @@ public virtual IList<EpisodeParseResult> FetchRss(IIndexerBase indexer)
return result;
}
public IList<EpisodeParseResult> Fetch(IIndexerBase indexer, SeasonSearchDefinition searchDefinition)
public IList<IndexerParseResult> Fetch(IIndexerBase indexer, SeasonSearchDefinition searchDefinition)
{
_logger.Debug("Searching for {0}", searchDefinition);
@ -54,7 +54,7 @@ public IList<EpisodeParseResult> Fetch(IIndexerBase indexer, SeasonSearchDefinit
return result;
}
public IList<EpisodeParseResult> Fetch(IIndexerBase indexer, SingleEpisodeSearchDefinition searchDefinition)
public IList<IndexerParseResult> Fetch(IIndexerBase indexer, SingleEpisodeSearchDefinition searchDefinition)
{
_logger.Debug("Searching for {0}", searchDefinition);
@ -67,7 +67,7 @@ public IList<EpisodeParseResult> Fetch(IIndexerBase indexer, SingleEpisodeSearch
}
public IList<EpisodeParseResult> Fetch(IIndexerBase indexer, PartialSeasonSearchDefinition searchDefinition)
public IList<IndexerParseResult> Fetch(IIndexerBase indexer, PartialSeasonSearchDefinition searchDefinition)
{
_logger.Debug("Searching for {0}", searchDefinition);
@ -79,7 +79,7 @@ public IList<EpisodeParseResult> Fetch(IIndexerBase indexer, PartialSeasonSearch
return result;
}
public IList<EpisodeParseResult> Fetch(IIndexerBase indexer, DailyEpisodeSearchDefinition searchDefinition)
public IList<IndexerParseResult> Fetch(IIndexerBase indexer, DailyEpisodeSearchDefinition searchDefinition)
{
_logger.Debug("Searching for {0}", searchDefinition);
@ -90,9 +90,9 @@ public IList<EpisodeParseResult> Fetch(IIndexerBase indexer, DailyEpisodeSearchD
return result;
}
private List<EpisodeParseResult> Fetch(IIndexerBase indexer, IEnumerable<string> urls)
private List<IndexerParseResult> Fetch(IIndexerBase indexer, IEnumerable<string> urls)
{
var result = new List<EpisodeParseResult>();
var result = new List<IndexerParseResult>();
foreach (var url in urls)
{

View File

@ -18,7 +18,7 @@ protected override string GetNzbInfoUrl(SyndicationItem item)
return item.Id;
}
protected override EpisodeParseResult PostProcessor(SyndicationItem item, EpisodeParseResult currentResult)
protected override IndexerParseResult PostProcessor(SyndicationItem item, IndexerParseResult currentResult)
{
if (currentResult != null)
{

View File

@ -7,7 +7,7 @@ namespace NzbDrone.Core.Indexers.NzbClub
{
public class NzbClubParser : BasicRssParser
{
protected override EpisodeParseResult PostProcessor(SyndicationItem item, EpisodeParseResult currentResult)
protected override IndexerParseResult PostProcessor(SyndicationItem item, IndexerParseResult currentResult)
{
if (currentResult != null)
{

View File

@ -18,7 +18,7 @@ protected override string GetNzbInfoUrl(SyndicationItem item)
return item.Links[0].Uri.ToString();
}
protected override EpisodeParseResult PostProcessor(SyndicationItem item, EpisodeParseResult currentResult)
protected override IndexerParseResult PostProcessor(SyndicationItem item, IndexerParseResult currentResult)
{
if (currentResult != null)
{

View File

@ -6,7 +6,7 @@ namespace NzbDrone.Core.Indexers.NzbsRUs
{
public class NzbsrusParser : BasicRssParser
{
protected override EpisodeParseResult PostProcessor(SyndicationItem item, EpisodeParseResult currentResult)
protected override IndexerParseResult PostProcessor(SyndicationItem item, IndexerParseResult currentResult)
{
if (currentResult != null)
{

View File

@ -19,9 +19,9 @@ public NzbxParser(Logger logger)
_serializer = new JsonSerializer();
}
public IEnumerable<EpisodeParseResult> Process(Stream source)
public IEnumerable<IndexerParseResult> Process(Stream source)
{
var result = new List<EpisodeParseResult>();
var result = new List<IndexerParseResult>();
var jsonReader = new JsonTextReader(new StreamReader(source));
var feed = _serializer.Deserialize<List<NzbxRecentItem>>(jsonReader);
@ -29,7 +29,7 @@ public IEnumerable<EpisodeParseResult> Process(Stream source)
{
try
{
var episodeParseResult = Parser.ParseTitle(item.Name);
var episodeParseResult = Parser.ParseTitle<IndexerParseResult>(item.Name);
if (episodeParseResult != null)
{
episodeParseResult.Age = DateTime.Now.Date.Subtract(item.PostDate).Days;

View File

@ -26,7 +26,7 @@ protected override string GetNzbInfoUrl(SyndicationItem item)
return String.Empty;
}
protected override EpisodeParseResult PostProcessor(SyndicationItem item, EpisodeParseResult currentResult)
protected override IndexerParseResult PostProcessor(SyndicationItem item, IndexerParseResult currentResult)
{
if (currentResult != null)
{

View File

@ -65,7 +65,7 @@ public void Sync()
public interface IFetchAndParseRss
{
List<EpisodeParseResult> Fetch();
List<IndexerParseResult> Fetch();
}
public class FetchAndParseRssService : IFetchAndParseRss
@ -79,9 +79,9 @@ public FetchAndParseRssService(IIndexerService indexerService, IFetchFeedFromInd
_feedFetcher = feedFetcher;
}
public List<EpisodeParseResult> Fetch()
public List<IndexerParseResult> Fetch()
{
var result = new List<EpisodeParseResult>();
var result = new List<IndexerParseResult>();
var indexers = _indexerService.GetAvailableIndexers();

View File

@ -15,7 +15,7 @@ protected override string GetNzbInfoUrl(SyndicationItem item)
return null;
}
protected override EpisodeParseResult PostProcessor(SyndicationItem item, EpisodeParseResult currentResult)
protected override IndexerParseResult PostProcessor(SyndicationItem item, IndexerParseResult currentResult)
{
if (currentResult != null)
{

View File

@ -4,7 +4,6 @@
using NLog;
using NzbDrone.Common;
using NzbDrone.Common.Eventing;
using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Tv;

View File

@ -5,9 +5,9 @@ namespace NzbDrone.Core.MediaFiles.Events
{
public class EpisodeDownloadedEvent : IEvent
{
public EpisodeParseResult ParseResult { get; private set; }
public FileNameParseResult ParseResult { get; private set; }
public EpisodeDownloadedEvent(EpisodeParseResult parseResult)
public EpisodeDownloadedEvent(FileNameParseResult parseResult)
{
ParseResult = parseResult;
}

View File

@ -7,7 +7,7 @@
namespace NzbDrone.Core.Model
{
public class EpisodeParseResult
public class ParseResult
{
public string SeriesTitle { get; set; }
@ -19,7 +19,6 @@ public string CleanTitle
}
}
public DownloadDecision Decision { get; set; }
public string EpisodeTitle { get; set; }
@ -33,24 +32,14 @@ public string CleanTitle
public LanguageType Language { get; set; }
public string NzbUrl { get; set; }
public string NzbInfoUrl { get; set; }
public string OriginalString { get; set; }
public Series Series { get; set; }
public String Indexer { get; set; }
public bool FullSeason { get; set; }
public long Size { get; set; }
public int Age { get; set; }
public string ReleaseGroup { get; set; }
public bool SceneSource { get; set; }
public IList<Episode> Episodes { get; set; }
@ -74,8 +63,23 @@ public override string ToString()
return string.Format("{0} - {1} {2}", SeriesTitle, episodeString, Quality);
}
}
public class IndexerParseResult : ParseResult
{
public DownloadDecision Decision { get; set; }
public string NzbUrl { get; set; }
public string NzbInfoUrl { get; set; }
public String Indexer { get; set; }
public int Age { get; set; }
public string ReleaseGroup { get; set; }
public string GetDownloadTitle()
{
var seriesTitle = FileNameBuilder.CleanFilename(Series.Title);
@ -134,4 +138,10 @@ public string GetDownloadTitle()
return result;
}
}
public class FileNameParseResult :ParseResult
{
}
}

View File

@ -509,7 +509,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="ExternalNotification\ExternalNotificationDefinition.cs" />
<Compile Include="Model\EpisodeParseResult.cs" />
<Compile Include="Model\IndexerParseResult.cs" />
<Compile Include="Model\EpisodeStatusType.cs" />
<Compile Include="Download\Clients\Sabnzbd\SabPriorityType.cs" />
<Compile Include="Model\SeasonParseResult.cs" />

View File

@ -1,4 +1,4 @@
 using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@ -6,9 +6,9 @@
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
namespace NzbDrone.Core
{
@ -91,16 +91,16 @@ public static class Parser
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?<italian>ita|italian)|(?<german>german\b)|(?<flemish>flemish)|(?<greek>greek)(?:\W|_)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
internal static EpisodeParseResult ParsePath(string path)
internal static FileNameParseResult ParsePath(string path)
{
var fileInfo = new FileInfo(path);
var result = ParseTitle(fileInfo.Name);
var result = ParseTitle<FileNameParseResult>(fileInfo.Name);
if (result == null)
{
Logger.Trace("Attempting to parse episode info using full path. {0}", fileInfo.FullName);
result = ParseTitle(fileInfo.FullName);
result = ParseTitle<FileNameParseResult>(fileInfo.FullName);
}
if (result != null)
@ -115,7 +115,7 @@ internal static EpisodeParseResult ParsePath(string path)
return result;
}
internal static EpisodeParseResult ParseTitle(string title)
internal static T ParseTitle<T>(string title) where T : ParseResult, new()
{
try
{
@ -128,7 +128,7 @@ internal static EpisodeParseResult ParseTitle(string title)
if (match.Count != 0)
{
var result = ParseMatchCollection(match);
var result = ParseMatchCollection<T>(match);
if (result != null)
{
//Check if episode is in the future (most likley a parse error)
@ -138,7 +138,6 @@ internal static EpisodeParseResult ParseTitle(string title)
result.Language = ParseLanguage(title);
result.Quality = ParseQuality(title);
result.OriginalString = title;
result.ReleaseGroup = ParseReleaseGroup(title);
return result;
}
}
@ -155,14 +154,14 @@ internal static EpisodeParseResult ParseTitle(string title)
return null;
}
private static EpisodeParseResult ParseMatchCollection(MatchCollection matchCollection)
private static T ParseMatchCollection<T>(MatchCollection matchCollection) where T : ParseResult, new()
{
var seriesName = matchCollection[0].Groups["title"].Value.Replace('.', ' ');
int airyear;
Int32.TryParse(matchCollection[0].Groups["airyear"].Value, out airyear);
EpisodeParseResult parsedEpisode;
T parsedIndexer;
if (airyear < 1900)
{
@ -183,7 +182,7 @@ private static EpisodeParseResult ParseMatchCollection(MatchCollection matchColl
if (seasons.Distinct().Count() > 1)
return null;
parsedEpisode = new EpisodeParseResult
parsedIndexer = new T
{
SeasonNumber = seasons.First(),
EpisodeNumbers = new List<int>()
@ -198,7 +197,7 @@ private static EpisodeParseResult ParseMatchCollection(MatchCollection matchColl
{
var first = Convert.ToInt32(episodeCaptures.First().Value);
var last = Convert.ToInt32(episodeCaptures.Last().Value);
parsedEpisode.EpisodeNumbers = Enumerable.Range(first, last - first + 1).ToList();
parsedIndexer.EpisodeNumbers = Enumerable.Range(first, last - first + 1).ToList();
}
else
{
@ -207,7 +206,7 @@ private static EpisodeParseResult ParseMatchCollection(MatchCollection matchColl
if (!String.IsNullOrWhiteSpace(matchCollection[0].Groups["extras"].Value))
return null;
parsedEpisode.FullSeason = true;
parsedIndexer.FullSeason = true;
}
}
}
@ -226,26 +225,26 @@ private static EpisodeParseResult ParseMatchCollection(MatchCollection matchColl
airmonth = tempDay;
}
parsedEpisode = new EpisodeParseResult
{
parsedIndexer = new T
{
AirDate = new DateTime(airyear, airmonth, airday).Date,
};
}
parsedEpisode.SeriesTitle = seriesName;
parsedIndexer.SeriesTitle = seriesName;
Logger.Trace("Episode Parsed. {0}", parsedEpisode);
Logger.Trace("Episode Parsed. {0}", parsedIndexer);
return parsedEpisode;
return parsedIndexer;
}
public static string ParseSeriesName(string title)
{
Logger.Trace("Parsing string '{0}'", title);
var parseResult = ParseTitle(title);
var parseResult = ParseTitle<ParseResult>(title);
if(parseResult == null)
if (parseResult == null)
return NormalizeTitle(title);
return parseResult.CleanTitle;
@ -309,7 +308,7 @@ internal static QualityModel ParseQuality(string name)
return result;
}
if(name.Contains("[WEBDL]"))
if (name.Contains("[WEBDL]"))
{
result.Quality = Quality.WEBDL720p;
return result;
@ -327,7 +326,7 @@ internal static QualityModel ParseQuality(string name)
if (normalizedName.Contains("x264") || normalizedName.Contains("h264") || normalizedName.Contains("720p"))
{
if(normalizedName.Contains("1080p"))
if (normalizedName.Contains("1080p"))
{
result.Quality = Quality.HDTV1080p;
return result;
@ -472,27 +471,7 @@ internal static LanguageType ParseLanguage(string title)
return LanguageType.English;
}
internal static string ParseReleaseGroup(string title)
{
Logger.Trace("Trying to parse release group for {0}", title);
title = title.Trim();
var index = title.LastIndexOf('-');
if (index < 0)
index = title.LastIndexOf(' ');
if (index < 0)
return String.Empty;
var group = title.Substring(index + 1);
if (group.Length == title.Length)
return String.Empty;
Logger.Trace("Release Group found: {0}", group);
return group;
}
public static string NormalizeTitle(string title)
{
@ -527,7 +506,7 @@ public static long GetReportSize(string sizeString)
internal static string ParseHeader(string header)
{
foreach(var regex in HeaderRegex)
foreach (var regex in HeaderRegex)
{
var match = regex.Matches(header);

View File

@ -155,7 +155,6 @@ public virtual EpisodeFile ImportFile(Series series, string filePath)
episodeFile.Quality = parseResult.Quality;
episodeFile.SeasonNumber = parseResult.SeasonNumber;
episodeFile.SceneName = Path.GetFileNameWithoutExtension(filePath.NormalizePath());
episodeFile.ReleaseGroup = parseResult.ReleaseGroup;
//Todo: We shouldn't actually import the file until we confirm its the only one we want.
//Todo: Separate episodeFile creation from importing (pass file to import to import)

View File

@ -19,7 +19,7 @@ public interface IEpisodeService
Episode GetEpisode(int seriesId, DateTime date);
List<Episode> GetEpisodeBySeries(int seriesId);
List<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber);
List<Episode> GetEpisodesByParseResult(EpisodeParseResult parseResult);
List<Episode> GetEpisodesByParseResult(ParseResult parseResult);
List<Episode> EpisodesWithoutFiles(bool includeSpecials);
List<Episode> GetEpisodesByFileId(int episodeFileId);
List<Episode> EpisodesWithFiles();
@ -85,7 +85,7 @@ public List<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber)
return _episodeRepository.GetEpisodes(seriesId, seasonNumber);
}
public List<Episode> GetEpisodesByParseResult(EpisodeParseResult parseResult)
public List<Episode> GetEpisodesByParseResult(ParseResult parseResult)
{
var result = new List<Episode>();
@ -120,7 +120,10 @@ public List<Episode> GetEpisodesByParseResult(EpisodeParseResult parseResult)
Episode episodeInfo = null;
if (parseResult.SceneSource && parseResult.Series.UseSceneNumbering)
episodeInfo = _episodeRepository.GetEpisodeBySceneNumbering(parseResult.Series.Id, parseResult.SeasonNumber, episodeNumber);
{
episodeInfo = _episodeRepository.GetEpisodeBySceneNumbering(parseResult.Series.Id,
parseResult.SeasonNumber, episodeNumber);
}
if (episodeInfo == null)
{