diff --git a/src/NzbDrone.Core/Extras/ExtraService.cs b/src/NzbDrone.Core/Extras/ExtraService.cs index 1b3969d31..b85475bfe 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; @@ -55,7 +56,7 @@ namespace NzbDrone.Core.Extras { ImportExtraFiles(localTrack, trackFile, isReadOnly); - CreateAfterImport(localTrack.Artist, trackFile); + CreateAfterTrackImport(localTrack.Artist, trackFile); } public void ImportExtraFiles(LocalTrack localTrack, TrackFile trackFile, bool isReadOnly) @@ -123,7 +124,7 @@ namespace NzbDrone.Core.Extras } } - private void CreateAfterImport(Artist artist, TrackFile trackFile) + private void CreateAfterTrackImport(Artist artist, TrackFile trackFile) { foreach (var extraFileManager in _extraFileManagers) { @@ -132,6 +133,19 @@ namespace NzbDrone.Core.Extras } public void Handle(MediaCoversUpdatedEvent message) + { + if (message.Updated) + { + var artist = message.Artist; + + foreach (var extraFileManager in _extraFileManagers) + { + extraFileManager.CreateAfterMediaCoverUpdate(artist); + } + } + } + + public void Handle(ArtistScannedEvent message) { var artist = message.Artist; @@ -150,7 +164,7 @@ namespace NzbDrone.Core.Extras foreach (var extraFileManager in _extraFileManagers) { - extraFileManager.CreateAfterTrackImport(artist, album, message.ArtistFolder, message.AlbumFolder); + extraFileManager.CreateAfterTrackFolder(artist, album, message.ArtistFolder, message.AlbumFolder); } } diff --git a/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs b/src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs index c618557d9..5036a226b 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(Artist artist); IEnumerable CreateAfterArtistScan(Artist artist, List trackFiles); IEnumerable CreateAfterTrackImport(Artist artist, TrackFile trackFile); - IEnumerable CreateAfterTrackImport(Artist artist, Album album, string artistFolder, string albumFolder); + IEnumerable CreateAfterTrackFolder(Artist artist, Album album, string artistFolder, string albumFolder); IEnumerable MoveFilesAfterRename(Artist artist, List trackFiles); ExtraFile Import(Artist artist, TrackFile trackFile, string path, string extension, bool readOnly); } @@ -41,9 +42,10 @@ namespace NzbDrone.Core.Extras.Files } public abstract int Order { get; } + public abstract IEnumerable CreateAfterMediaCoverUpdate(Artist artist); public abstract IEnumerable CreateAfterArtistScan(Artist artist, List trackFiles); public abstract IEnumerable CreateAfterTrackImport(Artist artist, TrackFile trackFile); - public abstract IEnumerable CreateAfterTrackImport(Artist artist, Album album, string artistFolder, string albumFolder); + public abstract IEnumerable CreateAfterTrackFolder(Artist artist, Album album, string artistFolder, string albumFolder); public abstract IEnumerable MoveFilesAfterRename(Artist artist, List trackFiles); public abstract ExtraFile Import(Artist artist, TrackFile trackFile, string path, string extension, bool readOnly); diff --git a/src/NzbDrone.Core/Extras/Lyrics/LyricService.cs b/src/NzbDrone.Core/Extras/Lyrics/LyricService.cs index 69f4b684e..78325429c 100644 --- a/src/NzbDrone.Core/Extras/Lyrics/LyricService.cs +++ b/src/NzbDrone.Core/Extras/Lyrics/LyricService.cs @@ -33,6 +33,11 @@ namespace NzbDrone.Core.Extras.Lyrics public override int Order => 1; + public override IEnumerable CreateAfterMediaCoverUpdate(Artist artist) + { + return Enumerable.Empty(); + } + public override IEnumerable CreateAfterArtistScan(Artist artist, List trackFiles) { return Enumerable.Empty(); @@ -43,7 +48,7 @@ namespace NzbDrone.Core.Extras.Lyrics return Enumerable.Empty(); } - public override IEnumerable CreateAfterTrackImport(Artist artist, Album album, string artistFolder, string albumFolder) + public override IEnumerable CreateAfterTrackFolder(Artist artist, Album album, string artistFolder, string albumFolder) { return Enumerable.Empty(); } diff --git a/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs b/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs index 7432fc35b..56158403b 100644 --- a/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs +++ b/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs @@ -59,6 +59,31 @@ namespace NzbDrone.Core.Extras.Metadata public override int Order => 0; + public override IEnumerable CreateAfterMediaCoverUpdate(Artist artist) + { + var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id); + _cleanMetadataService.Clean(artist); + + if (!_diskProvider.FolderExists(artist.Path)) + { + _logger.Info("Artist 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(ProcessArtistImages(consumer, artist, consumerFiles)); + } + + _metadataFileService.Upsert(files); + + return files; + } + public override IEnumerable CreateAfterArtistScan(Artist artist, List trackFiles) { var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id); @@ -114,7 +139,7 @@ namespace NzbDrone.Core.Extras.Metadata return files; } - public override IEnumerable CreateAfterTrackImport(Artist artist, Album album, string artistFolder, string albumFolder) + public override IEnumerable CreateAfterTrackFolder(Artist artist, Album album, string artistFolder, string albumFolder) { var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id); diff --git a/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs b/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs index 98470e5fe..5e0e6f3af 100644 --- a/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs +++ b/src/NzbDrone.Core/Extras/Others/OtherExtraService.cs @@ -29,6 +29,11 @@ namespace NzbDrone.Core.Extras.Others public override int Order => 2; + public override IEnumerable CreateAfterMediaCoverUpdate(Artist artist) + { + return Enumerable.Empty(); + } + public override IEnumerable CreateAfterArtistScan(Artist artist, List trackFiles) { return Enumerable.Empty(); @@ -39,7 +44,7 @@ namespace NzbDrone.Core.Extras.Others return Enumerable.Empty(); } - public override IEnumerable CreateAfterTrackImport(Artist artist, Album album, string artistFolder, string albumFolder) + public override IEnumerable CreateAfterTrackFolder(Artist artist, Album album, string artistFolder, string albumFolder) { return Enumerable.Empty(); }