diff options
| -rw-r--r-- | MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs | 12 | ||||
| -rw-r--r-- | tests/Jellyfin.Providers.Tests/Tmdb/TmdbUtilsTests.cs | 13 |
2 files changed, 16 insertions, 9 deletions
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs b/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs index c8db90799d..4ef8c53b30 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs @@ -41,8 +41,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb private const int TitleExactScore = 8; private const int TitlePrefixScore = 4; - private const int YearExactScore = 2; - private const int YearAdjacentScore = 1; + private const int YearScore = 2; /// <summary> /// The crew types to keep. @@ -251,13 +250,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb return 0; } - return Math.Abs(candidateYear - year) switch - { - 0 => YearExactScore, - // Regional release dates routinely straddle a new year. - 1 => YearAdjacentScore, - _ => 0 - }; + // Regional and festival release dates routinely straddle a new year, so a year off by one is as good as an exact one. + return Math.Abs(candidateYear - year) <= 1 ? YearScore : 0; } /// <summary> diff --git a/tests/Jellyfin.Providers.Tests/Tmdb/TmdbUtilsTests.cs b/tests/Jellyfin.Providers.Tests/Tmdb/TmdbUtilsTests.cs index 8342621d97..6e36c08064 100644 --- a/tests/Jellyfin.Providers.Tests/Tmdb/TmdbUtilsTests.cs +++ b/tests/Jellyfin.Providers.Tests/Tmdb/TmdbUtilsTests.cs @@ -219,6 +219,19 @@ namespace Jellyfin.Providers.Tests.Tmdb [Movie(1, "Some Movie", "Some Movie", 2015), Movie(2, "Some Movie", "Some Movie", 2010)], 2 }, + // M. Night Shyamalan's Split premiered at a festival in 2016 and was released in 2017, so the obscure + // 2016 film of the same name must not outrank it. Years one apart tie and TMDb's own ordering decides. + { + "Split (2016)", "Split", 2016, + [Movie(381288, "Split", "Split", 2017), Movie(358364, "Split", "Split", 2016)], + 381288 + }, + // Two years apart is a different film, so the tie only covers a year off by one. + { + "Two years apart", "Some Movie", 2016, + [Movie(1, "Some Movie", "Some Movie", 2018), Movie(2, "Some Movie", "Some Movie", 2016)], + 2 + }, // Nothing matches the name, so TMDb's own ordering is kept. { "A Christmas No. 1 (2021)", "A Christmas No. 1", 2021, |
