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