2011-08-23 05:29:12 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2011-11-26 07:52:54 +00:00
|
|
|
|
using System.Linq;
|
2011-08-23 05:29:12 +00:00
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
|
{
|
|
|
|
|
public class SeriesSearchJob : IJob
|
|
|
|
|
{
|
|
|
|
|
private readonly EpisodeProvider _episodeProvider;
|
2011-08-28 06:37:34 +00:00
|
|
|
|
private readonly SeasonSearchJob _seasonSearchJob;
|
2011-08-23 05:29:12 +00:00
|
|
|
|
|
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
2011-08-28 06:37:34 +00:00
|
|
|
|
public SeriesSearchJob(EpisodeProvider episodeProvider, SeasonSearchJob seasonSearchJob)
|
2011-08-23 05:29:12 +00:00
|
|
|
|
{
|
|
|
|
|
_episodeProvider = episodeProvider;
|
2011-08-28 06:37:34 +00:00
|
|
|
|
_seasonSearchJob = seasonSearchJob;
|
2011-08-23 05:29:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
2011-08-28 06:37:34 +00:00
|
|
|
|
Logger.Debug("Getting seasons from database for series: {0}", targetId);
|
2011-11-26 07:52:54 +00:00
|
|
|
|
var seasons = _episodeProvider.GetSeasons(targetId).Where(s => s > 0);
|
2011-08-23 05:29:12 +00:00
|
|
|
|
|
2011-08-28 06:37:34 +00:00
|
|
|
|
foreach (var season in seasons)
|
2011-08-23 05:29:12 +00:00
|
|
|
|
{
|
2011-08-28 06:37:34 +00:00
|
|
|
|
//Skip ignored seasons
|
|
|
|
|
if (_episodeProvider.IsIgnored(targetId, season))
|
|
|
|
|
continue;
|
2011-08-23 05:29:12 +00:00
|
|
|
|
|
2011-08-28 06:37:34 +00:00
|
|
|
|
_seasonSearchJob.Start(notification, targetId, season);
|
2011-08-23 05:29:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|