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)
{
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));
}
}
}

@ -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;

@ -52,11 +52,14 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification
if (edition.Book.Value.SeriesLinks?.Value?.Any() ?? false)
{
foreach (var l in edition.Book.Value.SeriesLinks.Value)
{
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}");
}
}
}
dist.AddString("book", title, titleOptions);
Logger.Trace("book: '{0}' vs '{1}'; {2}", title, titleOptions.ConcatToString("' or '"), dist.NormalizedDistance());

@ -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);

Loading…
Cancel
Save