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.
Readarr/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs

49 lines
1.4 KiB

12 years ago
using System;
using System.Collections.Generic;
using NLog;
using NzbDrone.Common;
using NzbDrone.Common.Serializer;
12 years ago
using NzbDrone.Core.Configuration;
namespace NzbDrone.Core.DataAugmentation.DailySeries
12 years ago
{
public interface IDailySeriesDataProxy
{
IEnumerable<int> GetDailySeriesIds();
}
public class DailySeriesDataProxy : IDailySeriesDataProxy
{
private readonly IHttpProvider _httpProvider;
12 years ago
private readonly IConfigService _configService;
private readonly IJsonSerializer _jsonSerializer;
12 years ago
private readonly Logger _logger;
public DailySeriesDataProxy(IHttpProvider httpProvider, IConfigService configService, IJsonSerializer jsonSerializer, Logger logger)
12 years ago
{
_httpProvider = httpProvider;
_configService = configService;
_jsonSerializer = jsonSerializer;
12 years ago
_logger = logger;
}
public IEnumerable<int> GetDailySeriesIds()
{
try
{
var dailySeriesIds = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/DailySeries/AllIds");
var seriesIds = _jsonSerializer.Deserialize<List<int>>(dailySeriesIds);
12 years ago
return seriesIds;
}
catch (Exception ex)
{
_logger.WarnException("Failed to get Daily Series", ex);
return new List<int>();
}
}
}
}