Fixed: Trying to get book details from filename when already obtained from tags

pull/838/head
ta264 4 years ago
parent 446a0591db
commit 791bba471f

@ -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) private void VerifyData(LocalBook track, string author, string title, int trackNum, int disc)
{ {
track.FileTrackInfo.AuthorTitle.Should().Be(author); 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.TrackNumbers[0].Should().Be(trackNum);
track.FileTrackInfo.DiscNumber.Should().Be(disc); track.FileTrackInfo.DiscNumber.Should().Be(disc);
} }
@ -172,21 +172,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Aggregation.Aggregators
if (tokens.Contains("title")) if (tokens.Contains("title"))
{ {
info.Title.Should().Be($"{(char)(96 + i)} track title {i}".Replace(" ", whitespace)); info.BookTitle.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);
} }
} }
} }

@ -58,9 +58,8 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators
public LocalEdition Aggregate(LocalEdition release, bool others) public LocalEdition Aggregate(LocalEdition release, bool others)
{ {
var tracks = release.LocalBooks; var tracks = release.LocalBooks;
if (tracks.Count(x => x.FileTrackInfo.Title.IsNullOrWhiteSpace()) > 0 if (tracks.Any(x => x.FileTrackInfo.BookTitle.IsNullOrWhiteSpace())
|| tracks.Count(x => x.FileTrackInfo.TrackNumbers.First() == 0) > 0 || tracks.Any(x => x.FileTrackInfo.AuthorTitle.IsNullOrWhiteSpace()))
|| tracks.Count(x => x.FileTrackInfo.DiscNumber == 0) > 0)
{ {
_logger.Debug("Missing data in tags, trying filename augmentation"); _logger.Debug("Missing data in tags, trying filename augmentation");
foreach (var charSep in CharsAndSeps) foreach (var charSep in CharsAndSeps)
@ -163,11 +162,11 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators
// Apply the title and track // Apply the title and track
foreach (var track in matches.Keys) foreach (var track in matches.Keys)
{ {
if (track.FileTrackInfo.Title.IsNullOrWhiteSpace()) if (track.FileTrackInfo.BookTitle.IsNullOrWhiteSpace())
{ {
var title = matches[track].Groups[titleField].Value.Trim(); var title = matches[track].Groups[titleField].Value.Trim();
_logger.Debug("Got title from filename: {0}", title); _logger.Debug("Got title from filename: {0}", title);
track.FileTrackInfo.Title = title; track.FileTrackInfo.BookTitle = title;
} }
var trackNums = track.FileTrackInfo.TrackNumbers; var trackNums = track.FileTrackInfo.TrackNumbers;

@ -53,8 +53,11 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification
{ {
foreach (var l in edition.Book.Value.SeriesLinks.Value) foreach (var l in edition.Book.Value.SeriesLinks.Value)
{ {
titleOptions.Add($"{l.Series.Value.Title} {l.Position} {edition.Title}"); if (l.Series?.Value?.Title?.IsNotNullOrWhiteSpace() ?? false)
titleOptions.Add($"{edition.Title} {l.Series.Value.Title} {l.Position}"); {
titleOptions.Add($"{l.Series.Value.Title} {l.Position} {edition.Title}");
titleOptions.Add($"{edition.Title} {l.Series.Value.Title} {l.Position}");
}
} }
} }

@ -185,7 +185,8 @@ namespace NzbDrone.Core.MediaFiles
Modified = decision.Item.Modified, Modified = decision.Item.Modified,
DateAdded = DateTime.UtcNow, DateAdded = DateTime.UtcNow,
Quality = decision.Item.Quality, Quality = decision.Item.Quality,
MediaInfo = decision.Item.FileTrackInfo.MediaInfo MediaInfo = decision.Item.FileTrackInfo.MediaInfo,
Edition = decision.Item.Edition
}) })
.ToList(); .ToList();
_mediaFileService.AddMany(newFiles); _mediaFileService.AddMany(newFiles);

Loading…
Cancel
Save