Esempio n. 1
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);
        }
Esempio n. 2
0
        public override IEnumerable <ExtraFile> CreateAfterArtistScan(Artist artist, List <TrackFile> trackFiles)
        {
            var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id);

            _cleanMetadataService.Clean(artist);

            if (!_diskProvider.FolderExists(artist.Path))
            {
                _logger.Info("Artist 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(ProcessArtistMetadata(consumer, artist, consumerFiles));
                files.AddRange(ProcessArtistImages(consumer, artist, consumerFiles));

                var albumGroups = trackFiles.GroupBy(s => Path.GetDirectoryName(s.Path)).ToList();

                foreach (var group in albumGroups)
                {
                    var album       = _albumService.GetAlbum(group.First().AlbumId);
                    var albumFolder = group.Key;
                    files.AddIfNotNull(ProcessAlbumMetadata(consumer, artist, album, albumFolder, consumerFiles));
                    files.AddRange(ProcessAlbumImages(consumer, artist, album, albumFolder, consumerFiles));

                    foreach (var trackFile in group)
                    {
                        files.AddIfNotNull(ProcessTrackMetadata(consumer, artist, trackFile, consumerFiles));
                    }
                }
            }

            _metadataFileService.Upsert(files);

            return(files);
        }
Esempio n. 3
0
        public void Clean(Artist artist)
        {
            _logger.Debug("Cleaning missing metadata files for artist: {0}", artist.Name);

            var metadataFiles = _metadataFileService.GetFilesByArtist(artist.Id);

            foreach (var metadataFile in metadataFiles)
            {
                if (!_diskProvider.FileExists(Path.Combine(artist.Path, metadataFile.RelativePath)))
                {
                    _logger.Debug("Deleting metadata file from database: {0}", metadataFile.RelativePath);
                    _metadataFileService.Delete(metadataFile.Id);
                }
            }
        }
Esempio n. 4
0
        public void Clean()
        {
            if (!_configService.CleanupMetadataImages)
            {
                return;
            }

            var artists         = _artistService.GetAllArtists();
            var imageExtensions = new List <string> {
                ".jpg", ".png", ".gif"
            };

            foreach (var artist in artists)
            {
                var images = _metaFileService.GetFilesByArtist(artist.Id)
                             .Where(c => c.LastUpdated > new DateTime(2014, 12, 27) && imageExtensions.Any(x => c.RelativePath.EndsWith(x, StringComparison.InvariantCultureIgnoreCase)));

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


            _configService.CleanupMetadataImages = false;
        }