From ac387f208ac359353870e4d265c3c5f71d6daf18 Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 19 Mar 2019 06:03:40 -0400 Subject: [PATCH] Fixed: Support new feed url format IPTorrents (#573) (#3390) --- .../IPTorrentsTests/IPTorrentsFixture.cs | 60 ++++++++++++++++++- .../Indexers/IPTorrents/IPTorrentsSettings.cs | 6 +- 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core.Test/IndexerTests/IPTorrentsTests/IPTorrentsFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/IPTorrentsTests/IPTorrentsFixture.cs index 7b5b4fc1a..08204e6a7 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/IPTorrentsTests/IPTorrentsFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/IPTorrentsTests/IPTorrentsFixture.cs @@ -1,4 +1,4 @@ -using Moq; +using Moq; using NUnit.Framework; using NzbDrone.Common.Http; using NzbDrone.Core.Indexers; @@ -24,6 +24,64 @@ namespace NzbDrone.Core.Test.IndexerTests.IPTorrentsTests }; } + private void GivenOldFeedFormat() + { + Subject.Definition = new IndexerDefinition() + { + Name = "IPTorrents", + Settings = new IPTorrentsSettings() { BaseUrl = "https://iptorrents.com/torrents/rss?u=snip;tp=snip;3;80;93;37;download" } + }; + } + + private void GivenNewFeedFormat() + { + Subject.Definition = new IndexerDefinition() + { + Name = "IPTorrents", + Settings = new IPTorrentsSettings() { BaseUrl = "https://iptorrents.com/t.rss?u=USERID;tp=APIKEY;3;80;93;37;download" } + }; + } + + private void GivenFeedNoDownloadFormat() + { + Subject.Definition = new IndexerDefinition() + { + Name = "IPTorrents", + Settings = new IPTorrentsSettings() { BaseUrl = "https://iptorrents.com/t.rss?u=USERID;tp=APIKEY;3;80;93;37" } + }; + } + + [Test] + public void should_validate_old_feed_format() + { + GivenOldFeedFormat(); + var validationResult = Subject.Definition.Settings.Validate(); + validationResult.IsValid.Should().BeTrue(); + } + + [Test] + public void should_validate_new_feed_format() + { + GivenNewFeedFormat(); + var validationResult = Subject.Definition.Settings.Validate(); + validationResult.IsValid.Should().BeTrue(); + } + + [Test] + public void should_not_validate_bad_format() + { + var validationResult = Subject.Definition.Settings.Validate(); + validationResult.IsValid.Should().BeFalse(); + } + + [Test] + public void should_not_validate_no_download_format() + { + GivenFeedNoDownloadFormat(); + var validationResult = Subject.Definition.Settings.Validate(); + validationResult.IsValid.Should().BeFalse(); + } + [Test] public void should_parse_recent_feed_from_IPTorrents() { diff --git a/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsSettings.cs b/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsSettings.cs index 6d3023bbf..67a31bb01 100644 --- a/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsSettings.cs +++ b/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsSettings.cs @@ -16,11 +16,11 @@ namespace NzbDrone.Core.Indexers.IPTorrents { RuleFor(c => c.BaseUrl).ValidRootUrl(); - RuleFor(c => c.BaseUrl).Matches(@"/rss\?.+$"); + RuleFor(c => c.BaseUrl).Matches(@"(?:/|t\.)rss\?.+$"); - RuleFor(c => c.BaseUrl).Matches(@"/rss\?.+;download(?:;|$)") + RuleFor(c => c.BaseUrl).Matches(@"(?:/|t\.)rss\?.+;download(?:;|$)") .WithMessage("Use Direct Download Url (;download)") - .When(v => v.BaseUrl.IsNotNullOrWhiteSpace() && Regex.IsMatch(v.BaseUrl, @"/rss\?.+$")); + .When(v => v.BaseUrl.IsNotNullOrWhiteSpace() && Regex.IsMatch(v.BaseUrl, @"(?:/|t\.)rss\?.+$")); } }