sonarr-repo-only/NzbDrone.Core/Jobs/Implementations/SeriesSearchJob.cs

50 lines
1.6 KiB
C#
Raw Normal View History

2013-03-05 05:37:33 +00:00
using System;
2012-09-10 19:04:17 +00:00
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Model.Notification;
2013-03-05 05:37:33 +00:00
using NzbDrone.Core.Tv;
2013-03-05 05:37:33 +00:00
namespace NzbDrone.Core.Jobs.Implementations
{
public class SeriesSearchJob : IJob
{
private readonly SeasonSearchJob _seasonSearchJob;
private readonly ISeasonRepository _seasonRepository;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public SeriesSearchJob(SeasonSearchJob seasonSearchJob, ISeasonRepository seasonRepository)
{
_seasonSearchJob = seasonSearchJob;
_seasonRepository = seasonRepository;
}
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);
2013-02-22 23:55:43 +00:00
IList<int> seasons = _seasonRepository.GetSeasonNumbers((int)options.SeriesId);
2012-09-10 19:04:17 +00:00
foreach (var season in seasons.Where(s => s > 0))
{
2013-02-22 23:55:43 +00:00
if (!_seasonRepository.IsIgnored((int)options.SeriesId, season))
{
2012-09-10 19:04:17 +00:00
_seasonSearchJob.Start(notification, new { SeriesId = options.SeriesId, SeasonNumber = season });
}
}
}
}
}