diff options
| author | mysticalsoap <github@esotericsuds.com> | 2026-09-15 16:31:24 -0400 |
|---|---|---|
| committer | mysticalsoap <github@esotericsuds.com> | 2026-10-15 17:35:24 -0400 |
| commit | 2416fb56b4904fcf1fbf561be0c05b37d2d0886f (patch) | |
| tree | 15ce903dc9b8602fa7337f736f7c7989c30457d5 | |
| parent | aec42b345e1a7da25ee5492183f12209338df688 (diff) | |
Ignore container dates that disagree with a known production year
| -rw-r--r-- | CONTRIBUTORS.md | 1 | ||||
| -rw-r--r-- | MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs | 9 | ||||
| -rw-r--r-- | tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs | 46 |
3 files changed, 54 insertions, 2 deletions
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index a01162a3b4..4a63fa3148 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -252,6 +252,7 @@ - [Daniel Aquino](https://github.com/chino) - [klizas](https://github.com/klizas) - [p27ZuH6CNAdzr](https://github.com/p27ZuH6CNAdzr) + - [mysticalsoap](https://github.com/mysticalsoap) # Emby Contributors diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 1cb8e09414..97bc316f00 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -434,7 +434,12 @@ namespace MediaBrowser.Providers.MediaInfo // Extras have no release date of their own, they inherit it from the item they belong to. var useContainerDates = video.ExtraType is null; - if (useContainerDates && data.ProductionYear is not null) + + // creation_time is the mux time, so ignore container dates that contradict a known year. + var containerYear = data.PremiereDate?.Year ?? data.ProductionYear; + var containerDatesAgree = video.ProductionYear is null || containerYear == video.ProductionYear; + + if (useContainerDates && containerDatesAgree && data.ProductionYear is not null) { if (video.ProductionYear is null || replaceData) { @@ -442,7 +447,7 @@ namespace MediaBrowser.Providers.MediaInfo } } - if (useContainerDates && data.PremiereDate is not null) + if (useContainerDates && containerDatesAgree && data.PremiereDate is not null) { if (video.PremiereDate is null || replaceData) { diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs index 59d3f42edf..dc781af771 100644 --- a/tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs +++ b/tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs @@ -94,6 +94,52 @@ public class FFProbeVideoInfoTests [Theory] [InlineData(false)] [InlineData(true)] + public void FetchEmbeddedInfo_MismatchedYear_IgnoresContainerDates(bool replaceAllMetadata) + { + var video = new Video + { + ProductionYear = 2007 + }; + + _fFProbeVideoInfo.FetchEmbeddedInfo(video, CreateMediaInfoWithDates(), CreateRefreshOptions(replaceAllMetadata), new LibraryOptions()); + + Assert.Equal(2007, video.ProductionYear); + Assert.Null(video.PremiereDate); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public void FetchEmbeddedInfo_MatchingYear_AppliesContainerDates(bool replaceAllMetadata) + { + var video = new Video + { + ProductionYear = 2016 + }; + + _fFProbeVideoInfo.FetchEmbeddedInfo(video, CreateMediaInfoWithDates(), CreateRefreshOptions(replaceAllMetadata), new LibraryOptions()); + + Assert.Equal(2016, video.ProductionYear); + Assert.Equal(new DateTime(2016, 5, 4, 0, 0, 0, DateTimeKind.Utc), video.PremiereDate); + } + + [Fact] + public void FetchEmbeddedInfo_NoContainerDates_DerivesYearFromPremiereDate() + { + var video = new Video + { + PremiereDate = new DateTime(1982, 6, 25, 0, 0, 0, DateTimeKind.Utc) + }; + + _fFProbeVideoInfo.FetchEmbeddedInfo(video, new MediaBrowser.Model.MediaInfo.MediaInfo(), CreateRefreshOptions(false), new LibraryOptions()); + + Assert.Equal(1982, video.ProductionYear); + Assert.Equal(new DateTime(1982, 6, 25, 0, 0, 0, DateTimeKind.Utc), video.PremiereDate); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] public void FetchEmbeddedInfo_Extra_IgnoresContainerDates(bool replaceAllMetadata) { var video = new Video |
