Fixed: (AlphaRatio) Use FL tokens only if canUseToken is true

Fixes #1811
This commit is contained in:
Bogdan
2023-08-04 17:20:28 +03:00
parent 141f1597dc
commit 6961c5a1c6
3 changed files with 33 additions and 4 deletions
@@ -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<AlphaRatioSettings>
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")]