You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/NzbDrone.Core/MetadataSource/IMetadataRequestBuilder.cs

38 lines
1.1 KiB

using NzbDrone.Common.Cloud;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Core.MetadataSource
{
public interface IMetadataRequestBuilder
{
IHttpRequestBuilderFactory GetRequestBuilder();
}
public class MetadataRequestBuilder : IMetadataRequestBuilder
{
private readonly IConfigService _configService;
private readonly ILidarrCloudRequestBuilder _defaultRequestFactory;
public MetadataRequestBuilder(IConfigService configService, ILidarrCloudRequestBuilder defaultRequestBuilder)
{
_configService = configService;
_defaultRequestFactory = defaultRequestBuilder;
}
public IHttpRequestBuilderFactory GetRequestBuilder()
{
if (_configService.MetadataSource.IsNotNullOrWhiteSpace())
{
return new HttpRequestBuilder(_configService.MetadataSource.TrimEnd("/") + "/{route}").KeepAlive().CreateFactory();
}
else
{
return _defaultRequestFactory.Search;
}
}
}
}