Lidarr/NzbDrone.Core/Jobs/SeriesSearchJob.cs

50 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.Linq;
using NLog;
using NzbDrone.Core.Model.Notification;
2011-12-02 01:33:17 +00:00
using NzbDrone.Core.Providers;
2011-12-02 01:33:17 +00:00
namespace NzbDrone.Core.Jobs
{
public class SeriesSearchJob : IJob
{
private readonly EpisodeProvider _episodeProvider;
private readonly SeasonSearchJob _seasonSearchJob;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public SeriesSearchJob(EpisodeProvider episodeProvider, SeasonSearchJob seasonSearchJob)
{
_episodeProvider = episodeProvider;
_seasonSearchJob = seasonSearchJob;
}
public string Name
{
get { return "Series Search"; }
}
public int DefaultInterval
{
get { return 0; }
}
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
{
if (targetId <= 0)
throw new ArgumentOutOfRangeException("targetId");
Logger.Debug("Getting seasons from database for series: {0}", targetId);
var seasons = _episodeProvider.GetSeasons(targetId).Where(s => s > 0);
foreach (var season in seasons)
{
//Skip ignored seasons
if (_episodeProvider.IsIgnored(targetId, season))
continue;
_seasonSearchJob.Start(notification, targetId, season);
}
}
}
}