Radarr/NzbDrone.Core/Jobs/SeriesSearchJob.cs

52 lines
1.6 KiB
C#
Raw Normal View History

using System;
2012-09-10 19:04:17 +00:00
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Model.Notification;
2011-12-02 01:33:17 +00:00
using NzbDrone.Core.Providers;
2012-09-10 19:04:17 +00:00
using NzbDrone.Core.Repository;
2011-12-02 01:33:17 +00:00
namespace NzbDrone.Core.Jobs
{
public class SeriesSearchJob : IJob
{
private readonly SeasonSearchJob _seasonSearchJob;
private readonly SeasonProvider _seasonProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public SeriesSearchJob(SeasonSearchJob seasonSearchJob,
SeasonProvider seasonProvider)
{
_seasonSearchJob = seasonSearchJob;
_seasonProvider = seasonProvider;
}
public string Name
{
get { return "Series Search"; }
}
public TimeSpan DefaultInterval
{
get { return TimeSpan.FromTicks(0); }
}
2012-09-10 19:04:17 +00:00
public void Start(ProgressNotification notification, dynamic options)
{
2012-09-10 19:04:17 +00:00
if (options == null || options.SeriesId <= 0)
throw new ArgumentException("options.SeriesId");
2012-09-10 19:04:17 +00:00
logger.Debug("Getting seasons from database for series: {0}", options.SeriesId);
IList<int> seasons = _seasonProvider.GetSeasons(options.SeriesId);
2012-09-10 19:04:17 +00:00
foreach (var season in seasons.Where(s => s > 0))
{
2012-09-10 19:04:17 +00:00
if (!_seasonProvider.IsIgnored(options.SeriesId, season))
{
2012-09-10 19:04:17 +00:00
_seasonSearchJob.Start(notification, new { SeriesId = options.SeriesId, SeasonNumber = season });
}
}
}
}
}