diff --git a/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs b/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs index f68bcb2ef..bf3d72d11 100644 --- a/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs +++ b/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs @@ -28,8 +28,8 @@ namespace NzbDrone.Api.Test.ClientSchemaTests var schema = SchemaBuilder.GenerateSchema(model); - schema.Should().Contain(c => c.Order == 1 && c.Name == "LastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" && c.Value == "Poop"); - schema.Should().Contain(c => c.Order == 0 && c.Name == "FirstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && c.Value == "Bob"); + schema.Should().Contain(c => c.Order == 1 && c.Name == "LastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" && (string) c.Value == "Poop"); + schema.Should().Contain(c => c.Order == 0 && c.Name == "FirstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && (string) c.Value == "Bob"); } } diff --git a/NzbDrone.Api.Test/MappingTests/ResourceMappingFixture.cs b/NzbDrone.Api.Test/MappingTests/ResourceMappingFixture.cs index f12b1b136..82fb9425a 100644 --- a/NzbDrone.Api.Test/MappingTests/ResourceMappingFixture.cs +++ b/NzbDrone.Api.Test/MappingTests/ResourceMappingFixture.cs @@ -37,7 +37,7 @@ namespace NzbDrone.Api.Test.MappingTests [TestCase(typeof(RootFolder), typeof(RootFolderResource))] [TestCase(typeof(NamingConfig), typeof(NamingConfigResource))] [TestCase(typeof(Indexer), typeof(IndexerResource))] - [TestCase(typeof(ReportInfo), typeof(ReleaseResource))] + [TestCase(typeof(ReleaseInfo), typeof(ReleaseResource))] [TestCase(typeof(ParsedEpisodeInfo), typeof(ReleaseResource))] [TestCase(typeof(DownloadDecision), typeof(ReleaseResource))] [TestCase(typeof(Core.History.History), typeof(HistoryResource))] diff --git a/NzbDrone.Api/Indexers/ReleaseModule.cs b/NzbDrone.Api/Indexers/ReleaseModule.cs index 0da284f5e..f00d30542 100644 --- a/NzbDrone.Api/Indexers/ReleaseModule.cs +++ b/NzbDrone.Api/Indexers/ReleaseModule.cs @@ -42,7 +42,7 @@ namespace NzbDrone.Api.Indexers private Response DownloadRelease(ReleaseResource release) { var remoteEpisode = _parsingService.Map(release.InjectTo(), 0); - remoteEpisode.Report = release.InjectTo(); + remoteEpisode.Release = release.InjectTo(); _downloadService.DownloadReport(remoteEpisode); @@ -82,7 +82,7 @@ namespace NzbDrone.Api.Indexers { var release = new ReleaseResource(); - release.InjectFrom(downloadDecision.RemoteEpisode.Report); + release.InjectFrom(downloadDecision.RemoteEpisode.Release); release.InjectFrom(downloadDecision.RemoteEpisode.ParsedEpisodeInfo); release.InjectFrom(downloadDecision); release.Rejections = downloadDecision.Rejections.ToList(); diff --git a/NzbDrone.Api/Indexers/ReleaseResource.cs b/NzbDrone.Api/Indexers/ReleaseResource.cs index 3db66d39f..3cc4a054a 100644 --- a/NzbDrone.Api/Indexers/ReleaseResource.cs +++ b/NzbDrone.Api/Indexers/ReleaseResource.cs @@ -12,8 +12,6 @@ namespace NzbDrone.Api.Indexers public Int32 Age { get; set; } public Int64 Size { get; set; } public String Indexer { get; set; } - public String NzbInfoUrl { get; set; } - public String NzbUrl { get; set; } public String ReleaseGroup { get; set; } public String Title { get; set; } public Boolean FullSeason { get; set; } @@ -26,5 +24,9 @@ namespace NzbDrone.Api.Indexers public Boolean Approved { get; set; } public Int32 TvRageId { get; set; } public List Rejections { get; set; } + public DateTime PublishDate { get; set; } + public String CommentUrl { get; set; } + public String DownloadUrl { get; set; } + public String InfoUrl { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs index 32528beaf..5f511e3dc 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs @@ -26,14 +26,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { parseResultMulti = new RemoteEpisode { - Report = new ReportInfo(), + Release = new ReleaseInfo(), ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.SDTV, true) }, Episodes = new List { new Episode(), new Episode() } }; parseResultSingle = new RemoteEpisode { - Report = new ReportInfo(), + Release = new ReleaseInfo(), ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.SDTV, true) }, Episodes = new List { new Episode() } @@ -59,7 +59,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void IsAcceptableSize_true_single_episode_not_first_or_last_30_minute() { parseResultSingle.Series = series30minutes; - parseResultSingle.Report.Size = 184572800; + parseResultSingle.Release.Size = 184572800; Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void IsAcceptableSize_true_single_episode_not_first_or_last_60_minute() { parseResultSingle.Series = series60minutes; - parseResultSingle.Report.Size = 368572800; + parseResultSingle.Release.Size = 368572800; Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -97,7 +97,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void IsAcceptableSize_false_single_episode_not_first_or_last_30_minute() { parseResultSingle.Series = series30minutes; - parseResultSingle.Report.Size = 1.Gigabytes(); + parseResultSingle.Release.Size = 1.Gigabytes(); Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -116,7 +116,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void IsAcceptableSize_false_single_episode_not_first_or_last_60_minute() { parseResultSingle.Series = series60minutes; - parseResultSingle.Report.Size = 1.Gigabytes(); + parseResultSingle.Release.Size = 1.Gigabytes(); Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -133,7 +133,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void IsAcceptableSize_true_multi_episode_not_first_or_last_30_minute() { parseResultMulti.Series = series30minutes; - parseResultMulti.Report.Size = 184572800; + parseResultMulti.Release.Size = 184572800; Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -152,7 +152,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void IsAcceptableSize_true_multi_episode_not_first_or_last_60_minute() { parseResultMulti.Series = series60minutes; - parseResultMulti.Report.Size = 368572800; + parseResultMulti.Release.Size = 368572800; Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -171,7 +171,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void IsAcceptableSize_false_multi_episode_not_first_or_last_30_minute() { parseResultMulti.Series = series30minutes; - parseResultMulti.Report.Size = 1.Gigabytes(); + parseResultMulti.Release.Size = 1.Gigabytes(); Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -190,7 +190,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void IsAcceptableSize_false_multi_episode_not_first_or_last_60_minute() { parseResultMulti.Series = series60minutes; - parseResultMulti.Report.Size = 10.Gigabytes(); + parseResultMulti.Release.Size = 10.Gigabytes(); Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -209,7 +209,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void IsAcceptableSize_true_single_episode_first_30_minute() { parseResultSingle.Series = series30minutes; - parseResultSingle.Report.Size = 184572800; + parseResultSingle.Release.Size = 184572800; Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -228,7 +228,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void IsAcceptableSize_true_single_episode_first_60_minute() { parseResultSingle.Series = series60minutes; - parseResultSingle.Report.Size = 368572800; + parseResultSingle.Release.Size = 368572800; Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -247,7 +247,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void IsAcceptableSize_false_single_episode_first_30_minute() { parseResultSingle.Series = series30minutes; - parseResultSingle.Report.Size = 1.Gigabytes(); + parseResultSingle.Release.Size = 1.Gigabytes(); Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -268,7 +268,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests parseResultSingle.Series = series60minutes; - parseResultSingle.Report.Size = 10.Gigabytes(); + parseResultSingle.Release.Size = 10.Gigabytes(); Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -289,7 +289,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests parseResultSingle.Series = series30minutes; - parseResultSingle.Report.Size = 18457280000; + parseResultSingle.Release.Size = 18457280000; qualityType.MaxSize = 0; Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -311,7 +311,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests parseResultSingle.Series = series60minutes; - parseResultSingle.Report.Size = 36857280000; + parseResultSingle.Release.Size = 36857280000; qualityType.MaxSize = 0; Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); @@ -334,7 +334,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests parseResultSingle.Series = series60minutes; parseResultSingle.Series.SeriesType = SeriesTypes.Daily; - parseResultSingle.Report.Size = 300.Megabytes(); + parseResultSingle.Release.Size = 300.Megabytes(); qualityType.MaxSize = (int)600.Megabytes(); diff --git a/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs index 171387772..697e0b8ae 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [TestFixture] public class DownloadDecisionMakerFixture : CoreTest { - private List _reports; + private List _reports; private RemoteEpisode _remoteEpisode; private Mock _pass1; @@ -56,7 +56,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests _fail3.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(false); _fail3.Setup(c => c.RejectionReason).Returns("_fail3"); - _reports = new List { new ReportInfo { Title = "The.Office.S03E115.DVDRip.XviD-OSiTV" } }; + _reports = new List { new ReleaseInfo { Title = "The.Office.S03E115.DVDRip.XviD-OSiTV" } }; _remoteEpisode = new RemoteEpisode { Series = new Series() }; Mocker.GetMock().Setup(c => c.Map(It.IsAny(), It.IsAny())) @@ -177,11 +177,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Mocker.GetMock().Setup(c => c.Map(It.IsAny(), It.IsAny())) .Throws(); - _reports = new List + _reports = new List { - new ReportInfo{Title = "The.Office.S03E115.DVDRip.XviD-OSiTV"}, - new ReportInfo{Title = "The.Office.S03E115.DVDRip.XviD-OSiTV"}, - new ReportInfo{Title = "The.Office.S03E115.DVDRip.XviD-OSiTV"} + new ReleaseInfo{Title = "The.Office.S03E115.DVDRip.XviD-OSiTV"}, + new ReleaseInfo{Title = "The.Office.S03E115.DVDRip.XviD-OSiTV"}, + new ReleaseInfo{Title = "The.Office.S03E115.DVDRip.XviD-OSiTV"} }; Subject.GetRssDecision(_reports); diff --git a/NzbDrone.Core.Test/DecisionEngineTests/NotRestrictedReleaseSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/NotRestrictedReleaseSpecificationFixture.cs index f9bcf475e..cdbce8077 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/NotRestrictedReleaseSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/NotRestrictedReleaseSpecificationFixture.cs @@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { _parseResult = new RemoteEpisode { - Report = new ReportInfo + Release = new ReleaseInfo { Title = "Dexter.S08E01.EDITED.WEBRip.x264-KYR" } diff --git a/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs index 7a61aa04a..45db8a529 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs @@ -1,4 +1,5 @@ -using FluentAssertions; +using System; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Configuration; using NzbDrone.Core.DecisionEngine.Specifications; @@ -19,9 +20,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { parseResult = new RemoteEpisode { - Report = new ReportInfo + Release = new ReleaseInfo { - Age = 100 + PublishDate = DateTime.Now.AddDays(-100) } }; } diff --git a/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs b/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs index 5d9e16117..f13c81ccb 100644 --- a/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs +++ b/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs @@ -34,8 +34,8 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests remoteEpisode.Episodes = new List(); remoteEpisode.Episodes.AddRange(episodes); - remoteEpisode.Report = new ReportInfo(); - remoteEpisode.Report.Age = 0; + remoteEpisode.Release = new ReleaseInfo(); + remoteEpisode.Release.PublishDate = DateTime.UtcNow; return remoteEpisode; } diff --git a/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/GetQualifiedReportsFixture.cs b/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/GetQualifiedReportsFixture.cs index f8857f40b..370142d75 100644 --- a/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/GetQualifiedReportsFixture.cs +++ b/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/GetQualifiedReportsFixture.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; @@ -32,9 +33,9 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests remoteEpisode.Episodes = new List(); remoteEpisode.Episodes.AddRange(episodes); - remoteEpisode.Report = new ReportInfo(); - remoteEpisode.Report.Age = Age; - remoteEpisode.Report.Size = size; + remoteEpisode.Release = new ReleaseInfo(); + remoteEpisode.Release.PublishDate = DateTime.Now.AddDays(-Age); + remoteEpisode.Release.Size = size; return remoteEpisode; } @@ -110,9 +111,9 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests public void should_order_by_smallest_rounded_to_200mb_then_age() { var remoteEpisodeSd = GetRemoteEpisode(new List { GetEpisode(1) }, new QualityModel(Quality.SDTV), size: 100.Megabytes(), Age: 1); - var remoteEpisodeHdSmallOld = GetRemoteEpisode(new List { GetEpisode(1) }, new QualityModel(Quality.HDTV720p), size:1200.Megabytes(), Age:1000); - var remoteEpisodeHdSmallYounge = GetRemoteEpisode(new List { GetEpisode(1) }, new QualityModel(Quality.HDTV720p), size:1250.Megabytes(), Age:10); - var remoteEpisodeHdLargeYounge = GetRemoteEpisode(new List { GetEpisode(1) }, new QualityModel(Quality.HDTV720p), size:3000.Megabytes(), Age:1); + var remoteEpisodeHdSmallOld = GetRemoteEpisode(new List { GetEpisode(1) }, new QualityModel(Quality.HDTV720p), size: 1200.Megabytes(), Age: 1000); + var remoteEpisodeHdSmallYounge = GetRemoteEpisode(new List { GetEpisode(1) }, new QualityModel(Quality.HDTV720p), size: 1250.Megabytes(), Age: 10); + var remoteEpisodeHdLargeYounge = GetRemoteEpisode(new List { GetEpisode(1) }, new QualityModel(Quality.HDTV720p), size: 3000.Megabytes(), Age: 1); var decisions = new List(); decisions.Add(new DownloadDecision(remoteEpisodeSd)); diff --git a/NzbDrone.Core.Test/Download/DownloadClientTests/BlackholeProviderFixture.cs b/NzbDrone.Core.Test/Download/DownloadClientTests/BlackholeProviderFixture.cs index 6229aaf8a..9de3178b9 100644 --- a/NzbDrone.Core.Test/Download/DownloadClientTests/BlackholeProviderFixture.cs +++ b/NzbDrone.Core.Test/Download/DownloadClientTests/BlackholeProviderFixture.cs @@ -30,9 +30,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests Mocker.GetMock().SetupGet(c => c.BlackholeFolder).Returns(_blackHoleFolder); _remoteEpisode = new RemoteEpisode(); - _remoteEpisode.Report = new ReportInfo(); - _remoteEpisode.Report.Title = _title; - _remoteEpisode.Report.NzbUrl = _nzbUrl; + _remoteEpisode.Release = new ReleaseInfo(); + _remoteEpisode.Release.Title = _title; + _remoteEpisode.Release.DownloadUrl = _nzbUrl; } private void WithExistingFile() @@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests { var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]"; var expectedFilename = Path.Combine(_blackHoleFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb"); - _remoteEpisode.Report.Title = illegalTitle; + _remoteEpisode.Release.Title = illegalTitle; Subject.DownloadNzb(_remoteEpisode); diff --git a/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetProviderTests/DownloadNzbFixture.cs b/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetProviderTests/DownloadNzbFixture.cs index 3c742c263..c897df251 100644 --- a/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetProviderTests/DownloadNzbFixture.cs +++ b/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetProviderTests/DownloadNzbFixture.cs @@ -30,9 +30,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests fakeConfig.SetupGet(c => c.NzbgetRecentTvPriority).Returns(PriorityType.High); _remoteEpisode = new RemoteEpisode(); - _remoteEpisode.Report = new ReportInfo(); - _remoteEpisode.Report.Title = _title; - _remoteEpisode.Report.NzbUrl = _url; + _remoteEpisode.Release = new ReleaseInfo(); + _remoteEpisode.Release.Title = _title; + _remoteEpisode.Release.DownloadUrl = _url; _remoteEpisode.Episodes = Builder.CreateListOfSize(1) .All() diff --git a/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs b/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs index 66b3695cc..cfac3a99a 100644 --- a/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs +++ b/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs @@ -34,9 +34,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests Mocker.GetMock().SetupGet(c => c.DownloadedEpisodesFolder).Returns(_sabDrop); _remoteEpisode = new RemoteEpisode(); - _remoteEpisode.Report = new ReportInfo(); - _remoteEpisode.Report.Title = _title; - _remoteEpisode.Report.NzbUrl = _nzbUrl; + _remoteEpisode.Release = new ReleaseInfo(); + _remoteEpisode.Release.Title = _title; + _remoteEpisode.Release.DownloadUrl = _nzbUrl; _remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo(); _remoteEpisode.ParsedEpisodeInfo.FullSeason = false; @@ -72,7 +72,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests [Test] public void should_throw_if_full_season_download() { - _remoteEpisode.Report.Title = "30 Rock - Season 1"; + _remoteEpisode.Release.Title = "30 Rock - Season 1"; _remoteEpisode.ParsedEpisodeInfo.FullSeason = true; Assert.Throws(() => Subject.DownloadNzb(_remoteEpisode)); @@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests { var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]"; var expectedFilename = Path.Combine(_pneumaticFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb"); - _remoteEpisode.Report.Title = illegalTitle; + _remoteEpisode.Release.Title = illegalTitle; Subject.DownloadNzb(_remoteEpisode); diff --git a/NzbDrone.Core.Test/Download/DownloadClientTests/SabProviderTests/SabProviderFixture.cs b/NzbDrone.Core.Test/Download/DownloadClientTests/SabProviderTests/SabProviderFixture.cs index 0218acefc..f23a2b762 100644 --- a/NzbDrone.Core.Test/Download/DownloadClientTests/SabProviderTests/SabProviderFixture.cs +++ b/NzbDrone.Core.Test/Download/DownloadClientTests/SabProviderTests/SabProviderFixture.cs @@ -35,9 +35,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests fakeConfig.SetupGet(c => c.SabTvCategory).Returns("tv"); _remoteEpisode = new RemoteEpisode(); - _remoteEpisode.Report = new ReportInfo(); - _remoteEpisode.Report.Title = TITLE; - _remoteEpisode.Report.NzbUrl = URL; + _remoteEpisode.Release = new ReleaseInfo(); + _remoteEpisode.Release.Title = TITLE; + _remoteEpisode.Release.DownloadUrl = URL; _remoteEpisode.Episodes = Builder.CreateListOfSize(1) .All() diff --git a/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs b/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs index cc0285b78..86413bcc4 100644 --- a/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs +++ b/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.Download _parseResult = Builder.CreateNew() .With(c => c.Series = Builder.CreateNew().Build()) - .With(c => c.Report = Builder.CreateNew().Build()) + .With(c => c.Release = Builder.CreateNew().Build()) .With(c => c.Episodes = episodes) .Build(); diff --git a/NzbDrone.Core.Test/IndexerTests/BasicRssParserFixture.cs b/NzbDrone.Core.Test/IndexerTests/BasicRssParserFixture.cs index 4ac080e2a..2eca3586b 100644 --- a/NzbDrone.Core.Test/IndexerTests/BasicRssParserFixture.cs +++ b/NzbDrone.Core.Test/IndexerTests/BasicRssParserFixture.cs @@ -5,7 +5,7 @@ using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.IndexerTests { - public class BasicRssParserFixture : CoreTest + public class BasicRssParserFixture : CoreTest { [TestCase("Castle.2009.S01E14.English.HDTV.XviD-LOL", "LOL")] @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.IndexerTests [TestCase("The.Office.S03E115.DVDRip.XviD-OSiTV", "OSiTV")] public void parse_releaseGroup(string title, string expected) { - BasicRssParser.ParseReleaseGroup(title).Should().Be(expected); + RssParserBase.ParseReleaseGroup(title).Should().Be(expected); } @@ -29,7 +29,7 @@ namespace NzbDrone.Core.Test.IndexerTests [TestCase("845 MB", 886046720)] public void parse_size(string sizeString, long expectedSize) { - var result = BasicRssParser.GetReportSize(sizeString); + var result = RssParserBase.ParseSize(sizeString); result.Should().Be(expectedSize); } diff --git a/NzbDrone.Core.Test/IndexerTests/IndexerServiceFixture.cs b/NzbDrone.Core.Test/IndexerTests/IndexerServiceFixture.cs index 3e6239823..2de52fb5f 100644 --- a/NzbDrone.Core.Test/IndexerTests/IndexerServiceFixture.cs +++ b/NzbDrone.Core.Test/IndexerTests/IndexerServiceFixture.cs @@ -6,7 +6,6 @@ using Moq; using NUnit.Framework; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.Newznab; -using NzbDrone.Core.Indexers.NzbClub; using NzbDrone.Core.Indexers.Omgwtfnzbs; using NzbDrone.Core.Indexers.Wombles; using NzbDrone.Core.Lifecycle; @@ -24,7 +23,6 @@ namespace NzbDrone.Core.Test.IndexerTests _indexers = new List(); _indexers.Add(new Newznab()); - _indexers.Add(new NzbClub()); _indexers.Add(new Omgwtfnzbs()); _indexers.Add(new Wombles()); diff --git a/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs b/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs index 813c1a45f..1be142824 100644 --- a/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs +++ b/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs @@ -1,13 +1,14 @@ using System.Collections.Generic; using FluentAssertions; using NzbDrone.Core.Indexers; +using NzbDrone.Core.Indexers.Eztv; using NzbDrone.Core.Indexers.Newznab; -using NzbDrone.Core.Indexers.NzbClub; using NzbDrone.Core.Indexers.Wombles; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NUnit.Framework; using NzbDrone.Test.Common.Categories; +using System.Linq; namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests { @@ -22,24 +23,24 @@ namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests } [Test] - [Explicit] - public void nzbclub_rss() + public void wombles_rss() { - var indexer = new NzbClub(); + var indexer = new Wombles(); var result = Subject.FetchRss(indexer); - ValidateResult(result); + ValidateResult(result, skipSize: true, skipInfo: true); } + [Test] - public void wombles_rss() + public void extv_rss() { - var indexer = new Wombles(); + var indexer = new Eztv(); var result = Subject.FetchRss(indexer); - ValidateResult(result, skipSize: true, skipInfo: true); + ValidateTorrentResult(result, skipSize: false, skipInfo: true); } @@ -63,15 +64,17 @@ namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests - private void ValidateResult(IList reports, bool skipSize = false, bool skipInfo = false) + private void ValidateResult(IList reports, bool skipSize = false, bool skipInfo = false) { reports.Should().NotBeEmpty(); - reports.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.Title)); - reports.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.NzbUrl)); + reports.Should().NotContain(c => string.IsNullOrWhiteSpace(c.Title)); + reports.Should().NotContain(c => string.IsNullOrWhiteSpace(c.DownloadUrl)); + reports.Should().OnlyContain(c => c.PublishDate.Year > 2000); + reports.Should().OnlyContain(c => c.DownloadUrl.StartsWith("http")); if (!skipInfo) { - reports.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.NzbInfoUrl)); + reports.Should().NotContain(c => string.IsNullOrWhiteSpace(c.InfoUrl)); } if (!skipSize) @@ -80,5 +83,18 @@ namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests } } + private void ValidateTorrentResult(IList reports, bool skipSize = false, bool skipInfo = false) + { + + reports.Should().OnlyContain(c => c.GetType() == typeof(TorrentInfo)); + + ValidateResult(reports, skipSize, skipInfo); + + reports.Should().OnlyContain(c => c.DownloadUrl.EndsWith(".torrent")); + + reports.Cast().Should().OnlyContain(c => c.MagnetUrl.StartsWith("magnet:")); + reports.Cast().Should().NotContain(c => string.IsNullOrWhiteSpace(c.InfoHash)); + } + } -} \ No newline at end of file +} diff --git a/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index aad858d36..6700e12f9 100644 --- a/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -400,14 +400,6 @@ namespace NzbDrone.Core.Test.ParserTests result.Should().BeNull(); } - [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")] - public void parse_header(string title, string expected) - { - BasicRssParser.ParseHeader(title).Should().Be(expected); - } - [TestCase("76El6LcgLzqb426WoVFg1vVVVGx4uCYopQkfjmLe")] [TestCase("Vrq6e1Aba3U amCjuEgV5R2QvdsLEGYF3YQAQkw8")] [TestCase("TDAsqTea7k4o6iofVx3MQGuDK116FSjPobMuh8oB")] diff --git a/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 0676891cf..ee5793e95 100644 --- a/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -26,13 +26,13 @@ namespace NzbDrone.Core.Configuration string Password { get; } string LogLevel { get; } string Branch { get; } + bool Torrent { get; } } public class ConfigFileProvider : IConfigFileProvider { private const string CONFIG_ELEMENT_NAME = "Config"; - private readonly IAppFolderInfo _appFolderInfo; private readonly IMessageAggregator _messageAggregator; private readonly ICached _cache; @@ -40,10 +40,9 @@ namespace NzbDrone.Core.Configuration public ConfigFileProvider(IAppFolderInfo appFolderInfo, ICacheManger cacheManger, IMessageAggregator messageAggregator) { - _appFolderInfo = appFolderInfo; _cache = cacheManger.GetCache(GetType()); _messageAggregator = messageAggregator; - _configFile = _appFolderInfo.GetConfigPath(); + _configFile = appFolderInfo.GetConfigPath(); } public Dictionary GetConfigDictionary() @@ -96,6 +95,11 @@ namespace NzbDrone.Core.Configuration get { return GetValueBoolean("LaunchBrowser", true); } } + public bool Torrent + { + get { return GetValueBoolean("Torrent", false, persist: false); } + } + public bool AuthenticationEnabled { get { return GetValueBoolean("AuthenticationEnabled", false); } @@ -126,9 +130,9 @@ namespace NzbDrone.Core.Configuration return Convert.ToInt32(GetValue(key, defaultValue)); } - public bool GetValueBoolean(string key, bool defaultValue) + public bool GetValueBoolean(string key, bool defaultValue, bool persist = true) { - return Convert.ToBoolean(GetValue(key, defaultValue)); + return Convert.ToBoolean(GetValue(key, defaultValue, persist)); } public T GetValueEnum(string key, T defaultValue) @@ -136,7 +140,7 @@ namespace NzbDrone.Core.Configuration return (T)Enum.Parse(typeof(T), GetValue(key, defaultValue), true); } - public string GetValue(string key, object defaultValue) + public string GetValue(string key, object defaultValue, bool persist = true) { return _cache.Get(key, () => { @@ -153,7 +157,10 @@ namespace NzbDrone.Core.Configuration return valueHolder.First().Value; //Save the value - SetValue(key, defaultValue); + if (persist) + { + SetValue(key, defaultValue); + } //return the default value return defaultValue.ToString(); @@ -233,7 +240,7 @@ namespace NzbDrone.Core.Configuration catch (XmlException ex) { - throw new InvalidConfigFileException("config.xml is invalid, please see the wiki for steps to resolve this issue.", ex); + throw new InvalidConfigFileException(_configFile + " is invalid, please see the http://wiki.nzbdrone.com for steps to resolve this issue.", ex); } } diff --git a/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs index 659d7ae7f..425cc8bae 100644 --- a/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs +++ b/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs @@ -13,8 +13,8 @@ namespace NzbDrone.Core.DecisionEngine { public interface IMakeDownloadDecision { - List GetRssDecision(List reports); - List GetSearchDecision(List reports, SearchCriteriaBase searchCriteriaBase); + List GetRssDecision(List reports); + List GetSearchDecision(List reports, SearchCriteriaBase searchCriteriaBase); } public class DownloadDecisionMaker : IMakeDownloadDecision @@ -30,17 +30,17 @@ namespace NzbDrone.Core.DecisionEngine _logger = logger; } - public List GetRssDecision(List reports) + public List GetRssDecision(List reports) { return GetDecisions(reports).ToList(); } - public List GetSearchDecision(List reports, SearchCriteriaBase searchCriteriaBase) + public List GetSearchDecision(List reports, SearchCriteriaBase searchCriteriaBase) { return GetDecisions(reports, searchCriteriaBase).ToList(); } - private IEnumerable GetDecisions(List reports, SearchCriteriaBase searchCriteria = null) + private IEnumerable GetDecisions(List reports, SearchCriteriaBase searchCriteria = null) { if (reports.Any()) { @@ -66,7 +66,7 @@ namespace NzbDrone.Core.DecisionEngine if (parsedEpisodeInfo != null && !string.IsNullOrWhiteSpace(parsedEpisodeInfo.SeriesTitle)) { var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, report.TvRageId); - remoteEpisode.Report = report; + remoteEpisode.Release = report; if (remoteEpisode.Series != null) { @@ -118,13 +118,13 @@ namespace NzbDrone.Core.DecisionEngine } catch (Exception e) { - e.Data.Add("report", remoteEpisode.Report.ToJson()); + e.Data.Add("report", remoteEpisode.Release.ToJson()); e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo.ToJson()); - _logger.ErrorException("Couldn't evaluate decision on " + remoteEpisode.Report.Title, e); + _logger.ErrorException("Couldn't evaluate decision on " + remoteEpisode.Release.Title, e); return string.Format("{0}: {1}", spec.GetType().Name, e.Message); } return null; } } -} \ No newline at end of file +} diff --git a/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs index ada1817e5..ebf0ef813 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs @@ -65,9 +65,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications } //If the parsed size is greater than maxSize we don't want it - if (subject.Report.Size > maxSize) + if (subject.Release.Size > maxSize) { - _logger.Trace("Item: {0}, Size: {1} is greater than maximum allowed size ({2}), rejecting.", subject, subject.Report.Size, maxSize); + _logger.Trace("Item: {0}, Size: {1} is greater than maximum allowed size ({2}), rejecting.", subject, subject.Release.Size, maxSize); return false; } diff --git a/NzbDrone.Core/DecisionEngine/Specifications/NotRestrictedReleaseSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/NotRestrictedReleaseSpecification.cs index 698c1b32b..4c403ac31 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/NotRestrictedReleaseSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/NotRestrictedReleaseSpecification.cs @@ -41,7 +41,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications foreach (var restriction in restrictions) { - if (subject.Report.Title.ToLowerInvariant().Contains(restriction.ToLowerInvariant())) + if (subject.Release.Title.ToLowerInvariant().Contains(restriction.ToLowerInvariant())) { _logger.Trace("{0} is restricted: {1}", subject, restriction); return false; diff --git a/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs index 01b692adf..a2f4dee15 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { - var age = subject.Report.Age; + var age = subject.Release.Age; _logger.Trace("Checking if report meets retention requirements. {0}", age); if (_configService.Retention > 0 && age > _configService.Retention) diff --git a/NzbDrone.Core/Download/Clients/BlackholeProvider.cs b/NzbDrone.Core/Download/Clients/BlackholeProvider.cs index ff22ff45d..1598ee647 100644 --- a/NzbDrone.Core/Download/Clients/BlackholeProvider.cs +++ b/NzbDrone.Core/Download/Clients/BlackholeProvider.cs @@ -24,8 +24,8 @@ namespace NzbDrone.Core.Download.Clients public void DownloadNzb(RemoteEpisode remoteEpisode) { - var url = remoteEpisode.Report.NzbUrl; - var title = remoteEpisode.Report.Title; + var url = remoteEpisode.Release.DownloadUrl; + var title = remoteEpisode.Release.Title; title = FileNameBuilder.CleanFilename(title); diff --git a/NzbDrone.Core/Download/Clients/Nzbget/NzbgetClient.cs b/NzbDrone.Core/Download/Clients/Nzbget/NzbgetClient.cs index 6facdb7c0..144805113 100644 --- a/NzbDrone.Core/Download/Clients/Nzbget/NzbgetClient.cs +++ b/NzbDrone.Core/Download/Clients/Nzbget/NzbgetClient.cs @@ -23,8 +23,8 @@ namespace NzbDrone.Core.Download.Clients.Nzbget public void DownloadNzb(RemoteEpisode remoteEpisode) { - var url = remoteEpisode.Report.NzbUrl; - var title = remoteEpisode.Report.Title + ".nzb"; + var url = remoteEpisode.Release.DownloadUrl; + var title = remoteEpisode.Release.Title + ".nzb"; string cat = _configService.NzbgetTvCategory; int priority = remoteEpisode.IsRecentEpisode() ? (int)_configService.NzbgetRecentTvPriority : (int)_configService.NzbgetOlderTvPriority; diff --git a/NzbDrone.Core/Download/Clients/PneumaticClient.cs b/NzbDrone.Core/Download/Clients/PneumaticClient.cs index ff4929805..537683243 100644 --- a/NzbDrone.Core/Download/Clients/PneumaticClient.cs +++ b/NzbDrone.Core/Download/Clients/PneumaticClient.cs @@ -28,8 +28,8 @@ namespace NzbDrone.Core.Download.Clients public void DownloadNzb(RemoteEpisode remoteEpisode) { - var url = remoteEpisode.Report.NzbUrl; - var title = remoteEpisode.Report.Title; + var url = remoteEpisode.Release.DownloadUrl; + var title = remoteEpisode.Release.Title; if (remoteEpisode.ParsedEpisodeInfo.FullSeason) { diff --git a/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdClient.cs b/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdClient.cs index 780545e59..40a241a1c 100644 --- a/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdClient.cs +++ b/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdClient.cs @@ -26,8 +26,8 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd string cat = _configService.SabTvCategory; int priority = (int)_configService.SabRecentTvPriority; - string name = remoteEpisode.Report.NzbUrl.Replace("&", "%26"); - string nzbName = HttpUtility.UrlEncode(remoteEpisode.Report.Title); + string name = remoteEpisode.Release.DownloadUrl.Replace("&", "%26"); + string nzbName = HttpUtility.UrlEncode(remoteEpisode.Release.Title); string action = string.Format("mode=addurl&name={0}&priority={1}&pp=3&cat={2}&nzbname={3}&output=json", name, priority, cat, nzbName); @@ -66,8 +66,8 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd public void DownloadNzb(RemoteEpisode remoteEpisode) { - var url = remoteEpisode.Report.NzbUrl; - var title = remoteEpisode.Report.Title; + var url = remoteEpisode.Release.DownloadUrl; + var title = remoteEpisode.Release.Title; string cat = _configService.SabTvCategory; int priority = remoteEpisode.IsRecentEpisode() ? (int)_configService.SabRecentTvPriority : (int)_configService.SabOlderTvPriority; diff --git a/NzbDrone.Core/Download/DownloadApprovedReports.cs b/NzbDrone.Core/Download/DownloadApprovedReports.cs index fdaf953b5..46f54d1aa 100644 --- a/NzbDrone.Core/Download/DownloadApprovedReports.cs +++ b/NzbDrone.Core/Download/DownloadApprovedReports.cs @@ -59,8 +59,8 @@ namespace NzbDrone.Core.Download return decisions.Where(c => c.Approved && c.RemoteEpisode.Episodes.Any()) .OrderByDescending(c => c.RemoteEpisode.ParsedEpisodeInfo.Quality) .ThenBy(c => c.RemoteEpisode.Episodes.Select(e => e.EpisodeNumber).MinOrDefault()) - .ThenBy(c => c.RemoteEpisode.Report.Size.Round(200.Megabytes()) / c.RemoteEpisode.Episodes.Count) - .ThenBy(c => c.RemoteEpisode.Report.Age) + .ThenBy(c => c.RemoteEpisode.Release.Size.Round(200.Megabytes()) / c.RemoteEpisode.Episodes.Count) + .ThenBy(c => c.RemoteEpisode.Release.Age) .ToList(); } } diff --git a/NzbDrone.Core/Download/DownloadService.cs b/NzbDrone.Core/Download/DownloadService.cs index 091903f03..e95b194d0 100644 --- a/NzbDrone.Core/Download/DownloadService.cs +++ b/NzbDrone.Core/Download/DownloadService.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Download public void DownloadReport(RemoteEpisode remoteEpisode) { - var downloadTitle = remoteEpisode.Report.Title; + var downloadTitle = remoteEpisode.Release.Title; var downloadClient = _downloadClientProvider.GetDownloadClient(); if (!downloadClient.IsConfigured) diff --git a/NzbDrone.Core/History/HistoryService.cs b/NzbDrone.Core/History/HistoryService.cs index a32919b13..ff2b5536b 100644 --- a/NzbDrone.Core/History/HistoryService.cs +++ b/NzbDrone.Core/History/HistoryService.cs @@ -64,15 +64,15 @@ namespace NzbDrone.Core.History EventType = HistoryEventType.Grabbed, Date = DateTime.UtcNow, Quality = message.Episode.ParsedEpisodeInfo.Quality, - SourceTitle = message.Episode.Report.Title, + SourceTitle = message.Episode.Release.Title, SeriesId = episode.SeriesId, EpisodeId = episode.Id, }; - history.Data.Add("Indexer", message.Episode.Report.Indexer); - history.Data.Add("NzbInfoUrl", message.Episode.Report.NzbInfoUrl); - history.Data.Add("ReleaseGroup", message.Episode.Report.ReleaseGroup); - history.Data.Add("Age", message.Episode.Report.Age.ToString()); + history.Data.Add("Indexer", message.Episode.Release.Indexer); + history.Data.Add("NzbInfoUrl", message.Episode.Release.InfoUrl); + history.Data.Add("ReleaseGroup", message.Episode.Release.ReleaseGroup); + history.Data.Add("Age", message.Episode.Release.Age.ToString()); _historyRepository.Insert(history); } diff --git a/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index bcb8105ad..10ce200d6 100644 --- a/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -128,13 +128,13 @@ namespace NzbDrone.Core.IndexerSearch return spec; } - private List Dispatch(Func> searchAction, SearchCriteriaBase criteriaBase) + private List Dispatch(Func> searchAction, SearchCriteriaBase criteriaBase) { var indexers = _indexerService.GetAvailableIndexers().ToList(); + var reports = new List(); _logger.ProgressInfo("Searching {0} indexers for {1}", indexers.Count, criteriaBase); - var reports = new List(); var taskList = new List(); var taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.None); @@ -167,4 +167,4 @@ namespace NzbDrone.Core.IndexerSearch return _makeDownloadDecision.GetSearchDecision(reports, criteriaBase).ToList(); } } -} \ No newline at end of file +} diff --git a/NzbDrone.Core/Indexers/BasicTorrentRssParser.cs b/NzbDrone.Core/Indexers/BasicTorrentRssParser.cs new file mode 100644 index 000000000..d3c8ab15a --- /dev/null +++ b/NzbDrone.Core/Indexers/BasicTorrentRssParser.cs @@ -0,0 +1,48 @@ +using System; +using System.Xml.Linq; +using NLog; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.Indexers +{ + public class BasicTorrentRssParser : RssParserBase + { + protected override ReleaseInfo CreateNewReleaseInfo() + { + return new TorrentInfo(); + } + + protected override ReleaseInfo PostProcessor(XElement item, ReleaseInfo currentResult) + { + var torrentInfo = (TorrentInfo)currentResult; + + torrentInfo.MagnetUrl = MagnetUrl(item); + torrentInfo.InfoHash = InfoHash(item); + + return torrentInfo; + } + + protected override long GetSize(XElement item) + { + var elementLength = GetTorrentElement(item).Element("contentLength"); + return Convert.ToInt64(elementLength.Value); + } + + protected virtual string MagnetUrl(XElement item) + { + var elementLength = GetTorrentElement(item).Element("magnetURI"); + return elementLength.Value; + } + + protected virtual string InfoHash(XElement item) + { + var elementLength = GetTorrentElement(item).Element("infoHash"); + return elementLength.Value; + } + + private static XElement GetTorrentElement(XElement item) + { + return item.Element("torrent"); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/DownloadProtocols.cs b/NzbDrone.Core/Indexers/DownloadProtocols.cs new file mode 100644 index 000000000..4fff5e07d --- /dev/null +++ b/NzbDrone.Core/Indexers/DownloadProtocols.cs @@ -0,0 +1,8 @@ +namespace NzbDrone.Core.Indexers +{ + public enum DownloadProtocols + { + Nzb = 0, + Torrent =1 + } +} \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/Eztv/Eztv.cs b/NzbDrone.Core/Indexers/Eztv/Eztv.cs new file mode 100644 index 000000000..541f3a078 --- /dev/null +++ b/NzbDrone.Core/Indexers/Eztv/Eztv.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; + +namespace NzbDrone.Core.Indexers.Eztv +{ + public class Eztv : IndexerBase + { + public override string Name + { + get { return "Eztv"; } + } + + public override IndexerKind Kind + { + get + { + return IndexerKind.Torrent; + } + } + + public override bool EnableByDefault + { + get { return false; } + } + + public override IParseFeed Parser + { + get + { + return new BasicTorrentRssParser(); + } + } + + public override IEnumerable RecentFeed + { + get + { + return new[] + { + "http://www.ezrss.it/feed/" + }; + } + } + + public override IEnumerable GetEpisodeSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int episodeNumber) + { + yield return string.Format("http://www.ezrss.it/search/index.php?show_name={0}&season={1}&episode={2}&mode=rss", seriesTitle, seasonNumber, episodeNumber); + } + + public override IEnumerable GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int offset) + { + yield return string.Format("http://www.ezrss.it/search/index.php?show_name={0}&season={1}&mode=rss", seriesTitle, seasonNumber); + + } + + public override IEnumerable GetDailyEpisodeSearchUrls(string seriesTitle, int tvRageId, DateTime date) + { + //EZTV doesn't support searching based on actual epidose airdate. they only support release date. + return new string[0]; + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/FetchAndParseRssService.cs b/NzbDrone.Core/Indexers/FetchAndParseRssService.cs index 9ee704910..c9633c8d0 100644 --- a/NzbDrone.Core/Indexers/FetchAndParseRssService.cs +++ b/NzbDrone.Core/Indexers/FetchAndParseRssService.cs @@ -9,7 +9,7 @@ namespace NzbDrone.Core.Indexers { public interface IFetchAndParseRss { - List Fetch(); + List Fetch(); } public class FetchAndParseRssService : IFetchAndParseRss @@ -25,9 +25,9 @@ namespace NzbDrone.Core.Indexers _logger = logger; } - public List Fetch() + public List Fetch() { - var result = new List(); + var result = new List(); var indexers = _indexerService.GetAvailableIndexers().ToList(); diff --git a/NzbDrone.Core/Indexers/IIndexer.cs b/NzbDrone.Core/Indexers/IIndexer.cs index c8e8e950f..a681ae3df 100644 --- a/NzbDrone.Core/Indexers/IIndexer.cs +++ b/NzbDrone.Core/Indexers/IIndexer.cs @@ -6,7 +6,7 @@ namespace NzbDrone.Core.Indexers public interface IIndexer { string Name { get; } - + bool EnableByDefault { get; } IEnumerable DefaultDefinitions { get; } @@ -16,6 +16,7 @@ namespace NzbDrone.Core.Indexers IEnumerable RecentFeed { get; } IParseFeed Parser { get; } + IndexerKind Kind { get; } IEnumerable GetEpisodeSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int episodeNumber); IEnumerable GetDailyEpisodeSearchUrls(string seriesTitle, int tvRageId, DateTime date); diff --git a/NzbDrone.Core/Indexers/IParseFeed.cs b/NzbDrone.Core/Indexers/IParseFeed.cs new file mode 100644 index 000000000..a101f0a07 --- /dev/null +++ b/NzbDrone.Core/Indexers/IParseFeed.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using System.IO; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.Indexers +{ + public interface IParseFeed + { + IEnumerable Process(string source, string url); + } +} \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/IndexerBase.cs b/NzbDrone.Core/Indexers/IndexerBase.cs index 4b2cd9f99..6f544a2be 100644 --- a/NzbDrone.Core/Indexers/IndexerBase.cs +++ b/NzbDrone.Core/Indexers/IndexerBase.cs @@ -7,6 +7,8 @@ namespace NzbDrone.Core.Indexers { public abstract string Name { get; } + public abstract IndexerKind Kind { get; } + public virtual bool EnableByDefault { get { return true; } } public IndexerDefinition InstanceDefinition { get; set; } @@ -25,17 +27,17 @@ namespace NzbDrone.Core.Indexers } } - public virtual IParseFeed Parser - { - get - { - return new BasicRssParser(); - } - } + public virtual IParseFeed Parser { get; private set; } public abstract IEnumerable RecentFeed { get; } public abstract IEnumerable GetEpisodeSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int episodeNumber); public abstract IEnumerable GetDailyEpisodeSearchUrls(string seriesTitle, int tvRageId, DateTime date); public abstract IEnumerable GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int offset); } + + public enum IndexerKind + { + Usenet, + Torrent + } } \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/IndexerFetchService.cs b/NzbDrone.Core/Indexers/IndexerFetchService.cs index cc0eb8691..638e2a4af 100644 --- a/NzbDrone.Core/Indexers/IndexerFetchService.cs +++ b/NzbDrone.Core/Indexers/IndexerFetchService.cs @@ -11,11 +11,11 @@ namespace NzbDrone.Core.Indexers { public interface IFetchFeedFromIndexers { - IList FetchRss(IIndexer indexer); + IList FetchRss(IIndexer indexer); - IList Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria); - IList Fetch(IIndexer indexer, SingleEpisodeSearchCriteria searchCriteria); - IList Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria); + IList Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria); + IList Fetch(IIndexer indexer, SingleEpisodeSearchCriteria searchCriteria); + IList Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria); } public class FetchFeedService : IFetchFeedFromIndexers @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Indexers } - public virtual IList FetchRss(IIndexer indexer) + public virtual IList FetchRss(IIndexer indexer) { _logger.Debug("Fetching feeds from " + indexer.Name); @@ -42,11 +42,11 @@ namespace NzbDrone.Core.Indexers return result; } - public IList Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria) + public IList Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria) { _logger.Debug("Searching for {0}", searchCriteria); - var result = Fetch(indexer, searchCriteria, 0).DistinctBy(c => c.NzbUrl).ToList(); + var result = Fetch(indexer, searchCriteria, 0).DistinctBy(c => c.DownloadUrl).ToList(); _logger.Info("Finished searching {0} for {1}. Found {2}", indexer.Name, searchCriteria, result.Count); @@ -54,7 +54,7 @@ namespace NzbDrone.Core.Indexers } - private IList Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria, int offset) + private IList Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria, int offset) { _logger.Debug("Searching for {0} offset: {1}", searchCriteria, offset); @@ -72,7 +72,7 @@ namespace NzbDrone.Core.Indexers return result; } - public IList Fetch(IIndexer indexer, SingleEpisodeSearchCriteria searchCriteria) + public IList Fetch(IIndexer indexer, SingleEpisodeSearchCriteria searchCriteria) { _logger.Debug("Searching for {0}", searchCriteria); @@ -84,7 +84,7 @@ namespace NzbDrone.Core.Indexers return result; } - public IList Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria) + public IList Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria) { _logger.Debug("Searching for {0}", searchCriteria); @@ -95,9 +95,9 @@ namespace NzbDrone.Core.Indexers return result; } - private List Fetch(IIndexer indexer, IEnumerable urls) + private List Fetch(IIndexer indexer, IEnumerable urls) { - var result = new List(); + var result = new List(); foreach (var url in urls) { @@ -138,4 +138,4 @@ namespace NzbDrone.Core.Indexers return result; } } -} \ No newline at end of file +} diff --git a/NzbDrone.Core/Indexers/IndexerService.cs b/NzbDrone.Core/Indexers/IndexerService.cs index aad4bf889..f3261eb3c 100644 --- a/NzbDrone.Core/Indexers/IndexerService.cs +++ b/NzbDrone.Core/Indexers/IndexerService.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Common.Serializer; +using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers.Newznab; using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Messaging; @@ -35,15 +36,26 @@ namespace NzbDrone.Core.Indexers public class IndexerService : IIndexerService, IHandle { private readonly IIndexerRepository _indexerRepository; + private readonly IConfigFileProvider _configFileProvider; private readonly Logger _logger; private readonly List _indexers; - public IndexerService(IIndexerRepository indexerRepository, IEnumerable indexers, Logger logger) + public IndexerService(IIndexerRepository indexerRepository, IEnumerable indexers, IConfigFileProvider configFileProvider, Logger logger) { _indexerRepository = indexerRepository; + _configFileProvider = configFileProvider; _logger = logger; - _indexers = indexers.ToList(); + + + if (!configFileProvider.Torrent) + { + _indexers = indexers.Where(c => c.Kind != IndexerKind.Torrent).ToList(); + } + else + { + _indexers = indexers.ToList(); + } } public List All() @@ -153,10 +165,16 @@ namespace NzbDrone.Core.Indexers RemoveMissingImplementations(); - if (!All().Any()) + var definitions = _indexers.SelectMany(indexer => indexer.DefaultDefinitions); + + var currentIndexer = All(); + + var newIndexers = definitions.Where(def => currentIndexer.All(c => c.Implementation != def.Implementation)).ToList(); + + + if (newIndexers.Any()) { - var definitions = _indexers.SelectMany(indexer => indexer.DefaultDefinitions); - _indexerRepository.InsertMany(definitions.ToList()); + _indexerRepository.InsertMany(newIndexers); } } diff --git a/NzbDrone.Core/Indexers/Newznab/Newznab.cs b/NzbDrone.Core/Indexers/Newznab/Newznab.cs index 51c49e26d..4341c22f7 100644 --- a/NzbDrone.Core/Indexers/Newznab/Newznab.cs +++ b/NzbDrone.Core/Indexers/Newznab/Newznab.cs @@ -123,6 +123,15 @@ namespace NzbDrone.Core.Indexers.Newznab } } + public override IndexerKind Kind + { + get + { + return IndexerKind.Usenet; + } + } + + private static string NewsnabifyTitle(string title) { return title.Replace("+", "%20"); diff --git a/NzbDrone.Core/Indexers/Newznab/NewznabParser.cs b/NzbDrone.Core/Indexers/Newznab/NewznabParser.cs index 54cfa1082..06c45ea1d 100644 --- a/NzbDrone.Core/Indexers/Newznab/NewznabParser.cs +++ b/NzbDrone.Core/Indexers/Newznab/NewznabParser.cs @@ -5,29 +5,33 @@ using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Indexers.Newznab { - public class NewznabParser : BasicRssParser + public class NewznabParser : RssParserBase { - private static readonly XNamespace NewznabNamespace = "http://www.newznab.com/DTD/2010/feeds/attributes/"; - protected override string GetNzbInfoUrl(XElement item) { return item.Comments().Replace("#comments", ""); } - protected override ReportInfo PostProcessor(XElement item, ReportInfo currentResult) + protected override long GetSize(XElement item) { - if (currentResult != null) + var attributes = item.Elements("attr").ToList(); + var sizeElement = attributes.SingleOrDefault(e => e.Attribute("name").Value.Equals("size", StringComparison.CurrentCultureIgnoreCase)); + + if (sizeElement == null) { - var attributes = item.Elements(NewznabNamespace + "attr").ToList(); - var sizeElement = attributes.SingleOrDefault(e => e.Attribute("name").Value.Equals("size", StringComparison.CurrentCultureIgnoreCase)); - var rageIdElement = attributes.SingleOrDefault(e => e.Attribute("name").Value.Equals("rageid", StringComparison.CurrentCultureIgnoreCase)); - if (sizeElement == null) - { - throw new SizeParsingException("Unable to parse size from: {0} [{1}]", currentResult.Title, currentResult.Indexer); - } + } - currentResult.Size = Convert.ToInt64(sizeElement.Attribute("value").Value); + return Convert.ToInt64(sizeElement.Attribute("value").Value); + } + + protected override ReleaseInfo PostProcessor(XElement item, ReleaseInfo currentResult) + { + if (currentResult != null) + { + var attributes = item.Elements("attr").ToList(); + + var rageIdElement = attributes.SingleOrDefault(e => e.Attribute("name").Value.Equals("rageid", StringComparison.CurrentCultureIgnoreCase)); if (rageIdElement != null) { diff --git a/NzbDrone.Core/Indexers/NzbClub/NzbClub.cs b/NzbDrone.Core/Indexers/NzbClub/NzbClub.cs deleted file mode 100644 index cb2bc8a5f..000000000 --- a/NzbDrone.Core/Indexers/NzbClub/NzbClub.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace NzbDrone.Core.Indexers.NzbClub -{ - public class NzbClub : IndexerBase - { - public override string Name - { - get { return "NzbClub"; } - } - - public override bool EnableByDefault - { - get { return false; } - } - - public override IParseFeed Parser - { - get - { - return new NzbClubParser(); - } - } - - public override IEnumerable RecentFeed - { - get - { - return new[] - { - String.Format("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=102952&st=1&ns=1&q=%23a.b.teevee"), - String.Format("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=5542&st=1&ns=1&q=") - }; - } - } - - public override IEnumerable GetEpisodeSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int episodeNumber) - { - var searchUrls = new List(); - - foreach (var url in RecentFeed) - { - searchUrls.Add(String.Format("{0}+{1}+s{2:00}e{3:00}", url, seriesTitle, seasonNumber, episodeNumber)); - } - - return searchUrls; - } - - public override IEnumerable GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int offset) - { - var searchUrls = new List(); - - foreach (var url in RecentFeed) - { - searchUrls.Add(String.Format("{0}+{1}+s{2:00}", url, seriesTitle, seasonNumber)); - } - - return searchUrls; - } - - public override IEnumerable GetDailyEpisodeSearchUrls(string seriesTitle, int tvRageId, DateTime date) - { - var searchUrls = new List(); - - foreach (var url in RecentFeed) - { - searchUrls.Add(String.Format("{0}+{1}+{2:yyyy MM dd}", url, seriesTitle, date)); - } - - return searchUrls; - } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/NzbClub/NzbClubParser.cs b/NzbDrone.Core/Indexers/NzbClub/NzbClubParser.cs deleted file mode 100644 index 30a3b899e..000000000 --- a/NzbDrone.Core/Indexers/NzbClub/NzbClubParser.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Linq; -using System.Text.RegularExpressions; -using System.Xml.Linq; -using NLog; -using NzbDrone.Common.Instrumentation; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.Indexers.NzbClub -{ - public class NzbClubParser : BasicRssParser - { - - private static readonly Regex SizeRegex = new Regex(@"(?:Size:)\s(?\d+.\d+\s[g|m]i?[b])", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private readonly Logger logger; - - public NzbClubParser() - { - logger = NzbDroneLogger.GetLogger(); - } - - - protected override ReportInfo PostProcessor(XElement item, ReportInfo currentResult) - { - if (currentResult != null) - { - var match = SizeRegex.Match(item.Description()); - - if (match.Success && match.Groups["size"].Success) - { - currentResult.Size = GetReportSize(match.Groups["size"].Value); - } - else - { - logger.Warn("Couldn't parse size from {0}", item.Description()); - } - } - - return currentResult; - } - - protected override string GetTitle(XElement item) - { - var title = ParseHeader(item.Title()); - - if (String.IsNullOrWhiteSpace(title)) - return item.Title(); - - return title; - } - - protected override string GetNzbInfoUrl(XElement item) - { - return item.Links().First(); - } - - protected override string GetNzbUrl(XElement item) - { - var enclosure = item.Element("enclosure"); - - return enclosure.Attribute("url").Value; - } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/Omgwtfnzbs/Omgwtfnzbs.cs b/NzbDrone.Core/Indexers/Omgwtfnzbs/Omgwtfnzbs.cs index 8d8e9b4a9..15f6dbbe5 100644 --- a/NzbDrone.Core/Indexers/Omgwtfnzbs/Omgwtfnzbs.cs +++ b/NzbDrone.Core/Indexers/Omgwtfnzbs/Omgwtfnzbs.cs @@ -10,6 +10,14 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs get { return "omgwtfnzbs"; } } + public override IndexerKind Kind + { + get + { + return IndexerKind.Usenet; + } + } + public override IParseFeed Parser { get diff --git a/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsParser.cs b/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsParser.cs index a2369f81a..afaeb3890 100644 --- a/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsParser.cs +++ b/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsParser.cs @@ -1,11 +1,10 @@ using System; using System.Text.RegularExpressions; using System.Xml.Linq; -using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Indexers.Omgwtfnzbs { - public class OmgwtfnzbsParser : BasicRssParser + public class OmgwtfnzbsParser : RssParserBase { protected override string GetNzbInfoUrl(XElement item) { @@ -21,15 +20,10 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs return String.Empty; } - protected override ReportInfo PostProcessor(XElement item, ReportInfo currentResult) + protected override long GetSize(XElement item) { - if (currentResult != null) - { - var sizeString = Regex.Match(item.Description(), @"(?:Size:\<\/b\>\s\d+\.)\d{1,2}\s\w{2}(?:\
)", RegexOptions.IgnoreCase | RegexOptions.Compiled).Value; - currentResult.Size = GetReportSize(sizeString); - } - - return currentResult; + var sizeString = Regex.Match(item.Description(), @"(?:Size:\<\/b\>\s\d+\.)\d{1,2}\s\w{2}(?:\
)", RegexOptions.IgnoreCase | RegexOptions.Compiled).Value; + return ParseSize(sizeString); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/BasicRssParser.cs b/NzbDrone.Core/Indexers/RssParserBase.cs similarity index 65% rename from NzbDrone.Core/Indexers/BasicRssParser.cs rename to NzbDrone.Core/Indexers/RssParserBase.cs index 447a27674..485bc0140 100644 --- a/NzbDrone.Core/Indexers/BasicRssParser.cs +++ b/NzbDrone.Core/Indexers/RssParserBase.cs @@ -8,43 +8,44 @@ using System.Xml; using System.Xml.Linq; using NLog; using NzbDrone.Common.Instrumentation; +using NzbDrone.Core.Indexers.Newznab; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Indexers { - public interface IParseFeed - { - IEnumerable Process(string xml, string url); - } - - public class BasicRssParser : IParseFeed + public abstract class RssParserBase : IParseFeed { private readonly Logger _logger; - public BasicRssParser() + protected virtual ReleaseInfo CreateNewReleaseInfo() + { + return new ReleaseInfo(); + } + + protected RssParserBase() { _logger = NzbDroneLogger.GetLogger(this); } - public IEnumerable Process(string xml, string url) + public IEnumerable Process(string xml, string url) { using (var xmlTextReader = XmlReader.Create(new StringReader(xml), new XmlReaderSettings { ProhibitDtd = false, IgnoreComments = true })) { + var document = XDocument.Load(xmlTextReader); var items = document.Descendants("item"); - var result = new List(); + var result = new List(); foreach (var item in items) { try { - var reportInfo = ParseFeedItem(item); + var reportInfo = ParseFeedItem(item.StripNameSpace(), url); if (reportInfo != null) { - reportInfo.NzbUrl = GetNzbUrl(item); - reportInfo.NzbInfoUrl = GetNzbInfoUrl(item); - + reportInfo.DownloadUrl = GetNzbUrl(item); + reportInfo.InfoUrl = GetNzbInfoUrl(item); result.Add(reportInfo); } } @@ -59,6 +60,31 @@ namespace NzbDrone.Core.Indexers } } + private ReleaseInfo ParseFeedItem(XElement item, string url) + { + var title = GetTitle(item); + + var reportInfo = CreateNewReleaseInfo(); + + reportInfo.Title = title; + reportInfo.PublishDate = item.PublishDate(); + reportInfo.ReleaseGroup = ParseReleaseGroup(title); + reportInfo.DownloadUrl = GetNzbUrl(item); + reportInfo.InfoUrl = GetNzbInfoUrl(item); + + try + { + reportInfo.Size = GetSize(item); + } + catch (Exception) + { + throw new SizeParsingException("Unable to parse size from: {0} [{1}]", reportInfo.Title, url); + } + + _logger.Trace("Parsed: {0} from: {1}", reportInfo, item.Title()); + + return PostProcessor(item, reportInfo); + } protected virtual string GetTitle(XElement item) { @@ -75,25 +101,14 @@ namespace NzbDrone.Core.Indexers return String.Empty; } - protected virtual ReportInfo PostProcessor(XElement item, ReportInfo currentResult) + protected abstract long GetSize(XElement item); + + protected virtual ReleaseInfo PostProcessor(XElement item, ReleaseInfo currentResult) { return currentResult; } - private ReportInfo ParseFeedItem(XElement item) - { - var title = GetTitle(item); - var reportInfo = new ReportInfo(); - - reportInfo.Title = title; - reportInfo.Age = DateTime.Now.Date.Subtract(item.PublishDate().Date).Days; - reportInfo.ReleaseGroup = ParseReleaseGroup(title); - - _logger.Trace("Parsed: {0} from: {1}", reportInfo, item.Title()); - - return PostProcessor(item, reportInfo); - } public static string ParseReleaseGroup(string title) { @@ -111,39 +126,15 @@ namespace NzbDrone.Core.Indexers if (@group.Length == title.Length) return String.Empty; - return @group; - } - - private static readonly Regex[] HeaderRegex = new[] - { - new Regex(@"(?:\[.+\]\-\[.+\]\-\[.+\]\-\[)(?.+)(?:\]\-.+)", - RegexOptions.IgnoreCase), - - new Regex(@"(?:\[.+\]\W+\[.+\]\W+\[.+\]\W+\"")(?.+)(?:\"".+)", - RegexOptions.IgnoreCase), - - new Regex(@"(?:\[)(?.+)(?:\]\-.+)", - RegexOptions.IgnoreCase), - }; - - public static string ParseHeader(string header) - { - foreach (var regex in HeaderRegex) - { - var match = regex.Matches(header); - - if (match.Count != 0) - return match[0].Groups["nzbTitle"].Value.Trim(); - } - - return header; + return @group.Trim('-', ' ', '[', ']'); } private static readonly Regex ReportSizeRegex = new Regex(@"(?\d+\.\d{1,2}|\d+\,\d+\.\d{1,2}|\d+)\W?(?GB|MB|GiB|MiB)", RegexOptions.IgnoreCase | RegexOptions.Compiled); - public static long GetReportSize(string sizeString) + + public static long ParseSize(string sizeString) { var match = ReportSizeRegex.Matches(sizeString); @@ -177,4 +168,4 @@ namespace NzbDrone.Core.Indexers return Convert.ToInt64(result); } } -} \ No newline at end of file +} diff --git a/NzbDrone.Core/Indexers/Wombles/Wombles.cs b/NzbDrone.Core/Indexers/Wombles/Wombles.cs index adff820ec..95cd559de 100644 --- a/NzbDrone.Core/Indexers/Wombles/Wombles.cs +++ b/NzbDrone.Core/Indexers/Wombles/Wombles.cs @@ -10,6 +10,14 @@ namespace NzbDrone.Core.Indexers.Wombles get { return "WomblesIndex"; } } + public override IndexerKind Kind + { + get + { + return IndexerKind.Usenet; + } + } + public override IParseFeed Parser { get diff --git a/NzbDrone.Core/Indexers/Wombles/WomblesParser.cs b/NzbDrone.Core/Indexers/Wombles/WomblesParser.cs index de2aa0a99..2b67dfe97 100644 --- a/NzbDrone.Core/Indexers/Wombles/WomblesParser.cs +++ b/NzbDrone.Core/Indexers/Wombles/WomblesParser.cs @@ -1,23 +1,17 @@ using System.Xml.Linq; -using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Indexers.Wombles { - public class WomblesParser : BasicRssParser + public class WomblesParser : RssParserBase { protected override string GetNzbInfoUrl(XElement item) { return null; } - protected override ReportInfo PostProcessor(XElement item, ReportInfo currentResult) + protected override long GetSize(XElement item) { - if (currentResult != null) - { - currentResult.Size = 0; - } - - return currentResult; + return 0; } } } \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/XElementExtensions.cs b/NzbDrone.Core/Indexers/XElementExtensions.cs index 1608d0ec6..254c9ae6f 100644 --- a/NzbDrone.Core/Indexers/XElementExtensions.cs +++ b/NzbDrone.Core/Indexers/XElementExtensions.cs @@ -11,7 +11,6 @@ namespace NzbDrone.Core.Indexers { public static class XElementExtensions { - private static readonly Logger Logger = NzbDroneLogger.GetLogger(); private static readonly Regex RemoveTimeZoneRegex = new Regex(@"\s[A-Z]{2,4}$", RegexOptions.Compiled); @@ -21,6 +20,21 @@ namespace NzbDrone.Core.Indexers return item.TryGetValue("title", "Unknown"); } + public static XElement StripNameSpace(this XElement root) + { + var res = new XElement( + root.Name.LocalName, + root.HasElements ? + root.Elements().Select(StripNameSpace) : + (object)root.Value + ); + + res.ReplaceAttributes( + root.Attributes().Where(attr => (!attr.IsNamespaceDeclaration))); + + return res; + } + public static DateTime PublishDate(this XElement item) { string dateString = item.TryGetValue("pubDate"); @@ -33,7 +47,7 @@ namespace NzbDrone.Core.Indexers dateString = RemoveTimeZoneRegex.Replace(dateString, ""); result = DateTime.Parse(dateString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal); } - return result.ToUniversalTime(); + return result.ToUniversalTime().Date; } catch (FormatException e) { @@ -59,6 +73,11 @@ namespace NzbDrone.Core.Indexers return item.TryGetValue("comments"); } + public static long Length(this XElement item) + { + return long.Parse(item.TryGetValue("length")); + } + private static string TryGetValue(this XElement item, string elementName, string defaultValue = "") { var element = item.Element(elementName); diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 00914e182..bcba2a519 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -215,10 +215,14 @@ + + + + @@ -294,7 +298,7 @@ - + @@ -303,8 +307,6 @@ - - @@ -373,7 +375,8 @@ - + + diff --git a/NzbDrone.Core/Parser/Model/ReleaseInfo.cs b/NzbDrone.Core/Parser/Model/ReleaseInfo.cs new file mode 100644 index 000000000..e5b3d9ed8 --- /dev/null +++ b/NzbDrone.Core/Parser/Model/ReleaseInfo.cs @@ -0,0 +1,27 @@ +using System; + +namespace NzbDrone.Core.Parser.Model +{ + public class ReleaseInfo + { + public string Title { get; set; } + public long Size { get; set; } + public string DownloadUrl { get; set; } + public string InfoUrl { get; set; } + public string CommentUrl { get; set; } + public String Indexer { get; set; } + + public DateTime PublishDate { get; set; } + + public int Age + { + get + { + return DateTime.UtcNow.Subtract(PublishDate).Days; + } + } + + public string ReleaseGroup { get; set; } + public int TvRageId { get; set; } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/Parser/Model/RemoteEpisode.cs b/NzbDrone.Core/Parser/Model/RemoteEpisode.cs index 70b001511..ac394d0d8 100644 --- a/NzbDrone.Core/Parser/Model/RemoteEpisode.cs +++ b/NzbDrone.Core/Parser/Model/RemoteEpisode.cs @@ -7,7 +7,7 @@ namespace NzbDrone.Core.Parser.Model { public class RemoteEpisode { - public ReportInfo Report { get; set; } + public ReleaseInfo Release { get; set; } public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; } @@ -22,7 +22,7 @@ namespace NzbDrone.Core.Parser.Model public override string ToString() { - return Report.Title; + return Release.Title; } } } \ No newline at end of file diff --git a/NzbDrone.Core/Parser/Model/ReportInfo.cs b/NzbDrone.Core/Parser/Model/ReportInfo.cs deleted file mode 100644 index d357d7d66..000000000 --- a/NzbDrone.Core/Parser/Model/ReportInfo.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace NzbDrone.Core.Parser.Model -{ - public class ReportInfo - { - public string Title { get; set; } - public long Size { 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 int TvRageId { get; set; } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Parser/Model/TorrentInfo.cs b/NzbDrone.Core/Parser/Model/TorrentInfo.cs new file mode 100644 index 000000000..434967b2b --- /dev/null +++ b/NzbDrone.Core/Parser/Model/TorrentInfo.cs @@ -0,0 +1,8 @@ +namespace NzbDrone.Core.Parser.Model +{ + public class TorrentInfo : ReleaseInfo + { + public string MagnetUrl { get; set; } + public string InfoHash { get; set; } + } +} \ No newline at end of file diff --git a/NzbDrone.Integration.Test/ReleaseIntegrationTest.cs b/NzbDrone.Integration.Test/ReleaseIntegrationTest.cs index 8af6f77e4..b9a86674e 100644 --- a/NzbDrone.Integration.Test/ReleaseIntegrationTest.cs +++ b/NzbDrone.Integration.Test/ReleaseIntegrationTest.cs @@ -22,7 +22,7 @@ namespace NzbDrone.Integration.Test { releaseResource.Age.Should().BeGreaterOrEqualTo(-1); releaseResource.Title.Should().NotBeBlank(); - releaseResource.NzbUrl.Should().NotBeBlank(); + releaseResource.DownloadUrl.Should().NotBeBlank(); releaseResource.SeriesTitle.Should().NotBeBlank(); //TODO: uncomment these after moving to restsharp for rss //releaseResource.NzbInfoUrl.Should().NotBeBlank(); diff --git a/NzbDrone.Wix/configuration.xml b/NzbDrone.Wix/configuration.xml new file mode 100644 index 000000000..fdf4f44bf --- /dev/null +++ b/NzbDrone.Wix/configuration.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/NzbDrone.Wix/dotNetInstaller.exe b/NzbDrone.Wix/dotNetInstaller.exe new file mode 100644 index 000000000..a0dd60f8b Binary files /dev/null and b/NzbDrone.Wix/dotNetInstaller.exe differ diff --git a/NzbDrone.Wix/nzbdrone.wix.build.bat b/NzbDrone.Wix/nzbdrone.wix.build.bat new file mode 100644 index 000000000..f031916c2 --- /dev/null +++ b/NzbDrone.Wix/nzbdrone.wix.build.bat @@ -0,0 +1,8 @@ +rd _raw /s /q +rd _setup /s /q +xcopy ..\SyntikX.Client\bin\release\*.* _raw\ /S /V /I /F /R + +"C:\Program Files (x86)\WiX Toolset v3.6\bin\candle.exe" -nologo "syntik.wix.build.wxs" -out "_setup\SyntikX.Wix.wixobj" -ext WixNetFxExtension -ext WixUIExtension +"C:\Program Files (x86)\WiX Toolset v3.6\bin\light.exe" -nologo "_setup\SyntikX.Wix.wixobj" -out "_setup\SyntikX.msi" -ext WixNetFxExtension -ext WixUIExtension + +pause \ No newline at end of file diff --git a/NzbDrone.Wix/nzbdrone.wix.build.debug.bat b/NzbDrone.Wix/nzbdrone.wix.build.debug.bat new file mode 100644 index 000000000..abf84ccaf --- /dev/null +++ b/NzbDrone.Wix/nzbdrone.wix.build.debug.bat @@ -0,0 +1,10 @@ +rd _raw /s /q +rd _setup /s /q +xcopy ..\SyntikX.Client\bin\debug\*.* _raw\ /S /V /I /F /R + +SET BUILD_NUMBER=1.9.9.9 + +"C:\Program Files (x86)\WiX Toolset v3.6\bin\candle.exe" -nologo "syntik.wix.build.wxs" -out "_setup\SyntikX.Wix.wixobj" -ext WixNetFxExtension -ext WixUIExtension +"C:\Program Files (x86)\WiX Toolset v3.6\bin\light.exe" -nologo "_setup\SyntikX.Wix.wixobj" -out "_setup\SyntikX.Wix.msi" -ext WixNetFxExtension -ext WixUIExtension + +pause \ No newline at end of file diff --git a/NzbDrone.Wix/nzbdrone.wix.build.wxs b/NzbDrone.Wix/nzbdrone.wix.build.wxs new file mode 100644 index 000000000..36284be23 --- /dev/null +++ b/NzbDrone.Wix/nzbdrone.wix.build.wxs @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NETFRAMEWORK40FULL + + + + + + + + + \ No newline at end of file diff --git a/UI/Cells/EpisodeNumberCell.js b/UI/Cells/EpisodeNumberCell.js index b72720de1..6ce14f131 100644 --- a/UI/Cells/EpisodeNumberCell.js +++ b/UI/Cells/EpisodeNumberCell.js @@ -17,11 +17,11 @@ define( var seasonField = this.column.get('seasonNumber') || 'seasonNumber'; var episodeField = this.column.get('episodes') || 'episodeNumber'; - if (this.cellValue) { + if (this.model) { - var airDate = this.cellValue.get(airDateField); - var seasonNumber = this.cellValue.get(seasonField); - var episodes = this.cellValue.get(episodeField); + var airDate = this.model.get(airDateField); + var seasonNumber = this.model.get(seasonField); + var episodes = this.model.get(episodeField); var result = 'Unknown'; diff --git a/UI/History/Details/HistoryDetailsViewTemplate.html b/UI/History/Details/HistoryDetailsViewTemplate.html index 5d15ca7b4..2dd83ed5e 100644 --- a/UI/History/Details/HistoryDetailsViewTemplate.html +++ b/UI/History/Details/HistoryDetailsViewTemplate.html @@ -27,7 +27,7 @@ {{#if nzbInfoUrl}}
Info
-
{{nzbInfoUrl}}o
+
{{infoUrl}}o
{{/if}} {{/with}}