Fixed: Generating Kodi episode metadata files when scanning series folder

This commit is contained in:
Taloth Saldono 2020-04-28 23:30:18 +02:00
parent b8e2f3d716
commit 23dc7794f1
5 changed files with 59 additions and 8 deletions

View File

@ -24,6 +24,7 @@ namespace NzbDrone.Core.Extras
public class ExtraService : IExtraService,
IHandle<MediaCoversUpdatedEvent>,
IHandle<EpisodeFolderCreatedEvent>,
IHandle<SeriesScannedEvent>,
IHandle<SeriesRenamedEvent>
{
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);
}
}

View File

@ -14,9 +14,10 @@ namespace NzbDrone.Core.Extras.Files
public interface IManageExtraFiles
{
int Order { get; }
IEnumerable<ExtraFile> CreateAfterMediaCoverUpdate(Series series);
IEnumerable<ExtraFile> CreateAfterSeriesScan(Series series, List<EpisodeFile> episodeFiles);
IEnumerable<ExtraFile> CreateAfterEpisodeImport(Series series, EpisodeFile episodeFile);
IEnumerable<ExtraFile> CreateAfterEpisodeImport(Series series, string seriesFolder, string seasonFolder);
IEnumerable<ExtraFile> CreateAfterEpisodeFolder(Series series, string seriesFolder, string seasonFolder);
IEnumerable<ExtraFile> MoveFilesAfterRename(Series series, List<EpisodeFile> 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<ExtraFile> CreateAfterMediaCoverUpdate(Series series);
public abstract IEnumerable<ExtraFile> CreateAfterSeriesScan(Series series, List<EpisodeFile> episodeFiles);
public abstract IEnumerable<ExtraFile> CreateAfterEpisodeImport(Series series, EpisodeFile episodeFile);
public abstract IEnumerable<ExtraFile> CreateAfterEpisodeImport(Series series, string seriesFolder, string seasonFolder);
public abstract IEnumerable<ExtraFile> CreateAfterEpisodeFolder(Series series, string seriesFolder, string seasonFolder);
public abstract IEnumerable<ExtraFile> MoveFilesAfterRename(Series series, List<EpisodeFile> episodeFiles);
public abstract ExtraFile Import(Series series, EpisodeFile episodeFile, string path, string extension, bool readOnly);

View File

@ -56,6 +56,31 @@ namespace NzbDrone.Core.Extras.Metadata
public override int Order => 0;
public override IEnumerable<ExtraFile> 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<MetadataFile>();
}
var files = new List<MetadataFile>();
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<ExtraFile> CreateAfterSeriesScan(Series series, List<EpisodeFile> episodeFiles)
{
var metadataFiles = _metadataFileService.GetFilesBySeries(series.Id);
@ -104,7 +129,7 @@ namespace NzbDrone.Core.Extras.Metadata
return files;
}
public override IEnumerable<ExtraFile> CreateAfterEpisodeImport(Series series, string seriesFolder, string seasonFolder)
public override IEnumerable<ExtraFile> CreateAfterEpisodeFolder(Series series, string seriesFolder, string seasonFolder)
{
var metadataFiles = _metadataFileService.GetFilesBySeries(series.Id);

View File

@ -31,6 +31,11 @@ namespace NzbDrone.Core.Extras.Others
public override int Order => 2;
public override IEnumerable<ExtraFile> CreateAfterMediaCoverUpdate(Series series)
{
return Enumerable.Empty<ExtraFile>();
}
public override IEnumerable<ExtraFile> CreateAfterSeriesScan(Series series, List<EpisodeFile> episodeFiles)
{
return Enumerable.Empty<ExtraFile>();
@ -41,7 +46,7 @@ namespace NzbDrone.Core.Extras.Others
return Enumerable.Empty<ExtraFile>();
}
public override IEnumerable<ExtraFile> CreateAfterEpisodeImport(Series series, string seriesFolder, string seasonFolder)
public override IEnumerable<ExtraFile> CreateAfterEpisodeFolder(Series series, string seriesFolder, string seasonFolder)
{
return Enumerable.Empty<ExtraFile>();
}

View File

@ -35,6 +35,11 @@ namespace NzbDrone.Core.Extras.Subtitles
public override int Order => 1;
public override IEnumerable<ExtraFile> CreateAfterMediaCoverUpdate(Series series)
{
return Enumerable.Empty<SubtitleFile>();
}
public override IEnumerable<ExtraFile> CreateAfterSeriesScan(Series series, List<EpisodeFile> episodeFiles)
{
return Enumerable.Empty<SubtitleFile>();
@ -45,7 +50,7 @@ namespace NzbDrone.Core.Extras.Subtitles
return Enumerable.Empty<SubtitleFile>();
}
public override IEnumerable<ExtraFile> CreateAfterEpisodeImport(Series series, string seriesFolder, string seasonFolder)
public override IEnumerable<ExtraFile> CreateAfterEpisodeFolder(Series series, string seriesFolder, string seasonFolder)
{
return Enumerable.Empty<SubtitleFile>();
}