From 710b4f5ec68b5d69a227c93eb9597b3d0ca6b180 Mon Sep 17 00:00:00 2001 From: Qstick Date: Wed, 18 Nov 2020 16:46:24 -0500 Subject: [PATCH] Remove FetchRecent, Pass Cats back on Newznab Search --- .../FileListTests/FileListFixture.cs | 3 +- .../FileListRequestGeneratorFixture.cs | 2 +- .../IndexerTests/HDBitsTests/HDBitsFixture.cs | 7 +- .../IPTorrentsTests/IPTorrentsFixture.cs | 3 +- .../NewznabTests/NewznabFixture.cs | 3 +- .../IndexerTests/NyaaTests/NyaaFixture.cs | 5 +- .../IndexerTests/PTPTests/PTPFixture.cs | 5 +- .../IndexerTests/RarbgTests/RarbgFixture.cs | 9 ++- .../TorrentRssIndexerFixture.cs | 25 +++--- .../TorznabTests/TorznabFixture.cs | 7 +- .../Datastore/Migration/001_initial_setup.cs | 3 +- .../IndexerSearch/NewznabResults.cs | 1 + .../Definitions/Cardigann/CardigannBase.cs | 12 ++- .../Definitions/Cardigann/CardigannParser.cs | 6 +- .../Cardigann/CardigannRequestGenerator.cs | 7 ++ .../FileList/FileListRequestGenerator.cs | 13 ++-- .../Indexers/FetchAndParseRssService.cs | 77 ------------------- src/NzbDrone.Core/Indexers/HttpIndexerBase.cs | 14 +--- src/NzbDrone.Core/Indexers/IIndexer.cs | 1 - .../Indexers/IIndexerRequestGenerator.cs | 1 - src/NzbDrone.Core/Indexers/IndexerBase.cs | 1 - src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs | 2 + 22 files changed, 70 insertions(+), 137 deletions(-) delete mode 100644 src/NzbDrone.Core/Indexers/FetchAndParseRssService.cs diff --git a/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs index 2fd076e92..60d73fbd4 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs @@ -6,6 +6,7 @@ using NUnit.Framework; using NzbDrone.Common.Http; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.FileList; +using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -33,7 +34,7 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) .Returns(r => new HttpResponse(r, new HttpHeader(), recentFeed)); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(4); releases.First().Should().BeOfType(); diff --git a/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListRequestGeneratorFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListRequestGeneratorFixture.cs index c9b079ee4..738329e2d 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListRequestGeneratorFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListRequestGeneratorFixture.cs @@ -37,7 +37,7 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests [Test] public void should_use_categories_for_feed() { - var results = Subject.GetRecentRequests(); + var results = Subject.GetSearchRequests(new MovieSearchCriteria()); results.GetAllTiers().Should().HaveCount(1); diff --git a/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs index 99c716cb8..7d2a794c3 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Text; using FluentAssertions; @@ -8,6 +8,7 @@ using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.HDBits; +using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -37,7 +38,7 @@ namespace NzbDrone.Core.Test.IndexerTests.HDBitsTests .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.POST))) .Returns(r => new HttpResponse(r, new HttpHeader(), responseJson)); - var torrents = Subject.FetchRecent(); + var torrents = Subject.Fetch(new MovieSearchCriteria()); torrents.Should().HaveCount(2); torrents.First().Should().BeOfType(); @@ -66,7 +67,7 @@ namespace NzbDrone.Core.Test.IndexerTests.HDBitsTests .Setup(v => v.Execute(It.IsAny())) .Returns(r => new HttpResponse(r, new HttpHeader(), Encoding.UTF8.GetBytes(responseJson))); - var torrents = Subject.FetchRecent(); + var torrents = Subject.Fetch(new MovieSearchCriteria()); torrents.Should().BeEmpty(); diff --git a/src/NzbDrone.Core.Test/IndexerTests/IPTorrentsTests/IPTorrentsFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/IPTorrentsTests/IPTorrentsFixture.cs index cabc82040..cdda95731 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/IPTorrentsTests/IPTorrentsFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/IPTorrentsTests/IPTorrentsFixture.cs @@ -6,6 +6,7 @@ using NUnit.Framework; using NzbDrone.Common.Http; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.IPTorrents; +using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -91,7 +92,7 @@ namespace NzbDrone.Core.Test.IndexerTests.IPTorrentsTests .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) .Returns(r => new HttpResponse(r, new HttpHeader(), recentFeed)); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(5); releases.First().Should().BeOfType(); diff --git a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs index fb347d215..2ef5f3e81 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs @@ -6,6 +6,7 @@ using NUnit.Framework; using NzbDrone.Common.Http; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.Newznab; +using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.IndexerTests.NewznabTests @@ -43,7 +44,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) .Returns(r => new HttpResponse(r, new HttpHeader(), recentFeed)); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(100); diff --git a/src/NzbDrone.Core.Test/IndexerTests/NyaaTests/NyaaFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/NyaaTests/NyaaFixture.cs index 494e21780..ee777fc9b 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/NyaaTests/NyaaFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/NyaaTests/NyaaFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using FluentAssertions; using Moq; @@ -6,6 +6,7 @@ using NUnit.Framework; using NzbDrone.Common.Http; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.Nyaa; +using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -33,7 +34,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NyaaTests .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) .Returns(r => new HttpResponse(r, new HttpHeader(), recentFeed)); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(4); releases.First().Should().BeOfType(); diff --git a/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs index 707f0f2a7..3e5345e7f 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using FluentAssertions; using Moq; using NUnit.Framework; @@ -6,6 +6,7 @@ using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.PassThePopcorn; +using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -41,7 +42,7 @@ namespace NzbDrone.Core.Test.IndexerTests.PTPTests .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) .Returns(r => new HttpResponse(r, new HttpHeader { ContentType = HttpAccept.Json.Value }, responseJson)); - var torrents = Subject.FetchRecent(); + var torrents = Subject.Fetch(new MovieSearchCriteria()); torrents.Should().HaveCount(293); torrents.First().Should().BeOfType(); diff --git a/src/NzbDrone.Core.Test/IndexerTests/RarbgTests/RarbgFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/RarbgTests/RarbgFixture.cs index c38bfbbb6..8b1f93c09 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/RarbgTests/RarbgFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/RarbgTests/RarbgFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using FluentAssertions; using Moq; @@ -6,6 +6,7 @@ using NUnit.Framework; using NzbDrone.Common.Http; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.Rarbg; +using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -38,7 +39,7 @@ namespace NzbDrone.Core.Test.IndexerTests.RarbgTests .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) .Returns(r => new HttpResponse(r, new HttpHeader(), recentFeed)); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(4); releases.First().Should().BeOfType(); @@ -65,7 +66,7 @@ namespace NzbDrone.Core.Test.IndexerTests.RarbgTests .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) .Returns(r => new HttpResponse(r, new HttpHeader(), "{ error_code: 20, error: \"some message\" }")); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(0); } @@ -77,7 +78,7 @@ namespace NzbDrone.Core.Test.IndexerTests.RarbgTests .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) .Returns(r => new HttpResponse(r, new HttpHeader(), "{ error_code: 25, error: \"some message\" }")); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(0); diff --git a/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssIndexerFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssIndexerFixture.cs index 23131d280..240dad580 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssIndexerFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssIndexerFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using FluentAssertions; using Moq; @@ -6,6 +6,7 @@ using NUnit.Framework; using NzbDrone.Common.Http; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.TorrentRss; +using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -44,7 +45,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests { GivenRecentFeedResponse("TorrentRss/ImmortalSeed.xml"); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(50); releases.First().Should().BeOfType(); @@ -70,7 +71,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests { GivenRecentFeedResponse("TorrentRss/Ezrss.xml"); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(3); releases.First().Should().BeOfType(); @@ -98,7 +99,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests GivenRecentFeedResponse("TorrentRss/ShowRSS.info.xml"); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(5); releases.First().Should().BeOfType(); @@ -126,7 +127,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests GivenRecentFeedResponse("TorrentRss/Doki.xml"); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(5); releases.First().Should().BeOfType(); @@ -152,7 +153,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests { GivenRecentFeedResponse("TorrentRss/ExtraTorrents.xml"); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(5); releases.First().Should().BeOfType(); @@ -178,7 +179,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests { GivenRecentFeedResponse("TorrentRss/LimeTorrents.xml"); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(5); releases.First().Should().BeOfType(); @@ -204,7 +205,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests { GivenRecentFeedResponse("TorrentRss/AnimeTosho_NoSize.xml"); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(2); releases.First().Should().BeOfType(); @@ -230,7 +231,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests { GivenRecentFeedResponse("TorrentRss/AnimeTosho_NoSize.xml"); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(2); releases.Last().Should().BeOfType(); @@ -247,7 +248,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests { GivenRecentFeedResponse("TorrentRss/AlphaRatio.xml"); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(2); releases.Last().Should().BeOfType(); @@ -265,7 +266,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests Subject.Definition.Settings.As().AllowZeroSize = true; GivenRecentFeedResponse("TorrentRss/EvolutionWorld.xml"); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(2); releases.First().Should().BeOfType(); @@ -291,7 +292,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests { GivenRecentFeedResponse("TorrentRss/invalid/TorrentDay_NoPubDate.xml"); - Subject.FetchRecent().Should().BeEmpty(); + Subject.Fetch(new MovieSearchCriteria()).Should().BeEmpty(); Mocker.GetMock() .Verify(v => v.RecordFailure(It.IsAny(), TimeSpan.Zero), Times.Once()); diff --git a/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs index 5e9160965..a6e1ec1cb 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs @@ -7,6 +7,7 @@ using NzbDrone.Common.Http; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.Newznab; using NzbDrone.Core.Indexers.Torznab; +using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; @@ -44,7 +45,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) .Returns(r => new HttpResponse(r, new HttpHeader(), recentFeed)); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(5); @@ -73,7 +74,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) .Returns(r => new HttpResponse(r, new HttpHeader(), recentFeed)); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(5); @@ -103,7 +104,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) .Returns(r => new HttpResponse(r, new HttpHeader(), recentFeed)); - var releases = Subject.FetchRecent(); + var releases = Subject.Fetch(new MovieSearchCriteria()); releases.Should().HaveCount(2); diff --git a/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs b/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs index 3c83367b0..d84c9170c 100644 --- a/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs +++ b/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs @@ -87,7 +87,8 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("EscalationLevel").AsInt32().NotNullable() .WithColumn("DisabledTill").AsDateTime().Nullable() .WithColumn("LastRssSyncReleaseInfo").AsString().Nullable() - .WithColumn("Cookies").AsString().WithDefaultValue("{}"); + .WithColumn("Cookies").AsString().Nullable() + .WithColumn("CookiesExpirationDate").AsDateTime().Nullable(); Create.TableForModel("CustomFilters") .WithColumn("Type").AsString().NotNullable() diff --git a/src/NzbDrone.Core/IndexerSearch/NewznabResults.cs b/src/NzbDrone.Core/IndexerSearch/NewznabResults.cs index 58493d90d..a7a465b4e 100644 --- a/src/NzbDrone.Core/IndexerSearch/NewznabResults.cs +++ b/src/NzbDrone.Core/IndexerSearch/NewznabResults.cs @@ -72,6 +72,7 @@ namespace NzbDrone.Core.IndexerSearch new XElement("guid", r.Guid), // GUID and (Link or Magnet) are mandatory new XElement("prowlarrindexer", new XAttribute("id", r.IndexerId), r.Indexer), r.PublishDate == DateTime.MinValue ? new XElement("pubDate", XmlDateFormat(DateTime.Now)) : new XElement("pubDate", XmlDateFormat(r.PublishDate)), + r.Category == null ? null : from c in r.Category select new XElement("category", c), new XElement("size", r.Size), new XElement( "enclosure", diff --git a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannBase.cs b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannBase.cs index 454f2fddb..c30cd5b7e 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannBase.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannBase.cs @@ -186,13 +186,14 @@ namespace NzbDrone.Core.Indexers.Cardigann return variables; } - /* protected ICollection MapTrackerCatToNewznab(string input) { if (input == null) + { return new List(); + } - var cats = categoryMapping.Where(m => m.TrackerCategory != null && m.TrackerCategory.ToLowerInvariant() == input.ToLowerInvariant()).Select(c => c.NewzNabCategory).ToList(); + var cats = _definition.Caps.Categorymappings.Where(m => m.id != null && m.id.ToLowerInvariant() == input.ToLowerInvariant()).Select(c => TorznabCatType.GetCatByName(c.cat).Id).ToList(); // 1:1 category mapping try @@ -206,12 +207,17 @@ namespace NzbDrone.Core.Indexers.Cardigann } return cats; - }*/ + } public List MapTorznabCapsToTrackers(int[] searchCategories, bool mapChildrenCatsToParent = false) { var queryCats = new List(); + if (searchCategories == null) + { + return queryCats; + } + foreach (var searchCat in searchCategories) { var match = TorznabCatType.AllCats.FirstOrDefault(c => c.Id == searchCat); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs index fd023c0d2..c06192816 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs @@ -199,8 +199,7 @@ namespace NzbDrone.Core.Indexers.Cardigann value = release.Description; break; case "category": - // var cats = MapTrackerCatToNewznab(value); - var cats = new List { 2000 }; + var cats = MapTrackerCatToNewznab(value); if (cats.Any()) { if (release.Category == null || fieldModifiers.Contains("noappend")) @@ -482,7 +481,8 @@ namespace NzbDrone.Core.Indexers.Cardigann MagnetUrl = x.MagnetUri?.ToString(), InfoHash = x.InfoHash, Seeders = (int?)x.Seeders, - Peers = (int?)x.Peers + Peers = (int?)x.Peers, + Category = x.Category })); _logger.Debug($"Got {result.Count} releases"); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs index 5c28e2493..6638dee8a 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs @@ -30,6 +30,13 @@ namespace NzbDrone.Core.Indexers.Cardigann var variables = GetBaseTemplateVariables(); + variables[".Query.Type"] = null; + variables[".Query.Q"] = null; + variables[".Query.Categories"] = null; + variables[".Query.IMDBID"] = null; + variables[".Query.IMDBIDShort"] = null; + variables[".Query.TMDBID"] = null; + pageableRequests.Add(GetRequest(variables)); return pageableRequests; diff --git a/src/NzbDrone.Core/Indexers/Definitions/FileList/FileListRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/FileList/FileListRequestGenerator.cs index eeb76947a..ed84d22ba 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/FileList/FileListRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/FileList/FileListRequestGenerator.cs @@ -13,13 +13,6 @@ namespace NzbDrone.Core.Indexers.FileList public Func> GetCookies { get; set; } public Action, DateTime?> CookiesUpdater { get; set; } - public virtual IndexerPageableRequestChain GetRecentRequests() - { - var pageableRequests = new IndexerPageableRequestChain(); - pageableRequests.Add(GetRequest("latest-torrents", "")); - return pageableRequests; - } - public virtual IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); @@ -28,11 +21,15 @@ namespace NzbDrone.Core.Indexers.FileList { pageableRequests.Add(GetRequest("search-torrents", string.Format("&type=imdb&query={0}", searchCriteria.ImdbId))); } - else + else if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace()) { var titleYearSearchQuery = string.Format("{0}", searchCriteria.SearchTerm); pageableRequests.Add(GetRequest("search-torrents", string.Format("&type=name&query={0}", titleYearSearchQuery.Trim()))); } + else + { + pageableRequests.Add(GetRequest("latest-torrents", "")); + } return pageableRequests; } diff --git a/src/NzbDrone.Core/Indexers/FetchAndParseRssService.cs b/src/NzbDrone.Core/Indexers/FetchAndParseRssService.cs deleted file mode 100644 index 298d7f4fe..000000000 --- a/src/NzbDrone.Core/Indexers/FetchAndParseRssService.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using NLog; -using NzbDrone.Common.TPL; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.Indexers -{ - public interface IFetchAndParseRss - { - List Fetch(); - } - - public class FetchAndParseRssService : IFetchAndParseRss - { - private readonly IIndexerFactory _indexerFactory; - private readonly Logger _logger; - - public FetchAndParseRssService(IIndexerFactory indexerFactory, Logger logger) - { - _indexerFactory = indexerFactory; - _logger = logger; - } - - public List Fetch() - { - var result = new List(); - - var indexers = _indexerFactory.RssEnabled(); - - if (!indexers.Any()) - { - _logger.Warn("No available indexers. check your configuration."); - return result; - } - - _logger.Debug("Available indexers {0}", indexers.Count); - - var taskList = new List(); - var taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.None); - - foreach (var indexer in indexers) - { - var indexerLocal = indexer; - - var task = taskFactory.StartNew(() => - { - try - { - var indexerReports = indexerLocal.FetchRecent(); - - lock (result) - { - _logger.Debug("Found {0} from {1}", indexerReports.Count, indexer.Name); - - result.AddRange(indexerReports); - } - } - catch (Exception e) - { - _logger.Error(e, "Error during RSS Sync"); - } - }).LogExceptions(); - - taskList.Add(task); - } - - Task.WaitAll(taskList.ToArray()); - - _logger.Debug("Found {0} reports", result.Count); - - return result; - } - } -} diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index 8e56e9f8f..ddd27678b 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -39,16 +39,6 @@ namespace NzbDrone.Core.Indexers _httpClient = httpClient; } - public override IList FetchRecent() - { - if (!SupportsRss) - { - return new List(); - } - - return FetchReleases(g => g.GetRecentRequests(), true); - } - public override IList Fetch(MovieSearchCriteria searchCriteria) { if (!SupportsSearch) @@ -76,7 +66,7 @@ namespace NzbDrone.Core.Indexers return cookies; }; - var requests = searchCriteria == null ? generator.GetRecentRequests() : generator.GetSearchRequests(searchCriteria as MovieSearchCriteria); + var requests = generator.GetSearchRequests(searchCriteria as MovieSearchCriteria); generator.CookiesUpdater = (cookies, expiration) => { @@ -322,7 +312,7 @@ namespace NzbDrone.Core.Indexers _indexerStatusService.UpdateCookies(Definition.Id, cookies, expiration); }; var generator = GetRequestGenerator(); - var releases = FetchPage(generator.GetRecentRequests().GetAllTiers().First().First(), parser); + var releases = FetchPage(generator.GetSearchRequests(new MovieSearchCriteria()).GetAllTiers().First().First(), parser); if (releases.Empty()) { diff --git a/src/NzbDrone.Core/Indexers/IIndexer.cs b/src/NzbDrone.Core/Indexers/IIndexer.cs index a05e42362..a2e7e995b 100644 --- a/src/NzbDrone.Core/Indexers/IIndexer.cs +++ b/src/NzbDrone.Core/Indexers/IIndexer.cs @@ -14,7 +14,6 @@ namespace NzbDrone.Core.Indexers DownloadProtocol Protocol { get; } IndexerPrivacy Privacy { get; } - IList FetchRecent(); IList Fetch(MovieSearchCriteria searchCriteria); } } diff --git a/src/NzbDrone.Core/Indexers/IIndexerRequestGenerator.cs b/src/NzbDrone.Core/Indexers/IIndexerRequestGenerator.cs index ef32b2ab0..e80c54d39 100644 --- a/src/NzbDrone.Core/Indexers/IIndexerRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/IIndexerRequestGenerator.cs @@ -6,7 +6,6 @@ namespace NzbDrone.Core.Indexers { public interface IIndexerRequestGenerator { - IndexerPageableRequestChain GetRecentRequests(); IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria); Func> GetCookies { get; set; } Action, DateTime?> CookiesUpdater { get; set; } diff --git a/src/NzbDrone.Core/Indexers/IndexerBase.cs b/src/NzbDrone.Core/Indexers/IndexerBase.cs index 0059277ad..e04e638c2 100644 --- a/src/NzbDrone.Core/Indexers/IndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/IndexerBase.cs @@ -65,7 +65,6 @@ namespace NzbDrone.Core.Indexers protected TSettings Settings => (TSettings)Definition.Settings; - public abstract IList FetchRecent(); public abstract IList Fetch(MovieSearchCriteria searchCriteria); protected virtual IList CleanupReleases(IEnumerable releases) diff --git a/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs b/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs index 3f72c93e5..2ccf2336a 100644 --- a/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Text; using NzbDrone.Core.Indexers; @@ -27,6 +28,7 @@ namespace NzbDrone.Core.Parser.Model public string Container { get; set; } public string Codec { get; set; } public string Resolution { get; set; } + public ICollection Category { get; set; } public IndexerFlags IndexerFlags { get; set; }