mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Fixed: (AlphaRatio) Use FL tokens only if canUseToken
is true
Fixes #1811
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using NzbDrone.Common.Http;
|
||||||
using NzbDrone.Core.Annotations;
|
using NzbDrone.Core.Annotations;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Indexers.Definitions.Gazelle;
|
using NzbDrone.Core.Indexers.Definitions.Gazelle;
|
||||||
@@ -29,6 +30,11 @@ public class AlphaRatio : GazelleBase<AlphaRatioSettings>
|
|||||||
return new AlphaRatioRequestGenerator(Settings, Capabilities, _httpClient, _logger);
|
return new AlphaRatioRequestGenerator(Settings, Capabilities, _httpClient, _logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IParseIndexerResponse GetParser()
|
||||||
|
{
|
||||||
|
return new AlphaRatioParser(Settings, Capabilities);
|
||||||
|
}
|
||||||
|
|
||||||
protected override IndexerCapabilities SetCapabilities()
|
protected override IndexerCapabilities SetCapabilities()
|
||||||
{
|
{
|
||||||
var caps = new IndexerCapabilities
|
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
|
public class AlphaRatioSettings : GazelleSettings
|
||||||
{
|
{
|
||||||
[FieldDefinition(6, Label = "Freeleech Only", Type = FieldType.Checkbox, HelpText = "Search freeleech torrents only")]
|
[FieldDefinition(6, Label = "Freeleech Only", Type = FieldType.Checkbox, HelpText = "Search freeleech torrents only")]
|
||||||
|
@@ -78,7 +78,7 @@ public class GazelleParser : IParseIndexerResponse
|
|||||||
Grabs = torrent.Snatches,
|
Grabs = torrent.Snatches,
|
||||||
Codec = torrent.Format,
|
Codec = torrent.Format,
|
||||||
Size = long.Parse(torrent.Size),
|
Size = long.Parse(torrent.Size),
|
||||||
DownloadUrl = GetDownloadUrl(id),
|
DownloadUrl = GetDownloadUrl(id, torrent.CanUseToken),
|
||||||
InfoUrl = infoUrl,
|
InfoUrl = infoUrl,
|
||||||
Seeders = int.Parse(torrent.Seeders),
|
Seeders = int.Parse(torrent.Seeders),
|
||||||
Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders),
|
Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders),
|
||||||
@@ -113,7 +113,7 @@ public class GazelleParser : IParseIndexerResponse
|
|||||||
Guid = infoUrl,
|
Guid = infoUrl,
|
||||||
Title = groupName,
|
Title = groupName,
|
||||||
Size = long.Parse(result.Size),
|
Size = long.Parse(result.Size),
|
||||||
DownloadUrl = GetDownloadUrl(id),
|
DownloadUrl = GetDownloadUrl(id, result.CanUseToken),
|
||||||
InfoUrl = infoUrl,
|
InfoUrl = infoUrl,
|
||||||
Seeders = int.Parse(result.Seeders),
|
Seeders = int.Parse(result.Seeders),
|
||||||
Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders),
|
Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders),
|
||||||
@@ -146,7 +146,7 @@ public class GazelleParser : IParseIndexerResponse
|
|||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual string GetDownloadUrl(int torrentId)
|
protected virtual string GetDownloadUrl(int torrentId, bool canUseToken)
|
||||||
{
|
{
|
||||||
var url = new HttpUri(Settings.BaseUrl)
|
var url = new HttpUri(Settings.BaseUrl)
|
||||||
.CombinePath("/torrents.php")
|
.CombinePath("/torrents.php")
|
||||||
|
@@ -227,7 +227,7 @@ public class GreatPosterWallParser : GazelleParser
|
|||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetDownloadUrl(int torrentId, bool canUseToken)
|
protected override string GetDownloadUrl(int torrentId, bool canUseToken)
|
||||||
{
|
{
|
||||||
var url = new HttpUri(_settings.BaseUrl)
|
var url = new HttpUri(_settings.BaseUrl)
|
||||||
.CombinePath("/torrents.php")
|
.CombinePath("/torrents.php")
|
||||||
|
Reference in New Issue
Block a user