jellyfin/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs

62 lines
1.9 KiB
C#
Raw Normal View History

using System;
2013-11-24 20:51:45 +00:00
using System.Collections.Generic;
using System.Threading.Tasks;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Tasks;
2013-11-24 20:51:45 +00:00
2016-11-03 23:35:19 +00:00
namespace Emby.Server.Implementations.LiveTv
2013-11-24 20:51:45 +00:00
{
public class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask
2013-11-24 20:51:45 +00:00
{
private readonly ILiveTvManager _liveTvManager;
2015-07-23 17:58:20 +00:00
private readonly IConfigurationManager _config;
2013-11-24 20:51:45 +00:00
2015-07-23 17:58:20 +00:00
public RefreshChannelsScheduledTask(ILiveTvManager liveTvManager, IConfigurationManager config)
2013-11-24 20:51:45 +00:00
{
_liveTvManager = liveTvManager;
2015-07-23 17:58:20 +00:00
_config = config;
2013-11-24 20:51:45 +00:00
}
public string Name => "Refresh Guide";
2013-11-24 20:51:45 +00:00
public string Description => "Downloads channel information from live tv services.";
2013-11-24 20:51:45 +00:00
public string Category => "Live TV";
2013-11-24 20:51:45 +00:00
public Task Execute(System.Threading.CancellationToken cancellationToken, IProgress<double> progress)
{
var manager = (LiveTvManager)_liveTvManager;
2013-11-24 20:51:45 +00:00
return manager.RefreshChannels(progress, cancellationToken);
}
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
2013-11-24 20:51:45 +00:00
{
2019-01-07 23:27:46 +00:00
return new[] {
// Every so often
2017-09-10 03:18:23 +00:00
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
2013-11-24 20:51:45 +00:00
};
}
2015-07-23 17:58:20 +00:00
private LiveTvOptions GetConfiguration()
{
return _config.GetConfiguration<LiveTvOptions>("livetv");
}
2015-07-28 12:33:30 +00:00
public bool IsHidden => _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Length == 0;
public bool IsEnabled => true;
2014-12-13 21:26:04 +00:00
public bool IsLogged => true;
public string Key => "RefreshGuide";
2013-11-24 20:51:45 +00:00
}
}