From 434b07ae648d04088ada30c6853680831e3cc04b Mon Sep 17 00:00:00 2001 From: jaype87 Date: Sun, 8 Sep 2024 10:34:26 +0200 Subject: [PATCH] New: Sync seeding limits for LazyLibrarian (#2215) * add support for seeders, seed_ratio and seed_duration for LazyLibrarian --- .../Applications/LazyLibrarian/LazyLibrarian.cs | 7 +++++++ .../LazyLibrarian/LazyLibrarianIndexer.cs | 8 +++++++- .../LazyLibrarian/LazyLibrarianV1Proxy.cs | 15 +++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarian.cs b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarian.cs index 24837c3ec..108972d6e 100644 --- a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarian.cs +++ b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarian.cs @@ -165,6 +165,13 @@ namespace NzbDrone.Core.Applications.LazyLibrarian Priority = indexer.Priority }; + if (indexer.Protocol == DownloadProtocol.Torrent) + { + lazyLibrarianIndexer.MinimumSeeders = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.AppMinimumSeeders ?? indexer.AppProfile.Value.MinimumSeeders; + lazyLibrarianIndexer.SeedRatio = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedRatio.GetValueOrDefault(); + lazyLibrarianIndexer.SeedTime = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedTime.GetValueOrDefault(); + } + return lazyLibrarianIndexer; } } diff --git a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianIndexer.cs b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianIndexer.cs index bc20c3ddf..b13403aac 100644 --- a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianIndexer.cs +++ b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianIndexer.cs @@ -31,6 +31,9 @@ namespace NzbDrone.Core.Applications.LazyLibrarian public string Altername { get; set; } public LazyLibrarianProviderType Type { get; set; } public int Priority { get; set; } + public double SeedRatio { get; set; } + public int SeedTime { get; set; } + public int MinimumSeeders { get; set; } public bool Equals(LazyLibrarianIndexer other) { @@ -45,7 +48,10 @@ namespace NzbDrone.Core.Applications.LazyLibrarian other.Categories == Categories && other.Enabled == Enabled && other.Altername == Altername && - other.Priority == Priority; + other.Priority == Priority && + other.SeedRatio == SeedRatio && + other.SeedTime == SeedTime && + other.MinimumSeeders == MinimumSeeders; } } } diff --git a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs index 563f9ed3b..f4c6da138 100644 --- a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs +++ b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Net.Http; using FluentValidation.Results; @@ -96,6 +97,13 @@ namespace NzbDrone.Core.Applications.LazyLibrarian { "dlpriority", CalculatePriority(indexer.Priority).ToString() } }; + if (indexer.Type == LazyLibrarianProviderType.Torznab) + { + parameters.Add("seeders", indexer.MinimumSeeders.ToString()); + parameters.Add("seed_ratio", indexer.SeedRatio.ToString(CultureInfo.InvariantCulture)); + parameters.Add("seed_duration", indexer.SeedTime.ToString()); + } + var request = BuildRequest(settings, "/api", "addProvider", HttpMethod.Get, parameters); CheckForError(Execute(request)); return indexer; @@ -115,6 +123,13 @@ namespace NzbDrone.Core.Applications.LazyLibrarian { "dlpriority", CalculatePriority(indexer.Priority).ToString() } }; + if (indexer.Type == LazyLibrarianProviderType.Torznab) + { + parameters.Add("seeders", indexer.MinimumSeeders.ToString()); + parameters.Add("seed_ratio", indexer.SeedRatio.ToString(CultureInfo.InvariantCulture)); + parameters.Add("seed_duration", indexer.SeedTime.ToString()); + } + var request = BuildRequest(settings, "/api", "changeProvider", HttpMethod.Get, parameters); CheckForError(Execute(request)); return indexer;