2013-03-02 19:25:39 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Common;
|
2013-05-12 17:18:17 +02:00
|
|
|
using NzbDrone.Common.Serializer;
|
2013-03-02 19:25:39 +01:00
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
|
2013-04-01 04:43:58 +02:00
|
|
|
namespace NzbDrone.Core.DataAugmentation.DailySeries
|
2013-03-02 19:25:39 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
public interface IDailySeriesDataProxy
|
|
|
|
{
|
|
|
|
IEnumerable<int> GetDailySeriesIds();
|
2013-07-19 03:52:31 +02:00
|
|
|
bool IsDailySeries(int tvdbid);
|
2013-03-02 19:25:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public class DailySeriesDataProxy : IDailySeriesDataProxy
|
|
|
|
{
|
2013-04-11 01:41:45 +02:00
|
|
|
private readonly IHttpProvider _httpProvider;
|
2013-03-02 19:25:39 +01:00
|
|
|
private readonly Logger _logger;
|
|
|
|
|
2013-08-24 04:21:12 +02:00
|
|
|
public DailySeriesDataProxy(IHttpProvider httpProvider, Logger logger)
|
2013-03-02 19:25:39 +01:00
|
|
|
{
|
|
|
|
_httpProvider = httpProvider;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IEnumerable<int> GetDailySeriesIds()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-08-24 04:21:12 +02:00
|
|
|
var dailySeriesIds = _httpProvider.DownloadString(Services.RootUrl + "/DailySeries/AllIds");
|
2013-03-02 19:25:39 +01:00
|
|
|
|
2013-05-13 04:52:55 +02:00
|
|
|
var seriesIds = Json.Deserialize<List<int>>(dailySeriesIds);
|
2013-03-02 19:25:39 +01:00
|
|
|
|
|
|
|
return seriesIds;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
_logger.WarnException("Failed to get Daily Series", ex);
|
|
|
|
return new List<int>();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-07-19 03:52:31 +02:00
|
|
|
|
|
|
|
public bool IsDailySeries(int tvdbid)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-08-24 04:21:12 +02:00
|
|
|
var result = _httpProvider.DownloadString(Services.RootUrl + "/DailySeries/Check?seriesId=" + tvdbid);
|
2013-07-19 03:52:31 +02:00
|
|
|
return Convert.ToBoolean(result);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
_logger.WarnException("Failed to check Daily Series status for: " + tvdbid, ex);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2013-03-02 19:25:39 +01:00
|
|
|
}
|
|
|
|
}
|