2011-08-23 05:29:12 +00:00
|
|
|
|
using System;
|
2011-11-26 07:52:54 +00:00
|
|
|
|
using System.Linq;
|
2011-08-23 05:29:12 +00:00
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
2011-12-02 01:33:17 +00:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2011-08-23 05:29:12 +00:00
|
|
|
|
|
2011-12-02 01:33:17 +00:00
|
|
|
|
namespace NzbDrone.Core.Jobs
|
2011-08-23 05:29:12 +00:00
|
|
|
|
{
|
|
|
|
|
public class SeriesSearchJob : IJob
|
|
|
|
|
{
|
2011-08-28 06:37:34 +00:00
|
|
|
|
private readonly SeasonSearchJob _seasonSearchJob;
|
2012-02-21 03:25:19 +00:00
|
|
|
|
private readonly SeasonProvider _seasonProvider;
|
2011-08-23 05:29:12 +00:00
|
|
|
|
|
2012-02-28 05:50:56 +00:00
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
2011-08-23 05:29:12 +00:00
|
|
|
|
|
2012-02-21 03:25:19 +00:00
|
|
|
|
public SeriesSearchJob(SeasonSearchJob seasonSearchJob,
|
|
|
|
|
SeasonProvider seasonProvider)
|
2011-08-23 05:29:12 +00:00
|
|
|
|
{
|
2011-08-28 06:37:34 +00:00
|
|
|
|
_seasonSearchJob = seasonSearchJob;
|
2012-02-21 03:25:19 +00:00
|
|
|
|
_seasonProvider = seasonProvider;
|
2011-08-23 05:29:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Series Search"; }
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-15 02:47:23 +00:00
|
|
|
|
public TimeSpan DefaultInterval
|
2011-08-23 05:29:12 +00:00
|
|
|
|
{
|
2012-01-15 02:47:23 +00:00
|
|
|
|
get { return TimeSpan.FromTicks(0); }
|
2011-08-23 05:29:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
|
|
|
|
|
{
|
|
|
|
|
if (targetId <= 0)
|
|
|
|
|
throw new ArgumentOutOfRangeException("targetId");
|
|
|
|
|
|
2012-02-28 05:50:56 +00:00
|
|
|
|
logger.Debug("Getting seasons from database for series: {0}", targetId);
|
2012-02-21 03:25:19 +00:00
|
|
|
|
var seasons = _seasonProvider.GetSeasons(targetId).Where(s => s > 0);
|
2011-08-23 05:29:12 +00:00
|
|
|
|
|
2011-08-28 06:37:34 +00:00
|
|
|
|
foreach (var season in seasons)
|
2011-08-23 05:29:12 +00:00
|
|
|
|
{
|
2012-02-28 05:50:56 +00:00
|
|
|
|
if (!_seasonProvider.IsIgnored(targetId, season))
|
|
|
|
|
{
|
|
|
|
|
_seasonSearchJob.Start(notification, targetId, season);
|
|
|
|
|
}
|
2011-08-23 05:29:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|