private ImportDecision <LocalAlbumRelease> GetDecision(LocalAlbumRelease localAlbumRelease, DownloadClientItem downloadClientItem) { ImportDecision <LocalAlbumRelease> decision = null; if (localAlbumRelease.AlbumRelease == null) { decision = new ImportDecision <LocalAlbumRelease>(localAlbumRelease, new Rejection($"Couldn't find similar album for {localAlbumRelease}")); } else { var reasons = _albumSpecifications.Select(c => EvaluateSpec(c, localAlbumRelease, downloadClientItem)) .Where(c => c != null); decision = new ImportDecision <LocalAlbumRelease>(localAlbumRelease, reasons.ToArray()); } if (decision == null) { _logger.Error("Unable to make a decision on {0}", localAlbumRelease); } else if (decision.Rejections.Any()) { _logger.Debug("Album rejected for the following reasons: {0}", string.Join(", ", decision.Rejections)); } else { _logger.Debug("Album accepted"); } return(decision); }
private ImportDecision <LocalTrack> GetDecision(LocalTrack localTrack, DownloadClientItem downloadClientItem) { ImportDecision <LocalTrack> decision = null; if (localTrack.Tracks.Empty()) { decision = localTrack.Album != null ? new ImportDecision <LocalTrack>(localTrack, new Rejection($"Couldn't parse track from: {localTrack.FileTrackInfo}")) : new ImportDecision <LocalTrack>(localTrack, new Rejection($"Couldn't parse album from: {localTrack.FileTrackInfo}")); } else { var reasons = _trackSpecifications.Select(c => EvaluateSpec(c, localTrack, downloadClientItem)) .Where(c => c != null); decision = new ImportDecision <LocalTrack>(localTrack, reasons.ToArray()); } if (decision == null) { _logger.Error("Unable to make a decision on {0}", localTrack.Path); } else if (decision.Rejections.Any()) { _logger.Debug("File rejected for the following reasons: {0}", string.Join(", ", decision.Rejections)); } else { _logger.Debug("File accepted"); } return(decision); }
public ImportResult(ImportDecision <LocalTrack> importDecision, params string[] errors) { Ensure.That(importDecision, () => importDecision).IsNotNull(); ImportDecision = importDecision; Errors = errors.ToList(); }