2011-06-18 03:46:22 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2011-06-14 03:23:04 +02:00
|
|
|
|
using Ninject;
|
2011-04-20 09:44:13 +02:00
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
|
{
|
|
|
|
|
public class UpdateInfoJob : IJob
|
|
|
|
|
{
|
|
|
|
|
private readonly SeriesProvider _seriesProvider;
|
|
|
|
|
private readonly EpisodeProvider _episodeProvider;
|
|
|
|
|
|
2011-06-14 03:23:04 +02:00
|
|
|
|
[Inject]
|
2011-04-20 09:44:13 +02:00
|
|
|
|
public UpdateInfoJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider)
|
|
|
|
|
{
|
|
|
|
|
_seriesProvider = seriesProvider;
|
|
|
|
|
_episodeProvider = episodeProvider;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-21 02:23:49 +02:00
|
|
|
|
public UpdateInfoJob()
|
|
|
|
|
{
|
2011-06-14 03:23:04 +02:00
|
|
|
|
|
2011-05-21 02:23:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-20 09:44:13 +02:00
|
|
|
|
public string Name
|
|
|
|
|
{
|
2011-07-05 08:46:03 +02:00
|
|
|
|
get { return "Update Episode Info"; }
|
2011-04-20 09:44:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int DefaultInterval
|
|
|
|
|
{
|
|
|
|
|
get { return 1440; } //Daily
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-21 02:23:49 +02:00
|
|
|
|
public virtual void Start(ProgressNotification notification, int targetId)
|
2011-04-20 09:44:13 +02:00
|
|
|
|
{
|
|
|
|
|
IList<Series> seriesToUpdate;
|
|
|
|
|
if (targetId == 0)
|
|
|
|
|
{
|
|
|
|
|
seriesToUpdate = _seriesProvider.GetAllSeries().ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
seriesToUpdate = new List<Series>() { _seriesProvider.GetSeries(targetId) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var series in seriesToUpdate)
|
|
|
|
|
{
|
2011-04-24 07:48:12 +02:00
|
|
|
|
notification.CurrentMessage = "Updating " + series.Title;
|
2011-04-20 09:44:13 +02:00
|
|
|
|
_seriesProvider.UpdateSeriesInfo(series.SeriesId);
|
2011-05-29 05:01:35 +02:00
|
|
|
|
_episodeProvider.RefreshEpisodeInfo(series);
|
2011-04-24 07:48:12 +02:00
|
|
|
|
notification.CurrentMessage = "Update completed for " + series.Title;
|
2011-04-20 09:44:13 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|