From 17f6841426e81b912b309ba59534ac27a371f6d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Dahlgren?= Date: Sat, 3 Sep 2016 11:18:19 +0200 Subject: [PATCH] Fixed: Updated HDBits api to api changes. Closes #1448 --- ...RecentFeed.json => RecentFeedLongIDs.json} | 0 .../Indexers/HdBits/RecentFeedStringIDs.json | 57 +++++++++++++++++++ .../IndexerTests/HDBitsTests/HDBitsFixture.cs | 7 ++- .../NzbDrone.Core.Test.csproj | 5 +- .../Indexers/HDBits/HDBitsApi.cs | 4 +- .../Indexers/HDBits/HDBitsParser.cs | 8 +-- 6 files changed, 70 insertions(+), 11 deletions(-) rename src/NzbDrone.Core.Test/Files/Indexers/HdBits/{RecentFeed.json => RecentFeedLongIDs.json} (100%) create mode 100644 src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedStringIDs.json diff --git a/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeed.json b/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedLongIDs.json similarity index 100% rename from src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeed.json rename to src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedLongIDs.json diff --git a/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedStringIDs.json b/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedStringIDs.json new file mode 100644 index 000000000..2c533f5c4 --- /dev/null +++ b/src/NzbDrone.Core.Test/Files/Indexers/HdBits/RecentFeedStringIDs.json @@ -0,0 +1,57 @@ +{ + "status": 0, + "data": [ + { + "id": "257142", + "hash": "EABC50AEF9F53CEDED84ADF14144D3368E586F3A", + "leechers": 1, + "seeders": 46, + "name": "Supernatural S10E17 1080p WEB-DL DD5.1 H.264-ECI", + "times_completed": 49, + "size": 1718009717, + "utadded": 1428179446, + "added": "2015-04-04T20:30:46+0000", + "comments": 0, + "numfiles": 1, + "filename": "Supernatural.S10E17.1080p.WEB-DL.DD5.1.H.264-ECI.torrent", + "freeleech": "no", + "type_category": 2, + "type_codec": 1, + "type_medium": 6, + "type_origin": 0, + "username": "abc", + "owner": 1107944, + "tvdb": { + "id": 78901, + "season": 10, + "episode": 17 + } + }, + { + "id": "257140", + "hash": "BE3BA5396B9A30544353B55FDD89EDE46C8FB72A", + "leechers": 0, + "seeders": 18, + "name": "Scandal S04E18 1080p WEB-DL DD5.1 H.264-ECI", + "times_completed": 19, + "size": 1789106197, + "utadded": 1428179128, + "added": "2015-04-04T20:25:28+0000", + "comments": 0, + "numfiles": 1, + "filename": "Scandal.2012.S04E18.1080p.WEB-DL.DD5.1.H.264-ECI.torrent", + "freeleech": "no", + "type_category": 2, + "type_codec": 1, + "type_medium": 6, + "type_origin": 0, + "username": "abc", + "owner": 1107944, + "tvdb": { + "id": 248841, + "season": 4, + "episode": 18 + } + } + ] +} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs index 57511f449..833a2a437 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs @@ -27,10 +27,11 @@ namespace NzbDrone.Core.Test.IndexerTests.HDBitsTests }; } - [Test] - public void should_parse_recent_feed_from_HDBits() + [TestCase("Files/Indexers/HdBits/RecentFeedLongIDs.json")] + [TestCase("Files/Indexers/HdBits/RecentFeedStringIDs.json")] + public void should_parse_recent_feed_from_HDBits(string fileName) { - var responseJson = ReadAllText(@"Files/Indexers/HdBits/RecentFeed.json"); + var responseJson = ReadAllText(fileName); Mocker.GetMock() .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.POST))) diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 26ae602a3..2b065a4c3 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -373,6 +373,9 @@ + + Always + @@ -408,7 +411,7 @@ Always - + Always diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsApi.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsApi.cs index d88bf39a7..9bb6d624b 100644 --- a/src/NzbDrone.Core/Indexers/HDBits/HDBitsApi.cs +++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsApi.cs @@ -10,8 +10,6 @@ namespace NzbDrone.Core.Indexers.HDBits [JsonProperty(Required = Required.Always)] public string Passkey { get; set; } - public int? Id { get; set; } - public string Hash { get; set; } public string Search { get; set; } @@ -54,7 +52,7 @@ namespace NzbDrone.Core.Indexers.HDBits public class TorrentQueryResponse { - public long Id { get; set; } + public string Id { get; set; } public string Hash { get; set; } public int Leechers { get; set; } public int Seeders { get; set; } diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs index 9f3c5fd9a..bc06f9553 100644 --- a/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs +++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs @@ -70,21 +70,21 @@ namespace NzbDrone.Core.Indexers.HDBits return torrentInfos.ToArray(); } - private string GetDownloadUrl(long torrentId) + private string GetDownloadUrl(string torrentId) { var url = new HttpUri(_settings.BaseUrl) .CombinePath("/download.php") - .AddQueryParam("id", torrentId.ToString()) + .AddQueryParam("id", torrentId) .AddQueryParam("passkey", _settings.ApiKey); return url.FullUri; } - private string GetInfoUrl(long torrentId) + private string GetInfoUrl(string torrentId) { var url = new HttpUri(_settings.BaseUrl) .CombinePath("/details.php") - .AddQueryParam("id", torrentId.ToString()); + .AddQueryParam("id", torrentId); return url.FullUri;