Fixed: Generating Kodi episode metadata files when scanning series folder

(cherry picked from commit 23dc7794f14c99558b7d40729d6c63f8ae747a1e)
pull/1689/head
Taloth Saldono 4 years ago committed by Qstick
parent a085dd38a6
commit bf0617f999

@ -24,6 +24,7 @@ namespace NzbDrone.Core.Extras
public class ExtraService : IExtraService, public class ExtraService : IExtraService,
IHandle<MediaCoversUpdatedEvent>, IHandle<MediaCoversUpdatedEvent>,
IHandle<TrackFolderCreatedEvent>, IHandle<TrackFolderCreatedEvent>,
IHandle<ArtistScannedEvent>,
IHandle<ArtistRenamedEvent> IHandle<ArtistRenamedEvent>
{ {
private readonly IMediaFileService _mediaFileService; private readonly IMediaFileService _mediaFileService;
@ -55,7 +56,7 @@ namespace NzbDrone.Core.Extras
{ {
ImportExtraFiles(localTrack, trackFile, isReadOnly); ImportExtraFiles(localTrack, trackFile, isReadOnly);
CreateAfterImport(localTrack.Artist, trackFile); CreateAfterTrackImport(localTrack.Artist, trackFile);
} }
public void ImportExtraFiles(LocalTrack localTrack, TrackFile trackFile, bool isReadOnly) 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) foreach (var extraFileManager in _extraFileManagers)
{ {
@ -132,6 +133,19 @@ namespace NzbDrone.Core.Extras
} }
public void Handle(MediaCoversUpdatedEvent message) 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; var artist = message.Artist;
@ -150,7 +164,7 @@ namespace NzbDrone.Core.Extras
foreach (var extraFileManager in _extraFileManagers) foreach (var extraFileManager in _extraFileManagers)
{ {
extraFileManager.CreateAfterTrackImport(artist, album, message.ArtistFolder, message.AlbumFolder); extraFileManager.CreateAfterTrackFolder(artist, album, message.ArtistFolder, message.AlbumFolder);
} }
} }

