From bea9bd39ff627ec5e543bd9a56427a5cd52fbeef Mon Sep 17 00:00:00 2001 From: Bogdan Date: Mon, 9 Jan 2023 12:04:39 +0200 Subject: [PATCH] Fixed: (LazyLibrarian) Sync priority --- .../Applications/LazyLibrarian/LazyLibrarian.cs | 1 + .../Applications/LazyLibrarian/LazyLibrarianIndexer.cs | 4 +++- .../Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs | 10 ++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarian.cs b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarian.cs index 26ba2392f..da68d6d0c 100644 --- a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarian.cs +++ b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarian.cs @@ -147,6 +147,7 @@ namespace NzbDrone.Core.Applications.LazyLibrarian Categories = string.Join(",", indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray())), Enabled = indexer.Enable, Type = schema, + Priority = indexer.Priority }; return lazyLibrarianIndexer; diff --git a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianIndexer.cs b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianIndexer.cs index ff77f47b7..bc20c3ddf 100644 --- a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianIndexer.cs +++ b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianIndexer.cs @@ -30,6 +30,7 @@ namespace NzbDrone.Core.Applications.LazyLibrarian public bool Enabled { get; set; } public string Altername { get; set; } public LazyLibrarianProviderType Type { get; set; } + public int Priority { get; set; } public bool Equals(LazyLibrarianIndexer other) { @@ -43,7 +44,8 @@ namespace NzbDrone.Core.Applications.LazyLibrarian other.Name == Name && other.Categories == Categories && other.Enabled == Enabled && - other.Altername == Altername; + other.Altername == Altername && + other.Priority == Priority; } } } diff --git a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs index dbf435f65..43df7764f 100644 --- a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs +++ b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs @@ -21,6 +21,8 @@ namespace NzbDrone.Core.Applications.LazyLibrarian public class LazyLibrarianV1Proxy : ILazyLibrarianV1Proxy { + private const int ProwlarrHighestPriority = 50; + private readonly IHttpClient _httpClient; private readonly Logger _logger; @@ -90,7 +92,8 @@ namespace NzbDrone.Core.Applications.LazyLibrarian { "host", indexer.Host }, { "prov_apikey", indexer.Apikey }, { "enabled", indexer.Enabled.ToString().ToLower() }, - { "categories", indexer.Categories } + { "categories", indexer.Categories }, + { "dlpriority", CalculatePriority(indexer.Priority).ToString() } }; var request = BuildRequest(settings, "/api", "addProvider", HttpMethod.Get, parameters); @@ -108,7 +111,8 @@ namespace NzbDrone.Core.Applications.LazyLibrarian { "prov_apikey", indexer.Apikey }, { "enabled", indexer.Enabled.ToString().ToLower() }, { "categories", indexer.Categories }, - { "altername", indexer.Altername } + { "altername", indexer.Altername }, + { "dlpriority", CalculatePriority(indexer.Priority).ToString() } }; var request = BuildRequest(settings, "/api", "changeProvider", HttpMethod.Get, parameters); @@ -191,5 +195,7 @@ namespace NzbDrone.Core.Applications.LazyLibrarian return results; } + + private int CalculatePriority(int indexerPriority) => ProwlarrHighestPriority - indexerPriority + 1; } }