ExternalNotification now has AfterRename, to notify (XBMC) after all episodes have been renamed.

This commit is contained in:
Mark McDowall 2012-01-04 19:40:25 -08:00
parent 7963390126
commit e734bb6ecb
10 changed files with 75 additions and 5 deletions

View File

@ -11,15 +11,20 @@ namespace NzbDrone.Core.Jobs
{
private readonly DiskScanProvider _diskScanProvider;
private readonly MediaFileProvider _mediaFileProvider;
private readonly ExternalNotificationProvider _externalNotificationProvider;
private readonly SeriesProvider _seriesProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public RenameEpisodeJob(DiskScanProvider diskScanProvider, MediaFileProvider mediaFileProvider)
public RenameEpisodeJob(DiskScanProvider diskScanProvider, MediaFileProvider mediaFileProvider,
ExternalNotificationProvider externalNotificationProvider, SeriesProvider seriesProvider)
{
_diskScanProvider = diskScanProvider;
_mediaFileProvider = mediaFileProvider;
_externalNotificationProvider = externalNotificationProvider;
_seriesProvider = seriesProvider;
}
public string Name
@ -39,6 +44,12 @@ namespace NzbDrone.Core.Jobs
var episode = _mediaFileProvider.GetEpisodeFile(targetId);
_diskScanProvider.MoveEpisodeFile(episode);
//Start AfterRename
var series = _seriesProvider.GetSeries(episode.SeriesId);
var message = String.Format("Renamed: Series {0}, Season: {1}", series.Title, secondaryTargetId);
_externalNotificationProvider.AfterRename(message, series);
notification.CurrentMessage = String.Format("Episode rename completed for: {0} ", targetId);
}
}

View File

@ -11,15 +11,19 @@ namespace NzbDrone.Core.Jobs
{
private readonly MediaFileProvider _mediaFileProvider;
private readonly DiskScanProvider _diskScanProvider;
private readonly ExternalNotificationProvider _externalNotificationProvider;
private readonly SeriesProvider _seriesProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public RenameSeasonJob(MediaFileProvider mediaFileProvider, DiskScanProvider diskScanProvider)
public RenameSeasonJob(MediaFileProvider mediaFileProvider, DiskScanProvider diskScanProvider,
ExternalNotificationProvider externalNotificationProvider, SeriesProvider seriesProvider)
{
_mediaFileProvider = mediaFileProvider;
_diskScanProvider = diskScanProvider;
_externalNotificationProvider = externalNotificationProvider;
_seriesProvider = seriesProvider;
}
public string Name
@ -54,6 +58,11 @@ namespace NzbDrone.Core.Jobs
_diskScanProvider.MoveEpisodeFile(episodeFile);
}
//Start AfterRename
var series = _seriesProvider.GetSeries(targetId);
var message = String.Format("Renamed: Series {0}, Season: {1}", series.Title, secondaryTargetId);
_externalNotificationProvider.AfterRename(message, series);
notification.CurrentMessage = String.Format("Season rename completed for Series: {0} Season: {1}", targetId, secondaryTargetId);
}
}

View File

@ -11,15 +11,19 @@ namespace NzbDrone.Core.Jobs
{
private readonly MediaFileProvider _mediaFileProvider;
private readonly DiskScanProvider _diskScanProvider;
private readonly ExternalNotificationProvider _externalNotificationProvider;
private readonly SeriesProvider _seriesProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public RenameSeriesJob(MediaFileProvider mediaFileProvider, DiskScanProvider diskScanProvider)
public RenameSeriesJob(MediaFileProvider mediaFileProvider, DiskScanProvider diskScanProvider,
ExternalNotificationProvider externalNotificationProvider, SeriesProvider seriesProvider)
{
_mediaFileProvider = mediaFileProvider;
_diskScanProvider = diskScanProvider;
_externalNotificationProvider = externalNotificationProvider;
_seriesProvider = seriesProvider;
}
public string Name
@ -51,6 +55,11 @@ namespace NzbDrone.Core.Jobs
_diskScanProvider.MoveEpisodeFile(episodeFile);
}
//Start AfterRename
var series = _seriesProvider.GetSeries(targetId);
var message = String.Format("Renamed: Series {0}", series.Title);
_externalNotificationProvider.AfterRename(message, series);
notification.CurrentMessage = String.Format("Series rename completed for Series: {0}", targetId);
}
}

View File

@ -41,5 +41,12 @@ namespace NzbDrone.Core.Providers.ExternalNotification
/// <param name = "message">The message to send to the receiver</param>
/// <param name = "series">The Series for the new download</param>
public abstract void OnRename(string message, Series series);
/// <summary>
/// Performs the after rename action, this will be handled after all renaming for episode/season/series
/// </summary>
/// <param name = "message">The message to send to the receiver</param>
/// <param name = "series">The Series for the new download</param>
public abstract void AfterRename(string message, Series series);
}
}

View File

@ -70,5 +70,10 @@ namespace NzbDrone.Core.Providers.ExternalNotification
{
}
public override void AfterRename(string message, Series series)
{
}
}
}

View File

@ -69,5 +69,10 @@ namespace NzbDrone.Core.Providers.ExternalNotification
{
}
public override void AfterRename(string message, Series series)
{
}
}
}

View File

@ -47,5 +47,10 @@ namespace NzbDrone.Core.Providers.ExternalNotification
{
}
public override void AfterRename(string message, Series series)
{
}
}
}

View File

@ -39,6 +39,12 @@ namespace NzbDrone.Core.Providers.ExternalNotification
public override void OnRename(string message, Series series)
{
}
public override void AfterRename(string message, Series series)
{
}
}
}

View File

@ -44,6 +44,11 @@ namespace NzbDrone.Core.Providers.ExternalNotification
}
public override void OnRename(string message, Series series)
{
}
public override void AfterRename(string message, Series series)
{
UpdateAndClean(series);
}

View File

@ -108,5 +108,13 @@ namespace NzbDrone.Core.Providers
notifier.OnRename(message, series);
}
}
public virtual void AfterRename(string message, Series series)
{
foreach (var notifier in _notifiers.Where(i => GetSettings(i.GetType()).Enable))
{
notifier.OnRename(message, series);
}
}
}
}