Code cleanup
This commit is contained in:
15
UmlautAdaptarr/Providers/ArrClientFactory.cs
Normal file
15
UmlautAdaptarr/Providers/ArrClientFactory.cs
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace UmlautAdaptarr.Providers
|
||||
{
|
||||
public class ReadarrClient(
|
||||
IHttpClientFactory clientFactory,
|
||||
IConfiguration configuration,
|
||||
CacheService cacheService,
|
||||
IMemoryCache cache,
|
||||
IOptions<ReadarrInstanceOptions> options,
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user