2016-10-29 11:46:56 -07:00
|
|
|
|
using MediaBrowser.Controller.Channels;
|
2015-07-28 20:42:03 -07:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Model.Logging;
|
2014-03-18 10:05:57 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
2017-06-23 09:04:45 -07:00
|
|
|
|
using MediaBrowser.Common.Progress;
|
2016-10-23 12:14:57 -07:00
|
|
|
|
using MediaBrowser.Model.Tasks;
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
2016-11-02 13:53:50 -07:00
|
|
|
|
namespace Emby.Server.Implementations.Channels
|
2014-03-18 10:05:57 -07:00
|
|
|
|
{
|
2016-10-23 12:14:57 -07:00
|
|
|
|
class RefreshChannelsScheduledTask : IScheduledTask
|
2014-03-18 10:05:57 -07:00
|
|
|
|
{
|
2015-07-28 20:42:03 -07:00
|
|
|
|
private readonly IChannelManager _channelManager;
|
|
|
|
|
private readonly IUserManager _userManager;
|
|
|
|
|
private readonly ILogger _logger;
|
2015-08-22 10:50:37 -07:00
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
2015-08-22 10:50:37 -07:00
|
|
|
|
public RefreshChannelsScheduledTask(IChannelManager channelManager, IUserManager userManager, ILogger logger, ILibraryManager libraryManager)
|
2014-03-18 10:05:57 -07:00
|
|
|
|
{
|
2015-07-28 20:42:03 -07:00
|
|
|
|
_channelManager = channelManager;
|
|
|
|
|
_userManager = userManager;
|
|
|
|
|
_logger = logger;
|
2015-08-22 10:50:37 -07:00
|
|
|
|
_libraryManager = libraryManager;
|
2014-03-18 10:05:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Refresh Channels"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Description
|
|
|
|
|
{
|
|
|
|
|
get { return "Refreshes internet channel information."; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Category
|
|
|
|
|
{
|
2016-09-27 22:11:41 -07:00
|
|
|
|
get { return "Internet Channels"; }
|
2014-03-18 10:05:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-28 20:42:03 -07:00
|
|
|
|
public async Task Execute(System.Threading.CancellationToken cancellationToken, IProgress<double> progress)
|
2014-03-18 10:05:57 -07:00
|
|
|
|
{
|
2015-07-28 20:42:03 -07:00
|
|
|
|
var manager = (ChannelManager)_channelManager;
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
2017-06-23 09:04:45 -07:00
|
|
|
|
await manager.RefreshChannels(new SimpleProgress<double>(), cancellationToken).ConfigureAwait(false);
|
2015-07-28 20:42:03 -07:00
|
|
|
|
|
2015-08-22 10:50:37 -07:00
|
|
|
|
await new ChannelPostScanTask(_channelManager, _userManager, _logger, _libraryManager).Run(progress, cancellationToken)
|
2015-07-28 20:42:03 -07:00
|
|
|
|
.ConfigureAwait(false);
|
2014-03-18 10:05:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-23 12:14:57 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates the triggers that define when the task will run
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
2014-03-18 10:05:57 -07:00
|
|
|
|
{
|
2016-10-23 12:14:57 -07:00
|
|
|
|
return new[] {
|
|
|
|
|
|
|
|
|
|
// Every so often
|
|
|
|
|
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
|
2014-03-18 10:05:57 -07:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-23 12:14:57 -07:00
|
|
|
|
public string Key
|
|
|
|
|
{
|
|
|
|
|
get { return "RefreshInternetChannels"; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-18 10:05:57 -07:00
|
|
|
|
public bool IsHidden
|
|
|
|
|
{
|
2015-07-28 20:42:03 -07:00
|
|
|
|
get { return false; }
|
2014-03-18 10:05:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsEnabled
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|