1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-01 00:12:30 +01:00
Sonarr/NzbDrone.Core/Jobs/SeriesSearchJob.cs

52 lines
1.6 KiB
C#
Raw Normal View History

using System;
2012-09-10 21:04:17 +02:00
using System.Collections.Generic;
using System.Linq;
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-12-02 02:33:17 +01: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 21:04:17 +02:00
public void Start(ProgressNotification notification, dynamic options)
{
2012-09-10 21:04:17 +02:00
if (options == null || options.SeriesId <= 0)
throw new ArgumentException("options.SeriesId");
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);
2012-09-10 21:04:17 +02:00
foreach (var season in seasons.Where(s => s > 0))
{
2012-09-10 21:04:17 +02:00
if (!_seasonProvider.IsIgnored(options.SeriesId, season))
{
2012-09-10 21:04:17 +02:00
_seasonSearchJob.Start(notification, new { SeriesId = options.SeriesId, SeasonNumber = season });
}
}
}
}
}