2014-03-18 17:05:57 +00:00
|
|
|
|
using MediaBrowser.Common.ScheduledTasks;
|
|
|
|
|
using MediaBrowser.Controller.Channels;
|
2015-07-29 03:42:03 +00:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Model.Logging;
|
2014-03-18 17:05:57 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Implementations.Channels
|
|
|
|
|
{
|
|
|
|
|
class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask
|
|
|
|
|
{
|
2015-07-29 03:42:03 +00:00
|
|
|
|
private readonly IChannelManager _channelManager;
|
|
|
|
|
private readonly IUserManager _userManager;
|
|
|
|
|
private readonly ILogger _logger;
|
2014-03-18 17:05:57 +00:00
|
|
|
|
|
2015-07-29 03:42:03 +00:00
|
|
|
|
public RefreshChannelsScheduledTask(IChannelManager channelManager, IUserManager userManager, ILogger logger)
|
2014-03-18 17:05:57 +00:00
|
|
|
|
{
|
2015-07-29 03:42:03 +00:00
|
|
|
|
_channelManager = channelManager;
|
|
|
|
|
_userManager = userManager;
|
|
|
|
|
_logger = logger;
|
2014-03-18 17:05:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Refresh Channels"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Description
|
|
|
|
|
{
|
|
|
|
|
get { return "Refreshes internet channel information."; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Category
|
|
|
|
|
{
|
|
|
|
|
get { return "Channels"; }
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-29 03:42:03 +00:00
|
|
|
|
public async Task Execute(System.Threading.CancellationToken cancellationToken, IProgress<double> progress)
|
2014-03-18 17:05:57 +00:00
|
|
|
|
{
|
2015-07-29 03:42:03 +00:00
|
|
|
|
var manager = (ChannelManager)_channelManager;
|
2014-03-18 17:05:57 +00:00
|
|
|
|
|
2015-07-29 03:42:03 +00:00
|
|
|
|
await manager.RefreshChannels(new Progress<double>(), cancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
await new ChannelPostScanTask(_channelManager, _userManager, _logger).Run(progress, cancellationToken)
|
|
|
|
|
.ConfigureAwait(false);
|
2014-03-18 17:05:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
|
|
|
|
|
{
|
|
|
|
|
return new ITaskTrigger[]
|
|
|
|
|
{
|
|
|
|
|
new IntervalTrigger{ Interval = TimeSpan.FromHours(24)}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsHidden
|
|
|
|
|
{
|
2015-07-29 03:42:03 +00:00
|
|
|
|
get { return false; }
|
2014-03-18 17:05:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsEnabled
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|