Lidarr/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.Tv;
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 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 });
}
}
}
}
}