diff --git a/src/NzbDrone.Core/Extras/ExtraService.cs b/src/NzbDrone.Core/Extras/ExtraService.cs index 1f089e4ab..a75b0edae 100644 --- a/src/NzbDrone.Core/Extras/ExtraService.cs +++ b/src/NzbDrone.Core/Extras/ExtraService.cs @@ -24,6 +24,7 @@ namespace NzbDrone.Core.Extras public class ExtraService : IExtraService, IHandle, IHandle, + IHandle, IHandle { private readonly IMediaFileService _mediaFileService; @@ -52,7 +53,7 @@ namespace NzbDrone.Core.Extras { ImportExtraFiles(localEpisode, episodeFile, isReadOnly); - CreateAfterImport(localEpisode.Series, episodeFile); + CreateAfterEpisodeImport(localEpisode.Series, episodeFile); } private void ImportExtraFiles(LocalEpisode localEpisode, EpisodeFile episodeFile, bool isReadOnly) @@ -121,7 +122,7 @@ namespace NzbDrone.Core.Extras } } - private void CreateAfterImport(Series series, EpisodeFile episodeFile) + private void CreateAfterEpisodeImport(Series series, EpisodeFile episodeFile) { foreach (var extraFileManager in _extraFileManagers) { @@ -130,6 +131,19 @@ namespace NzbDrone.Core.Extras } public void Handle(MediaCoversUpdatedEvent message) + { + if (message.Updated) + { + var series = message.Series; + + foreach (var extraFileManager in _extraFileManagers) + { + extraFileManager.CreateAfterMediaCoverUpdate(series); + } + } + } + + public void Handle(SeriesScannedEvent message) { var series = message.Series; var episodeFiles = GetEpisodeFiles(series.Id); @@ -146,7 +160,7 @@ namespace NzbDrone.Core.Extras foreach (var extraFileManager in _extraFileManagers) { - extraFileManager.CreateAfterEpisodeImport(series, message.SeriesFolder, message.SeasonFolder); + extraFileManager.CreateAfterEpisodeFolder(series, message.SeriesFolder, message.SeasonFolder); } } diff --git a/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs b/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs index 6d4450f72..5e108fe45 100644 --- a/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs +++ b/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs @@ -14,9 +14,10 @@ namespace NzbDrone.Core.Extras.Files public interface IManageExtraFiles { int Order { get; } + IEnumerable CreateAfterMediaCoverUpdate(Series series); IEnumerable CreateAfterSeriesScan(Series series, List episodeFiles); IEnumerable CreateAfterEpisodeImport(Series series, EpisodeFile episodeFile); - IEnumerable CreateAfterEpisodeImport(Series series, string seriesFolder, string seasonFolder); + IEnumerable CreateAfterEpisodeFolder(Series series, string seriesFolder, string seasonFolder); IEnumerable MoveFilesAfterRename(Series series, List episodeFiles); ExtraFile Import(Series series, EpisodeFile episodeFile, string path, string extension, bool readOnly); } @@ -42,9 +43,10 @@ namespace NzbDrone.Core.Extras.Files } public abstract int Order { get; } + public abstract IEnumerable CreateAfterMediaCoverUpdate(Series series); public abstract IEnumerable CreateAfterSeriesScan(Series series, List episodeFiles); public abstract IEnumerable CreateAfterEpisodeImport(Series series, EpisodeFile episodeFile); - public abstract IEnumerable CreateAfterEpisodeImport(Series series, string seriesFolder, string seasonFolder); + public abstract IEnumerable CreateAfterEpisodeFolder(Series series, string seriesFolder, string seasonFolder); public abstract IEnumerable MoveFilesAfterRename(Series series, List episodeFiles); public abstract ExtraFile Import(Series series, EpisodeFile episodeFile, string path, string extension, bool readOnly); diff --git a/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs b/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs index 793662bcd..4b320cfa9 100644 --- a/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs +++ b/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs @@ -56,6 +56,31 @@ namespace NzbDrone.Core.Extras.Metadata public override int Order => 0; + public override IEnumerable CreateAfterMediaCoverUpdate(Series series) + { + var metadataFiles = _metadataFileService.GetFilesBySeries(series.Id); + _cleanMetadataService.Clean(series); + + if (!_diskProvider.FolderExists(series.Path)) + { + _logger.Info("Series folder does not exist, skipping metadata image creation"); + return Enumerable.Empty(); + } + + var files = new List(); + + foreach (var consumer in _metadataFactory.Enabled()) + { + var consumerFiles = GetMetadataFilesForConsumer(consumer, metadataFiles); + + files.AddRange(ProcessSeriesImages(consumer, series, consumerFiles)); + } + + _metadataFileService.Upsert(files); + + return files; + } + public override IEnumerable CreateAfterSeriesScan(Series series, List episodeFiles) { var metadataFiles = _metadataFileService.GetFilesBySeries(series.Id); @@ -104,7 +129,7 @@ namespace NzbDrone.Core.Extras.Metadata return files; } - public override IEnumerable CreateAfterEpisodeImport(Series series, string seriesFolder, string seasonFolder) + public override IEnumerable CreateAfterEpisodeFolder(Series series, string seriesFolder, string seasonFolder) { var metadataFiles = _metadataFileService.GetFilesBySeries(series.Id); diff --git a/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs b/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs index 5323a2488..9e2cad223 100644 --- a/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs +++ b/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs @@ -31,6 +31,11 @@ namespace NzbDrone.Core.Extras.Others public override int Order => 2; + public override IEnumerable CreateAfterMediaCoverUpdate(Series series) + { + return Enumerable.Empty(); + } + public override IEnumerable CreateAfterSeriesScan(Series series, List episodeFiles) { return Enumerable.Empty(); @@ -41,7 +46,7 @@ namespace NzbDrone.Core.Extras.Others return Enumerable.Empty(); } - public override IEnumerable CreateAfterEpisodeImport(Series series, string seriesFolder, string seasonFolder) + public override IEnumerable CreateAfterEpisodeFolder(Series series, string seriesFolder, string seasonFolder) { return Enumerable.Empty(); } diff --git a/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs b/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs index d8d72612f..4a9c16a64 100644 --- a/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs +++ b/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs @@ -35,6 +35,11 @@ namespace NzbDrone.Core.Extras.Subtitles public override int Order => 1; + public override IEnumerable CreateAfterMediaCoverUpdate(Series series) + { + return Enumerable.Empty(); + } + public override IEnumerable CreateAfterSeriesScan(Series series, List episodeFiles) { return Enumerable.Empty(); @@ -45,7 +50,7 @@ namespace NzbDrone.Core.Extras.Subtitles return Enumerable.Empty(); } - public override IEnumerable CreateAfterEpisodeImport(Series series, string seriesFolder, string seasonFolder) + public override IEnumerable CreateAfterEpisodeFolder(Series series, string seriesFolder, string seasonFolder) { return Enumerable.Empty(); }