From 65f1dbde00766376469e8fc2dd749f2bd435eb66 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 19 Apr 2015 13:13:14 -0700 Subject: [PATCH] Fixed: Torznab parsing when enclosure is magent link --- .../Files/RSS/torznab_tpb.xml | 97 +++++++++++++++++++ .../TorznabTests/TorznabFixture.cs | 30 ++++++ .../NzbDrone.Core.Test.csproj | 3 + .../Indexers/Torznab/TorznabRssParser.cs | 2 +- 4 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 src/NzbDrone.Core.Test/Files/RSS/torznab_tpb.xml diff --git a/src/NzbDrone.Core.Test/Files/RSS/torznab_tpb.xml b/src/NzbDrone.Core.Test/Files/RSS/torznab_tpb.xml new file mode 100644 index 000000000..67b39cf5e --- /dev/null +++ b/src/NzbDrone.Core.Test/Files/RSS/torznab_tpb.xml @@ -0,0 +1,97 @@ + + + + + The Pirate Bay + The worlds largest bittorrent indexer + https://thepiratebay.se/ + en-us + search + + http://localhost:9117/logos/thepiratebay.png + The Pirate Bay + https://thepiratebay.se/ + The Pirate Bay + + + Game of Thrones S05E02 HDTV x264-Xclusive [eztv] + https://thepiratebay.se/torrent/11811366/Game_of_Thrones_S05E02_HDTV_x264-Xclusive_[eztv] + https://thepiratebay.se/torrent/11811366/Game_of_Thrones_S05E02_HDTV_x264-Xclusive_[eztv] + Sat, 11 Apr 2015 21:34:00 -0600 + 388895872 + Game of Thrones S05E02 HDTV x264-Xclusive [eztv] + magnet:?xt=urn:btih:9fb267cff5ae5603f07a347676ec3bf3e35f75e1&dn=Game+of+Thrones+S05E02+HDTV+x264-Xclusive+[eztv]&tr=udp:%2F%2Fopen.demonii.com:1337&tr=udp:%2F%2Ftracker.coppersurfer.tk:6969&tr=udp:%2F%2Ftracker.leechers-paradise.org:6969&tr=udp:%2F%2Fexodus.desync.com:6969 + + + + + + + + + + Game of Thrones S05E03 WEBRip XviD-FUM[ettv] + https://thepiratebay.se/torrent/11811373/Game_of_Thrones_S05E03_WEBRip_XviD-FUM[ettv] + https://thepiratebay.se/torrent/11811373/Game_of_Thrones_S05E03_WEBRip_XviD-FUM[ettv] + Sat, 11 Apr 2015 21:42:00 -0600 + 471722880 + Game of Thrones S05E03 WEBRip XviD-FUM[ettv] + magnet:?xt=urn:btih:c1f9f6bade11a4c46028b118053452460ab94be1&dn=Game+of+Thrones+S05E03+WEBRip+XviD-FUM[ettv]&tr=udp:%2F%2Fopen.demonii.com:1337&tr=udp:%2F%2Ftracker.coppersurfer.tk:6969&tr=udp:%2F%2Ftracker.leechers-paradise.org:6969&tr=udp:%2F%2Fexodus.desync.com:6969 + + + + + + + + + + Game Of Thrones S05E01 HDTV x264-Xclusive + https://thepiratebay.se/torrent/11811268/Game_Of_Thrones_S05E01_HDTV_x264-Xclusive + https://thepiratebay.se/torrent/11811268/Game_Of_Thrones_S05E01_HDTV_x264-Xclusive + Sat, 11 Apr 2015 18:14:00 -0600 + 312339328 + Game Of Thrones S05E01 HDTV x264-Xclusive + magnet:?xt=urn:btih:fd8b1062af0d8c2426cb4d180b86815ffa91b479&dn=Game+Of+Thrones+S05E01+HDTV+x264-Xclusive&tr=udp:%2F%2Fopen.demonii.com:1337&tr=udp:%2F%2Ftracker.coppersurfer.tk:6969&tr=udp:%2F%2Ftracker.leechers-paradise.org:6969&tr=udp:%2F%2Fexodus.desync.com:6969 + + + + + + + + + + Game of Thrones S05E04 WEBRip XviD-FUM[ettv] + https://thepiratebay.se/torrent/11811448/Game_of_Thrones_S05E04_WEBRip_XviD-FUM[ettv] + https://thepiratebay.se/torrent/11811448/Game_of_Thrones_S05E04_WEBRip_XviD-FUM[ettv] + Sat, 11 Apr 2015 23:10:00 -0600 + 442970944 + Game of Thrones S05E04 WEBRip XviD-FUM[ettv] + magnet:?xt=urn:btih:30abe6b5816c758d327672a0fa58ff2b055ad3fe&dn=Game+of+Thrones+S05E04+WEBRip+XviD-FUM[ettv]&tr=udp:%2F%2Fopen.demonii.com:1337&tr=udp:%2F%2Ftracker.coppersurfer.tk:6969&tr=udp:%2F%2Ftracker.leechers-paradise.org:6969&tr=udp:%2F%2Fexodus.desync.com:6969 + + + + + + + + + + Arrow.S03E19.HDTV.x264-LOL[ettv] + https://thepiratebay.se/torrent/11817918/Arrow.S03E19.HDTV.x264-LOL[ettv] + https://thepiratebay.se/torrent/11817918/Arrow.S03E19.HDTV.x264-LOL[ettv] + Wed, 15 Apr 2015 18:58:00 -0600 + 243951200 + Arrow.S03E19.HDTV.x264-LOL[ettv] + magnet:?xt=urn:btih:53896c2a6391a69a672041139e023c018c0f4aff&dn=Arrow.S03E19.HDTV.x264-LOL[ettv]&tr=udp:%2F%2Fopen.demonii.com:1337&tr=udp:%2F%2Ftracker.coppersurfer.tk:6969&tr=udp:%2F%2Ftracker.leechers-paradise.org:6969&tr=udp:%2F%2Fexodus.desync.com:6969 + + + + + + + + + + \ 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 d4b456d16..079ed30f9 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs @@ -57,5 +57,35 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests releaseInfo.Seeders.Should().Be(7); releaseInfo.Peers.Should().Be(7); } + + [Test] + public void should_parse_recent_feed_from_torznab_tpb() + { + var recentFeed = ReadAllText(@"Files/RSS/torznab_tpb.xml"); + + Mocker.GetMock() + .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) + .Returns(r => new HttpResponse(r, new HttpHeader(), recentFeed)); + + var releases = Subject.FetchRecent(); + + releases.Should().HaveCount(5); + + releases.First().Should().BeOfType(); + var releaseInfo = releases.First() as TorrentInfo; + + releaseInfo.Title.Should().Be("Game of Thrones S05E02 HDTV x264-Xclusive [eztv]"); + releaseInfo.DownloadProtocol.Should().Be(DownloadProtocol.Torrent); + releaseInfo.MagnetUrl.Should().Be("magnet:?xt=urn:btih:9fb267cff5ae5603f07a347676ec3bf3e35f75e1&dn=Game+of+Thrones+S05E02+HDTV+x264-Xclusive+[eztv]&tr=udp:%2F%2Fopen.demonii.com:1337&tr=udp:%2F%2Ftracker.coppersurfer.tk:6969&tr=udp:%2F%2Ftracker.leechers-paradise.org:6969&tr=udp:%2F%2Fexodus.desync.com:6969"); + releaseInfo.DownloadUrl.Should().Be("magnet:?xt=urn:btih:9fb267cff5ae5603f07a347676ec3bf3e35f75e1&dn=Game+of+Thrones+S05E02+HDTV+x264-Xclusive+[eztv]&tr=udp:%2F%2Fopen.demonii.com:1337&tr=udp:%2F%2Ftracker.coppersurfer.tk:6969&tr=udp:%2F%2Ftracker.leechers-paradise.org:6969&tr=udp:%2F%2Fexodus.desync.com:6969"); + releaseInfo.InfoUrl.Should().Be("https://thepiratebay.se/torrent/11811366/Game_of_Thrones_S05E02_HDTV_x264-Xclusive_[eztv]"); + releaseInfo.CommentUrl.Should().Be("https://thepiratebay.se/torrent/11811366/Game_of_Thrones_S05E02_HDTV_x264-Xclusive_[eztv]"); + releaseInfo.Indexer.Should().Be(Subject.Definition.Name); + releaseInfo.PublishDate.Should().Be(DateTime.Parse("Sat, 11 Apr 2015 21:34:00 -0600").ToUniversalTime()); + releaseInfo.Size.Should().Be(388895872); + releaseInfo.InfoHash.Should().Be("9fb267cff5ae5603f07a347676ec3bf3e35f75e1"); + releaseInfo.Seeders.Should().Be(34128); + releaseInfo.Peers.Should().Be(36724); + } } } diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 3efcec4c5..476dcd639 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -448,6 +448,9 @@ Always + + Always + Always Designer diff --git a/src/NzbDrone.Core/Indexers/Torznab/TorznabRssParser.cs b/src/NzbDrone.Core/Indexers/Torznab/TorznabRssParser.cs index 0badab6f2..60a861c6c 100644 --- a/src/NzbDrone.Core/Indexers/Torznab/TorznabRssParser.cs +++ b/src/NzbDrone.Core/Indexers/Torznab/TorznabRssParser.cs @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Indexers.Torznab protected override ReleaseInfo PostProcess(XElement item, ReleaseInfo releaseInfo) { var enclosureType = item.Element("enclosure").Attribute("type").Value; - if (enclosureType != "application/x-bittorrent") + if (!enclosureType.Contains("application/x-bittorrent")) { throw new UnsupportedFeedException("Feed contains {0} instead of application/x-bittorrent", enclosureType); }