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