aboutsummaryrefslogtreecommitdiff
path: root/src/Jellyfin.LiveTv/RefreshGuideScheduledTask.cs
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2023-12-28 15:15:03 -0500
committerPatrick Barron <barronpm@gmail.com>2024-01-09 10:16:56 -0500
commitc1a3084312fa4fb7796b83640bfe9ad2b5044afa (patch)
treeb7e81594c3782128d37f875a0ce54d0bad12c6e5 /src/Jellyfin.LiveTv/RefreshGuideScheduledTask.cs
parent7eba162879f6d1ff04539cac5c0d6372a955d82b (diff)
Move LiveTv to separate project
Diffstat (limited to 'src/Jellyfin.LiveTv/RefreshGuideScheduledTask.cs')
-rw-r--r--src/Jellyfin.LiveTv/RefreshGuideScheduledTask.cs75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/Jellyfin.LiveTv/RefreshGuideScheduledTask.cs b/src/Jellyfin.LiveTv/RefreshGuideScheduledTask.cs
new file mode 100644
index 000000000..e58296a70
--- /dev/null
+++ b/src/Jellyfin.LiveTv/RefreshGuideScheduledTask.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Model.LiveTv;
+using MediaBrowser.Model.Tasks;
+
+namespace Jellyfin.LiveTv
+{
+ /// <summary>
+ /// The "Refresh Guide" scheduled task.
+ /// </summary>
+ public class RefreshGuideScheduledTask : IScheduledTask, IConfigurableScheduledTask
+ {
+ private readonly ILiveTvManager _liveTvManager;
+ private readonly IConfigurationManager _config;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="RefreshGuideScheduledTask"/> class.
+ /// </summary>
+ /// <param name="liveTvManager">The live tv manager.</param>
+ /// <param name="config">The configuration manager.</param>
+ public RefreshGuideScheduledTask(ILiveTvManager liveTvManager, IConfigurationManager config)
+ {
+ _liveTvManager = liveTvManager;
+ _config = config;
+ }
+
+ /// <inheritdoc />
+ public string Name => "Refresh Guide";
+
+ /// <inheritdoc />
+ public string Description => "Downloads channel information from live tv services.";
+
+ /// <inheritdoc />
+ public string Category => "Live TV";
+
+ /// <inheritdoc />
+ public bool IsHidden => _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Length == 0;
+
+ /// <inheritdoc />
+ public bool IsEnabled => true;
+
+ /// <inheritdoc />
+ public bool IsLogged => true;
+
+ /// <inheritdoc />
+ public string Key => "RefreshGuide";
+
+ /// <inheritdoc />
+ public Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken)
+ {
+ var manager = (LiveTvManager)_liveTvManager;
+
+ return manager.RefreshChannels(progress, cancellationToken);
+ }
+
+ /// <inheritdoc />
+ public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
+ {
+ return new[]
+ {
+ // Every so often
+ new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
+ };
+ }
+
+ private LiveTvOptions GetConfiguration()
+ {
+ return _config.GetConfiguration<LiveTvOptions>("livetv");
+ }
+ }
+}