Esempio n. 1
0
        public override IEnumerable <ExtraFile> CreateAfterSeriesScan(Series series, List <EpisodeFile> episodeFiles)
        {
            var metadataFiles = _metadataFileService.GetFilesBySeries(series.Id);

            _cleanMetadataService.Clean(series);

            if (!_diskProvider.FolderExists(series.Path))
            {
                _logger.Info("Series folder does not exist, skipping metadata creation");
                return(Enumerable.Empty <MetadataFile>());
            }

            var files = new List <MetadataFile>();

            foreach (var consumer in _metadataFactory.Enabled())
            {
                var consumerFiles = GetMetadataFilesForConsumer(consumer, metadataFiles);

                files.AddIfNotNull(ProcessSeriesMetadata(consumer, series, consumerFiles));
                files.AddRange(ProcessSeriesImages(consumer, series, consumerFiles));
                files.AddRange(ProcessSeasonImages(consumer, series, consumerFiles));

                foreach (var episodeFile in episodeFiles)
                {
                    files.AddIfNotNull(ProcessEpisodeMetadata(consumer, series, episodeFile, consumerFiles));
                    files.AddRange(ProcessEpisodeImages(consumer, series, episodeFile, consumerFiles));
                }
            }

            _metadataFileService.Upsert(files);

            return(files);
        }
Esempio n. 2
0
        public void Handle(MediaCoversUpdatedEvent message)
        {
            _cleanMetadataService.Clean(message.Series);

            if (!_diskProvider.FolderExists(message.Series.Path))
            {
                _logger.Info("Series folder does not exist, skipping metadata creation");
                return;
            }

            var seriesMetadataFiles = _metadataFileService.GetFilesBySeries(message.Series.Id);
            var episodeFiles        = GetEpisodeFiles(message.Series.Id);

            foreach (var consumer in _metadataFactory.Enabled())
            {
                var consumerFiles = GetMetadataFilesForConsumer(consumer, seriesMetadataFiles);
                var files         = new List <MetadataFile>();

                files.AddIfNotNull(ProcessSeriesMetadata(consumer, message.Series, consumerFiles));
                files.AddRange(ProcessSeriesImages(consumer, message.Series, consumerFiles));
                files.AddRange(ProcessSeasonImages(consumer, message.Series, consumerFiles));

                foreach (var episodeFile in episodeFiles)
                {
                    files.AddIfNotNull(ProcessEpisodeMetadata(consumer, message.Series, episodeFile, consumerFiles));
                    files.AddRange(ProcessEpisodeImages(consumer, message.Series, episodeFile, consumerFiles));
                }

                _eventAggregator.PublishEvent(new MetadataFilesUpdated(files));
            }
        }
        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);
        }
Esempio n. 4
0
        public void Handle(MediaCoversUpdatedEvent message)
        {
            _cleanMetadataService.Clean(message.Series);
            var seriesMetadata = _metadataFileService.GetFilesBySeries(message.Series.Id);

            foreach (var consumer in _metadataFactory.Enabled())
            {
                consumer.OnSeriesUpdated(message.Series, GetMetadataFilesForConsumer(consumer, seriesMetadata), GetEpisodeFiles(message.Series.Id));
            }
        }
Esempio n. 5
0
        public void Clean()
        {
            if (!_configService.CleanupMetadataImages)
            {
                return;
            }

            var series = _seriesService.GetAllSeries();

            foreach (var show in series)
            {
                var images = _metadataFileService.GetFilesBySeries(show.Id)
                             .Where(c => c.LastUpdated > new DateTime(2014, 12, 27) && c.RelativePath.EndsWith(".jpg", StringComparison.InvariantCultureIgnoreCase));

                foreach (var image in images)
                {
                    try
                    {
                        var path = Path.Combine(show.Path, image.RelativePath);
                        if (!IsValid(path))
                        {
                            _logger.Debug("Deleting invalid image file " + path);
                            DeleteMetadata(image.Id, path);
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.ErrorException("Couldn't validate image " + image.RelativePath, e);
                    }
                }
            }


            _configService.CleanupMetadataImages = false;
        }
Esempio n. 6
0
        public void Clean(Series series)
        {
            _logger.Debug("Cleaning missing metadata files for series: {0}", series.Title);

            var metadataFiles = _metadataFileService.GetFilesBySeries(series.Id);

            foreach (var metadataFile in metadataFiles)
            {
                if (!_diskProvider.FileExists(Path.Combine(series.Path, metadataFile.RelativePath)))
                {
                    _logger.Debug("Deleting metadata file from database: {0}", metadataFile.RelativePath);
                    _metadataFileService.Delete(metadataFile.Id);
                }
            }
        }