aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Library/VersionResumeData.cs
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2026-08-01 14:25:20 +0200
committerShadowghost <Ghost_of_Stone@web.de>2026-08-01 14:25:20 +0200
commitb94ba9d409abd48b9e01bee8c039e85d951505ab (patch)
treec27d4734d351941cb5d01b2145374cd264702b0a /MediaBrowser.Controller/Library/VersionResumeData.cs
parent5a2809e33725631ed25c0361331060e1821b66de (diff)
parentc55fde25a54e9d2c2ba0e781d4a6f790990f85bd (diff)
Merge remote-tracking branch 'upstream/master' into tmdb-missing-episodes
# Conflicts: # Jellyfin.Server.Implementations/Item/BaseItemRepository.QueryBuilding.cs
Diffstat (limited to 'MediaBrowser.Controller/Library/VersionResumeData.cs')
-rw-r--r--MediaBrowser.Controller/Library/VersionResumeData.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Library/VersionResumeData.cs b/MediaBrowser.Controller/Library/VersionResumeData.cs
new file mode 100644
index 0000000000..772e2bf3a7
--- /dev/null
+++ b/MediaBrowser.Controller/Library/VersionResumeData.cs
@@ -0,0 +1,41 @@
+using System;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Dto;
+
+namespace MediaBrowser.Controller.Library
+{
+ /// <summary>
+ /// The user data of the most recently played alternate version that should drive the completion state of a multi-version item.
+ /// </summary>
+ /// <param name="VersionId">The id of the version that owns <paramref name="UserData"/>.</param>
+ /// <param name="UserData">The resume version's user data.</param>
+ public record VersionResumeData(Guid VersionId, UserItemData UserData)
+ {
+ /// <summary>
+ /// Merges the most recently played version's completion state into the supplied user data dto.
+ /// Completion (played) propagates to the primary. An in-progress resume position stays on the version
+ /// that owns it, which is surfaced directly (e.g. in resume queries) so that playback always targets
+ /// the correct version rather than resuming the primary at another version's offset. When the movie was
+ /// finished on a different version, the primary's own stale resume position is cleared so it does not
+ /// render as "watched and resumable" at the same time.
+ /// </summary>
+ /// <param name="dto">The user data dto to update.</param>
+ public void ApplyTo(UserItemDataDto dto)
+ {
+ dto.Played = dto.Played || UserData.Played;
+
+ if ((UserData.LastPlayedDate ?? DateTime.MinValue) > (dto.LastPlayedDate ?? DateTime.MinValue))
+ {
+ dto.LastPlayedDate = UserData.LastPlayedDate;
+ }
+
+ // A different version was finished (played, no resume position of its own) and is the most
+ // recently played: the whole movie is watched.
+ if (!VersionId.Equals(dto.ItemId) && UserData.Played && UserData.PlaybackPositionTicks <= 0)
+ {
+ dto.PlaybackPositionTicks = 0;
+ dto.PlayedPercentage = null;
+ }
+ }
+ }
+}