Clean up stale Continue Watching entries
Livestreams and ended broadcasts accumulated in every user's resume row
because Jellyfin saves a playback position for channel items regardless
of whether the position means anything. A livestream has nothing to
return to, so the entry stayed pinned forever.
Two parts:
- PlaybackResumeGuard, an IHostedService on ISessionManager.PlaybackStopped.
Jellyfin saves the resume point before raising the event, so the guard
zeroes it afterwards for livestreams. Stops new entries at the source.
- ResumeCleanupService plus a daily 4 AM task (after the 3 AM expiration
check) for the existing backlog. Clears livestreams, resume points older
than N days, positions under N seconds and playback past N% of runtime,
each threshold configurable.
Only plugin-owned items are touched, matched by the SRF provider ID with a
fallback to the owning channel ID so recordings are covered too. Clearing
sets PlaybackPositionTicks to 0 and leaves Played false: nothing is deleted
and the item stays unwatched.
Config page gains the thresholds plus "Clean Up Stale Entries Now" and
"Clear All SRF Play Entries" buttons, backed by MaintenanceController
under RequiresElevation.
Also folds the duplicated urn.Contains("livestream") check in
MediaSourceFactory and RecordingService into UrnHelper.IsLivestreamUrn.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -76,6 +76,11 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
EnabledTopics = new System.Collections.Generic.List<string>();
|
||||
GenerateTitleCards = true;
|
||||
LiveStartSegmentsBack = 3;
|
||||
CleanUpResumePoints = true;
|
||||
ClearLiveStreamResumePoints = true;
|
||||
ResumePointMaxAgeDays = 30;
|
||||
ResumePointMinPositionSeconds = 60;
|
||||
ResumePointCompletedPercent = 92;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -173,4 +178,37 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
/// Set to 0 to disable injection entirely.
|
||||
/// </summary>
|
||||
public int LiveStartSegmentsBack { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the "Clean Up SRF Play Continue Watching" task
|
||||
/// removes stale resume points. When false the task inspects nothing and clears nothing.
|
||||
/// </summary>
|
||||
public bool CleanUpResumePoints { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether resume points for livestreams are cleared.
|
||||
/// A livestream has no meaningful resume position, so stopping one otherwise leaves it
|
||||
/// pinned in "Continue Watching" forever. When enabled the position is also cleared
|
||||
/// immediately on playback stop, not just by the scheduled task.
|
||||
/// </summary>
|
||||
public bool ClearLiveStreamResumePoints { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the age in days after which an untouched resume point is cleared.
|
||||
/// Measured from the last time the item was played. Set to 0 to disable the age rule.
|
||||
/// </summary>
|
||||
public int ResumePointMaxAgeDays { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum resume position in seconds. Anything at or below this is
|
||||
/// treated as an accidental start rather than something worth resuming.
|
||||
/// Set to 0 to disable the rule.
|
||||
/// </summary>
|
||||
public int ResumePointMinPositionSeconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the percentage of runtime at or beyond which playback counts as finished.
|
||||
/// Only applied to items with a known runtime. Set to 0 to disable the rule.
|
||||
/// </summary>
|
||||
public int ResumePointCompletedPercent { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user