| | 1 | | using System.Threading; |
| | 2 | | using System.Threading.Tasks; |
| | 3 | | using Jellyfin.LiveTv.Timers; |
| | 4 | | using MediaBrowser.Controller.LiveTv; |
| | 5 | | using Microsoft.Extensions.Hosting; |
| | 6 | |
|
| | 7 | | namespace Jellyfin.LiveTv.Recordings; |
| | 8 | |
|
| | 9 | | /// <summary> |
| | 10 | | /// <see cref="IHostedService"/> responsible for Live TV recordings. |
| | 11 | | /// </summary> |
| | 12 | | public sealed class RecordingsHost : IHostedService |
| | 13 | | { |
| | 14 | | private readonly IRecordingsManager _recordingsManager; |
| | 15 | | private readonly TimerManager _timerManager; |
| | 16 | |
|
| | 17 | | /// <summary> |
| | 18 | | /// Initializes a new instance of the <see cref="RecordingsHost"/> class. |
| | 19 | | /// </summary> |
| | 20 | | /// <param name="recordingsManager">The <see cref="IRecordingsManager"/>.</param> |
| | 21 | | /// <param name="timerManager">The <see cref="TimerManager"/>.</param> |
| | 22 | | public RecordingsHost(IRecordingsManager recordingsManager, TimerManager timerManager) |
| | 23 | | { |
| 21 | 24 | | _recordingsManager = recordingsManager; |
| 21 | 25 | | _timerManager = timerManager; |
| 21 | 26 | | } |
| | 27 | |
|
| | 28 | | /// <inheritdoc /> |
| | 29 | | public Task StartAsync(CancellationToken cancellationToken) |
| | 30 | | { |
| 21 | 31 | | _timerManager.RestartTimers(); |
| 21 | 32 | | return _recordingsManager.CreateRecordingFolders(); |
| | 33 | | } |
| | 34 | |
|
| | 35 | | /// <inheritdoc /> |
| 21 | 36 | | public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; |
| | 37 | | } |