diff --git a/src/NzbDrone.Core.Test/Files/Indexers/Torznab/torznab_morethantv.xml b/src/NzbDrone.Core.Test/Files/Indexers/Torznab/torznab_morethantv.xml new file mode 100644 index 000000000..2722c7aee --- /dev/null +++ b/src/NzbDrone.Core.Test/Files/Indexers/Torznab/torznab_morethantv.xml @@ -0,0 +1,55 @@ + + + + + Out of the Past 1947 720p BluRay FLAC2.0 x264-CtrlHD.mkv + https://www.morethantv.me/torrents.php?id=(removed)&torrentid=836164 + https://www.morethantv.me/torrents.php?action=download&id=(removed)&authkey=(removed)&torrent_pass=(removed) + https://www.morethantv.me/torrents.php?id=(removed)&torrentid=836164 + Tue, 20 Dec 2022 21:32:17 +0000 + 5412993028 + 1 + 2 + 2000 + 2040 + A private eye escapes his past to run a gas station in a small town, but his past catches up with him. Now he must return to the big city world of danger, corruption, double crosses, and duplicitous dames. + + + + + + + + + + + + + + + Out of the Past 1947 1080p USA Blu-ray AVC DTS-HD MA 2.0-PCH + https://www.morethantv.me/torrents.php?id=(removed)&torrentid=836165 + https://www.morethantv.me/torrents.php?action=download&id=(removed)&authkey=(removed)&torrent_pass=(removed) + https://www.morethantv.me/torrents.php?id=(removed)&torrentid=836165 + Tue, 20 Dec 2022 21:47:40 +0000 + 30524085127 + 78 + 0 + 2000 + 2040 + A private eye escapes his past to run a gas station in a small town, but his past catches up with him. Now he must return to the big city world of danger, corruption, double crosses, and duplicitous dames. + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs index 2c96236fc..9018763a7 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs @@ -34,6 +34,10 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests }; _caps = new IndexerCapabilities(); + + _caps.Categories.AddCategoryMapping(2000, NewznabStandardCategory.Movies, "Movies"); + _caps.Categories.AddCategoryMapping(2040, NewznabStandardCategory.MoviesHD, "Movies/HD"); + Mocker.GetMock() .Setup(v => v.GetCapabilities(It.IsAny(), It.IsAny())) .Returns(_caps); @@ -129,6 +133,38 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests releaseInfo.Peers.Should().BeNull(); } + [Test] + public async Task should_parse_recent_feed_from_torznab_morethantv() + { + var recentFeed = ReadAllText(@"Files/Indexers/Torznab/torznab_morethantv.xml"); + + Mocker.GetMock() + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) + .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed))); + + var releases = (await Subject.Fetch(new MovieSearchCriteria())).Releases; + + releases.Should().HaveCount(2); + + releases.First().Should().BeOfType(); + var releaseInfo = releases.First() as TorrentInfo; + + releaseInfo.Title.Should().Be("Out of the Past 1947 720p BluRay FLAC2.0 x264-CtrlHD.mkv"); + releaseInfo.DownloadProtocol.Should().Be(DownloadProtocol.Torrent); + releaseInfo.DownloadUrl.Should().Be("https://www.morethantv.me/torrents.php?action=download&id=(removed)&authkey=(removed)&torrent_pass=(removed)"); + releaseInfo.InfoUrl.Should().Be("https://www.morethantv.me/torrents.php?id=(removed)&torrentid=836164"); + releaseInfo.CommentUrl.Should().Be("https://www.morethantv.me/torrents.php?id=(removed)&torrentid=836164"); + releaseInfo.Indexer.Should().Be(Subject.Definition.Name); + releaseInfo.PublishDate.Should().Be(DateTime.Parse("Tue, 20 Dec 2022 21:32:17 +0000").ToUniversalTime()); + releaseInfo.Size.Should().Be(5412993028); + releaseInfo.TvdbId.Should().Be(0); + releaseInfo.TvRageId.Should().Be(0); + releaseInfo.InfoHash.Should().Be("(removed)"); + releaseInfo.Seeders.Should().Be(3); + releaseInfo.Peers.Should().Be(3); + releaseInfo.Categories.Count().Should().Be(4); + } + [Test] public void should_use_pagesize_reported_by_caps() { diff --git a/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabRssParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabRssParser.cs index 665b2c75d..5f8eb652e 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabRssParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabRssParser.cs @@ -127,6 +127,12 @@ namespace NzbDrone.Core.Indexers.Newznab var cats = TryGetMultipleNewznabAttributes(item, "category"); var results = new List(); + // Try to find elements for some indexers that suck at following the rules. + if (results.Count == 0) + { + cats = item.Elements("category").Select(e => e.Value).ToList(); + } + foreach (var cat in cats) { var indexerCat = capabilities.Categories.MapTrackerCatToNewznab(cat); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Torznab/TorznabRssParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Torznab/TorznabRssParser.cs index 46fa0e92a..0e2dc6cb1 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Torznab/TorznabRssParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Torznab/TorznabRssParser.cs @@ -165,9 +165,15 @@ namespace NzbDrone.Core.Indexers.Torznab protected override ICollection GetCategory(XElement item) { var capabilities = _capabilitiesProvider.GetCapabilities(_settings, _definition); - var cats = TryGetMultipleNewznabAttributes(item, "category"); + var cats = TryGetMultipleTorznabAttributes(item, "category"); var results = new List(); + // Try to find elements for some indexers that suck at following the rules. + if (results.Count == 0) + { + cats = item.Elements("category").Select(e => e.Value).ToList(); + } + foreach (var cat in cats) { var indexerCat = capabilities.Categories.MapTrackerCatToNewznab(cat); @@ -265,7 +271,7 @@ namespace NzbDrone.Core.Indexers.Torznab return defaultValue; } - protected List TryGetMultipleNewznabAttributes(XElement item, string key) + protected List TryGetMultipleTorznabAttributes(XElement item, string key) { var attrElements = item.Elements(ns + "attr").Where(e => e.Attribute("name").Value.Equals(key, StringComparison.OrdinalIgnoreCase)); var results = new List();