| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using System.Threading; |
| | | 4 | | using System.Threading.Tasks; |
| | | 5 | | using Jellyfin.LiveTv.Configuration; |
| | | 6 | | using MediaBrowser.Common.Configuration; |
| | | 7 | | using MediaBrowser.Controller.LiveTv; |
| | | 8 | | using MediaBrowser.Model.Tasks; |
| | | 9 | | |
| | | 10 | | namespace Jellyfin.LiveTv.Guide; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// The "Refresh Guide" scheduled task. |
| | | 14 | | /// </summary> |
| | | 15 | | public class RefreshGuideScheduledTask : IScheduledTask, IConfigurableScheduledTask |
| | | 16 | | { |
| | | 17 | | private readonly ILiveTvManager _liveTvManager; |
| | | 18 | | private readonly IGuideManager _guideManager; |
| | | 19 | | private readonly IConfigurationManager _config; |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Initializes a new instance of the <see cref="RefreshGuideScheduledTask"/> class. |
| | | 23 | | /// </summary> |
| | | 24 | | /// <param name="liveTvManager">The live tv manager.</param> |
| | | 25 | | /// <param name="guideManager">The guide manager.</param> |
| | | 26 | | /// <param name="config">The configuration manager.</param> |
| | | 27 | | public RefreshGuideScheduledTask( |
| | | 28 | | ILiveTvManager liveTvManager, |
| | | 29 | | IGuideManager guideManager, |
| | | 30 | | IConfigurationManager config) |
| | | 31 | | { |
| | 21 | 32 | | _liveTvManager = liveTvManager; |
| | 21 | 33 | | _guideManager = guideManager; |
| | 21 | 34 | | _config = config; |
| | 21 | 35 | | } |
| | | 36 | | |
| | | 37 | | /// <inheritdoc /> |
| | 30 | 38 | | public string Name => "Refresh Guide"; |
| | | 39 | | |
| | | 40 | | /// <inheritdoc /> |
| | 0 | 41 | | public string Description => "Downloads channel information from live tv services."; |
| | | 42 | | |
| | | 43 | | /// <inheritdoc /> |
| | 0 | 44 | | public string Category => "Live TV"; |
| | | 45 | | |
| | | 46 | | /// <inheritdoc /> |
| | 0 | 47 | | public bool IsHidden => _liveTvManager.Services.Count == 1 && _config.GetLiveTvConfiguration().TunerHosts.Length == |
| | | 48 | | |
| | | 49 | | /// <inheritdoc /> |
| | 0 | 50 | | public bool IsEnabled => true; |
| | | 51 | | |
| | | 52 | | /// <inheritdoc /> |
| | 0 | 53 | | public bool IsLogged => true; |
| | | 54 | | |
| | | 55 | | /// <inheritdoc /> |
| | 2 | 56 | | public string Key => "RefreshGuide"; |
| | | 57 | | |
| | | 58 | | /// <inheritdoc /> |
| | | 59 | | public Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken) |
| | 1 | 60 | | => _guideManager.RefreshGuide(progress, cancellationToken); |
| | | 61 | | |
| | | 62 | | /// <inheritdoc /> |
| | | 63 | | public IEnumerable<TaskTriggerInfo> GetDefaultTriggers() |
| | | 64 | | { |
| | 21 | 65 | | return new[] |
| | 21 | 66 | | { |
| | 21 | 67 | | new TaskTriggerInfo |
| | 21 | 68 | | { |
| | 21 | 69 | | Type = TaskTriggerInfoType.IntervalTrigger, |
| | 21 | 70 | | IntervalTicks = TimeSpan.FromHours(24).Ticks |
| | 21 | 71 | | } |
| | 21 | 72 | | }; |
| | | 73 | | } |
| | | 74 | | } |