mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-22 22:34:53 -04:00
New: Add Freeleech Only for HDS, iS and XS
This commit is contained in:
@@ -9,6 +9,7 @@ using AngleSharp.Html.Parser;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Indexers.Exceptions;
|
||||
using NzbDrone.Core.Indexers.Settings;
|
||||
@@ -19,7 +20,7 @@ using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Definitions;
|
||||
|
||||
public class XSpeeds : TorrentIndexerBase<UserPassTorrentBaseSettings>
|
||||
public class XSpeeds : TorrentIndexerBase<XSpeedsSettings>
|
||||
{
|
||||
public override string Name => "XSpeeds";
|
||||
public override string[] IndexerUrls => new[] { "https://www.xspeeds.eu/" };
|
||||
@@ -45,7 +46,7 @@ public class XSpeeds : TorrentIndexerBase<UserPassTorrentBaseSettings>
|
||||
|
||||
public override IParseIndexerResponse GetParser()
|
||||
{
|
||||
return new XSpeedsParser(Capabilities.Categories);
|
||||
return new XSpeedsParser(Settings, Capabilities.Categories);
|
||||
}
|
||||
|
||||
protected override async Task DoLogin()
|
||||
@@ -276,11 +277,14 @@ public class XSpeedsRequestGenerator : IIndexerRequestGenerator
|
||||
|
||||
public class XSpeedsParser : IParseIndexerResponse
|
||||
{
|
||||
private readonly XSpeedsSettings _settings;
|
||||
private readonly IndexerCapabilitiesCategories _categories;
|
||||
|
||||
private readonly Regex _dateAddedRegex = new (@"\d{2}-\d{2}-\d{4} \d{2}:\d{2}", RegexOptions.Compiled);
|
||||
|
||||
public XSpeedsParser(IndexerCapabilitiesCategories categories)
|
||||
public XSpeedsParser(XSpeedsSettings settings, IndexerCapabilitiesCategories categories)
|
||||
{
|
||||
_settings = settings;
|
||||
_categories = categories;
|
||||
}
|
||||
|
||||
@@ -294,6 +298,23 @@ public class XSpeedsParser : IParseIndexerResponse
|
||||
var rows = dom.QuerySelectorAll("table#sortabletable > tbody > tr:has(a[href*=\"details.php?id=\"])");
|
||||
foreach (var row in rows)
|
||||
{
|
||||
var downloadVolumeFactor = 1.0;
|
||||
|
||||
if (row.QuerySelector("img[title^=\"Free Torrent\"], img[title^=\"Sitewide Free Torrent\"]") != null)
|
||||
{
|
||||
downloadVolumeFactor = 0.0;
|
||||
}
|
||||
else if (row.QuerySelector("img[title^=\"Silver Torrent\"]") != null)
|
||||
{
|
||||
downloadVolumeFactor = 0.5;
|
||||
}
|
||||
|
||||
// Skip non-freeleech results when freeleech only is set
|
||||
if (_settings.FreeleechOnly && downloadVolumeFactor != 0.0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var qDetails = row.QuerySelector("div > a[href*=\"details.php?id=\"]");
|
||||
var title = qDetails?.TextContent.Trim();
|
||||
|
||||
@@ -320,6 +341,7 @@ public class XSpeedsParser : IParseIndexerResponse
|
||||
Peers = peers,
|
||||
Size = ParseUtil.GetBytes(row.QuerySelector("td:nth-of-type(5)")?.TextContent.Trim()),
|
||||
Grabs = ParseUtil.CoerceInt(row.QuerySelector("td:nth-child(6)")?.TextContent),
|
||||
DownloadVolumeFactor = downloadVolumeFactor,
|
||||
UploadVolumeFactor = row.QuerySelector("img[title^=\"x2 Torrent\"]") != null ? 2 : 1,
|
||||
MinimumRatio = 0.8
|
||||
};
|
||||
@@ -330,19 +352,6 @@ public class XSpeedsParser : IParseIndexerResponse
|
||||
release.PublishDate = DateTime.ParseExact(dateAddedMatch.Value, "dd-MM-yyyy HH:mm", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (row.QuerySelector("img[title^=\"Free Torrent\"], img[title^=\"Sitewide Free Torrent\"]") != null)
|
||||
{
|
||||
release.DownloadVolumeFactor = 0;
|
||||
}
|
||||
else if (row.QuerySelector("img[title^=\"Silver Torrent\"]") != null)
|
||||
{
|
||||
release.DownloadVolumeFactor = 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
release.DownloadVolumeFactor = 1;
|
||||
}
|
||||
|
||||
releaseInfos.Add(release);
|
||||
}
|
||||
|
||||
@@ -351,3 +360,9 @@ public class XSpeedsParser : IParseIndexerResponse
|
||||
|
||||
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
||||
}
|
||||
|
||||
public class XSpeedsSettings : UserPassTorrentBaseSettings
|
||||
{
|
||||
[FieldDefinition(4, Label = "Freeleech Only", Type = FieldType.Checkbox, HelpText = "Show freeleech releases only")]
|
||||
public bool FreeleechOnly { get; set; } = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user