mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-10-23 03:27:39 +09:00
Backport pull request #18343 from jellyfin/release-12.z
Treat a year off by one as a tie in TMDb result ranking
Original-merge: 2002095e0f
Merged-by: crobibero <cody@robibe.ro>
Backported-by: Bond_009 <bond.009@outlook.com>
This commit is contained in:
1 parent
f624cb4cc5
commit
34768404f7
2 files changed
+16
-9
No files matched your search
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user