From 1da3954879184098d7605b13d428a62c6b2986f4 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 17 Jan 2024 10:41:03 +0200 Subject: [PATCH] New: (GazelleGames) Freeleech only option --- .../Indexers/Definitions/GazelleGames.cs | 21 ++++++++++++++++--- src/NzbDrone.Core/Localization/Core/en.json | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/GazelleGames.cs b/src/NzbDrone.Core/Indexers/Definitions/GazelleGames.cs index 0599be0d6..2f51ff2cc 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/GazelleGames.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/GazelleGames.cs @@ -324,6 +324,11 @@ namespace NzbDrone.Core.Indexers.Definitions categoryMappings.ForEach(category => parameters.Add("artistcheck[]", category)); } + if (_settings.FreeleechOnly) + { + parameters.Add("freetorrent", "1"); + } + if (searchCriteria.MinSize is > 0) { var minSize = searchCriteria.MinSize.Value / 1024L / 1024L; @@ -404,6 +409,15 @@ namespace NzbDrone.Core.Indexers.Definitions foreach (var torrent in torrents) { + Enum.TryParse(torrent.Value.FreeTorrent, true, out GazelleGamesFreeTorrent freeTorrent); + var downloadVolumeFactor = freeTorrent is GazelleGamesFreeTorrent.FreeLeech or GazelleGamesFreeTorrent.Neutral || torrent.Value.LowSeedFL ? 0 : 1; + + // Skip non-freeleech results when freeleech only is set + if (_settings.FreeleechOnly && downloadVolumeFactor != 0.0) + { + continue; + } + var torrentId = torrent.Key; var infoUrl = GetInfoUrl(group.Key, torrentId); @@ -412,8 +426,6 @@ namespace NzbDrone.Core.Indexers.Definitions categories = _categories.MapTrackerCatToNewznab(torrent.Value.CategoryId.ToString()).ToArray(); } - Enum.TryParse(torrent.Value.FreeTorrent, true, out GazelleGamesFreeTorrent freeTorrent); - var release = new TorrentInfo { Guid = infoUrl, @@ -428,7 +440,7 @@ namespace NzbDrone.Core.Indexers.Definitions Peers = torrent.Value.Leechers + torrent.Value.Seeders, PublishDate = torrent.Value.Time.ToUniversalTime(), Scene = torrent.Value.Scene == 1, - DownloadVolumeFactor = freeTorrent is GazelleGamesFreeTorrent.FreeLeech or GazelleGamesFreeTorrent.Neutral || torrent.Value.LowSeedFL ? 0 : 1, + DownloadVolumeFactor = downloadVolumeFactor, UploadVolumeFactor = freeTorrent == GazelleGamesFreeTorrent.Neutral ? 0 : 1, MinimumSeedTime = 288000 // Minimum of 3 days and 8 hours (80 hours in total) }; @@ -543,6 +555,9 @@ namespace NzbDrone.Core.Indexers.Definitions [FieldDefinition(3, Label = "IndexerGazelleGamesSettingsSearchGroupNames", Type = FieldType.Checkbox, HelpText = "IndexerGazelleGamesSettingsSearchGroupNamesHelpText")] public bool SearchGroupNames { get; set; } + [FieldDefinition(4, Label = "IndexerSettingsFreeleechOnly", HelpText = "IndexerGazelleGamesSettingsFreeleechOnlyHelpText", Type = FieldType.Checkbox, Advanced = true)] + public bool FreeleechOnly { get; set; } + public string Passkey { get; set; } public override NzbDroneValidationResult Validate() diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index f8ef93533..4fbfbf10a 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -336,6 +336,7 @@ "IndexerFlags": "Indexer Flags", "IndexerGazelleGamesSettingsApiKeyHelpText": "API Key from the Site (Found in Settings => Access Settings)", "IndexerGazelleGamesSettingsApiKeyHelpTextWarning": "Must have User and Torrents permissions", + "IndexerGazelleGamesSettingsFreeleechOnlyHelpText": "Search freeleech releases only", "IndexerGazelleGamesSettingsSearchGroupNames": "Search Group Names", "IndexerGazelleGamesSettingsSearchGroupNamesHelpText": "Search releases by group names", "IndexerHDBitsSettingsCodecs": "Codecs",