From 4a771978770a2b3eaecb545c1790039446e9a2ef Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 18 Jul 2013 18:52:31 -0700 Subject: [PATCH] Daily series status will be fetched from API on data refresh --- .../DailySeries/DailySeriesDataProxy.cs | 15 +++++++++++++++ .../DailySeries/DailySeriesService.cs | 15 +++++++++++++-- NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs | 2 +- NzbDrone.Core/Tv/RefreshSeriesService.cs | 11 ++++++++++- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs b/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs index 62f6f8503..fc2a591a2 100644 --- a/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs +++ b/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs @@ -11,6 +11,7 @@ namespace NzbDrone.Core.DataAugmentation.DailySeries public interface IDailySeriesDataProxy { IEnumerable 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; + } + } } } \ No newline at end of file diff --git a/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs b/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs index 8aac187fc..823570958 100644 --- a/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs +++ b/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs @@ -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); + } } } diff --git a/NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs b/NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs index 7a6b513ca..1038b0926 100644 --- a/NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs +++ b/NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs @@ -2,7 +2,7 @@ namespace NzbDrone.Core.Tv.Events { - public class SeriesAddedEvent:IEvent + public class SeriesAddedEvent : IEvent { public Series Series { get; private set; } diff --git a/NzbDrone.Core/Tv/RefreshSeriesService.cs b/NzbDrone.Core/Tv/RefreshSeriesService.cs index 94381c8bb..ea83a12c9 100644 --- a/NzbDrone.Core/Tv/RefreshSeriesService.cs +++ b/NzbDrone.Core/Tv/RefreshSeriesService.cs @@ -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);