2015-07-23 17:58:20 +00:00
|
|
|
|
using MediaBrowser.Common.Configuration;
|
2013-11-24 20:51:45 +00:00
|
|
|
|
using MediaBrowser.Controller.LiveTv;
|
2015-07-23 17:58:20 +00:00
|
|
|
|
using MediaBrowser.Model.LiveTv;
|
2013-11-24 20:51:45 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2015-07-27 16:21:18 +00:00
|
|
|
|
using System.Linq;
|
2013-11-24 20:51:45 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2016-10-23 19:14:57 +00:00
|
|
|
|
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
|
|
|
|
{
|
2016-10-23 19:14:57 +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
|
|
|
|
|
{
|
2013-11-25 00:46:25 +00:00
|
|
|
|
get { return "Refresh Guide"; }
|
2013-11-24 20:51:45 +00: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)
|
|
|
|
|
{
|
2013-11-29 16:58:24 +00:00
|
|
|
|
var manager = (LiveTvManager)_liveTvManager;
|
2013-11-24 20:51:45 +00:00
|
|
|
|
|
|
|
|
|
return manager.RefreshChannels(progress, cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-23 19:14:57 +00:00
|
|
|
|
/// <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
|
|
|
|
{
|
2016-10-23 19:14:57 +00:00
|
|
|
|
return new[] {
|
|
|
|
|
|
|
|
|
|
// Every so often
|
|
|
|
|
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(12).Ticks}
|
2013-11-24 20:51:45 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
2013-11-29 16:58:24 +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
|
|
|
|
|
2013-11-29 16:58:24 +00:00
|
|
|
|
public bool IsHidden
|
|
|
|
|
{
|
2017-03-13 04:56:41 +00:00
|
|
|
|
get { return _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Count == 0; }
|
2013-11-29 16:58:24 +00:00
|
|
|
|
}
|
2014-01-19 06:36:21 +00:00
|
|
|
|
|
|
|
|
|
public bool IsEnabled
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
2014-12-13 21:26:04 +00:00
|
|
|
|
|
2016-10-23 19:14:57 +00:00
|
|
|
|
public bool IsLogged
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-13 21:26:04 +00:00
|
|
|
|
public string Key
|
|
|
|
|
{
|
|
|
|
|
get { return "RefreshGuide"; }
|
|
|
|
|
}
|
2013-11-24 20:51:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|