@ -14,9 +14,10 @@ namespace NzbDrone.Core.Extras.Files
public interface IManageExtraFiles public interface IManageExtraFiles
{ {
int Order { get; } int Order { get; }
IEnumerable<ExtraFile> CreateAfterMediaCoverUpdate(Artist artist);
IEnumerable<ExtraFile> CreateAfterArtistScan(Artist artist, List<TrackFile> trackFiles); IEnumerable<ExtraFile> CreateAfterArtistScan(Artist artist, List<TrackFile> trackFiles);
IEnumerable<ExtraFile> CreateAfterTrackImport(Artist artist, TrackFile trackFile); IEnumerable<ExtraFile> CreateAfterTrackImport(Artist artist, TrackFile trackFile);
IEnumerable<ExtraFile> CreateAfterTrackImport(Artist artist, Album album, string artistFolder, string albumFolder); IEnumerable<ExtraFile> CreateAfterTrackFolder(Artist artist, Album album, string artistFolder, string albumFolder);
IEnumerable<ExtraFile> MoveFilesAfterRename(Artist artist, List<TrackFile> trackFiles); IEnumerable<ExtraFile> MoveFilesAfterRename(Artist artist, List<TrackFile> trackFiles);
ExtraFile Import(Artist artist, TrackFile trackFile, string path, string extension, bool readOnly); 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 int Order { get; }
public abstract IEnumerable<ExtraFile> CreateAfterMediaCoverUpdate(Artist artist);
public abstract IEnumerable<ExtraFile> CreateAfterArtistScan(Artist artist, List<TrackFile> trackFiles); public abstract IEnumerable<ExtraFile> CreateAfterArtistScan(Artist artist, List<TrackFile> trackFiles);
public abstract IEnumerable<ExtraFile> CreateAfterTrackImport(Artist artist, TrackFile trackFile); public abstract IEnumerable<ExtraFile> CreateAfterTrackImport(Artist artist, TrackFile trackFile);
public abstract IEnumerable<ExtraFile> CreateAfterTrackImport(Artist artist, Album album, string artistFolder, string albumFolder); public abstract IEnumerable<ExtraFile> CreateAfterTrackFolder(Artist artist, Album album, string artistFolder, string albumFolder);
public abstract IEnumerable<ExtraFile> MoveFilesAfterRename(Artist artist, List<TrackFile> trackFiles); public abstract IEnumerable<ExtraFile> MoveFilesAfterRename(Artist artist, List<TrackFile> trackFiles);
public abstract ExtraFile Import(Artist artist, TrackFile trackFile, string path, string extension, bool readOnly); public abstract ExtraFile Import(Artist artist, TrackFile trackFile, string path, string extension, bool readOnly);

@ -33,6 +33,11 @@ namespace NzbDrone.Core.Extras.Lyrics
public override int Order => 1; public override int Order => 1;
public override IEnumerable<ExtraFile> CreateAfterMediaCoverUpdate(Artist artist)
{
return Enumerable.Empty<ExtraFile>();
}
public override IEnumerable<ExtraFile> CreateAfterArtistScan(Artist artist, List<TrackFile> trackFiles) public override IEnumerable<ExtraFile> CreateAfterArtistScan(Artist artist, List<TrackFile> trackFiles)
{ {
return Enumerable.Empty<LyricFile>(); return Enumerable.Empty<LyricFile>();
@ -43,7 +48,7 @@ namespace NzbDrone.Core.Extras.Lyrics
return Enumerable.Empty<LyricFile>(); return Enumerable.Empty<LyricFile>();
} }
public override IEnumerable<ExtraFile> CreateAfterTrackImport(Artist artist, Album album, string artistFolder, string albumFolder) public override IEnumerable<ExtraFile> CreateAfterTrackFolder(Artist artist, Album album, string artistFolder, string albumFolder)
{ {
return Enumerable.Empty<LyricFile>(); return Enumerable.Empty<LyricFile>();
} }

@ -59,6 +59,31 @@ namespace NzbDrone.Core.Extras.Metadata
public override int Order => 0; public override int Order => 0;
public override IEnumerable<ExtraFile> 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<MetadataFile>();
}
var files = new List<MetadataFile>();
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<ExtraFile> CreateAfterArtistScan(Artist artist, List<TrackFile> trackFiles) public override IEnumerable<ExtraFile> CreateAfterArtistScan(Artist artist, List<TrackFile> trackFiles)
{ {
var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id); var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id);
@ -114,7 +139,7 @@ namespace NzbDrone.Core.Extras.Metadata
return files; return files;
} }
public override IEnumerable<ExtraFile> CreateAfterTrackImport(Artist artist, Album album, string artistFolder, string albumFolder) public override IEnumerable<ExtraFile> CreateAfterTrackFolder(Artist artist, Album album, string artistFolder, string albumFolder)
{ {
var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id); var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id);

@ -29,6 +29,11 @@ namespace NzbDrone.Core.Extras.Others
public override int Order => 2; public override int Order => 2;
public override IEnumerable<ExtraFile> CreateAfterMediaCoverUpdate(Artist artist)
{
return Enumerable.Empty<ExtraFile>();
}
public override IEnumerable<ExtraFile> CreateAfterArtistScan(Artist artist, List<TrackFile> trackFiles) public override IEnumerable<ExtraFile> CreateAfterArtistScan(Artist artist, List<TrackFile> trackFiles)
{ {
return Enumerable.Empty<ExtraFile>(); return Enumerable.Empty<ExtraFile>();
@ -39,7 +44,7 @@ namespace NzbDrone.Core.Extras.Others
return Enumerable.Empty<ExtraFile>(); return Enumerable.Empty<ExtraFile>();
} }
public override IEnumerable<ExtraFile> CreateAfterTrackImport(Artist artist, Album album, string artistFolder, string albumFolder) public override IEnumerable<ExtraFile> CreateAfterTrackFolder(Artist artist, Album album, string artistFolder, string albumFolder)
{ {
return Enumerable.Empty<ExtraFile>(); return Enumerable.Empty<ExtraFile>();
} }

Loading…
Cancel
Save