2014-01-19 09:33:36 -07:00
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
using MediaBrowser.Common.ScheduledTasks;
|
2014-01-18 23:36:21 -07:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2014-01-20 09:09:53 -07:00
|
|
|
|
using MediaBrowser.Controller.FileOrganization;
|
2014-01-18 23:36:21 -07:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2014-02-19 21:53:15 -07:00
|
|
|
|
using MediaBrowser.Controller.Providers;
|
2014-07-30 19:09:23 -07:00
|
|
|
|
using MediaBrowser.Model.FileOrganization;
|
2014-01-18 23:36:21 -07:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2014-01-20 09:09:53 -07:00
|
|
|
|
namespace MediaBrowser.Server.Implementations.FileOrganization
|
2014-01-18 23:36:21 -07:00
|
|
|
|
{
|
2014-08-10 15:13:17 -07:00
|
|
|
|
public class OrganizerScheduledTask : IScheduledTask, IConfigurableScheduledTask, IScheduledTaskActivityLog
|
2014-01-18 23:36:21 -07:00
|
|
|
|
{
|
2014-01-28 14:25:10 -07:00
|
|
|
|
private readonly ILibraryMonitor _libraryMonitor;
|
2014-01-18 23:36:21 -07:00
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
2014-01-22 10:05:06 -07:00
|
|
|
|
private readonly ILogger _logger;
|
2014-01-19 09:33:36 -07:00
|
|
|
|
private readonly IFileSystem _fileSystem;
|
2014-01-22 10:05:06 -07:00
|
|
|
|
private readonly IServerConfigurationManager _config;
|
|
|
|
|
private readonly IFileOrganizationService _organizationService;
|
2014-02-19 21:53:15 -07:00
|
|
|
|
private readonly IProviderManager _providerManager;
|
2014-01-18 23:36:21 -07:00
|
|
|
|
|
2014-02-19 21:53:15 -07:00
|
|
|
|
public OrganizerScheduledTask(ILibraryMonitor libraryMonitor, ILibraryManager libraryManager, ILogger logger, IFileSystem fileSystem, IServerConfigurationManager config, IFileOrganizationService organizationService, IProviderManager providerManager)
|
2014-01-18 23:36:21 -07:00
|
|
|
|
{
|
2014-01-28 14:25:10 -07:00
|
|
|
|
_libraryMonitor = libraryMonitor;
|
2014-01-18 23:36:21 -07:00
|
|
|
|
_libraryManager = libraryManager;
|
2014-01-22 10:05:06 -07:00
|
|
|
|
_logger = logger;
|
2014-01-19 09:33:36 -07:00
|
|
|
|
_fileSystem = fileSystem;
|
2014-01-22 10:05:06 -07:00
|
|
|
|
_config = config;
|
|
|
|
|
_organizationService = organizationService;
|
2014-02-19 21:53:15 -07:00
|
|
|
|
_providerManager = providerManager;
|
2014-01-18 23:36:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
2014-01-20 09:09:53 -07:00
|
|
|
|
get { return "Organize new media files"; }
|
2014-01-18 23:36:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Description
|
|
|
|
|
{
|
2014-01-20 09:09:53 -07:00
|
|
|
|
get { return "Processes new files available in the configured watch folder."; }
|
2014-01-18 23:36:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Category
|
|
|
|
|
{
|
|
|
|
|
get { return "Library"; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-30 19:09:23 -07:00
|
|
|
|
private TvFileOrganizationOptions GetTvOptions()
|
|
|
|
|
{
|
|
|
|
|
return _config.GetAutoOrganizeOptions().TvOptions;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-18 23:36:21 -07:00
|
|
|
|
public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
|
|
|
|
|
{
|
2014-02-19 21:53:15 -07:00
|
|
|
|
return new TvFolderOrganizer(_libraryManager, _logger, _fileSystem, _libraryMonitor, _organizationService, _config, _providerManager)
|
2014-07-30 19:09:23 -07:00
|
|
|
|
.Organize(GetTvOptions(), cancellationToken, progress);
|
2014-01-18 23:36:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
|
|
|
|
|
{
|
|
|
|
|
return new ITaskTrigger[]
|
|
|
|
|
{
|
|
|
|
|
new IntervalTrigger{ Interval = TimeSpan.FromMinutes(5)}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsHidden
|
|
|
|
|
{
|
2014-07-30 19:09:23 -07:00
|
|
|
|
get { return !GetTvOptions().IsEnabled; }
|
2014-01-18 23:36:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsEnabled
|
|
|
|
|
{
|
2014-08-02 19:16:37 -07:00
|
|
|
|
get { return GetTvOptions().IsEnabled; }
|
2014-01-18 23:36:21 -07:00
|
|
|
|
}
|
2014-08-10 15:13:17 -07:00
|
|
|
|
|
|
|
|
|
public bool IsActivityLogged
|
|
|
|
|
{
|
|
|
|
|
get { return false; }
|
|
|
|
|
}
|
2014-01-18 23:36:21 -07:00
|
|
|
|
}
|
|
|
|
|
}
|