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