jellyfin/MediaBrowser.Server.Implementations/Sync/SyncConvertScheduledTask.cs

94 lines
3.1 KiB
C#
Raw Normal View History

2015-01-16 21:29:53 -07:00
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.ScheduledTasks;
2014-12-12 20:56:30 -07:00
using MediaBrowser.Controller.Library;
2015-01-01 22:36:27 -07:00
using MediaBrowser.Controller.MediaEncoding;
2014-12-12 20:56:30 -07:00
using MediaBrowser.Controller.Sync;
2014-12-30 09:36:49 -07:00
using MediaBrowser.Controller.TV;
2014-12-12 20:56:30 -07:00
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
2015-10-03 21:23:11 -07:00
using CommonIO;
2014-12-12 20:56:30 -07:00
namespace MediaBrowser.Server.Implementations.Sync
{
2015-03-07 10:19:44 -07:00
public class SyncConvertScheduledTask : IScheduledTask, IConfigurableScheduledTask, IHasKey
2014-12-12 20:56:30 -07:00
{
private readonly ILibraryManager _libraryManager;
private readonly ISyncRepository _syncRepo;
private readonly ISyncManager _syncManager;
private readonly ILogger _logger;
private readonly IUserManager _userManager;
2014-12-30 09:36:49 -07:00
private readonly ITVSeriesManager _tvSeriesManager;
2015-01-04 07:18:28 -07:00
private readonly IMediaEncoder _mediaEncoder;
2015-01-16 13:54:37 -07:00
private readonly ISubtitleEncoder _subtitleEncoder;
2015-01-16 21:29:53 -07:00
private readonly IConfigurationManager _config;
private readonly IFileSystem _fileSystem;
2015-03-07 15:43:53 -07:00
private readonly IMediaSourceManager _mediaSourceManager;
2014-12-12 20:56:30 -07:00
2015-03-07 15:43:53 -07:00
public SyncConvertScheduledTask(ILibraryManager libraryManager, ISyncRepository syncRepo, ISyncManager syncManager, ILogger logger, IUserManager userManager, ITVSeriesManager tvSeriesManager, IMediaEncoder mediaEncoder, ISubtitleEncoder subtitleEncoder, IConfigurationManager config, IFileSystem fileSystem, IMediaSourceManager mediaSourceManager)
2014-12-12 20:56:30 -07:00
{
_libraryManager = libraryManager;
_syncRepo = syncRepo;
_syncManager = syncManager;
_logger = logger;
_userManager = userManager;
2014-12-30 09:36:49 -07:00
_tvSeriesManager = tvSeriesManager;
2015-01-04 07:18:28 -07:00
_mediaEncoder = mediaEncoder;
2015-01-16 13:54:37 -07:00
_subtitleEncoder = subtitleEncoder;
2015-01-16 21:29:53 -07:00
_config = config;
_fileSystem = fileSystem;
2015-03-07 15:43:53 -07:00
_mediaSourceManager = mediaSourceManager;
2014-12-12 20:56:30 -07:00
}
public string Name
{
2015-01-20 13:19:54 -07:00
get { return "Convert media"; }
2014-12-12 20:56:30 -07:00
}
public string Description
{
get { return "Runs scheduled sync jobs"; }
}
public string Category
{
get
{
2015-01-20 13:19:54 -07:00
return "Sync";
2014-12-12 20:56:30 -07:00
}
}
public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
{
2015-03-07 15:43:53 -07:00
return new SyncJobProcessor(_libraryManager, _syncRepo, (SyncManager)_syncManager, _logger, _userManager, _tvSeriesManager, _mediaEncoder, _subtitleEncoder, _config, _fileSystem, _mediaSourceManager)
2015-01-19 13:53:02 -07:00
.Sync(progress, cancellationToken);
2014-12-12 20:56:30 -07:00
}
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
{
return new ITaskTrigger[]
{
2015-07-28 05:33:30 -07:00
new IntervalTrigger { Interval = TimeSpan.FromHours(3) }
2014-12-12 20:56:30 -07:00
};
}
2014-12-15 22:46:54 -07:00
public bool IsHidden
{
get { return false; }
2014-12-15 22:46:54 -07:00
}
public bool IsEnabled
{
get { return true; }
}
2015-01-20 13:19:54 -07:00
public string Key
{
get { return "SyncPrepare"; }
}
2014-12-12 20:56:30 -07:00
}
}