mirror of
https://github.com/Readarr/Readarr
synced 2025-12-27 02:32:27 +01:00
Fixed: Check language of book file matches edition language if possible
This commit is contained in:
parent
94adb4d582
commit
0031214fb3
2 changed files with 11 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ public class Distance
|
|||
{ "media_format", 1.0 },
|
||||
{ "year", 1.0 },
|
||||
{ "country", 0.5 },
|
||||
{ "language", 5.0 },
|
||||
{ "label", 0.5 },
|
||||
{ "catalog_number", 0.5 },
|
||||
{ "book_disambiguation", 0.5 },
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Books;
|
||||
using NzbDrone.Core.Books.Calibre;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
|
|
@ -113,6 +114,15 @@ public static Distance BookDistance(List<LocalBook> localTracks, Edition edition
|
|||
Logger.Trace($"year: {localYear} vs {edition.ReleaseDate?.Year}; {dist.NormalizedDistance()}");
|
||||
}
|
||||
|
||||
// Language - only if set for both the local book and remote edition
|
||||
var localLanguage = localTracks.MostCommon(x => x.FileTrackInfo.Language).CanonicalizeLanguage();
|
||||
var editionLanguage = edition.Language.CanonicalizeLanguage();
|
||||
if (localLanguage.IsNotNullOrWhiteSpace() && editionLanguage.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
dist.AddBool("language", localLanguage != editionLanguage);
|
||||
Logger.Trace($"language: {localLanguage} vs {editionLanguage}; {dist.NormalizedDistance()}");
|
||||
}
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue