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

74 lines
2.0 KiB
C#
Raw Normal View History

2015-07-23 10:58:20 -07:00
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.ScheduledTasks;
2013-11-24 13:51:45 -07:00
using MediaBrowser.Controller.LiveTv;
2015-07-23 10:58:20 -07:00
using MediaBrowser.Model.LiveTv;
2013-11-24 13:51:45 -07:00
using System;
using System.Collections.Generic;
2015-07-27 09:21:18 -07:00
using System.Linq;
2013-11-24 13:51:45 -07:00
using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.LiveTv
{
2015-10-16 11:11:11 -07:00
public class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask, IHasKey
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
}
public string Name
{
2013-11-24 17:46:25 -07:00
get { return "Refresh Guide"; }
2013-11-24 13:51:45 -07:00
}
public string Description
{
get { return "Downloads channel information from live tv services."; }
}
public string Category
{
get { return "Live TV"; }
}
public Task Execute(System.Threading.CancellationToken cancellationToken, IProgress<double> progress)
{
var manager = (LiveTvManager)_liveTvManager;
2013-11-24 13:51:45 -07:00
return manager.RefreshChannels(progress, cancellationToken);
}
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
{
return new ITaskTrigger[]
{
2015-07-28 05:33:30 -07:00
new IntervalTrigger{ Interval = TimeSpan.FromHours(12)}
2013-11-24 13:51:45 -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
public bool IsHidden
{
2015-07-27 09:21:18 -07:00
get { return _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Count(i => i.IsEnabled) == 0; }
}
public bool IsEnabled
{
get { return true; }
}
2014-12-13 14:26:04 -07:00
public string Key
{
get { return "RefreshGuide"; }
}
2013-11-24 13:51:45 -07:00
}
}