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>
68 lines
3.2 KiB
C#
68 lines
3.2 KiB
C#
using Jellyfin.Plugin.SRFPlay.Api;
|
|
using Jellyfin.Plugin.SRFPlay.Channels;
|
|
using Jellyfin.Plugin.SRFPlay.Providers;
|
|
using Jellyfin.Plugin.SRFPlay.ScheduledTasks;
|
|
using Jellyfin.Plugin.SRFPlay.Services;
|
|
using Jellyfin.Plugin.SRFPlay.Services.Interfaces;
|
|
using MediaBrowser.Controller;
|
|
using MediaBrowser.Controller.Channels;
|
|
using MediaBrowser.Controller.Plugins;
|
|
using MediaBrowser.Model.Tasks;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Jellyfin.Plugin.SRFPlay;
|
|
|
|
/// <summary>
|
|
/// Service registrator for dependency injection.
|
|
/// </summary>
|
|
public class ServiceRegistrator : IPluginServiceRegistrator
|
|
{
|
|
/// <inheritdoc />
|
|
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
|
|
{
|
|
// Register API client factory
|
|
serviceCollection.AddSingleton<ISRFApiClientFactory, SRFApiClientFactory>();
|
|
|
|
// Register core services with interfaces
|
|
serviceCollection.AddSingleton<IMetadataCache, MetadataCache>();
|
|
serviceCollection.AddSingleton<IStreamUrlResolver, StreamUrlResolver>();
|
|
serviceCollection.AddSingleton<IMediaCompositionFetcher, MediaCompositionFetcher>();
|
|
serviceCollection.AddSingleton<IStreamProxyService, StreamProxyService>();
|
|
serviceCollection.AddSingleton<IMediaSourceFactory, MediaSourceFactory>();
|
|
serviceCollection.AddSingleton<IContentExpirationService, ContentExpirationService>();
|
|
serviceCollection.AddSingleton<IContentRefreshService, ContentRefreshService>();
|
|
serviceCollection.AddSingleton<ICategoryService, CategoryService>();
|
|
serviceCollection.AddSingleton<IResumeCleanupService, ResumeCleanupService>();
|
|
|
|
// Clears livestream resume points the moment playback stops, so ended broadcasts never
|
|
// linger in "Continue Watching" waiting for the nightly cleanup task.
|
|
serviceCollection.AddHostedService<PlaybackResumeGuard>();
|
|
|
|
// Register metadata providers
|
|
serviceCollection.AddSingleton<SRFSeriesProvider>();
|
|
serviceCollection.AddSingleton<SRFEpisodeProvider>();
|
|
serviceCollection.AddSingleton<SRFImageProvider>();
|
|
|
|
// Register media source provider
|
|
serviceCollection.AddSingleton<SRFMediaProvider>();
|
|
|
|
// Register recording service
|
|
serviceCollection.AddSingleton<IRecordingService, RecordingService>();
|
|
|
|
// Register scheduled tasks
|
|
serviceCollection.AddSingleton<IScheduledTask, ContentRefreshTask>();
|
|
serviceCollection.AddSingleton<IScheduledTask, ExpirationCheckTask>();
|
|
serviceCollection.AddSingleton<IScheduledTask, RecordingSchedulerTask>();
|
|
serviceCollection.AddSingleton<IScheduledTask, ResumeCleanupTask>();
|
|
|
|
// Register one channel (tile) per SRG business unit. Each must be registered as IChannel
|
|
// for Jellyfin to discover it. A unit that is not in EnabledBusinessUnits returns no
|
|
// content (its tile appears empty) - see SrgChannelBase.
|
|
serviceCollection.AddSingleton<IChannel, SrfChannel>();
|
|
serviceCollection.AddSingleton<IChannel, RtsChannel>();
|
|
serviceCollection.AddSingleton<IChannel, RsiChannel>();
|
|
serviceCollection.AddSingleton<IChannel, RtrChannel>();
|
|
serviceCollection.AddSingleton<IChannel, SwiChannel>();
|
|
}
|
|
}
|