diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Aggregation/AggregateFilenameInfoFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Aggregation/AggregateFilenameInfoFixture.cs index 61841c560..6bdcd39ad 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Aggregation/AggregateFilenameInfoFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Aggregation/AggregateFilenameInfoFixture.cs @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Aggregation.Aggregators private void VerifyData(LocalBook track, string author, string title, int trackNum, int disc) { track.FileTrackInfo.AuthorTitle.Should().Be(author); - track.FileTrackInfo.Title.Should().Be(title); + track.FileTrackInfo.BookTitle.Should().Be(title); track.FileTrackInfo.TrackNumbers[0].Should().Be(trackNum); track.FileTrackInfo.DiscNumber.Should().Be(disc); } @@ -172,21 +172,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Aggregation.Aggregators if (tokens.Contains("title")) { - info.Title.Should().Be($"{(char)(96 + i)} track title {i}".Replace(" ", whitespace)); - } - - if (tokens.Contains("trackNum2") || tokens.Contains("trackNum3")) - { - info.TrackNumbers[0].Should().Be(i); - } - - if (tokens.Contains("trackNum3")) - { - info.DiscNumber.Should().Be(1); - } - else - { - info.DiscNumber.Should().Be(0); + info.BookTitle.Should().Be($"{(char)(96 + i)} track title {i}".Replace(" ", whitespace)); } } } diff --git a/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateFilenameInfo.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateFilenameInfo.cs index 95958df78..6e1d1fbb9 100644 --- a/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateFilenameInfo.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Aggregation/Aggregators/AggregateFilenameInfo.cs @@ -58,9 +58,8 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators public LocalEdition Aggregate(LocalEdition release, bool others) { var tracks = release.LocalBooks; - if (tracks.Count(x => x.FileTrackInfo.Title.IsNullOrWhiteSpace()) > 0 - || tracks.Count(x => x.FileTrackInfo.TrackNumbers.First() == 0) > 0 - || tracks.Count(x => x.FileTrackInfo.DiscNumber == 0) > 0) + if (tracks.Any(x => x.FileTrackInfo.BookTitle.IsNullOrWhiteSpace()) + || tracks.Any(x => x.FileTrackInfo.AuthorTitle.IsNullOrWhiteSpace())) { _logger.Debug("Missing data in tags, trying filename augmentation"); foreach (var charSep in CharsAndSeps) @@ -163,11 +162,11 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators // Apply the title and track foreach (var track in matches.Keys) { - if (track.FileTrackInfo.Title.IsNullOrWhiteSpace()) + if (track.FileTrackInfo.BookTitle.IsNullOrWhiteSpace()) { var title = matches[track].Groups[titleField].Value.Trim(); _logger.Debug("Got title from filename: {0}", title); - track.FileTrackInfo.Title = title; + track.FileTrackInfo.BookTitle = title; } var trackNums = track.FileTrackInfo.TrackNumbers; diff --git a/src/NzbDrone.Core/MediaFiles/BookImport/Identification/DistanceCalculator.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/DistanceCalculator.cs index acf3d625a..9a737d069 100644 --- a/src/NzbDrone.Core/MediaFiles/BookImport/Identification/DistanceCalculator.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/DistanceCalculator.cs @@ -53,8 +53,11 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification { foreach (var l in edition.Book.Value.SeriesLinks.Value) { - titleOptions.Add($"{l.Series.Value.Title} {l.Position} {edition.Title}"); - titleOptions.Add($"{edition.Title} {l.Series.Value.Title} {l.Position}"); + if (l.Series?.Value?.Title?.IsNotNullOrWhiteSpace() ?? false) + { + titleOptions.Add($"{l.Series.Value.Title} {l.Position} {edition.Title}"); + titleOptions.Add($"{edition.Title} {l.Series.Value.Title} {l.Position}"); + } } } diff --git a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs index 89037db96..a56dd05a2 100644 --- a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs +++ b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs @@ -185,7 +185,8 @@ namespace NzbDrone.Core.MediaFiles Modified = decision.Item.Modified, DateAdded = DateTime.UtcNow, Quality = decision.Item.Quality, - MediaInfo = decision.Item.FileTrackInfo.MediaInfo + MediaInfo = decision.Item.FileTrackInfo.MediaInfo, + Edition = decision.Item.Edition }) .ToList(); _mediaFileService.AddMany(newFiles);