diff --git a/src/NzbDrone.Core/Indexers/Definitions/AlphaRatio.cs b/src/NzbDrone.Core/Indexers/Definitions/AlphaRatio.cs index ef9d70139..aa8d6d9b4 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/AlphaRatio.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/AlphaRatio.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using NLog; +using NzbDrone.Common.Http; using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers.Definitions.Gazelle; @@ -29,6 +30,11 @@ public class AlphaRatio : GazelleBase return new AlphaRatioRequestGenerator(Settings, Capabilities, _httpClient, _logger); } + public override IParseIndexerResponse GetParser() + { + return new AlphaRatioParser(Settings, Capabilities); + } + protected override IndexerCapabilities SetCapabilities() { var caps = new IndexerCapabilities @@ -110,6 +116,29 @@ public class AlphaRatioRequestGenerator : GazelleRequestGenerator } } +public class AlphaRatioParser : GazelleParser +{ + public AlphaRatioParser(AlphaRatioSettings settings, IndexerCapabilities capabilities) + : base(settings, capabilities) + { + } + + protected override string GetDownloadUrl(int torrentId, bool canUseToken) + { + var url = new HttpUri(Settings.BaseUrl) + .CombinePath("/torrents.php") + .AddQueryParam("action", "download") + .AddQueryParam("id", torrentId); + + if (Settings.UseFreeleechToken && canUseToken) + { + url = url.AddQueryParam("usetoken", "1"); + } + + return url.FullUri; + } +} + public class AlphaRatioSettings : GazelleSettings { [FieldDefinition(6, Label = "Freeleech Only", Type = FieldType.Checkbox, HelpText = "Search freeleech torrents only")] diff --git a/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleParser.cs index fab9ee8d2..cd6b08ada 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleParser.cs @@ -78,7 +78,7 @@ public class GazelleParser : IParseIndexerResponse Grabs = torrent.Snatches, Codec = torrent.Format, Size = long.Parse(torrent.Size), - DownloadUrl = GetDownloadUrl(id), + DownloadUrl = GetDownloadUrl(id, torrent.CanUseToken), InfoUrl = infoUrl, Seeders = int.Parse(torrent.Seeders), Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), @@ -113,7 +113,7 @@ public class GazelleParser : IParseIndexerResponse Guid = infoUrl, Title = groupName, Size = long.Parse(result.Size), - DownloadUrl = GetDownloadUrl(id), + DownloadUrl = GetDownloadUrl(id, result.CanUseToken), InfoUrl = infoUrl, Seeders = int.Parse(result.Seeders), Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders), @@ -146,7 +146,7 @@ public class GazelleParser : IParseIndexerResponse .ToArray(); } - protected virtual string GetDownloadUrl(int torrentId) + protected virtual string GetDownloadUrl(int torrentId, bool canUseToken) { var url = new HttpUri(Settings.BaseUrl) .CombinePath("/torrents.php") diff --git a/src/NzbDrone.Core/Indexers/Definitions/GreatPosterWall.cs b/src/NzbDrone.Core/Indexers/Definitions/GreatPosterWall.cs index ace0e0829..744dbf642 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/GreatPosterWall.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/GreatPosterWall.cs @@ -227,7 +227,7 @@ public class GreatPosterWallParser : GazelleParser .ToArray(); } - private string GetDownloadUrl(int torrentId, bool canUseToken) + protected override string GetDownloadUrl(int torrentId, bool canUseToken) { var url = new HttpUri(_settings.BaseUrl) .CombinePath("/torrents.php")