Fixed: (LazyLibrarian) Sync priority

This commit is contained in:
Bogdan 2023-01-09 12:04:39 +02:00
parent 077e4727f2
commit bea9bd39ff
3 changed files with 12 additions and 3 deletions

View file

@ -147,6 +147,7 @@ private LazyLibrarianIndexer BuildLazyLibrarianIndexer(IndexerDefinition indexer
Categories = string.Join(",", indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray())),
Enabled = indexer.Enable,
Type = schema,
Priority = indexer.Priority
};
return lazyLibrarianIndexer;

View file

@ -30,6 +30,7 @@ public class LazyLibrarianIndexer
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 @@ public bool Equals(LazyLibrarianIndexer other)
other.Name == Name &&
other.Categories == Categories &&
other.Enabled == Enabled &&
other.Altername == Altername;
other.Altername == Altername &&
other.Priority == Priority;
}
}
}

View file

@ -21,6 +21,8 @@ public interface ILazyLibrarianV1Proxy
public class LazyLibrarianV1Proxy : ILazyLibrarianV1Proxy
{
private const int ProwlarrHighestPriority = 50;
private readonly IHttpClient _httpClient;
private readonly Logger _logger;
@ -90,7 +92,8 @@ public LazyLibrarianIndexer AddIndexer(LazyLibrarianIndexer indexer, LazyLibrari
{ "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 @@ public LazyLibrarianIndexer UpdateIndexer(LazyLibrarianIndexer indexer, LazyLibr
{ "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 @@ private TResource Execute<TResource>(HttpRequest request)
return results;
}
private int CalculatePriority(int indexerPriority) => ProwlarrHighestPriority - indexerPriority + 1;
}
}