2014-12-13 04:56:30 +01:00
|
|
|
|
using MediaBrowser.Common.ScheduledTasks;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
2015-01-02 06:36:27 +01:00
|
|
|
|
using MediaBrowser.Controller.MediaEncoding;
|
2014-12-13 04:56:30 +01:00
|
|
|
|
using MediaBrowser.Controller.Sync;
|
2014-12-30 17:36:49 +01:00
|
|
|
|
using MediaBrowser.Controller.TV;
|
2014-12-13 04:56:30 +01:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Implementations.Sync
|
|
|
|
|
{
|
2014-12-16 06:46:54 +01:00
|
|
|
|
public class SyncScheduledTask : IScheduledTask, IConfigurableScheduledTask
|
2014-12-13 04:56:30 +01:00
|
|
|
|
{
|
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
|
private readonly ISyncRepository _syncRepo;
|
|
|
|
|
private readonly ISyncManager _syncManager;
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
private readonly IUserManager _userManager;
|
2014-12-30 17:36:49 +01:00
|
|
|
|
private readonly ITVSeriesManager _tvSeriesManager;
|
2015-01-04 15:18:28 +01:00
|
|
|
|
private readonly IMediaEncoder _mediaEncoder;
|
2015-01-16 21:54:37 +01:00
|
|
|
|
private readonly ISubtitleEncoder _subtitleEncoder;
|
2014-12-13 04:56:30 +01:00
|
|
|
|
|
2015-01-16 21:54:37 +01:00
|
|
|
|
public SyncScheduledTask(ILibraryManager libraryManager, ISyncRepository syncRepo, ISyncManager syncManager, ILogger logger, IUserManager userManager, ITVSeriesManager tvSeriesManager, IMediaEncoder mediaEncoder, ISubtitleEncoder subtitleEncoder)
|
2014-12-13 04:56:30 +01:00
|
|
|
|
{
|
|
|
|
|
_libraryManager = libraryManager;
|
|
|
|
|
_syncRepo = syncRepo;
|
|
|
|
|
_syncManager = syncManager;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_userManager = userManager;
|
2014-12-30 17:36:49 +01:00
|
|
|
|
_tvSeriesManager = tvSeriesManager;
|
2015-01-04 15:18:28 +01:00
|
|
|
|
_mediaEncoder = mediaEncoder;
|
2015-01-16 21:54:37 +01:00
|
|
|
|
_subtitleEncoder = subtitleEncoder;
|
2014-12-13 04:56:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
2014-12-28 18:59:40 +01:00
|
|
|
|
get { return "Sync preparation"; }
|
2014-12-13 04:56:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Description
|
|
|
|
|
{
|
|
|
|
|
get { return "Runs scheduled sync jobs"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Category
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return "Library";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
|
|
|
|
|
{
|
2015-01-16 21:54:37 +01:00
|
|
|
|
return new SyncJobProcessor(_libraryManager, _syncRepo, _syncManager, _logger, _userManager, _tvSeriesManager, _mediaEncoder, _subtitleEncoder).Sync(progress,
|
2014-12-13 04:56:30 +01:00
|
|
|
|
cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
|
|
|
|
|
{
|
|
|
|
|
return new ITaskTrigger[]
|
|
|
|
|
{
|
|
|
|
|
new IntervalTrigger { Interval = TimeSpan.FromHours(3) },
|
|
|
|
|
new StartupTrigger{ DelayMs = Convert.ToInt32(TimeSpan.FromMinutes(5).TotalMilliseconds)}
|
|
|
|
|
};
|
|
|
|
|
}
|
2014-12-16 06:46:54 +01:00
|
|
|
|
|
|
|
|
|
public bool IsHidden
|
|
|
|
|
{
|
2015-01-13 04:46:44 +01:00
|
|
|
|
get { return false; }
|
2014-12-16 06:46:54 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsEnabled
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
2014-12-13 04:56:30 +01:00
|
|
|
|
}
|
|
|
|
|
}
|