Daily series status will be fetched from API on data refresh

pull/6/head
Mark McDowall 11 years ago
parent 17ffdbc89e
commit 4a77197877

@ -11,6 +11,7 @@ namespace NzbDrone.Core.DataAugmentation.DailySeries
public interface IDailySeriesDataProxy
{
IEnumerable<int> GetDailySeriesIds();
bool IsDailySeries(int tvdbid);
}
public class DailySeriesDataProxy : IDailySeriesDataProxy
@ -43,5 +44,19 @@ namespace NzbDrone.Core.DataAugmentation.DailySeries
}
}
public bool IsDailySeries(int tvdbid)
{
try
{
var result = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/DailySeries/Check?seriesId=" + tvdbid);
return Convert.ToBoolean(result);
}
catch (Exception ex)
{
_logger.WarnException("Failed to check Daily Series status for: " + tvdbid, ex);
return false;
}
}
}
}

@ -2,7 +2,13 @@ using NzbDrone.Core.Tv;
namespace NzbDrone.Core.DataAugmentation.DailySeries
{
public class DailySeriesService
public interface IDailySeriesService
{
void UpdateDailySeries();
bool IsDailySeries(int tvdbid);
}
public class DailySeriesService : IDailySeriesService
{
//TODO: add timer command
@ -15,7 +21,7 @@ namespace NzbDrone.Core.DataAugmentation.DailySeries
_seriesService = seriesService;
}
public virtual void UpdateDailySeries()
public void UpdateDailySeries()
{
var dailySeries = _proxy.GetDailySeriesIds();
@ -29,5 +35,10 @@ namespace NzbDrone.Core.DataAugmentation.DailySeries
}
}
}
public bool IsDailySeries(int tvdbid)
{
return _proxy.IsDailySeries(tvdbid);
}
}
}

@ -2,7 +2,7 @@
namespace NzbDrone.Core.Tv.Events
{
public class SeriesAddedEvent:IEvent
public class SeriesAddedEvent : IEvent
{
public Series Series { get; private set; }

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.DataAugmentation.DailySeries;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Tv.Commands;
using NzbDrone.Core.Tv.Events;
@ -17,16 +18,18 @@ namespace NzbDrone.Core.Tv
private readonly IEpisodeService _episodeService;
private readonly ISeasonRepository _seasonRepository;
private readonly IMessageAggregator _messageAggregator;
private readonly IDailySeriesService _dailySeriesService;
private readonly Logger _logger;
public RefreshSeriesService(IProvideSeriesInfo seriesInfo, ISeriesService seriesService, IEpisodeService episodeService,
ISeasonRepository seasonRepository, IMessageAggregator messageAggregator, Logger logger)
ISeasonRepository seasonRepository, IMessageAggregator messageAggregator, IDailySeriesService dailySeriesService, Logger logger)
{
_seriesInfo = seriesInfo;
_seriesService = seriesService;
_episodeService = episodeService;
_seasonRepository = seasonRepository;
_messageAggregator = messageAggregator;
_dailySeriesService = dailySeriesService;
_logger = logger;
}
@ -77,6 +80,12 @@ namespace NzbDrone.Core.Tv
series.Images = seriesInfo.Images;
series.Network = seriesInfo.Network;
series.FirstAired = seriesInfo.FirstAired;
if (_dailySeriesService.IsDailySeries(series.TvdbId))
{
series.SeriesType = SeriesTypes.Daily;
}
_seriesService.UpdateSeries(series);
RefreshEpisodeInfo(series, tuple.Item2);

Loading…
Cancel
Save