diff options
| author | Bond-009 <bond.009@outlook.com> | 2026-11-06 09:36:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-06 09:36:52 +0100 |
| commit | deb2c9c59297003e9fa3372c9fdecee4f1beb1bf (patch) | |
| tree | b5d86856b3a90806de75df305d6d4a1f19fae247 /tests | |
| parent | de93ba4f545c278fbc81ec9c69e9d4f7814b01bc (diff) | |
| parent | a92a574be09dc415198ed7e5775ffd9ef2b44a58 (diff) | |
Merge pull request #17642 from mysticalsoap/fix-premiere-date-from-container-encode-date
Keep container creation time out of the premiere date chain
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeResultNormalizerTests.cs | 13 | ||||
| -rw-r--r-- | tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs | 141 |
2 files changed, 154 insertions, 0 deletions
diff --git a/tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeResultNormalizerTests.cs b/tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeResultNormalizerTests.cs index cf9930abe1..e68abf6947 100644 --- a/tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeResultNormalizerTests.cs +++ b/tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeResultNormalizerTests.cs @@ -291,6 +291,19 @@ namespace Jellyfin.MediaEncoding.Tests.Probing } [Fact] + public void GetMediaInfo_ContainerCreationTime_KeptOutOfPremiereDate() + { + var bytes = File.ReadAllBytes("Test Data/Probing/video_progressive_no_field_order.json"); + + var internalMediaInfoResult = JsonSerializer.Deserialize<InternalMediaInfoResult>(bytes, _jsonOptions); + MediaInfo res = _probeResultNormalizer.GetMediaInfo(internalMediaInfoResult, VideoType.VideoFile, false, "Test Data/Probing/video_progressive_no_field_order.mp4", MediaProtocol.File); + + Assert.Equal(new DateTime(2020, 1, 20, 13, 56, 34, DateTimeKind.Utc), res.ContainerCreationDate); + Assert.Null(res.PremiereDate); + Assert.Null(res.ProductionYear); + } + + [Fact] public void GetMediaInfo_ProgressiveVideoNoFieldOrder_Success() { var bytes = File.ReadAllBytes("Test Data/Probing/video_progressive_no_field_order.json"); diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs index 59d3f42edf..c4f25f3cb0 100644 --- a/tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs +++ b/tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs @@ -123,6 +123,141 @@ public class FFProbeVideoInfoTests Assert.Null(video.PremiereDate); } + [Theory] + [InlineData(false)] + [InlineData(true)] + public void FetchEmbeddedInfo_NoYear_AppliesContainerCreationDate(bool replaceAllMetadata) + { + var video = new Video(); + + _fFProbeVideoInfo.FetchEmbeddedInfo(video, CreateMediaInfoWithCreationDate(), CreateRefreshOptions(replaceAllMetadata), new LibraryOptions()); + + Assert.Equal(new DateTime(2025, 10, 24, 19, 38, 17, DateTimeKind.Utc), video.PremiereDate); + Assert.Equal(2025, video.ProductionYear); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public void FetchEmbeddedInfo_KnownYear_IgnoresContainerCreationDate(bool replaceAllMetadata) + { + var video = new Video + { + ProductionYear = 2007 + }; + + _fFProbeVideoInfo.FetchEmbeddedInfo(video, CreateMediaInfoWithCreationDate(), CreateRefreshOptions(replaceAllMetadata), new LibraryOptions()); + + Assert.Equal(2007, video.ProductionYear); + Assert.Null(video.PremiereDate); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public void FetchEmbeddedInfo_MatchingYear_AppliesContainerCreationDate(bool replaceAllMetadata) + { + var video = new Video + { + ProductionYear = 2025 + }; + + _fFProbeVideoInfo.FetchEmbeddedInfo(video, CreateMediaInfoWithCreationDate(), CreateRefreshOptions(replaceAllMetadata), new LibraryOptions()); + + Assert.Equal(2025, video.ProductionYear); + Assert.Equal(new DateTime(2025, 10, 24, 19, 38, 17, DateTimeKind.Utc), video.PremiereDate); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public void FetchEmbeddedInfo_KnownYear_StillAppliesTaggedPremiereDate(bool replaceAllMetadata) + { + var video = new Video + { + ProductionYear = 2007 + }; + + _fFProbeVideoInfo.FetchEmbeddedInfo(video, CreateMediaInfoWithDates(), CreateRefreshOptions(replaceAllMetadata), new LibraryOptions()); + + Assert.Equal(new DateTime(2016, 5, 4, 0, 0, 0, DateTimeKind.Utc), video.PremiereDate); + } + + [Fact] + public void FetchEmbeddedInfo_KnownYear_ReplacingAppliesTaggedProductionYear() + { + var video = new Video + { + ProductionYear = 2007 + }; + + _fFProbeVideoInfo.FetchEmbeddedInfo(video, CreateMediaInfoWithDates(), CreateRefreshOptions(true), new LibraryOptions()); + + Assert.Equal(2016, video.ProductionYear); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public void FetchEmbeddedInfo_TaggedDateAndSameYearCreationDate_PrefersTaggedDate(bool replaceAllMetadata) + { + var video = new Video(); + var mediaInfo = new MediaBrowser.Model.MediaInfo.MediaInfo + { + ProductionYear = 2025, + PremiereDate = new DateTime(2025, 5, 4, 0, 0, 0, DateTimeKind.Utc), + ContainerCreationDate = new DateTime(2025, 10, 24, 19, 38, 17, DateTimeKind.Utc) + }; + + _fFProbeVideoInfo.FetchEmbeddedInfo(video, mediaInfo, CreateRefreshOptions(replaceAllMetadata), new LibraryOptions()); + + Assert.Equal(new DateTime(2025, 5, 4, 0, 0, 0, DateTimeKind.Utc), video.PremiereDate); + } + + [Fact] + public void FetchEmbeddedInfo_ExistingPremiereDate_KeepsItOverCreationDate() + { + var video = new Video + { + ProductionYear = 2025, + PremiereDate = new DateTime(2025, 3, 1, 0, 0, 0, DateTimeKind.Utc) + }; + + _fFProbeVideoInfo.FetchEmbeddedInfo(video, CreateMediaInfoWithCreationDate(), CreateRefreshOptions(false), new LibraryOptions()); + + Assert.Equal(new DateTime(2025, 3, 1, 0, 0, 0, DateTimeKind.Utc), video.PremiereDate); + } + + [Fact] + public void FetchEmbeddedInfo_ExistingPremiereDate_ReplacingUsesCreationDate() + { + var video = new Video + { + ProductionYear = 2025, + PremiereDate = new DateTime(2025, 3, 1, 0, 0, 0, DateTimeKind.Utc) + }; + + _fFProbeVideoInfo.FetchEmbeddedInfo(video, CreateMediaInfoWithCreationDate(), CreateRefreshOptions(true), new LibraryOptions()); + + Assert.Equal(new DateTime(2025, 10, 24, 19, 38, 17, DateTimeKind.Utc), video.PremiereDate); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public void FetchEmbeddedInfo_ExtraWithCreationDate_StaysWithoutDates(bool replaceAllMetadata) + { + var video = new Video + { + ExtraType = ExtraType.Trailer + }; + + _fFProbeVideoInfo.FetchEmbeddedInfo(video, CreateMediaInfoWithCreationDate(), CreateRefreshOptions(replaceAllMetadata), new LibraryOptions()); + + Assert.Null(video.ProductionYear); + Assert.Null(video.PremiereDate); + } + private static MediaBrowser.Model.MediaInfo.MediaInfo CreateMediaInfoWithDates() => new() { @@ -130,6 +265,12 @@ public class FFProbeVideoInfoTests PremiereDate = new DateTime(2016, 5, 4, 0, 0, 0, DateTimeKind.Utc) }; + private static MediaBrowser.Model.MediaInfo.MediaInfo CreateMediaInfoWithCreationDate() + => new() + { + ContainerCreationDate = new DateTime(2025, 10, 24, 19, 38, 17, DateTimeKind.Utc) + }; + private static MetadataRefreshOptions CreateRefreshOptions(bool replaceAllMetadata) => new(Mock.Of<IDirectoryService>()) { |
