private Artist SetPropertiesAndValidate(Artist newArtist) { if (string.IsNullOrWhiteSpace(newArtist.Path)) { var folderName = _fileNameBuilder.GetArtistFolder(newArtist); newArtist.Path = Path.Combine(newArtist.RootFolderPath, folderName); } newArtist.CleanName = newArtist.Metadata.Value.Name.CleanArtistName(); newArtist.SortName = ArtistNameNormalizer.Normalize(newArtist.Metadata.Value.Name, newArtist.Metadata.Value.ForeignArtistId); newArtist.Added = DateTime.UtcNow; if (newArtist.AddOptions != null && newArtist.AddOptions.Monitor == MonitorTypes.None) { newArtist.Monitored = false; } var validationResult = _addArtistValidator.Validate(newArtist); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } return(newArtist); }
private Artist SetPropertiesAndValidate(Artist newArtist) { var path = newArtist.Path; if (string.IsNullOrWhiteSpace(path)) { var folderName = _fileNameBuilder.GetArtistFolder(newArtist); path = Path.Combine(newArtist.RootFolderPath, folderName); } // Disambiguate artist path if it exists already if (_artistService.ArtistPathExists(path)) { if (newArtist.Metadata.Value.Disambiguation.IsNotNullOrWhiteSpace()) { path += $" ({newArtist.Metadata.Value.Disambiguation})"; } if (_artistService.ArtistPathExists(path)) { var basepath = path; int i = 0; do { i++; path = basepath + $" ({i})"; }while (_artistService.ArtistPathExists(path)); } } newArtist.Path = path; newArtist.CleanName = newArtist.Metadata.Value.Name.CleanArtistName(); newArtist.SortName = Parser.Parser.NormalizeTitle(newArtist.Metadata.Value.Name).ToLower(); newArtist.Added = DateTime.UtcNow; if (newArtist.AddOptions != null && newArtist.AddOptions.Monitor == MonitorTypes.None) { newArtist.Monitored = false; } var validationResult = _addArtistValidator.Validate(newArtist); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } return(newArtist); }
public string BuildPath(Artist artist, bool useExistingRelativeFolder) { if (artist.RootFolderPath.IsNullOrWhiteSpace()) { throw new ArgumentException("Root folder was not provided", nameof(artist)); } if (useExistingRelativeFolder && artist.Path.IsNotNullOrWhiteSpace()) { var relativePath = GetExistingRelativePath(artist); return(Path.Combine(artist.RootFolderPath, relativePath)); } return(Path.Combine(artist.RootFolderPath, _fileNameBuilder.GetArtistFolder(artist))); }
public void Execute(BulkMoveArtistCommand message) { var artistToMove = message.Artist; var destinationRootFolder = message.DestinationRootFolder; _logger.ProgressInfo("Moving {0} artist to '{1}'", artistToMove.Count, destinationRootFolder); for (var index = 0; index < artistToMove.Count; index++) { var s = artistToMove[index]; var artist = _artistService.GetArtist(s.ArtistId); var destinationPath = Path.Combine(destinationRootFolder, _filenameBuilder.GetArtistFolder(artist)); MoveSingleArtist(artist, s.SourcePath, destinationPath, index, artistToMove.Count); } _logger.ProgressInfo("Finished moving {0} artist to '{1}'", artistToMove.Count, destinationRootFolder); }
public string GetArtistFolderSample(NamingConfig nameSpec) { return(_buildFileNames.GetArtistFolder(_standardArtist, nameSpec)); }