1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs

49 lines
1.4 KiB
C#
Raw Normal View History

2013-03-02 21:25:39 +03:00
using System;
using System.Collections.Generic;
using NLog;
using NzbDrone.Common;
2013-05-12 18:18:17 +03:00
using NzbDrone.Common.Serializer;
2013-03-02 21:25:39 +03:00
using NzbDrone.Core.Configuration;
2013-04-01 05:43:58 +03:00
namespace NzbDrone.Core.DataAugmentation.DailySeries
2013-03-02 21:25:39 +03:00
{
public interface IDailySeriesDataProxy
{
IEnumerable<int> GetDailySeriesIds();
}
public class DailySeriesDataProxy : IDailySeriesDataProxy
{
2013-04-11 02:41:45 +03:00
private readonly IHttpProvider _httpProvider;
2013-03-02 21:25:39 +03:00
private readonly IConfigService _configService;
2013-04-18 02:32:06 +03:00
private readonly IJsonSerializer _jsonSerializer;
2013-03-02 21:25:39 +03:00
private readonly Logger _logger;
2013-04-18 02:32:06 +03:00
public DailySeriesDataProxy(IHttpProvider httpProvider, IConfigService configService, IJsonSerializer jsonSerializer, Logger logger)
2013-03-02 21:25:39 +03:00
{
_httpProvider = httpProvider;
_configService = configService;
2013-04-18 02:32:06 +03:00
_jsonSerializer = jsonSerializer;
2013-03-02 21:25:39 +03:00
_logger = logger;
}
public IEnumerable<int> GetDailySeriesIds()
{
try
{
var dailySeriesIds = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/DailySeries/AllIds");
2013-04-18 02:32:06 +03:00
var seriesIds = _jsonSerializer.Deserialize<List<int>>(dailySeriesIds);
2013-03-02 21:25:39 +03:00
return seriesIds;
}
catch (Exception ex)
{
_logger.WarnException("Failed to get Daily Series", ex);
return new List<int>();
}
}
}
}