mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-04-24 05:47:22 -04:00
Fixed: (AlphaRatio) Use FL tokens only if canUseToken
is true
Fixes #1811
This commit is contained in:
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")]
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue