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