Code cleanup

This commit is contained in:
pcjones
2024-04-14 22:44:07 +02:00
parent 12d9217964
commit 389d685e95
11 changed files with 20 additions and 181 deletions

View File

@@ -0,0 +1,15 @@
namespace UmlautAdaptarr.Providers
{
public static class ArrClientFactory
{
public static IEnumerable<TClient> CreateClients<TClient>(
Func<string, TClient> constructor, IConfiguration configuration, string configKey) where TClient : ArrClientBase
{
var hosts = configuration.GetValue<string>(configKey)?.Split(',') ?? throw new ArgumentException($"{configKey} environment variable must be set if the app is enabled");
foreach (var host in hosts)
{
yield return constructor(host.Trim());
}
}
}
}

View File

@@ -11,7 +11,6 @@ namespace UmlautAdaptarr.Providers
{
public class LidarrClient(
IHttpClientFactory clientFactory,
IConfiguration configuration,
CacheService cacheService,
IMemoryCache cache,
ILogger<LidarrClient> logger, IOptions<LidarrInstanceOptions> options) : ArrClientBase()
@@ -136,7 +135,7 @@ namespace UmlautAdaptarr.Providers
{
try
{
// this should never be called at the moment
// this should never be called at the moment
throw new NotImplementedException();
}
catch (Exception ex)

View File

@@ -11,7 +11,6 @@ namespace UmlautAdaptarr.Providers
{
public class ReadarrClient(
IHttpClientFactory clientFactory,
IConfiguration configuration,
CacheService cacheService,
IMemoryCache cache,
IOptions<ReadarrInstanceOptions> options,

View File

@@ -9,14 +9,11 @@ namespace UmlautAdaptarr.Providers
{
public class SonarrClient(
IHttpClientFactory clientFactory,
IConfiguration configuration,
TitleApiService titleService,
IOptions<SonarrInstanceOptions> options,
ILogger<SonarrClient> logger) : ArrClientBase()
{
public SonarrInstanceOptions SonarrOptions { get; } = options.Value;
//private readonly string _sonarrHost = configuration.GetValue<string>("SONARR_HOST") ?? throw new ArgumentException("SONARR_HOST environment variable must be set");
//private readonly string _sonarrApiKey = configuration.GetValue<string>("SONARR_API_KEY") ?? throw new ArgumentException("SONARR_API_KEY environment variable must be set");
private readonly string _mediaType = "tv";
public override async Task<IEnumerable<SearchItem>> FetchAllItemsAsync()